+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    88
    Points
    53,348.00
    Rep Power
    208

    Default Using assembly in psp programming(generic C)

    The first, and easier is asm tags, ex.
    asm("HAITHURR:;");

    An example which would be
    Code:
    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).
    Code:
    .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 cvtFloat
    Now, how you would call these:
    Code:
    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.
    Last edited by NOFX; 09-21-2008 at 03:09 PM.

    Promote Free Software!

  2. #2
    Join Date
    Jan 2008
    Location
    PA
    Posts
    1,164
    Points
    3,846,166.25
    Rep Power
    220

    Default

    it helped =] i gota mess around with this stuff more its fun
    Nice Tut


    Get Vip: »Here«
    Donate: »Here«
    >>List of Compilers<<
    >>SFDM Name Generator<<
    [Owner Of FluidCoding]

  3. #3
    Join Date
    Jun 2008
    Posts
    709
    Points
    578,700.48
    Rep Power
    210

    Default

    wow im shocked i dont get it lol

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts