diff runtime_win.S @ 741:80a67be1770b

Initial work on Windows port
author Michael Pavone <pavone@retrodev.com>
date Tue, 01 Apr 2014 19:43:58 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runtime_win.S	Tue Apr 01 19:43:58 2014 -0700
@@ -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
+
+
+