Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C to MIPS32 assembly

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?

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:

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List