Mercurial > repos > blastem
comparison runtime_32.S @ 612:5a6ff0d76032
Removed bcd_add and bcd_sub from runtime.S and generated the logic inline with the rest of abcd and sbcd translation. Fixed some edge cases and undefined flag behavior in the process
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 28 Dec 2014 17:25:36 -0800 |
parents | 96489fb27dbf |
children |
comparison
equal
deleted
inserted
replaced
611:744b305965f7 | 612:5a6ff0d76032 |
---|---|
10 xor %eax, %eax | 10 xor %eax, %eax |
11 call printf | 11 call printf |
12 push $1 | 12 push $1 |
13 call exit | 13 call exit |
14 | 14 |
15 .global bcd_add | |
16 bcd_add: | |
17 xchg %eax, %edi | |
18 | |
19 mov %cl, %ch | |
20 mov %al, %ah | |
21 and $0xF, %ch | |
22 and $0xF, %ah | |
23 and $0xF0, %cl | |
24 and $0xF0, %al | |
25 add %ah, %ch | |
26 cmp $10, %ch | |
27 jb no_adjust | |
28 add $6, %ch | |
29 no_adjust: | |
30 add %ch, %al | |
31 add %al, %cl | |
32 mov $0, %ch | |
33 jc def_adjust | |
34 cmp $0xA0, %cl | |
35 jb no_adjust_h | |
36 def_adjust: | |
37 add $0x60, %cl | |
38 mov $1, %ch | |
39 no_adjust_h: | |
40 | |
41 mov %edi, %eax | |
42 ret | |
43 | |
44 .global bcd_sub | |
45 bcd_sub: | |
46 xchg %eax, %edi | |
47 | |
48 mov %cl, %ch | |
49 mov %al, %ah | |
50 and $0xF, %ch | |
51 and $0xF, %ah | |
52 and $0xF0, %cl | |
53 and $0xF0, %al | |
54 sub %ah, %ch | |
55 cmp $10, %ch | |
56 jb no_adjusts | |
57 sub $6, %ch | |
58 no_adjusts: | |
59 add %ch, %cl | |
60 sub %al, %cl | |
61 mov $0, %ch | |
62 jc def_adjusts | |
63 cmp $0xA0, %cl | |
64 jb no_adjust_hs | |
65 def_adjusts: | |
66 sub $0x60, %cl | |
67 mov $1, %ch | |
68 no_adjust_hs: | |
69 | |
70 mov %edi, %eax | |
71 ret | |
72 | 15 |
73 | 16 |
74 | 17 |