Simplify the .trp API to make it a bit smaller.

This commit is contained in:
David Given 2019-06-11 20:02:03 +02:00
parent 4e90de00e9
commit 3feb79ad0c
4 changed files with 13 additions and 16 deletions

View file

@ -2475,5 +2475,6 @@ with hlreg
gen shld {label,".reghp"}
pat trp
with areg
kills ALL
gen Call {label,".trp"}

View file

@ -170,8 +170,7 @@ _cpm_cmdline = 0x0081
! Some magic data. All EM systems need these.
.define .trppc, .ignmask, _errno
.comm .trppc, 2
.define .ignmask, _errno
.comm .ignmask, 2
.comm _errno, 2
@ -184,11 +183,10 @@ envp: .space 2 ! envp array (always empty, must be after argv)
! These are used specifically by the i80 code generator.
.define .trapproc, .retadr, .retadr1
.define .retadr, .retadr1
.define .bcreg, .areg
.define .tmp1, .fra, block1, block2, block3
.comm .trapproc, 2
.comm .retadr, 2 ! used to save return address
.comm .retadr1, 2 ! reserve
.comm .bcreg, 2

View file

@ -13,7 +13,8 @@
.define EUNIMPL
! Trap routine
! Expects trap number on stack.
! Expects trap number in A, and must be called directly from the code
! where execution should resume (for those traps which support it).
! Just returns if trap has to be ignored.
! Otherwise it calls a user-defined trap handler if provided.
! When no user-defined trap handler is provided or when the user-defined
@ -46,9 +47,6 @@
EUNIMPL = 63 ! unimplemented em-instruction called
.trp:
pop h
xthl
push h ! trap number and return address exchanged
mov a,l
cpi 16
jnc 3f ! jump if trap cannot be ignored
@ -66,7 +64,9 @@
ret ! OGEN DICHT EN ... SPRING!!!
3:
lhld .trapproc ! user defined trap handler?
.define .trapproc
.trapproc = . + 1
lxi h, 0 ! user defined trap handler held inline here
mov a,l
ora h
jz 1f ! jump if there was not

View file

@ -4,9 +4,7 @@ cat <<EOF
#include "asm.h"
.define $1
$1:
lxi h, $2
push h
call .trp
ret
mvi a, $2
jmp .trp
EOF