how in assembly masm do you do a if not less then statement
I have this code in vb.net
If Not variable1 < variable2 Then
count += 1
End If
If Not variable1 < variable3 Then
count += 1
End If
msgbox.show(count)
for this code count = 1
I tried all the below code and it does not work. it either gives me count = 2 at the end or count = 0 at the end. it should give me count = 1
here is the code for assembly masm
.data
variable1 dd ?
variable2 dd ?
variable3 dd ?
this is what is suppose to happen. I read from a text file 3 values they are 500,109,500 they get stored into the 3 variables so
variable1 = 500
variable2 = 109
variable3 = 506
then I need to list these in order from least to greatest so I tried to compare these.
I tried all of these variations and none of them worked
mov esi, offset variable1
mov ecx, offset variable2
.if esi > ecx
inc count
.endif
mov ecx, offset variable3
.if esi > ecx
inc count
.endif
.if variable1 > offset variable2
inc count
.endif
.if variable1 > offset variable3
inc count
.endif
mov esi, offset variable1
mov ecx, offset variable2
cmp esi,ecx
JB n2
inc count
n2:
mov ecx, offset variable3
cmp esi,ecx
JB n3
inc count
n3:
mov esi, offset variable1
mov ecx, offset variable2
cmp esi,ecx
JG n3
inc count
n3:
mov ecx, offset variable3
cmp esi,ecx
JG n4
inc count
n4:
mov esi, [variable1]
mov ecx, [variable2]
cmp esi, ecx
ja n1
inc Level3DNS1rank
n1:
mov ecx, [variable3]
cmp esi, ecx
ja n2
inc Level3DNS1rank
n2:
how can i convert the above vb.net code into masm assembly
thank you
Update
here is the answer to these 2 questions
what I needed to do was convert the string to an integer. I used this code to do that invoke atodw,ADDR variable1
for the if not in assembly I just changed if not variable1 < variable2
to if variable1 > variable2
Perhaps:
mov esi, [variable1]
mov ecx, [variable2]
cmp esi, ecx
jge n2
Aha. I see the problem now. You have:
variable1 db "500",0
variable2 db "109",0
variable3 db "506",0
That gets stored in memory as (the hex bytes):
variable1 35 30 30 00
variable2 31 30 39 00
variable3 35 30 36 00
But when you load a register from memory, it loads it little-endian. So when you have:
mov esi, [variable1]
mov ecx, [variable2]
The contents of esi
is 00303035
, and ecx
is 00393031
. And the last value is loaded as 00363035
.
You're trying to load a string of characters as an unsigned 32-bit value. Are you really wanting to compare strings?