forked from rxwei/x86-assembly-textmate-bundle
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ opmask suffixes + rounding suffixes plus some fixes to labels and what not
- Loading branch information
1 parent
846016f
commit d8463a0
Showing
8 changed files
with
297 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
segment code | ||
..start: | ||
mov ax,data | ||
mov ds,ax | ||
mov ax,stack | ||
mov ss,ax | ||
mov sp,stacktop | ||
|
||
mov dx,hello | ||
mov ah,9 | ||
int 0x21 | ||
|
||
mov ax,0x4c00 | ||
int 0x21 | ||
|
||
segment data | ||
hello: db 'hello, world', 13, 10, '$' | ||
|
||
segment stack stack | ||
resb 64 | ||
stacktop: | ||
|
||
|
||
|
||
org 100h | ||
section .text | ||
start: | ||
; put your code here | ||
section .data | ||
; put data items here | ||
section .bss | ||
; put uninitialized data here | ||
|
||
|
||
%macro cglobal 1 | ||
global _%1 | ||
%define %1 _%1 | ||
%endmacro | ||
|
||
%macro cextern 1 | ||
extern _%1 | ||
%define %1 _%1 | ||
%endmacro | ||
|
||
cextern printf | ||
|
||
extern _printf | ||
%define printf _printf | ||
|
||
|
||
|
||
global _myfunc | ||
_myfunc: | ||
push bp | ||
mov bp,sp | ||
sub sp,0x40 ; 64 bytes of local stack space | ||
mov bx,[bp+4] ; first parameter to function | ||
; some more code | ||
mov sp,bp ; undo "sub sp,0x40" above | ||
pop bp | ||
ret | ||
|
||
extern _printf | ||
; and then, further down... | ||
push word [myint] ; one of my integer variables | ||
push word mystring ; pointer into my data segment | ||
call _printf | ||
add sp,byte 4 ; `byte' saves space | ||
; then those data items... | ||
segment _DATA | ||
myint dw 1234 | ||
mystring db 'This number -> %d <- should be 1234',10,0 | ||
|
||
push word [myint] | ||
push word seg mystring ; Now push the segment, and... | ||
push word mystring ; ... offset of "mystring" | ||
call far _printf | ||
add sp,byte 6 | ||
|
||
|
||
extern _i | ||
mov ax,[_i] | ||
|
||
global _j | ||
_j dw 0 | ||
|
||
|
||
proc _nearproc | ||
%$i arg | ||
%$j arg | ||
mov ax,[bp + %$i] | ||
mov bx,[bp + %$j] | ||
add ax,[bx] | ||
endproc | ||
|
||
%define FARCODE | ||
proc _farproc | ||
%$i arg | ||
%$j arg 4 | ||
mov ax,[bp + %$i] | ||
mov bx,[bp + %$j] | ||
mov es,[bp + %$j + 2] | ||
add ax,[bx] | ||
endproc | ||
|
||
|
||
|
||
global myfunc | ||
myfunc: push bp | ||
mov bp,sp | ||
sub sp,0x40 ; 64 bytes of local stack space | ||
mov bx,[bp+8] ; first parameter to function | ||
mov bx,[bp+6] ; second parameter to function | ||
; some more code | ||
mov sp,bp ; undo "sub sp,0x40" above | ||
pop bp | ||
retf 4 ; total size of params is 4 | ||
|
||
extern SomeFunc | ||
; and then, further down... | ||
push word seg mystring ; Now push the segment, and... | ||
push word mystring ; ... offset of "mystring" | ||
push word [myint] ; one of my variables | ||
call far SomeFunc | ||
|
||
|
||
%define PASCAL | ||
proc _pascalproc | ||
%$j arg 4 | ||
%$i arg | ||
mov ax,[bp + %$i] | ||
mov bx,[bp + %$j] | ||
mov es,[bp + %$j + 2] | ||
add ax,[bx] | ||
endproc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
global _myfunc | ||
_myfunc: | ||
push ebp | ||
mov ebp,esp | ||
sub esp,0x40 ; 64 bytes of local stack space | ||
mov ebx,[ebp+8] ; first parameter to function | ||
; some more code | ||
leave ; mov esp,ebp / pop ebp | ||
ret | ||
|
||
extern _printf | ||
; and then, further down... | ||
push dword [myint] ; one of my integer variables | ||
push dword mystring ; pointer into my data segment | ||
call _printf | ||
add esp,byte 8 ; `byte' saves space | ||
; then those data items... | ||
segment _DATA | ||
myint dd 1234 | ||
mystring db 'This number -> %d <- should be 1234',10,0 | ||
|
||
extern _i | ||
mov eax,[_i] | ||
|
||
global _j | ||
_j dd 0 | ||
|
||
proc _proc32 | ||
%$i arg | ||
%$j arg | ||
mov eax,[ebp + %$i] | ||
mov ebx,[ebp + %$j] | ||
add eax,[ebx] | ||
endproc | ||
|
||
extern _GLOBAL_OFFSET_TABLE_ ; in ELF | ||
extern __GLOBAL_OFFSET_TABLE_ ; in BSD a.out | ||
|
||
func: push ebp | ||
mov ebp,esp | ||
push ebx | ||
call .get_GOT | ||
.get_GOT: | ||
pop ebx | ||
add ebx,_GLOBAL_OFFSET_TABLE_+$$-.get_GOT wrt ..gotpc | ||
; the function body comes here | ||
mov ebx,[ebp-4] | ||
mov esp,ebp | ||
pop ebp | ||
ret | ||
|
||
%macro get_GOT 0 | ||
call %%getgot | ||
%%getgot: | ||
pop ebx | ||
add ebx,_GLOBAL_OFFSET_TABLE_+$$-%%getgot wrt ..gotpc | ||
%endmacro | ||
|
||
lea eax,[ebx+myvar wrt ..gotoff] | ||
|
||
mov eax,[ebx+extvar wrt ..got] | ||
|
||
global func:function ; declare it as a function | ||
func: push ebp | ||
; etc. | ||
|
||
global array:data array.end-array ; give the size too | ||
array: resd 128 | ||
.end: | ||
|
||
dataptr: dd global_data_item ; WRONG | ||
dataptr: dd global_data_item wrt ..sym | ||
|
||
funcptr: dd my_function | ||
funcptr: dd my_function wrt ..sym |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; SYNTAX TEST "Packages/User/x86_64 Assembly.tmbundle/Syntaxes/x86_64 Assembly.sublime-syntax" | ||
|
||
%pragma | ||
%pragma bluttan | ||
%pragma bluttan blej | ||
%pragma "Hej tomtegubbar" | ||
%define PR asm foobar | ||
%pragma PR | ||
%pragma preproc | ||
%pragma preproc tjo fidelittan preproc | ||
%pragma dbg tjo fidelittan output | ||
%pragma dbgdbg tjo fidelittan debug format | ||
%pragma Dbg Tjo Fidelittan Output | ||
%pragma Dbgdbg Tjo Fidelittan Debug Format | ||
|
||
; opmask | ||
VDIVPD zmm0{k1}{z}, zmm1, zmm3 ; conditional vector operation | ||
; broadcasting | ||
VDIVPS zmm4, zmm5, [rbx]{1to16} ; load single-precision float and | ||
; embedded rounding | ||
VCVTSI2SD xmm6, xmm7, {rz-sae}, rax ; round toward zero. note that it | ||
; is used as if a separate operand. | ||
; it comes after the last SIMD operand | ||
|
||
mov eax,[nosplit eax] ; eax as base register | ||
mov eax,[nosplit eax*1] ; eax as index register | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.