【问题标题】:Assembly program of adding two number [closed]两个数相加的汇编程序[关闭]
【发布时间】:2017-06-09 02:20:51
【问题描述】:

我从一个只添加两个数字的程序生成了下面的转储 我无法理解添加两个数字的逻辑 在给定的代码第 6 行和第 7 行中,根据我的理解是没有意义的,请帮助解决两行

add ecx,00001010  6th line 

and ecx,00002020 7th line

 

       movzx   ecx,%GWA+000000E0 : VAR1
       movzx   eax,%GWA+000000E8 : VAR2
       sal     ecx,08
       or      ecx,eax
       mov     eax,ecx
       add     ecx,00001010
       and     ecx,00002020
       jne     GLB.4
       movzx   ecx,%GWA+000000E0 : VAR1
       movzx   eax,%GWA+000000E8 : VAR2
       and     ecx,0F0F0F0F
       and     eax,0F0F0F0F
       add     ecx,eax
       add     ecx,F6F6F6F6
       mov     eax,ecx
       and     eax,60606060
       shr     eax,04
       and     ecx,0F0F0F0F
       sub     ecx,eax
       or      ecx,30303030
       add     ecx,10
       bswap   ecx
       shr     ecx,10
       mov     %GWA+0000000A,cx : TRLP+0
       jmp     GLB.5

【问题讨论】:

  • @user143252 提供格式正确的问题是您的工作。如果你不这样做,你就会被否决。
  • 它首先将 0x1010 添加到 ecx,然后将 ecx 与 0x2020 进行按位与运算。那是你不明白的部分吗?你到底在这里问什么?
  • @CodyGray 是的,为什么需要这个?

标签: assembly x86


【解决方案1】:

这两行正在检查 16 位分区或未压缩十进制数中的任何一个上的“负”号,这些数字在低位(位 0 到 3)中每个字节包含一个十进制数字(bcd - 二进制编码的十进制) )。符号存储在最低有效字节的第 4 位到第 7 位中。查看分区或未打包十进制数的最后一个字节,值 0x10、0x50、0x90、0xd0 表示负数。

jne GLB.4 之后的代码是在做一个解压的 bcd 加法,然后它做了一个字节交换,所以我不确定它对总和做了什么。

能否包括两个数字的 Cobol 数据除法和加法的过程除法?

;       using desktop calculator in hex mode
;               ecx = 002030405h      ;decimal 2345
;               eax = 002070809h      ;decimal 2789
        add     ecx,eax               ;ecx = 0040A0C0Eh
        add     ecx,0F6F6F6F6h        ;ecx = 0FB010304h  ;F6 does carries
        mov     eax,ecx               ;eax = 0FB010304h
        and     eax,060606060h        ;eax = 060000000h  ;eax = value to subtract
        shr     eax,004               ;eax = 006000000h  ; for the non carries
        and     ecx,00F0F0F0Fh        ;ecx = 00B010304h  ;clear any 'F's
        sub     ecx,eax               ;ecx = 005010304h  ;fix the non carries
                                      ;ecx = decimal 5134

【讨论】:

  • 是的,我会的,谢谢你的帮助
  • 我已添加信息@rcgldr
  • @user143252 - 我正在寻找的是变量 VAR1 和 VAR2 的 Cobol 源代码,以及显示添加的源代码。
  • @user143252 - 解压添加的代码已经存在,第一行代码在 00000200,最后一行在 00000223。
  • @user143252 - 您可以使用十六进制模式的桌面计算器来遵循逻辑。添加 F6F6F6F6 会在生成进位的字节中产生正确的结果(字节总和 >= 10)。其余代码是处理未生成进位的字节。我用一个例子更新了我的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-26
  • 2011-01-29
  • 1970-01-01
  • 2010-10-29
  • 1970-01-01
相关资源
最近更新 更多