PDA

View Full Version : Using assembly in psp programming(generic C)



NOFX
09-21-2008, 03:07 PM
The first, and easier is asm tags, ex.
asm("HAITHURR:;");

An example which would be

asm("lui $t0, 0x08cf;"
"lw $t1, 0x0500($t0);"
"beq $t1, $zero, endOfAsmCrap;"
"nop;"
"lw $t2, 0x001c($t1);"
"addiu $t2, $t2, 0xffff;"
"sw $t2, 0x001c($t2);");That would load what's in 08cf0500 offset 1c, subtract 1(ffff), and store it

Now, the real deal, is a .S file(not sure of the exact syntax, but who gives a rats ass).

.set noreorder

#add an address
.global addAddress
.ent addAddress
addAddress:
lw $t0, 0x0000($a0)
addu $t0, $t0, $a1
sw $t0, 0x0000($a0)
jr $ra
add $v0, $t0, $zero #this returns it, but it's not necessarily needed
.end addAddress

#convert dec and return as float
.global cvtFloat
.ent cvtFloat
cvtFloat:
mtc1 $a0, $f0
cvt.w.s $f0, $f0
mfc1 $t0, $f0
jr $ra
add $v0, $t0, $zero #moves whats in t0(the converted) to the return var
.end cvtFloatNow, how you would call these:

addAddress(address, value);
buffer = cvtFloat(buffer);Hope that helped some.

Oh yeah, this is a codinghs ONLY tut, it is to stay here, and here only.

SonniE
09-21-2008, 03:07 PM
it helped =] i gota mess around with this stuff more its fun
Nice Tut

Mako-Infused
09-21-2008, 03:10 PM
wow im shocked i dont get it lol