From 3aec06a088e42829cb46a3e47ff2d51ef2e8af6c Mon Sep 17 00:00:00 2001 From: ceriel Date: Wed, 28 Jun 1989 12:40:22 +0000 Subject: [PATCH] Added ret.s --- mach/z80/libem/LIST | 1 + mach/z80/libem/ret.s | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 mach/z80/libem/ret.s diff --git a/mach/z80/libem/LIST b/mach/z80/libem/LIST index b61d8d8f4..cc081f7a4 100644 --- a/mach/z80/libem/LIST +++ b/mach/z80/libem/LIST @@ -40,3 +40,4 @@ xor.s nop.s outdec.s pstrng.s +ret.s diff --git a/mach/z80/libem/ret.s b/mach/z80/libem/ret.s new file mode 100644 index 000000000..bbc145b42 --- /dev/null +++ b/mach/z80/libem/ret.s @@ -0,0 +1,57 @@ +.define .ret +.define .lfr + +.sect .text +.sect .rom +.sect .data +.sect .bss + +! 'ret' and 'lfr' for sizes > 4 (and <= 8) + +retarea: .space 8 + +.sect .text + +.ret: +! parameters: +! de: size in bytes +! stack: return value + + pop ix ! save return address + ld hl,retarea + srl d + rr e ! divide size by 2 +1: + pop bc + ld (hl), c + inc hl + ld (hl), b + inc hl + dec de + ld a,d + or e + jr nz,1b ! done? + jp (ix) ! yes, return + +.lfr: +! parameters: +! de: size in bytes +! result on stack: return value + + pop ix ! save return address + ld hl,retarea + add hl,de + srl d + rr e ! divide size by 2 +1: + dec hl + ld b,(hl) + dec hl + ld c,(hl) + push bc + dec de + ld a,d + or e + jr nz,1b ! done? + jp (ix) ! yes, return +