C to MIPS32 assembly
1
Name:
Anonymous
2009-11-11 1:35
I'm having some trouble figuring out how to express the following C segment, specifically the compound if statement, in MIPS32 assembly:
if((text[i] >= 65 && text[i] <= 90) || (text[i] >= 97 && text[i] <= 122))
{
text[j] = text[i] ;
charCount++;
}
else
{
badword = true;
last = last - charCount;
}
Can anybody give me some help with this?
2
Name:
Anonymous
2009-11-11 1:40
Use gcc -S
3
Name:
Anonymous
2009-11-11 2:20
;assume i = si, j = di
;assume es = ds
;assume charCount = cx
mov bx, text
mov ax, [si+bx]
AND1:
cmp ax, 65
jl AND2
cmp ax, 90
jg AND2
jmp TRUE
AND2:
cmp ax, 97
jl FALSE
cmp ax, 122
jg FALSE
TRUE:
movsb
inc cx
jmp END
FALSE:
mov [p_badword], word ptr 1
sub [p_last], cx
END:
4
Name:
Anonymous
2009-11-11 2:25
oops I mean mov ax, [si+text]
5
Name:
Anonymous
2009-11-11 3:41
>>3
>>4
Thanks, although it wasn't MIPS32 assembly, the control structure is what I really needed.
6
Name:
Anonymous
2009-11-11 3:44
Tip:
Write in C then disassemble.
7
Name:
Anonymous
2009-11-11 4:02
>>3
EXPERT ASSEMBLY ASSEMBLER
8
Name:
Anonymous
2009-11-11 4:17
Tip:
Write in harpy, then you will have TWO probloms;
main = do
cmp $ ax 65
jl AND2
cmp $ ax 90
jg AND2
jmp $ liftM TRUE
9
Name:
Anonymous
2010-11-28 11:47