From f648c6fdbfc1dba55cfc55728724233716c63dd0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 30 Nov 2014 15:08:04 +0000 Subject: [PATCH] z80: add different includes for CMOS/NMOS Z80 --- Kernel/lowlevel-z80-cmos.s | 20 ++++++++++++++++++++ Kernel/lowlevel-z80-nmos.s | 26 ++++++++++++++++++++++++++ Kernel/lowlevel-z80.s | 32 +++++++++----------------------- 3 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 Kernel/lowlevel-z80-cmos.s create mode 100644 Kernel/lowlevel-z80-nmos.s diff --git a/Kernel/lowlevel-z80-cmos.s b/Kernel/lowlevel-z80-cmos.s new file mode 100644 index 00000000..4e392041 --- /dev/null +++ b/Kernel/lowlevel-z80-cmos.s @@ -0,0 +1,20 @@ + .area _COMMONMEM + + ; IRQ helpers, in common as they may get used by common C + ; code (and are tiny) + +_di: ld a, i + push af + pop hl + di + ret + +_irqrestore: pop hl ; sdcc needs to get register arg passing + pop af ; so badly + jp po, was_di + ei + jr irqres_out +was_di: di +irqres_out: push af + jp (hl) + diff --git a/Kernel/lowlevel-z80-nmos.s b/Kernel/lowlevel-z80-nmos.s new file mode 100644 index 00000000..715a7a5f --- /dev/null +++ b/Kernel/lowlevel-z80-nmos.s @@ -0,0 +1,26 @@ + .area _COMMONMEM + +_di: xor a ; NMOS Z80 bug work around as per CPU manual + push af + pop af ; clear byte on stack below our usage + ld a, i + jp pe, was_ei ; P is now IFF2, if irqs on return is safe + dec sp ; the CPU may have lied due to an erratum + dec sp + pop af ; see if anyone pushed a return address + and a + jr nz, was_ei ; someone did - IRQs were enabled then + scf ; disabled +was_ei: push af + pop hl + ret + +_irqrestore: pop hl + pop af + jr c, was_di + ei + jr irqres_out +was_di: di +irqres_out: push af + jp (hl) + diff --git a/Kernel/lowlevel-z80.s b/Kernel/lowlevel-z80.s index b90593a9..2893fe0f 100644 --- a/Kernel/lowlevel-z80.s +++ b/Kernel/lowlevel-z80.s @@ -430,29 +430,6 @@ nmi_handler: .area _COMMONMEM -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - ; IRQ helpers, in common as they may get used by common C - ; code (and are tiny) - -_di: ld a, i - push af - pop hl - di - ret - -_irqrestore: pop hl ; sdcc needs to get register arg passing - pop af ; so badly - jp po, was_di - ei - jr irqres_out -was_di: di -irqres_out: push af - jp (hl) - - - ; outstring: Print the string at (HL) until 0 byte is found ; destroys: AF HL @@ -530,3 +507,12 @@ numeral:add a, #0x30 ; start at '0' (0x30='0') call outchar ret +; +; Pull in the CPU specific workarounds +; + + .if NMOS_Z80 + .include "lowlevel-z80-nmos.s" + .else + .include "lowlevel-z80-cmos.s" + .endif -- 2.34.1