汇编语言-标志设置让我头疼 [英] Assembly language - Flag setting giving me headaches

查看:86
本文介绍了汇编语言-标志设置让我头疼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定在执行以下操作后应将各种标志设置为(进位,符号,零,溢出):

I'm trying to determine what various flags should be set to (carry, sign, zero, overflow) after the following operation:

mov ax, 7ff0h;       ax register is now 7ff0h

add al, 10h;         

我对程序集如何处理感到困惑.由于我们仅添加了包含 f0h 的寄存器的al部分,因此 f0h + 10h 给出了 100h .这会设置溢出标志吗?进位标志?两者都不?我认为会设置溢出标志,但是,我想到的另一种可能性是程序检测到此情况并自动将ah寄存器从 7fh 更改为 80h ,从而完整的 ax 寄存器 8000h .从理论上讲,这不会设置进位标志,而是设置符号标志和溢出标志,因为我们的总数 8000h 现在为负.谁能解释这是怎么处理的?

I'm confused as to how assembly handles this. since we are adding to just the al portion of the register which contains f0h, f0h + 10h gives 100h. Does this set the overflow flag? The carry flag? Neither? I would think the overflow flag would be set, however, another possibility running through my mind is that the program detects this and automatically alters the ah register from 7fh to 80h, making the full ax register 8000h. This would in theory not set the carry flag, but would instead set the sign flag and overflow flag because our overall number 8000h is now negative. could anyone explain how this is handled?

谢谢.

推荐答案

我在使用debug命令(x86 Windows附带)方面有点过:

I have played a bit with the debug command (shipped with x86 Windows):

-a 100
1A2F:0100 mov ax, 7ff0
1A2F:0103 add al, 10
1A2F:0105
-t =100 2

AX=7FF0  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1A2F  ES=1A2F  SS=1A2F  CS=1A2F  IP=0103   NV UP EI PL NZ NA PO NC
1A2F:0103 0410          ADD     AL,10

AX=7F00  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1A2F  ES=1A2F  SS=1A2F  CS=1A2F  IP=0105   NV UP EI PL ZR NA PE CY
1A2F:0105 0000          ADD     [BX+SI],AL                         DS:0000=CD
-

NV [无溢出]PL(正)CY [Carry]

NV [No Overflow] PL (positive) CY [Carry]

这篇关于汇编语言-标志设置让我头疼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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