Skip to content

Instantly share code, notes, and snippets.

@whitequark whitequark/_delay_4c.asm
Last active May 20, 2019

Embed
What would you like to do?
lcall _delay_4c
sjmp .
_delay_4c::
; (ljmp delay_4c) ; 0c > 4c
mov acc, dph ; 3c
cjne a, #0, 00000$ ; 4c > 11c [A]
mov acc, dpl ; 3c
subb a, #(24/4+1) ; 2c
inc a ; 1c
jnc 00003$ ; 3c > 20c [B]
ret ; 4c > 24c
00000$:
mov a, dpl ; [A] > 2c
jz 00002$ ; 3c > 16c [C]
00001$:
djnz acc, 00001$ ; [C] > 4Lc > (16+4L)c [D]
; [E] > 1016c > (16+1024H+4L)c [G]
00002$:
nop ; [D] > 1c
mov acc, #-2 ; 3c
djnz dph, 00001$ ; 4c > (16+8+4L) [E]
nop ; 1c
mov acc, #-((28+4)/4) ; 3c > (28+4L) [F]
; [G] > 1c
; 3c
; 4c > (16+8+1024H+4L)c [E]
; 1c
; 3c > (28+1024H+4L)c [F]
00003$:
djnz acc, 00003$ ; [B] > 4Lc
ret ; 4c > (24+4L)c
; [F] > 992c
; 4c > (1024H+4L)c
#!/bin/sh -ex
sdas8051 -o -l _delay_4c.asm
sdld -i _delay_4c.rel
#!/bin/sh -e
dpl=${1-0}
dph=${2-0}
lowbound=6
if [ ${dph} -ge 1 -o ${dpl} -ge ${lowbound} ]; then
expect=$(( (${dpl}+(${dph}<<8))<<2 ))
else
expect=$(( ${lowbound}<<2 ))
fi
actual=$(s51 -t DS320 _delay_4c.ihx -c - <<END | grep Simulated | awk '{print $2/4-3}')
break 0x3
SP=0x80
dpl=${dpl}
dph=${dph}
cont
quit
END
[ ${expect} -eq ${actual} ] || (echo "failed: actual ${actual}, expect ${expect}"; exit 1)
#!/bin/sh -ex
./build.sh
for dph in `seq 0 255`; do
for dpl in `seq 0 255`; do
./run.sh ${dpl} ${dph}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.