且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在运行时中断汇编指令

更新时间:2023-02-08 21:38:16

我不确定8080是否设计用于具有共享RAM的多CPU系统,但这不一定意味着不可能或不存在8080.这样的系统. 8086锁前缀用于此类系统,以确保在执行一系列内存读取,值修改,内存写入(RMW)的过程中,只有一个CPU可以独占访问内存.锁前缀不存在,可以防止一条指令或一些指令被中断处理程序抢占.

I'm not sure the 8080 was designed to be used in multi-CPU systems with shared RAM, which, however doesn't necessarily imply impossibility or nonexistence of such systems. The 8086 lock prefix is for such systems to ensure just one CPU can have exclusive access to memory while executing a sequence of memory read, value modification, memory write (RMW). The lock prefix isn't there to guard an instruction or a few instructions from being preempted by an interrupt handler.

您可以确定个别说明不会在飞行途中被打断.要么让它们运行直到完成,要么恢复它们的任何副作用,然后在稍后的时间重新启动它们.这是大多数CPU上的常见实现.没有它,将很难在出现中断的情况下编写行为良好的代码.

You can be sure that individual instructions don't somehow get interrupted in mid-flight. Either they're let to run until completion or any of their side effects are reverted and they are restarted at a later time. That's a common implementation on most CPUs. Without it it would be hard to write well behaving code in presence of interrupts.

实际上,您不能使用一条8080指令执行64位加法运算,因此该操作可以被ISR抢占.

Indeed, you cannot perform a 64-bit addition with a single 8080 instruction, so, that operation can be preempted by the ISR.

如果您根本不想要这种抢占,则可以通过禁用中断和启用指令(DI和EI)来保护64位添加.

If you don't want that preemption at all, you can guard your 64-bit add with interrupt disable and enable instructions (DI and EI).

如果要让ISR抢占64位,但又不干扰64位添加使用的寄存器,则ISR必须通过以下方式保存和恢复这些寄存器:使用PUSH和POP指令.

If you want to let the ISR preempt the 64-bit but without disturbing the registers that the 64-bit add uses, the ISR must save and restore those registers by e.g. using the PUSH and POP instructions.

找到8080手册以详细描述中断处理(例如,此处).

Find a 8080 manual for detailed description of interrupt handling (e.g. here).