Refactor print_hex
This commit is contained in:
9
common.h
9
common.h
@@ -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
4
cs.S
@@ -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
|
||||
|
||||
@@ -30,6 +30,6 @@ loop:
|
||||
cmp %al, %cl
|
||||
jz loop
|
||||
mov %al, %cl
|
||||
PRINT_HEX(%al)
|
||||
PRINT_HEX <%al>
|
||||
PRINT_NEWLINE
|
||||
jmp loop
|
||||
|
||||
12
in_rtc.S
12
in_rtc.S
@@ -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
|
||||
|
||||
@@ -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
4
ss.S
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user