在运行时中断汇编指令 [英] Interrupting an assembly instruction while it is operating

查看:178
本文介绍了在运行时中断汇编指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当发生CPU中断时,如果已确认,则通过保存当前地址位置来处理该中断,然后再跳入处理程序.否则它将被忽略.

When an interrupt comes to CPU, it is handled by saving current address location prior jumping into the handler if it is acknowledged. Otherwise it is ignored.

我想知道汇编指令调用是否被中断.

I wonder whether an assembly instruction call is interrupted.

例如,

mvi a, 03h ; put 3 value into acc. in 8080 assembly

单行指令可以中断吗?或者,如果不是,那是原子的??

Can be the one line instruction interrupted? Or if not, it is atomic??

是否总是保证一行汇编指令"始终是原子的?

Is there always a guarantee that "one line assembly instruction" is always atomic??

如果没有"lock"关键字(即在8080汇编中),那么如何提供原子性呢?

What if there is no "lock" keyword i.e. in 8080 assembly, then how is the atomicity provided?

例如,如果要对64位求和进行操作,但是无法用一行指令"执行该操作,并且对求和进行操作时会出现中断.如何在组装级别上防止这种情况?

For example, what if 64 bit sum is wanted to be operated, but there is no way to do it with "one line instruction" and an interrupt comes while operating on sum. How can it be prevented at assembly level??

这个概念对我来说很简单.

The concept is being started to boil down for me.

推荐答案

我不确定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).

这篇关于在运行时中断汇编指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆