summaryrefslogtreecommitdiff
path: root/runtime_win.S
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-05-28 23:05:32 -0700
committerMichael Pavone <pavone@retrodev.com>2015-05-28 23:05:32 -0700
commitd597043be9f8d1c22ac6a2365e5cbb9f82e7ea46 (patch)
tree131c7ea0f3ec03882bb8183a734f04c757918180 /runtime_win.S
parent391656eca9eb35b7e3937b2af1316460d5639306 (diff)
parent66aedc9c1a87c8811be4dba263dbcd7ec026cc70 (diff)
Merge
Diffstat (limited to 'runtime_win.S')
-rw-r--r--runtime_win.S74
1 files changed, 74 insertions, 0 deletions
diff --git a/runtime_win.S b/runtime_win.S
new file mode 100644
index 0000000..c107030
--- /dev/null
+++ b/runtime_win.S
@@ -0,0 +1,74 @@
+
+
+invalid_msg:
+ .asciz "Invalid instruction at %X\n"
+
+ .global _m68k_invalid
+_m68k_invalid:
+ push %ecx
+ push invalid_msg
+ xor %eax, %eax
+ call _printf
+ push $1
+ call _exit
+
+ .global _bcd_add
+_bcd_add:
+ xchg %eax, %edi
+
+ 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 %edi, %eax
+ ret
+
+ .global _bcd_sub
+_bcd_sub:
+ xchg %eax, %edi
+
+ 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 %edi, %eax
+ ret
+
+
+