z80: make the outfoo routines preserve everything
authorAlan Cox <alan@linux.intel.com>
Fri, 30 Jan 2015 17:51:55 +0000 (17:51 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 30 Jan 2015 17:51:55 +0000 (17:51 +0000)
They are mostly used for debug, so having them eat AF is just too good a way to
have them muck up the debug work.

Kernel/lowlevel-z80.s
Kernel/platform-socz80/socz80.s

index 85bf1a7..c923d5e 100644 (file)
@@ -483,30 +483,37 @@ outnewline:
         call outchar
         ret
 
-outhl:  ; prints HL in hex. Destroys AF.
+outhl:  ; prints HL in hex.
+       push af
         ld a, h
         call outcharhex
         ld a, l
         call outcharhex
+       pop af
         ret
 
-outbc:  ; prints BC in hex. Destroys AF.
+outbc:  ; prints BC in hex.
+       push af
         ld a, b
         call outcharhex
         ld a, c
         call outcharhex
+       pop af
         ret
 
-outde:  ; prints DE in hex. Destroys AF.
+outde:  ; prints DE in hex.
+       push af
         ld a, d
         call outcharhex
         ld a, e
         call outcharhex
+       pop af
         ret
 
 ; print the byte in A as a two-character hex value
 outcharhex:
         push bc
+       push af
         ld c, a  ; copy value
         ; print the top nibble
         rra
@@ -517,6 +524,7 @@ outcharhex:
         ; print the bottom nibble
         ld a, c
         call outnibble
+       pop af
         pop bc
         ret
 
@@ -527,8 +535,7 @@ outnibble:
         jr c, numeral ; less than 10?
         add a, #0x07 ; start at 'A' (10+7+0x30=0x41='A')
 numeral:add a, #0x30 ; start at '0' (0x30='0')
-        call outchar
-        ret
+        jp outchar
 
 ;
 ;      Pull in the CPU specific workarounds
index 825b0d9..16bbd15 100644 (file)
@@ -559,9 +559,9 @@ saved_map:  .db 0, 0, 0, 0
 map_current: .db 0, 0, 0, 0
 
 ; outchar: Wait for UART TX idle, then print the char in A
-; destroys: AF
 outchar:
             push bc
+           push af
             ld b, a
             ; wait for transmitter to be idle
 ocloop:     in a, (UART0_STATUS)
@@ -570,5 +570,6 @@ ocloop:     in a, (UART0_STATUS)
             ; now output the char to serial port
             ld a, b
             out (UART0_DATA), a
+           pop af
             pop bc
             ret