+;Testname=unoptimized; Arguments=-O0 -fbin -oa32offs.bin; Files=a32offs.bin .stdout .stderr
+;Testname=optimized; Arguments=-Ox -fbin -oa32offs.bin; Files=a32offs.bin .stdout .stderr
bits 16
foo: a32 loop foo
bar: loop bar, ecx
+;Testname=bin; Arguments=-fbin -oabsolute.bin; Files=.stdout .stderr absolute.bin
org 7c00h
init_foo:
jmp init_bar
+;Testname=O0; Arguments=-O0 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=O1; Arguments=-O1 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=O2; Arguments=-O2 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=O3; Arguments=-O3 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=O4; Arguments=-O4 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=O5; Arguments=-O5 -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
+;Testname=Ox; Arguments=-Ox -fbin -oaddr64.bin; Files=.stdout .stderr addr64.bin
bits 64
mov rdx,[rax]
mov eax,[byte rsp+0x01]
+;Testname=unoptimized; Arguments=-O0 -faoutb -oaoutso.o; Files=.stdout .stderr aoutso.o
+;Testname=optimized; Arguments=-Ox -faoutb -oaoutso.o; Files=.stdout .stderr aoutso.o
+
; test source file for assembling to NetBSD/FreeBSD a.out shared library
; build with:
; nasm -f aoutb aoutso.asm
+;Testname=unoptimized; Arguments=-O0 -faout -oaouttest.o; Files=.stdout .stderr aouttest.o
+;Testname=optimized; Arguments=-Ox -faout -oaouttest.o; Files=.stdout .stderr aouttest.o
+
; test source file for assembling to a.out
; build with:
; nasm -f aout aouttest.asm
+;Testname=unoptimized; Arguments=-O0 -fbin -obinexe.exe -i../misc/; Files=.stdout .stderr binexe.exe
+;Testname=optimized; Arguments=-Ox -fbin -obinexe.exe -i../misc/; Files=.stdout .stderr binexe.exe
+
; Demonstration of how to write an entire .EXE format program by using
; the `exebin.mac' macro package.
; To build:
+;Testname=unoptimized; Arguments=-O0 -fbin -obintest.bin; Files=.stdout .stderr bintest.bin
+;Testname=optimized; Arguments=-Ox -fbin -obintest.bin; Files=.stdout .stderr bintest.bin
+
; test source file for assembling to binary files
; build with:
; nasm -f bin -o bintest.com bintest.asm
+;Testname=unoptimized; Arguments=-O0 -fbin -obr1879590.bin; Files=.stdout .stderr br1879590.bin
+;Testname=optimized; Arguments=-Ox -fbin -obr1879590.bin; Files=.stdout .stderr br1879590.bin
+
bits 32
pavgb mm0,[ebx]
-;
-; Test for bug report 560575
+;Testname=aout; Arguments=-faout -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=aoutb; Arguments=-faoutb -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=coff; Arguments=-fcoff -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=elf32; Arguments=-felf32 -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=elf64; Arguments=-felf64 -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=as86; Arguments=-fas86 -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=win32; Arguments=-fwin32 -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=win64; Arguments=-fwin64 -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=rdf; Arguments=-frdf -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=ieee; Arguments=-fieee -obr560575.o; Files=.stderr .stdout br560575.o
+;Testname=macho; Arguments=-fmacho -obr560575.o; Files=.stderr .stdout br560575.o
+
+;Test for bug report 560575 - Using SEG with non-relocatable values doesn't work
;
dw seg ~1
dw seg "a"
+;Testname=unoptimized; Arguments=-O0 -frdf -obr560873.rdf; Files=.stdout .stderr br560873.rdf
+;Testname=optimized; Arguments=-Ox -frdf -obr560873.rdf; Files=.stdout .stderr br560873.rdf
+
label:
bits 16
call far dword label
+;Cannot be automatically tested because it differs every time,
+;I guess because of a date/time field.
+
; test source file for assembling to COFF
; build with (under DJGPP, for example):
; nasm -f coff cofftest.asm
+;Testname=unoptimized; Arguments=-O0 -felf -oelfso.o; Files=.stdout .stderr elfso.o
+;Testname=optimized; Arguments=-Ox -felf -oelfso.o; Files=.stdout .stderr elfso.o
+
; test source file for assembling to ELF shared library
; build with:
; nasm -f elf elfso.asm
+;Testname=unoptimized; Arguments=-O0 -fobj -oelif.obj; Files=.stdout .stderr elif.obj
+;Testname=optimized; Arguments=-Ox -fobj -oelif.obj; Files=.stdout .stderr elif.obj
+
%macro DosPrintMsg 1+
%ifnid %1
section .data
+;Testname=O0; Arguments=-O0 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=O1; Arguments=-O1 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=O2; Arguments=-O2 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=O3; Arguments=-O3 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=O4; Arguments=-O4 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=O5; Arguments=-O5 -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=Ox; Arguments=-Ox -fbin -oexpimp.bin; Files=.stdout .stderr expimp.bin
+;Testname=error-O0; Arguments=-O0 -fbin -oexpimp.bin -DERROR; Files=.stdout .stderr expimp.bin
+;Testname=error-Ox; Arguments=-Ox -fbin -oexpimp.bin -DERROR; Files=.stdout .stderr expimp.bin
+
;
; Test of explicitly and implicitly sized operands
;
+ BITS 32
+
add esi,2 ; Implicit
add esi,123456h ; Implicit
add esi,byte 2 ; Explicit
+;Testname=unoptimized; Arguments=-O0 -fbin -ofloat.bin; Files=.stdout .stderr float.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofloat.bin; Files=.stdout .stderr float.bin
+
;
; Test of floating-point formats
;
+;Testname=unoptimized; Arguments=-O0 -fbin -ofloat8.bin; Files=.stdout .stderr float8.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofloat8.bin; Files=.stdout .stderr float8.bin
+
; Test of 8-bit floating-point constants
; Zero
+;Testname=unoptimized; Arguments=-O0 -fbin -ofloatb.bin; Files=.stdout .stderr floatb.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofloatb.bin; Files=.stdout .stderr floatb.bin
+
;; Known problematic floating-point numbers and their proper
;; encoding...
+;Testname=unoptimized; Arguments=-O0 -fbin -ofloatexp.bin; Files=.stdout .stderr floatexp.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofloatexp.bin; Files=.stdout .stderr floatexp.bin
+
bits 64
;
; Test of floating-point formats
+;Testname=unoptimized; Arguments=-O0 -fbin -ofloatize.bin; Files=.stdout .stderr floatize.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofloatize.bin; Files=.stdout .stderr floatize.bin
+
%assign x13 13+26
%assign f16 __float16__(1.6e-7)
%assign f32 __float32__(1.6e-7)
+;Testname=optimized; Arguments=-Ox -felf -ofloattest.o; Files=.stdout .stderr floattest.o
+
; nasm -O99 -f elf32 floattest.asm
; ld -m elf_i386 -o floattest floattest.o -I/lib/ld-linux.so.2 -lc
+;Testname=unoptimized; Arguments=-O0 -fbin -ofmsub.bin; Files=.stdout .stderr fmsub.bin
+;Testname=optimized; Arguments=-Ox -fbin -ofmsub.bin; Files=.stdout .stderr fmsub.bin
+
bits 64
fmsubps xmm0,xmm0,xmm1,xmm2
+;Testname=test; Arguments=-fbin -ofpu.bin; Files=.stdout .stderr fpu.bin
+
; relaxed encodings for FPU instructions, which NASM should support
; -----------------------------------------------------------------
+;Testname=test; Arguments=-fbin -oifmacro.txt; Files=.stdout .stderr ifmacro.txt
+
;
; ifmacro.asm
;
+;Testname=test; Arguments=-fbin -oiftoken.txt; Files=.stdout .stderr iftoken.txt
+
%define ZMACRO
%define NMACRO 1
%define TMACRO 1 2
'foo', 'foo bar', '%', '+foo', '<<');
@tests = ('token', 'empty');
+print ";Testname=test; Arguments=-fbin -oiftoken.txt; Files=.stdout .stderr iftoken.txt"
print "%define ZMACRO\n";
print "%define NMACRO 1\n";
print "%define TMACRO 1 2\n";
+;Testname=test; Arguments=-fbin -oinctest.com; Files=.stdout .stderr inctest.com
+
; This file, plus inc1.asm and inc2.asm, test NASM's file inclusion
; mechanism.
;
+;Testname=test; Arguments=-fbin -oinsnlbl.bin; Files=.stdout .stderr insnlbl.bin
+
;
; Test "instruction as label" -- make opcodes legal as labels if
; they are followed by a colon.
+;Testname=unoptimized; Arguments=-fbin -oinvlpga.bin; Files=.stdout .stderr invlpga.bin
+;Testname=optimized; Arguments=-fbin -oinvlpga.bin -Ox; Files=.stdout .stderr invlpga.bin
+
bits 32
invlpga
invlpga ax,ecx
-; LAR/LSL\r
-;---------\r
-\r
-; 1x ; = invalid due to lack of REX\r
-; 3x ; = invalid due to Mw\r
-\r
-%macro m 1\r
-\r
- bits 16\r
-\r
- %1 ax, ax\r
- %1 ax,eax\r
-; %1 ax,rax\r
-\r
- %1 eax, ax\r
- %1 eax,eax\r
-; %1 eax,rax\r
-\r
-; %1 rax, ax\r
-; %1 rax,eax\r
-; %1 rax,rax\r
-\r
- %1 ax, [0]\r
- %1 ax, word [0]\r
-;;; %1 ax,dword [0]\r
-; %1 ax,qword [0]\r
-\r
- %1 eax, [0]\r
- %1 eax, word [0]\r
-;;; %1 eax,dword [0]\r
-; %1 eax,qword [0]\r
-\r
-; %1 rax, [0]\r
-; %1 rax, word [0]\r
-; %1 rax,dword [0]\r
-; %1 rax,qword [0]\r
-\r
- bits 32\r
-\r
- %1 ax, ax\r
- %1 ax,eax\r
-; %1 ax,rax\r
-\r
- %1 eax, ax\r
- %1 eax,eax\r
-; %1 eax,rax\r
-\r
-; %1 rax, ax\r
-; %1 rax,eax\r
-; %1 rax,rax\r
-\r
- %1 ax, [0]\r
- %1 ax, word [0]\r
-;;; %1 ax,dword [0]\r
-; %1 ax,qword [0]\r
-\r
- %1 eax, [0]\r
- %1 eax, word [0]\r
-;;; %1 eax,dword [0]\r
-; %1 eax,qword [0]\r
-\r
-; %1 rax, [0]\r
-; %1 rax, word [0]\r
-; %1 rax,dword [0]\r
-; %1 rax,qword [0]\r
-\r
- bits 64\r
-\r
- %1 ax, ax\r
- %1 ax,eax\r
- %1 ax,rax ; $TODO: shouldn't emit REX.W $\r
-\r
- %1 eax, ax\r
- %1 eax,eax\r
- %1 eax,rax ; $TODO: shouldn't emit REX.W $\r
-\r
- %1 rax, ax\r
- %1 rax,eax\r
- %1 rax,rax\r
-\r
- %1 ax, [0]\r
- %1 ax, word [0]\r
-;;; %1 ax,dword [0]\r
-;;; %1 ax,qword [0]\r
-\r
- %1 eax, [0]\r
- %1 eax, word [0]\r
-;;; %1 eax,dword [0]\r
-;;; %1 eax,qword [0]\r
-\r
- %1 rax, [0]\r
- %1 rax, word [0]\r
-;;; %1 rax,dword [0]\r
-;;; %1 rax,qword [0]\r
-\r
-%endmacro\r
-\r
-m lar\r
-\r
-m lsl\r
-\r
-bits 16\r
-lar ax,[ si]\r
-lar ax,[esi]\r
-bits 32\r
-lar ax,[ si]\r
-lar ax,[esi]\r
-bits 64\r
-lar ax,[esi]\r
-lar ax,[rsi]\r
-\r
-bits 16\r
-lsl ax,[ si]\r
-lsl ax,[esi]\r
-bits 32\r
-lsl ax,[ si]\r
-lsl ax,[esi]\r
-bits 64\r
-lar ax,[esi]\r
-lsl ax,[rsi]\r
-\r
-; EOF\r
+;Testname=test; Arguments=-fbin -olar_lsl.bin; Files=.stdout .stderr lar_lsl.bin
+
+; LAR/LSL
+;---------
+
+; 1x ; = invalid due to lack of REX
+; 3x ; = invalid due to Mw
+
+%macro m 1
+
+ bits 16
+
+ %1 ax, ax
+ %1 ax,eax
+; %1 ax,rax
+
+ %1 eax, ax
+ %1 eax,eax
+; %1 eax,rax
+
+; %1 rax, ax
+; %1 rax,eax
+; %1 rax,rax
+
+ %1 ax, [0]
+ %1 ax, word [0]
+;;; %1 ax,dword [0]
+; %1 ax,qword [0]
+
+ %1 eax, [0]
+ %1 eax, word [0]
+;;; %1 eax,dword [0]
+; %1 eax,qword [0]
+
+; %1 rax, [0]
+; %1 rax, word [0]
+; %1 rax,dword [0]
+; %1 rax,qword [0]
+
+ bits 32
+
+ %1 ax, ax
+ %1 ax,eax
+; %1 ax,rax
+
+ %1 eax, ax
+ %1 eax,eax
+; %1 eax,rax
+
+; %1 rax, ax
+; %1 rax,eax
+; %1 rax,rax
+
+ %1 ax, [0]
+ %1 ax, word [0]
+;;; %1 ax,dword [0]
+; %1 ax,qword [0]
+
+ %1 eax, [0]
+ %1 eax, word [0]
+;;; %1 eax,dword [0]
+; %1 eax,qword [0]
+
+; %1 rax, [0]
+; %1 rax, word [0]
+; %1 rax,dword [0]
+; %1 rax,qword [0]
+
+ bits 64
+
+ %1 ax, ax
+ %1 ax,eax
+ %1 ax,rax ; $TODO: shouldn't emit REX.W $
+
+ %1 eax, ax
+ %1 eax,eax
+ %1 eax,rax ; $TODO: shouldn't emit REX.W $
+
+ %1 rax, ax
+ %1 rax,eax
+ %1 rax,rax
+
+ %1 ax, [0]
+ %1 ax, word [0]
+;;; %1 ax,dword [0]
+;;; %1 ax,qword [0]
+
+ %1 eax, [0]
+ %1 eax, word [0]
+;;; %1 eax,dword [0]
+;;; %1 eax,qword [0]
+
+ %1 rax, [0]
+ %1 rax, word [0]
+;;; %1 rax,dword [0]
+;;; %1 rax,qword [0]
+
+%endmacro
+
+m lar
+
+m lsl
+
+bits 16
+lar ax,[ si]
+lar ax,[esi]
+bits 32
+lar ax,[ si]
+lar ax,[esi]
+bits 64
+lar ax,[esi]
+lar ax,[rsi]
+
+bits 16
+lsl ax,[ si]
+lsl ax,[esi]
+bits 32
+lsl ax,[ si]
+lsl ax,[esi]
+bits 64
+lar ax,[esi]
+lsl ax,[rsi]
+
+; EOF
+;Testname=test; Arguments=-fbin -olarlsl.bin; Files=.stdout .stderr larlsl.bin
+
bits 64
lar ax,bx
+;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+
;
; Assembly "Hello, World!" for Linux
;
+;Testname=test; Arguments=-fbin -olocal.bin; Files=.stdout .stderr local.bin
bits 32
%push bluttan
+;Testname=unoptimized; Arguments=-fbin -oloopoffs.bin -O0; Files=.stdout .stderr loopoffs.bin
+;Testname=optimized; Arguments=-fbin -oloopoffs.bin -Ox; Files=.stdout .stderr loopoffs.bin
bits 16
delay: loop delay
loop $
+;Testname=unoptimized; Arguments=-fbin -ommxsize.bin -O0; Files=.stdout .stderr mmxsize.bin
+;Testname=optimized; Arguments=-fbin -ommxsize.bin -Ox; Files=.stdout .stderr mmxsize.bin
bits 32
movd mm0,eax
movd mm0,[foo]
+;Testname=unoptimized; Arguments=-fbin -omovimm.bin -O0; Files=.stdout .stderr movimm.bin
+;Testname=optimized; Arguments=-fbin -omovimm.bin -Ox; Files=.stdout .stderr movimm.bin
bits 64
mov rax,1234567890abcdefh
+;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=elf64; Arguments=-felf64 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=obj; Arguments=-fobj -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=rdf; Arguments=-frdf -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=win32; Arguments=-fwin32 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+;Testname=win64; Arguments=-fwin64 -olnxhello.o -Ox; Files=.stdout .stderr lnxhello.o
+
; To test where code that is placed before any explicit SECTION
; gets placed, and what happens if a .text section has an ORG
;statement, uncomment the following lines.
+;Testname=obj; Arguments=-fobj -onasmfomat.o; Files=.stdout .stderr nasmfomat.o
+;Testname=bin; Arguments=-fbin -onasmfomat.o; Files=.stdout .stderr nasmfomat.o
+;Testname=rdf; Arguments=-frdf -onasmfomat.o; Files=.stdout .stderr nasmfomat.o
%if __OUTPUT_FORMAT__ == 'bin'
+;Testname=unoptimized; Arguments=-fbin -onop.bin; Files=.stdout .stderr nop.bin
+;Testname=optimized; Arguments=-fbin -onop.bin -Ox; Files=.stdout .stderr nop.bin
+
bits 64
nop
+;Testname=test; Arguments=-fbin -onull.bin; Files=.stdout .stderr null.bin
;
; A file that produces no output has been known to occationally crash NASM.
;
+;Testname=unoptimized; Arguments=-O0 -fobj -oobj.o; Files=.stdout .stderr obj.o
+;Testname=optimized; Arguments=-Ox -fobj -oobj.o; Files=.stdout .stderr obj.o
+
; test source file for assembling to Microsoft 16-bit .OBJ
; build with (16-bit Microsoft C):
; nasm -f obj objtest.asm
+;Testname=elf64; Arguments=-Ox -felf64 -oorg.o; Files=.stdout .stderr org.o
+;Testname=win64; Arguments=-Ox -fwin64 -oorg.o; Files=.stdout .stderr org.o
+
;
; Simple test of a 64-bit org directive
;
+;Testname=test; Arguments=-fbin -or13.bin; Files=.stdout .stderr r13.bin
+
bits 64
mov rax,[rbx]
mov rax,[rbx*4]
+;Testname=test; Arguments=-fbin -oradix.bin; Files=.stdout .stderr radix.bin
+
;; Integer constants...
dd 1010_0101 ; Decimal
+;Testname=unoptimized; Arguments=-fbin -oriprel.bin -O0; Files=.stdout .stderr riprel.bin
+;Testname=optimized; Arguments=-fbin -oriprel.bin -Ox; Files=.stdout .stderr riprel.bin
bits 64
default abs
#!/usr/bin/perl
+print ";Testname=unoptimized; Arguments=-fbin -oriprel.bin -O0; Files=.stdout .stderr riprel.bin\n";
+print ";Testname=optimized; Arguments=-fbin -oriprel.bin -Ox; Files=.stdout .stderr riprel.bin\n";
+
+
print "\tbits 64\n";
foreach $mode ('abs', 'rel') {
+;Testname=unoptimized; Arguments=-fbin -otest67.bin -O0; Files=.stdout .stderr test67.bin
+;Testname=optimized; Arguments=-fbin -otest67.bin -Ox; Files=.stdout .stderr test67.bin
+
bits 16
mov ax,[bx]
+;Testname=test; Arguments=-fbin -otestdos.bin; Files=.stdout .stderr testdos.bin
;
; This file was known to miscompile with the 16-bit NASM built
; under Borland C++ 3.1, so keep it around for testing...
+;Testname=test; Arguments=-fbin -otestnos3.bin; Files=.stdout .stderr testnos3.bin
;
; Double-precision floating point tests, derived from Fred Tydeman's posting
; of 26 February 1996 to comp.arch.arithmetic, via David M. Gay's gdtoa
+;Not automatically testable because it is not constant
db __DATE__, 13, 10
db __TIME__, 13, 10
db __UTC_DATE__, 13, 10
+;Testname=test; Arguments=-fbin -ouscore.bin; Files=.stdout .stderr uscore.bin
dd 0x1234_5678
dd 305_419_896 ; Same number as above it
dd 0x1e16 ; NOT a floating-point number!
+;Testname=unoptimized; Arguments=-fbin -oxchg.bin -O0; Files=.stdout .stderr xchg.bin
+;Testname=optimized; Arguments=-fbin -oxchg.bin -Ox; Files=.stdout .stderr xchg.bin
+
%macro x 2
xchg %1,%2
xchg %2,%1
+;Testname=test; Arguments=-fbin -ozerobyte.bin; Files=.stdout .stderr zerobyte.bin
bits 64
mov eax,bar-foo