diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-01-16 22:40:56 -0800 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-01-16 22:40:56 -0800 |
commit | 37c257ea6d0270ca3feac75ba1f88b1ce962c663 (patch) | |
tree | ea5a3418dcd8f9a533a1c1b528cb69399e801937 /runtime.S | |
parent | 4b69daeb68eea734a057f0b66b2bf7700a2a4809 (diff) |
Implement ABCD an SBCD. Fix BTEST with register source.
Diffstat (limited to 'runtime.S')
-rw-r--r-- | runtime.S | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -100,6 +100,64 @@ m68k_invalid: call printf mov $1, %rdi call exit + + .global bcd_add +bcd_add: + xchg %rax, %rdi + + mov %cl, %ch + mov %al, %ah + and $0xF, %ch + and $0xF, %ah + and $0xF0, %cl + and $0xF0, %al + add %ah, %ch + cmp $10, %ch + jb no_adjust + add $6, %ch +no_adjust: + add %ch, %al + add %al, %cl + mov $0, %ch + jc def_adjust + cmp $0xA0, %cl + jb no_adjust_h +def_adjust: + add $0x60, %cl + mov $1, %ch +no_adjust_h: + + mov %rdi, %rax + ret + + .global bcd_sub +bcd_sub: + xchg %rax, %rdi + + mov %cl, %ch + mov %al, %ah + and $0xF, %ch + and $0xF, %ah + and $0xF0, %cl + and $0xF0, %al + sub %ah, %ch + cmp $10, %ch + jb no_adjusts + sub $6, %ch +no_adjusts: + add %ch, %cl + sub %al, %cl + mov $0, %ch + jc def_adjusts + cmp $0xA0, %cl + jb no_adjust_hs +def_adjusts: + sub $0x60, %cl + mov $1, %ch +no_adjust_hs: + + mov %rdi, %rax + ret int_dbg_msg: .asciz "Executing Interrupt!" |