Assembly Language
-
- Posts: 5
- Joined: Tue Jan 01, 2008 4:11 am
Assembly Language
Can anyone point me to a web page that will teach me how to program the PSP in pure assembly language? I already know Zilog Z80 assembly, and I have a Mac with OS 10.4 to program the PSP from, but I have a Windows computer at my dad's house that I can use if necessary. I have found this, but is there a site specifically about PSP assembly?
Last edited by Recursive Acronym on Tue Jan 01, 2008 9:55 am, edited 2 times in total.
You can read all about the MIPS32 ISA here:
http://www.csl.cornell.edu/courses/ece3 ... S_Vol2.pdf
The PSP main processor, Allegrex, is a custom MIPS R4000 32 bit. There's lots of good stuff on the wiki of this website:
http://wiki.ps2dev.org/
http://www.csl.cornell.edu/courses/ece3 ... S_Vol2.pdf
The PSP main processor, Allegrex, is a custom MIPS R4000 32 bit. There's lots of good stuff on the wiki of this website:
http://wiki.ps2dev.org/
-
- Posts: 5
- Joined: Tue Jan 01, 2008 4:11 am
Yes, very nicely put and exactly the point I was trying to make. Thanks!Jim wrote:What JF is saying is that learning assembly is learning assembly, no matter the platform. Learning PSP programming is a separate task. You almost certainly won't find a tutorial that teaches you both in one step.
Jim
Learn MIPS assembly, then learn programming the PSP, THEN put the two together. You'll have answered your own original request.
Oh, I do have one suggestion for after you learn MIPS assembly - edit the pspsdk sample makefile to add -S to the CFLAGS to have it stop after generating the assembly intermediate files. You can then look at how the sdk is called from assembly. One interesting thing I learned from that is that args are passed in a0-a3, then t0-t3, then on the stack. Most MIPS ABIs don't use the temps for passing args.
this is because t0-t3 (old ABI) may be also called a4-a7 (EABI32) but the unofficial gcc and bintools for psp are old and tend to use the old register naming whereas firmware and sony applications or games are probably using EABI.J.F. wrote:Yes, very nicely put and exactly the point I was trying to make. Thanks!Jim wrote:What JF is saying is that learning assembly is learning assembly, no matter the platform. Learning PSP programming is a separate task. You almost certainly won't find a tutorial that teaches you both in one step.
Jim
Learn MIPS assembly, then learn programming the PSP, THEN put the two together. You'll have answered your own original request.
Oh, I do have one suggestion for after you learn MIPS assembly - edit the pspsdk sample makefile to add -S to the CFLAGS to have it stop after generating the assembly intermediate files. You can then look at how the sdk is called from assembly. One interesting thing I learned from that is that args are passed in a0-a3, then t0-t3, then on the stack. Most MIPS ABIs don't use the temps for passing args.
Nothing really weird indeed.
Last edited by hlide on Wed Jan 02, 2008 7:06 am, edited 1 time in total.
a0-a3 can be used as temporary registers as well, but they are still named as aX and not tX. In fact, the only issue is that people tend to think tX as NOT being an argument register and that's all. If i'm not wrong, the unofficial psp-gcc also uses eabi which explains why we can have functions with over 4 argument registers : that's the only important point here.TyRaNiD wrote:The unofficial gcc/binutils are not old at all and standard binutils as doesn't support mnemonic register names anyway (except a few special ones), I added support for that with names which more closely reflect the fact that tX is more often used as a temp value than it is used as an argument.
By old, i mean this gcc doesn't reflect what the last official gcc can do : i was told it can handle VFPU intrinsics for instance. That's all. Official binutils probably uses r0-r31 or $0-$31 as register naming, which is another way to make the naming problem irrelevant.
Last edited by hlide on Wed Jan 02, 2008 7:42 am, edited 1 time in total.
Odd, the docs I've read on EABI for MIPS say the args go in a0-a3, then onto the stack. There is no mention of any a4-a7, or using t0-t3 for args. Oh well, not a big deal. I was aware that you could use unused arg regs as temporaries - that seems like a no-brainer to me. Arg regs are just temporaries that happen to have an initial value when the function is entered. I guess it would depend on how you learned assembly, and on what platform. If you initially learned on the x86, you might not have run into that idea as the x86 has very few registers, and the normal ABI has you passing all args on the stack. Funny enough, the SYSV ABI for the 68000 also passes args on the stack even though the 68000 has plenty of regs. Most 68000-based machines used the regs for passing args to the OS/BIOS. Both the Mac and Amiga were that way.
they don't mention explicitely aX/tX but use rX indeed :J.F. wrote:Odd, the docs I've read on EABI for MIPS say the args go in a0-a3, then onto the stack.
"If GR > r11, go to STACK" (r11 = a7/t3)
http://sourceware.org/ml/binutils/2003-06/msg00436.html
NOTE : EABI is not alone, there are also :
- O32 ABI which uses mnemonic registers a0-a3, t0-t3
- N32 ABI which uses mnemonic registers a0-a7
Very odd indeed. If you read the MIPS stuff, you find stuff like this: from the MIPS32 Instruction Set Quick Reference PDF...hlide wrote:they don't mention explicitely aX/tX but use rX indeed :J.F. wrote:Odd, the docs I've read on EABI for MIPS say the args go in a0-a3, then onto the stack.
"If GR > r11, go to STACK" (r11 = a7/t3)
http://sourceware.org/ml/binutils/2003-06/msg00436.html
NOTE : EABI is not alone, there are also :
- O32 ABI which uses mnemonic registers a0-a3, t0-t3
- N32 ABI which uses mnemonic registers a0-a7
The main MIPS32 reference manual I have says the same thing. I guess the ABI MIPS itself came up with is different from the SYSV ABIs you quote from.Function Pararmeters
* Every parameter smaller than 32 bits is promoted to 32 bits.
* First four parameters are passed in registers $a0-$a3.
(a note about 64 bit passing I won't type out)
* Every subsequent parameter is passed on the stack.
* First 16 bytes on the stack are not used.
(etc)
Anyway, when i made some modifications in MIPS gcc source (trying to add vfpu handling), i happen to find out psp-gcc was using EABI - and in the code, it is 8 general purpose argument registers exactly as specified in my last link. There are also O32 (the one you probably specified with only 4 general purpose argument registers) and N32 (which uses also 8 general purpose argument registers), but psp-gcc doesn't use them.J.F. wrote:The main MIPS32 reference manual I have says the same thing. I guess the ABI MIPS itself came up with is different from the SYSV ABIs you quote from.
-
- Posts: 5
- Joined: Tue Jan 01, 2008 4:11 am