ack/mach/i80/libem/set.s

71 lines
928 B
ArmAsm
Raw Permalink Normal View History

1985-03-18 12:46:51 +00:00
.define .set
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
! Create set with one bit on
! Expects in de-reg: size of set to be created
! Expects on stack: bit number
! Yields on stack: resulting set
.set: pop h
shld .retadr
mov h,b
mov l,c
shld .bcreg
mov a,e
rar
cc eoddz ! trap if size is odd
xchg ! hl = size of set
pop d ! de = bit number
mov a,e ! c = bit number in byte
ani 7
sta .areg ! save bit number in byte
mvi b,3 ! de = byte number
1: xra a
mov a,d
rar
mov d,a
mov a,e
rar
mov e,a
dcr b
jnz 1b
mov a,l ! trap if bit number is too large
sub e
mov a,h
sbb d
cc eset
lxi b,0 ! make empty set on stack
1: push b
dcx h
dcx h
mov a,l
ora h
jnz 1b
lxi h,0
dad sp
dad d ! hl points to byte that will contain a one
lda .areg
mov c,a ! c = bit number in byte
mvi a,1
1: dcr c
jm 2f
rlc
jmp 1b
2: mov m,a
lhld .bcreg
mov b,h
mov c,l
lhld .retadr
pchl