From: Peter Johnson Date: Sat, 17 Nov 2001 08:39:14 +0000 (-0000) Subject: Decided to go ahead and commit these little NASM-syntax test files I've been X-Git-Tag: v0.1.0~194 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd9ad840fe045e3c3cb299618a741e338099d348;p=yasm Decided to go ahead and commit these little NASM-syntax test files I've been using for testing various things during development. Many don't even actually assemble, as they're testing error conditions. These all need to be integrated into a test suite at some point to be truly useful. svn path=/trunk/yasm/; revision=336 --- diff --git a/tests/nasm/addrop.asm b/tests/nasm/addrop.asm new file mode 100644 index 00000000..23574cba --- /dev/null +++ b/tests/nasm/addrop.asm @@ -0,0 +1,35 @@ +[BITS 32] +db 0FFh +idiv al ; F6 F8 +db 0FEh +idiv ax ; 66 F7 F8 +db 0FDh +idiv eax ; F7 F8 +db 0FCh +idiv byte [word 0] ; 67 F6 3E 00 00 +db 0FBh +idiv byte [dword 0xFFFFFFFF] ; F6 3D FF FF FF FF +db 0FAh +idiv byte [0] ; F6 3D 00 00 00 00 +db 0F9h +a16 idiv byte [word 0] ; 67 67 F6 3E 00 00 +db 0F8h +a16 idiv byte [dword 0] ; 67 F6 3D 00 00 00 00 +db 0F7h +a16 idiv byte [0] ; 67 F6 3D 00 00 +db 0F6h +a32 idiv byte [0] ; F6 3D 00 00 00 00 +[BITS 16] +nop +idiv al +idiv ax +idiv eax +nop +idiv byte [word 0] +idiv byte [dword 0xFFFFFFFF] +idiv byte [0] +idiv dword [es:dword 5] +idiv dword [byte es:5] +idiv word [es:dword edi+5] +idiv word [es:edi+dword 5] +nop diff --git a/tests/nasm/bits.asm b/tests/nasm/bits.asm new file mode 100644 index 00000000..8da27c9d --- /dev/null +++ b/tests/nasm/bits.asm @@ -0,0 +1,14 @@ + bits 16 +[ bits 16 ] +[bits +[bits 16 + [eax] + [bits 16] + [bits 32] +[bits 64] +a equ 5 +[bits a] +b equ 16 +[bits b] +[bits 30+2] +[section .text] diff --git a/tests/nasm/data.asm b/tests/nasm/data.asm new file mode 100644 index 00000000..9e2f1d73 --- /dev/null +++ b/tests/nasm/data.asm @@ -0,0 +1,18 @@ +db 1,2, +;db 1,#ss,3 +;db 1.5 +;dw 1.5 +dd 1.5 +dq 1.5 +dt 1.5 +dd "hello" +dq "hello" +dt "hello" +dd 0x1 +dq 0x1 +dt 0x1 +dd hello +dq hello +dt hello + +hello: diff --git a/tests/nasm/enter.asm b/tests/nasm/enter.asm new file mode 100644 index 00000000..0aaf258d --- /dev/null +++ b/tests/nasm/enter.asm @@ -0,0 +1,4 @@ +tst equ 69000 + +enter tst, 5 + diff --git a/tests/nasm/equ.asm b/tests/nasm/equ.asm new file mode 100644 index 00000000..85271ab5 --- /dev/null +++ b/tests/nasm/equ.asm @@ -0,0 +1,5 @@ +mov ax,blah + +shl ax,4-blah + +blah equ 3 diff --git a/tests/nasm/error1.asm b/tests/nasm/error1.asm new file mode 100644 index 00000000..114579a6 --- /dev/null +++ b/tests/nasm/error1.asm @@ -0,0 +1,2 @@ +BITS 16 +mov ax, es:[di] diff --git a/tests/nasm/errors.asm b/tests/nasm/errors.asm new file mode 100644 index 00000000..34be1c84 --- /dev/null +++ b/tests/nasm/errors.asm @@ -0,0 +1,11 @@ +[BITS 16] +;mov ax,es:[di] +mov ax,[es:ds:0] +mov ax,[word dword es:0] +[BITS 32] +;mov ax,fs:[di] +mov ax,[fs:di] +;mov ax,[gs:edi+eax+ebx] +mov ,bx +mov ax, + [blah] diff --git a/tests/nasm/first.asm b/tests/nasm/first.asm new file mode 100644 index 00000000..cdfc83c9 --- /dev/null +++ b/tests/nasm/first.asm @@ -0,0 +1,2 @@ +aaa + diff --git a/tests/nasm/fp.asm b/tests/nasm/fp.asm new file mode 100644 index 00000000..9b9cc4e2 --- /dev/null +++ b/tests/nasm/fp.asm @@ -0,0 +1,65 @@ +[SECTION .data] +dt 3.141592653589793 +resb 6 +dq 3.141592653589793 +resb 8 +dd 3.141592653589793 +resb 12 +dt 1.e-4096 +resb 6 +dt 1.e-2048 +resb 6 +dt 1.e-1024 +resb 6 +dt 1.e-512 +resb 6 +dt 1.e-256 +resb 6 +dt 1.e-128 +resb 6 +dt 1.e-64 +resb 6 +dt 1.e-32 +resb 6 +dt 1.e-16 +resb 6 +dt 1.e-8 +resb 6 +dt 1.e-4 +resb 6 +dt 1.e-2 +resb 6 +dt 1.e-1 +resb 6 +dt 1.e-0 +resb 6 +dt 1.e+4096 +resb 6 +dt 1.e+2048 +resb 6 +dt 1.e+1024 +resb 6 +dt 1.e+512 +resb 6 +dt 1.e+256 +resb 6 +dt 1.e+128 +resb 6 +dt 1.e+64 +resb 6 +dt 1.e+32 +resb 6 +dt 1.e+16 +resb 6 +dt 1.e+8 +resb 6 +dt 1.e+4 +resb 6 +dt 1.e+2 +resb 6 +dt 1.e+1 +resb 6 +dt 1.e+0 +resb 6 +dt 0. +dt 0.0000 diff --git a/tests/nasm/fp2.asm b/tests/nasm/fp2.asm new file mode 100644 index 00000000..8c52f22c --- /dev/null +++ b/tests/nasm/fp2.asm @@ -0,0 +1,38 @@ +dt 125. +;times 6 db 0 +dt 1.25 +;times 6 db 0 +dt 3.141592653589793 +;times 6 db 0 +dt 1.e16 +;times 6 db 0 +dt 1.6e-20 +;times 6 db 0 +dt 5876. +;times 6 db 0 + +dd 1.1754943508222875e-38 +;times 4 db 0 +dq 1.1754943508222875e-38 +dt 1.1754943508222875e-38 +;times 6 db 0 + +dd 3.4028234663852886e+38 +;times 4 db 0 +dq 3.4028234663852886e+38 +dt 3.4028234663852886e+38 +;times 6 db 0 + +dd 2.2250738585072014E-308 +;times 4 db 0 +dq 2.2250738585072014E-308 +dt 2.2250738585072014E-308 +;times 6 db 0 + +;dd 1.7976931348623157E+308 +;times 4 db 0 +;times 4 db 0 +dq 1.7976931348623157E+308 +dt 1.7976931348623157E+308 +;times 6 db 0 + diff --git a/tests/nasm/jumps.asm b/tests/nasm/jumps.asm new file mode 100644 index 00000000..c3241137 --- /dev/null +++ b/tests/nasm/jumps.asm @@ -0,0 +1,12 @@ +BITS 16 + +label: +jmp 1 +jmp +1 +jmp -1 +jmp label +nop +je $$+1 +je $+1 +je $-1 +je label diff --git a/tests/nasm/labels.asm b/tests/nasm/labels.asm new file mode 100644 index 00000000..3e2862b0 --- /dev/null +++ b/tests/nasm/labels.asm @@ -0,0 +1,26 @@ +label +.label2 +..@label3 +..start +amaze +.0 +.? +.~ +.$ +.# +._ +.@ +.a +;.. +jmp ._ +test0$#@~.?: +jmp amaze.~ +.@@#~?_.$ +ret +_ +jmp test0$#@~.?.@@#~?_.$ +? +ret; +jmp 5 +jmp _ +jmp ? diff --git a/tests/nasm/labels2.asm b/tests/nasm/labels2.asm new file mode 100644 index 00000000..f2f693d7 --- /dev/null +++ b/tests/nasm/labels2.asm @@ -0,0 +1,31 @@ +;[EXTERN banana] +[GLOBAL banana] +;[COMMON banana 4] +apple: +mov ax, 5 + .orange: +mov dx, banana + .orange.white: +mov al, 1 +banana.echo: +mov dx, 5+2 + .insane: +banana: + +blah..host..me: + +test.: + .me: + +;banana.echo: +jmp apple +jmp apple.orange +jmp apple.orange.white +jmp banana +jmp banana.echo +;jmp banana.insane +jmp banana.echo.insane +jmp blah..host..me +jmp test..me +;banana equ 5 +;banana equ 7 diff --git a/tests/nasm/labels3.asm b/tests/nasm/labels3.asm new file mode 100644 index 00000000..7ef13b07 --- /dev/null +++ b/tests/nasm/labels3.asm @@ -0,0 +1,16 @@ +apple: + .orange: + .orange.white: +banana.echo: + .insane: + +jmp joe +jmp apple +jmp apple.orange +jmp apple.orange.white +jmp joe +jmp banana +jmp banana.echo +jmp banana.insane +jmp banana.echo.insane +jmp joe diff --git a/tests/nasm/lds.asm b/tests/nasm/lds.asm new file mode 100644 index 00000000..596e54bf --- /dev/null +++ b/tests/nasm/lds.asm @@ -0,0 +1,3 @@ +lds ax,[1] +lds ax,dword [1] + diff --git a/tests/nasm/mem.asm b/tests/nasm/mem.asm new file mode 100644 index 00000000..abc65a3d --- /dev/null +++ b/tests/nasm/mem.asm @@ -0,0 +1,39 @@ +[BITS 16] +a32 mov ax, [eax] +mov ax, [eax] +mov ax, [di] +mov ax, [di-si+si] +mov ax, [bx-(bx-di)-2] +mov ax, [2*(bx+di)-bx-2*di] +mov ax, [2*(bx*2+di)-bx-2*bx-2*di] +mov ax, [2*(bx*2)-bx-2*bx+di] +mov ax, [(bx+di)*(bx+di)-bx*bx-2*bx*di-di*di+di] +mov ax, [(blah2-blah)*di] +blah +inc ax +blah2 +mov ax, [(blah2-blah)*di] +[BITS 32] +mov ax, [si] +mov ax, [esi+400] +mov ax, [byte esi+400] +a16 mov ax, [esi+eax] +mov ax, [400-esi] +mov ax, [esi-eax] +mov ax, [(esi+400)+200] +mov ax, [esi+400-200] +mov ax, [eax+400/200] +mov ax, [400/200+eax] +mov ax, [eax+'a'] +mov ax, [eax+eax-eax+eax-ebx+ebx] +mov ax, [eax*5] +mov ax, [10] +mov ax, [edx] +mov ax, [edx*2] +mov ax, [nosplit edx*2] +mov ax, [edx*1] +mov ax, [nosplit edx*1] +mov ax, [edx*3] +mov ax, [esi+ebp] +mov ax, [ebp+esi] +mov ax, [ebp*1+esi] diff --git a/tests/nasm/mem2.asm b/tests/nasm/mem2.asm new file mode 100644 index 00000000..41fc7cf5 --- /dev/null +++ b/tests/nasm/mem2.asm @@ -0,0 +1,2 @@ +[bits 16] +mov ax,[di-si+si+126] diff --git a/tests/nasm/multisect.asm b/tests/nasm/multisect.asm new file mode 100644 index 00000000..92ad4790 --- /dev/null +++ b/tests/nasm/multisect.asm @@ -0,0 +1,21 @@ +[section .text] +aaa +aam +div ax +imul eax + +[section .data] +db 'hello',0 + +[section .text] +div al +bswap eax + +[section .bss] +resb 25 + +[section .data] +db 'bye!',0 + +[section .text] +mov ax, 5 diff --git a/tests/nasm/multisect2.asm b/tests/nasm/multisect2.asm new file mode 100644 index 00000000..2da2d62b --- /dev/null +++ b/tests/nasm/multisect2.asm @@ -0,0 +1,21 @@ +[section text] +aaa +aam +div ax +imul eax + +[section .data] +db 'hello',0 + +[section .TEXT] +div al +bswap eax + +[section .bss] +resb 25 + +[section .data] +db 'bye!',0 + +[section .TEXT] +mov ax, 5 diff --git a/tests/nasm/numconst.asm b/tests/nasm/numconst.asm new file mode 100644 index 00000000..040f62de --- /dev/null +++ b/tests/nasm/numconst.asm @@ -0,0 +1,12 @@ +mov ax,100 +mov ax,0a2h +mov ax,$0a2 +mov ax,0xa2 +mov ax,777q +mov ax,10010011b +mov eax,'abcd' +db 'hello' +db 'h','e','l','l','o' +dd 'ninechars' +dd 'nine','char','s' +db 'ninechars',0,0,0 diff --git a/tests/nasm/opsize.asm b/tests/nasm/opsize.asm new file mode 100644 index 00000000..161a7f6f --- /dev/null +++ b/tests/nasm/opsize.asm @@ -0,0 +1,3 @@ +mov ax,1 +mov ax,word 1 +mov ax,byte 1 diff --git a/tests/nasm/reloc.asm b/tests/nasm/reloc.asm new file mode 100644 index 00000000..031ad9a6 --- /dev/null +++ b/tests/nasm/reloc.asm @@ -0,0 +1,24 @@ +[SECTION .data] + +uhoh db 5 + +[GLOBAL blah] + +blah dw 5 +[SECTION .text] + +[EXTERN hi] +[EXTERN hi] +[EXTERN bye] + +mov eax, hi+2 +mov eax, bye +mov eax, [hi] +mov eax, [bye+2] +mov eax, $$ +mov eax, $ +mov eax, $-$$ +;mov eax, uhoh wrt $$ +mov eax, hi+bye +mov eax, bye+$ +mov eax, hi-$ diff --git a/tests/nasm/reloc2.asm b/tests/nasm/reloc2.asm new file mode 100644 index 00000000..eb598a51 --- /dev/null +++ b/tests/nasm/reloc2.asm @@ -0,0 +1,5 @@ +SECTION .text + +.text db 5 + + diff --git a/tests/nasm/second.asm b/tests/nasm/second.asm new file mode 100644 index 00000000..92e81ee5 --- /dev/null +++ b/tests/nasm/second.asm @@ -0,0 +1,20 @@ +aaa +aam +mov ax,16 +test al,al + +blah +xor ax,ax + +[SECTION .text] + +daa + +[SECTION .data] + +db 5,6,7,8 + +[SECTION .text] + +jmp blah + diff --git a/tests/nasm/shift.asm b/tests/nasm/shift.asm new file mode 100644 index 00000000..eb689a37 --- /dev/null +++ b/tests/nasm/shift.asm @@ -0,0 +1,6 @@ +blah equ 1 + +shl al, 1 +shl al, 2-1 +shl al, blah +shl al, 2-blah diff --git a/tests/nasm/signed.asm b/tests/nasm/signed.asm new file mode 100644 index 00000000..fbd368f4 --- /dev/null +++ b/tests/nasm/signed.asm @@ -0,0 +1,6 @@ +imul ax, bx, byte 255 +imul ax, bx, byte 0xFF +imul ax, bx, byte -0x80 +imul ax, bx, byte -0x7F +add ax, 100000 +add ax, -100000 diff --git a/tests/nasm/sizes.asm b/tests/nasm/sizes.asm new file mode 100644 index 00000000..8be304e3 --- /dev/null +++ b/tests/nasm/sizes.asm @@ -0,0 +1,11 @@ +BITS 32 +aaa +aad 500 +aad 10 +aad 0xFF +aad 0 +idiv al +idiv ax +idiv eax +idiv byte [0] + diff --git a/tests/nasm/sizes2.asm b/tests/nasm/sizes2.asm new file mode 100644 index 00000000..d4750f42 --- /dev/null +++ b/tests/nasm/sizes2.asm @@ -0,0 +1,12 @@ +aaa +aad 500 +aad 10 +aad 0xFF +aad 0 +here: +idiv al +idiv ax +idiv eax +idiv byte [0] +idiv dword [eax] + diff --git a/tests/nasm/store.asm b/tests/nasm/store.asm new file mode 100644 index 00000000..4d9bec54 --- /dev/null +++ b/tests/nasm/store.asm @@ -0,0 +1,6 @@ +label: + +db label +dw label +dd label + diff --git a/tests/nasm/string.asm b/tests/nasm/string.asm new file mode 100644 index 00000000..8a974ab6 --- /dev/null +++ b/tests/nasm/string.asm @@ -0,0 +1,8 @@ +mov eax, 'hi' +mov eax, 'hehe' +mov eax, 'hello' +mov eax, '' +db 0,0,0 +db 'hi"' +db "hi\" +db "hi\n" diff --git a/tests/nasm/test1.asm b/tests/nasm/test1.asm new file mode 100644 index 00000000..acf30402 --- /dev/null +++ b/tests/nasm/test1.asm @@ -0,0 +1,2 @@ +mov ax,[di] + diff --git a/tests/nasm/times.asm b/tests/nasm/times.asm new file mode 100644 index 00000000..964318dc --- /dev/null +++ b/tests/nasm/times.asm @@ -0,0 +1,3 @@ +;times 8 times 4 db 0 +times 'ab' db 0 +times 1.2 db 0