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
*/
#define PRINT_HEX(reg) \
HEX(<reg>);\
mov %ah, %dl;\
PUTC(%al);\
.macro PRINT_HEX reg
HEX(<\reg>)
mov %ah, %dl
PUTC(%al)
PUTC(%dl)
.endm
#define PRINT_NEWLINE \
PUTC($0x0A);\

4
cs.S
View File

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

View File

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

View File

@@ -50,42 +50,42 @@ update_in_progress:
je update_in_progress
mov %al, %cl
PRINT_HEX(%al)
PRINT_HEX <%al>
PUTC($0x20)
/* Minute. */
mov $0x02, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_HEX <%al>
PUTC($0x20)
/* Hour. */
mov $0x04, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_HEX <%al>
PUTC($0x20)
/* Day. */
mov $0x07, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_HEX <%al>
PUTC($0x20)
/* Month. */
mov $0x08, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_HEX <%al>
PUTC($0x20)
/* Year. */
mov $0x09, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX(%al)
PRINT_HEX <%al>
PRINT_NEWLINE
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) \
PRINT($x ## s);\
PRINT_HEX(x);\
PRINT_HEX <x>;\
PRINT_NEWLINE
INITIAL_STORE(ax)

4
ss.S
View File

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