import lmacros from snapshot of hg 9fa0e64034cd

From https://hg.pushbx.org/ecm/lmacros/file/9fa0e64034cd
This commit is contained in:
C. Masloch 2022-05-26 21:30:34 +02:00 committed by E. C. Masloch
parent fd281799eb
commit fb689c1372
29 changed files with 3845 additions and 0 deletions

304
test/lmacros/jn_warn.mac Normal file
View File

@ -0,0 +1,304 @@
[list -]
%if 0
Warn for near jumps
Public Domain by C. Masloch, 2018
%endif
%ifndef __JN_WARN_MAC__
%assign __JN_WARN_MAC__ 1
%imacro jz 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnz 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro je 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jne 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jc 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnc 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jb 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnb 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro ja 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jna 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jae 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnae 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jbe 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnbe 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro js 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jns 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jo 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jno 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jp 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnp 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jl 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnl 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jg 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jng 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jge 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnge 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jle 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jnle 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jecxz 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jcxz 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%imacro jmp 1.nolist
%%start:
%? %1
%%end:
%assign %%length %%end - %%start
%if %%length > 2 && %%length < 5
%warning __FILE__ __LINE__ %? %1 %%length
%endif
%endmacro
%endif
[list +]

1101
test/lmacros/lmacros1.mac Normal file

File diff suppressed because it is too large Load Diff

1218
test/lmacros/lmacros2.mac Normal file

File diff suppressed because it is too large Load Diff

137
test/lmacros/lmacros3.mac Normal file
View File

@ -0,0 +1,137 @@
[list -]
%if 0
Extensions to NASM macro collection
Public Domain by C. Masloch, 2019
Intended for 86 Mode programs.
%endif
%ifndef __lMACROS3_MAC__
%assign __lMACROS3_MAC__ 1
%include "lmacros2.mac"
[list -]
; This macro is used to generate byte or word access to specific
; bits of a dword variable.
; %1 = token: if "~", bit value will be negated after checking
; %2 = instruction
; %3 = variable, in the form "[address]" without size specification
; %4 = bit value(s) to access
; %5 = bool: disable word access warning, defaults to 0
; If the value in %4 has bits set in different bytes so that
; a single 8- or 16-bit instruction cannot access all the bits,
; an error is displayed. This insures that the macro only has
; to generate one instruction, as a 32-bit access on 16-bit
; CPUs requires multiple instructions. This workaround code
; needs to be written specifically then, or the flags have to
; be re-ordered to allow the access.
%macro _opt 4-5.nolist 0
%push
%defstr %$adr %3
%strlen %$len %$adr
%substr %$tf %$adr 1
%substr %$tb %$adr %$len
%substr %$adr %$adr 2,-2
%deftok %$adr %$adr
%%num: equ %4
%assign %$num %%num
%ifnidn %$tf,"["
%error Invalid memory access syntax
%elifnidn %$tb,"]"
%error Invalid memory access syntax
%elifn %$num
%error Bit value is zero! Check code.
%elifn (%$num) & ~0FFh
%2 byte [%$adr], %1(%$num)
%elifn (%$num) & ~0FF00h
%2 byte [%$adr+1], %1((%$num)>>8)
%elifn (%$num) & ~0FF0000h
%2 byte [%$adr+2], %1((%$num)>>16)
%elifn (%$num) & ~0FF000000h
%2 byte [%$adr+3], %1((%$num)>>24)
%elifn (%$num) & ~0FFFFh
%ifn %5
%warning Macro generated word access
%endif
%2 word [%$adr], %1(%$num)
%elifn (%$num) & ~0FFFF00h
%ifn %5
%warning Macro generated word access
%endif
%2 word [%$adr+1], %1((%$num)>>8)
%elifn (%$num) & ~0FFFF0000h
%ifn %5
%warning Macro generated word access
%endif
%2 word [%$adr+2], %1((%$num)>>16)
%else
%error Unsupported macro usage, requires dword:
%ifempty %1
%error %2 dword [%$adr], %$num
%else
%error %2 dword [%$adr], %1(%$num)
%endif
%endif
%pop
%endmacro
; User forms for above macro.
; %1 = variable, in the form "[address]" without size specification
; %2 = bit value(s) to access
; %3 = bool: disable word access warning, defaults to 0
; testopt tests the specified bits (using a "test" instruction) and
; leaves a meaningful result in ZF, as well as NC.
; clropt clears the specified bits (using an "and" instruction with
; the negated value) and leaves NC, but a random ZF.
; setopt sets the specified bits (using an "or" instruction) and
; leaves NC, NZ.
; xoropt toggles the specified bits (using a "xor" instruction) and
; leaves NC, but a random ZF.
%idefine testopt _opt ,test,
%idefine clropt _opt ~,and,
%idefine setopt _opt ,or,
%idefine xoropt _opt ,xor,
%imacro addsection 1-2.nolist
%ifdef _SECTION_ADDED_%1
%error Section %1 already added
%endif
section %1 %2
%define _SECTION_ADDED_%1 1
usesection %1
%endmacro
%imacro usesection 1-2.nolist 0
%ifndef _SECTION_ADDED_%1
%error Section %1 not yet added
%endif
%if %2
[section %1]
%else
section %1
%endif
%endmacro
%macro subcpu 1.nolist
%push SUBCPU
%xdefine %$CPU_PREV __CPU__
cpu %1
%endmacro
%macro subcpureset 0.nolist
%ifnctx SUBCPU
%error Wrong context
%endif
%xdefine __CPU__ %$CPU_PREV
%pop
__CPU__
%endmacro
%endif
[list +]

View File

@ -0,0 +1,68 @@
%assign _@@_check 2
%assign _@@_start 0
%include "lmacros2.mac"
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start: @S
jmp @F
nop
nop
@@:
;%fatal 1>@F1< 2>@F2< 3>@F3< 4>@F4<
jz @F
nop
nop
@@:
jnz @F
nop
nop
@@:
call @F
nop
@@:
exit:
mov ax, 4C00h
int 21h
align 16
second: @S 0
jmp @F
nop
nop
@@:
;%fatal 1>@F1< 2>@F2< 3>@F3< 4>@F4<
jz @F
nop
nop
@@:
jnz @F
nop
nop
@@:
call @F
nop
@@:
jmp exit
align 16
jmp @B
jmp @BB
jmp @B3
jmp @B4

View File

@ -0,0 +1,32 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun1
mov ax, 4C00h
int 21h
%endif
fun1:
lframe near
lvar word, foo
lvar word, bar
lenter
lvar word, quux
push ax
lleave
lret

View File

@ -0,0 +1,37 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
push ax
call fun2
mov ax, 4C00h
int 21h
%endif
fun2:
lframe near
lpar word, alpha
lvar word, foo
lvar word, bar
lenter
lvar word, quux
push ax
mov word [bp + ?foo], 0F00h
mov dx, word [bp + ?alpha]
lleave
lret

View File

@ -0,0 +1,40 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
push bx
push cx
call fun3
pop bx
mov ax, 4C00h
int 21h
%endif
fun3:
lframe near
lpar word, beta
lpar_return
lpar word, alpha
lvar word, foo
lvar word, bar
lenter
lvar word, quux
push ax
mov word [bp + ?beta], 0BE7Ah
lleave
lret

View File

@ -0,0 +1,34 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun4
mov ax, 4C00h
int 21h
%endif
fun4:
lframe near
lenter early
lvar word, foo
push bx
lvar word, bar
lenter
lvar word, quux
push ax
lleave
lret

View File

@ -0,0 +1,34 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun5
mov ax, 4C00h
int 21h
%endif
fun5:
lframe near
lenter
lvar word, foo
push bx
lvar word, bar
lreserve
lvar word, quux
push ax
lleave
lret

View File

@ -0,0 +1,43 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun6
mov ax, 4C00h
int 21h
%endif
fun6:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
lframe 0, nested
lvar word, qux
lvar word, foo
lenter
mov word [bp + ?foo], bx
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,44 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun7
mov ax, 4C00h
int 21h
%endif
fun7:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
lframe 0, inner
lvar word, qux
lvar word, foo
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,51 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun8
mov ax, 4C00h
int 21h
%endif
fun8:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
push cs
push si
lframe 0, inner
lpar word, segment
lpar word, offset
lvar word, qux
lvar word, foo
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?segment]
mov dx, word [bp + ?offset]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,52 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun9
mov ax, 4C00h
int 21h
%endif
fun9:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
push cs
push si
lframe 0, inner
lpar word, segment
lpar word, offset
lvar word, qux
lvar word, foo
lvar word, xyzzy
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?segment]
mov dx, word [bp + ?offset]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,49 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun10
mov ax, 4C00h
int 21h
%endif
fun10:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
push cs
push si
lframe 0, inner
lpar word, segment
lpar word, offset
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?segment]
mov dx, word [bp + ?offset]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,50 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun11
mov ax, 4C00h
int 21h
%endif
fun11:
lframe near
lvar word, foo
lvar word, bar
lenter
mov word [bp + ?foo], ax
push cs
push si
lframe 0, inner
lpar word, segment
lpar_return
lpar word, offset
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?segment]
mov dx, word [bp + ?offset]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,48 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun12
mov ax, 4C00h
int 21h
%endif
fun12:
lframe near
lvar word, foo
lvar word, bar
lenter
lvar word, baz
push bx
mov word [bp + ?foo], ax
lframe 0, inner
lvar word, quux
lvar word, foo
lenter
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?quux]
mov dx, word [bp + ?baz]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,49 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun13
mov ax, 4C00h
int 21h
%endif
fun13:
lframe near
lvar word, foo
lvar word, bar
lenter
lvar word, baz
push bx
mov word [bp + ?foo], ax
lframe 0, inner
lenter
lvar word, quux
lvar word, foo
lreserve
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?quux]
mov dx, word [bp + ?baz]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,56 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun14
mov ax, 4C00h
int 21h
%endif
fun14:
lframe near
lvar word, foo
lvar word, bar
lenter
lvar word, baz
push bx
mov word [bp + ?foo], ax
push cs
push si
lframe 0, inner
lpar word, alpha
lpar word, beta
lpar_return
lenter
lvar word, quux
lvar word, foo
lreserve
mov word [bp + ?foo], bx
mov ax, word [bp + ?bar]
mov bx, word [bp + ?quux]
mov dx, word [bp + ?baz]
mov si, word [bp + ?beta]
inc word [bp + ?alpha]
lleave
mov ax, word [bp + ?foo]
lleave
lret

View File

@ -0,0 +1,70 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
push ax
call fun15
mov ax, 4C00h
int 21h
%endif
fun15:
.1:
lframe near
lpar word, alpha
lvar word, foo
lvar word, bar
lenter
lvar word, baz
push bx
jmp .common
.2:
%ifdef FAIL3
bits 32
%endif
%ifdef FAIL4
lframe far, nested
%else
lframe near, nested
%endif
lpar word, alpha
%ifdef FAIL2
lpar_return
%endif
lvar word, foo
%ifdef FAIL5
lvar word, foobar
%else
lvar word, bar
%endif
%ifdef FAIL1
lvar word, quux
%endif
lenter
lvar word, baz
push bx
ldup
lleave ctx
.common:
mov dx, word [bp + ?alpha]
mov word [bp + ?foo], ax
lleave
lret

View File

@ -0,0 +1,64 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
xor ax, ax
push ax
call fun16
mov ax, 1
push bx
call fun16
mov ax, 4C00h
int 21h
%endif
fun16:
mov bx, 0B3B3h
mov dx, 0D3D3h
lframe near
lpar word, alpha
lvar word, foo
lvar word, bar
lenter
test ax, ax
jnz .handler2
.handler1:
lvar word, quux
push cx
mov dx, word [bp + ?alpha]
mov word [bp + ?foo], ax
add ax, word [bp + ?quux]
lleave
lret
.handler2:
lframe near
lemit off
lpar word, alpha
lvar word, foo
lvar word, bar
lenter
lemit
lvar word, baz
push dx
mov bx, word [bp + ?alpha]
mov word [bp + ?foo], ax
lleave
lret

View File

@ -0,0 +1,60 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
mov cx, 1234h
xor ax, ax
push ax
call fun17
mov ax, 4C00h
int 21h
%endif
fun17:
lframe near
lpar word, alpha
lvar word, foo
lvar word, bar
lenter ; push bp \ mov bp, sp \ push ax \ push ax
lvar word, quux
push cx ; push cx
lvar word, baz
lvar dword, xyzzy
lreserve ; lea sp, [bp - 0Ch]
mov dx, word [bp + ?alpha]
; [bp + 4]
mov word [bp + ?foo], ax
; [bp - 2]
add ax, word [bp + ?quux]
; [bp - 6]
mov word [bp + ?xyzzy], dx
; [bp - 0Ch]
lframe 0, inner
lvar word, e
lvar word, f
lvar word, g
lenter ; lea sp, [bp - 12h]
lvar word, h
push ax ; push ax
lvar dword, i
lreserve ; lea sp, [bp - 18h]
lleave ; lea sp, [bp - 0Ch]
lleave ; mov sp, bp \ pop bp
lret ; retn 2

View File

@ -0,0 +1,36 @@
%include "lmacros2.mac"
numdef STANDALONE, 1
%if _STANDALONE
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun18
mov ax, 4C00h
int 21h
%endif
fun18:
lframe near
lequ 16 * 3, 16tablesize
lvar ?16tablesize, firsttable
lvar fromparas(paras(26)), secondtable
lenter ; push bp \ mov bp, sp \ lea sp, [bp - 50h]
lea si, [bp + ?firsttable]
; lea si, [bp - 30h]
lea di, [bp + ?secondtable]
; lea di, [bp - 50h]
lleave ; mov sp, bp \ pop bp
lret ; retn

View File

@ -0,0 +1,26 @@
%define _@@_check
%assign _@@_start 0
%include "lmacros2.mac"
@S
nop
@@:
nop
jmp @F
nop
nop
jmp @B
@@:
nop
nop
@I
nop
nop
@S
@@:
nop
nop
jmp @B
@I

8
test/lmacros/tests/test.sh Executable file
View File

@ -0,0 +1,8 @@
#! /bin/bash
echo -ne "" > "$1.lst"
[ -z "$NASM" ] && NASM=nasm
"$NASM" "$1.asm" -D_MAP="$1.map" -l "$1.lst" -f bin -o "$@" -I ../
cat "$1.lst"
ndisasm "$1"

View File

@ -0,0 +1,51 @@
%include "lmacros2.mac"
%ifdef _MAP
[map symbols brief _MAP]
%endif
cpu 8086
org 256
sectalign off
section lCode start=256 align=1
start:
call fun1
push ax
call fun2
push bx
push cx
call fun3
pop bx
call fun4
call fun5
call fun6
call fun7
call fun8
call fun9
call fun10
call fun11
call fun12
call fun13
call fun14
mov ax, 4C00h
int 21h
overridedef STANDALONE, 0
%include "001.asm"
%include "002.asm"
%include "003.asm"
%include "004.asm"
%include "005.asm"
%include "006.asm"
%include "007.asm"
%include "008.asm"
%include "009.asm"
%include "010.asm"
%include "011.asm"
%include "012.asm"
%include "013.asm"
%include "014.asm"
resetdef

7
test/lmacros/tests/testmap.sh Executable file
View File

@ -0,0 +1,7 @@
#! /bin/bash
echo -ne "" > "$1.lst"
[ -z "$NASM" ] && NASM=nasm
"$NASM" "$1.asm" -D_MAP="$1.map" -l "$1.lst" -f bin -o "$@" -I ../
cat "$1.lst"
cat "$1.map"

View File

@ -0,0 +1,58 @@
%include "lmacros2.mac"
cpu 8086
org 100h
start:
mov ax, 1
mov bx, 2
push ax
push bx
call fun
mov cx, 3
mov dx, 4
push cx
push dx
call fun2
pop ax
mov word [fifth], ax
mov ax, 4C00h
int 21h
fun:
lframe near
lpar word, alpha
lpar word, beta
lenter
mov ax, [bp + ?alpha]
mov word [first], ax
mov ax, [bp + ?beta]
mov word [second], ax
lleave
lret
fun2:
lframe near
lpar word, gamma
lpar_return
lpar word, delta
lenter
mov ax, [bp + ?gamma]
mov word [third], ax
mov ax, [bp + ?delta]
mov word [fourth], ax
mov word [bp + ?gamma], 5
lleave
lret
align 256
first: dw 0
second: dw 0
third: dw 0
fourth: dw 0
fifth: dw 0

View File

@ -0,0 +1,18 @@
%include "lmacros2.mac"
[map all testsat.map]
cpu 8086
org 0
struc TESTSTRUC
resb 1
struc_at 1, at_1: resb 3
struc_at 4, at_4:
resw 1
exact_struc_at 6
at_6: resb 1
struc_at 32
at_32: resb 10
warn_struc_at 64
at_64: resb 1
endstruc