From eb4ccf58869c89fde324bd41ce054a8a0404f7f6 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 30 Apr 2002 20:56:02 +0000 Subject: NASM 0.98-j5 --- Readme | 155 ++++++++++++---------------------------------- assemble.c | 36 ++++++----- c16.mac | 123 ++++++++++++++++++++++++------------ c32.mac | 78 +++++++++++++++-------- changes.asm | 45 +++++++++----- exebin.mac | 171 +++++++++++++++++++++++++++++++++----------------- insns.dat | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++++- nasm.h | 6 +- parser.c | 3 +- preproc.c | 38 +++++++++--- rdoff/Makefile.sc | 169 +++++++++++++++++++++++++++++++++----------------- 11 files changed, 663 insertions(+), 343 deletions(-) diff --git a/Readme b/Readme index 11fb184e..6e7c56c7 100644 --- a/Readme +++ b/Readme @@ -1,130 +1,53 @@ -This is a distribution of NASM, the Netwide Assembler. NASM is a -prototype general-purpose x86 assembler. It will currently output -flat-form binary files, a.out, COFF and ELF Unix object files, -Microsoft Win32 and 16-bit DOS object files, OS/2 object files, the -as86 object format, and a home-grown format called RDF. +This directory contains the necessary files to port the C compiler +``LCC'' (available by FTP from sunsite.doc.ic.ac.uk in the directory +/computing/programming/languages/c/lcc) to compile for Linux (a.out or +ELF) or other supported operating systems by using NASM as a back-end +code generator. -Also included is NDISASM, a prototype x86 binary-file disassembler -which uses the same instruction table as NASM. +This patch has been tested on lcc version 4.0. -To install NASM on Linux, type `make', and then when it has finished -copy the file `nasm' (and maybe `ndisasm') to a directory on your -search path (maybe /usr/local/bin, or ~/bin if you don't have root -access). You may also want to copy the man page `nasm.1' (and maybe -`ndisasm.1') to somewhere sensible. +To install: -To install under DOS, if you don't need to rebuild from the sources, -you can just copy nasm.exe and ndisasm.exe (16-bit DOS executables), -or nasmw.exe and ndisasmw.exe (Win32 console applications - less -likely to run out of memory), to somewhere on your PATH. +- Copy `x86nasm.md' into the `src' directory of the lcc tree. -To rebuild the DOS sources, various makefiles are provided: +- Copy either `lin-elf.c' or `lin-aout.c' into the `etc' directory. -- Makefile.dos, the one I build the standard 16-bit releases from, - designed for a hybrid system using Microsoft C and Borland Make - (don't ask why :-) -- Makefile.vc, for Microsoft Visual C++ compiling to a Win32 - command-line application. This is the one I build the standard - Win32 release binaries from. +- With previous versions, you had to modify x86-nasm.md if you weren't + using ELF. There is now inbuilt support within NASM in the shape + of the __CDECL__ macro, so this modification is no longer necessary. -- Makefile.bor, for Borland C. -- Makefile.bc2, also for Borland C, contributed by Fox Cutter. - Reported to work better than Makefile.bor on some systems. +- Make the following changes to `bind.c' in the `src' directory: -- Makefile.sc, for Symantec C++, compiling to a 32-bit extended DOS - executable.. Contributed by Mark Junker. -- Makefile.scw, also for Symantec C++, compiling to a Win32 command- - line application. Also contributed by Mark Junker. + - Near the top of the file, add a line that reads + extern Interface x86nasmIR; -- Makefile.wc, for Watcom C, compiling to a 32-bit extended DOS - executable. Contributed by Dominik Behr. -- Makefile.wcw, also for Watcom C, compiling to a Win32 command- - line application. Also contributed by Dominik Behr. + - In the `bindings' array, add the lines + "x86-nasm", &x86nasmIR, + "x86/nasm", &x86nasmIR, + (in sensible looking places...) -- Makefile.dj, for DJGPP, compiling to a 32-bit extended DOS - executable. Contributed by Dominik Behr. + A sample `bind.c' has been provided to show what the result of + this might look like. You might be able to get away with using it + directly... -- Makefile.lcc, for lcc-win32, compiling to a Win32 command line - application. (The lcc-win32 compiler and tools are available from - http://www.remcomp.com/lcc-win32/) +- Modify the lcc makefile to include rules for x86nasm.o: this will + have to be done in about three places. Just copy any line with + `x86' on it and modify it to read `x86nasm' everywhere. (Except + that in the list of object files that rcc is made up from, do + remember to ensure that every line but the last has a trailing + backslash...) -I can't guarantee that all of those makefiles work, because I don't -have all of those compilers. However, Makefile.dos and Makefile.vc -work on my system, and so do Makefile.bor and Makefile.bc2. +- You may have to modify the contents of `lin-elf.c' or `lin-aout.c' + to reflect the true locations of files such as crt0.o, crt1.o, + ld-linux.so and so forth. If you don't know where to find these, + compile a short C program with `gcc -v' and see what command line + gcc feeds to `ld'. -Be careful with Borland C: there have been various conflicting -reports about how reliable the Huge memory model is. If you try to -compile NASM in Large model, you may get DGROUP overflows due to the -vast quantity of data in the instruction tables. I've had reports -from some people that Huge model doesn't work at all (and also -reports from others that it works fine), so if you don't want to try -moving to Huge, you could try adding the option `-dc' to the -compiler command line instead, which causes string literals to be -moved from DGROUP to the code segments and might make Large model -start working. (Either solution works for me.) +- You should now be able to build lcc, using `lin-elf.c' or + `lin-aout.c' as the system-dependent part of the `lcc' wrapper + program. -Dominik Behr has also contributed the file misc/pmw.bat, which is a -batch file to turn the output from Makefile.wc (NASM.EXE and -NDISASM.EXE) into standalone executables incorporating Tran's -PMODE/W DOS extender, rather than depending on an external extender -program. +- Symlink x86nasm.c into the `src' directory before attempting the + triple test, or the compile will fail. -Some of the Windows makefiles produce executables called nasmw.exe -and ndisasmw.exe, and some don't. Be prepared for either... - -If you're trying to unpack the DOS (.ZIP format) archive under Unix -instead of using the .tar.gz version, you can save some time by -doing `unzip -aL', which will convert the DOS-format text files to -Unix and also convert all names to lower case. - -If you want to build a restricted version of NASM containing only -some of the object file formats, you can achieve this by adding -#defines to `outform.h' (see the file itself for documentation), or -equivalently by adding compiler command line options in the -Makefile. - -There is a machine description file for the `LCC' retargetable C -compiler (version 3.6), in the directory `lcc', along with -instructions for its use. This means that NASM can now be used as -the code-generator back end for a useful C compiler. - -Michael `Wuschel' Tippach has ported his DOS extender `WDOSX' to -enable it to work with the 32-bit binary files NASM can output: the -original extender and his port `WDOSX/N' are available from his web -page, http://www.geocities.com/SiliconValley/Park/4493. - -Matt Mastracci has written a document explaining how to write -assembly language modules in DJGPP programs using NASM: it's on his -web site at http://www.ucalgary.ca/~mmastrac/djgppasm.doc. - -The `misc' directory contains `nasm.sl', a NASM editing mode for the -JED programmers' editor (see http://space.mit.edu/~davis/jed.html -for details about JED). The comment at the start of the file gives -instructions on how to install the mode. This directory also -contains a file (`magic') containing lines to add to /etc/magic on -Unix systems to allow the `file' command to recognise RDF files, and -a zip file (`exasm.zip') containing the necessary files for syntax -highlighting in the Aurora DOS editor. (The Aurora files were -contributed by ; I haven't tested them as I -don't have Aurora.) - -The `rdoff' directory contains sources for a linker and loader for -the RDF object file format, to run under Linux, and also -documentation on the internal structure of RDF files. - -For information about how you can distribute and use NASM, see the -file Licence. We were tempted to put NASM under the GPL, but decided -that in many ways it was too restrictive for developers. - -For information about how to use NASM, see the various forms of -documentation in the `doc' directory: documentation is provided in -HTML, PostScript, plain text, Texinfo, and Windows Help formats. For -information about how to use NDISASM, see `ndisasm.doc'. For -information about the internal structure of NASM, see -`internal.doc'. (In particular, _please_ read `internal.doc' before -writing any code for us...) - -The NASM web page is at http://www.cryogen.com/Nasm/ - -Bug reports (and patches if you can) should be sent to - or . +- Now it should pass the triple test, on either ELF or a.out. Voila! diff --git a/assemble.c b/assemble.c index 65bcea39..65bd082a 100644 --- a/assemble.c +++ b/assemble.c @@ -611,7 +611,7 @@ static void gencode (long segment, long offset, int bits, case R_SS: bytes[0] = 0x16 + (c == 0x04 ? 1 : 0); break; default: - errfunc (ERR_PANIC, "bizarre 8086 segment register received"); + errfunc (ERR_PANIC, "bizarre 8086 segment register received"); } out (offset, segment, bytes, OUT_RAWDATA+1, NO_SEG, NO_SEG); offset++; @@ -622,7 +622,7 @@ static void gencode (long segment, long offset, int bits, case R_FS: bytes[0] = 0xA0 + (c == 0x05 ? 1 : 0); break; case R_GS: bytes[0] = 0xA8 + (c == 0x05 ? 1 : 0); break; default: - errfunc (ERR_PANIC, "bizarre 386 segment register received"); + errfunc (ERR_PANIC, "bizarre 386 segment register received"); } out (offset, segment, bytes, OUT_RAWDATA+1, NO_SEG, NO_SEG); offset++; @@ -928,31 +928,31 @@ static int regval (operand *o) { switch (o->basereg) { case R_EAX: case R_AX: case R_AL: case R_ES: case R_CR0: case R_DR0: - case R_ST0: case R_MM0: + case R_ST0: case R_MM0: case R_XMM0: return 0; case R_ECX: case R_CX: case R_CL: case R_CS: case R_DR1: case R_ST1: - case R_MM1: + case R_MM1: case R_XMM1: return 1; case R_EDX: case R_DX: case R_DL: case R_SS: case R_CR2: case R_DR2: - case R_ST2: case R_MM2: + case R_ST2: case R_MM2: case R_XMM2: return 2; case R_EBX: case R_BX: case R_BL: case R_DS: case R_CR3: case R_DR3: - case R_TR3: case R_ST3: case R_MM3: + case R_TR3: case R_ST3: case R_MM3: case R_XMM3: return 3; case R_ESP: case R_SP: case R_AH: case R_FS: case R_CR4: case R_TR4: - case R_ST4: case R_MM4: + case R_ST4: case R_MM4: case R_XMM4: return 4; case R_EBP: case R_BP: case R_CH: case R_GS: case R_TR5: case R_ST5: - case R_MM5: + case R_MM5: case R_XMM5: return 5; case R_ESI: case R_SI: case R_DH: case R_DR6: case R_TR6: case R_ST6: - case R_MM6: + case R_MM6: case R_XMM6: return 6; case R_EDI: case R_DI: case R_BH: case R_DR7: case R_TR7: case R_ST7: - case R_MM7: + case R_MM7: case R_XMM7: return 7; default: /* panic */ - errfunc (ERR_PANIC, "invalid register operand given to regval()"); + errfunc (ERR_PANIC, "invalid register operand given to regval()"); return 0; } } @@ -1031,10 +1031,14 @@ static ea *process_ea (operand *input, ea *output, int addrbits, int rfield, { if (!(REGISTER & ~input->type)) { /* it's a single register */ static int regs[] = { - R_MM0, R_EAX, R_AX, R_AL, R_MM1, R_ECX, R_CX, R_CL, - R_MM2, R_EDX, R_DX, R_DL, R_MM3, R_EBX, R_BX, R_BL, - R_MM4, R_ESP, R_SP, R_AH, R_MM5, R_EBP, R_BP, R_CH, - R_MM6, R_ESI, R_SI, R_DH, R_MM7, R_EDI, R_DI, R_BH + R_MM0, R_XMM0, R_EAX, R_AX, R_AL, + R_MM1, R_XMM1, R_ECX, R_CX, R_CL, + R_MM2, R_XMM2, R_EDX, R_DX, R_DL, + R_MM3, R_XMM3, R_EBX, R_BX, R_BL, + R_MM4, R_XMM4, R_ESP, R_SP, R_AH, + R_MM5, R_XMM5, R_EBP, R_BP, R_CH, + R_MM6, R_XMM6, R_ESI, R_SI, R_DH, + R_MM7, R_XMM7, R_EDI, R_DI, R_BH }; int i; @@ -1043,7 +1047,7 @@ static ea *process_ea (operand *input, ea *output, int addrbits, int rfield, if (isib_present = FALSE;/* no SIB necessary */ output->bytes = 0; /* no offset necessary either */ - output->modrm = 0xC0 | (rfield << 3) | (i/4); + output->modrm = 0xC0 | (rfield << 3) | (i/5); } else return NULL; diff --git a/c16.mac b/c16.mac index 2853db51..50b5d5ee 100644 --- a/c16.mac +++ b/c16.mac @@ -1,41 +1,82 @@ -; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*- - -%imacro proc 1 ; begin a procedure definition -%push proc - global %1 -%1: push bp - mov bp,sp -%ifdef FARCODE PASCAL ; arguments may start at bp+4 or bp+6 -%assign %$arg 6 -%define %$firstarg 6 -%else -%assign %$arg 4 -%define %$firstarg 4 -%endif -%define %$procname %1 -%endmacro - -%imacro arg 0-1 2 ; used with the argument name as a label -%00 equ %$arg - ; we could possibly be adding some - ; debug information at this point...? -%assign %$arg %1+%$arg -%endmacro - -%imacro endproc 0 -%ifnctx proc -%error Mismatched `endproc'/`proc' -%else - mov sp,bp - pop bp -%ifdef PASCAL - retf %$arg - %$firstarg -%elifdef FARCODE - retf -%else - retn -%endif -__end_%$procname: ; useful for calculating function size -%pop -%endif -%endmacro +; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*- + + + +%imacro proc 1 ; begin a procedure definition + +%push proc + + global %1 + +%1: push bp + + mov bp,sp + +%ifdef FARCODE PASCAL ; arguments may start at bp+4 or bp+6 + +%assign %$arg 6 + +%define %$firstarg 6 + +%else + +%assign %$arg 4 + +%define %$firstarg 4 + +%endif + +%define %$procname %1 + +%endmacro + + + +%imacro arg 0-1 2 ; used with the argument name as a label + +%00 equ %$arg + + ; we could possibly be adding some + + ; debug information at this point...? + +%assign %$arg %1+%$arg + +%endmacro + + + +%imacro endproc 0 + +%ifnctx proc + +%error Mismatched `endproc'/`proc' + +%else + + mov sp,bp + + pop bp + +%ifdef PASCAL + + retf %$arg - %$firstarg + +%elifdef FARCODE + + retf + +%else + + retn + +%endif + +__end_%$procname: ; useful for calculating function size + +%pop + +%endif + +%endmacro + diff --git a/c32.mac b/c32.mac index 6abad995..f0c116ba 100644 --- a/c32.mac +++ b/c32.mac @@ -1,26 +1,52 @@ -; NASM macro set to make interfacing to 32-bit programs easier -*- nasm -*- - -%imacro proc 1 ; begin a procedure definition -%push proc - global %1 -%1: push ebp - mov ebp,esp -%assign %$arg 8 -%define %$procname %1 -%endmacro - -%imacro arg 0-1 4 ; used with the argument name as a label -%00 equ %$arg -%assign %$arg %1+%$arg -%endmacro - -%imacro endproc 0 -%ifnctx proc -%error Mismatched `endproc'/`proc' -%else - leave - ret -__end_%$procname: ; useful for calculating function size -%pop -%endif -%endmacro +; NASM macro set to make interfacing to 32-bit programs easier -*- nasm -*- + + + +%imacro proc 1 ; begin a procedure definition + +%push proc + + global %1 + +%1: push ebp + + mov ebp,esp + +%assign %$arg 8 + +%define %$procname %1 + +%endmacro + + + +%imacro arg 0-1 4 ; used with the argument name as a label + +%00 equ %$arg + +%assign %$arg %1+%$arg + +%endmacro + + + +%imacro endproc 0 + +%ifnctx proc + +%error Mismatched `endproc'/`proc' + +%else + + leave + + ret + +__end_%$procname: ; useful for calculating function size + +%pop + +%endif + +%endmacro + diff --git a/changes.asm b/changes.asm index 3c2edfdf..4b0b30af 100644 --- a/changes.asm +++ b/changes.asm @@ -98,6 +98,19 @@ forwardref: %endmacro xxx yyy +;----------------------------------------------------------------------------- +; Bug added by John in preproc.c 0.98-J4, removed by John in 0.98-J5 +; +; Tested here to make sure it stays removed +; +%macro TestElse 1 +%if %1=0 +%elif %1=1 +nop +%endif +%endmacro +TestElse 1 + %ifdef oldmsg ;*************************************************************** ; @@ -269,7 +282,20 @@ arg_example2 arg2 RETF word 4 ; note "ENTER" has not been changed yet. - + +;----------------------------------------------------------------------------- +; Enhancement by hpa in insns.dat et al +; +; Simplified adding new instructions, and added some missing instructions +; + int03 ; Instead of INT3 + ud1 ; No documented mnemonic for this one + ud2 + sysenter + sysexit + fxsave [ebx] + fxrstor [es:ebx+esi*4+0x3000] + %endif %ifdef oldcrash ;************************************************************* @@ -289,21 +315,6 @@ This_label_is_256_characters_long__There_used_to_be_a_bug_in_stdscan_which_made_ emlabel empty_macro jmp emlabel -%endif - -;----------------------------------------------------------------------------- -; Enhancement by hpa in insns.dat et al -; -; Simplified added new instructions, and added some missing instructions -; - int03 ; Instead of INT3 - ud1 ; No documented mnemonic for this one - ud2 - sysenter - sysexit - fxsave [ebx] - fxrstor [es:ebx+esi*4+0x3000] - ;----------------------------------------------------------------------------- ; Enhancement by Conan Brink in preproc.c ; @@ -314,3 +325,5 @@ emlabel empty_macro nop %endrep %endrep + +%endif diff --git a/exebin.mac b/exebin.mac index 022183fa..89c68898 100644 --- a/exebin.mac +++ b/exebin.mac @@ -1,57 +1,114 @@ -; -*- nasm -*- -; NASM macro file to allow the `bin' output format to generate -; simple .EXE files by constructing the EXE header by hand. -; Adapted from a contribution by Yann Guidon - -%define EXE_stack_size EXE_realstacksize - -%macro EXE_begin 0 - ORG 0E0h - section .text - -header_start: - db 4Dh,5Ah ; EXE file signature - dw EXE_allocsize % 512 - dw (EXE_allocsize + 511) / 512 - dw 0 ; relocation information: none - dw (header_end-header_start)/16 ; header size in paragraphs - dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem - dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem - dw -10h ; Initial SS (before fixup) - dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK) - dw 0 ; (no) Checksum - dw 100h ; Initial IP - start just after the header - dw -10h ; Initial CS (before fixup) - dw 0 ; file offset to relocation table: none - dw 0 ; (no overlay) - align 16,db 0 -header_end: - -EXE_startcode: - section .data -EXE_startdata: - section .bss -EXE_startbss: -%endmacro - -%macro EXE_stack 1 -EXE_realstacksize equ %1 -%define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end -%endmacro - -%macro EXE_end 0 - section .text -EXE_endcode: - section .data -EXE_enddata: - section .bss - alignb 4 -EXE_endbss: - -EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3) -EXE_datasize equ EXE_enddata-EXE_startdata -EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3) -EXE_allocsize equ EXE_acodesize + EXE_datasize - -EXE_stack_size equ 0x800 ; default if nothing else was used -%endmacro +; -*- nasm -*- + +; NASM macro file to allow the `bin' output format to generate + +; simple .EXE files by constructing the EXE header by hand. + +; Adapted from a contribution by Yann Guidon + + + +%define EXE_stack_size EXE_realstacksize + + + +%macro EXE_begin 0 + + ORG 0E0h + + section .text + + + +header_start: + + db 4Dh,5Ah ; EXE file signature + + dw EXE_allocsize % 512 + + dw (EXE_allocsize + 511) / 512 + + dw 0 ; relocation information: none + + dw (header_end-header_start)/16 ; header size in paragraphs + + dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem + + dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem + + dw -10h ; Initial SS (before fixup) + + dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK) + + dw 0 ; (no) Checksum + + dw 100h ; Initial IP - start just after the header + + dw -10h ; Initial CS (before fixup) + + dw 0 ; file offset to relocation table: none + + dw 0 ; (no overlay) + + align 16,db 0 + +header_end: + + + +EXE_startcode: + + section .data + +EXE_startdata: + + section .bss + +EXE_startbss: + +%endmacro + + + +%macro EXE_stack 1 + +EXE_realstacksize equ %1 + +%define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end + +%endmacro + + + +%macro EXE_end 0 + + section .text + +EXE_endcode: + + section .data + +EXE_enddata: + + section .bss + + alignb 4 + +EXE_endbss: + + + +EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3) + +EXE_datasize equ EXE_enddata-EXE_startdata + +EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3) + +EXE_allocsize equ EXE_acodesize + EXE_datasize + + + +EXE_stack_size equ 0x800 ; default if nothing else was used + +%endmacro + diff --git a/insns.dat b/insns.dat index 425d0a82..f7859874 100644 --- a/insns.dat +++ b/insns.dat @@ -387,8 +387,9 @@ FXCH void \2\xD9\xC9 8086,FPU FXCH fpureg \1\xD9\10\xC8 8086,FPU FXCH fpureg,fpu0 \1\xD9\10\xC8 8086,FPU FXCH fpu0,fpureg \1\xD9\11\xC8 8086,FPU -FXRSTOR mem \300\2\x0F\xAE\202 P6,FPU -FXSAVE mem \300\2\x0F\xAE\200 P6,FPU +; these are KNI instructions and FXRSTOR should be \201 at the end +;FXRSTOR mem \300\2\x0F\xAE\202 P6,FPU +;FXSAVE mem \300\2\x0F\xAE\200 P6,FPU FXTRACT void \2\xD9\xF4 8086,FPU FYL2X void \2\xD9\xF1 8086,FPU FYL2XP1 void \2\xD9\xF9 8086,FPU @@ -1088,3 +1089,180 @@ Jcc imm \330\x70\50 8086 Jcc imm|short \330\x70\50 8086 SETcc mem \300\1\x0F\330\x90\200 386,SB SETcc reg8 \300\1\x0F\330\x90\200 386 + +;kni katmai new instructions +ADDPS xmmreg,xmmreg \2\x0F\x58\110 P6,MMX +ADDPS xmmreg,mem \301\2\x0F\x58\110 P6,MMX +ADDSS xmmreg,xmmreg \3\xF3\x0F\x58\110 P6,MMX +ADDSS xmmreg,mem \301\3\xF3\x0F\x58\110 P6,MMX + +MULPS xmmreg,xmmreg \2\x0F\x59\110 P6,MMX +MULPS xmmreg,mem \301\2\x0F\x59\110 P6,MMX +MULSS xmmreg,xmmreg \3\xF3\x0F\x59\110 P6,MMX +MULSS xmmreg,mem \301\3\xF3\x0F\x59\110 P6,MMX + +DIVPS xmmreg,xmmreg \2\x0F\x5E\110 P6,MMX +DIVPS xmmreg,mem \301\2\x0F\x5E\110 P6,MMX +DIVSS xmmreg,xmmreg \3\xF3\x0F\x5E\110 P6,MMX +DIVSS xmmreg,mem \301\3\xF3\x0F\x5E\110 P6,MMX + +SUBPS xmmreg,xmmreg \2\x0F\x5C\110 P6,MMX +SUBPS xmmreg,mem \301\2\x0F\x5C\110 P6,MMX +SUBSS xmmreg,xmmreg \3\xF3\x0F\x5C\110 P6,MMX +SUBSS xmmreg,mem \301\3\xF3\x0F\x5C\110 P6,MMX + +RCPPS xmmreg,xmmreg \2\x0F\x53\110 P6,MMX +RCPPS xmmreg,mem \301\2\x0F\x53\110 P6,MMX +RCPSS xmmreg,xmmreg \3\xF3\x0F\x53\110 P6,MMX +RCPSS xmmreg,mem \301\3\xF3\x0F\x53\110 P6,MMX + +RSQRTPS xmmreg,xmmreg \2\x0F\x52\110 P6,MMX +RSQRTPS xmmreg,mem \301\2\x0F\x52\110 P6,MMX +RSQRTSS xmmreg,xmmreg \3\xF3\x0F\x52\110 P6,MMX +RSQRTSS xmmreg,mem \301\3\xF3\x0F\x52\110 P6,MMX + +SQRTPS xmmreg,xmmreg \2\x0F\x51\110 P6,MMX +SQRTPS xmmreg,mem \301\2\x0F\x51\110 P6,MMX +SQRTSS xmmreg,xmmreg \3\xF3\x0F\x51\110 P6,MMX +SQRTSS xmmreg,mem \301\3\xF3\x0F\x51\110 P6,MMX + +ANDPS xmmreg,xmmreg \2\x0F\x54\110 P6,MMX +ANDPS xmmreg,mem \301\2\x0F\x54\110 P6,MMX +ANDNPS xmmreg,xmmreg \2\x0F\x55\110 P6,MMX +ANDNPS xmmreg,mem \301\2\x0F\x55\110 P6,MMX +ORPS xmmreg,xmmreg \2\x0F\x56\110 P6,MMX +ORPS xmmreg,mem \301\2\x0F\x56\110 P6,MMX +XORPS xmmreg,xmmreg \2\x0F\x57\110 P6,MMX +XORPS xmmreg,mem \301\2\x0F\x57\110 P6,MMX + +MAXPS xmmreg,xmmreg \2\x0F\x5F\110 P6,MMX +MAXPS xmmreg,mem \301\2\x0F\x5F\110 P6,MMX +MAXSS xmmreg,xmmreg \3\xF3\x0F\x5F\110 P6,MMX +MAXSS xmmreg,mem \301\3\xF3\x0F\x5F\110 P6,MMX +MINPS xmmreg,xmmreg \2\x0F\x5D\110 P6,MMX +MINPS xmmreg,mem \301\2\x0F\x5D\110 P6,MMX +MINSS xmmreg,xmmreg \3\xF3\x0F\x5D\110 P6,MMX +MINSS xmmreg,mem \301\3\xF3\x0F\x5D\110 P6,MMX + +CMPEQPS xmmreg,xmmreg \2\x0F\xC2\110\1\x00 P6,MMX +CMPEQPS xmmreg,mem \301\2\x0F\xC2\110\1\x00 P6,MMX +CMPEQSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x00 P6,MMX +CMPEQSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\0x00 P6,MMX + +CMPLTPS xmmreg,xmmreg \2\x0F\xC2\110\1\x01 P6,MMX +CMPLTPS xmmreg,mem \301\2\x0F\xC2\110\1\x01 P6,MMX +CMPLTSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x01 P6,MMX +CMPLTSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x01 P6,MMX + +CMPLEPS xmmreg,xmmreg \2\x0F\xC2\110\1\x02 P6,MMX +CMPLEPS xmmreg,mem \301\2\x0F\xC2\110\1\x02 P6,MMX +CMPLESS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x02 P6,MMX +CMPLESS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x02 P6,MMX + +CMPUNORDPS xmmreg,xmmreg \2\x0F\xC2\110\1\x03 P6,MMX +CMPUNORDPS xmmreg,mem \301\2\x0F\xC2\110\1\x03 P6,MMX +CMPUNORDSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x03 P6,MMX +CMPUNORDSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x03 P6,MMX + +CMPNEQPS xmmreg,xmmreg \2\x0F\xC2\110\1\x04 P6,MMX +CMPNEQPS xmmreg,mem \301\2\x0F\xC2\110\1\x04 P6,MMX +CMPNEQSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x04 P6,MMX +CMPNEQSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x04 P6,MMX + +CMPNLTPS xmmreg,xmmreg \2\x0F\xC2\110\1\x05 P6,MMX +CMPNLTPS xmmreg,mem \301\2\x0F\xC2\110\1\x05 P6,MMX +CMPNLTSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x05 P6,MMX +CMPNLTSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x05 P6,MMX + +CMPNLEPS xmmreg,xmmreg \2\x0F\xC2\110\1\x06 P6,MMX +CMPNLEPS xmmreg,mem \301\2\x0F\xC2\110\1\x06 P6,MMX +CMPNLESS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x06 P6,MMX +CMPNLESS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x06 P6,MMX + +CMPORDPS xmmreg,xmmreg \2\x0F\xC2\110\1\x07 P6,MMX +CMPORDPS xmmreg,mem \301\2\x0F\xC2\110\1\x07 P6,MMX +CMPORDSS xmmreg,xmmreg \3\xF3\x0F\xC2\110\1\x07 P6,MMX +CMPORDSS xmmreg,mem \301\3\xF3\x0F\xC2\110\1\x07 P6,MMX + +UCOMISS xmmreg,xmmreg \2\x0F\x2E\110 P6,MMX +UCOMISS xmmreg,mem \301\2\x0F\x2E\110 P6,MMX +COMISS xmmreg,xmmreg \2\x0F\x2F\110 P6,MMX +COMISS xmmreg,mem \301\2\x0F\x2F\110 P6,MMX + +CVTPI2PS xmmreg,mmxreg \2\x0F\x2A\110 P6,MMX +CVTPI2PS xmmreg,mem \301\2\x0F\x2A\110 P6,MMX +CVTPS2PI mmxreg,xmmreg \2\x0F\x2D\110 P6,MMX +CVTPS2PI mmxreg,mem \301\2\x0F\x2D\110 P6,MMX +CVTTPS2PI mmxreg,xmmreg \2\x0F\x2C\110 P6,MMX +CVTTPS2PI mmxreg,mem \301\2\x0F\x2C\110 P6,MMX + +CVTSI2SS xmmreg,reg32 \3\xF3\x0F\x2A\110 P6,MMX +CVTSI2SS xmmreg,mem \301\3\xF3\x0F\x2A\110 P6,MMX +CVTSS2SI reg32,xmmreg \3\xF3\x0F\x2D\110 P6,MMX +CVTSS2SI reg32,mem \301\3\xF3\x0F\x2D\110 P6,MMX +CVTTSS2SI reg32,xmmreg \3\xF3\x0F\x2C\110 P6,MMX +CVTTSS2SI reg32,mem \301\xF3\3\x0F\x2C\110 P6,MMX + +FXSAVE mem \300\2\x0F\xAE\200 P6,MMX +FXRSTOR mem \300\2\x0F\xAE\201 P6,MMX +LDMXCSR mem \300\2\x0F\xAE\202 P6,MMX +STMXCSR mem \300\2\x0F\xAE\203 P6,MMX +SFENCE void \3\x0F\xAE\xF8 P6,MMX + +PREFETCHNTA mem \300\2\x0F\x18\200 P6,MMX +PREFETCHT0 mem \300\2\x0F\x18\201 P6,MMX +PREFETCHT1 mem \300\2\x0F\x18\202 P6,MMX +PREFETCHT2 mem \300\2\x0F\x18\203 P6,MMX + +MOVAPS xmmreg,xmmreg \2\x0F\x28\110 P6,MMX +MOVAPS xmmreg,mem \301\2\x0F\x28\110 P6,MMX +MOVAPS xmmreg,xmmreg \2\x0F\x29\101 P6,MMX +MOVAPS mem,xmmreg \300\2\x0F\x29\101 P6,MMX + +MOVHPS xmmreg,xmmreg \2\x0F\x16\110 P6,MMX +MOVHPS xmmreg,mem \301\2\x0F\x16\110 P6,MMX +MOVHPS xmmreg,xmmreg \2\x0F\x17\101 P6,MMX +MOVHPS mem,xmmreg \300\2\x0F\x17\101 P6,MMX + +MOVLPS xmmreg,xmmreg \2\x0F\x12\110 P6,MMX +MOVLPS xmmreg,mem \301\2\x0F\x12\110 P6,MMX +MOVLPS xmmreg,xmmreg \2\x0F\x13\101 P6,MMX +MOVLPS mem,xmmreg \300\2\x0F\x13\101 P6,MMX + +MOVUPS xmmreg,xmmreg \2\x0F\x10\110 P6,MMX +MOVUPS xmmreg,mem \301\2\x0F\x10\110 P6,MMX +MOVUPS xmmreg,xmmreg \2\x0F\x11\101 P6,MMX +MOVUPS mem,xmmreg \300\2\x0F\x11\101 P6,MMX + +MOVSS xmmreg,xmmreg \3\xF3\x0F\x10\110 P6,MMX +MOVSS xmmreg,mem \301\3\xF3\x0F\x10\110 P6,MMX +MOVSS xmmreg,xmmreg \3\xF3\x0F\x11\101 P6,MMX +MOVSS mem,xmmreg \300\3\xF3\x0F\x11\101 P6,MMX + +MOVMSKPS reg32,xmmreg \2\x0F\x50\110 P6,MMX + +MOVNTPS mem,xmmreg \2\x0F\x2B\101 P6,MMX + +SHUFPS xmmreg,xmmreg,imm8 \2\x0F\xC6\110\22 P6,MMX + +UNPCKHPS xmmreg,xmmreg \2\x0F\x15\110 P6,MMX +UNPCKLPS xmmreg,xmmreg \2\x0F\x14\110 P6,MMX + + +; extra mmx instructions introduced in katmai +MOVNTQ mem,mmxreg \2\x0F\xE7\101 P6,MMX +;PAVGB \xE0 +;PAVGW \xE3 +;PEXTRW \xC5 +;PINSRW \xC4 +;PMAXSW \xEE +;PMAXUB \xDE +;PMINSW \xEA +;PMINUB \xDA +;PMOVMSKB \xD7 +;PMULHUW \xE4 +;PSADBW \xF6 +;PSHUFW \x70 +;MASKMOVQ \xF7 + + diff --git a/nasm.h b/nasm.h index 833e68d6..baf82b48 100644 --- a/nasm.h +++ b/nasm.h @@ -13,7 +13,7 @@ #define NASM_MAJOR_VER 0 #define NASM_MINOR_VER 98 -#define NASM_VER "0.98 pre-release 3.3" +#define NASM_VER "0.98 pre-release J5" #ifndef NULL #define NULL 0 @@ -380,6 +380,7 @@ enum { #define REG16 0x00201002L #define REG32 0x00201004L #define MMXREG 0x00201008L /* MMX registers */ +#define XMMREG 0x00201010L /* XMM Katmai reg */ #define FPUREG 0x01000000L /* floating point stack registers */ #define FPU0 0x01000800L /* FPU stack register zero */ @@ -423,7 +424,8 @@ enum { /* register names */ R_EBP, R_EBX, R_ECX, R_EDI, R_EDX, R_ES, R_ESI, R_ESP, R_FS, R_GS, R_MM0, R_MM1, R_MM2, R_MM3, R_MM4, R_MM5, R_MM6, R_MM7, R_SI, R_SP, R_SS, R_ST0, R_ST1, R_ST2, R_ST3, R_ST4, R_ST5, - R_ST6, R_ST7, R_TR3, R_TR4, R_TR5, R_TR6, R_TR7, REG_ENUM_LIMIT + R_ST6, R_ST7, R_TR3, R_TR4, R_TR5, R_TR6, R_TR7, + R_XMM0, R_XMM1, R_XMM2, R_XMM3, R_XMM4, R_XMM5, R_XMM6, R_XMM7, REG_ENUM_LIMIT }; /* Instruction names automatically generated from insns.dat */ diff --git a/parser.c b/parser.c index 704e2eb4..1a9c9e4e 100644 --- a/parser.c +++ b/parser.c @@ -28,7 +28,8 @@ static long reg_flags[] = { /* sizes and special flags */ MMXREG, MMXREG, MMXREG, MMXREG, MMXREG, MMXREG, MMXREG, MMXREG, REG16, REG16, REG_DESS, FPU0, FPUREG, FPUREG, FPUREG, FPUREG, FPUREG, FPUREG, FPUREG, REG_TREG, REG_TREG, REG_TREG, REG_TREG, - REG_TREG + REG_TREG, + XMMREG, XMMREG, XMMREG, XMMREG, XMMREG, XMMREG, XMMREG, XMMREG }; enum { /* special tokens */ diff --git a/preproc.c b/preproc.c index e16432a5..44609075 100644 --- a/preproc.c +++ b/preproc.c @@ -8,10 +8,30 @@ * initial version 18/iii/97 by Simon Tatham */ -#define br0 '{' -#define br1 "{" -#define br2 '}' -#define br3 "}" +/* Typical flow of text through preproc + * + * pp_getline gets tokenised lines, either + * + * from a macro expansion + * + * or + * { + * read_line gets raw text from stdmacpos, or predef, or current input file + * tokenise converts to tokens + * } + * + * expand_mmac_params is used to expand %1 etc., unless a macro is being + * defined or a false conditional is being processed + * (%0, %1, %+1, %-1, %%foo + * + * do_directive checks for directives + * + * expand_smacro is used to expand single line macros + * + * expand_mmacro is used to expand multi-line macros + * + * detoken is used to convert the line back to text + */ #include #include @@ -323,8 +343,9 @@ int any_extrastdmac; /* * Forward declarations. */ +static Token *expand_mmac_params (Token *tline); static Token *expand_smacro (Token *tline); -static void make_tok_num(Token *tok, long val); +static void make_tok_num(Token *tok, long val); /* * Macros for safe checking of token pointers, avoid *(NULL) @@ -1413,7 +1434,7 @@ static int do_directive (Token *tline) if (emitting(istk->conds->state) || istk->conds->state == COND_NEVER) istk->conds->state = COND_NEVER; else { - j = if_condition(tline->next, i); + j = if_condition(expand_mmac_params(tline->next), i); tline->next = NULL; /* it got freed */ free_tlist (origline); if (j < 0) @@ -2279,7 +2300,7 @@ static Token *expand_smacro (Token *tline) white = 0; continue; /* parameter loop */ } - if (ch == br0 && + if (ch == '{' && (brackets>0 || (brackets==0 && !paramsize[nparam]))) { @@ -2289,7 +2310,7 @@ static Token *expand_smacro (Token *tline) continue; /* parameter loop */ } } - if (ch == br2 && brackets>0) + if (ch == '}' && brackets>0) if (--brackets == 0) { brackets = -1; continue; /* parameter loop */ @@ -2966,7 +2987,6 @@ void pp_include_path (char *path) i = nasm_malloc(sizeof(IncPath)); i->path = nasm_strdup(path); i->next = ipath; - ipath = i; } diff --git a/rdoff/Makefile.sc b/rdoff/Makefile.sc index fca911ad..816cc98e 100644 --- a/rdoff/Makefile.sc +++ b/rdoff/Makefile.sc @@ -1,57 +1,112 @@ -# Makefile for RDOFF object file utils; part of the Netwide Assembler -# -# The Netwide Assembler is copyright (C) 1996 Simon Tatham and -# Julian Hall. All rights reserved. The software is -# redistributable under the licence given in the file "Licence" -# distributed in the NASM archive. -# -# This Makefile is designed for use under Unix (probably fairly -# portably). - -CC = sc -CCFLAGS = -I..\ -c -a1 -mn -Nc -w2 -w7 -o+time -5 -LINK = link -LINKFLAGS = /noi /exet:NT /su:console - -OBJ=obj -EXE=.exe - -NASMLIB = ..\nasmlib.$(OBJ) -NASMLIB_H = ..\nasmlib.h -LDRDFLIBS = rdoff.$(OBJ) $(NASMLIB) symtab.$(OBJ) collectn.$(OBJ) rdlib.$(OBJ) -RDXLIBS = rdoff.$(OBJ) rdfload.$(OBJ) symtab.$(OBJ) collectn.$(OBJ) - -.c.$(OBJ): - $(CC) $(CCFLAGS) $*.c - -all : rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) rdf2com$(EXE) - -rdfdump$(EXE) : rdfdump.$(OBJ) - $(LINK) $(LINKFLAGS) rdfdump.$(OBJ), rdfdump$(EXE); -ldrdf$(EXE) : ldrdf.$(OBJ) $(LDRDFLIBS) - $(LINK) $(LINKFLAGS) ldrdf.$(OBJ) $(LDRDFLIBS), ldrdf$(EXE); -rdx$(EXE) : rdx.$(OBJ) $(RDXLIBS) - $(LINK) $(LINKFLAGS) rdx.$(OBJ) $(RDXLIBS), rdx$(EXE); -rdflib$(EXE) : rdflib.$(OBJ) - $(LINK) $(LINKFLAGS) rdflib.$(OBJ), rdflib$(EXE); -rdf2bin$(EXE) : rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB) - $(LINK) $(LINKFLAGS) rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB), rdf2bin$(EXE); -rdf2com$(EXE) : rdf2bin$(EXE) - copy rdf2bin$(EXE) rdf2com$(EXE) - -rdf2bin.$(OBJ) : rdf2bin.c -rdfdump.$(OBJ) : rdfdump.c -rdoff.$(OBJ) : rdoff.c rdoff.h -ldrdf.$(OBJ) : ldrdf.c rdoff.h $(NASMLIB_H) symtab.h collectn.h rdlib.h -symtab.$(OBJ) : symtab.c symtab.h -collectn.$(OBJ) : collectn.c collectn.h -rdx.$(OBJ) : rdx.c rdoff.h rdfload.h symtab.h -rdfload.$(OBJ) : rdfload.c rdfload.h rdoff.h collectn.h symtab.h -rdlib.$(OBJ) : rdlib.c rdlib.h -rdflib.$(OBJ) : rdflib.c - -clean : - del *.$(OBJ) rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) - - - \ No newline at end of file +# Makefile for RDOFF object file utils; part of the Netwide Assembler + +# + +# The Netwide Assembler is copyright (C) 1996 Simon Tatham and + +# Julian Hall. All rights reserved. The software is + +# redistributable under the licence given in the file "Licence" + +# distributed in the NASM archive. + +# + +# This Makefile is designed for use under Unix (probably fairly + +# portably). + + + +CC = sc + +CCFLAGS = -I..\ -c -a1 -mn -Nc -w2 -w7 -o+time -5 + +LINK = link + +LINKFLAGS = /noi /exet:NT /su:console + + + +OBJ=obj + +EXE=.exe + + + +NASMLIB = ..\nasmlib.$(OBJ) + +NASMLIB_H = ..\nasmlib.h + +LDRDFLIBS = rdoff.$(OBJ) $(NASMLIB) symtab.$(OBJ) collectn.$(OBJ) rdlib.$(OBJ) + +RDXLIBS = rdoff.$(OBJ) rdfload.$(OBJ) symtab.$(OBJ) collectn.$(OBJ) + + + +.c.$(OBJ): + + $(CC) $(CCFLAGS) $*.c + + + +all : rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) rdf2com$(EXE) + + + +rdfdump$(EXE) : rdfdump.$(OBJ) + + $(LINK) $(LINKFLAGS) rdfdump.$(OBJ), rdfdump$(EXE); + +ldrdf$(EXE) : ldrdf.$(OBJ) $(LDRDFLIBS) + + $(LINK) $(LINKFLAGS) ldrdf.$(OBJ) $(LDRDFLIBS), ldrdf$(EXE); + +rdx$(EXE) : rdx.$(OBJ) $(RDXLIBS) + + $(LINK) $(LINKFLAGS) rdx.$(OBJ) $(RDXLIBS), rdx$(EXE); + +rdflib$(EXE) : rdflib.$(OBJ) + + $(LINK) $(LINKFLAGS) rdflib.$(OBJ), rdflib$(EXE); + +rdf2bin$(EXE) : rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB) + + $(LINK) $(LINKFLAGS) rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB), rdf2bin$(EXE); + +rdf2com$(EXE) : rdf2bin$(EXE) + + copy rdf2bin$(EXE) rdf2com$(EXE) + + + +rdf2bin.$(OBJ) : rdf2bin.c + +rdfdump.$(OBJ) : rdfdump.c + +rdoff.$(OBJ) : rdoff.c rdoff.h + +ldrdf.$(OBJ) : ldrdf.c rdoff.h $(NASMLIB_H) symtab.h collectn.h rdlib.h + +symtab.$(OBJ) : symtab.c symtab.h + +collectn.$(OBJ) : collectn.c collectn.h + +rdx.$(OBJ) : rdx.c rdoff.h rdfload.h symtab.h + +rdfload.$(OBJ) : rdfload.c rdfload.h rdoff.h collectn.h symtab.h + +rdlib.$(OBJ) : rdlib.c rdlib.h + +rdflib.$(OBJ) : rdflib.c + + + +clean : + + del *.$(OBJ) rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) + + + + + -- cgit v1.2.1