本文介绍了加16位寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码

addInt:
        add cx, bx
        cmp cx, 0FFFFh
        JBE convert

我正在尝试添加cx和bx寄存器,每个寄存器具有相同的值 FFFF ,而不是得到 1FFFE ,我只得到 FFFE ,并且当我尝试使用 JBE 跳转到转换循环时,JBE istruction不会执行任何操作,因为 ecx 注册现在包含仅 FFFE ,而不是 1FFF ,因此如何解决此代码以使 ecx 包含1FFFE,如何比较它是否仍然是16位。我不能使用使事情变得更复杂的任何32位寄存器

I'm trying to add cx and bx registers, each have the same value of FFFF, instead of getting 1FFFE, I get only FFFE, and when I try to use JBE to jump to convert loop, JBE istruction does nothing because ecx register now contain only FFFE, but not 1FFF, so how can i fix this code to make ecx contain 1FFFE and how do I compare to check if it is still 16 bits or not. I cannot use any 32 bits registers which make thing more complicated

预先感谢

推荐答案

addInt:

    clc            ;clear carry flag

    add cx,bx

    jnc convert    ;jump no carry

    cmp cx,FFFEh   ;This now needs to be true, only FFFF+FFFF will succeed

                    because it generates a carry AND matches the cmp

    Jnz convert    ;will let it through

这会起作用,但是非常有限和简单化

This will work, but it's very limited and simplistic

要计数进位,请在ajnc转换后插入adc dx,0

To "count" the carry use adc dx,0 inserted after jnc convert

进位标志如果一个寄存器全天候工作,则会置位,因此它的作用就像一个位

The carry flag is set if a register goes round the clock, so it acts like a single bit

ADD FFFF + 2会将其关闭,给您一个+ ve进位标志和0001在寄存器中

ADD FFFF+2 will set it off, giving you a +ve carry flag and 0001 in the register

您可以将该标志计数存储在带有ADC的单独寄存器中[other register],0

You can store that flag count in a separate register with adc [other register],0

使用汽车ry标志可让您将寄存器拍在一起以计数

using the carry flag allows you slap your registers together to count up to something like

1,208,741,363,432,547,555,475,424,4x16位寄存器

1,208,741,363,432,547,555,475,424 with 4x16 bit registers

其中比65,534好很多,英里也好

which is quite a lot and miles better than 65,534

这篇关于加16位寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 23:51