This commit is contained in:
2026-08-30 19:27:08 +02:00
parent d8f7ebeaad
commit 6fb404fe60
2 changed files with 53 additions and 104 deletions

View File

@@ -1,12 +1,13 @@
STACK_TOP = 0xFFFF
; At 500 kHz the CPU has about 500 T-states per millisecond.
; At 1 MHz the CPU has about 1000 T-states per millisecond.
; The inner delay loop below costs about 26 T-states per taken iteration:
; dec hl = 6T
; ld a,h = 4T
; or l = 4T
; jr nz = 12T
; 500 / 26 = 19.2, so 20 iterations is the nearest simple whole-number choice.
DELAY_LOOPS_PER_MS = 20
; 1000 / 26 = 38.5. Use 40 iterations to retain the previous calibration,
; which used 20 iterations at 500 kHz.
DELAY_LOOPS_PER_MS = 40
.globl _main
.globl _delay_ms
@@ -99,7 +100,7 @@ _io_in::
; Approximate millisecond delay.
; Input: HL = delay in milliseconds.
; For CLK_SPEED = 500000 Hz this uses 20 inner iterations per ms.
; For CLK_SPEED = 1000000 Hz this uses 40 inner iterations per ms.
_delay_ms::
ld a, h
or l