ack/mach/i80/libem/rck.s

58 lines
831 B
ArmAsm
Raw Normal View History

1985-03-18 12:46:51 +00:00
.define .rck
1987-01-28 18:57:04 +00:00
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
1985-03-18 12:46:51 +00:00
! Range check
! Expects on stack: address of range check descriptor
! index
! Yields index on stack unchanged
! Causes a trap if index is out of bounds
.rck: pop h
shld .retadr
mov h,b
mov l,c
shld .bcreg
pop h ! hl = return address
pop d ! de = index
mov c,m ! bc = lower bound
inx h
mov b,m
inx h
mov a,d
1987-01-28 22:54:52 +00:00
xra b
1985-03-18 12:46:51 +00:00
jm 1f ! jump if index and l.b. have different signs
mov a,e
sub c
mov a,d
sbb b
jmp 2f
1987-01-28 22:54:52 +00:00
1: xra b ! now a = d again
1985-03-18 12:46:51 +00:00
2: cm erange ! trap if index too small
mov c,m
inx h
mov b,m
mov a,d
1987-01-28 22:54:52 +00:00
xra b
1985-03-18 12:46:51 +00:00
jm 1f ! jump if index and u.b. have different signs
mov a,c
sub e
mov a,b
sbb d
jmp 2f
1987-01-28 22:54:52 +00:00
1: xra d ! now a = b
1985-03-18 12:46:51 +00:00
2: cm erange ! trap if index is too large
lhld .bcreg
mov b,h
mov c,l
lhld .retadr
pchl