2017-01-24 29 views
-7

我在一個程序中生成了下面的轉儲,只添加了兩個數字 我無法理解添加兩個數字的邏輯 在給定的代碼第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 
+0

@ user143252您的工作是提供適當格式的問題。如果你不這樣做,你會得到讚譽。 – fuz

+0

它首先將0x1010添加到'ecx',然後用0x2020對'ecx'進行按位與操作。這是你不明白的部分嗎?你究竟在這裏問什麼? –

+0

@CodyGray是的,爲什麼這是必要的? – user143252

回答

1

這兩個線對無論是16位劃或未壓縮十進制數,其中包含每一個十進制數字的檢查「負」標誌幫助字節(bcd - 二進制編碼的十進制)在低位(位0到3)中。符號存儲在最低有效字節的第4至7位中。查看分區或解壓縮的十進制數字的最後一個字節,0x10,0x50,0x90,0xd0的值表示負數。

jne GLB.4之後的代碼正在做一個解壓縮的bcd add,但後來它做了一個字節交換,所以我不確定它在做什麼。

您可以包含兩個數字的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 
+0

是的,我會這樣做,感謝您的幫助 – user143252

+0

我已經添加了信息@rcgldr – user143252

+0

@ user143252 - 我在尋找的是變量VAR1和VAR2的Cobol源代碼,以及顯示添加的源代碼。 – rcgldr