首先,如果你要移动SP,你需要保存并恢复它。其次,您需要禁用中断,否则您将遇到竞争条件错误:如果在副本末尾附近触发中断,堆栈将向下增长到其下方的任何内容,这恰好是增值税。
; Index registers are actually fast on the eZ80
ld ix, 0
add ix, sp
di
; Do some hack using SP here
ld sp, ix
ei
@Ped7g The eZ80 will cache any -IR/-DR suffix instruction; unlike the Z80, it doesn't reread the opcode from memory on each iteration. Consequently, instructions like LDIR can execute each iteration in just 2 bus cycles, one read and one write. The SP hack is therefore not only needlessly complicated, but actually slower. The SP hack still best left to more experienced programmers.
eZ80 的流水线性能非常好,但由于缺乏缓存和 1 字节宽总线,其性能受到限制。唯一运行速度比总线慢的指令是 MLT,这是一条需要 5 个时钟周期的 2 个总线周期指令。对于其他每条指令,只需计算操作码中的字节数以及读写周期数,就可以得到其执行时间。非常遗憾的是,在 TI-84+CE 系列中,TI 决定将快速的 eZ80 与不知何故需要的 SRAM 配对four每次读写的时钟周期(48 MHz)!是的,半导体设计领域的世界领导者 TO 成功设计了一款slow静态随机存储器。让片上 SRAM 执行poorly是一项工程壮举。
@harold 有正确的答案,尽管我更喜欢优化大小而不是内部循环之外的速度。
#include "includes\ti84pce.inc"
.assume ADL=1
.org userMem-2
.db tExtTok,tAsm84CeCmp
call _homeup
call _ClrScrnFull
; Initialize registers
ld hl, vRam
ld bc, lcdWidth * lcdHeight * 2 - 2
push hl
pop de
; Write initial 2-byte value
ld (hl), 31
inc hl
ld (hl), 0
inc hl
ex de, hl
; Copy everything all at once. Interrupts may trigger while this instruction is processing.
ldir
call _GetKey
call _ClrScrnFull
ret
在 EFnet 上,#ez80-dev 是提问的好地方。水泥技术网 https://www.cemetech.net/forum/viewforum.php?f=16也是一个好地方。