From aaaea79a6f9770271d6624b932c9b871fb8fa15c Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Tue, 20 Oct 2015 21:04:49 +0200 Subject: [PATCH] Refactor print_hex --- common.h | 9 +++++---- cs.S | 4 ++-- in_keyboard.S | 2 +- in_rtc.S | 12 ++++++------ initial_state.S | 2 +- ss.S | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common.h b/common.h index b4bce8b..9e1af43 100644 --- a/common.h +++ b/common.h @@ -201,11 +201,12 @@ reg: 1 byte register. Clobbers: ax, dl */ -#define PRINT_HEX(reg) \ - HEX();\ - mov %ah, %dl;\ - PUTC(%al);\ +.macro PRINT_HEX reg + HEX(<\reg>) + mov %ah, %dl + PUTC(%al) PUTC(%dl) +.endm #define PRINT_NEWLINE \ PUTC($0x0A);\ diff --git a/cs.S b/cs.S index 06312cc..83cdac6 100644 --- a/cs.S +++ b/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 diff --git a/in_keyboard.S b/in_keyboard.S index 40038d1..ebb8aa1 100644 --- a/in_keyboard.S +++ b/in_keyboard.S @@ -30,6 +30,6 @@ loop: cmp %al, %cl jz loop mov %al, %cl - PRINT_HEX(%al) + PRINT_HEX <%al> PRINT_NEWLINE jmp loop diff --git a/in_rtc.S b/in_rtc.S index 46250cf..250818d 100644 --- a/in_rtc.S +++ b/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 diff --git a/initial_state.S b/initial_state.S index b77ad16..69c916f 100644 --- a/initial_state.S +++ b/initial_state.S @@ -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 ;\ PRINT_NEWLINE INITIAL_STORE(ax) diff --git a/ss.S b/ss.S index 5af0188..e86d0df 100644 --- a/ss.S +++ b/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