windows - assembly masm can not figure out how to do a if not less then statement -
how in assembly masm do if not less statement
i have code in vb.net
if not variable1 < variable2 count += 1 end if if not variable1 < variable3 count += 1 end if msgbox.show(count)
for code count = 1
i tried below code , not work. either gives me count = 2 @ end or count = 0 @ end. should give me count = 1
here code assembly masm
.data variable1 dd ? variable2 dd ? variable3 dd ?
this suppose happen. read text file 3 values 500,109,500 stored 3 variables so
variable1 = 500 variable2 = 109 variable3 = 506
then need list these in order least greatest tried compare these.
i tried of these variations , 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 convert above vb.net code masm assembly
thank you
update
here answer these 2 questions
what needed convert string integer. used code invoke atodw,addr variable1
if not in assembly changed if not variable1 < variable2
if variable1 > variable2
perhaps:
mov esi, [variable1] mov ecx, [variable2] cmp esi, ecx jge n2
update
aha. see problem now. have:
variable1 db "500",0 variable2 db "109",0 variable3 db "506",0
that gets stored in memory (the hex bytes):
variable1 35 30 30 00 variable2 31 30 39 00 variable3 35 30 36 00
but when load register memory, loads little-endian. when have:
mov esi, [variable1] mov ecx, [variable2]
the contents of esi
00303035
, , ecx
00393031
. , last value loaded 00363035
.
you're trying load string of characters unsigned 32-bit value. wanting compare strings?
Comments
Post a Comment