Hi,I am trying to do if statement in Assembly but it doesnt work.Could you help me
putstr is predifine macro
Thanks

.386
.model Flat
include Cs266.inc
.data
mes1 DB "First Greater"
mes2 DB "Second Greater"
var1 DD 22
var2 DD 9
.code
main:
mov EAX,var1
cmp EAX,var2
jge else
jmp end_if
else:
putstr mes1
JMP exit
end_if:
putstr mes2
exit:
Ret
end

Recommended Answers

All 3 Replies

>>but it doesnt work
What does that mean???

lines 13 and 14 could be both replaced by one line: jl end_if

It prints First Greater Second Greater,instead only one or the other

Most likely because you failed to terminate the two strings on lines 5 and 6. How is putstr() supposed to know where the end of the string is? int 21 uses $ as a string terminator, while C and C++ languages use 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.