im getting pretty good at using the masm HLL syntax such as the .IF and .ELSE. im tring to learn the low level aspect of it such as jne etc.
.data
      Storage1        db "helpme",0
      Storage2        db "helpme",0
		NotEqual        db "NOT EQUAL",0
      Equal           db "THEY ARE EQUAL",0
........
........
.ELSEIF uMsg==WM_COMMAND
	mov eax,wParam
		.if ax==ButtonID
				cld
				mov ecx,7
             lea esi, Storage1
             lea edi, Storage2
             
             repe cmpsd
             jne @L1
             je  @L2
      @L1:   invoke MessageBox,hWnd,ADDR NotEqual,0,0
            
				
      @L2:   invoke MessageBox,hWnd,ADDR Equal,0,0
the problem im having is that i dont understand why my code processes both L1 and L2 and i only need it to process just one of them depending on if they are equal or not.
Posted on 2001-05-26 19:20:00 by smurf
The problem here is that after processing one, the program just continus on to the next line thereofre processing the second option here this should work cmpsd je @L2 @L1: invoke MessageBox,hWnd,ADDR NotEqual,0,0 jmp skp @L2: invoke MessageBox,hWnd,ADDR Equal,0,0 skp:
Posted on 2001-05-26 19:45:00 by Zadkiel
you dont need to put a je and a jne. just use one and if the condition is not met it doesnt jump and goes on to the next line. this is where you should put the code if the condition is not met obviously. hope that helps. skud.
Posted on 2001-05-27 16:33:00 by skud
The problems here are as follow: - you use old masm HLL syntax (good for 386/486 only) - you don't see what you and your compiler produce in a low level - you don't care about speed optimization of your code Is it so hard to write or copy&paste:


            mov  eax,wParam
            mov  ecx,7
            cmp  ax, ButtonID
            jne  NextCheck

            lea  esi, Storage1
            lea  edi, Storage2
L_Loop1:
            dec  ecx
            jl	 L_Equal             	   		
            mov  al, 
            inc  esi
            mov  ah, 
            inc  edi
            cmp  al, ah			
            je   L_Loop1
            lea  eax, NotEqual
            je   L_Message
L_Equal:             
            lea  eax, Equal
L_Message:   	   	             	   		
            push  0
            push  0
            push  eax
            push  hWnd
            call  MessageBox   	   		
            .....
            ..... 
....
....
Next_Check: 
or better


            mov  eax,wParam            ;u
            mov  ecx,7                 ;v 	
            cmp  ax, ButtonID          ;u 	
            jne  NextCheck             ;v
            mov  eax, offset Equal     ;u
            lea  esi, Storage1         ;v
            mov  ebx, hWnd             ;u
            lea  edi, Storage2         ;v
L_Loop1:
            dec  ecx                   ;u
            jl	 L_Equal              ;v
            mov  al,              ;u
            inc  esi                   ;v   
            mov  ah,              ;u
            inc  edi                   ;v
            cmp  al, ah                ;u 			
            je   L_Loop1               ;v
            lea  eax, NotEqual         ;u 
L_Equal:             
            push  0                    ;v
            push  0                    ;u
            push  eax                  ;v
            push  ebx                  ;u
            call  MessageBox           ;v    	   		
            .....
            ..... 
....
....
Next_Check: 
Is it so hard to learn about u&v pipe in the modern processors? Is it so hard to SEE and trace your code with a debugger? I'm new here and don't want to insult anybody because we are not so much, and I respect everybody who likes assembly, a newbie or a guru, but I hope to see more care about speed optimization and short code challenges which make the assembly programming so attractive...
Posted on 2001-05-27 19:04:00 by buliaNaza
Excuse my mistake in previous posting!!! Thanks The problems here are as follow: - you use old masm HLL syntax (good for 386/486 only) - you don't see what you and your compiler produce in a low level - you don't care about speed optimization of your code Is it so hard to write or copy&paste:


            mov  eax,wParam
            mov  ecx,7
            cmp  ax, ButtonID
            jne  NextCheck

            lea  esi, Storage1
            lea  edi, Storage2
L_Loop1:
            dec  ecx
            jl	 L_Equal             	   		
            mov  dl, 
            inc  esi
            mov  dh, 
            inc  edi
            cmp  dl, dh			
            je   L_Loop1
            lea  eax, NotEqual
            je   L_Message
L_Equal:             
            lea  eax, Equal
L_Message:   	   	             	   		
            push  0
            push  0
            push  eax
            push  hWnd
            call  MessageBox   	   		
            .....
            ..... 
....
....
Next_Check: 
or better


            mov  eax,wParam            ;u
            mov  ecx,7                 ;v 	
            cmp  ax, ButtonID          ;u 	
            jne  NextCheck             ;v
            mov  eax, offset Equal     ;u
            lea  esi, Storage1         ;v
            mov  ebx, hWnd             ;u
            lea  edi, Storage2         ;v
L_Loop1:
            dec  ecx                   ;u
            jl	 L_Equal              ;v
            mov  dl,              ;u
            inc  esi                   ;v   
            mov  dh,              ;u
            inc  edi                   ;v
            cmp  dl, dh                ;u 			
            je   L_Loop1               ;v
            lea  eax, NotEqual         ;u 
L_Equal:             
            push  0                    ;v
            push  0                    ;u
            push  eax                  ;v
            push  ebx                  ;u
            call  MessageBox           ;v    	   		
            .....
            ..... 
....
....
Next_Check: 
Is it so hard to learn about u&v pipe in the modern processors? Is it so hard to SEE and trace your code with a debugger? I'm new here and don't want to insult anybody because we are not so much, and I respect everybody who likes assembly, a newbie or a guru, but I hope to see more care about speed optimization and short code challenges which make the assembly programming so attractive...
Posted on 2001-05-27 19:17:00 by buliaNaza
Easy! http://www.agner.org/ Thanks for replay..
Posted on 2001-05-27 19:35:00 by buliaNaza
Zadkiel thanks for your answer you answered my question. as for everyone else thanks for putting my newbieness status into perspective. :) smurf
Posted on 2001-05-27 20:16:00 by smurf
1: repe cmpsd lea edx,Equal je @F lea edx,NotEqual @@: invoke MessageBox,hWnd,edx,0,0 ... 2: .data MsgOff dd offset Equal dd offset NotEqual .code ... repe cmpsd shr ecx,3 adc ecx,0 invoke MessageBox,hWnd,MsgOff,0,0 2.1: better repe cmpsd shr ecx,3 push 0 adc ecx,0 push 0 mov ecx,MsgOff mov eax,hWnd push ecx push eax call MessageBox ...
Posted on 2001-05-28 10:19:00 by The Svin
Thanks The Svin for the nice short code, but I have a note about repe cmpsd -

  - wrong use in this example ->  MUST be repe cmpsb
    your code will return always "NOT EQUAL" !!!
    because you compare 2 dwords (not 7 bytes) with another 2 dwords.. 
    We have:

      Storage1        db "helpme",0  ; 7 bytes
      Storage2        db "helpme",0  ; 7 bytes 
      ........
      ........
   .ELSEIF uMsg==WM_COMMAND
      ........
      ........
       cld
       MOV ECX,7   ; !!!
  

    translation of repe cmpsd is as follow:

    repe cmps   dword ptr , dword ptr  

    translation of repe cmpsb is as follow:

    repe cmps   byte ptr , byte ptr 


  - repe, cmpsd and cmpsb do not pair 
  - possible memory boundary violation (not in this example) 
  - slower then simple loop 

;...........................
    repe cmpsd             ; not pairing 
    shr  ecx,3             ; u   
    push 0                 ; v
    adc  ecx,0 ; not pairing -> do not pair in U pipe, pair in V pipe only.. 
    push 0                 ; u
    mov  ecx,MsgOff ; v
    mov  eax,hWnd          ; u
    push ecx               ; v
    push eax               ; u
    call MessageBox        ; v

Posted on 2001-05-29 23:22:00 by buliaNaza
You are right Naza. I didn't look closely what 'd been being compared in the original code and just copied it from the first code post and changed control handling principles. I had a little time just to point to some ideas. As to the task if it was to compare 7 bytes or variable not 4 aligned to lenth strings then cmpsd doesn't fit the task at all. But the comparesion itsell, I thought was not the issue, the author problem was handling conditional control blocks. Do you want me to have a look at your version? The Svin.
Posted on 2001-05-30 06:45:00 by The Svin
If 7 bytes only .if ax==ButtonID mov eax,dword ptr Storage1 mov edx,dword ptr Storage2 mov ecx,dword ptr Storage1+3 xor eax,edx mov ebx,dword ptr Storage2+3 mov edx,offset NotEqual jne @F xor ecx,ebx jne @F mov edx,offset Equal @@: invoke MessageBox,hWnd,edx,0,0
Posted on 2001-05-30 07:45:00 by The Svin
Thanks The Svin for replay What about my style U can take a look at: http://lir.50megs.com/BMCSNext.htm
Posted on 2001-05-30 09:13:00 by buliaNaza