News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

HJWASM 2.17 bugs

Started by powershadow, December 29, 2016, 03:53:22 AM

Previous topic - Next topic

habran

I agree with you JJ, test is better then cmp, 1 byte less.
I'll look if I can make it work for hll.
About purists : it can be translated to extremist, remind me on Nazis  :badgrin:
Cod-Father

habran

Quote
    15:         inc edx
00af1019 42                                  inc         edx 
    16:         add ecx, 1
00af101a 83 C1 01                         add         ecx, 0x1
Cod-Father

habran

I have succeeded to change to JS and JNS if we have >= 0 or <=0, here is GE:

    14:     .while     (edx ==0 || edx ==1)&&(SDWORD ptr ecx >=0)
00b91017 EB 02                            jmp 0xb9101b 
    15:         inc edx
00b91019 42                               inc edx 
    16:         dec ecx
00b9101a 49                               dec ecx 
    17:     .endw
00b9101b 85 D2                            test edx, edx 
00b9101d 74 05                            jz 0xb91024 
00b9101f 83 FA 01                         cmp edx, 0x1 
00b91022 75 04                            jnz 0xb91028 
00b91024 85 C9                            test ecx, ecx 
00b91026 79 F1                            jns 0xb91019 
    18:     .if edx == 3
00b91028 83 FA 03                         cmp edx, 0x3 
00b9102b 75 0F                            jnz 0xb9103c 

and here is LE:
    14:     .while     (edx ==0 || edx ==1)&&(SDWORD ptr ecx <=0)
00cc1017 EB 02                            jmp 0xcc101b 
    15:         inc edx
00cc1019 42                               inc edx 
    16:         dec ecx
00cc101a 49                               dec ecx 
    17:     .endw
00cc101b 85 D2                            test edx, edx 
00cc101d 74 05                            jz 0xcc1024 
00cc101f 83 FA 01                         cmp edx, 0x1 
00cc1022 75 04                            jnz 0xcc1028 
00cc1024 85 C9                            test ecx, ecx 
00cc1026 78 F1                            js 0xcc1019 
    18:     .if edx == 3
00cc1028 83 FA 03                         cmp edx, 0x3 
00cc102b 75 0F                            jnz 0xcc103c

Cod-Father

habran

Hi nidud,
Give me one example where ')&&' doesn't work properly
Cod-Father

nidud

#19
deleted

habran

I think you are not concentrated enough to realise that first example is doing correct job.
In second example '!' is taken only for the first register and not for the second. If you write  .while (!eax || !edx) && ecx
it does a proper job:

    18: .while (!eax || !edx) && ecx
0010102e EB 01                            jmp 0x101031 
    19: nop
00101030 90                               nop 
    20: .endw
00101031 85 C0                            test eax, eax 
    20: .endw
00101033 74 04                            jz 0x101039 
00101035 85 D2                            test edx, edx 
00101037 75 04                            jnz 0x10103d 
00101039 85 C9                            test ecx, ecx 
0010103b 75 F3                            jnz 0x101030 
    21:
    21:
Cod-Father

habran

here is the first example:

    12: .while (eax || edx) && ecx
00101010 EB 01                            jmp 0x101013 
    13: nop
00101012 90                               nop 
    14: .endw
00101013 85 C0                            test eax, eax 
00101015 75 04                            jnz 0x10101b 
00101017 85 D2                            test edx, edx 
00101019 74 04                            jz 0x10101f 
0010101b 85 C9                            test ecx, ecx 
0010101d 75 F3                            jnz 0x101012 
0010101f EB 01
Cod-Father

nidud

#22
deleted

nidud

#23
deleted

habran

It looks like .while !(eax || edx) && ecx is icorect encoding because ml.exe creates the wrong code as well

Here is what ml.exe does:

?_004:  jmp     ?_006                                   ; 0040101F _ EB, 01

?_005:  nop                                             ; 00401021 _ 90
?_006:  or      eax, eax                                ; 00401022 _ 0B. C0
        jnz     ?_007                                   ; 00401024 _ 75, 08
        or      edx, edx                                ; 00401026 _ 0B. D2
        jnz     ?_007                                   ; 00401028 _ 75, 04
        or      ecx, ecx                                ; 0040102A _ 0B. C9
        jnz     ?_005                                   ; 0040102C _ 75, F3
?_007: 

It should be .while (!eax || !edx) && ecx
This produces a proper code:

?_007:  jmp     ?_009                                   ; 0040102E _ EB, 01

?_008:  nop                                             ; 00401030 _ 90
?_009:  or      eax, eax                                ; 00401031 _ 0B. C0
        jz      ?_010                                   ; 00401033 _ 74, 04
        or      edx, edx                                ; 00401035 _ 0B. D2
        jnz     ?_011                                   ; 00401037 _ 75, 04
?_010:  or      ecx, ecx                                ; 00401039 _ 0B. C9
        jnz     ?_008                                   ; 0040103B _ 75, F3
?_011:  or      eax, eax                                ; 0040103D _ 0B. C0


If you check code few posts above you'll see that hjwasm produces the same output

Cod-Father

nidud

#25
deleted

nidud

#26
deleted

habran

The second one is incorrect! Your algorithm is correct but .while !(eax || edx) && ecx is not. It should produce this:

009d102e EB 01                            jmp 0x9d1031 
009d1030 90                               nop 
009d1031 85 C0                            test eax, eax 
009d1033 74 04                            jz 0x9d1039 
009d1035 85 D2                            test edx, edx 
009d1037 75 04                            jnz 0x9d103d 
009d1039 85 C9                            test ecx, ecx 
009d103b 75 F3                            jnz 0x9d1030 
009d103d
Cod-Father

nidud

#28
deleted

habran

This .while !(eax || edx) && ecx   should be the same as .while (!eax || !edx) && ecx, however:


.while !(eax || edx) && ecx
nop
.endw
ml.exe produces:
?_004:  jmp     ?_006                                   ; 0040101F _ EB, 01

?_005:  nop                                             ; 00401021 _ 90
?_006:  or      eax, eax                                ; 00401022 _ 0B. C0
        jnz     ?_007                                   ; 00401024 _ 75, 08
        or      edx, edx                                ; 00401026 _ 0B. D2
        jnz     ?_007                                   ; 00401028 _ 75, 04
        or      ecx, ecx                                ; 0040102A _ 0B. C9
        jnz     ?_005                                   ; 0040102C _ 75, F3
?_007: 



.while (!eax || !edx) && ecx
nop
.endw
ml.exe produces:
?_007:  jmp     ?_009                                   ; 0040102E _ EB, 01

?_008:  nop                                             ; 00401030 _ 90
?_009:  or      eax, eax                                ; 00401031 _ 0B. C0
        jz      ?_010                                   ; 00401033 _ 74, 04
        or      edx, edx                                ; 00401035 _ 0B. D2
        jnz     ?_011                                   ; 00401037 _ 75, 04
?_010:  or      ecx, ecx                                ; 00401039 _ 0B. C9
        jnz     ?_008                                   ; 0040103B _ 75, F3
?_011: 

Cod-Father