From 7072b70c3dc2aaf94128da1592b09eaf51854926 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 30 Jan 2015 17:51:55 +0000 Subject: [PATCH] z80: make the outfoo routines preserve everything 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 | 17 ++++++++++++----- Kernel/platform-socz80/socz80.s | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Kernel/lowlevel-z80.s b/Kernel/lowlevel-z80.s index 85bf1a77..c923d5eb 100644 --- a/Kernel/lowlevel-z80.s +++ b/Kernel/lowlevel-z80.s @@ -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 diff --git a/Kernel/platform-socz80/socz80.s b/Kernel/platform-socz80/socz80.s index 825b0d90..16bbd158 100644 --- a/Kernel/platform-socz80/socz80.s +++ b/Kernel/platform-socz80/socz80.s @@ -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 -- 2.34.1