Refactor print_hex

This commit is contained in:
Ciro Santilli
2015-10-20 21:04:49 +02:00
parent 3e01929b63
commit aaaea79a6f
6 changed files with 17 additions and 16 deletions

View File

@@ -201,11 +201,12 @@ reg: 1 byte register.
Clobbers: ax, dl Clobbers: ax, dl
*/ */
#define PRINT_HEX(reg) \ .macro PRINT_HEX reg
HEX(<reg>);\ HEX(<\reg>)
mov %ah, %dl;\ mov %ah, %dl
PUTC(%al);\ PUTC(%al)
PUTC(%dl) PUTC(%dl)
.endm
#define PRINT_NEWLINE \ #define PRINT_NEWLINE \
PUTC($0x0A);\ PUTC($0x0A);\

4
cs.S
View File

@@ -20,12 +20,12 @@ BEGIN
1: 1:
.skip 0x10 .skip 0x10
mov %cs, %ax mov %cs, %ax
PRINT_HEX(%al) PRINT_HEX <%al>
ljmp $2, $1f ljmp $2, $1f
1: 1:
.skip 0x20 .skip 0x20
mov %cs, %ax mov %cs, %ax
PRINT_HEX(%al) PRINT_HEX <%al>
hlt hlt

View File

@@ -30,6 +30,6 @@ loop:
cmp %al, %cl cmp %al, %cl
jz loop jz loop
mov %al, %cl mov %al, %cl
PRINT_HEX(%al) PRINT_HEX <%al>
PRINT_NEWLINE PRINT_NEWLINE
jmp loop jmp loop

View File

@@ -50,42 +50,42 @@ update_in_progress:
je update_in_progress je update_in_progress
mov %al, %cl mov %al, %cl
PRINT_HEX(%al) PRINT_HEX <%al>
PUTC($0x20) PUTC($0x20)
/* Minute. */ /* Minute. */
mov $0x02, %al mov $0x02, %al
out %al, $RTCaddress out %al, $RTCaddress
in $RTCdata, %al in $RTCdata, %al
PRINT_HEX(%al) PRINT_HEX <%al>
PUTC($0x20) PUTC($0x20)
/* Hour. */ /* Hour. */
mov $0x04, %al mov $0x04, %al
out %al, $RTCaddress out %al, $RTCaddress
in $RTCdata, %al in $RTCdata, %al
PRINT_HEX(%al) PRINT_HEX <%al>
PUTC($0x20) PUTC($0x20)
/* Day. */ /* Day. */
mov $0x07, %al mov $0x07, %al
out %al, $RTCaddress out %al, $RTCaddress
in $RTCdata, %al in $RTCdata, %al
PRINT_HEX(%al) PRINT_HEX <%al>
PUTC($0x20) PUTC($0x20)
/* Month. */ /* Month. */
mov $0x08, %al mov $0x08, %al
out %al, $RTCaddress out %al, $RTCaddress
in $RTCdata, %al in $RTCdata, %al
PRINT_HEX(%al) PRINT_HEX <%al>
PUTC($0x20) PUTC($0x20)
/* Year. */ /* Year. */
mov $0x09, %al mov $0x09, %al
out %al, $RTCaddress out %al, $RTCaddress
in $RTCdata, %al in $RTCdata, %al
PRINT_HEX(%al) PRINT_HEX <%al>
PRINT_NEWLINE PRINT_NEWLINE
jmp update_in_progress jmp update_in_progress

View File

@@ -14,7 +14,7 @@ Could be done with GDB on the emulator, but this will also work on real hardware
#define INITIAL_PRINT(x) \ #define INITIAL_PRINT(x) \
PRINT($x ## s);\ PRINT($x ## s);\
PRINT_HEX(x);\ PRINT_HEX <x>;\
PRINT_NEWLINE PRINT_NEWLINE
INITIAL_STORE(ax) INITIAL_STORE(ax)

4
ss.S
View File

@@ -17,7 +17,7 @@ BEGIN
pop %ax pop %ax
/* Restore the old stack so that it won't mess with our othe functions. */ /* Restore the old stack so that it won't mess with our othe functions. */
mov %bx, %sp mov %bx, %sp
PRINT_HEX(%al) PRINT_HEX <%al>
/* Now let's move ss and see if anything happens. */ /* Now let's move ss and see if anything happens. */
mov $1, %ax mov $1, %ax
@@ -26,7 +26,7 @@ BEGIN
/* This pop should happen 16 bytes higher than the first one. */ /* This pop should happen 16 bytes higher than the first one. */
pop %ax pop %ax
mov %bx, %sp mov %bx, %sp
PRINT_HEX(%al) PRINT_HEX <%al>
hlt hlt