Author Topic: cmpal, 02dh  (Read 158 times)

six_L

  • Member
  • **
  • Posts: 117
cmpal, 02dh
« on: January 06, 2018, 07:08:12 PM »
hi,johnsa
UASM64(WIN) convert the "cmp   al, 02dh" into "cmp   al, 2".

jj2007

  • Member
  • *****
  • Posts: 7884
  • Assembler is fun ;-)
    • MasmBasic
Re: cmpal, 02dh
« Reply #1 on: January 06, 2018, 08:28:43 PM »
UASM v2.46, Dec 14 2017 works correctly. Which version are you using, six_L?

six_L

  • Member
  • **
  • Posts: 117
Re: cmpal, 02dh
« Reply #2 on: January 06, 2018, 08:33:03 PM »
UASM v2.46, Dec 14 2017 works correctly. Which version are you using, six_L?
ASM v2.46, Dec 14 2017, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

calc_1.asm: 59 lines, 3 passes, 141 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

jj2007

  • Member
  • *****
  • Posts: 7884
  • Assembler is fun ;-)
    • MasmBasic
Re: cmpal, 02dh
« Reply #3 on: January 06, 2018, 08:35:06 PM »
Same as mine ::)
Code: [Select]
include \masm32\include\masm32rt.inc
.code
start:
  mov al, "-" ; 2d
  cmp al, 02dh
  .if Zero?
inkey "correct"  ; yep
  .else
inkey "wrong"
  .endif
  exit
end start
Can you post a snippet that doesn't work?

six_L

  • Member
  • **
  • Posts: 117
Re: cmpal, 02dh
« Reply #4 on: January 06, 2018, 08:40:13 PM »
atodq proc uses rsi rdi String:QWORD
   ; ----------------------------------------
   ; Convert decimal string into qword value
   ; return value in rax
   ; ----------------------------------------
   
   xor   rax, rax
   mov   rsi, [String]
   xor   rcx, rcx
   xor   rdx, rdx
   mov   al, [rsi]
   inc   rsi
   cmp   al, 02Dh      ;====>here   
   jne   proceed
   mov   al, [rsi]
   not   rdx
   inc   rsi
   jmp   proceed
@@:
   sub   al, 30h
   lea   rcx, qword ptr [rcx+4*rcx]
   lea   rcx, qword ptr [rax+2*rcx]
   mov   al, [rsi]
   inc   rsi
proceed:
   or   al, al
   jne   @B
   lea   rax, qword ptr [rdx+rcx]
   xor   rax, rdx
   ret

atodq endp

jj2007

  • Member
  • *****
  • Posts: 7884
  • Assembler is fun ;-)
    • MasmBasic
Re: cmpal, 02dh
« Reply #5 on: January 06, 2018, 08:57:59 PM »
UAsm64:
Code: [Select]
0000000140001022   | 8A 06                     | mov al,byte ptr ds:[rsi]                |
0000000140001024   | 48 FF C6                  | inc rsi                                 |
0000000140001027   | 3C 2D                     | cmp al,2D                               | 2D:'-'
0000000140001029   | 75 19                     | jne 140001044                           |

Same for UAsm32. Do you use any specific options?

Minor incompatibility: mov rsi, [String] triggers a syntax error with ML64. Instead, the simpler mov rsi, String works with both ML and UAsm.

habran

  • Member
  • *****
  • Posts: 1121
    • uasm
Re: cmpal, 02dh
« Reply #6 on: January 06, 2018, 09:07:29 PM »
same here:
Code: [Select]
   266:    xor   rcx, rcx
00007FF6E2E317EA 48 33 C9             xor         rcx,rcx 
   267:    xor   rdx, rdx
00007FF6E2E317ED 48 33 D2             xor         rdx,rdx 
   268:    mov   al, [rsi]
00007FF6E2E317F0 8A 06                mov         al,byte ptr [rsi] 
   269:    inc   rsi
00007FF6E2E317F2 48 FF C6             inc         rsi 
   270:    cmp   al, 02Dh      ;====>here   
00007FF6E2E317F5 3C 2D                cmp         al,2Dh 
   271:    jne   proceed
00007FF6E2E317F7 75 08                jne         WinMainCRTStartup+1Bh (07FF6E2E31801h) 
   272:    mov   al, [rsi]
00007FF6E2E317F9 8A 06                mov         al,byte ptr [rsi] 
   273:    not   rdx
00007FF6E2E317FB 48 F7 D2             not         rdx 
   274:    inc   rsi
00007FF6E2E317FE 48 FF C6             inc         rsi 
   275: proceed:   
Cod-Father

six_L

  • Member
  • **
  • Posts: 117
Re: cmpal, 02dh
« Reply #7 on: January 06, 2018, 09:25:47 PM »
hi,all
i'v got the error. sorry
Quote
atodq proc uses rsi rdi String:QWORD
   ; ----------------------------------------
   ; Convert decimal string into qword value
   ; return value in rax
   ; ----------------------------------------
   
   xor   rax, rax
   mov   rsi, [String]
   xor   rcx, rcx
   xor   rdx, rdx
   mov   al, [rsi]
   inc   rsi
   ;cmp   al, "-"   
int 3
   cmp   al, 2Dh   
   jne   proceed
   mov   al, [rsi]
   not   rdx
   inc   rsi
   jmp   proceed
@@:
   sub   al, 30h
   lea   rcx, qword ptr [rcx+4*rcx]
   lea   rcx, qword ptr [rax+2*rcx]
   mov   al, [rsi]
   inc   rsi
proceed:
   or   al, al
   jne   @B
   lea   rax, qword ptr [rdx+rcx]
   xor   rax, rdx
   ret

atodq endp

johnsa

  • Member
  • ****
  • Posts: 638
    • Uasm
Re: cmpal, 02dh
« Reply #8 on: January 07, 2018, 11:39:59 PM »
So did you come right in the end ?

six_L

  • Member
  • **
  • Posts: 117
Re: cmpal, 02dh
« Reply #9 on: January 08, 2018, 12:22:50 AM »
So did you come right in the end ?
hi´╝îjohnsa
yes. see the post http://masm32.com/board/index.php?PHPSESSID=cec620e4dd421c2eb1a90d06fc181c77&topic=6803.0#msg73171 .
keep up the great works, because it's the easiest step to transit  from masm32 to UASM64. UASM64 inherited most of the masm32's features.