diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/c16.mac | 37 | ||||
-rw-r--r-- | misc/c32.mac | 26 | ||||
-rw-r--r-- | misc/exasm.zip | bin | 0 -> 6058 bytes | |||
-rw-r--r-- | misc/exebin.mac | 57 | ||||
-rw-r--r-- | misc/nasm.sl | 8 |
5 files changed, 128 insertions, 0 deletions
diff --git a/misc/c16.mac b/misc/c16.mac new file mode 100644 index 0000000..86e6bf9 --- /dev/null +++ b/misc/c16.mac @@ -0,0 +1,37 @@ +; 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 +%else +%assign %$arg 4 +%endif +%define %$procname %1 +%endmacro + +%imacro arg 0-1 2 ; used with the argument name as a label + equ %$arg +%assign %$arg %1+%$arg +%endmacro + +%imacro endproc 0 +%ifnctx proc +%error Mismatched `endproc'/`proc' +%else + mov sp,bp + pop bp +%ifdef PASCAL + retf %$arg +%elifdef FARCODE + retf +%else + retn +%endif +__end_%$procname: ; useful for calculating function size +%pop +%endif +%endmacro diff --git a/misc/c32.mac b/misc/c32.mac new file mode 100644 index 0000000..a59acfd --- /dev/null +++ b/misc/c32.mac @@ -0,0 +1,26 @@ +; 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 + 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/misc/exasm.zip b/misc/exasm.zip Binary files differnew file mode 100644 index 0000000..b4e9e58 --- /dev/null +++ b/misc/exasm.zip diff --git a/misc/exebin.mac b/misc/exebin.mac new file mode 100644 index 0000000..8d1eaf8 --- /dev/null +++ b/misc/exebin.mac @@ -0,0 +1,57 @@ +; -*- 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 <whygee_corp@hol.fr> + +%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/misc/nasm.sl b/misc/nasm.sl index c47d28b..691254a 100644 --- a/misc/nasm.sl +++ b/misc/nasm.sl @@ -294,6 +294,14 @@ define_keywords_n($1, nasm_kw_8, 8, 0); define_keywords_n($1, nasm_kw_9, 9, 0); define_keywords_n($1, nasm_kw_10, 10, 0); +define_keywords_n($1, "org", 3, 1); +define_keywords_n($1, "bitsiend", 4, 1); +define_keywords_n($1, "aligngroupstruc", 5, 1); +define_keywords_n($1, "alignbcommonexternglobalistruc", 6, 1); +define_keywords_n($1, "sectionsegmentlibrary", 7, 1); +define_keywords_n($1, "absoluteendstruc", 8, 1); +define_keywords_n($1, "uppercase", 9, 1); + !if (keymap_p ($1)) make_keymap ($1); definekey("nasm_bol_self_ins", ";", $1); definekey("nasm_bol_self_ins", "#", $1); |