From 6a669fac4f5b190aa0c695ce3a80b8436ab6123d Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 20 Feb 2019 22:32:09 +0000 Subject: [PATCH] z80: add out16 for out's to a 16bit port, and in16 likewise We need these for some of the systems that do I/O decoding on the cheap (like the ZX spectrum). Not yet tested. --- Kernel/cpu-z80/cpu.h | 5 +++++ Kernel/lowlevel-z80-banked.s | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Kernel/cpu-z80/cpu.h b/Kernel/cpu-z80/cpu.h index add210b1..29357547 100644 --- a/Kernel/cpu-z80/cpu.h +++ b/Kernel/cpu-z80/cpu.h @@ -25,6 +25,11 @@ typedef uint16_t irqflags_t; extern void out(uint8_t addr, uint8_t val); extern uint8_t in(uint8_t addr) __z88dk_fastcall; +/* This is an 8bit value to 16bit port - its defined as dual uint16_t to get + better code out of SDCC */ +extern void out16(uint16_t addr, uint16_t val); +extern uint8_t in16(uint16_t addr) __z88dk_fastcall; + /* Z80 binaries start with a JP */ #define EMAGIC 0xc3 /* Header of executable */ #define EMAGIC_2 0x18 /* JR */ diff --git a/Kernel/lowlevel-z80-banked.s b/Kernel/lowlevel-z80-banked.s index bec1ae67..1bd15771 100644 --- a/Kernel/lowlevel-z80-banked.s +++ b/Kernel/lowlevel-z80-banked.s @@ -48,6 +48,8 @@ .globl ___hard_irqrestore .globl _in .globl _out + .globl _in16 + .globl _out16 ; imported symbols .globl _chksigs @@ -676,6 +678,20 @@ _out: push de jp (hl) +_out16: + pop hl ; return + pop iy ; bank + pop bc ; port + pop de ; data + push de + push bc + push hl + push iy + out (c),e + jp (hl) + +_in16: + ld b,h _in: ld c,l in l, (c) -- 2.34.1