Skip to content

Instantly share code, notes, and snippets.

@robey
Created February 20, 2013 03:52
Show Gist options
  • Save robey/4992726 to your computer and use it in GitHub Desktop.
Save robey/4992726 to your computer and use it in GitHub Desktop.
bit_blit or memmove for DCPU
; ----- blit from B (len X) into C -- preserves A Y Z
:blit
ifl b, c
bra blit.backward.extern
:blit.forward.extern
set i, b
set j, c
add x, b
; blit from [I, X) forward into J
:blit.forward
set b, x
sub b, 8
:.1
ifl b, i
bra .3
:.2
sti [j], [i]
sti [j], [i]
sti [j], [i]
sti [j], [i]
sti [j], [i]
sti [j], [i]
sti [j], [i]
sti [j], [i]
ifg b, i
bra .2
:.3
ifl i, x
:.4
sti [j], [i]
ifl i, x
bra .4
ret
:blit.backward.extern
set j, c
add j, x
sub j, 1
set i, b
add i, x
sub i, 1
set x, b
sub x, 1
; blit from (X, I] backward into J
:blit.backward
set b, x
add b, 8
:.1
ifg b, i
bra .3
:.2
std [j], [i]
std [j], [i]
std [j], [i]
std [j], [i]
std [j], [i]
std [j], [i]
std [j], [i]
std [j], [i]
ifl b, i
bra .2
:.3
ifg i, x
:.4
std [j], [i]
ifg i, x
bra .4
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment