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

Pages: 1-

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 1:40

Use gcc -S

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:

Name: Anonymous 2009-11-11 2:25

oops I mean mov ax, [si+text]

Name: Anonymous 2009-11-11 3:41

>>3
>>4
Thanks, although it wasn't MIPS32 assembly, the control structure is what I really needed.

Name: Anonymous 2009-11-11 3:44

Tip:

Write in C then disassemble.

Name: Anonymous 2009-11-11 4:02

>>3
EXPERT ASSEMBLY ASSEMBLER

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

Name: Anonymous 2010-11-28 11:47


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