├── version ├── test ├── br890790_i.asm ├── tmap.nas ├── _version.asm ├── strlen.asm ├── _file_.asm ├── br890790.asm ├── imacro.asm ├── inc1.asm ├── nullfile.asm ├── inc2.asm ├── br3028880.asm ├── paste.asm ├── movnti.asm ├── new ├── br2030823.asm ├── br3104312.asm ├── br3187743.asm ├── far64.asm ├── movd.asm ├── movd64.asm ├── br3074517.asm ├── time.asm ├── br3189064.asm ├── br3200749.asm ├── pushseg.asm ├── a32offs.asm ├── insnlbl.asm ├── br3109604.asm ├── hle.asm ├── invlpga.asm ├── riprel2.asm ├── br3174983.asm ├── zerobyte.asm ├── r13.asm ├── br2003451.asm ├── nop.asm ├── testdos.asm ├── br3026808.asm ├── br3058845.asm ├── loopoffs.asm ├── perf │ ├── label.pl │ ├── macro.pl │ └── token.pl ├── br3092924.asm ├── br3385573.asm ├── org.asm ├── andbyte.asm ├── local.asm ├── xcrypt.asm ├── inctest.asm ├── align13.asm ├── align13s.asm ├── jmp64.asm ├── br2222615.asm ├── larlsl.asm ├── prefix66.asm ├── nasmformat.asm ├── newrdwr.asm ├── bcd.asm ├── absolute.asm ├── weirdpaste.asm ├── bisect.sh ├── uscore.asm ├── vmread.asm ├── floattest.asm ├── floatize.asm ├── addr64x.asm ├── smartalign16.asm ├── smartalign32.asm ├── smartalign64.asm ├── br3005117.asm ├── ifenv.asm ├── popcnt.asm ├── gotoff64.asm ├── br1879590.asm ├── objexe.asm ├── struc.asm ├── br560873.asm ├── crc32.asm ├── ifelse.asm ├── test67.asm ├── floatb.asm ├── ppindirect.asm ├── riprel.pl ├── iftoken.pl ├── mmxsize.asm ├── elif.asm ├── binexe.asm ├── br2496848.asm ├── br3041451.asm ├── br560575.asm ├── objlink.c ├── cofftest.c ├── movimm.asm ├── aouttest.c ├── elftest.c ├── lnxhello.asm ├── elftest64.c ├── sreg.asm ├── pinsr16.asm ├── pinsr32.asm ├── avx.asm ├── radix.asm ├── xchg.asm ├── pinsr64.asm ├── br3066383.asm ├── bintest.asm ├── immwarn.asm ├── macro-defaults.asm ├── dtbcd.asm ├── utf.asm ├── imm64.asm ├── lar_lsl.asm ├── multisection.asm ├── vgather.asm └── optimization.asm ├── rdoff ├── rdf2com.1 ├── rdf2ihx.1 ├── rdf2ith.1 ├── rdf2srec.1 ├── Mkfiles │ ├── README │ ├── Makefile.sc │ ├── Makefile.dj │ └── Makefile.unx ├── test │ ├── Makefile │ ├── makelib.sh │ ├── rdfseg2.asm │ ├── testlib.asm │ ├── rdfseg.asm │ ├── rdtlib.asm │ ├── rdftest2.asm │ ├── rdtmain.asm │ └── rdftest1.asm ├── hash.h ├── rdx.1 ├── doc │ └── Makefile ├── collectn.h ├── rdfdump.1 ├── rdfload.h ├── collectn.c ├── rdflib.1 ├── rdlar.h ├── ldrdf.1 ├── rdf2bin.1 ├── ldsegs.h ├── segtab.h └── symtab.h ├── nsis ├── nasm.ico └── nasm-un.ico ├── misc ├── README ├── magic ├── pmw.bat ├── Nindent ├── hints.txt ├── c32.mac ├── fmtinsns.pl ├── findleak.pl ├── tag-release ├── c16.mac ├── crcgen.c ├── xcrcgen.c ├── exebin.mac ├── genfma.pl ├── findleak.txt └── exebin2.mac ├── CHANGES ├── perllib ├── README └── gensv.pl ├── autogen.sh ├── lib ├── snprintf.c ├── vsnprintf.c └── strlcpy.c ├── doc └── pswidth.ph ├── contrib ├── VSrules │ └── nasm.README └── MSVC6.txt ├── README ├── .gitignore ├── aclocal.m4 ├── LICENSE ├── Mkfiles └── README ├── headers ├── c ├── doc ├── mac └── perl ├── output ├── outas86.mac ├── outaout.mac ├── outmacho.mac ├── outbin.mac ├── outrdf.mac ├── outelf.mac ├── outrdf2.mac ├── outcoff.mac ├── outobj.mac ├── outlib.c └── nullout.c ├── listing.h ├── quote.h ├── sync.h ├── parser.h ├── stdscan.h ├── disasm.h ├── assemble.h ├── ver.c ├── float.h ├── macros └── fp.mac ├── directiv.dat ├── rbtree.h └── preproc.h /version: -------------------------------------------------------------------------------- 1 | 2.10rc15 2 | -------------------------------------------------------------------------------- /test/br890790_i.asm: -------------------------------------------------------------------------------- 1 | db 2 2 | -------------------------------------------------------------------------------- /rdoff/rdf2com.1: -------------------------------------------------------------------------------- 1 | .so man1/rdf2bin.1 2 | -------------------------------------------------------------------------------- /rdoff/rdf2ihx.1: -------------------------------------------------------------------------------- 1 | .so man1/rdf2bin.1 2 | -------------------------------------------------------------------------------- /rdoff/rdf2ith.1: -------------------------------------------------------------------------------- 1 | .so man1/rdf2bin.1 2 | -------------------------------------------------------------------------------- /rdoff/rdf2srec.1: -------------------------------------------------------------------------------- 1 | .so man1/rdf2bin.1 2 | -------------------------------------------------------------------------------- /nsis/nasm.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/letolabs/nasm/HEAD/nsis/nasm.ico -------------------------------------------------------------------------------- /test/tmap.nas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/letolabs/nasm/HEAD/test/tmap.nas -------------------------------------------------------------------------------- /nsis/nasm-un.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/letolabs/nasm/HEAD/nsis/nasm-un.ico -------------------------------------------------------------------------------- /test/_version.asm: -------------------------------------------------------------------------------- 1 | ;Testname=version; Arguments=-v; Files=stdout 2 | ;Dummy test to record version numbers 3 | -------------------------------------------------------------------------------- /misc/README: -------------------------------------------------------------------------------- 1 | There are various helpful bits and pieces for NASM, 2 | including but not limited to Simon photograph =) 3 | -------------------------------------------------------------------------------- /test/strlen.asm: -------------------------------------------------------------------------------- 1 | %macro strlen_test 1 2 | %strlen len %2 ; not existing argument 3 | %endmacro 4 | 5 | strlen_test 'a' 6 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | The revision history has moved to the file doc/changes.src, and 2 | is now included in the documentation as Appendix C. 3 | -------------------------------------------------------------------------------- /perllib/README: -------------------------------------------------------------------------------- 1 | This directory contains the following Perl modules from CPAN: 2 | 3 | Graph-0.84 4 | 5 | See the .pod documentation for copyright and license terms. 6 | -------------------------------------------------------------------------------- /test/_file_.asm: -------------------------------------------------------------------------------- 1 | ;Testname=bin; Arguments=-fbin -o_file_.bin; Files=stdout stderr _file_.bin 2 | db __FILE__, `\r\n` 3 | db __FILE__, `\r\n` 4 | dw __LINE__ 5 | dw __LINE__ 6 | -------------------------------------------------------------------------------- /test/br890790.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -obr890790.bin; Files=stdout stderr br890790.bin 2 | %rep 5 3 | db 0 4 | %include "br890790_i.asm" 5 | %endrep 6 | 7 | db 1 8 | -------------------------------------------------------------------------------- /test/imacro.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oimacro.bin; Files=stdout stderr imacro.bin 2 | 3 | %imacro Zero 1 4 | xor %1,%1 5 | %endmacro 6 | 7 | Zero eax 8 | zero eax 9 | -------------------------------------------------------------------------------- /test/inc1.asm: -------------------------------------------------------------------------------- 1 | ; This file is part of the include test. 2 | ; See inctest.asm for build instructions. 3 | 4 | message: db 'hello, world',13,10,'$' 5 | 6 | %include "inc2.asm" 7 | -------------------------------------------------------------------------------- /test/nullfile.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -onull.bin; Files=stdout stderr null.bin 2 | ; 3 | ; A file that produces no output has been known to occationally crash NASM. 4 | ; 5 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # 3 | # Simple script to run the appropriate autotools from a repository. 4 | # 5 | autoheader 6 | autoconf 7 | rm -rf autom4te.cache config.log config.status 8 | -------------------------------------------------------------------------------- /test/inc2.asm: -------------------------------------------------------------------------------- 1 | ; This file is part of the include test. 2 | ; See inctest.asm for build instructions. 3 | 4 | _main: mov dx,message 5 | mov ah,9 6 | int 21h 7 | mov ax,4c00h 8 | int 21h 9 | -------------------------------------------------------------------------------- /test/br3028880.asm: -------------------------------------------------------------------------------- 1 | ;Testname=br3028880; Arguments=-Ox -fbin -obr3028880.o; Files=stdout stderr br3028880.o 2 | 3 | %macro import 1 4 | %define %%incfile %!PROJECTBASEDIR/%{1}.inc 5 | %endmacro 6 | 7 | import foo 8 | 9 | -------------------------------------------------------------------------------- /rdoff/Mkfiles/README: -------------------------------------------------------------------------------- 1 | These are pre-created Makefiles for various platforms, use them if 2 | GNU autoconf/automake packages are not supported on your system. 3 | 4 | Copy appropriate Makefile to ../Makefile and run make. 5 | -------------------------------------------------------------------------------- /rdoff/test/Makefile: -------------------------------------------------------------------------------- 1 | RDT = $(patsubst %.asm,%.rdf,$(wildcard *.asm)) 2 | NASM = ../../nasm 3 | 4 | all: $(RDT) 5 | 6 | %.rdf: %.asm 7 | $(NASM) -f rdf -o $@ -l $*.lst $< 8 | 9 | clean: 10 | rm -f *.rdf *.rdx *.lst 11 | -------------------------------------------------------------------------------- /test/paste.asm: -------------------------------------------------------------------------------- 1 | %macro bug 1-* 2 | %push foo 3 | %define %$v %1 4 | %define vv %$v_ %+ %1 5 | %%top_{%$v}%1: 6 | mov eax, eax 7 | mov eax, %%top_{%$v}%1 8 | mov eax, vv 9 | %pop 10 | %endmacro 11 | 12 | bug a 13 | -------------------------------------------------------------------------------- /test/movnti.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -omovnti.bin; Files=stdout stderr movnti.bin 2 | ; BR 2028995 3 | 4 | bits 16 5 | movnti [si],eax 6 | bits 32 7 | movnti [esi],eax 8 | bits 64 9 | movnti [rsi],eax 10 | movnti [rsi],rax 11 | -------------------------------------------------------------------------------- /rdoff/test/makelib.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | [ $1 ] || { 4 | echo "Usage: $0 [...]" 5 | exit 1 6 | } 7 | 8 | libname=$1; shift 9 | 10 | rdflib c $libname 11 | 12 | for f in $*; do 13 | rdflib a $libname $f $f 14 | done 15 | -------------------------------------------------------------------------------- /test/new: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for f; do 3 | if [ -e "$f".asm ]; then 4 | # For safety... 5 | echo "$0: $f already exists" 1>&2 6 | exit 1 7 | fi 8 | echo ";Testname=test; Arguments=-fbin -o$f.bin; Files=stdout stderr $f.bin" > "$f".asm 9 | done 10 | -------------------------------------------------------------------------------- /test/br2030823.asm: -------------------------------------------------------------------------------- 1 | ;Testname=optimized; Arguments=-Ox -fbin -obr2030823.bin; Files=stdout stderr br2030823.bin 2 | 3 | bits 64 4 | VFMADDPD xmm0, xmm1, [0], xmm3 5 | VFMADDPD xmm0, xmm1, xmm2, [0] 6 | VFMADDPD ymm0, ymm1, [0], ymm3 7 | VFMADDPD ymm0, ymm1, ymm2, [0] 8 | -------------------------------------------------------------------------------- /test/br3104312.asm: -------------------------------------------------------------------------------- 1 | %if 1 < 8000_0002h 2 | %warning No bug with 8000_0002h 3 | %else 4 | %warning Bug with 8000_0002h 5 | %endif 6 | 7 | %if 1 < 8000_0001h 8 | %warning No bug with 8000_0001h 9 | %else 10 | %warning Bug with 8000_0001h 11 | %endif 12 | -------------------------------------------------------------------------------- /test/br3187743.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3187743.bin; Files=stdout stderr br3187743.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3187743.bin; Files=stdout stderr br3187743.bin 3 | 4 | bits 64 5 | 6 | vlddqu xmm0,[edi] 7 | vlddqu ymm0,[edi] 8 | -------------------------------------------------------------------------------- /test/far64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ofar64.bin; Files=stdout stderr far64.bin 2 | ; BR 2039212 3 | bits 64 4 | 5 | call qword far [rax] 6 | jmp qword far [rax] 7 | call dword far [rax] 8 | jmp dword far [rax] 9 | call far [rax] 10 | jmp far [rax] 11 | -------------------------------------------------------------------------------- /test/movd.asm: -------------------------------------------------------------------------------- 1 | ;Testname=optimized; Arguments=-Ox -fbin -omovd.bin; Files=stdout stderr movd.bin 2 | [BITS 32] 3 | movd mm0,eax 4 | movd mm0,[eax] 5 | movd [eax],mm0 6 | movd eax,mm0 7 | 8 | movd xmm0,eax 9 | movd xmm0,[eax] 10 | 11 | movd [eax],xmm0 12 | movd eax,xmm0 13 | -------------------------------------------------------------------------------- /test/movd64.asm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | movd r8d, mm1 4 | movd r8, mm1 5 | movq r8, mm1 6 | 7 | movd [rax], mm1 8 | movq [rax], mm1 9 | movd dword [rax], mm1 10 | ; movq dword [rax], mm1 11 | movd qword [rax], mm1 12 | movq qword [rax], mm1 13 | 14 | ; movd mm2, mm1 15 | movq mm2, mm1 16 | -------------------------------------------------------------------------------- /test/br3074517.asm: -------------------------------------------------------------------------------- 1 | ;%define UNDEFINED 2 | %macro macro 0 3 | %ifndef UNDEFINED 4 | %rep 1 5 | %fatal This should display "fatal: (m:3)" 6 | %endrep 7 | %endif 8 | %fatal This should display "fatal: (m:6)" if 'UNDEFINED' defined 9 | %endmacro 10 | 11 | macro 12 | 13 | -------------------------------------------------------------------------------- /misc/magic: -------------------------------------------------------------------------------- 1 | # Put the following lines in your /etc/magic file to get 'file' to recognise 2 | # RDOFF Object Files 3 | 4 | 0 string RDOFF RDOFF Object File 5 | >5 byte >32 version %c (little endian) 6 | >5 byte <32 version %d (big endian) 7 | -------------------------------------------------------------------------------- /test/time.asm: -------------------------------------------------------------------------------- 1 | ;Not automatically testable because it is not constant 2 | db __DATE__, 13, 10 3 | db __TIME__, 13, 10 4 | db __UTC_DATE__, 13, 10 5 | db __UTC_TIME__, 13, 10 6 | align 4 7 | dd __DATE_NUM__ 8 | dd __TIME_NUM__ 9 | dd __UTC_DATE_NUM__ 10 | dd __UTC_TIME_NUM__ 11 | dd __POSIX_TIME__ 12 | -------------------------------------------------------------------------------- /test/br3189064.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3189064.bin; Files=stdout stderr br3189064.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3189064.bin; Files=stdout stderr br3189064.bin 3 | 4 | [bits 64] 5 | VMASKMOVPS [edi],ymm0,ymm1 6 | VEXTRACTF128 xmm0,ymm1,1 7 | VEXTRACTF128 [edi],ymm1,1 8 | -------------------------------------------------------------------------------- /test/br3200749.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3200749.bin; Files=stdout stderr br3200749.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3200749.bin; Files=stdout stderr br3200749.bin 3 | %define IFNDEF %ifndef 4 | %define ENDIF %endif 5 | 6 | IFNDEF foo 7 | ; bar 8 | ENDIF 9 | 10 | -------------------------------------------------------------------------------- /test/pushseg.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -opushseg.bin; Files=stdout stderr pushseg.bin 2 | 3 | bits 16 4 | 5 | push cs 6 | push ds 7 | push es 8 | push ss 9 | push fs 10 | push gs 11 | 12 | pop gs 13 | pop fs 14 | pop ss 15 | pop es 16 | pop ds 17 | pop cs ; 8086 only, does not disassemble 18 | -------------------------------------------------------------------------------- /test/a32offs.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -oa32offs.bin; Files=a32offs.bin stdout stderr 2 | ;Testname=optimized; Arguments=-Ox -fbin -oa32offs.bin; Files=a32offs.bin stdout stderr 3 | bits 16 4 | foo: a32 loop foo 5 | bar: loop bar, ecx 6 | 7 | bits 32 8 | baz: a16 loop baz 9 | qux: loop qux, cx 10 | -------------------------------------------------------------------------------- /test/insnlbl.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oinsnlbl.bin; Files=stdout stderr insnlbl.bin 2 | 3 | ; 4 | ; Test "instruction as label" -- make opcodes legal as labels if 5 | ; they are followed by a colon. 6 | ; 7 | 8 | do: jmp dq+2 9 | dw do, add, sub, dq 10 | add: jmp add-2 11 | sub: jmp do+2 12 | dq: dw $-sub 13 | -------------------------------------------------------------------------------- /rdoff/test/rdfseg2.asm: -------------------------------------------------------------------------------- 1 | ;; library function for rdfseg - this file is linked as a far segment 2 | 3 | [BITS 16] 4 | [GLOBAL _puts] 5 | _puts: 6 | ;; can't remember how to print a string in DOS, but if anyone wants 7 | ;; to actually test this program, it should be fairly easy to put 8 | ;; in here! 9 | 10 | retf 11 | 12 | -------------------------------------------------------------------------------- /test/br3109604.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3109604.bin; Files=stdout stderr br3109604.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3109604.bin; Files=stdout stderr br3109604.bin 3 | 4 | bits 64 5 | b0: vmovd xmm2, [rdx+r9] 6 | e0: 7 | 8 | section .data 9 | len: dd e0 - b0 ; Should be 6 10 | -------------------------------------------------------------------------------- /test/hle.asm: -------------------------------------------------------------------------------- 1 | bits 32 2 | 3 | xacquire lock add [esi],eax 4 | xacquire xchg [eax],ebx 5 | xrelease lock mov [eax],ecx 6 | xrelease mov [eax],ecx 7 | xacquire add ecx,[eax] 8 | xrelease mov [eax],ecx 9 | 10 | ; Different opcodes! 11 | mov [sym],eax 12 | xrelease mov [sym],eax 13 | xacquire mov [sym],eax 14 | 15 | sym dd 0 16 | -------------------------------------------------------------------------------- /test/invlpga.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -oinvlpga.bin; Files=stdout stderr invlpga.bin 2 | ;Testname=optimized; Arguments=-fbin -oinvlpga.bin -Ox; Files=stdout stderr invlpga.bin 3 | 4 | bits 32 5 | invlpga 6 | invlpga ax,ecx 7 | invlpga eax,ecx 8 | bits 64 9 | invlpga 10 | invlpga eax,ecx 11 | invlpga rax,ecx 12 | -------------------------------------------------------------------------------- /misc/pmw.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem some batch file to bind nasm and ndisasm with pmode/w 3 | rem a mega cool dos extender for watcom done by tran 4 | rem 5 | rem max 8 megs, dpmi stack 256*16=4096, no banner 6 | pmwlite.exe nasm.exe 7 | pmwsetup.exe /X8388608 /P256 /B0 nasm.exe 8 | pmwlite.exe ndisasm.exe 9 | pmwsetup.exe /X8388608 /P256 /B0 ndisasm.exe 10 | -------------------------------------------------------------------------------- /test/riprel2.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -oriprel2.bin -O0; Files=stdout stderr riprel.bin 2 | ;Testname=optimized; Arguments=-fbin -oriprel2.bin -Ox; Files=stdout stderr riprel.bin 3 | 4 | bits 64 5 | 6 | default rel 7 | mov dword [foo],12345678h 8 | mov qword [foo],12345678h 9 | mov [foo],rax 10 | mov dword [foo],12345678h 11 | foo: 12 | -------------------------------------------------------------------------------- /test/br3174983.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3174983.bin; Files=stdout stderr br3174983.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3174983.bin; Files=stdout stderr br3174983.bin 3 | 4 | bits 32 5 | vpextrw ecx,xmm0,8 ; c5 f9 c5 c8 08 6 | vpextrw ecx,xmm2,3 ; c5 f9 c5 ca 03 7 | 8 | bits 64 9 | vpextrw rcx,xmm0,8 ; c5 f9 c5 c8 08 10 | -------------------------------------------------------------------------------- /test/zerobyte.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ozerobyte.bin; Files=stdout stderr zerobyte.bin 2 | bits 64 3 | 4 | mov eax,bar-foo 5 | 6 | foo: 7 | add al,r10b 8 | bar: 9 | 10 | lldt ax 11 | lldt r8w 12 | ltr [rax] 13 | sldt eax 14 | sldt r8d 15 | str eax 16 | str rax 17 | str r8d 18 | str r8 19 | verr ax 20 | verr r8w 21 | verw ax 22 | verw r8w 23 | -------------------------------------------------------------------------------- /test/r13.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -or13.bin; Files=stdout stderr r13.bin 2 | 3 | bits 64 4 | mov rax,[rbx] 5 | mov rax,[rbx*4] 6 | mov rax,[rbx+rbx*2] 7 | mov rax,[r13+rbx*2] 8 | mov rax,[rbp] 9 | mov rax,[rbp*4] 10 | mov rax,[rbp+rbp*2] 11 | mov rax,[rbp+r13*2] 12 | mov rax,[r13] 13 | mov rax,[r13*4] 14 | mov rax,[r13+rbp*2] 15 | mov rax,[r13+r13*2] 16 | -------------------------------------------------------------------------------- /test/br2003451.asm: -------------------------------------------------------------------------------- 1 | ;Testname=optimized; Arguments=-Ox -fbin -obr2003451.bin; Files=stdout stderr br2003451.bin 2 | 3 | cpu 8086 4 | org 0 5 | 6 | ; MOV r/m16,imm16 7 | ; (imm16 given as number) 8 | mov word [bx], 10h 9 | 10 | ; MOV r/m16,imm16 11 | ; (imm16 given as label) 12 | mov word [bx], label 13 | 14 | align 10h 15 | 16 | ; This label is at address 10h 17 | label: 18 | -------------------------------------------------------------------------------- /test/nop.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -onop.bin; Files=stdout stderr nop.bin 2 | ;Testname=optimized; Arguments=-fbin -onop.bin -Ox; Files=stdout stderr nop.bin 3 | 4 | bits 64 5 | 6 | nop 7 | o64 nop 8 | pause 9 | o64 pause 10 | 11 | xchg ax,ax 12 | xchg eax,eax 13 | xchg rax,rax 14 | 15 | rep xchg ax,ax 16 | rep xchg eax,eax 17 | rep xchg rax,rax 18 | -------------------------------------------------------------------------------- /test/testdos.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -otestdos.bin; Files=stdout stderr testdos.bin 2 | ; 3 | ; This file was known to miscompile with the 16-bit NASM built 4 | ; under Borland C++ 3.1, so keep it around for testing... 5 | ; 6 | ; The proper output looks like: 7 | ; 8 | ; 00000000 A10300 9 | ; 00000003 EA0000FFFF 10 | ; 11 | org 0100h 12 | mov ax,[3] 13 | jmp 0FFFFh:0000 14 | -------------------------------------------------------------------------------- /test/br3026808.asm: -------------------------------------------------------------------------------- 1 | ;Testname=br3026808; Arguments=-Ox -fbin -obr3026808.o; Files=stdout stderr br3026808.o 2 | 3 | %imacro proc 1 4 | %push proc 5 | %assign %$arg 1 6 | %endmacro 7 | 8 | %imacro arg 0-1 1 9 | %assign %$arg %1+%$arg 10 | %endmacro 11 | 12 | %imacro endproc 0 13 | %pop 14 | %endmacro 15 | 16 | ;---------------------------- 17 | 18 | proc Test 19 | %$ARG arg 20 | endproc 21 | -------------------------------------------------------------------------------- /test/br3058845.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3058845.bin; Files=stdout stderr br3058845.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3058845.bin; Files=stdout stderr br3058845.bin 3 | 4 | BITS 16 5 | cmp ax, 0xFFFF 6 | cmp eax, 0xFFFF_FFFF 7 | 8 | BITS 32 9 | cmp ax, 0xFFFF 10 | cmp eax, 0xFFFF_FFFF 11 | 12 | BITS 64 13 | cmp ax, 0xFFFF 14 | cmp eax, 0xFFFF_FFFF 15 | -------------------------------------------------------------------------------- /test/loopoffs.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -oloopoffs.bin -O0; Files=stdout stderr loopoffs.bin 2 | ;Testname=optimized; Arguments=-fbin -oloopoffs.bin -Ox; Files=stdout stderr loopoffs.bin 3 | bits 16 4 | delay: loop delay 5 | loop $ 6 | delay2: a32 loop delay2 7 | a32 loop $ 8 | delay3: loop delay3,ecx 9 | loop $,ecx 10 | delay4: a32 loop delay4,ecx 11 | a32 loop $,ecx 12 | -------------------------------------------------------------------------------- /test/perf/label.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Generate a test case for label lookup performance 4 | # 5 | 6 | ($len) = @ARGV; 7 | $len = 100000 unless ($len); 8 | 9 | print "\tbits 32\n"; 10 | print "\tsection .data\n"; 11 | print "\n"; 12 | 13 | for ($i = 0; $i < $len; $i++) { 14 | print "l$i:\n"; 15 | for ($j = 0; $j < 8; $j++) { 16 | print "\tdd l", int(rand($i+1)), "\n"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/br3092924.asm: -------------------------------------------------------------------------------- 1 | %define RNUM 0x10000 ; max of relocations in a section is 0xffff 2 | 3 | section .data1 4 | r1 dd RNUM 5 | 6 | section .data2 7 | r2 dd RNUM 8 | 9 | %macro x1 1 10 | mov eax, [r1 + %1] 11 | %endmacro 12 | 13 | %macro x2 1 14 | mov eax, [r2 + %1] 15 | %endmacro 16 | 17 | section .text1 18 | 19 | %assign i 0 20 | %rep RNUM 21 | x1 i 22 | x2 i 23 | %assign i i+1 24 | %endrep 25 | 26 | -------------------------------------------------------------------------------- /test/perf/macro.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Generate a test case for macro lookup performance 4 | # 5 | 6 | ($len) = @ARGV; 7 | $len = 100000 unless ($len); 8 | 9 | print "\tbits 32\n"; 10 | print "\tsection .data\n"; 11 | print "\n"; 12 | 13 | for ($i = 0; $i < $len; $i++) { 14 | print "%define m$i $i\n"; 15 | for ($j = 0; $j < 8; $j++) { 16 | print "\tdd m", int(rand($i+1)), "\n"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/br3385573.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr3385573.bin; Files=stdout stderr br3385573.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr3385573.bin; Files=stdout stderr br3385573.bin 3 | [bits 64] 4 | 5 | vpmovsxbw ymm1, xmm2 6 | vpsllw ymm1, ymm2, 3 7 | vpslld ymm1, ymm2, 3 8 | vpsllq ymm1, ymm2, 3 9 | vpsrld ymm1, ymm2, 3 10 | vpsrad ymm1, ymm2, 3 11 | vpermq ymm1, [rsi], 9 12 | -------------------------------------------------------------------------------- /test/org.asm: -------------------------------------------------------------------------------- 1 | ;Testname=elf64; Arguments=-Ox -felf64 -oorg.o; Files=stdout stderr org.o 2 | ;Testname=win64; Arguments=-Ox -fwin64 -oorg.o; Files=stdout stderr org.o 3 | 4 | ; 5 | ; Simple test of a 64-bit org directive 6 | ; 7 | bits 64 8 | org 0xffffffffffff0000 9 | 10 | hello: jmp there 11 | nop 12 | nop 13 | there: 14 | add rax,[rsp+rbx] 15 | inc eax 16 | 17 | section .data 18 | there_ptr dq there 19 | -------------------------------------------------------------------------------- /test/andbyte.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oandbyte.bin; Files=stdout stderr andbyte.bin 2 | ;Testname=otest; Arguments=-Ox -fbin -oandbyte.bin; Files=stdout stderr andbyte.bin 3 | 4 | bits 16 5 | 6 | add sp, byte -0x10 7 | add sp, -0x10 8 | adc sp, byte -0x10 9 | adc sp, -0x10 10 | and sp, byte -0x10 11 | and sp, -0x10 12 | sbb sp, byte -0x10 13 | sbb sp, -0x10 14 | sub sp, byte -0x10 15 | sub sp, -0x10 16 | -------------------------------------------------------------------------------- /test/local.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -olocal.bin; Files=stdout stderr local.bin 2 | bits 32 3 | 4 | %push bluttan 5 | 6 | %define %$localsize 0 7 | 8 | %stacksize flat 9 | %local l1:qword, l2:dword, l3:dword, l4:qword 10 | %arg a1:qword, a2:dword, a3:dword, a4:qword 11 | 12 | mov eax,[a1] 13 | mov ebx,[a2] 14 | mov ecx,[a3] 15 | mov edx,[a4] 16 | mov [l1],eax 17 | mov [l2],ebx 18 | mov [l3],ecx 19 | mov [l4],edx 20 | -------------------------------------------------------------------------------- /test/xcrypt.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oxcrypt.bin; Files=stdout stderr xcrypt.bin 2 | ; BR 2029829 3 | 4 | bits 32 5 | 6 | rep xstore 7 | rep xcryptecb 8 | rep xcryptcbc 9 | rep xcryptctr 10 | rep xcryptcfb 11 | rep xcryptofb 12 | rep montmul 13 | rep xsha1 14 | rep xsha256 15 | 16 | xstore 17 | xcryptecb 18 | xcryptcbc 19 | xcryptctr 20 | xcryptcfb 21 | xcryptofb 22 | montmul 23 | xsha1 24 | xsha256 25 | -------------------------------------------------------------------------------- /rdoff/test/testlib.asm: -------------------------------------------------------------------------------- 1 | ; program to test retrieval of and linkage to modules in libraries by 2 | ; ldrdf 3 | 4 | [SECTION .text] 5 | [GLOBAL _main] 6 | [EXTERN _strcmp] 7 | 8 | _main: 9 | push dword string1 10 | push dword string2 11 | call _strcmp 12 | add esp,8 ; doh! clear up stack ;-) 13 | ret 14 | 15 | [SECTION .data] 16 | 17 | string1: db 'abc',0 ; try changing these strings and see 18 | string2: db 'abd',0 ; what happens! 19 | -------------------------------------------------------------------------------- /test/inctest.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oinctest.com; Files=stdout stderr inctest.com 2 | 3 | ; This file, plus inc1.asm and inc2.asm, test NASM's file inclusion 4 | ; mechanism. 5 | ; 6 | ; This produces a DOS .COM file: to assemble, use 7 | ; nasm -f bin inctest.asm -o inctest.com 8 | ; and when run, it should print `hello, world'. 9 | 10 | BITS 16 11 | ORG 0x100 12 | 13 | jmp _main 14 | 15 | %include "inc1.asm" 16 | -------------------------------------------------------------------------------- /test/align13.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -oalign13.bin; Files=stdout stderr align13.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -oalign13.bin; Files=stdout stderr align13.bin 3 | 4 | ; Test of non-power-of-2 alignment 5 | 6 | bits 32 7 | 8 | inc eax 9 | inc eax 10 | align 13 11 | inc eax 12 | inc eax 13 | align 13 14 | inc eax 15 | inc eax 16 | align 13 17 | align 13 ;should do nothing 18 | inc eax 19 | inc eax 20 | -------------------------------------------------------------------------------- /test/align13s.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -oalign13s.bin; Files=stdout stderr align13s.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -oalign13s.bin; Files=stdout stderr align13s.bin 3 | 4 | ; Test of non-power-of-2 alignment 5 | 6 | %use smartalign 7 | 8 | bits 32 9 | 10 | inc eax 11 | inc eax 12 | align 13 13 | inc eax 14 | inc eax 15 | align 13 16 | inc eax 17 | inc eax 18 | align 13 19 | inc eax 20 | inc eax 21 | -------------------------------------------------------------------------------- /test/jmp64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ojmp64.bin; Files=stdout stderr jmp64.bin 2 | 3 | bits 64 4 | jmp rcx 5 | jmp [rax] 6 | jmp qword [rax] 7 | jmp near [rax] 8 | jmp near qword [rax] 9 | jmp far [rax] 10 | jmp far dword [rax] 11 | jmp far qword [rax] 12 | call rcx 13 | call [rax] 14 | call qword [rax] 15 | call near [rax] 16 | call near qword [rax] 17 | call far [rax] 18 | call far dword [rax] 19 | call far qword [rax] 20 | -------------------------------------------------------------------------------- /test/br2222615.asm: -------------------------------------------------------------------------------- 1 | ;Testname=noerror; Arguments=-fbin -obr2222615.bin; Files=stdout stderr br2222615.bin 2 | ;Testname=error; Arguments=-DERROR -fbin -obr2222615.bin; Files=stdout stderr br2222615.bin 3 | 4 | %macro bluttan 0 5 | nop 6 | %endmacro 7 | 8 | %ifnmacro bluttan 9 | %error "bluttan is a macro" 10 | %endif 11 | 12 | %ifmacro blej 13 | %error "blej is not a macro" 14 | %endif 15 | 16 | %ifdef ERROR 17 | %ifnmacro 18 | %endif 19 | %endif 20 | -------------------------------------------------------------------------------- /test/larlsl.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -olarlsl.bin; Files=stdout stderr larlsl.bin 2 | 3 | bits 64 4 | 5 | lar ax,bx 6 | lar ax,[rsi] 7 | lar ax,word [rsi] 8 | lar eax,bx 9 | lar eax,[rsi] 10 | lar eax,word [rsi] 11 | lar rax,bx 12 | lar rax,[rsi] 13 | lar rax,word [rsi] 14 | 15 | lsl ax,bx 16 | lsl ax,[rsi] 17 | lsl ax,word [rsi] 18 | lsl eax,bx 19 | lsl eax,[rsi] 20 | lsl eax,word [rsi] 21 | lsl rax,bx 22 | lsl rax,[rsi] 23 | lsl rax,word [rsi] 24 | -------------------------------------------------------------------------------- /test/prefix66.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oprefix66.bin; Files=stdout stderr prefix66.bin 2 | 3 | BITS 16 4 | cmp ax, 1 5 | o16 cmp ax, 1 6 | o32 cmp ax, 1 7 | 8 | cmp eax, 1 9 | o16 cmp eax, 1 10 | o32 cmp eax, 1 11 | 12 | BITS 32 13 | cmp ax, 1 14 | o16 cmp ax, 1 15 | o32 cmp ax, 1 16 | 17 | cmp eax, 1 18 | o16 cmp eax, 1 19 | o32 cmp eax, 1 20 | 21 | BITS 64 22 | cmp ax, 1 23 | o16 cmp ax, 1 24 | o32 cmp ax, 1 25 | 26 | cmp eax, 1 27 | o16 cmp eax, 1 28 | o32 cmp eax, 1 29 | -------------------------------------------------------------------------------- /lib/snprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * snprintf() 3 | * 4 | * Implement snprintf() in terms of vsnprintf() 5 | */ 6 | 7 | #include "compiler.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "nasmlib.h" 14 | 15 | int snprintf(char *str, size_t size, const char *format, ...) 16 | { 17 | va_list ap; 18 | int rv; 19 | 20 | va_start(ap, format); 21 | rv = vsnprintf(str, size, format, ap); 22 | va_end(ap); 23 | 24 | return rv; 25 | } 26 | -------------------------------------------------------------------------------- /test/nasmformat.asm: -------------------------------------------------------------------------------- 1 | ;Testname=obj; Arguments=-fobj -onasmfomat.o; Files=stdout stderr nasmfomat.o 2 | ;Testname=bin; Arguments=-fbin -onasmfomat.o; Files=stdout stderr nasmfomat.o 3 | ;Testname=rdf; Arguments=-frdf -onasmfomat.o; Files=stdout stderr nasmfomat.o 4 | 5 | %if __OUTPUT_FORMAT__ == 'bin' 6 | 7 | db 'This is binary format file' 8 | 9 | %elif __OUTPUT_FORMAT__ == 'obj' 10 | 11 | db 'This is object format file' 12 | 13 | %else 14 | 15 | db 'This is some other format file' 16 | 17 | %endif 18 | -------------------------------------------------------------------------------- /test/newrdwr.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -onewrdwr.bin; Files=stdout stderr newrdwr.bin 2 | 3 | bits 64 4 | 5 | rdfsbase eax 6 | rdfsbase rax 7 | rdgsbase eax 8 | rdgsbase rax 9 | rdrand ax 10 | rdrand eax 11 | rdrand rax 12 | wrfsbase eax 13 | wrfsbase rax 14 | wrgsbase eax 15 | wrgsbase rax 16 | 17 | osp rdfsbase eax 18 | osp rdfsbase rax 19 | osp rdgsbase eax 20 | osp rdgsbase rax 21 | osp wrfsbase eax 22 | osp wrfsbase rax 23 | osp wrgsbase eax 24 | osp wrgsbase rax 25 | -------------------------------------------------------------------------------- /rdoff/test/rdfseg.asm: -------------------------------------------------------------------------------- 1 | ;; program to test inter-segment production and linkage of RDF objects 2 | 3 | ;; [1] should produce segment base ref 4 | ;; [2] should produce standard relocation 5 | 6 | [GLOBAL _main] 7 | [EXTERN _puts: far] 8 | [BITS 16] 9 | 10 | _main: 11 | mov ax, seg _message ; 0000 [1] 12 | mov ds, ax ; 0003 13 | mov dx, _message ; 0005 [2] 14 | call far _puts ; 0008 [2][1] 15 | xor ax,ax ; 000D 16 | int 21h ; 000F 17 | 18 | [SECTION .data] 19 | _message: db 'Hello, World', 10, 13, 0 20 | -------------------------------------------------------------------------------- /test/bcd.asm: -------------------------------------------------------------------------------- 1 | ;Testname=optimized; Arguments=-Ox -fbin -obcd.bin; Files=stdout stderr bcd.bin 2 | 3 | dt 765432109876543210p 4 | dt -765432109876543210p 5 | dt +765432109876543210p 6 | dt 123p 7 | dt -456p 8 | dt +789p 9 | dt 98765432109876543210p 10 | dt 123.0 11 | dt 0x123p+44 12 | dt 789p 13 | 14 | dt 0p765432109876543210 15 | dt -0p765432109876543210 16 | dt +0p765432109876543210 17 | dt 0p123 18 | dt -0p456 19 | dt +0p789 20 | dt 0p98765432109876543210 21 | dt 123.0 22 | dt 0x123p+44 23 | dt 0p789 24 | -------------------------------------------------------------------------------- /test/absolute.asm: -------------------------------------------------------------------------------- 1 | ;Testname=bin; Arguments=-fbin -oabsolute.bin; Files=stdout stderr absolute.bin 2 | org 7c00h 3 | init_foo: 4 | jmp init_bar 5 | nop 6 | nop 7 | nop 8 | nop 9 | nop 10 | nop 11 | nop 12 | nop 13 | nop 14 | nop 15 | nop 16 | nop 17 | nop 18 | 19 | init_bar: 20 | mov [b1],dl 21 | mov [b2],edx 22 | nop 23 | nop 24 | nop 25 | nop 26 | nop 27 | nop 28 | nop 29 | nop 30 | nop 31 | nop 32 | nop 33 | nop 34 | nop 35 | ret 36 | 37 | absolute init_bar+7 38 | b1: resb 1 39 | b2: resd 6 40 | 41 | -------------------------------------------------------------------------------- /rdoff/hash.h: -------------------------------------------------------------------------------- 1 | /* hash.h Routines to calculate a CRC32 hash value 2 | * 3 | * These routines donated to the NASM effort by Graeme Defty. 4 | * 5 | * The Netwide Assembler is copyright (C) 1996 Simon Tatham and 6 | * Julian Hall. All rights reserved. The software is 7 | * redistributable under the license given in the file "LICENSE" 8 | * distributed in the NASM archive. 9 | */ 10 | 11 | #ifndef RDOFF_HASH_H 12 | #define RDOFF_HASH_H 1 13 | 14 | #include 15 | 16 | uint32_t hash(const char *name); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /rdoff/rdx.1: -------------------------------------------------------------------------------- 1 | .TH RDX 1 "September 6, 1999" "Debian Project" "Debian Manual" 2 | .SH NAME 3 | rdx \- load and execute an RDOFF object 4 | .SH SYNOPSIS 5 | .B rdx 6 | .I object 7 | .SH DESCRIPTION 8 | .B rdx 9 | loads an RDOFF 10 | .IR object , 11 | and then calls 12 | .RB ` _main ', 13 | which it expects to be a C-style function, accepting two parameters, 14 | .I argc 15 | and 16 | .I argv 17 | in normal C style. 18 | .SH AUTHORS 19 | Julian Hall . 20 | .PP 21 | This manual page was written by Matej Vela . 22 | -------------------------------------------------------------------------------- /test/weirdpaste.asm: -------------------------------------------------------------------------------- 1 | ;Testname=preproc; Arguments=-E; Files=stdout stderr 2 | ;Testname=bin; Arguments=-fbin -oweirdpaste.bin; Files=stdout stderr weirdpaste.bin 3 | 4 | %define foo xyzzy 5 | %define bar 1e+10 6 | 7 | %define xyzzy1e 15 8 | 9 | %macro dx 2 10 | %assign xx %1%2 11 | dw xx 12 | %endmacro 13 | 14 | dx foo, bar 15 | 16 | %macro df 2 17 | %assign xy __float32__(%1e+%2) 18 | dd xy 19 | dd %1e+%2 20 | %endmacro 21 | 22 | df 1, 36 23 | df 33, 20 24 | df 0, 2 25 | df 1.2, 5 26 | 27 | 28 | %define N 1e%++%+ 5 29 | dd N, 1e+5 30 | -------------------------------------------------------------------------------- /misc/Nindent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PARAM="-npro -kr -i4 -ts8 -nut -sob -l80 -ss -ncs -cp1" 3 | RES=`indent --version` 4 | V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1` 5 | V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2` 6 | V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3` 7 | if [ $V1 -gt 2 ]; then 8 | PARAM="$PARAM -il0" 9 | elif [ $V1 -eq 2 ]; then 10 | if [ $V2 -gt 2 ]; then 11 | PARAM="$PARAM -il0"; 12 | elif [ $V2 -eq 2 ]; then 13 | if [ $V3 -ge 10 ]; then 14 | PARAM="$PARAM -il0" 15 | fi 16 | fi 17 | fi 18 | exec indent $PARAM "$@" 19 | -------------------------------------------------------------------------------- /test/perf/token.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Generate a test case for token lookup performance 4 | # 5 | 6 | @insns = qw(add sub adc sbb and or xor mov); 7 | @regs = qw(eax ebx ecx edx esp ebp esi edi); 8 | 9 | srand(0); 10 | sub pickone(@) { 11 | return $_[int(rand(scalar @_))]; 12 | } 13 | 14 | ($len) = @ARGV; 15 | $len = 1000000 unless ($len); 16 | 17 | print "\tbits 32\n"; 18 | print "\n"; 19 | 20 | for ($i = 0; $i < $len; $i++) { 21 | print "\t", pickone(@insns), " ", 22 | pickone(@regs), ",", pickone(@regs), "\n"; 23 | } 24 | -------------------------------------------------------------------------------- /test/bisect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Usage: 4 | 5 | # Make a test and a golden file, read ./performtest.pl --help 6 | 7 | # cd nasm 8 | # cp -r test somewhere (copy test dir out of the tree) 9 | # git bisect start HEAD nasm-2.07 (where HEAD is bad and nasm-2.07 is good) 10 | # git bisect run somewhere/test/bisect.sh br2148476 (what you want to test) 11 | 12 | # Done 13 | 14 | 15 | # Slow but sure 16 | ./autogen.sh 17 | ./configure 18 | make 19 | 20 | NASMDIR=$(pwd) 21 | cd $(dirname "$0") 22 | ./performtest.pl "--nasm=$NASMDIR/nasm" "$1.asm" --verbose 23 | -------------------------------------------------------------------------------- /test/uscore.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ouscore.bin; Files=stdout stderr uscore.bin 2 | dd 0x1234_5678 3 | dd 305_419_896 ; Same number as above it 4 | dd 0x1e16 ; NOT a floating-point number! 5 | dd 1e16h ; NOT a floating-point number! 6 | dd 1e16_h ; NOT a floating-point number! 7 | dd $1e16 ; NOT a floating-point number! 8 | dd $1e+16 ; NOT a floating-point number! 9 | dd 1e16 ; THIS is a floating-point number! 10 | dd 1e+16 11 | dd 1.e+16 12 | dd 1e+1_6 13 | dd 1e1_6 14 | dd 1.0e16 15 | dd 1_0e16 ; This is 1e17, not 1e16! 16 | -------------------------------------------------------------------------------- /test/vmread.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ovmread.bin; Files=stdout stderr vmread.bin 2 | 3 | bits 32 4 | vmread dword [0], eax 5 | vmwrite eax, dword [0] 6 | vmread [0], eax 7 | vmwrite eax, [0] 8 | 9 | bits 64 10 | vmread qword [0], rax 11 | vmwrite rax, qword [0] 12 | vmread [0], rax 13 | vmwrite rax, [0] 14 | 15 | %ifdef ERROR 16 | bits 32 17 | vmread qword [0], eax 18 | vmwrite eax, qword [0] 19 | 20 | bits 64 21 | vmread dword [0], eax 22 | vmwrite eax, dword [0] 23 | 24 | vmread qword [0], eax 25 | vmwrite eax, qword [0] 26 | %endif -------------------------------------------------------------------------------- /test/floattest.asm: -------------------------------------------------------------------------------- 1 | ;Testname=optimized; Arguments=-Ox -felf -ofloattest.o; Files=stdout stderr floattest.o 2 | 3 | ; nasm -O99 -f elf32 floattest.asm 4 | ; ld -m elf_i386 -o floattest floattest.o -I/lib/ld-linux.so.2 -lc 5 | 6 | global _start 7 | extern printf 8 | 9 | section .text 10 | _start: 11 | 12 | fld qword [num1] 13 | fadd qword [num2] 14 | sub esp, 8 15 | fstp qword [esp] 16 | push fmt 17 | call printf 18 | add esp, 4*3 19 | 20 | mov eax, 1 21 | xor ebx, ebx 22 | int 80h 23 | 24 | section .data 25 | num1 dq 41.5 26 | num2 dq 0.5 27 | 28 | fmt db "%f", 10, 0 29 | -------------------------------------------------------------------------------- /test/floatize.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -ofloatize.bin; Files=stdout stderr floatize.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -ofloatize.bin; Files=stdout stderr floatize.bin 3 | 4 | %assign x13 13+26 5 | %assign f16 __float16__(1.6e-7) 6 | %assign f32 __float32__(1.6e-7) 7 | %assign f64 __float64__(1.6e-7) 8 | %assign f80m __float80m__(1.6e-7) 9 | %assign f80e __float80e__(1.6e-7) 10 | %assign f128l __float128l__(1.6e-7) 11 | %assign f128h __float128h__(1.6e-7) 12 | 13 | dw f16 14 | dd f32 15 | dq f64 16 | dq f80m 17 | dw f80e 18 | dq f128l 19 | dq f128h 20 | -------------------------------------------------------------------------------- /rdoff/doc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make info documentation 3 | # 4 | 5 | AUXFILES = *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.dvi 6 | 7 | SRCS = rdoff.texi 8 | OUTS = rdoff.info rdoff.html rdoff.ps rdoff.pdf 9 | 10 | 11 | ## Implicit rules 12 | %.html : %.texi 13 | makeinfo --html $< 14 | 15 | %.dvi : %.texi 16 | texi2dvi $< 17 | 18 | %.ps: %.dvi 19 | dvips $< 20 | 21 | %.pdf: %.dvi 22 | dvipdf $< 23 | 24 | 25 | ## Explicit rules 26 | all: info 27 | 28 | info: rdoff.info 29 | 30 | html: rdoff.html 31 | 32 | ps: rdoff.ps 33 | 34 | pdf: rdoff.pdf 35 | 36 | clean: 37 | rm -f $(OUTS) $(AUXFILES) 38 | -------------------------------------------------------------------------------- /test/addr64x.asm: -------------------------------------------------------------------------------- 1 | ;Testname=O0; Arguments=-O0 -fbin -oaddr64.bin; Files=stdout stderr addr64.bin 2 | ;Testname=O1; Arguments=-O1 -fbin -oaddr64.bin; Files=stdout stderr addr64.bin 3 | ;Testname=Ox; Arguments=-Ox -fbin -oaddr64.bin; Files=stdout stderr addr64.bin 4 | bits 64 5 | mov rdx,[rax] 6 | mov eax,[byte rsp+0x01] 7 | mov eax,[byte rsp-0x01] 8 | mov eax,[byte rsp+0xFF] 9 | mov eax,[byte rsp-0xFF] 10 | mov eax,[rsp+0x08] 11 | mov eax,[rsp-0x01] 12 | mov eax,[rsp+0xFF] 13 | mov eax,[rsp-0xFF] 14 | mov rax,[rsp+56] 15 | mov [rsi],dl 16 | mov byte [rsi],'-' 17 | mov [rsi],al 18 | mov byte [rsi],' ' 19 | -------------------------------------------------------------------------------- /test/smartalign16.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -osmartalign16.bin; Files=stdout stderr smartalign16.bin 2 | 3 | %use smartalign 4 | 5 | bits 16 6 | 7 | alignmode nop, 32 8 | add ax,ax 9 | align 32 10 | 11 | alignmode generic, 32 12 | add ax,ax 13 | align 32 14 | 15 | alignmode k7, 32 16 | add ax,ax 17 | align 32 18 | 19 | alignmode k8, 32 20 | add ax,ax 21 | align 32 22 | 23 | alignmode p6, 32 24 | add ax,ax 25 | align 32 26 | 27 | add ecx,ecx 28 | align 32 29 | add edx,edx 30 | align 128 31 | add ebx,ebx 32 | align 256 33 | add esi,esi 34 | align 512 35 | 36 | add edi,edi 37 | -------------------------------------------------------------------------------- /test/smartalign32.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -osmartalign32.bin; Files=stdout stderr smartalign32.bin 2 | 3 | %use smartalign 4 | 5 | bits 32 6 | 7 | alignmode nop, 32 8 | add ax,ax 9 | align 32 10 | 11 | alignmode generic, 32 12 | add ax,ax 13 | align 32 14 | 15 | alignmode k7, 32 16 | add ax,ax 17 | align 32 18 | 19 | alignmode k8, 32 20 | add ax,ax 21 | align 32 22 | 23 | alignmode p6, 32 24 | add ax,ax 25 | align 32 26 | 27 | add ecx,ecx 28 | align 32 29 | add edx,edx 30 | align 128 31 | add ebx,ebx 32 | align 256 33 | add esi,esi 34 | align 512 35 | 36 | add edi,edi 37 | -------------------------------------------------------------------------------- /test/smartalign64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -osmartalign64.bin; Files=stdout stderr smartalign64.bin 2 | 3 | %use smartalign 4 | 5 | bits 64 6 | 7 | alignmode nop, 32 8 | add ax,ax 9 | align 32 10 | 11 | alignmode generic, 32 12 | add ax,ax 13 | align 32 14 | 15 | alignmode k7, 32 16 | add ax,ax 17 | align 32 18 | 19 | alignmode k8, 32 20 | add ax,ax 21 | align 32 22 | 23 | alignmode p6, 32 24 | add ax,ax 25 | align 32 26 | 27 | add ecx,ecx 28 | align 32 29 | add edx,edx 30 | align 128 31 | add ebx,ebx 32 | align 256 33 | add esi,esi 34 | align 512 35 | 36 | add edi,edi 37 | -------------------------------------------------------------------------------- /test/br3005117.asm: -------------------------------------------------------------------------------- 1 | ;Testname=br3005117; Arguments=-Ox -felf -obr3005117.o; Files=stdout stderr br3005117.o 2 | 3 | %macro B_STRUC 1-* 4 | %push foo 5 | %define %$strucname %1 6 | %%top_%$strucname: 7 | %rep %0 - 1 8 | %rotate 1 9 | resb %{$strucname}%1 - ($ - %%top_%$strucname) 10 | %1: 11 | %endrep 12 | resb %{$strucname}_size - ($ - %%top_%$strucname) 13 | %pop 14 | %endmacro 15 | 16 | struc timeval 17 | .tv_sec resd 1 18 | .tv_usec resd 1 19 | endstruc 20 | 21 | mov [timeval_struct.tv_sec], eax 22 | 23 | section .bss 24 | 25 | timeval_struct B_STRUC timeval, .tv_sec, .tv_usec 26 | timeval_struct_len equ $ - timeval_struct 27 | -------------------------------------------------------------------------------- /test/ifenv.asm: -------------------------------------------------------------------------------- 1 | %macro import 1 2 | %defstr %%incfile %!PROJECTBASEDIR/%{1}.inc 3 | %defstr %%decfile %!'PROJECTBASEDIR'/%{1}.dec 4 | db %%incfile, `\n` 5 | db %%decfile, `\n` 6 | %endmacro 7 | 8 | %ifenv PROJECTBASEDIR 9 | import foo 10 | %else 11 | %warning No PROJECTBASEDIR defined 12 | %endif 13 | 14 | %ifenv %!PROJECTBASEDIR 15 | import foo 16 | %else 17 | %warning No PROJECTBASEDIR defined 18 | %endif 19 | 20 | %ifenv 'PROJECTBASEDIR' 21 | import foo 22 | %else 23 | %warning No PROJECTBASEDIR defined 24 | %endif 25 | 26 | %ifenv %!'PROJECTBASEDIR' 27 | import foo 28 | %else 29 | %warning No PROJECTBASEDIR defined 30 | %endif 31 | 32 | -------------------------------------------------------------------------------- /test/popcnt.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -opopcnt.bin; Files=stdout stderr popcnt.bin 2 | 3 | bits 16 4 | 5 | popcnt ax,cx 6 | popcnt ax,[si] 7 | popcnt ax,word [si] 8 | popcnt eax,ecx 9 | popcnt eax,[si] 10 | popcnt eax,dword [si] 11 | 12 | bits 32 13 | 14 | popcnt ax,cx 15 | popcnt ax,[esi] 16 | popcnt ax,word [esi] 17 | popcnt eax,ecx 18 | popcnt eax,[esi] 19 | popcnt eax,dword [esi] 20 | 21 | bits 64 22 | 23 | popcnt ax,cx 24 | popcnt ax,[rsi] 25 | popcnt ax,word [rsi] 26 | popcnt eax,ecx 27 | popcnt eax,[rsi] 28 | popcnt eax,dword [rsi] 29 | popcnt rax,rcx 30 | popcnt rax,[rsi] 31 | popcnt rax,qword [rsi] 32 | -------------------------------------------------------------------------------- /test/gotoff64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=noerr; Arguments=-felf64 -ogotoff64.o; Files=stdout stderr gotoff64.o 2 | ;Testname=err; Arguments=-DERROR -felf64 -ogotoff64.o; Files=stdout stderr gotoff64.o 3 | 4 | bits 64 5 | default rel 6 | 7 | extern foo 8 | 9 | mov r15,[foo wrt ..got] 10 | lea r12,[foo wrt ..got] 11 | %ifdef ERROR 12 | lea rax,[foo wrt ..gotoff] 13 | mov rax,[foo wrt ..gotoff] 14 | %endif 15 | 16 | default abs 17 | 18 | mov r15,[foo wrt ..got] 19 | lea r12,[foo wrt ..got] 20 | mov rax,[qword foo wrt ..got] 21 | %ifdef ERROR 22 | lea rax,[foo wrt ..gotoff] 23 | mov rax,[foo wrt ..gotoff] 24 | %endif 25 | mov rax,[qword foo wrt ..gotoff] 26 | -------------------------------------------------------------------------------- /test/br1879590.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obr1879590.bin; Files=stdout stderr br1879590.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obr1879590.bin; Files=stdout stderr br1879590.bin 3 | 4 | bits 32 5 | 6 | pavgb mm0,[ebx] 7 | pavgb mm0,qword [ebx] 8 | pavgw mm0,[ebx] 9 | pavgw mm0,qword [ebx] 10 | pavgb xmm0,[ebx] 11 | pavgb xmm0,oword [ebx] 12 | pavgw xmm0,[ebx] 13 | pavgw xmm0,oword [ebx] 14 | 15 | bits 64 16 | 17 | pavgb mm0,[rbx] 18 | pavgb mm0,qword [rbx] 19 | pavgw mm0,[rbx] 20 | pavgw mm0,qword [rbx] 21 | pavgb xmm0,[rbx] 22 | pavgb xmm0,oword [rbx] 23 | pavgw xmm0,[rbx] 24 | pavgw xmm0,oword [rbx] 25 | 26 | -------------------------------------------------------------------------------- /doc/pswidth.ph: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Get the width of a PostScript string in font units 4 | # (1000 font units == the font point height) given a set of 5 | # font metrics and an encoding vector. 6 | # 7 | sub ps_width($$$) { 8 | my($str, $met, $encoding) = @_; 9 | my($w) = 0; 10 | my($i,$c,$p); 11 | 12 | $l = length($str); 13 | undef $p; 14 | for ( $i = 0 ; $i < $l ; $i++ ) { 15 | $c = substr($str,$i,1); 16 | $w += $$met{widths}{$encoding->[ord($c)]}; 17 | # The standard PostScript "show" operator doesn't do kerning. 18 | # $w += $$met{kern}{$p.$c}; 19 | $p = $c; 20 | } 21 | 22 | return $w; 23 | } 24 | 25 | # OK 26 | 1; 27 | -------------------------------------------------------------------------------- /test/objexe.asm: -------------------------------------------------------------------------------- 1 | ; Demonstration of how to write an entire .EXE format program as a .OBJ 2 | ; file to be linked. Tested with the VAL free linker. 3 | ; To build: 4 | ; nasm -fobj objexe.asm 5 | ; val objexe.obj,objexe.exe; 6 | ; To test: 7 | ; objexe 8 | ; (should print `hello, world') 9 | 10 | segment code 11 | 12 | ..start: mov ax,data 13 | mov ds,ax 14 | mov ax,stack 15 | mov ss,ax 16 | mov sp,stacktop 17 | 18 | mov dx,hello 19 | mov ah,9 20 | int 0x21 21 | 22 | mov ax,0x4c00 23 | int 0x21 24 | 25 | segment data 26 | hello: db 'hello, world', 13, 10, '$' 27 | 28 | segment stack stack 29 | resb 64 30 | stacktop: 31 | -------------------------------------------------------------------------------- /rdoff/collectn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * collectn.h - header file for 'collection' abstract data type. 3 | * 4 | * This file is public domain, and does not come under the NASM license. 5 | * It, aint32_t with 'collectn.c' implements what is basically a variable 6 | * length array (of pointers). 7 | */ 8 | 9 | #ifndef RDOFF_COLLECTN_H 10 | #define RDOFF_COLLECTN_H 1 11 | 12 | typedef struct tagCollection { 13 | void *p[32]; /* array of pointers to objects */ 14 | 15 | struct tagCollection *next; 16 | } Collection; 17 | 18 | void collection_init(Collection * c); 19 | void **colln(Collection * c, int index); 20 | void collection_reset(Collection * c); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /test/struc.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ostruc.bin; Files=stdout stderr struc.bin 2 | 3 | bits 32 4 | 5 | ; Simple struc example 6 | struc teststruc1 7 | .long: resd 1 8 | .word: resw 1 9 | .byte: resb 1 10 | .str: resb 32 11 | endstruc 12 | 13 | ; Reference with offset 14 | mov [ebp - 40 + teststruc1.word], ax 15 | 16 | istruc teststruc1 17 | at .word, db 5 18 | iend 19 | 20 | ; Struc with base offset 21 | ; should be the same as the previous stuc 22 | struc teststruc2, -40 23 | .long: resd 1 24 | .word: resw 1 25 | .byte: resb 1 26 | .str: resb 32 27 | endstruc 28 | 29 | mov [ebp + teststruc2.word], ax 30 | 31 | istruc teststruc2 32 | at .word, db 5 33 | iend 34 | -------------------------------------------------------------------------------- /test/br560873.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -frdf -obr560873.rdf; Files=stdout stderr br560873.rdf 2 | ;Testname=optimized; Arguments=-Ox -frdf -obr560873.rdf; Files=stdout stderr br560873.rdf 3 | 4 | label: 5 | bits 16 6 | call far dword label 7 | mov [label],ax 8 | mov [label],eax 9 | mov [word label],ax 10 | mov [word label],eax 11 | mov [dword label],ax 12 | mov [dword label],eax 13 | push 3700 14 | push word 3700 15 | push dword 3700 16 | 17 | bits 32 18 | call far word label 19 | mov [label],ax 20 | mov [label],eax 21 | mov [word label],ax 22 | mov [word label],eax 23 | mov [dword label],ax 24 | mov [dword label],eax 25 | push 3700 26 | push word 3700 27 | push dword 3700 28 | -------------------------------------------------------------------------------- /contrib/VSrules/nasm.README: -------------------------------------------------------------------------------- 1 | Visual Studio 2008 NASM integration 2 | 3 | 4 | In order to use nasm seamlessly in your VS2k8, follow the steps below. 5 | 6 | 1. First install nasm by running its installer 7 | 2. copy nasm.rules to c:\Program Files\Microsoft Visual Studio 2008\VC\VCProjectDefaults 8 | 3. Start Visual Studio 2008 9 | 4. go to Tools->Options->VC++ Directories 10 | 5. click on Show Directories for Executables 11 | 6. add C:\Program Files\NASM to the list of paths 12 | 7. Open a solution that you want to use NASM with 13 | 8. Right click on the project name and select Custom Build Rules 14 | 9. Check the box next to the NASM line 15 | 10. Add any .asm files to the project 16 | 11. click on build to test 17 | -------------------------------------------------------------------------------- /test/crc32.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -ocrc32.bin; Files=stdout stderr crc32.bin 2 | 3 | bits 16 4 | 5 | crc32 eax,cl 6 | crc32 eax,byte [di] 7 | crc32 eax,cx 8 | crc32 eax,word [di] 9 | crc32 eax,ecx 10 | crc32 eax,dword [di] 11 | 12 | bits 32 13 | align 16 14 | 15 | crc32 eax,cl 16 | crc32 eax,byte [edi] 17 | crc32 eax,cx 18 | crc32 eax,word [edi] 19 | crc32 eax,ecx 20 | crc32 eax,dword [edi] 21 | 22 | bits 64 23 | align 16 24 | 25 | crc32 eax,cl 26 | crc32 eax,byte [rdi] 27 | crc32 eax,r9b 28 | crc32 eax,cx 29 | crc32 eax,word [rdi] 30 | crc32 eax,ecx 31 | crc32 eax,dword [rdi] 32 | crc32 rax,cl 33 | crc32 rax,byte [rdi] 34 | crc32 rax,r9b 35 | crc32 rax,rcx 36 | crc32 rax,qword [rdi] 37 | crc32 rax,r9 38 | -------------------------------------------------------------------------------- /test/ifelse.asm: -------------------------------------------------------------------------------- 1 | ;Testname=ifelse; Arguments=-fbin -oifelse.bin; Files=stdout stderr ifelse.bin 2 | 3 | ;No problems -> db 3 4 | %if 0 5 | db 0 6 | %elif 0 > 0 7 | db 1 8 | %elif 1 < 1 9 | db 2 10 | %else 11 | db 3 12 | %endif 13 | 14 | ;Garbage after else, elif after else -> db 5 15 | %if 0 16 | db 4 17 | %else trailing garbage 18 | db 5 19 | %elif 1 20 | db 6 21 | %endif 22 | 23 | ;Garbage after endif -> 24 | %if 0 25 | db 7 26 | %endif trailing garbage 27 | 28 | ;else after else -> db 9 29 | %if 0 30 | db 8 31 | %else 32 | db 9 33 | %else 34 | db 10 35 | %endif 36 | 37 | ;Problem preprocessed out, no warning -> 38 | %if 0 39 | %if 1 40 | db 11 41 | %else 42 | db 12 43 | %else 44 | db 13 45 | %endif 46 | %endif 47 | -------------------------------------------------------------------------------- /test/test67.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -otest67.bin -O0; Files=stdout stderr test67.bin 2 | ;Testname=optimized; Arguments=-fbin -otest67.bin -Ox; Files=stdout stderr test67.bin 3 | 4 | bits 16 5 | 6 | mov ax,[bx] 7 | mov ax,[foo] 8 | mov ax,[word foo] 9 | mov ax,[dword foo] 10 | mov ax,[ebx] 11 | rep movsb 12 | a16 rep movsb 13 | a32 rep movsb 14 | a32 mov ax,bx 15 | 16 | bits 32 17 | 18 | mov ax,[bx] 19 | mov ax,[foo] 20 | mov ax,[word foo] 21 | mov ax,[dword foo] 22 | mov ax,[ebx] 23 | rep movsb 24 | a16 rep movsb 25 | a32 rep movsb 26 | 27 | bits 64 28 | 29 | mov ax,[rbx] 30 | mov ax,[foo] 31 | mov ax,[qword foo] 32 | mov ax,[dword foo] 33 | mov ax,[ebx] 34 | rep movsb 35 | a32 rep movsb 36 | a64 rep movsb 37 | 38 | foo: 39 | -------------------------------------------------------------------------------- /misc/hints.txt: -------------------------------------------------------------------------------- 1 | Subject: Re: [nasm-devel] P4 insns 2 | Date: Sat, 05 May 2001 11:39:36 -0500 3 | From: Kyle Markley 4 | Reply-To: nasm-devel@yahoogroups.com 5 | To: nasm-devel@yahoogroups.com 6 | 7 | berkus wrote: 8 | > 9 | > Use The Source, NASM! 10 | > 11 | > Do we have the P4 'probable branch taken' (3e) and 'probable branch 12 | > not taken' (2e) prefixes opcodes? 13 | 14 | They're just segment override prefixes: 2e is CS, 3e is DS. You can just 15 | say 16 | "cs jnz foo" for a not-taken hint, "ds jnz foo" for a taken hint. 17 | 18 | Maybe it would be nice to have a more suggestive name, but you could just 19 | %define one. 20 | 21 | --- 22 | Kyle Markley 23 | 24 | 25 | 26 | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 27 | -------------------------------------------------------------------------------- /perllib/gensv.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Generate a list of rotation vectors so we always use the same set. 4 | # This needs to be run on a platform with /dev/urandom. 5 | # 6 | 7 | ($n) = @ARGV; 8 | 9 | sysopen(UR, '/dev/urandom', O_RDONLY) or die; 10 | 11 | $maxlen = 78; 12 | 13 | print "\@random_sv_vectors = (\n"; 14 | $outl = ' '; 15 | 16 | for ($i = 0; $i < $n; $i++) { 17 | 18 | die if (sysread(UR, $x8, 8) != 8); 19 | @n = unpack("V*", $x8); 20 | 21 | $xl = sprintf(" [0x%08x, 0x%08x]%s", 22 | $n[0], $n[1], 23 | ($i == $n-1) ? '' : ','); 24 | if (length($outl.$xl) > $maxlen) { 25 | print $outl, "\n"; 26 | $outl = ' '; 27 | } 28 | $outl .= $xl; 29 | } 30 | close(UR); 31 | 32 | print $outl, "\n"; 33 | print ");\n"; 34 | print "1;\n"; 35 | -------------------------------------------------------------------------------- /misc/c32.mac: -------------------------------------------------------------------------------- 1 | ; NASM macro set to make interfacing to 32-bit programs easier -*- nasm -*- 2 | 3 | 4 | 5 | %imacro proc 1 ; begin a procedure definition 6 | 7 | %push proc 8 | 9 | global %1 10 | 11 | %1: push ebp 12 | 13 | mov ebp,esp 14 | 15 | %assign %$arg 8 16 | 17 | %define %$procname %1 18 | 19 | %endmacro 20 | 21 | 22 | 23 | %imacro arg 0-1 4 ; used with the argument name as a label 24 | 25 | %00 equ %$arg 26 | 27 | %assign %$arg %1+%$arg 28 | 29 | %endmacro 30 | 31 | 32 | 33 | %imacro endproc 0 34 | 35 | %ifnctx proc 36 | 37 | %error Mismatched `endproc'/`proc' 38 | 39 | %else 40 | 41 | leave 42 | 43 | ret 44 | 45 | __end_%$procname: ; useful for calculating function size 46 | 47 | %pop 48 | 49 | %endif 50 | 51 | %endmacro 52 | 53 | -------------------------------------------------------------------------------- /rdoff/test/rdtlib.asm: -------------------------------------------------------------------------------- 1 | ;; library functions for rdtmain - test of rdx linking and execution 2 | 3 | ;; library function = _strcmp, defined as in C 4 | 5 | [SECTION .text] 6 | [BITS 32] 7 | 8 | [GLOBAL _strcmp] 9 | _strcmp: 10 | push ebp 11 | mov ebp,esp 12 | 13 | ;; ebp+8 = first paramater, ebp+12 = second 14 | 15 | mov esi,[ebp+8] 16 | mov edi,[ebp+12] 17 | 18 | .loop: 19 | mov cl,byte [esi] 20 | mov dl,byte [edi] 21 | cmp cl,dl 22 | jb .below 23 | ja .above 24 | or cl,cl 25 | jz .match 26 | inc esi 27 | inc edi 28 | jmp .loop 29 | 30 | .below: 31 | mov eax,-1 32 | pop ebp 33 | ret 34 | 35 | .above: 36 | mov eax,1 37 | pop ebp 38 | ret 39 | 40 | .match: 41 | xor eax,eax 42 | pop ebp 43 | ret 44 | 45 | [SECTION .data] 46 | [GLOBAL _message] 47 | 48 | _message: db 'hello',0 -------------------------------------------------------------------------------- /rdoff/test/rdftest2.asm: -------------------------------------------------------------------------------- 1 | ;; rdftest2.asm - test linkage and generation of RDOFF files 2 | 3 | [SECTION .text] 4 | [BITS 32] 5 | 6 | [GLOBAL _farproc] 7 | [EXTERN _test1proc] 8 | [EXTERN localdata2] 9 | [EXTERN _term] 10 | _farproc: 11 | 12 | mov bx,localdata2 ; [4] 0 => 66 bb 000a(+0) 13 | mov eax,_term ; [3] 5 => b8 00000000(+26+0) 14 | call _test1proc ; [6] A => e8 fffffff2(-40+0+31)(=ffffffe3) 15 | 16 | mov eax,_farproc ; [1] => b8 00000000(+40) 17 | add eax,[_fardata] ; [2] => 03 05 00000000(+20) 18 | 19 | mov ebx,mybssdata ; [7] => bb 00000000(+08) 20 | call myproc ; [5] => e8 00000001 21 | ret 22 | 23 | myproc: 24 | add eax,ebx 25 | ret 26 | 27 | [SECTION .data] 28 | [GLOBAL _fardata] 29 | _fardata: dw _term ; [4] 30 | _localref: dd _farproc ; [2] 31 | 32 | [SECTION .bss] 33 | mybssdata: resw 1 34 | -------------------------------------------------------------------------------- /test/floatb.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -ofloatb.bin; Files=stdout stderr floatb.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -ofloatb.bin; Files=stdout stderr floatb.bin 3 | 4 | ;; Known problematic floating-point numbers and their proper 5 | ;; encoding... 6 | 7 | bits 64 8 | 9 | dd 1.1e10 10 | dd 0x5023e9ac ; Should be... 11 | 12 | dd 50.40e9 13 | dd 0x513bc130 ; Should be... 14 | 15 | dq 1.4e23 16 | dq 0x44bda56a4b0835c0 17 | 18 | dq 50.48e21 19 | dq 0x44a5610d7502feae 20 | 21 | dt 1.2e28 22 | dq 0x9b18ab5df7180b6c 23 | dw 0x405c 24 | 25 | dt 50.46e25 26 | dq 0xd0b29a67e95dcb60 27 | dw 0x4057 28 | 29 | ;; Way too big numbers, should overflow to +Inf 30 | dd 1.0E646456955 31 | dd 1.0E646456956 32 | dd 1.0E2147483646 33 | dd 1.0E2147483647 34 | dd 1.0E2147483648 35 | dd 1.0E2147483649 36 | -------------------------------------------------------------------------------- /test/ppindirect.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-E -o ppindirect.out; Files=ppindirect.out 2 | 3 | ; Fun tests of the preprocessor indirection mode... 4 | 5 | %assign foo1 11 6 | %assign foo11 1111 7 | %assign foo2 22 8 | %assign foo22 2222 9 | %assign foo3 33 10 | %assign foo33 3333 11 | %assign n 2 12 | foo%[foo%[n]]*100 13 | foo%[n]*100 14 | %assign foo%[foo%[n]] foo%[foo%[n]]*100 15 | ;%assign foo%[n] foo%[n]*100 16 | 17 | foo1 18 | foo2 19 | foo3 20 | foo11 21 | foo22 22 | foo33 23 | 24 | %define foo33bar 999999 25 | %[foo%[foo3]bar] 26 | 27 | %assign bctr 0 28 | %macro bluttan 0 29 | %assign bctr bctr+1 30 | %assign bluttan%[bctr] bctr 31 | %defstr bstr bluttan%[bctr] 32 | bluttan%[bctr] 33 | bstr 34 | %endmacro 35 | 36 | %rep 20 37 | bluttan 38 | %endrep 39 | %rep 20 40 | bluttan%[bctr] 41 | %assign bctr bctr-1 42 | %endrep 43 | -------------------------------------------------------------------------------- /contrib/MSVC6.txt: -------------------------------------------------------------------------------- 1 | Compilation with Nasm on MSVC 6.0, with usage of Custom Build step. 2 | 3 | 1) Open your project in MSVC. 4 | 5 | 2) Add .asm at the list of source files. 6 | 7 | 3) Click on it with the right button, further press Settings... 8 | 9 | 4) In General tab, flags "Always use custom build step" and "Exclude file 10 | from build" should be disabled. 11 | 12 | 5) In "Custom Build" tab it is necessary to define "Commands" and "Outputs" 13 | (By "Outputs" build system checks if it has reached a necessary result. 14 | This parameter is mandatory and without it MSVC will not let you close 15 | the window by OK button). 16 | 17 | The "Commands" should be set to 18 | 19 | nasmw.exe -fwin -o $(OUTDIR)\$(InputName).obj $(InputName).asm 20 | 21 | And "Outputs" to 22 | 23 | $(OUTDIR)\$(InputName).obj 24 | 25 | Have fun! 26 | -------------------------------------------------------------------------------- /rdoff/rdfdump.1: -------------------------------------------------------------------------------- 1 | .TH RDFDUMP 1 "September 6, 1999" "Debian Project" "Debian Manual" 2 | .SH NAME 3 | rdfdump \- dumps an RDOFF object in human-readable form 4 | .SH SYNOPSIS 5 | .B rdfdump 6 | [-v] 7 | .RI < filename > 8 | .SH DESCRIPTION 9 | .B rdfdump 10 | prints a list of the header records in an RDOFF object in human-readable 11 | form, and optionally prints a hex dump of the contents of the segments. 12 | .PP 13 | .B rdfdump 14 | supports both version 1 and 2 of RDOFF. It will give warnings if the RDOFF2 15 | format is violated (it looks for incorrect lengths for header records, and 16 | checks the overall length count at the start of the file). 17 | .SH OPTIONS 18 | .TP 19 | -v 20 | Print a hex dump of the contents of the segments. 21 | .SH AUTHORS 22 | Julian Hall . 23 | .PP 24 | This manual page was written by Matej Vela . 25 | -------------------------------------------------------------------------------- /test/riprel.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | print ";Testname=unoptimized; Arguments=-fbin -oriprel.bin -O0; Files=stdout stderr riprel.bin\n"; 4 | print ";Testname=optimized; Arguments=-fbin -oriprel.bin -Ox; Files=stdout stderr riprel.bin\n"; 5 | 6 | 7 | print "\tbits 64\n"; 8 | 9 | foreach $mode ('abs', 'rel') { 10 | print "\n\tdefault $mode\n\n"; 11 | 12 | foreach $so ('', 'fs:', 'es:') { 13 | foreach $rq ('', 'abs ', 'rel ') { 14 | foreach $ao ('', 'a64 ', 'a32 ') { 15 | foreach $sq ('', 'dword ', 'qword ') { 16 | foreach $v ('foo', '0xaaaaaaaaaaaaaaaa', '0xbbbbbbbb', 17 | '0xffffffffcccccccc') { 18 | foreach $r ( 'al', 'bl', 'ax', 'bx', 'eax', 'ebx', 'rax', 'rbx') { 19 | print "\tmov $r,[$ao$rq$sq$so$v]\n"; 20 | } 21 | } 22 | print "\n"; 23 | } 24 | } 25 | } 26 | } 27 | } 28 | 29 | print "\nfoo:\n"; 30 | -------------------------------------------------------------------------------- /test/iftoken.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | @list = ('', 'ZMACRO', 'NMACRO', 'TMACRO', '1', '+1', '1 2', '1,2', 4 | 'foo', 'foo bar', '%', '+foo', '<<'); 5 | @tests = ('token', 'empty'); 6 | 7 | print ";Testname=test; Arguments=-fbin -oiftoken.txt; Files=stdout stderr iftoken.txt" 8 | print "%define ZMACRO\n"; 9 | print "%define NMACRO 1\n"; 10 | print "%define TMACRO 1 2\n"; 11 | 12 | foreach $x (@list) { 13 | print "\tdb 'N \"$x\":'\n"; 14 | foreach $t (@tests) { 15 | print "%if$t $x\n"; 16 | print "\tdb ' $t'\n"; 17 | print "%else\n"; 18 | print "\tdb ' n$t'\n"; 19 | print "%endif\n"; 20 | } 21 | print "\tdb 10\n"; 22 | 23 | print "\tdb 'C \"$x\":'\n"; 24 | foreach $t (@tests) { 25 | print "%if$t $x ; With a comment!\n"; 26 | print "\tdb ' $t'\n"; 27 | print "%else\n"; 28 | print "\tdb ' n$t'\n"; 29 | print "%endif\n"; 30 | } 31 | print "\tdb 10\n"; 32 | } 33 | -------------------------------------------------------------------------------- /test/mmxsize.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -ommxsize.bin -O0; Files=stdout stderr mmxsize.bin 2 | ;Testname=optimized; Arguments=-fbin -ommxsize.bin -Ox; Files=stdout stderr mmxsize.bin 3 | bits 32 4 | movd mm0,eax 5 | movd mm0,[foo] 6 | movq mm0,[foo] 7 | movd mm0,dword [foo] 8 | movq mm0,qword [foo] 9 | movmskps eax,xmm1 10 | movmskpd eax,xmm1 11 | nop 12 | movd xmm0,eax 13 | movd xmm0,[foo] 14 | movq xmm0,[foo] 15 | movd xmm0,dword [foo] 16 | movq xmm0,qword [foo] 17 | nop 18 | 19 | bits 64 20 | movd mm0,eax 21 | movq mm0,[foo] 22 | movd mm0,dword [foo] 23 | movq mm0,qword [foo] 24 | movq mm0,rax 25 | movmskps eax,xmm1 26 | movmskpd eax,xmm1 27 | nop 28 | movd xmm0,eax 29 | movq xmm0,[foo] 30 | movd xmm0,dword [foo] 31 | movq xmm0,qword [foo] 32 | movq xmm0,rax 33 | movmskps rax,xmm1 34 | movmskpd rax,xmm1 35 | nop 36 | 37 | section .bss 38 | foo resq 1 39 | -------------------------------------------------------------------------------- /test/elif.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fobj -oelif.obj; Files=stdout stderr elif.obj 2 | ;Testname=optimized; Arguments=-Ox -fobj -oelif.obj; Files=stdout stderr elif.obj 3 | 4 | %macro DosPrintMsg 1+ 5 | %ifnid %1 6 | section .data 7 | %%str_to_print:db %1 8 | section .text 9 | mov dx,%%str_to_print 10 | mov ah,9 11 | int 0x21 12 | %else 13 | mov dx,(%1) 14 | mov ah,9 15 | int 0x21 16 | %endif 17 | %endmacro 18 | 19 | %macro DosExit 1 20 | %if (%1) == 0 21 | ;use short-form return 0 exit 22 | int 0x20 23 | %elif ((%1) < 256) && ((%1) > 0) 24 | mov ax,0x4C00 | (%1) 25 | int 0x21 26 | %else 27 | %error Invalid return value 28 | %endif 29 | %endmacro 30 | 31 | org 0x100 32 | DosPrintMsg predefined_str 33 | DosPrintMsg "Using string with macro-defined label",10,0 34 | DosExit 0 35 | DosExit 1 36 | DosExit 256 37 | 38 | section .data 39 | predefined_str:db "Using string with predefined label",10,0 40 | -------------------------------------------------------------------------------- /rdoff/rdfload.h: -------------------------------------------------------------------------------- 1 | /* rdfload.h RDOFF Object File loader library header file 2 | * 3 | * The Netwide Assembler is copyright (C) 1996 Simon Tatham and 4 | * Julian Hall. All rights reserved. The software is 5 | * redistributable under the license given in the file "LICENSE" 6 | * distributed in the NASM archive. 7 | * 8 | * See the file 'rdfload.c' for special license information for this 9 | * file. 10 | */ 11 | 12 | #ifndef RDOFF_RDFLOAD_H 13 | #define RDOFF_RDFLOAD_H 1 14 | 15 | #define RDOFF_UTILS 16 | 17 | #include "rdoff.h" 18 | 19 | typedef struct RDFModuleStruct { 20 | rdffile f; /* file structure */ 21 | uint8_t *t, *d, *b; /* text, data, and bss segments */ 22 | uint32_t textrel; 23 | uint32_t datarel; 24 | uint32_t bssrel; 25 | void *symtab; 26 | } rdfmodule; 27 | 28 | rdfmodule *rdfload(const char *filename); 29 | int rdf_relocate(rdfmodule * m); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /test/binexe.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obinexe.exe -i../misc/; Files=stdout stderr binexe.exe 2 | ;Testname=optimized; Arguments=-Ox -fbin -obinexe.exe -i../misc/; Files=stdout stderr binexe.exe 3 | 4 | ; Demonstration of how to write an entire .EXE format program by using 5 | ; the `exebin.mac' macro package. 6 | ; To build: 7 | ; nasm -fbin binexe.asm -o binexe.exe -ipath 8 | ; (where `path' is such as to allow the %include directive to find 9 | ; exebin.mac) 10 | ; To test: 11 | ; binexe 12 | ; (should print `hello, world') 13 | 14 | %include "exebin.mac" 15 | 16 | EXE_begin 17 | EXE_stack 64 ; demonstrates overriding the 0x800 default 18 | 19 | section .text 20 | 21 | mov ax,cs 22 | mov ds,ax 23 | 24 | mov dx,hello 25 | mov ah,9 26 | int 0x21 27 | 28 | mov ax,0x4c00 29 | int 0x21 30 | 31 | section .data 32 | 33 | hello: db 'hello, world', 13, 10, '$' 34 | 35 | EXE_end 36 | -------------------------------------------------------------------------------- /rdoff/collectn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * collectn.c - implements variable length pointer arrays [collections]. 3 | * 4 | * This file is public domain. 5 | */ 6 | 7 | #include "compiler.h" 8 | #include 9 | #include "collectn.h" 10 | 11 | void collection_init(Collection * c) 12 | { 13 | int i; 14 | 15 | for (i = 0; i < 32; i++) 16 | c->p[i] = NULL; 17 | c->next = NULL; 18 | } 19 | 20 | void **colln(Collection * c, int index) 21 | { 22 | while (index >= 32) { 23 | index -= 32; 24 | if (c->next == NULL) { 25 | c->next = malloc(sizeof(Collection)); 26 | collection_init(c->next); 27 | } 28 | c = c->next; 29 | } 30 | return &(c->p[index]); 31 | } 32 | 33 | void collection_reset(Collection * c) 34 | { 35 | int i; 36 | 37 | if (c->next) { 38 | collection_reset(c->next); 39 | free(c->next); 40 | } 41 | 42 | c->next = NULL; 43 | for (i = 0; i < 32; i++) 44 | c->p[i] = NULL; 45 | } 46 | -------------------------------------------------------------------------------- /test/br2496848.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -o br2496848.bin; Files=stdout stderr br2496848.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -o br2496848.bin; Files=stdout stderr br2496848.bin 3 | 4 | bits 64 5 | 6 | foo: 7 | 8 | default abs 9 | 10 | mov al, [qword 0xffffffffffffffff] 11 | mov al, [qword 0x1ffffffffffffffff] 12 | 13 | mov cl, [byte 0x12345678] 14 | 15 | default rel 16 | 17 | mov cl, [foo] 18 | mov cl, [foo + 0x10000000] 19 | mov cl, [foo + 0x100000000] 20 | 21 | mov cl, [0x100] 22 | mov cl, [$$ + 0x100] 23 | 24 | mov cl, [rax - 1] 25 | mov cl, [rax + 0xffffffff] 26 | mov cl, [rax + 0x1ffffffff] 27 | 28 | bits 32 29 | mov cl, [eax - 1] 30 | mov cl, [eax + 0xffffffff] 31 | mov cl, [eax + 0x1ffffffff] 32 | mov cl, [byte eax + 0xffffffff] 33 | mov cl, [byte eax + 0x1ffffffff] 34 | mov cl, [byte eax + 0x1000ffff] 35 | 36 | bits 16 37 | mov cl, [di - 1] 38 | mov cl, [di + 0xffff] 39 | mov cl, [di + 0x1ffff] 40 | mov cl, [byte di + 0xffff] 41 | mov cl, [byte di + 0x1ffff] 42 | mov cl, [byte di + 0x10ff] 43 | -------------------------------------------------------------------------------- /test/br3041451.asm: -------------------------------------------------------------------------------- 1 | ;Testname=br3041451; Arguments=-Ox -fbin -obr3041451.bin; Files=stdout stderr br3041451.bin 2 | 3 | [bits 64] 4 | 5 | ; 6 | ; HIT: Maximum possible value 7 | %assign i 0 8 | %rep ((1<<62)-1) 9 | mov rax, i 10 | %assign i i+1 11 | %if i == 2 12 | %exitrep 13 | %endif 14 | %endrep 15 | 16 | ; 17 | ; MISS: It's negative 18 | %assign i 0 19 | %rep 0xffffFFFFffffFFFE 20 | mov rax, 0xffffFFFFffffFFFE 21 | %assign i i+1 22 | %if i == 2 23 | %exitrep 24 | %endif 25 | %endrep 26 | 27 | ; 28 | ; MISS: It's negative 29 | %assign i 0 30 | %rep 0xffffFFFFffffFFFF 31 | db i 32 | %assign i i+1 33 | %if i == 2 34 | %exitrep 35 | %endif 36 | %endrep 37 | 38 | ; 39 | ; MISS: It's negative 40 | %assign i 0 41 | %rep -2 42 | db i 43 | %assign i i+1 44 | %if i == 2 45 | %exitrep 46 | %endif 47 | %endrep 48 | 49 | ; 50 | ; MISS: It's negative 51 | %assign i 0 52 | %rep -1 53 | db i 54 | %assign i i+1 55 | %if i == 2 56 | %exitrep 57 | %endif 58 | %endrep 59 | 60 | -------------------------------------------------------------------------------- /rdoff/rdflib.1: -------------------------------------------------------------------------------- 1 | .TH RDFLIB 1 "September 6, 1999" "Debian Project" "Debian Manual" 2 | .SH NAME 3 | rdflib \- manage a library file for use with ldrdf(1) 4 | .SH SYNOPSIS 5 | .B rdflib 6 | .I command 7 | .I arguments 8 | .SH DESCRIPTION 9 | .B rdflib 10 | manages a library file which can be used by 11 | .BR ldrdf (1). 12 | It is supplied with a shell script 13 | .B makelib 14 | which should probably be used to create libraries. 15 | .SH COMMANDS 16 | .TP 17 | .BI c " library-file" 18 | Create (or truncate) a library. 19 | .TP 20 | .BI a " library-file object-file module" 21 | Add the 22 | .I object-file 23 | to the library under the name 24 | .IR module . 25 | .TP 26 | .BI x " library-file module object-file" 27 | Extract a 28 | .I module 29 | from the library to the file 30 | .IR object-file . 31 | .TP 32 | .B t " library-file" 33 | Display a list of modules in the library. 34 | .SH NOTES 35 | A remove command will be added soon. 36 | .SH AUTHORS 37 | Julian Hall . 38 | .PP 39 | This manual page was written by Matej Vela . 40 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | NASM, the Netwide Assembler. 2 | 3 | Many many developers all over the net respect NASM for what it is 4 | - a widespread (thus netwide), portable (thus netwide!), very 5 | flexible and mature assembler tool with support for many output 6 | formats (thus netwide!!). 7 | 8 | Now we have good news for you: NASM is licensed under the "simplified" 9 | (2-clause) BSD license. This means its development is open to even 10 | wider society of programmers wishing to improve their lovely 11 | assembler. 12 | 13 | The NASM project is now situated at SourceForge.net, the most 14 | popular Open Source development site on the Internet. 15 | 16 | Visit our website at http://nasm.sourceforge.net/ and our 17 | SourceForge project at http://sourceforge.net/projects/nasm/ 18 | 19 | See the file CHANGES for the description of changes between revisions, 20 | and the file AUTHORS for a list of contributors. 21 | 22 | With best regards, 23 | NASM crew. 24 | -------------------------------------------------------------------------------- /test/br560575.asm: -------------------------------------------------------------------------------- 1 | ;Testname=aout; Arguments=-faout -obr560575.o; Files=stderr stdout br560575.o 2 | ;Testname=aoutb; Arguments=-faoutb -obr560575.o; Files=stderr stdout br560575.o 3 | ;Testname=coff; Arguments=-fcoff -obr560575.o; Files=stderr stdout br560575.o 4 | ;Testname=elf32; Arguments=-felf32 -obr560575.o; Files=stderr stdout br560575.o 5 | ;Testname=elf64; Arguments=-felf64 -obr560575.o; Files=stderr stdout br560575.o 6 | ;Testname=as86; Arguments=-fas86 -obr560575.o; Files=stderr stdout br560575.o 7 | ;Testname=win32; Arguments=-fwin32 -obr560575.o; Files=stderr stdout br560575.o 8 | ;Testname=win64; Arguments=-fwin64 -obr560575.o; Files=stderr stdout br560575.o 9 | ;Testname=rdf; Arguments=-frdf -obr560575.o; Files=stderr stdout br560575.o 10 | ;Testname=ieee; Arguments=-fieee -obr560575.o; Files=stderr stdout br560575.o 11 | ;Testname=macho; Arguments=-fmacho -obr560575.o; Files=stderr stdout br560575.o 12 | 13 | ;Test for bug report 560575 - Using SEG with non-relocatable values doesn't work 14 | ; 15 | dw seg ~1 16 | dw seg "a" 17 | dw seg 'a' 18 | -------------------------------------------------------------------------------- /test/objlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test source file for assembling to Microsoft 16-bit .OBJ 3 | * build with (16-bit Microsoft C): 4 | * nasm -f obj objtest.asm 5 | * cl /AL objtest.obj objlink.c 6 | * other compilers should work too, provided they handle large 7 | * model in the same way as MS C 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | int8_t text[] = "hello, world\n"; 14 | 15 | extern void function(int8_t *); 16 | extern int bsssym, commvar; 17 | extern void *selfptr; 18 | extern void *selfptr2; 19 | 20 | int main(void) 21 | { 22 | printf("these should be identical: %p, %p\n", 23 | (int32_t)selfptr, (int32_t)&selfptr); 24 | printf("these should be equivalent but different: %p, %p\n", 25 | (int32_t)selfptr2, (int32_t)&selfptr2); 26 | printf("you should see \"hello, world\" twice:\n"); 27 | bsssym = 0xF00D; 28 | commvar = 0xD00F; 29 | function(text); 30 | printf("this should be 0xF00E: 0x%X\n", bsssym); 31 | printf("this should be 0xD00E: 0x%X\n", commvar); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /rdoff/rdlar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rdlar.h - definitions of new RDOFF library/archive format. 3 | */ 4 | 5 | #ifndef RDOFF_RDLAR_H 6 | #define RDOFF_RDLAR_H 1 7 | 8 | #include 9 | 10 | #ifdef HAVE_CONFIG_H 11 | #include "config.h" 12 | #endif 13 | 14 | /* For non-POSIX operating systems */ 15 | #ifndef HAVE_GETUID 16 | # define getuid() 0 17 | #endif 18 | #ifndef HAVE_GETGID 19 | # define getgid() 0 20 | #endif 21 | 22 | #define RDLAMAG 0x414C4452 /* Archive magic */ 23 | #define RDLMMAG 0x4D4C4452 /* Member magic */ 24 | 25 | #define MAXMODNAMELEN 256 /* Maximum length of module name */ 26 | 27 | struct rdlm_hdr { 28 | uint32_t magic; /* Must be RDLAMAG */ 29 | uint32_t hdrsize; /* Header size + sizeof(module_name) */ 30 | uint32_t date; /* Creation date */ 31 | uint32_t owner; /* UID */ 32 | uint32_t group; /* GID */ 33 | uint32_t mode; /* File mode */ 34 | uint32_t size; /* File size */ 35 | /* NULL-terminated module name immediately follows */ 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /test/cofftest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test source file for assembling to COFF 3 | * build with (under DJGPP, for example): 4 | * nasm -f coff cofftest.asm 5 | * gcc -o cofftest cofftest.c cofftest.o 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | extern int lrotate(int32_t, int); 12 | extern void greet(void); 13 | extern int8_t asmstr[]; 14 | extern void *selfptr; 15 | extern void *textptr; 16 | extern int integer, commvar; 17 | 18 | int main(void) 19 | { 20 | 21 | printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 22 | printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4)); 23 | printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000, 14)); 24 | 25 | printf("This string should read `hello, world': `%s'\n", asmstr); 26 | 27 | printf("The integers here should be 1234, 1235 and 4321:\n"); 28 | integer = 1234; 29 | commvar = 4321; 30 | greet(); 31 | 32 | printf("These pointers should be equal: %p and %p\n", &greet, textptr); 33 | 34 | printf("So should these: %p and %p\n", selfptr, &selfptr); 35 | } 36 | -------------------------------------------------------------------------------- /test/movimm.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -omovimm.bin -O0; Files=stdout stderr movimm.bin 2 | ;Testname=optimized; Arguments=-fbin -omovimm.bin -Ox; Files=stdout stderr movimm.bin 3 | bits 64 4 | 5 | mov rax,1234567890abcdefh 6 | mov eax,1234567890abcdefh 7 | mov rax,dword 1234567890abcdefh 8 | mov rax,qword 1234567890abcdefh 9 | mov dword [rsi],1234567890abcdefh 10 | mov qword [rsi],1234567890abcdefh 11 | mov dword [rsi],dword 1234567890abcdefh 12 | mov qword [rsi],dword 1234567890abcdefh 13 | ; mov qword [rsi],qword 1234567890abcdefh ; Error 14 | ; mov [rsi],qword 1234567890abcdefh ; Error 15 | mov [rsi],dword 1234567890abcdefh 16 | 17 | ; The optimizer probably should compact these forms, doesn't yet? 18 | mov rax,12345678h 19 | mov eax,12345678h 20 | mov rax,dword 12345678h 21 | mov rax,qword 12345678h 22 | mov dword [rsi],12345678h 23 | mov qword [rsi],12345678h 24 | mov dword [rsi],dword 12345678h 25 | mov qword [rsi],dword 12345678h 26 | ; mov qword [rsi],qword 12345678h ; Error 27 | ; mov [rsi],qword 12345678h ; Error 28 | mov [rsi],dword 12345678h 29 | -------------------------------------------------------------------------------- /test/aouttest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test source file for assembling to a.out 3 | * build with: 4 | * nasm -f aout aouttest.asm 5 | * gcc -o aouttest aouttest.c aouttest.o 6 | * (assuming your gcc is a.out) 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | extern int lrotate(int32_t, int); 13 | extern void greet(void); 14 | extern int8_t asmstr[]; 15 | extern void *selfptr; 16 | extern void *textptr; 17 | extern int integer, commvar; 18 | 19 | int main(void) 20 | { 21 | 22 | printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 23 | printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4)); 24 | printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000, 14)); 25 | 26 | printf("This string should read `hello, world': `%s'\n", asmstr); 27 | 28 | printf("The integers here should be 1234, 1235 and 4321:\n"); 29 | integer = 1234; 30 | commvar = 4321; 31 | greet(); 32 | 33 | printf("These pointers should be equal: %p and %p\n", &greet, textptr); 34 | 35 | printf("So should these: %p and %p\n", selfptr, &selfptr); 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | *.dbg 3 | *.exe 4 | *.lst 5 | *.o 6 | *.o64 7 | *.obj 8 | *.obj64 9 | *.orig 10 | *.out 11 | *.rej 12 | *~ 13 | \#* 14 | *.bak 15 | *.tmp 16 | /Makefile 17 | /config.h 18 | /config.h.in 19 | /config.log 20 | /config.status 21 | /configure 22 | /directiv.c 23 | /directiv.h 24 | /doc/*.dip 25 | /doc/*.hpj 26 | /doc/*.pdf 27 | /doc/*.ps 28 | /doc/*.rtf 29 | /doc/*.texi 30 | /doc/*.txt 31 | /doc/Makefile 32 | /doc/inslist.src 33 | /doc/html 34 | /doc/info 35 | /insnsa.c 36 | /insnsb.c 37 | /insnsd.c 38 | /insnsi.h 39 | /insnsn.c 40 | /macros.c 41 | /nasm 42 | /nasm.man 43 | /ndisasm 44 | /ndisasm.man 45 | /pptok.c 46 | /pptok.h 47 | /pptok.ph 48 | /rdoff/Makefile 49 | /rdoff/ldrdf 50 | /rdoff/rdf2bin 51 | /rdoff/rdf2com 52 | /rdoff/rdf2ihx 53 | /rdoff/rdf2ith 54 | /rdoff/rdf2srec 55 | /rdoff/rdfdump 56 | /rdoff/rdflib 57 | /rdoff/rdx 58 | /regdis.c 59 | /regdis.h 60 | /regflags.c 61 | /regs.c 62 | /regs.h 63 | /regvals.c 64 | /test/golden 65 | /test/perf/*.asm 66 | /test/testresults 67 | /tokens.h 68 | /tokhash.c 69 | /version.h 70 | /version.mac 71 | /version.mak 72 | /version.nsh 73 | /version.sed 74 | -------------------------------------------------------------------------------- /misc/fmtinsns.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Re-align the columns in insns.dat, and enforce case conventions 4 | # 5 | 6 | @cols = (0, 16, 48, 96); 7 | 8 | while ($line = ) { 9 | chomp $line; 10 | if ($line !~ /^\s*(\;.*|)$/) { 11 | ($ln = $line) =~ s/\s+$//; 12 | if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) { 13 | @fields = ($1, $2, $3, $4); 14 | $fields[0] = "\U$fields[0]" unless ($fields[0] =~ /^[^a-z]+cc$/); 15 | $fields[3] =~ s/\,+$//; 16 | $fields[3] = "\U$fields[3]" unless ($fields[3] eq 'ignore'); 17 | $c = 0; 18 | $line = ''; 19 | for ($i = 0; $i < scalar(@fields); $i++) { 20 | if ($i > 0 && $c >= $cols[$i]) { 21 | $line .= ' '; 22 | $c++; 23 | } 24 | while ($c < $cols[$i]) { 25 | $line .= "\t"; 26 | $c = ($c+8) & ~7; 27 | } 28 | $line .= $fields[$i]; 29 | for ($j = 0; $j < length($fields[$i]); $j++) { 30 | if (substr($fields[$i], $j, 1) eq "\t") { 31 | $c = ($c+8) & ~7; 32 | } else { 33 | $c++; 34 | } 35 | } 36 | } 37 | } 38 | } 39 | print $line, "\n"; 40 | } 41 | -------------------------------------------------------------------------------- /test/elftest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test source file for assembling to ELF 3 | * build with: 4 | * nasm -f elf elftest.asm 5 | * gcc -o elftest elftest.c elftest.o 6 | * (assuming your gcc is ELF) 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | extern int lrotate(int32_t, int); 13 | extern void greet(void); 14 | extern int8_t asmstr[]; 15 | extern void *selfptr; 16 | extern void *textptr; 17 | extern int integer, commvar; 18 | 19 | int main(void) 20 | { 21 | 22 | printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 23 | printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4)); 24 | printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000, 14)); 25 | 26 | printf("This string should read `hello, world': `%s'\n", asmstr); 27 | 28 | printf("The integers here should be 1234, 1235 and 4321:\n"); 29 | integer = 1234; 30 | commvar = 4321; 31 | greet(); 32 | 33 | printf("These pointers should be equal: %p and %p\n", &greet, textptr); 34 | 35 | printf("So should these: %p and %p\n", selfptr, &selfptr); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /test/lnxhello.asm: -------------------------------------------------------------------------------- 1 | ;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 2 | ;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 3 | ;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 4 | ;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 5 | 6 | ; 7 | ; Assembly "Hello, World!" for Linux 8 | ; 9 | 10 | 11 | ; Properly defined in 12 | %define SYS_exit 1 13 | %define SYS_write 4 14 | 15 | section .text 16 | 17 | global _start 18 | _start: 19 | ; gdb doesn't like to stop at the entry point address, so 20 | ; we put a nop here for pure convenience 21 | nop 22 | 23 | 24 | write_hello: 25 | mov edx, hello_len 26 | mov ecx, hello 27 | 28 | .loop: 29 | mov eax, SYS_write 30 | mov ebx, 1 ; stdout 31 | int 80h 32 | 33 | cmp eax, -4096 34 | ja error 35 | 36 | add ecx, eax 37 | sub edx, eax 38 | jnz .loop 39 | 40 | ok: 41 | mov eax, SYS_exit 42 | xor ebx, ebx 43 | int 80h 44 | hlt 45 | 46 | error: 47 | mov eax, SYS_exit 48 | mov ebx, 1 ; Error 49 | int 80h 50 | hlt 51 | 52 | section .rodata 53 | hello: db "Hello, World!", 10 54 | hello_len equ $-hello 55 | -------------------------------------------------------------------------------- /lib/vsnprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vsnprintf() 3 | * 4 | * Poor substitute for a real vsnprintf() function for systems 5 | * that don't have them... 6 | */ 7 | 8 | #include "compiler.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "nasmlib.h" 16 | 17 | #define BUFFER_SIZE 65536 /* Bigger than any string we might print... */ 18 | 19 | static char snprintf_buffer[BUFFER_SIZE]; 20 | 21 | int vsnprintf(char *str, size_t size, const char *format, va_list ap) 22 | { 23 | int rv, bytes; 24 | 25 | if (size > BUFFER_SIZE) { 26 | nasm_error(ERR_PANIC|ERR_NOFILE, 27 | "vsnprintf: size (%d) > BUFFER_SIZE (%d)", 28 | size, BUFFER_SIZE); 29 | size = BUFFER_SIZE; 30 | } 31 | 32 | rv = vsprintf(snprintf_buffer, format, ap); 33 | if (rv >= BUFFER_SIZE) 34 | nasm_error(ERR_PANIC|ERR_NOFILE, "vsnprintf buffer overflow"); 35 | 36 | if (size > 0) { 37 | if ((size_t)rv < size-1) 38 | bytes = rv; 39 | else 40 | bytes = size-1; 41 | memcpy(str, snprintf_buffer, bytes); 42 | str[bytes] = '\0'; 43 | } 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /misc/findleak.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # From: Ed Beroset 3 | 4 | my %mem = {}; 5 | my %alloc = {}; 6 | while(<>) 7 | { 8 | if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/) 9 | { 10 | $mem{$1}--; 11 | if ($mem{$1} != 0) { 12 | print "free before alloc! $_"; 13 | } 14 | if ($mem{$2} != 0) { 15 | print "memory leak! $_"; 16 | } 17 | $mem{$2}++; 18 | $alloc{$2} = $_; 19 | } 20 | elsif (/free\((0x[0-9a-f]+)/) 21 | { 22 | $mem{$1}--; 23 | if ($mem{$1} != 0) { 24 | print "free before alloc! $_"; 25 | } 26 | } 27 | elsif (m/returns (0x[0-9a-f]+)/) 28 | { 29 | if ($mem{$1} != 0) { 30 | print "memory leak! $_"; 31 | } 32 | $mem{$1}++; 33 | $alloc{$1} = $_; 34 | } 35 | } 36 | foreach $goo (sort keys %mem) 37 | { 38 | if ($mem{$goo}) 39 | { 40 | print "$mem{$goo} $alloc{$goo}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /misc/tag-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version="" 4 | repo="" 5 | branch="" 6 | push=1 7 | 8 | for opt in $* 9 | do 10 | case "$opt" in 11 | --ver=*) 12 | version=`echo $opt | sed 's/[-a-zA-Z0-9]*=//'` 13 | ;; 14 | --repo=*) 15 | repo=`echo $opt | sed 's/[-a-zA-Z0-9]*=//'` 16 | ;; 17 | --branch=*) 18 | branch=`echo $opt | sed 's/[-a-zA-Z0-9]*=//'` 19 | ;; 20 | --no-push) 21 | push=0 22 | ;; 23 | *) 24 | version=$opt 25 | ;; 26 | esac 27 | done 28 | 29 | if [ -z "$version" ]; then 30 | echo " Usage" 31 | echo " $0 --ver=num [--repo=name --branch=name --push]" 1>&2 32 | echo " Example" 33 | echo " $0 --ver=2.10rc1 --repo=git+ssh://user@repo.or.cz/nasm.git --branch=master --no-push" 1>&2 34 | echo " With --no-push the changes are not pushed out to remote repo" 35 | exit 1 36 | fi 37 | 38 | tag="nasm-$version" 39 | 40 | echo "$version" > version 41 | git add version 42 | git commit -m "NASM $version" 43 | git tag -a -m "NASM $version" "$tag" 44 | 45 | if [ $push = 1 ]; then 46 | set -x 47 | git push $repo $branch 48 | git push $repo $tag 49 | git push --tags $repo 50 | set +x 51 | fi 52 | 53 | -------------------------------------------------------------------------------- /test/elftest64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * build with: 3 | * nasm -f elf64 elf64so.asm 4 | * ld -shared -o elf64so.so elf64so.o 5 | * test with: 6 | * gcc -o elf64so elftest64.c ./elf64so.so 7 | * ./elf64so 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | extern long lrotate(long, int); 14 | extern void greet_s(void); 15 | extern void greet_m(void); 16 | extern int8_t asmstr[]; 17 | extern void *selfptr; 18 | extern void *textptr; 19 | extern long integer; 20 | long commvar; 21 | 22 | int main(void) 23 | { 24 | 25 | printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 26 | printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000, 4)); 27 | printf("lrotate(0x00040000, 46) = 0x%08lx\n", lrotate(0x40000, 46)); 28 | 29 | printf("This string should read `hello, world': `%s'\n", asmstr); 30 | 31 | printf("&integer = %p, &commvar = %p\n", &integer, &commvar); 32 | printf("The integers here should be 1234, 1235 and 4321:\n"); 33 | integer = 1234; 34 | commvar = 4321; 35 | greet_s(); 36 | greet_m(); 37 | 38 | printf("These pointers should be equal: %p and %p\n", &greet_s, textptr); 39 | 40 | printf("So should these: %p and %p\n", selfptr, &selfptr); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /test/sreg.asm: -------------------------------------------------------------------------------- 1 | bits 64 2 | mov es,rax 3 | mov ss,rax 4 | mov ds,rax 5 | mov fs,rax 6 | mov gs,rax 7 | mov es,eax 8 | mov ss,eax 9 | mov ds,eax 10 | mov fs,eax 11 | mov gs,eax 12 | mov es,ax 13 | mov ss,ax 14 | mov ds,ax 15 | mov fs,ax 16 | mov gs,ax 17 | mov es,[rsi] 18 | mov ss,[rsi] 19 | mov ds,[rsi] 20 | mov fs,[rsi] 21 | mov gs,[rsi] 22 | mov es,word [rsi] 23 | mov ss,word [rsi] 24 | mov ds,word [rsi] 25 | mov fs,word [rsi] 26 | mov gs,word [rsi] 27 | mov es,qword [rsi] 28 | mov ss,qword [rsi] 29 | mov ds,qword [rsi] 30 | mov fs,qword [rsi] 31 | mov gs,qword [rsi] 32 | mov rax,es 33 | mov rax,cs 34 | mov rax,ss 35 | mov rax,ds 36 | mov rax,fs 37 | mov rax,gs 38 | mov eax,es 39 | mov eax,ss 40 | mov eax,ds 41 | mov eax,fs 42 | mov eax,fs 43 | mov ax,es 44 | mov ax,ss 45 | mov ax,ds 46 | mov ax,fs 47 | mov ax,gs 48 | mov [rdi],es 49 | mov [rdi],cs 50 | mov [rdi],ss 51 | mov [rdi],ds 52 | mov [rdi],fs 53 | mov [rdi],gs 54 | mov word [rdi],es 55 | mov word [rdi],cs 56 | mov word [rdi],ss 57 | mov word [rdi],ds 58 | mov word [rdi],fs 59 | mov word [rdi],gs 60 | mov qword [rdi],es 61 | mov qword [rdi],cs 62 | mov qword [rdi],ss 63 | mov qword [rdi],ds 64 | mov qword [rdi],fs 65 | mov qword [rdi],gs 66 | -------------------------------------------------------------------------------- /misc/c16.mac: -------------------------------------------------------------------------------- 1 | ; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*- 2 | 3 | 4 | 5 | %imacro proc 1 ; begin a procedure definition 6 | 7 | %push proc 8 | 9 | global %1 10 | 11 | %1: push bp 12 | 13 | mov bp,sp 14 | 15 | %ifdef FARCODE PASCAL ; arguments may start at bp+4 or bp+6 16 | 17 | %assign %$arg 6 18 | 19 | %define %$firstarg 6 20 | 21 | %else 22 | 23 | %assign %$arg 4 24 | 25 | %define %$firstarg 4 26 | 27 | %endif 28 | 29 | %define %$procname %1 30 | 31 | %endmacro 32 | 33 | 34 | 35 | %imacro arg 0-1 2 ; used with the argument name as a label 36 | 37 | %00 equ %$arg 38 | 39 | ; we could possibly be adding some 40 | 41 | ; debug information at this point...? 42 | 43 | %assign %$arg %1+%$arg 44 | 45 | %endmacro 46 | 47 | 48 | 49 | %imacro endproc 0 50 | 51 | %ifnctx proc 52 | 53 | %error Mismatched `endproc'/`proc' 54 | 55 | %else 56 | 57 | mov sp,bp 58 | 59 | pop bp 60 | 61 | %ifdef PASCAL 62 | 63 | retf %$arg - %$firstarg 64 | 65 | %elifdef FARCODE 66 | 67 | retf 68 | 69 | %else 70 | 71 | retn 72 | 73 | %endif 74 | 75 | __end_%$procname: ; useful for calculating function size 76 | 77 | %pop 78 | 79 | %endif 80 | 81 | %endmacro 82 | 83 | -------------------------------------------------------------------------------- /misc/crcgen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | /* Polynomial in bit-reversed notation */ 7 | uint64_t poly; 8 | uint64_t crctab[256], v; 9 | int i, j; 10 | 11 | poly = strtoumax(argv[1], NULL, 0); 12 | 13 | printf("/* C */\n"); 14 | printf("static const uint64_t crc64_tab[256] = {\n"); 15 | for (i = 0; i < 256; i++) { 16 | v = i; 17 | for (j = 0; j < 8; j++) 18 | v = (v >> 1) ^ ((v & 1) ? poly : 0); 19 | crctab[i] = v; 20 | } 21 | 22 | for (i = 0; i < 256; i += 2) { 23 | printf(" /* %02x */ UINT64_C(0x%016"PRIx64"), " 24 | "UINT64_C(0x%016"PRIx64")%s\n", 25 | i, crctab[i], crctab[i+1], (i == 254) ? "" : ","); 26 | } 27 | printf("};\n\n"); 28 | 29 | printf("# perl\n"); 30 | printf("@crc64_tab = (\n"); 31 | for (i = 0; i < 256; i += 2) { 32 | printf(" [0x%08"PRIx32", 0x%08"PRIx32"], " 33 | "[0x%08"PRIx32", 0x%08"PRIx32"]%-1s # %02x\n", 34 | (uint32_t)(crctab[i] >> 32), 35 | (uint32_t)(crctab[i]), 36 | (uint32_t)(crctab[i+1] >> 32), 37 | (uint32_t)(crctab[i+1]), 38 | (i == 254) ? "" : ",", 39 | i); 40 | } 41 | printf(");\n"); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /test/pinsr16.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-O0 -fbin -opinsr16.bin; Files=stdout stderr pinsr16.bin 2 | bits 16 3 | 4 | pinsrw mm0,eax,0 5 | pinsrw mm1,si,0 6 | pinsrw mm2,[bx],0 7 | pinsrw mm3,word [bx],0 8 | 9 | pinsrb xmm0,eax,0 10 | pinsrb xmm1,sil,0 11 | ; pinsrb xmm1,bh,0 12 | pinsrb xmm2,[bx],0 13 | pinsrb xmm3,byte [bx],0 14 | 15 | pinsrw xmm0,eax,0 16 | pinsrw xmm1,si,0 17 | pinsrw xmm2,[bx],0 18 | pinsrw xmm3,word [bx],0 19 | 20 | pinsrd xmm0,eax,0 21 | pinsrd xmm1,esi,0 22 | pinsrd xmm2,[bx],0 23 | pinsrd xmm3,dword [bx],0 24 | 25 | vpinsrb xmm0,eax,0 26 | vpinsrb xmm1,bl,0 27 | vpinsrb xmm2,[bx],0 28 | vpinsrb xmm3,byte [bx],0 29 | 30 | vpinsrw xmm0,eax,0 31 | vpinsrw xmm1,si,0 32 | vpinsrw xmm2,[bx],0 33 | vpinsrw xmm3,word [bx],0 34 | 35 | vpinsrd xmm0,eax,0 36 | vpinsrd xmm1,esi,0 37 | vpinsrd xmm2,[bx],0 38 | vpinsrd xmm3,dword [bx],0 39 | 40 | vpinsrb xmm4,xmm0,eax,0 41 | vpinsrb xmm5,xmm1,bl,0 42 | vpinsrb xmm6,xmm2,[bx],0 43 | vpinsrb xmm7,xmm3,byte [bx],0 44 | 45 | vpinsrw xmm4,xmm0,eax,0 46 | vpinsrw xmm5,xmm1,si,0 47 | vpinsrw xmm6,xmm2,[bx],0 48 | vpinsrw xmm7,xmm3,word [bx],0 49 | 50 | vpinsrd xmm4,xmm0,eax,0 51 | vpinsrd xmm5,xmm1,esi,0 52 | vpinsrd xmm6,xmm2,[bx],0 53 | vpinsrd xmm7,xmm3,dword [bx],0 54 | -------------------------------------------------------------------------------- /test/pinsr32.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-O0 -fbin -opinsr32.bin; Files=stdout stderr pinsr32.bin 2 | bits 32 3 | 4 | pinsrw mm0,eax,0 5 | pinsrw mm1,si,0 6 | pinsrw mm2,[ecx],0 7 | pinsrw mm3,word [ecx],0 8 | 9 | pinsrb xmm0,eax,0 10 | pinsrb xmm1,sil,0 11 | ; pinsrb xmm1,bh,0 12 | pinsrb xmm2,[ecx],0 13 | pinsrb xmm3,byte [ecx],0 14 | 15 | pinsrw xmm0,eax,0 16 | pinsrw xmm1,si,0 17 | pinsrw xmm2,[ecx],0 18 | pinsrw xmm3,word [ecx],0 19 | 20 | pinsrd xmm0,eax,0 21 | pinsrd xmm1,esi,0 22 | pinsrd xmm2,[ecx],0 23 | pinsrd xmm3,dword [ecx],0 24 | 25 | vpinsrb xmm0,eax,0 26 | vpinsrb xmm1,bl,0 27 | vpinsrb xmm2,[ecx],0 28 | vpinsrb xmm3,byte [ecx],0 29 | 30 | vpinsrw xmm0,eax,0 31 | vpinsrw xmm1,si,0 32 | vpinsrw xmm2,[ecx],0 33 | vpinsrw xmm3,word [ecx],0 34 | 35 | vpinsrd xmm0,eax,0 36 | vpinsrd xmm1,esi,0 37 | vpinsrd xmm2,[ecx],0 38 | vpinsrd xmm3,dword [ecx],0 39 | 40 | vpinsrb xmm4,xmm0,eax,0 41 | vpinsrb xmm5,xmm1,bl,0 42 | vpinsrb xmm6,xmm2,[ecx],0 43 | vpinsrb xmm7,xmm3,byte [ecx],0 44 | 45 | vpinsrw xmm4,xmm0,eax,0 46 | vpinsrw xmm5,xmm1,si,0 47 | vpinsrw xmm6,xmm2,[ecx],0 48 | vpinsrw xmm7,xmm3,word [ecx],0 49 | 50 | vpinsrd xmm4,xmm0,eax,0 51 | vpinsrd xmm5,xmm1,esi,0 52 | vpinsrd xmm6,xmm2,[ecx],0 53 | vpinsrd xmm7,xmm3,dword [ecx],0 54 | -------------------------------------------------------------------------------- /test/avx.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -oavx.bin; Files=stdout stderr avx.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -oavx.bin; Files=stdout stderr avx.bin 3 | 4 | bits 64 5 | blendvpd xmm2,xmm1,xmm0 6 | 7 | vblendvpd xmm2,xmm1,xmm0,xmm0 8 | vblendvpd xmm2,xmm1,xmm0 9 | vblendvpd ymm2,ymm1,ymm0,ymm0 10 | vblendvpd ymm2,ymm1,ymm0 11 | 12 | vcvtsi2sd xmm9,xmm10,ecx 13 | vcvtsi2sd xmm9,xmm10,rcx 14 | vcvtsi2sd xmm9,xmm10,dword [rdi] 15 | vcvtsi2sd xmm9,xmm10,qword [rdi] 16 | 17 | vpextrb [rax],xmm1,0x33 18 | vpextrw [rax],xmm1,0x33 19 | vpextrd [rax],xmm1,0x33 20 | vpextrq [rax],xmm1,0x33 21 | vpextrb rax,xmm1,0x33 22 | vpextrw rax,xmm1,0x33 23 | vpextrd rax,xmm1,0x33 24 | vpextrq rax,xmm1,0x33 25 | vpextrb eax,xmm1,0x33 26 | vpextrw eax,xmm1,0x33 27 | vpextrd eax,xmm1,0x33 28 | ; vpextrq eax,xmm1,0x33 29 | 30 | vcvtpd2ps xmm0,xmm1 31 | vcvtpd2ps xmm0,oword [rsi] 32 | vcvtpd2ps xmm0,ymm1 33 | vcvtpd2ps xmm0,yword [rsi] 34 | ; vcvtpd2ps xmm0,[rsi] 35 | 36 | vcvtpd2dq xmm0,xmm1 37 | vcvtpd2dq xmm0,oword [rsi] 38 | vcvtpd2dq xmm0,ymm1 39 | vcvtpd2dq xmm0,yword [rsi] 40 | ; vcvtpd2dq xmm0,[rsi] 41 | 42 | vcvttpd2dq xmm0,xmm1 43 | vcvttpd2dq xmm0,oword [rsi] 44 | vcvttpd2dq xmm0,ymm1 45 | vcvttpd2dq xmm0,yword [rsi] 46 | ; vcvttpd2dq xmm0,[rsi] 47 | -------------------------------------------------------------------------------- /rdoff/test/rdtmain.asm: -------------------------------------------------------------------------------- 1 | ;; rdtmain - main part of test program for RDX execution. 2 | ;; returns true (0) if its parameter equals the phrase "hello" 3 | ;; "hello" is stored in the library part, to complicate the 4 | ;; linkage. 5 | 6 | ;; assemble and link with the following commands: 7 | ;; nasm -f rdf rdtmain.asm 8 | ;; nasm -f rdf rdtlib.asm 9 | ;; ldrdf rdtmain.rdf rdtlib.rdf -o rdxtest.rdx 10 | 11 | ;; run with 'rdx rdxtest.rdx [parameters]' on a Linux (or possibly 12 | ;; other 32 bit OS) systems (x86 architectures only!) 13 | ;; try using '&& echo Yes' afterwards to find out when it returns 0. 14 | 15 | [EXTERN _strcmp] ; strcmp is an imported function 16 | [EXTERN _message] ; imported data 17 | [SECTION .text] 18 | [BITS 32] 19 | 20 | ;; main(int argc,char **argv) 21 | [GLOBAL _main] 22 | _main: 23 | push ebp 24 | mov ebp,esp 25 | 26 | ;; ebp+8 = argc, ebp+12 = argv 27 | 28 | cmp dword [ebp+8],2 29 | jb error ; cause error if < 1 parameters 30 | 31 | mov eax, [ebp+12] ; eax = argv 32 | 33 | mov ebx, [eax+4] ; ebx = argv[1] 34 | mov ecx, _message ; ecx = "hello" 35 | 36 | push ecx 37 | push ebx 38 | call _strcmp ; compare strings 39 | add esp,8 ; caller clears stack 40 | 41 | pop ebp 42 | ret ; return return value of _strcmp 43 | 44 | error: 45 | mov eax,2 ; return 2 on error 46 | pop ebp 47 | ret 48 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | dnl -------------------------------------------------------------------------- 2 | dnl PA_ADD_CFLAGS() 3 | dnl 4 | dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation 5 | dnl -------------------------------------------------------------------------- 6 | AC_DEFUN(PA_ADD_CFLAGS, 7 | [AC_MSG_CHECKING([if $CC accepts $1]) 8 | pa_add_cflags__old_cflags="$CFLAGS" 9 | CFLAGS="$CFLAGS $1" 10 | AC_TRY_LINK([#include ], 11 | [printf("Hello, World!\n");], 12 | AC_MSG_RESULT([yes]), 13 | AC_MSG_RESULT([no]) 14 | CFLAGS="$pa_add_cflags__old_cflags")]) 15 | 16 | dnl -------------------------------------------------------------------------- 17 | dnl PA_WORKING_STDBOOL 18 | dnl 19 | dnl See if we have a working and bool support; in particular, 20 | dnl OpenWatcom 1.8 has a broken _Bool type that we don't want to use. 21 | dnl -------------------------------------------------------------------------- 22 | AC_DEFUN(PA_WORKING_BOOL, 23 | [AC_MSG_CHECKING([if $CC has a working bool type]) 24 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 25 | #ifndef __cplusplus 26 | #include 27 | #endif 28 | int foo(bool x, int y) 29 | { 30 | return x+y; 31 | } 32 | ])], 33 | [AC_MSG_RESULT([yes]) 34 | AC_DEFINE(HAVE_WORKING_BOOL, 1, 35 | [Define to 1 if your compiler has a correct implementation of bool])], 36 | [AC_MSG_RESULT([no])]) 37 | ]) 38 | 39 | -------------------------------------------------------------------------------- /test/radix.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -oradix.bin; Files=stdout stderr radix.bin 2 | 3 | ;; Integer constants... 4 | 5 | dd 1010_0101 ; Decimal 6 | dd 01010_0101 ; Decimal (*not* octal!) 7 | dd 0d1010_0101 ; Decimal 8 | dd 0t1010_0101 ; Decimal 9 | dd 1010_0101d ; Decimal 10 | dd 1010_0101t ; Decimal 11 | 12 | dd 0b1010_0101 ; Binary 13 | dd 0y1010_0101 ; Binary 14 | dd 1010_0101b ; Binary 15 | dd 1010_0101y ; Binary 16 | 17 | dd 0o1010_0101 ; Octal 18 | dd 0q1010_0101 ; Octal 19 | dd 1010_0101o ; Octal 20 | dd 1010_0101q ; Octal 21 | 22 | dd 0h1010_0101 ; Hex 23 | dd 0x1010_0101 ; Hex 24 | dd 1010_0101h ; Hex 25 | dd 1010_0101x ; Hex 26 | dd $1010_0101 ; Hex 27 | 28 | db 0h ; Zero! 29 | db 0x ; Zero! 30 | db 0b ; Zero! 31 | db 0dh ; Hex 32 | db 0bh ; Hex 33 | db 0dx ; Hex 34 | db 0bx ; Hex 35 | db 0hd ; Hex 36 | db 0hb ; Hex 37 | db 0xd ; Hex 38 | db 0xb ; Hex 39 | 40 | ;; Floating-point constants 41 | ;; All of these should output B4A21147 42 | dd 3.7282705e+4 ; Decimal 43 | dd 00003.7282705e+4 ; Decimal 44 | dd 0d3.7282705e+4 ; Decimal 45 | dd 0t3.7282705e+4 ; Decimal 46 | 47 | dd 0x1.23456789p+15 ; Hex 48 | dd 0h1.23456789p+15 ; Hex 49 | 50 | dd 0o1.10642547422p+15 ; Octal 51 | dd 0q1.10642547422p+15 ; Octal 52 | 53 | dd 0b1.0010_0011_0100_0101_0110_0111_1000_1001p+15 ; Binary 54 | dd 0y1.0010_0011_0100_0101_0110_0111_1000_1001p+15 ; Binary 55 | -------------------------------------------------------------------------------- /rdoff/ldrdf.1: -------------------------------------------------------------------------------- 1 | .TH LDRDF 1 "September 6, 1999" "Debian Project" "Debian Manual" 2 | .SH NAME 3 | ldrdf \- link RDOFF objects and libraries produced by rdflib(1) 4 | .SH SYNOPSIS 5 | .B ldrdf 6 | .RI "[-o " output-file ] 7 | .I object-file\c 8 | .RI "... [-l" library "...]" 9 | .SH DESCRIPTION 10 | .B ldrdf 11 | is a version of unix 12 | .BR ld (1) 13 | (or DOS LINK) for use with RDOFF files. It is capable of linking RDOFF 14 | objects, and libraries produced with the 15 | .BR rdflib (1) 16 | utility. 17 | .PP 18 | Libraries must be specified with their path as no search is performed. 19 | Modules in libraries are not linked to the program unless they are 20 | referred to. 21 | .SH OPTIONS 22 | .TP 23 | .RI "-o " output-file 24 | Specify an output file. The default output filename is 25 | .RI ' aout.rdx '. 26 | .TP 27 | -v 28 | Increase verbosity level. Currently 4 verbosity levels are available: 29 | default (which only prints error information), normal (which prints 30 | information about the produced object, -v), medium (which prints information 31 | about what the program is doing, -v -v) and high (which prints all available 32 | information, -v -v -v). 33 | .TP 34 | -p 35 | Change alignment value to which multiple segments combigned into a single 36 | segment should be aligned (must be either 1, 2, 4, 8, 16, 32 or 256; default 37 | is 16). 38 | .SH AUTHORS 39 | Julian Hall . 40 | .PP 41 | This manual page was written by Matej Vela . 42 | -------------------------------------------------------------------------------- /test/xchg.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-fbin -oxchg.bin -O0; Files=stdout stderr xchg.bin 2 | ;Testname=optimized; Arguments=-fbin -oxchg.bin -Ox; Files=stdout stderr xchg.bin 3 | 4 | %macro x 2 5 | xchg %1,%2 6 | xchg %2,%1 7 | %endmacro 8 | 9 | bits 16 10 | 11 | x ax,ax 12 | x ax,cx 13 | x ax,dx 14 | x ax,bx 15 | x ax,sp 16 | x ax,bp 17 | x ax,si 18 | x ax,di 19 | x eax,eax 20 | x eax,ecx 21 | x eax,edx 22 | x eax,ebx 23 | x eax,esp 24 | x eax,ebp 25 | x eax,esi 26 | x eax,edi 27 | 28 | bits 32 29 | 30 | x ax,ax 31 | x ax,cx 32 | x ax,dx 33 | x ax,bx 34 | x ax,sp 35 | x ax,bp 36 | x ax,si 37 | x ax,di 38 | x eax,eax 39 | x eax,ecx 40 | x eax,edx 41 | x eax,ebx 42 | x eax,esp 43 | x eax,ebp 44 | x eax,esi 45 | x eax,edi 46 | 47 | bits 64 48 | 49 | x ax,ax 50 | x ax,cx 51 | x ax,dx 52 | x ax,bx 53 | x ax,sp 54 | x ax,bp 55 | x ax,si 56 | x ax,di 57 | x ax,r8w 58 | x ax,r9w 59 | x ax,r10w 60 | x ax,r11w 61 | x ax,r12w 62 | x ax,r13w 63 | x ax,r14w 64 | x ax,r15w 65 | x eax,eax 66 | x eax,ecx 67 | x eax,edx 68 | x eax,ebx 69 | x eax,esp 70 | x eax,ebp 71 | x eax,esi 72 | x eax,edi 73 | x eax,r8d 74 | x eax,r9d 75 | x eax,r10d 76 | x eax,r11d 77 | x eax,r12d 78 | x eax,r13d 79 | x eax,r14d 80 | x eax,r15d 81 | x rax,rax 82 | x rax,rcx 83 | x rax,rdx 84 | x rax,rbx 85 | x rax,rsp 86 | x rax,rbp 87 | x rax,rsi 88 | x rax,rdi 89 | x rax,r8 90 | x rax,r9 91 | x rax,r10 92 | x rax,r11 93 | x rax,r12 94 | x rax,r13 95 | x rax,r14 96 | x rax,r15 97 | -------------------------------------------------------------------------------- /rdoff/test/rdftest1.asm: -------------------------------------------------------------------------------- 1 | ;; program to test RDOFF production and linkage 2 | 3 | ;; items to test include: 4 | ;; [1] relocation within the same segment in each module 5 | ;; [2] relocation to different segments in same module 6 | ;; [3] relocation to same segment in different module 7 | ;; [4] relocation to different segment in different module 8 | ;; [5] relative relocation to same module 9 | ;; [6] relative relocation to different module 10 | ;; [7] correct generation of BSS addresses 11 | 12 | [SECTION .text] 13 | [BITS 32] 14 | 15 | _main: 16 | mov ax,localdata ; [2] (16 bit) => 66 b8 0000 17 | mov eax,localdata2 ; [2] (32 bit) => b8 0000000a 18 | 19 | [EXTERN _fardata] 20 | 21 | mov eax,[_fardata] ; [4] => a1 00000000 (+20) 22 | mov cx,next ; [1] => 66 b9 0012 23 | next: 24 | call localproc ; [5] => e8 00000019 25 | 26 | [EXTERN _farproc] 27 | mov eax,_farproc ; [3] => b8 00000000 (+40+0) 28 | call _farproc ; [6] => e8 -$ (-0+40+0) (=1f) 29 | 30 | mov eax,localbss ; [7] => b8 00000000 31 | 32 | [GLOBAL _term] 33 | _term: xor ax,ax ; => 66 31 c0 34 | int 21h ; => cd 21 35 | jmp _term ; => e9 -0a (=fffffff6) 36 | 37 | localproc: 38 | ret ; => c3 39 | 40 | [GLOBAL _test1proc] 41 | _test1proc: 42 | call localproc ; [5] => e8 -$ (-0+0+?) (=-6=fffffffa) 43 | ret ; => c3 44 | 45 | [SECTION .data] 46 | [GLOBAL localdata2] 47 | localdata: db 'localdata',0 48 | localdata2: db 'localdata2',0 49 | farref: dd _fardata ; [3] => 0 (+20) 50 | localref: dd _main ; [2] => 0 (+0) 51 | 52 | [SECTION .bss] 53 | localbss: resw 4 ; reserve 8 bytes BSS 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | NASM is now licensed under the 2-clause BSD license, also known as the 2 | simplified BSD license. 3 | 4 | Copyright 1996-2010 the NASM Authors - All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following 8 | conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 18 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Mkfiles/README: -------------------------------------------------------------------------------- 1 | These are pre-created Makefiles for various platforms, use them if 2 | GNU autoconf/automake packages are not supported on your system. 3 | 4 | The Makefiles are: 5 | 6 | Filename Target Compiler Tested with 7 | --------------------------------------------------------------------------- 8 | msvc.mak Win32 MS Visual C++ Visual C++ Express 2005 9 | 10 | For building on a Win32 host using Microsoft Visual C++. 11 | 12 | Usage: nmake /f Mkfiles/msvc.mak 13 | 14 | 15 | Filename Target Compiler Tested with 16 | --------------------------------------------------------------------------- 17 | openwcom.mak DOS,Win32,OS/2 OpenWatcom C OpenWatcom 1.7 (Win32) 18 | 19 | For building on a DOS, OS/2 or Win32 host using OpenWatcom. 20 | OpenWatcom can be downloaded from http://www.openwatcom.org/. 21 | 22 | Usage: wmake /f Mkfiles/ 23 | 24 | is dos, win32, or os2. 25 | 26 | Filename Target Compiler Tested with 27 | --------------------------------------------------------------------------- 28 | owlinux.mak DOS,Win32,OS/2 OpenWatcom C OpenWatcom 1.6rc2 (Linux) 29 | 30 | For building on a Linux host using OpenWatcom for Linux. 31 | 32 | Usage: make -f Mkfiles/ 33 | 34 | is dos, win32, or os2. 35 | 36 | Filename Target Compiler Tested with 37 | --------------------------------------------------------------------------- 38 | netware.mak NetWare Cross-GCC Cross-GCC 3.2.3 (Linux, Win32) 39 | 40 | For building on a Linux or Win32 host using Cross-GCC for Linux/Win32. 41 | 42 | Usage: make -f Mkfiles/netware.mak 43 | -------------------------------------------------------------------------------- /test/pinsr64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-O0 -fbin -opinsr64.bin; Files=stdout stderr pinsr64.bin 2 | bits 64 3 | 4 | pinsrw mm0,eax,0 5 | pinsrw mm1,si,0 6 | pinsrw mm2,[rcx],0 7 | pinsrw mm3,word [rcx],0 8 | 9 | pinsrb xmm0,eax,0 10 | pinsrb xmm1,sil,0 11 | ; pinsrb xmm1,bh,0 12 | pinsrb xmm2,[rcx],0 13 | pinsrb xmm3,byte [rcx],0 14 | 15 | pinsrw xmm0,eax,0 16 | pinsrw xmm1,si,0 17 | pinsrw xmm2,[rcx],0 18 | pinsrw xmm3,word [rcx],0 19 | 20 | pinsrd xmm0,eax,0 21 | pinsrd xmm1,esi,0 22 | pinsrd xmm2,[rcx],0 23 | pinsrd xmm3,dword [rcx],0 24 | 25 | pinsrq xmm0,rax,0 26 | pinsrq xmm1,rsi,0 27 | pinsrq xmm2,[rcx],0 28 | pinsrq xmm3,qword [rcx],0 29 | 30 | vpinsrb xmm0,eax,0 31 | vpinsrb xmm1,sil,0 32 | vpinsrb xmm2,[rcx],0 33 | vpinsrb xmm3,byte [rcx],0 34 | 35 | vpinsrw xmm0,eax,0 36 | vpinsrw xmm1,si,0 37 | vpinsrw xmm2,[rcx],0 38 | vpinsrw xmm3,word [rcx],0 39 | 40 | vpinsrd xmm0,eax,0 41 | vpinsrd xmm1,esi,0 42 | vpinsrd xmm2,[rcx],0 43 | vpinsrd xmm3,dword [rcx],0 44 | 45 | vpinsrq xmm0,rax,0 46 | vpinsrq xmm1,rsi,0 47 | vpinsrq xmm2,[rcx],0 48 | vpinsrq xmm3,qword [rcx],0 49 | 50 | vpinsrb xmm4,xmm0,eax,0 51 | vpinsrb xmm5,xmm1,sil,0 52 | vpinsrb xmm6,xmm2,[rcx],0 53 | vpinsrb xmm7,xmm3,byte [rcx],0 54 | 55 | vpinsrw xmm4,xmm0,eax,0 56 | vpinsrw xmm5,xmm1,si,0 57 | vpinsrw xmm6,xmm2,[rcx],0 58 | vpinsrw xmm7,xmm3,word [rcx],0 59 | 60 | vpinsrd xmm4,xmm0,eax,0 61 | vpinsrd xmm5,xmm1,esi,0 62 | vpinsrd xmm6,xmm2,[rcx],0 63 | vpinsrd xmm7,xmm3,dword [rcx],0 64 | 65 | vpinsrq xmm4,xmm0,rax,0 66 | vpinsrq xmm5,xmm1,rsi,0 67 | vpinsrq xmm6,xmm2,[rcx],0 68 | vpinsrq xmm7,xmm3,qword [rdx],0 69 | -------------------------------------------------------------------------------- /misc/xcrcgen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Produce a "generalized CRC" table. Assumes a platform with 3 | * /dev/urandom -- otherwise reimplement get_random_byte(). 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | static uint8_t get_random_byte(void) 15 | { 16 | static int fd = -1; 17 | uint8_t buf; 18 | int rv; 19 | 20 | if (fd < 0) 21 | fd = open("/dev/urandom", O_RDONLY); 22 | 23 | do { 24 | errno = 0; 25 | rv = read(fd, &buf, 1); 26 | if (rv < 1 && errno != EAGAIN) 27 | abort(); 28 | } while (rv < 1); 29 | 30 | return buf; 31 | } 32 | 33 | static void random_permute(uint8_t *buf) 34 | { 35 | int i, j, k; 36 | int m; 37 | 38 | for (i = 0; i < 256; i++) 39 | buf[i] = i; 40 | 41 | m = 255; 42 | for (i = 255; i > 0; i--) { 43 | if (i <= (m >> 1)) 44 | m >>= 1; 45 | do { 46 | j = get_random_byte() & m; 47 | } while (j > i); 48 | k = buf[i]; 49 | buf[i] = buf[j]; 50 | buf[j] = k; 51 | } 52 | } 53 | 54 | static void xcrc_table(uint64_t *buf) 55 | { 56 | uint8_t perm[256]; 57 | int i, j; 58 | 59 | memset(buf, 0, 8*256); /* Make static checkers happy */ 60 | 61 | for (i = 0; i < 8; i++) { 62 | random_permute(perm); 63 | for (j = 0; j < 256; j++) 64 | buf[j] = (buf[j] << 8) | perm[j]; 65 | } 66 | } 67 | 68 | int main(void) 69 | { 70 | int i; 71 | uint64_t buf[256]; 72 | 73 | xcrc_table(buf); 74 | 75 | for (i = 0; i < 256; i++) { 76 | printf("%016"PRIx64"\n", buf[i]); 77 | } 78 | 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /rdoff/rdf2bin.1: -------------------------------------------------------------------------------- 1 | .TH RDF2BIN 1 "September 6, 1999" "Debian Project" "Debian Manual" 2 | .SH NAME 3 | rdf2bin, rdf2com \- convert an RDOFF object file to flat binary 4 | .SH SYNOPSIS 5 | .B rdf2bin 6 | .RI "[\-o " relocation-origin ] 7 | .RI "[\-p " segment-alignment ] 8 | .RI "[\-f " format ] 9 | .I input-file 10 | .I output-file 11 | .br 12 | .B rdf2com 13 | .RI "[\-p " segment-alignment ] 14 | .I input-file 15 | .I output-file 16 | .br 17 | .B rdf2ith 18 | .RI "[\-o " relocation-origin ] 19 | .RI "[\-p " segment-alignment ] 20 | .I input-file 21 | .I output-file 22 | .br 23 | .B rdf2srec 24 | .RI "[\-o " relocation-origin ] 25 | .RI "[\-p " segment-alignment ] 26 | .I input-file 27 | .I output-file 28 | .SH OPTIONS 29 | .TP 30 | .RI "\-o " relocation-origin 31 | Relocate at origin 32 | .IR relocation-origin . 33 | If invoked as 34 | .BR rdf2com , 35 | the default relocation origin will be 0x100. Else, the default origin is 0. 36 | .TP 37 | .RI "\-p " segment-alignment 38 | Pad segments until their size is a multiple of 39 | .IR segment-alignment . 40 | By default, 16 is used. 41 | .TP 42 | .RI "\-f " format 43 | Specify the output format. The currently supported formats are binary 44 | .RI ( bin ), 45 | DOS COM (binary with origin 0x100) 46 | .RI ( com ) 47 | Intel hex 48 | .RI ( ith 49 | or 50 | .IR ihx ), 51 | and 52 | Motorola S-Records 53 | .RI ( srec ). 54 | If not specified, the format is set by the command name. 55 | .SH AUTHORS 56 | Julian Hall , H. Peter Anvin . 57 | .PP 58 | This manual page was written by Matej Vela . 59 | .SH BUGS 60 | This utility currently only supports the classic segments 61 | .IR .text , 62 | .I .data 63 | and 64 | .IR .bss . 65 | 66 | -------------------------------------------------------------------------------- /test/br3066383.asm: -------------------------------------------------------------------------------- 1 | ;Testname=br3066383; Arguments=-Ox -fbin -obr3066383.bin; Files=stdout stderr br3066383.bin 2 | 3 | ; 4 | ; this is a for BR3005117 5 | ; http://sourceforge.net/tracker/?func=detail&aid=3005117&group_id=6208&atid=106208 6 | ; 7 | %macro b_struc 1-* 8 | %push foo 9 | %define %$strucname %1 10 | %%top_%$strucname: 11 | %rep %0 - 1 12 | %rotate 1 13 | resb %{$strucname}%1 - ($ - %%top_%$strucname) 14 | %1: 15 | %endrep 16 | resb %{$strucname}_size - ($ - %%top_%$strucname) 17 | %pop 18 | %endmacro 19 | 20 | struc timeval 21 | .tv_sec resd 1 22 | .tv_usec resd 1 23 | endstruc 24 | 25 | section .text 26 | mov [timeval_struct.tv_sec], eax 27 | 28 | section .bss 29 | timeval_struct b_struc timeval, .tv_sec, .tv_usec 30 | timeval_struct_len equ $ - timeval_struct 31 | 32 | section .text 33 | 34 | ; 35 | ; this is a test for BR3026808 36 | ; http://sourceforge.net/tracker/?func=detail&aid=3026808&group_id=6208&atid=106208 37 | ; 38 | %imacro proc 1 39 | %push proc 40 | %assign %$arg 1 41 | %endmacro 42 | 43 | %imacro arg 0-1 1 44 | %assign %$arg %1+%$arg 45 | %endmacro 46 | 47 | %imacro endproc 0 48 | %pop 49 | %endmacro 50 | 51 | proc Test 52 | %$ARG arg 53 | endproc 54 | 55 | ; 56 | ; this is a test for BR3066383 57 | ; http://sourceforge.net/tracker/?func=detail&aid=3066383&group_id=6208&atid=106208 58 | ; 59 | %macro pp_local 1 60 | %push 61 | %assign %$_uses 0 62 | %rep 4 63 | %assign %$_ur%$_uses %$_uses 64 | mov ecx, %$_ur%$_uses 65 | %assign %$_uses %$_uses+1 66 | %endrep 67 | %pop 68 | %endmacro 69 | 70 | pp_local 1 71 | -------------------------------------------------------------------------------- /lib/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 Todd C. Miller 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include 18 | #include 19 | #include "compiler.h" 20 | 21 | /* 22 | * Copy src to string dst of size siz. At most siz-1 characters 23 | * will be copied. Always NUL terminates (unless siz == 0). 24 | * Returns strlen(src); if retval >= siz, truncation occurred. 25 | */ 26 | #ifndef HAVE_STRLCPY 27 | 28 | size_t strlcpy(char *dst, const char *src, size_t siz) 29 | { 30 | char *d = dst; 31 | const char *s = src; 32 | size_t n = siz; 33 | 34 | /* Copy as many bytes as will fit */ 35 | if (n != 0) { 36 | while (--n != 0) { 37 | if ((*d++ = *s++) == '\0') 38 | break; 39 | } 40 | } 41 | 42 | /* Not enough room in dst, add NUL and traverse rest of src */ 43 | if (n == 0) { 44 | if (siz != 0) 45 | *d = '\0'; /* NUL-terminate dst */ 46 | while (*s++) 47 | ; 48 | } 49 | 50 | return(s - src - 1); /* count does not include NUL */ 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /misc/exebin.mac: -------------------------------------------------------------------------------- 1 | ; -*- nasm -*- 2 | ; NASM macro file to allow the `bin' output format to generate 3 | ; simple .EXE files by constructing the EXE header by hand. 4 | ; Adapted from a contribution by Yann Guidon 5 | 6 | %define EXE_stack_size EXE_realstacksize 7 | 8 | %macro EXE_begin 0 9 | ORG 0E0h 10 | section .text 11 | 12 | header_start: 13 | db 4Dh,5Ah ; EXE file signature 14 | dw EXE_allocsize % 512 15 | dw (EXE_allocsize + 511) / 512 16 | dw 0 ; relocation information: none 17 | dw (header_end-header_start)/16 ; header size in paragraphs 18 | dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem 19 | dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem 20 | dw -10h ; Initial SS (before fixup) 21 | dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK) 22 | dw 0 ; (no) Checksum 23 | dw 100h ; Initial IP - start just after the header 24 | dw -10h ; Initial CS (before fixup) 25 | dw 0 ; file offset to relocation table: none 26 | dw 0 ; (no overlay) 27 | align 16,db 0 28 | header_end: 29 | 30 | EXE_startcode: 31 | section .data 32 | EXE_startdata: 33 | section .bss 34 | EXE_startbss: 35 | %endmacro 36 | 37 | %macro EXE_stack 1 38 | EXE_realstacksize equ %1 39 | %define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end 40 | %endmacro 41 | 42 | %macro EXE_end 0 43 | section .text 44 | EXE_endcode: 45 | section .data 46 | EXE_enddata: 47 | section .bss 48 | alignb 4 49 | EXE_endbss: 50 | 51 | EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3) 52 | EXE_datasize equ EXE_enddata-EXE_startdata 53 | EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3) 54 | EXE_allocsize equ EXE_acodesize + EXE_datasize 55 | 56 | EXE_stack_size equ 0x800 ; default if nothing else was used 57 | %endmacro 58 | -------------------------------------------------------------------------------- /test/bintest.asm: -------------------------------------------------------------------------------- 1 | ;Testname=unoptimized; Arguments=-O0 -fbin -obintest.bin; Files=stdout stderr bintest.bin 2 | ;Testname=optimized; Arguments=-Ox -fbin -obintest.bin; Files=stdout stderr bintest.bin 3 | 4 | ; test source file for assembling to binary files 5 | ; build with: 6 | ; nasm -f bin -o bintest.com bintest.asm 7 | 8 | ; When run (as a DOS .COM file), this program should print 9 | ; hello, world 10 | ; on two successive lines, then exit cleanly. 11 | 12 | ; This file should test the following: 13 | ; [1] Define a text-section symbol 14 | ; [2] Define a data-section symbol 15 | ; [3] Define a BSS-section symbol 16 | ; [4] Define a NASM local label 17 | ; [5] Reference a NASM local label 18 | ; [6] Reference a text-section symbol in the text section 19 | ; [7] Reference a data-section symbol in the text section 20 | ; [8] Reference a BSS-section symbol in the text section 21 | ; [9] Reference a text-section symbol in the data section 22 | ; [10] Reference a data-section symbol in the data section 23 | ; [11] Reference a BSS-section symbol in the data section 24 | 25 | BITS 16 26 | ORG 0x100 27 | 28 | SECTION .text 29 | 30 | jmp start ; [6] 31 | 32 | endX mov ax,0x4c00 ; [1] 33 | int 0x21 34 | 35 | start mov byte [bss_sym],',' ; [1] [8] 36 | mov bx,[bssptr] ; [7] 37 | mov al,[bx] 38 | mov bx,[dataptr] ; [7] 39 | mov [bx],al 40 | mov cx,2 41 | .loop mov dx,datasym ; [1] [4] [7] 42 | mov ah,9 43 | push cx 44 | int 0x21 45 | pop cx 46 | loop .loop ; [5] [6] 47 | mov bx,[textptr] ; [7] 48 | jmp bx 49 | 50 | SECTION .data 51 | 52 | datasym db 'hello world', 13, 10, '$' ; [2] 53 | bssptr dw bss_sym ; [2] [11] 54 | dataptr dw datasym+5 ; [2] [10] 55 | textptr dw endX ; [2] [9] 56 | 57 | SECTION .bss 58 | 59 | bss_sym resb 1 ; [3] 60 | -------------------------------------------------------------------------------- /misc/genfma.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | %packed_insns = ( 3 | 'vfmadd' => 0x98, 4 | 'vfmaddsub' => 0x96, 5 | 'vfmsubadd' => 0x97, 6 | 'vfmsub' => 0x9a, 7 | 'vfnmadd' => 0x9c, 8 | 'vfnmsub' => 0x9e 9 | ); 10 | 11 | %scalar_insns = ( 12 | 'vfmadd' => 0x99, 13 | 'vfmsub' => 0x9b, 14 | 'vfnmadd' => 0x9d, 15 | 'vfnmsub' => 0x9f 16 | ); 17 | 18 | foreach $pi ( sort(keys(%packed_insns)) ) { 19 | $op = $packed_insns{$pi}; 20 | foreach $order ('132', '213', '231') { 21 | $xorder = substr($order,1,1).substr($order,0,1).substr($order,2,1); 22 | foreach $o ($order, $xorder) { 23 | for ($w = 0; $w < 2; $w++) { 24 | $suf = $w ? 'pd' : 'ps'; 25 | for ($l = 128; $l <= 256; $l <<= 1) { 26 | $sx = ($l == 256) ? 'SY' : 'SO'; 27 | $mm = ($l == 256) ? 'ymm' : 'xmm'; 28 | printf "%-15s %-31s %-8s%-39s %s\n", 29 | "\U${pi}${o}${suf}", 30 | "${mm}reg,${mm}reg,${mm}rm", 31 | "[rvm:", 32 | sprintf("vex.dds.%d.66.0f38.w%d %02x /r]", 33 | $l, $w, $op), 34 | "FMA,FUTURE,${sx}"; 35 | } 36 | } 37 | } 38 | $op += 0x10; 39 | } 40 | } 41 | 42 | foreach $si ( sort(keys(%scalar_insns)) ) { 43 | $op = $scalar_insns{$si}; 44 | foreach $order ('132', '213', '231') { 45 | $xorder = substr($order,1,1).substr($order,0,1).substr($order,2,1); 46 | foreach $o ($order, $xorder) { 47 | for ($w = 0; $w < 2; $w++) { 48 | $suf = $w ? 'sd' : 'ss'; 49 | $sx = $w ? 'SQ' : 'SD'; 50 | $l = 128; 51 | $mm = 'xmm'; 52 | printf "%-15s %-31s %-8s%-39s %s\n", 53 | "\U${si}${o}${suf}", 54 | "${mm}reg,${mm}reg,${mm}rm", 55 | '[rvm:', 56 | sprintf("vex.dds.%d.66.0f38.w%d %02x /r]", 57 | $l, $w, $op), 58 | "FMA,FUTURE,${sx}"; 59 | } 60 | } 61 | $op += 0x10; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /headers/c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2010 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | -------------------------------------------------------------------------------- /headers/doc: -------------------------------------------------------------------------------- 1 | \# -------------------------------------------------------------------------- 2 | \# 3 | \# Copyright 1996-2010 The NASM Authors - All Rights Reserved 4 | \# See the file AUTHORS included with the NASM distribution for 5 | \# the specific copyright holders. 6 | \# 7 | \# Redistribution and use in source and binary forms, with or without 8 | \# modification, are permitted provided that the following 9 | \# conditions are met: 10 | \# 11 | \# * Redistributions of source code must retain the above copyright 12 | \# notice, this list of conditions and the following disclaimer. 13 | \# * Redistributions in binary form must reproduce the above 14 | \# copyright notice, this list of conditions and the following 15 | \# disclaimer in the documentation and/or other materials provided 16 | \# with the distribution. 17 | \# 18 | \# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | \# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | \# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | \# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | \# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | \# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | \# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | \# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | \# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | \# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | \# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | \# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | \# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | \# 32 | \# -------------------------------------------------------------------------- 33 | 34 | -------------------------------------------------------------------------------- /headers/mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2010 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | -------------------------------------------------------------------------------- /test/immwarn.asm: -------------------------------------------------------------------------------- 1 | ;Testname=onowarn; Arguments=-Ox -DOPT=1 -DWARN=0 -fbin -oimmwarn.bin; Files=stdout stderr immwarn.bin 2 | ;Testname=owarn; Arguments=-Ox -DOPT=1 -DWARN=1 -fbin -oimmwarn.bin; Files=stdout stderr immwarn.bin 3 | ;Testname=nowarn; Arguments=-O0 -DOPT=0 -DWARN=0 -fbin -oimmwarn.bin; Files=stdout stderr immwarn.bin 4 | ;Testname=warn; Arguments=-O0 -DOPT=1 -DWARN=1 -fbin -oimmwarn.bin; Files=stdout stderr immwarn.bin 5 | 6 | %ifndef WARN 7 | %define WARN 1 8 | %endif 9 | 10 | bits 16 11 | push 1 12 | %if WARN 13 | push 0ffffffffh 14 | %endif 15 | push -1 16 | push 0ffffh 17 | push byte 0FFFFh 18 | 19 | add ax,0FFFFh 20 | %if WARN 21 | add ax,0FFFFFFFFh 22 | %endif 23 | add ax,-1 24 | add ax,byte 0FFFFh 25 | %if WARN 26 | add ax,byte 0FFFFFFFFh 27 | %endif 28 | add ax,-1 29 | 30 | add cx,0FFFFh 31 | %if WARN 32 | add cx,0FFFFFFFFh 33 | %endif 34 | add cx,-1 35 | add cx,byte 0FFFFh 36 | %if WARN 37 | add cx,byte 0FFFFFFFFh 38 | %endif 39 | add cx,-1 40 | 41 | bits 32 42 | push 1 43 | push 0ffffffffh 44 | push -1 45 | push 0ffffh 46 | 47 | push byte 1 48 | %if WARN 49 | push byte 0ffffh 50 | %endif 51 | push byte -1 52 | 53 | push word 1 54 | push word 0ffffh 55 | push word -1 56 | 57 | push dword 1 58 | push dword 0ffffffffh 59 | push dword -1 60 | 61 | add eax,0FFFFh 62 | add eax,0FFFFFFFFh 63 | add eax,-1 64 | 65 | add ecx,0FFFFh 66 | add ecx,0FFFFFFFFh 67 | add ecx,-1 68 | 69 | bits 64 70 | mov eax,7fffffffh 71 | mov eax,80000000h 72 | mov rax,7fffffffh 73 | mov rax,80000000h 74 | %if WARN 75 | mov rax,dword 80000000h 76 | %endif 77 | add rcx,0FFFFh 78 | %if WARN 79 | add rcx,0FFFFFFFFh 80 | %endif 81 | add rcx,-1 82 | 83 | add ecx,0FFFFh 84 | add ecx,0FFFFFFFFh 85 | add ecx,-1 86 | 87 | push byte 1 88 | %if WARN 89 | push byte 0ffffffffh 90 | %endif 91 | push byte -1 92 | -------------------------------------------------------------------------------- /headers/perl: -------------------------------------------------------------------------------- 1 | ## -------------------------------------------------------------------------- 2 | ## 3 | ## Copyright 1996-2010 The NASM Authors - All Rights Reserved 4 | ## See the file AUTHORS included with the NASM distribution for 5 | ## the specific copyright holders. 6 | ## 7 | ## Redistribution and use in source and binary forms, with or without 8 | ## modification, are permitted provided that the following 9 | ## conditions are met: 10 | ## 11 | ## * Redistributions of source code must retain the above copyright 12 | ## notice, this list of conditions and the following disclaimer. 13 | ## * Redistributions in binary form must reproduce the above 14 | ## copyright notice, this list of conditions and the following 15 | ## disclaimer in the documentation and/or other materials provided 16 | ## with the distribution. 17 | ## 18 | ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ## 32 | ## -------------------------------------------------------------------------- 33 | 34 | -------------------------------------------------------------------------------- /test/macro-defaults.asm: -------------------------------------------------------------------------------- 1 | ;Testname=warning; Arguments=-fbin -omacdef.bin -w+macro-defaults; Files=stdout stderr macdef.bin 2 | ;Testname=nonwarning; Arguments=-fbin -omacdef.bin -w-macro-defaults; Files=stdout stderr macdef.bin 3 | 4 | %MACRO mmac_fix 1 a 5 | ; While defined to take one parameter, any invocation will 6 | ; see two, due to the default parameter. 7 | %warning %0 %1 %2 %3 %4 %5 8 | %ENDMACRO 9 | mmac_fix one 10 | 11 | %MACRO mmac_var 1-2 a,b 12 | ; While defined to take one or two parameters, invocations 13 | ; will see three, due to the default parameters. 14 | %warning %0 %1 %2 %3 %4 %5 15 | %ENDMACRO 16 | mmac_var one 17 | mmac_var one,two 18 | 19 | %MACRO mmac_plus 1-2+ a,b 20 | ; This does not warn. Although this looks like two default 21 | ; parameters, it ends up being only one: the "+" limits it 22 | ; to two parameters; if invoked without a second parameter 23 | ; the second parameter will be "a,b". 24 | %warning %0 %1 %2 %3 %4 %5 25 | ;Check rotating behaviour 26 | %ENDMACRO 27 | mmac_plus one 28 | mmac_plus one,two 29 | mmac_plus one,two,three 30 | 31 | %MACRO mmac_star 1-* a,b 32 | ; This does not warn. Because the "*" extends the range of 33 | ; parameters to infinity, the "a,b" default parameters can 34 | ; not exceed that range. 35 | %warning %0 %1 %2 %3 %4 %5 36 | %ENDMACRO 37 | mmac_star one 38 | mmac_star one,two 39 | mmac_star one,two,three 40 | 41 | %MACRO mmac_rotate 0-* a,b 42 | %warning %0 %1 %2 %3 %4 %5 43 | ;%rotate should rotate all parameters 44 | %rotate 1 45 | %warning %0 %1 %2 %3 %4 %5 46 | %ENDMACRO 47 | mmac_rotate 48 | mmac_rotate one 49 | mmac_rotate one,two 50 | mmac_rotate one,two,three 51 | 52 | ;Scope / evaluation time test 53 | %define I 0 54 | %assign J 0 55 | %xdefine K 0 56 | 57 | %MACRO mmac_scope 0 I J K 58 | %warning %1 %2 %3 59 | %ENDMACRO 60 | 61 | %define I 1 62 | %assign J 1 63 | %xdefine K 1 64 | mmac_scope 65 | -------------------------------------------------------------------------------- /output/outas86.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: as86 35 | %define __SECT__ [section .text] 36 | %macro __NASM_CDecl__ 1 37 | %endmacro 38 | -------------------------------------------------------------------------------- /output/outaout.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: aout aoutb 35 | %define __SECT__ [section .text] 36 | %macro __NASM_CDecl__ 1 37 | %endmacro 38 | -------------------------------------------------------------------------------- /misc/findleak.txt: -------------------------------------------------------------------------------- 1 | Subject: [nasm-devel] tool to help find memory leaks 2 | Date: Fri, 02 Nov 2001 22:08:01 -0500 3 | From: Ed Beroset 4 | Reply-To: nasm-devel@yahoogroups.com 5 | To: nasm-devel@yahoogroups.com 6 | 7 | Here's a little Perl script I wrote a while ago to help track down memory 8 | leaks in nasm. First, compile nasm with LOGALLOC defined (see 9 | nasmlib.c). That creates a log file of all allocs and frees. This Perl 10 | script reads that file and tells you which source code lines caused a leak 11 | (or a free of unallocated memory). There are many leaks, almost all of 12 | them in the preprocessor. 13 | 14 | -+--- findleak.pl begins 15 | #!/usr/bin/perl 16 | my %mem = {}; 17 | my %alloc = {}; 18 | while(<>) 19 | { 20 | if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/) 21 | { 22 | $mem{$1}--; 23 | if ($mem{$1} != 0) { 24 | print "free before alloc! $_"; 25 | } 26 | if ($mem{$2} != 0) { 27 | print "memory leak! $_"; 28 | } 29 | $mem{$2}++; 30 | $alloc{$2} = $_; 31 | } 32 | elsif (/free\((0x[0-9a-f]+)/) 33 | { 34 | $mem{$1}--; 35 | if ($mem{$1} != 0) { 36 | print "free before alloc! $_"; 37 | } 38 | } 39 | elsif (m/returns (0x[0-9a-f]+)/) 40 | { 41 | if ($mem{$1} != 0) { 42 | print "memory leak! $_"; 43 | } 44 | $mem{$1}++; 45 | $alloc{$1} = $_; 46 | } 47 | } 48 | foreach $goo (sort keys %mem) 49 | { 50 | if ($mem{$goo}) 51 | { 52 | print "$mem{$goo} $alloc{$goo}"; 53 | } 54 | } 55 | -+--- findleak.pl ends 56 | 57 | 58 | 59 | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 60 | -------------------------------------------------------------------------------- /output/outmacho.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: macho macho32 macho64 35 | %define __SECT__ [section .text] 36 | %macro __NASM_CDecl__ 1 37 | %endmacro 38 | -------------------------------------------------------------------------------- /test/dtbcd.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; This is a macro to generate packed BCD constants. 3 | ; It is obsoleted by "dt" with a packed BCD value with a "p" 4 | ; suffix, but it is included here as a rest of nested %rep. 5 | ; 6 | %macro dtbcd 1-*.nolist 7 | %push dtbcd 8 | %rep %0 9 | %defstr %$abc %1 10 | %substr %$sign %$abc 1 11 | %if %$sign == '-' 12 | %substr %$abc %$abc 2,-1 13 | %xdefine %$sign 0x80 14 | %elif %$sign == '+' 15 | %substr %$abc %$abc 2,-1 16 | %xdefine %$sign 0x00 17 | %else 18 | %xdefine %$sign 0x00 19 | %endif 20 | %strlen %$abclen %$abc 21 | %defstr %$abclen_str %$abclen 22 | %assign %$pos %$abclen 23 | %assign %$bc 0 24 | %assign %$ld -1 25 | %rep %$abclen 26 | %substr %$chr %$abc %$pos 27 | %assign %$pos %$pos-1 28 | %if %$chr >= '0' && %$chr <= '9' 29 | %if %$ld < 0 30 | %assign %$ld %$chr-'0' 31 | %assign %$bc %$bc+1 32 | %if %$bc > 9 33 | %warning "too many digits in BCD constant" 34 | %exitrep 35 | %endif 36 | %else 37 | db %$ld+((%$chr-'0') << 4) 38 | %assign %$ld -1 39 | %endif 40 | %elif %$chr == '_' 41 | ; Do nothing... 42 | %else 43 | %error "invalid character in BCD constant" 44 | %exitrep 45 | %endif 46 | %endrep 47 | %if %$ld >= 0 48 | db %$ld 49 | %endif 50 | %rep 9-%$bc 51 | db 0 52 | %endrep 53 | db %$sign 54 | %rotate 1 55 | %endrep 56 | %pop 57 | %endmacro 58 | 59 | dtbcd 123, -456, +789 60 | dt 123p, -456p, +789p 61 | dtbcd 765432109876543210 62 | dt 765432109876543210p 63 | dtbcd -765432109876543210 64 | dt -765432109876543210p 65 | dtbcd +765_432_109_876_543_210 66 | dt +765_432_109_876_543_210p 67 | dtbcd -765_432_109_876_543_210 68 | dt -765_432_109_876_543_210p 69 | 70 | ;; Both of these should warn... 71 | dtbcd 8_765_432_109_876_543_210 72 | dt 8_765_432_109_876_543_210p 73 | -------------------------------------------------------------------------------- /test/utf.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -outf.bin; Files=stdout stderr utf.bin 2 | ;Testname=error; Arguments=-fbin -outf.bin -DERROR; Files=stdout stderr utf.bin 3 | %define u(x) __utf16__(x) 4 | %define w(x) __utf32__(x) 5 | %define ul(x) __utf16le__(x) 6 | %define wl(x) __utf32le__(x) 7 | %define ub(x) __utf16be__(x) 8 | %define wb(x) __utf32be__(x) 9 | 10 | db `Test \u306a\U0001abcd\n` 11 | dw u(`Test \u306a\U0001abcd\n`) 12 | dd w(`Test \u306a\U0001abcd\n`) 13 | 14 | db `\u306a` 15 | db `\xe3\x81\xaa` 16 | 17 | dw __utf16__ "Hello, World!" 18 | 19 | nop 20 | 21 | mov ax,u(`a`) 22 | mov bx,u(`\u306a`) 23 | mov cx,u(`\xe3\x81\xaa`) 24 | mov eax,u(`ab`) 25 | mov ebx,u(`\U0001abcd`) 26 | mov ecx,w(`\U0001abcd`) 27 | 28 | db `Test \u306a\U0001abcd\n` 29 | dw ul(`Test \u306a\U0001abcd\n`) 30 | dd wl(`Test \u306a\U0001abcd\n`) 31 | 32 | db `\u306a` 33 | db `\xe3\x81\xaa` 34 | 35 | dw __utf16le__ "Hello, World!" 36 | 37 | nop 38 | 39 | mov ax,ul(`a`) 40 | mov bx,ul(`\u306a`) 41 | mov cx,ul(`\xe3\x81\xaa`) 42 | mov eax,ul(`ab`) 43 | mov ebx,ul(`\U0001abcd`) 44 | mov ecx,wl(`\U0001abcd`) 45 | 46 | db `Test \u306a\U0001abcd\n` 47 | dw ub(`Test \u306a\U0001abcd\n`) 48 | dd wb(`Test \u306a\U0001abcd\n`) 49 | 50 | db `\u306a` 51 | db `\xe3\x81\xaa` 52 | 53 | dw __utf16be__ "Hello, World!" 54 | 55 | nop 56 | 57 | mov ax,ub(`a`) 58 | mov bx,ub(`\u306a`) 59 | mov cx,ub(`\xe3\x81\xaa`) 60 | mov eax,ub(`ab`) 61 | mov ebx,ub(`\U0001abcd`) 62 | mov ecx,wb(`\U0001abcd`) 63 | 64 | %ifdef ERROR 65 | dw __utf16__ 33 66 | dw __utf16__, 46 67 | dw __utf16__("Hello, World!",16) 68 | dw __utf16__("Hello, World!",16 69 | dw u(`\xff`) 70 | 71 | dw __utf16le__ 33 72 | dw __utf16le__, 46 73 | dw __utf16le__("Hello, World!",16) 74 | dw __utf16le__("Hello, World!",16 75 | dw ul(`\xff`) 76 | 77 | dw __utf16be__ 33 78 | dw __utf16be__, 46 79 | dw __utf16be__("Hello, World!",16) 80 | dw __utf16be__("Hello, World!",16 81 | dw ub(`\xff`) 82 | %endif 83 | -------------------------------------------------------------------------------- /output/outbin.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: bin 35 | %define __SECT__ [section .text] 36 | %imacro org 1+.nolist 37 | [org %1] 38 | %endmacro 39 | %macro __NASM_CDecl__ 1 40 | %endmacro 41 | -------------------------------------------------------------------------------- /output/outrdf.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: rdf 35 | %define __SECT__ [section .text] 36 | %imacro library 1+.nolist 37 | [library %1] 38 | %endmacro 39 | %macro __NASM_CDecl__ 1 40 | %endmacro 41 | -------------------------------------------------------------------------------- /output/outelf.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: elf elf32 elf64 35 | %define __SECT__ [section .text] 36 | %macro __NASM_CDecl__ 1 37 | %define $_%1 $%1 38 | %endmacro 39 | %macro osabi 1+.nolist 40 | [osabi %1] 41 | %endmacro 42 | -------------------------------------------------------------------------------- /output/outrdf2.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: rdf2 35 | %define __SECT__ [section .text] 36 | %imacro library 1+.nolist 37 | [library %1] 38 | %endmacro 39 | %imacro module 1+.nolist 40 | [module %1] 41 | %endmacro 42 | %macro __NASM_CDecl__ 1 43 | %endmacro 44 | -------------------------------------------------------------------------------- /listing.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * listing.h header file for listing.c 36 | */ 37 | 38 | #ifndef NASM_LISTING_H 39 | #define NASM_LISTING_H 40 | 41 | extern ListGen nasmlist; 42 | extern int user_nolist; /* fbk - 9/1/00 */ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /output/outcoff.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: coff win32 win64 35 | %define __SECT__ [section .text] 36 | %macro __NASM_CDecl__ 1 37 | %endmacro 38 | %imacro export 1+.nolist 39 | [export %1] 40 | %endmacro 41 | %imacro safeseh 1.nolist 42 | [safeseh %1] 43 | %endmacro 44 | -------------------------------------------------------------------------------- /quote.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #ifndef NASM_QUOTE_H 35 | #define NASM_QUOTE_H 36 | 37 | #include "compiler.h" 38 | 39 | char *nasm_quote(char *str, size_t len); 40 | size_t nasm_unquote(char *str, char **endptr); 41 | char *nasm_skip_string(char *str); 42 | 43 | #endif /* NASM_QUOTE_H */ 44 | 45 | -------------------------------------------------------------------------------- /sync.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * sync.h header file for sync.c 36 | */ 37 | 38 | #ifndef NASM_SYNC_H 39 | #define NASM_SYNC_H 40 | 41 | void init_sync(void); 42 | void add_sync(uint32_t position, uint32_t length); 43 | uint32_t next_sync(uint32_t position, uint32_t *length); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /rdoff/Mkfiles/Makefile.sc: -------------------------------------------------------------------------------- 1 | # Makefile for RDOFF object file utils; part of the Netwide Assembler 2 | # 3 | # The Netwide Assembler is copyright (C) 1996 Simon Tatham and 4 | # Julian Hall. All rights reserved. The software is 5 | # redistributable under the license given in the file "LICENSE" 6 | # distributed in the NASM archive. 7 | # 8 | # This Makefile is designed for use under Unix (probably fairly 9 | # portably). 10 | 11 | CC = sc 12 | CCFLAGS = -I..\ -c -a1 -mn -Nc -w2 -w7 -o+time -5 13 | LINK = link 14 | LINKFLAGS = /noi /exet:NT /su:console 15 | 16 | OBJ=obj 17 | EXE=.exe 18 | 19 | NASMLIB = ..\nasmlib.$(OBJ) 20 | NASMLIB_H = ..\nasmlib.h 21 | LDRDFLIBS = rdoff.$(OBJ) $(NASMLIB) symtab.$(OBJ) collectn.$(OBJ) rdlib.$(OBJ) 22 | RDXLIBS = rdoff.$(OBJ) rdfload.$(OBJ) symtab.$(OBJ) collectn.$(OBJ) 23 | 24 | .c.$(OBJ): 25 | $(CC) $(CCFLAGS) $*.c 26 | 27 | all : rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) rdf2com$(EXE) 28 | 29 | rdfdump$(EXE) : rdfdump.$(OBJ) 30 | $(LINK) $(LINKFLAGS) rdfdump.$(OBJ), rdfdump$(EXE); 31 | ldrdf$(EXE) : ldrdf.$(OBJ) $(LDRDFLIBS) 32 | $(LINK) $(LINKFLAGS) ldrdf.$(OBJ) $(LDRDFLIBS), ldrdf$(EXE); 33 | rdx$(EXE) : rdx.$(OBJ) $(RDXLIBS) 34 | $(LINK) $(LINKFLAGS) rdx.$(OBJ) $(RDXLIBS), rdx$(EXE); 35 | rdflib$(EXE) : rdflib.$(OBJ) 36 | $(LINK) $(LINKFLAGS) rdflib.$(OBJ), rdflib$(EXE); 37 | rdf2bin$(EXE) : rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB) 38 | $(LINK) $(LINKFLAGS) rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB), rdf2bin$(EXE); 39 | rdf2com$(EXE) : rdf2bin$(EXE) 40 | copy rdf2bin$(EXE) rdf2com$(EXE) 41 | 42 | rdf2bin.$(OBJ) : rdf2bin.c 43 | rdfdump.$(OBJ) : rdfdump.c 44 | rdoff.$(OBJ) : rdoff.c rdoff.h 45 | ldrdf.$(OBJ) : ldrdf.c rdoff.h $(NASMLIB_H) symtab.h collectn.h rdlib.h 46 | symtab.$(OBJ) : symtab.c symtab.h 47 | collectn.$(OBJ) : collectn.c collectn.h 48 | rdx.$(OBJ) : rdx.c rdoff.h rdfload.h symtab.h 49 | rdfload.$(OBJ) : rdfload.c rdfload.h rdoff.h collectn.h symtab.h 50 | rdlib.$(OBJ) : rdlib.c rdlib.h 51 | rdflib.$(OBJ) : rdflib.c 52 | 53 | clean : 54 | del *.$(OBJ) rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) 55 | 56 | 57 | -------------------------------------------------------------------------------- /rdoff/ldsegs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ldsegs.h Data for 'ldrdf' to determine what to do with different 3 | * types of segment. This may be useful in other contexts also. 4 | */ 5 | 6 | #ifndef RDOFF_LDSEGS_H 7 | #define RDOFF_LDSEGS_H 1 8 | 9 | #include 10 | 11 | struct segconfig { 12 | uint16_t typelow, typehi; /* range of seg nos for which this is valid */ 13 | char *typedesc; /* a description of the segment type */ 14 | uint16_t dowhat; /* one of the SEG_xxxx values below */ 15 | uint16_t mergetype; /* if SEG_MERGE what type segment do we merge 16 | with? 17 | 0 -> same type of segment. This type is also 18 | used with SEG_NEWSEG. */ 19 | }; 20 | 21 | #define SEG_IGNORE 0 22 | #define SEG_NEWSEG 1 23 | #define SEG_MERGE 2 24 | 25 | #define SEGCONFIGMAX 11 26 | 27 | struct segconfig sconft[SEGCONFIGMAX] = { 28 | {0x0000, 0x0000, "NULL segment", 0, 0}, 29 | {0x0001, 0x0001, "text", 2, 0}, 30 | {0x0002, 0x0002, "data", 2, 0}, 31 | {0x0003, 0x0003, "comment(ignored)", 0, 0}, 32 | {0x0004, 0x0005, "comment(kept)", 2, 0}, 33 | {0x0006, 0x0007, "debug information", 2, 0}, 34 | {0x0008, 0x001F, "reserved(general extensions)", 1, 0}, 35 | {0x0020, 0x0FFF, "reserved(MOSCOW)", 1, 0}, 36 | {0x1000, 0x7FFF, "reserved(system dependant)", 1, 0}, 37 | {0x8000, 0xFFFE, "reserved(other)", 1, 0}, 38 | {0xFFFF, 0xFFFF, "invalid segment", 0, 0} 39 | }; 40 | 41 | #define getsegconfig(target,number) \ 42 | { \ 43 | int _i; \ 44 | int _t = number; \ 45 | for (_i = 0; _i < SEGCONFIGMAX; _i++) \ 46 | if (_t >= sconft[_i].typelow && _t <= sconft[_i].typehi) \ 47 | { \ 48 | target = sconft[_i]; \ 49 | if (target.mergetype == 0) target.mergetype = _t; \ 50 | break; \ 51 | } \ 52 | if (_i == SEGCONFIGMAX) \ 53 | { \ 54 | fprintf(stderr, "PANIC: can't find segment %04X in segconfig\n",\ 55 | _t); \ 56 | exit(1); \ 57 | } \ 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /output/outobj.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | OUT: obj 35 | %define __SECT__ [section .text] 36 | %imacro group 1+.nolist 37 | [group %1] 38 | %endmacro 39 | %imacro uppercase 0+.nolist 40 | [uppercase %1] 41 | %endmacro 42 | %imacro export 1+.nolist 43 | [export %1] 44 | %endmacro 45 | %imacro import 1+.nolist 46 | [import %1] 47 | %endmacro 48 | %macro __NASM_CDecl__ 1 49 | %endmacro 50 | -------------------------------------------------------------------------------- /parser.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * parser.h header file for the parser module of the Netwide 36 | * Assembler 37 | */ 38 | 39 | #ifndef NASM_PARSER_H 40 | #define NASM_PARSER_H 41 | 42 | void parser_global_info(struct location *locp); 43 | insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef); 44 | void cleanup_insn(insn *instruction); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /rdoff/segtab.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #ifndef RDOFF_SEGTAB_H 35 | #define RDOFF_SEGTAB_H 1 36 | 37 | #include 38 | 39 | typedef void *segtab; 40 | 41 | void init_seglocations(segtab * r); 42 | void add_seglocation(segtab * r, int localseg, int destseg, int32_t offset); 43 | int get_seglocation(segtab * r, int localseg, int *destseg, int32_t *offset); 44 | void done_seglocations(segtab * r); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /test/imm64.asm: -------------------------------------------------------------------------------- 1 | ;Testname=imm64-O0; Arguments=-O0 -fbin -oimm64.bin; Files=stdout stderr imm64.bin 2 | ;Testname=imm64-O1; Arguments=-O1 -fbin -oimm64.bin; Files=stdout stderr imm64.bin 3 | ;Testname=imm64-Ox; Arguments=-Ox -fbin -oimm64.bin; Files=stdout stderr imm64.bin 4 | 5 | bits 64 6 | mov rax,11223344h 7 | mov rax,dword 11223344h 8 | mov eax,11223344h 9 | mov [rax],dword 11223344h ; 32-bit operation 10 | mov qword [rax],11223344h 11 | mov qword [rax],dword 11223344h 12 | 13 | mov rax,0_ffffffff_8899aabbh 14 | mov rax,dword 0_ffffffff_8899aabbh 15 | mov eax,0_ffffffff_8899aabbh 16 | mov [rax],dword 0_ffffffff_8899aabbh ; 32-bit operation 17 | mov qword [rax],0_ffffffff_8899aabbh 18 | mov qword [rax],dword 0_ffffffff_8899aabbh 19 | 20 | mov rax,7fffffffh 21 | mov rax,80000000h 22 | mov rax,0_ffffffffh 23 | mov rax,1_00000000h 24 | mov rax,0_ffffffff_7fffffffh 25 | mov rax,0_ffffffff_80000000h 26 | 27 | mov rax,0_11223344_8899aabbh 28 | mov rax,dword 0_11223344_8899aabbh 29 | mov eax,0_11223344_8899aabbh 30 | mov [rax],dword 0_11223344_8899aabbh ; 32-bit operation 31 | mov qword [rax],0_11223344_8899aabbh 32 | mov qword [rax],dword 0_11223344_8899aabbh 33 | 34 | mov rax,strict 11223344h 35 | mov rax,strict dword 11223344h 36 | mov eax,strict 11223344h 37 | mov [rax],strict dword 11223344h ; 32-bit operation 38 | mov qword [rax],strict 11223344h 39 | mov qword [rax],strict dword 11223344h 40 | 41 | mov rax,strict 0_ffffffff_8899aabbh 42 | mov rax,strict dword 0_ffffffff_8899aabbh 43 | mov eax,strict 0_ffffffff_8899aabbh 44 | mov [rax],strict dword 0_ffffffff_8899aabbh ; 32-bit operation 45 | mov qword [rax],strict 0_ffffffff_8899aabbh 46 | mov qword [rax],strict dword 0_ffffffff_8899aabbh 47 | 48 | mov rax,strict 7fffffffh 49 | mov rax,strict 80000000h 50 | mov rax,strict 0_ffffffffh 51 | mov rax,strict 1_00000000h 52 | mov rax,strict 0_ffffffff_7fffffffh 53 | mov rax,strict 0_ffffffff_80000000h 54 | 55 | mov rax,strict 0_11223344_8899aabbh 56 | mov rax,strict dword 0_11223344_8899aabbh 57 | mov eax,strict 0_11223344_8899aabbh 58 | mov [rax],strict dword 0_11223344_8899aabbh ; 32-bit operation 59 | mov qword [rax],strict 0_11223344_8899aabbh 60 | mov qword [rax],strict dword 0_11223344_8899aabbh 61 | 62 | -------------------------------------------------------------------------------- /test/lar_lsl.asm: -------------------------------------------------------------------------------- 1 | ;Testname=test; Arguments=-fbin -olar_lsl.bin; Files=stdout stderr lar_lsl.bin 2 | 3 | ; LAR/LSL 4 | ;--------- 5 | 6 | ; 1x ; = invalid due to lack of REX 7 | ; 3x ; = invalid due to Mw 8 | 9 | %macro m 1 10 | 11 | bits 16 12 | 13 | %1 ax, ax 14 | %1 ax,eax 15 | ; %1 ax,rax 16 | 17 | %1 eax, ax 18 | %1 eax,eax 19 | ; %1 eax,rax 20 | 21 | ; %1 rax, ax 22 | ; %1 rax,eax 23 | ; %1 rax,rax 24 | 25 | %1 ax, [0] 26 | %1 ax, word [0] 27 | ;;; %1 ax,dword [0] 28 | ; %1 ax,qword [0] 29 | 30 | %1 eax, [0] 31 | %1 eax, word [0] 32 | ;;; %1 eax,dword [0] 33 | ; %1 eax,qword [0] 34 | 35 | ; %1 rax, [0] 36 | ; %1 rax, word [0] 37 | ; %1 rax,dword [0] 38 | ; %1 rax,qword [0] 39 | 40 | bits 32 41 | 42 | %1 ax, ax 43 | %1 ax,eax 44 | ; %1 ax,rax 45 | 46 | %1 eax, ax 47 | %1 eax,eax 48 | ; %1 eax,rax 49 | 50 | ; %1 rax, ax 51 | ; %1 rax,eax 52 | ; %1 rax,rax 53 | 54 | %1 ax, [0] 55 | %1 ax, word [0] 56 | ;;; %1 ax,dword [0] 57 | ; %1 ax,qword [0] 58 | 59 | %1 eax, [0] 60 | %1 eax, word [0] 61 | ;;; %1 eax,dword [0] 62 | ; %1 eax,qword [0] 63 | 64 | ; %1 rax, [0] 65 | ; %1 rax, word [0] 66 | ; %1 rax,dword [0] 67 | ; %1 rax,qword [0] 68 | 69 | bits 64 70 | 71 | %1 ax, ax 72 | %1 ax,eax 73 | %1 ax,rax ; $TODO: shouldn't emit REX.W $ 74 | 75 | %1 eax, ax 76 | %1 eax,eax 77 | %1 eax,rax ; $TODO: shouldn't emit REX.W $ 78 | 79 | %1 rax, ax 80 | %1 rax,eax 81 | %1 rax,rax 82 | 83 | %1 ax, [0] 84 | %1 ax, word [0] 85 | ;;; %1 ax,dword [0] 86 | ;;; %1 ax,qword [0] 87 | 88 | %1 eax, [0] 89 | %1 eax, word [0] 90 | ;;; %1 eax,dword [0] 91 | ;;; %1 eax,qword [0] 92 | 93 | %1 rax, [0] 94 | %1 rax, word [0] 95 | ;;; %1 rax,dword [0] 96 | ;;; %1 rax,qword [0] 97 | 98 | %endmacro 99 | 100 | m lar 101 | 102 | m lsl 103 | 104 | bits 16 105 | lar ax,[ si] 106 | lar ax,[esi] 107 | bits 32 108 | lar ax,[ si] 109 | lar ax,[esi] 110 | bits 64 111 | lar ax,[esi] 112 | lar ax,[rsi] 113 | 114 | bits 16 115 | lsl ax,[ si] 116 | lsl ax,[esi] 117 | bits 32 118 | lsl ax,[ si] 119 | lsl ax,[esi] 120 | bits 64 121 | lar ax,[esi] 122 | lsl ax,[rsi] 123 | 124 | ; EOF 125 | -------------------------------------------------------------------------------- /misc/exebin2.mac: -------------------------------------------------------------------------------- 1 | ; -*- nasm -*- 2 | 3 | ; NASM macro file to allow the `bin' output format to generate 4 | 5 | ; simple .EXE files by constructing the EXE header by hand. 6 | 7 | ; Adapted from a contribution by Yann Guidon 8 | 9 | 10 | 11 | %define EXE_stack_size EXE_realstacksize 12 | 13 | 14 | 15 | %macro EXE_begin 0 16 | 17 | ORG 0E0h 18 | 19 | section .text 20 | 21 | 22 | 23 | header_start: 24 | 25 | db 4Dh,5Ah ; EXE file signature 26 | 27 | dw EXE_allocsize % 512 28 | 29 | dw (EXE_allocsize + 511) / 512 30 | 31 | dw 0 ; relocation information: none 32 | 33 | dw (header_end-header_start)/16 ; header size in paragraphs 34 | 35 | dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem 36 | 37 | dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem 38 | 39 | dw -10h ; Initial SS (before fixup) 40 | 41 | dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK) 42 | 43 | dw 0 ; (no) Checksum 44 | 45 | dw 100h ; Initial IP - start just after the header 46 | 47 | dw -10h ; Initial CS (before fixup) 48 | 49 | dw 0 ; file offset to relocation table: none 50 | 51 | dw 0 ; (no overlay) 52 | 53 | align 16,db 0 54 | 55 | header_end: 56 | 57 | 58 | 59 | EXE_startcode: 60 | 61 | section .data 62 | 63 | EXE_startdata: 64 | 65 | section .bss 66 | 67 | EXE_startbss: 68 | 69 | %endmacro 70 | 71 | 72 | 73 | %macro EXE_stack 1 74 | 75 | EXE_realstacksize equ %1 76 | 77 | %define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end 78 | 79 | %endmacro 80 | 81 | 82 | 83 | %macro EXE_end 0 84 | 85 | section .text 86 | 87 | EXE_endcode: 88 | 89 | section .data 90 | 91 | EXE_enddata: 92 | 93 | section .bss 94 | 95 | alignb 4 96 | 97 | EXE_endbss: 98 | 99 | 100 | 101 | EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3) 102 | 103 | EXE_datasize equ EXE_enddata-EXE_startdata 104 | 105 | EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3) 106 | 107 | EXE_allocsize equ EXE_acodesize + EXE_datasize 108 | 109 | 110 | 111 | EXE_stack_size equ 0x800 ; default if nothing else was used 112 | 113 | %endmacro 114 | 115 | -------------------------------------------------------------------------------- /stdscan.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * stdscan.h header file for stdscan.c 36 | */ 37 | 38 | #ifndef NASM_STDSCAN_H 39 | #define NASM_STDSCAN_H 40 | 41 | /* Standard scanner */ 42 | void stdscan_set(char *str); 43 | char *stdscan_get(void); 44 | void stdscan_reset(void); 45 | int stdscan(void *private_data, struct tokenval *tv); 46 | int nasm_token_hash(const char *token, struct tokenval *tv); 47 | void stdscan_cleanup(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /disasm.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * disasm.h header file for disasm.c 36 | */ 37 | 38 | #ifndef NASM_DISASM_H 39 | #define NASM_DISASM_H 40 | 41 | #define INSN_MAX 32 /* one instruction can't be longer than this */ 42 | 43 | int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize, 44 | int32_t offset, int autosync, uint32_t prefer); 45 | int32_t eatbyte(uint8_t *data, char *output, int outbufsize, int segsize); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /assemble.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * assemble.h header file for assemble.c 36 | */ 37 | 38 | #ifndef NASM_ASSEMBLE_H 39 | #define NASM_ASSEMBLE_H 40 | 41 | int64_t insn_size(int32_t segment, int64_t offset, int bits, uint32_t cp, 42 | insn * instruction, efunc error); 43 | int64_t assemble(int32_t segment, int64_t offset, int bits, uint32_t cp, 44 | insn * instruction, struct ofmt *output, efunc error, 45 | ListGen * listgen); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ver.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #include "nasm.h" 35 | #include "version.h" 36 | 37 | /* This is printed when entering nasm -v */ 38 | const char nasm_version[] = NASM_VER; 39 | const char nasm_date[] = __DATE__; 40 | const char nasm_compile_options[] = "" 41 | #ifdef DEBUG 42 | " with -DDEBUG" 43 | #endif 44 | ; 45 | 46 | /* These are used by some backends. */ 47 | const char nasm_comment[] = 48 | "The Netwide Assembler " NASM_VER; 49 | 50 | const char nasm_signature[] = 51 | "NASM " NASM_VER; 52 | -------------------------------------------------------------------------------- /output/outlib.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * libout.c 36 | * 37 | * Common routines for the output backends. 38 | */ 39 | 40 | #include "compiler.h" 41 | #include "nasm.h" 42 | #include "output/outlib.h" 43 | 44 | uint64_t realsize(enum out_type type, uint64_t size) 45 | { 46 | switch (type) { 47 | case OUT_REL1ADR: 48 | return 1; 49 | case OUT_REL2ADR: 50 | return 2; 51 | case OUT_REL4ADR: 52 | return 4; 53 | case OUT_REL8ADR: 54 | return 8; 55 | default: 56 | return size; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test/multisection.asm: -------------------------------------------------------------------------------- 1 | ;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 2 | ;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 3 | ;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 4 | ;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 5 | ;Testname=elf64; Arguments=-felf64 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 6 | ;Testname=obj; Arguments=-fobj -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 7 | ;Testname=rdf; Arguments=-frdf -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 8 | ;Testname=win32; Arguments=-fwin32 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 9 | ;Testname=win64; Arguments=-fwin64 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o 10 | 11 | ; To test where code that is placed before any explicit SECTION 12 | ; gets placed, and what happens if a .text section has an ORG 13 | ;statement, uncomment the following lines. 14 | ; 15 | ; times 10h nop 16 | ; 17 | ;section .text 18 | ;org 0x300 19 | ; times 20h inc ax 20 | 21 | ; let's see which of these sections can be placed in the specified order. 22 | 23 | section .appspecific 24 | section .data 25 | section .stringdata 26 | section .mytext 27 | section .code 28 | section .extra_code 29 | 30 | 31 | section .stringdata 32 | mystr1: db "Hello, this is string 1", 13, 10, '$' 33 | 34 | section .extra_code 35 | org 0x200 36 | bits 16 37 | more: 38 | mov si, asciz1 39 | mov ah, 0x0E 40 | xor bx, bx 41 | .print: 42 | lodsb 43 | test al, al 44 | jz .end 45 | int 0x10 46 | jmp short .print 47 | .end: 48 | 49 | xor ax, ax 50 | int 0x16 51 | 52 | mov ax, 0x4c00 53 | int 0x21 54 | 55 | section .appspecific 56 | asciz1: db "This is string 2", 0 57 | 58 | section .code 59 | org 0x100 60 | bits 16 61 | 62 | start: 63 | mov dx, mystr1 64 | mov ah, 9 65 | int 0x21 66 | 67 | xor ax, ax 68 | int 0x16 69 | 70 | jmp more 71 | 72 | section .text 73 | xor eax,eax 74 | times 50h nop 75 | 76 | section .mytext 77 | 78 | xor ebx,ebx 79 | 80 | section .data 81 | db 95h,95h,95h,95h,95h,95h,95h,95h 82 | 83 | section .hmm 84 | resd 2 85 | 86 | section .bss 87 | resd 8 88 | 89 | section .final1 90 | inc ax 91 | 92 | section .final2 93 | inc bx 94 | 95 | section .final3 96 | inc cx 97 | -------------------------------------------------------------------------------- /float.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * float.h header file for the floating-point constant module of 36 | * the Netwide Assembler 37 | */ 38 | 39 | #ifndef NASM_FLOAT_H 40 | #define NASM_FLOAT_H 41 | 42 | #include "nasm.h" 43 | 44 | enum float_round { 45 | FLOAT_RC_NEAR, 46 | FLOAT_RC_ZERO, 47 | FLOAT_RC_DOWN, 48 | FLOAT_RC_UP, 49 | }; 50 | 51 | int float_const(const char *string, int sign, uint8_t *result, int bytes, 52 | efunc error); 53 | int float_option(const char *option); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /test/vgather.asm: -------------------------------------------------------------------------------- 1 | bits 64 2 | 3 | vgatherdpd xmm0,[rcx+xmm2],xmm3 4 | vgatherqpd xmm0,[rcx+xmm2],xmm3 5 | vgatherdpd ymm0,[rcx+xmm2],ymm3 6 | vgatherqpd ymm0,[rcx+ymm2],ymm3 7 | 8 | vgatherdpd xmm0,[rcx+xmm2*1],xmm3 9 | vgatherqpd xmm0,[rcx+xmm2*1],xmm3 10 | vgatherdpd ymm0,[rcx+xmm2*1],ymm3 11 | vgatherqpd ymm0,[rcx+ymm2*1],ymm3 12 | 13 | vgatherdpd xmm0,[rcx+xmm2*2],xmm3 14 | vgatherqpd xmm0,[rcx+xmm2*2],xmm3 15 | vgatherdpd ymm0,[rcx+xmm2*2],ymm3 16 | vgatherqpd ymm0,[rcx+ymm2*2],ymm3 17 | 18 | vgatherdpd xmm0,[rcx+xmm2*4],xmm3 19 | vgatherqpd xmm0,[rcx+xmm2*4],xmm3 20 | vgatherdpd ymm0,[rcx+xmm2*4],ymm3 21 | vgatherqpd ymm0,[rcx+ymm2*4],ymm3 22 | 23 | vgatherdpd xmm0,[rcx+xmm2*8],xmm3 24 | vgatherqpd xmm0,[rcx+xmm2*8],xmm3 25 | vgatherdpd ymm0,[rcx+xmm2*8],ymm3 26 | vgatherqpd ymm0,[rcx+ymm2*8],ymm3 27 | 28 | vgatherdpd xmm0,[xmm2],xmm3 29 | vgatherqpd xmm0,[xmm2],xmm3 30 | vgatherdpd ymm0,[xmm2],ymm3 31 | vgatherqpd ymm0,[ymm2],ymm3 32 | 33 | vgatherdpd xmm0,[xmm2*1],xmm3 34 | vgatherqpd xmm0,[xmm2*1],xmm3 35 | vgatherdpd ymm0,[xmm2*1],ymm3 36 | vgatherqpd ymm0,[ymm2*1],ymm3 37 | 38 | vgatherdpd xmm0,[xmm2*2],xmm3 39 | vgatherqpd xmm0,[xmm2*2],xmm3 40 | vgatherdpd ymm0,[xmm2*2],ymm3 41 | vgatherqpd ymm0,[ymm2*2],ymm3 42 | 43 | vgatherdpd xmm0,[xmm2*4],xmm3 44 | vgatherqpd xmm0,[xmm2*4],xmm3 45 | vgatherdpd ymm0,[xmm2*4],ymm3 46 | vgatherqpd ymm0,[ymm2*4],ymm3 47 | 48 | vgatherdpd xmm0,[xmm2*8],xmm3 49 | vgatherqpd xmm0,[xmm2*8],xmm3 50 | vgatherdpd ymm0,[xmm2*8],ymm3 51 | vgatherqpd ymm0,[ymm2*8],ymm3 52 | 53 | vgatherdpd xmm0,[xmm2+rcx],xmm3 54 | vgatherqpd xmm0,[xmm2+rcx],xmm3 55 | vgatherdpd ymm0,[xmm2+rcx],ymm3 56 | vgatherqpd ymm0,[ymm2+rcx],ymm3 57 | 58 | vgatherdpd xmm0,[xmm2*1+rcx],xmm3 59 | vgatherqpd xmm0,[xmm2*1+rcx],xmm3 60 | vgatherdpd ymm0,[xmm2*1+rcx],ymm3 61 | vgatherqpd ymm0,[ymm2*1+rcx],ymm3 62 | 63 | vgatherdpd xmm0,[xmm2*2+rcx],xmm3 64 | vgatherqpd xmm0,[xmm2*2+rcx],xmm3 65 | vgatherdpd ymm0,[xmm2*2+rcx],ymm3 66 | vgatherqpd ymm0,[ymm2*2+rcx],ymm3 67 | 68 | vgatherdpd xmm0,[xmm2*4+rcx],xmm3 69 | vgatherqpd xmm0,[xmm2*4+rcx],xmm3 70 | vgatherdpd ymm0,[xmm2*4+rcx],ymm3 71 | vgatherqpd ymm0,[ymm2*4+rcx],ymm3 72 | 73 | vgatherdpd xmm0,[xmm2*8+rcx],xmm3 74 | vgatherqpd xmm0,[xmm2*8+rcx],xmm3 75 | vgatherdpd ymm0,[xmm2*8+rcx],ymm3 76 | vgatherqpd ymm0,[ymm2*8+rcx],ymm3 77 | -------------------------------------------------------------------------------- /output/nullout.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #include "nasm.h" 35 | #include "nasmlib.h" 36 | #include "output/outlib.h" 37 | 38 | int null_setinfo(enum geninfo type, char **string) 39 | { 40 | (void)type; 41 | (void)string; 42 | return 0; 43 | } 44 | 45 | int null_directive(enum directives directive, char *value, int pass) 46 | { 47 | (void)directive; 48 | (void)value; 49 | (void)pass; 50 | return 0; 51 | } 52 | 53 | void null_sectalign(int32_t seg, unsigned int value) 54 | { 55 | (void)seg; 56 | (void)value; 57 | } 58 | -------------------------------------------------------------------------------- /test/optimization.asm: -------------------------------------------------------------------------------- 1 | ;Testname=O0; Arguments=-O0 -fbin -ooptimization.bin; Files=stdout stderr optimization.bin 2 | ;Testname=O1; Arguments=-O1 -fbin -ooptimization.bin; Files=stdout stderr optimization.bin 3 | ;Testname=Ox; Arguments=-Ox -fbin -ooptimization.bin; Files=stdout stderr optimization.bin 4 | 5 | BITS 32 6 | 7 | ; Simple 8 | jmp foo 9 | times 124 nop 10 | foo: 11 | 12 | ; Must start short to converge optimally 13 | jmp car 14 | times 127 nop 15 | car: 16 | 17 | ; Always near 18 | jmp cdr 19 | times 128 nop 20 | cdr: 21 | 22 | 23 | ; Simple 24 | add eax, quux2 - quux1 25 | quux1: 26 | times 127 nop 27 | quux2: 28 | 29 | ; Must start short 30 | corge1: 31 | add eax, corge2 - corge1 32 | times 127 - 3 nop 33 | corge2: 34 | 35 | 36 | ; Simple 37 | lea eax, [bolug2-bolug1] 38 | bolug1: 39 | times 127 nop 40 | bolug2: 41 | 42 | ; Must start short 43 | calog1: 44 | lea eax, [calog2-calog1] 45 | times 127 - 3 nop 46 | calog2: 47 | 48 | 49 | ; Simple 50 | lea eax, [eax+dolug2-dolug1] 51 | dolug1: 52 | times 127 nop 53 | dolug2: 54 | 55 | ; Must start short 56 | ealog1: 57 | lea eax, [eax+ealog2-ealog1] 58 | times 127 - 3 nop 59 | ealog2: 60 | 61 | ; Must stay long! 62 | lea eax, [eax+folug2-folug1] 63 | folug1: 64 | times 128 nop 65 | folug2: 66 | 67 | ; Must stay long! 68 | galog1: 69 | lea eax, [eax+galog2-galog1] 70 | times 128 - 3 nop 71 | galog2: 72 | 73 | ; Sbyte tests... 74 | onetwentysix equ 126 75 | onetwentynine equ 129 76 | 77 | add eax,onetwentyseven ; sbyte (forward) 78 | add eax,onetwentyeight ; not sbyte (forward) 79 | add eax,onetwentyseven ; sbyte (forward) 80 | add eax,onetwentysix ; sbyte (backward) 81 | add eax,onetwentynine ; not sbyte (backward) 82 | add ecx,onetwentyseven ; sbyte (forward) 83 | add ecx,onetwentyeight ; not sbyte (forward) 84 | add ecx,onetwentyseven ; sbyte (forward) 85 | add ecx,onetwentysix ; sbyte (backward) 86 | add ecx,onetwentynine ; not sbyte (backward) 87 | 88 | onetwentyseven equ 127 89 | onetwentyeight equ 128 90 | 91 | ; Simple 92 | add eax, holug2-holug1 93 | holug1: 94 | times 127 nop 95 | holug2: 96 | 97 | ; Must start short 98 | ialog1: 99 | add eax, ialog2-ialog1 100 | times 127 - 3 nop 101 | ialog2: 102 | 103 | ; Do not confuse forward references and segmentless addresses! 104 | jmp 12345 105 | -------------------------------------------------------------------------------- /macros/fp.mac: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 2010 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | 34 | ;; 35 | ;; fp.mac 36 | ;; 37 | ;; Floating-point utility macros 38 | ;; 39 | 40 | USE: fp 41 | 42 | %define Inf __Infinity__ 43 | %define NaN __QNaN__ 44 | %define QNaN __QNaN__ 45 | %define SNaN __SNaN__ 46 | 47 | %define float8(x) __float8__(x) 48 | %define float16(x) __float16__(x) 49 | %define float32(x) __float32__(x) 50 | %define float64(x) __float64__(x) 51 | %define float80m(x) __float80m__(x) 52 | %define float80e(x) __float80e__(x) 53 | %define float128l(x) __float128l__(x) 54 | %define float128h(x) __float128h__(x) 55 | -------------------------------------------------------------------------------- /rdoff/symtab.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * symtab.h Header file for symbol table manipulation routines 36 | */ 37 | 38 | #ifndef RDOFF_SYMTAB_H 39 | #define RDOFF_SYMTAB_H 1 40 | 41 | #include 42 | 43 | typedef struct { 44 | char *name; 45 | int segment; 46 | int32_t offset; 47 | int32_t flags; 48 | } symtabEnt; 49 | 50 | void *symtabNew(void); 51 | void symtabDone(void *symtab); 52 | void symtabInsert(void *symtab, symtabEnt * ent); 53 | symtabEnt *symtabFind(void *symtab, const char *name); 54 | void symtabDump(void *symtab, FILE * of); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /directiv.dat: -------------------------------------------------------------------------------- 1 | ;; -------------------------------------------------------------------------- 2 | ;; 3 | ;; Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | ;; See the file AUTHORS included with the NASM distribution for 5 | ;; the specific copyright holders. 6 | ;; 7 | ;; Redistribution and use in source and binary forms, with or without 8 | ;; modification, are permitted provided that the following 9 | ;; conditions are met: 10 | ;; 11 | ;; * Redistributions of source code must retain the above copyright 12 | ;; notice, this list of conditions and the following disclaimer. 13 | ;; * Redistributions in binary form must reproduce the above 14 | ;; copyright notice, this list of conditions and the following 15 | ;; disclaimer in the documentation and/or other materials provided 16 | ;; with the distribution. 17 | ;; 18 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | ;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | ;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | ;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | ;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | ;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | ;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | ;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | ;; 32 | ;; -------------------------------------------------------------------------- 33 | ;; 34 | ;; List of global NASM directives (including backend-specific ones) 35 | ;; 36 | 37 | ; --- Global directives 38 | absolute 39 | bits 40 | common 41 | cpu 42 | debug 43 | default 44 | extern 45 | float 46 | global 47 | list 48 | section 49 | segment 50 | warning 51 | sectalign 52 | 53 | ; --- Format-specific directives 54 | export ; outcoff, outobj 55 | group ; outobj 56 | import ; outobj 57 | library ; outrdf2 58 | map ; outbin 59 | module ; outrdf2 60 | org ; outbin 61 | osabi ; outelf 62 | safeseh ; outcoff 63 | uppercase ; outieee, outobj 64 | -------------------------------------------------------------------------------- /rbtree.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #ifndef NASM_RBTREE_H 35 | #define NASM_RBTREE_H 36 | 37 | #include "compiler.h" 38 | #include 39 | 40 | /* This structure should be embedded in a larger data structure; 41 | the final output from rb_search() can then be converted back 42 | to the larger data structure via container_of(). */ 43 | struct rbtree { 44 | uint64_t key; 45 | struct rbtree *left, *right; 46 | bool red; 47 | }; 48 | 49 | struct rbtree *rb_insert(struct rbtree *, struct rbtree *); 50 | struct rbtree *rb_search(struct rbtree *, uint64_t); 51 | 52 | #endif /* NASM_RBTREE_H */ 53 | -------------------------------------------------------------------------------- /rdoff/Mkfiles/Makefile.dj: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | # 3 | # Auto-configuring Makefile for RDOFF object file utils; part of the 4 | # Netwide Assembler 5 | # 6 | # The Netwide Assembler is copyright (C) 1996 Simon Tatham and 7 | # Julian Hall. All rights reserved. The software is 8 | # redistributable under the license given in the file "LICENSE" 9 | # distributed in the NASM archive. 10 | 11 | # You may need to adjust these values. 12 | 13 | prefix = /djgpp 14 | CC = gcc -s 15 | CFLAGS = -O2 -I.. 16 | 17 | # You _shouldn't_ need to adjust anything below this line. 18 | 19 | exec_prefix = ${prefix} 20 | bindir = ${exec_prefix}/bin 21 | mandir = ${prefix}/man 22 | 23 | INSTALL = /usr/bin/install -c 24 | INSTALL_PROGRAM = ${INSTALL} 25 | INSTALL_DATA = ${INSTALL} -m 644 26 | LN_S = ln -s 27 | 28 | LDRDFLIBS = rdoff.o ../nasmlib.o symtab.o hash.o collectn.o rdlib.o segtab.o 29 | RDXLIBS = rdoff.o rdfload.o symtab.o hash.o collectn.o 30 | 31 | .c.o: 32 | $(CC) -c $(CFLAGS) $*.c 33 | 34 | all: rdfdump ldrdf rdx rdflib rdf2bin rdf2com 35 | 36 | rdfdump: rdfdump.o rdoff.o 37 | $(CC) -o rdfdump rdfdump.o rdoff.o 38 | 39 | ldrdf: ldrdf.o $(LDRDFLIBS) 40 | $(CC) -o ldrdf ldrdf.o $(LDRDFLIBS) 41 | rdx: rdx.o $(RDXLIBS) 42 | $(CC) -o rdx rdx.o $(RDXLIBS) 43 | rdflib: rdflib.o 44 | $(CC) -o rdflib rdflib.o 45 | rdf2bin: rdf2bin.o $(RDXLIBS) nasmlib.o 46 | $(CC) -o rdf2bin rdf2bin.o $(RDXLIBS) nasmlib.o 47 | rdf2com: 48 | $(LN_S) rdf2bin rdf2com 49 | 50 | rdf2bin.o: rdf2bin.c 51 | rdfdump.o: rdfdump.c 52 | rdoff.o: rdoff.c rdoff.h 53 | ldrdf.o: ldrdf.c rdoff.h ../nasmlib.h symtab.h collectn.h rdlib.h 54 | symtab.o: symtab.c symtab.h hash.h 55 | collectn.o: collectn.c collectn.h 56 | rdx.o: rdx.c rdoff.h rdfload.h symtab.h 57 | rdfload.o: rdfload.c rdfload.h rdoff.h collectn.h symtab.h 58 | rdlib.o: rdlib.c rdlib.h 59 | rdflib.o: rdflib.c 60 | hash.o: hash.c hash.h 61 | segtab.o: segtab.c segtab.h 62 | 63 | nasmlib.o: ../nasmlib.c ../nasmlib.h ../names.c ../nasm.h 64 | $(CC) -c $(CFLAGS) ../nasmlib.c 65 | 66 | clean: 67 | rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com 68 | 69 | install: rdfdump ldrdf rdx rdflib rdf2bin rdf2com 70 | $(INSTALL_PROGRAM) rdfdump $(bindir)/rdfdump 71 | $(INSTALL_PROGRAM) ldrdf $(bindir)/ldrdf 72 | $(INSTALL_PROGRAM) rdx $(bindir)/rdx 73 | $(INSTALL_PROGRAM) rdflib $(bindir)/rdflib 74 | $(INSTALL_PROGRAM) rdf2bin $(bindir)/rdf2bin 75 | cd $(bindir); $(LN_S) rdf2bin rdf2com 76 | -------------------------------------------------------------------------------- /rdoff/Mkfiles/Makefile.unx: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | # 3 | # Auto-configuring Makefile for RDOFF object file utils; part of the 4 | # Netwide Assembler 5 | # 6 | # The Netwide Assembler is copyright (C) 1996 Simon Tatham and 7 | # Julian Hall. All rights reserved. The software is 8 | # redistributable under the license given in the file "LICENSE" 9 | # distributed in the NASM archive. 10 | 11 | # You may need to adjust these values. 12 | 13 | prefix = /usr/local 14 | CC = cc 15 | CFLAGS = -O -I.. 16 | 17 | # You _shouldn't_ need to adjust anything below this line. 18 | 19 | exec_prefix = ${prefix} 20 | bindir = ${exec_prefix}/bin 21 | mandir = ${prefix}/man 22 | 23 | INSTALL = /usr/bin/install -c 24 | INSTALL_PROGRAM = ${INSTALL} 25 | INSTALL_DATA = ${INSTALL} -m 644 26 | LN_S = ln -s 27 | 28 | LDRDFLIBS = rdoff.o ../nasmlib.o symtab.o hash.o collectn.o rdlib.o segtab.o 29 | RDXLIBS = rdoff.o rdfload.o symtab.o hash.o collectn.o 30 | 31 | .c.o: 32 | $(CC) -c $(CFLAGS) $*.c 33 | 34 | all: rdfdump ldrdf rdx rdflib rdf2bin rdf2com 35 | 36 | rdfdump: rdfdump.o rdoff.o 37 | $(CC) -o rdfdump rdfdump.o rdoff.o 38 | 39 | ldrdf: ldrdf.o $(LDRDFLIBS) 40 | $(CC) -o ldrdf ldrdf.o $(LDRDFLIBS) 41 | rdx: rdx.o $(RDXLIBS) 42 | $(CC) -o rdx rdx.o $(RDXLIBS) 43 | rdflib: rdflib.o 44 | $(CC) -o rdflib rdflib.o 45 | rdf2bin: rdf2bin.o $(RDXLIBS) nasmlib.o 46 | $(CC) -o rdf2bin rdf2bin.o $(RDXLIBS) nasmlib.o 47 | rdf2com: 48 | $(LN_S) rdf2bin rdf2com 49 | 50 | rdf2bin.o: rdf2bin.c 51 | rdfdump.o: rdfdump.c 52 | rdoff.o: rdoff.c rdoff.h 53 | ldrdf.o: ldrdf.c rdoff.h ../nasmlib.h symtab.h collectn.h rdlib.h 54 | symtab.o: symtab.c symtab.h hash.h 55 | collectn.o: collectn.c collectn.h 56 | rdx.o: rdx.c rdoff.h rdfload.h symtab.h 57 | rdfload.o: rdfload.c rdfload.h rdoff.h collectn.h symtab.h 58 | rdlib.o: rdlib.c rdlib.h 59 | rdflib.o: rdflib.c 60 | hash.o: hash.c hash.h 61 | segtab.o: segtab.c segtab.h 62 | 63 | nasmlib.o: ../nasmlib.c ../nasmlib.h ../names.c ../nasm.h 64 | $(CC) -c $(CFLAGS) ../nasmlib.c 65 | 66 | clean: 67 | rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com 68 | 69 | install: rdfdump ldrdf rdx rdflib rdf2bin rdf2com 70 | $(INSTALL_PROGRAM) rdfdump $(bindir)/rdfdump 71 | $(INSTALL_PROGRAM) ldrdf $(bindir)/ldrdf 72 | $(INSTALL_PROGRAM) rdx $(bindir)/rdx 73 | $(INSTALL_PROGRAM) rdflib $(bindir)/rdflib 74 | $(INSTALL_PROGRAM) rdf2bin $(bindir)/rdf2bin 75 | cd $(bindir); $(LN_S) rdf2bin rdf2com 76 | -------------------------------------------------------------------------------- /preproc.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * preproc.h header file for preproc.c 36 | */ 37 | 38 | #ifndef NASM_PREPROC_H 39 | #define NASM_PREPROC_H 40 | 41 | #include "pptok.h" 42 | 43 | extern const char * const pp_directives[]; 44 | extern const uint8_t pp_directives_len[]; 45 | 46 | /* Pointer to a macro chain */ 47 | typedef const unsigned char macros_t; 48 | 49 | enum preproc_token pp_token_hash(const char *token); 50 | void pp_include_path(char *); 51 | void pp_pre_include(char *); 52 | void pp_pre_define(char *); 53 | void pp_pre_undefine(char *); 54 | void pp_runtime(char *); 55 | void pp_extra_stdmac(macros_t *); 56 | 57 | #endif 58 | --------------------------------------------------------------------------------