NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: maplesirop on February 23, 2013, 09:22:05 PM
-
(...)
cmp ecx, 48
jl warn
cmp ecx, 57
jg warn
inc ecx
warn: cmp ecx, 97
jle stop
cmp ecx, 122
jge stop
mov eax, 4
mov ebx, 1
mov ecx, alert
mov edx, len
int 0x80
warn: (...)
would this work?
-
Hi maplesirop,
would this work?
probably not, because you've the same label (warn) two times in your source.
Gerhard
-
thanks, would it work otherwise?
-
Hi maplesirop,
thanks, would it work otherwise?
that's not so clear. Where is the label stop? What would you like to do? Do you need only the if-tree or the if-else-trees? In any case, that ressource could be of interst for you: http://www.drpaulcarter.com/pcasm/ (http://www.drpaulcarter.com/pcasm/). I hope that helps.
Gerhard
-
I need to embbed several if statements
if (x=1)
{
x++
}
else
{
if (x=2)
{
x=0;
}
else
{
if(x=0)
{
x++;
}
}
}
-
Hi maplesirop,
that looks like a case select:
case 0:
x++
case 1:
x++
case 2:
x=0
Is that your goal?
Gerhard
-
Hi maplesirop,
that looks like a case select:
case 0:
x++
case 1:
x++
case 2:
x=0
Is that your goal?
Gerhard
yes
can you help me with my segmentation fault problem?
-
if (x=1)
{
x++
}
else
{
if (x=2)
{
x=0;
}
else
{
if(x=0)
{
x++;
}
}
}
can be translated to.
cmp ecx,1
jne elselabel1
inc ecx
jmp endiflabel1
elselabel1:
cmp ecx, 2
jne elselabel2
mov ecx,2
jmp endiflabel2
elselabel2:
cmp ecx, 0
jne endiflabel3 ;;jump to endif directly
inc ecx
endiflabel3:
endiflabel2:
endiflabel1:
I would suggest to follow a label naming convention like this when you code a nested if-else constructs.
Try it and let us know.
-
thanks