【发布时间】:2018-08-27 03:34:10
【问题描述】:
我正在尝试设置中断以捕捉按下 ON 按钮。
这是我目前的代码:
SetInterrupt:
di
; copy the 4 bytes from InterruptVectorTable to cursorImage
; (I chose cursorImage because it's on a 512-byte boundary, 0E30800h)
ld hl, InterruptVectorTable
ld de, cursorImage
ld bc, 4
ldir
; clone the same 4 bytes into the rest of the 256-byte interrupt vector table
ld hl, cursorImage
ld de, cursorImage + 4
ld bc, 252
ldir
; load the address of the new interrupt vector in the i register
; and set interrupt mode to 2
ld hl, cursorImage >> 8 & 0ffffh
ld i, hl
im 2
ei
ret
FillScreen:
; fills the screen with black pixels
ld a, 0
ld hl, vRam
ld bc, 320*240*2
call _MemSet
ret
InterruptVectorTable:
; try to call FillScreen whenever there's an interrupt
.db 00, FillScreen & 0ffh, FillScreen >> 8 & 0ffh, FillScreen >> 16 & 0ffh
但是,这只会冻结我的计算器(因为我无法使用任何键来停止程序)。
我相信问题出在 InterruptVectorTable 中。我真的不明白应该如何格式化表格。我在下面链接到的 ez80 应用说明说“每个向量是一个指向 __vectptr 段的 4 字节地址”,但 ez80 使用 24 位地址,所以我不确定如何构造每个向量。
非常感谢任何帮助。
我已阅读/尝试阅读的参考文献:
【问题讨论】:
-
你可以使用调试器或模拟器吗?这通常对 asm 非常有帮助。
-
@PeterCordes 出于这个原因我尝试使用 CEmu,但是当我尝试设置中断时,程序就让计算器崩溃了。
-
@PeterCordes 它冻结了我的设备,因为所有按键输入都使用中断。但是,在 CEmu 上,它会导致 RAM 重置。
-
@Zeda 我做了一些研究(查看了一堆似乎禁用 ON 键的 asm 程序),似乎诀窍是继续调用 _GetCSC (根本没有中断)。我也可以通过检查是否有 ON 中断等待然后重置标志来捕捉 ON 按键。这将适合我的目的,我会尽量记住明天写一个答案。再次感谢!
-
哦,你是想在汇编程序中阻止它吗?那这绝对是可行的。请记住
res onInterrupt,(iy+onFlags)以防止用户收到 Err: Break on exit。
标签: assembly interrupt interrupt-handling texas-instruments z80