diff options
author | libjet <libj3t@gmail.com> | 2020-02-19 02:49:33 +0000 |
---|---|---|
committer | libjet <libj3t@gmail.com> | 2020-02-19 02:49:33 +0000 |
commit | b1a35aa1770c7972fdb6e7af50ad529118b972d2 (patch) | |
tree | e64b9ffbcaefc2f38ceceacb40390f660595e731 /home/compare.asm | |
parent | 0a0b273fee50a66baeac441600254d77af442bef (diff) |
Add home/compare.asm
Diffstat (limited to 'home/compare.asm')
-rwxr-xr-x | home/compare.asm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/home/compare.asm b/home/compare.asm new file mode 100755 index 00000000..bd665ef4 --- /dev/null +++ b/home/compare.asm @@ -0,0 +1,35 @@ +CompareBytes:: +; Compare c bytes at de and hl. +; Return z if they all match. +.loop + ld a, [de] + cp [hl] + ret nz + inc de + inc hl + dec c + jr nz, .loop + ret + +CompareBytesLong:: +; Compare bc bytes at de and hl. +; Return carry if they all match. +.loop + ld a, [de] + cp [hl] + jr nz, .diff + + inc de + inc hl + dec bc + + ld a, b + or c + jr nz, .loop + + scf + ret + +.diff: + and a + ret
\ No newline at end of file |