1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 01:28:06 +11:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Virgil Dupras
8926c33ab1 Fix tools/tests/zasm/runtests.sh shebang
It needs bash after all. On OpenBSD, /usr/sh works, but not on Ubuntu.
2019-10-10 15:22:21 -04:00
Keith Stellyes
4180b5873d Fix for tools/zasm.sh being dependent on readlink -f (an issue on macOS, preventing builds) (#28)
* Fix for tools/zasm.sh being dependent on readlink -f (an issue on macOS, preventing builds)

* Wrap zasm.sh shebang in /usr/bin/env ; remove comment about BSDs
2019-10-10 15:21:37 -04:00
Clanmaster21
6281e2036f Optimised intoXX functions (#19)
* Optimised intoXX functions

Rewrote intoXX functions to mainly rely on intoHL, as the HL instructions are smaller and faster. Also removed some redundant push and pop instructions. I edited the given unit tests to test these, and they seem to work as expected.

* Doesn't use self-modifying code

The number of bytes is the same as my previous attempt, with 11 more cycles in intoHL, so although I don't feel as clever this time it's still a good optimisation. I found an equivalent method for intoDE, however relying on intoHL still allows for  `ex (sp), hl` to be used in intoIX, which is smaller and faster.

* Update core.asm

* Tried harder to follow coding convention

Added tabs between mnemonics and operands, and replaced a new line I accidentally removed.
2019-10-10 14:44:23 -04:00
3 changed files with 25 additions and 26 deletions

View File

@ -27,34 +27,29 @@ addDE:
noop: ; piggy backing on the first "ret" we have
ret
; copy (DE) into DE, little endian style (addresses in z80 are always have
; their LSB before their MSB)
intoDE:
push af
ld a, (de)
inc de
ex af, af'
ld a, (de)
ld d, a
ex af, af'
ld e, a
pop af
; copy (HL) into DE, then exchange the two, utilising the optimised HL instructions.
; ld must be done little endian, so least significant byte first.
intoHL:
push de
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl
pop de
ret
intoHL:
push de
ex de, hl
call intoDE
ex de, hl
pop de
intoDE:
ex de, hl
call intoHL
ex de, hl ; de preserved by intoHL, so no push/pop needed
ret
intoIX:
push de
push ix \ pop de
call intoDE
push de \ pop ix
pop de
push ix
ex (sp), hl ;swap hl with ix, on the stack
call intoHL
ex (sp), hl ;restore hl from stack
pop ix
ret
; add the value of A into HL

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
set -e

View File

@ -1,7 +1,11 @@
#!/bin/sh
#!/usr/bin/env bash
# readlink -f doesn't work with macOS's implementation
# so, if we can't get readlink -f to work, try python with a realpath implementation
ABS_PATH=$(readlink -f "$0" || python -c "import sys, os; print(os.path.realpath('$0'))")
# wrapper around ./emul/zasm/zasm that prepares includes CFS prior to call
DIR=$(dirname $(readlink -f "$0"))
DIR=$(dirname "${ABS_PATH}")
ZASMBIN="${DIR}/emul/zasm/zasm"
CFSPACK="${DIR}/cfspack/cfspack"
INCCFS=$(mktemp)