Zilog Z80 - 如何使用中断模式 1(IM 1 指令)
我想在 Z80 上使用 IM 1 中断模式。
在中断模式 1 中,处理器跳转到内存中的 38h 地址(我是对的吗?),然后继续中断。我如何在我的代码中指定这一点? 我读过:
defs[,]ds[,]这个伪 指令将字节块插入代码段
我需要一些示例源代码。
亲切的问候
Rafał R.
I want to use IM 1 interrupt mode on Z80.
In Interrupt mode 1 processor jumps to 38h address in memory(am I right?) and then continues interrupt. How can I specify this in my code?
I have read about:
defs [,] ds [,] This pseudo
instruction inserts a block of bytes into the code segment
I need some sample source code.
Kind Regards
Rafał R.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,我面前没有Z80。
参考:Z80asm指令
使用org“手动”在指定地址定位“函数” 。
因此,要编写 IM1 处理程序:
另外,我不确定您的正常起始地址是,但原始 Z80 从位置 0 开始。如果是这种情况,您应该 JMP 越过 0x38 处理程序非常 在代码的早期。 (您只有 56 个字节可以玩)
快乐编码!
First off, I don't have a Z80 in front of me.
Referencing: Z80asm directives
Use org to 'manually' locate a 'function' at a specified address.
So, to write an IM1 handler:
Also, I'm not sure of your normal starting address is, but the original Z80s started at location 0. If this is the case you should JMP past the 0x38 handler very early in your code. (You only have 56 bytes to play with)
Happy Coding!
在 IM 1 中,一旦发现待处理中断(在操作码结束前的最后一个周期的上升沿进行采样;与 NMI 不同,只是对 IRQ 线进行采样),IFF1 和 2 被清除,并且 RST 38h 被执行。所以你最终应该看到 PC 位于 0x38,中断被禁用,旧程序计数器位于堆栈顶部。您需要做任何您必须做的事情来响应中断,然后执行
EI, RET
或EI, RETI
(这里没有区别,因为这两个IFF 标志在中断应答后具有相同的值)。在 Z80 上,PC 在加电或重置时设置为 0,因此您可能已经对内存末端的代码进行了一些控制。确切的语法取决于您的汇编器,但您可能想要类似的东西:
In IM 1, upon spotting a pending interrupt (which is sampled on the rising edge of the last cycle before the end of an opcode; the IRQ line is just sampled, unlike NMI) IFF1 and 2 are cleared and an
RST 38h
is executed. So you should end up with the PC at 0x38, interrupts disabled and the old program counter on the top of the stack. You'll want to do whatever you have to do to respond to the interrupt, then perform anEI, RET
orEI, RETI
(there being no difference here because the two IFF flags have the same value following the interrupt acknowledge).On a Z80 the PC is set to 0 upon power up or reset so probably you already have some control over the code down at that end of memory. Exact syntax depends on your assembler, but you probably want something like:
我已经弄清楚当你不从 0h 开始时该怎么做:
只要你这样做,处理器就会把 JP 01838h 指令放在地址 038h 处。
所以,处理者是对的。另外,请记住初始化堆栈指针。如果不这样做,您将无法从中断处理程序返回到程序。
I have figured out what to do when you are not starting from 0h:
As far as you make it like this, processor will put the JP 01838h instruction at the address 038h.
So the handler is right. Also, remember to initialize stack pointer. If you doesnt, you will not be able to return from interrupt handler to program.