Page 1 of 1

Writing an assembler for the PS1

Posted: August 9th, 2017, 3:46 am
by Misteek
I'm writing an assembler and a disassembler for the PS1. I want them to be the end-all, be-all of PS1 (dis)assemblers.

Questions:

1. The specific instruction set used by the PS1 is MIPS r3000, correct?

2. Are there any additional operations that a PS1 assembler should support? Operations such as reading from a disc image, writing to a memory card, communicating with the GPU, or what what have you.

3. If there are, where can I find more info about them?

4. What open source assemblers and disassemblers exist for the PS1?

5. What advice do you have for me?

Re: Writing an assembler for the PS1

Posted: August 10th, 2017, 6:26 am
by CodeAsm
isnt the GNU toolset good enough? (also I think they contain any hits you might need. tho you might want to write macros for like "Operations such as reading from a disc image, writing to a memory card, communicating with the GPU, or what what have you." :P
further im just a noob, I only know I probably could write in assembler using the GNU tools for MIPS

Re: Writing an assembler for the PS1

Posted: August 10th, 2017, 10:20 am
by Someone
For all needed info check nocash's site, he did comprehensive PS1 research and documented it very well, he also made very advanced PS1 emulator with debugger, though it's not perfect. Also you can use IDApro for disassembling PS1 games if you need reference source for your own work, though I doubt that if you write your disassembler then it will be better than IDA's and yet maybe for someone it still be useful so I won't stop you from doing that ;). Also on romchaking.net you can find some assembly tools and check them if you want.

Re: Writing an assembler for the PS1

Posted: August 11th, 2017, 2:45 am
by Misteek
http://problemkaputt.de/psx-spx.htm

I want to write a (dis)assembler that supports literally every opcode you would find in a PS1 game. This includes opcodes that deal with cd-rom seeks, reads, and writes, and anything else that you will find.

Re: Writing an assembler for the PS1

Posted: August 11th, 2017, 6:49 am
by Orion_
well, maybe you should learn first what "assembler" is, because such opcodes doesn't exist.
assembler is related to the CPU of the machine, it has nothing to do with CD ROM which is another peripheral to which you talk through specific addresses.

Re: Writing an assembler for the PS1

Posted: August 11th, 2017, 9:29 am
by Misteek
So the functions cdrom setloc, read, and write referenced in this post are not actual opcodes but something else entirely?

https://www.romhacking.net/forum/index. ... #msg266131
How do you find these LBA tables? Well you need to run pSX with logging enabled and you need to log all CDROM IO. now just play the game as normal and save the log. Any time you see a line in the log such as

[015b009c] cdrom: setloc 00000000:00000002:00000005

it will be closely followed by lines such as these
[015b00a4] cdrom: read byte 07801800 = 09 (800584dc)
[015b00a4] cdrom: write byte 07801800 = 01 (800584ec)

Those address in the brackets
(800584dc)
(800584ec)
Are a part of the function "setloc". mark the entry point of that function in your disassembly.
Are these functions the result of a call to syscall? Where can I find a complete listing of mips opcodes (and their parameters) that the PS1 supports?

https://courses.missouristate.edu/KenVo ... lHelp.html
^An example of syscall parameters on the MARS mips emulator.

http://psx.rules.org/system.txt
^Seems to be what I'm looking for, if anyone wants to verify.

https://stackoverflow.com/questions/203 ... nstruction
^A guy verifies that syscall was used to execute math calculations on a vector processing unit.

Re: Writing an assembler for the PS1

Posted: August 11th, 2017, 6:10 pm
by CodeAsm
I have no idea if this is any good: http://chortle.ccsu.edu/assemblytutorial/
I dont speak Mips assembly (yet) but @Orion_ seems to be right here, "what is an assembler" what does it do?
What is machine language... what do those bytes mean when you look at a executable? can you write those yourself?
And how do you call a function you created yourself from another part of your code?
can you call a "kernel" function? I think all those questions will be answered if I study assembly and use a assmbler before I would write my own assembler. (I want to, for a Z80, but have to understand the language of the cpu first, its default/common used tools first)

Or, you start with a few simple instructions and write an asembler for those first and hope the PS1 accepts your binairy. https://vhouten.home.xs4all.nl/mipsel/r3000-isa.html my head spins already ;)

Re: Writing an assembler for the PS1

Posted: August 11th, 2017, 10:09 pm
by Orion_
you should try to learn the assembler language and write some assembler code for the PS1 before writing an assembler yourself.
there are some asm source for PS1 on this page in the MISC section: http://hitmen.c02.at/html/psx_sources.html

Re: Writing an assembler for the PS1

Posted: August 12th, 2017, 7:28 am
by Misteek
I'm a programmer, the best way to learn MIPS is to write an assembler. It doesn't seem very hard. I need to know exactly what bits are set with each opcode and all their possible parameters, and what opcodes the PS1 supports.

Labels seem straight-forward.

For a disassembler, I want a way to make it read certain things as something other than assembly - maybe as a table of bytes. How I get it to do that is my problem.

My goal for the disassembler is to have something where once you know everything there is to know about a file, you can feed it everything you know and it will output something that you can assemble and get the exact same file back.

Depending on how I implement the opcode table I can see it being extensible.

Anyways, my questions are:

1. What opcodes doe the PS1 support?

2. What are the parameters for those opcodes not found in general purpose MIPS documents?

Probably the only people who could answer these questions are gemini and nocash.

Re: Writing an assembler for the PS1

Posted: August 12th, 2017, 10:02 pm
by Orion_

Re: Writing an assembler for the PS1

Posted: September 28th, 2017, 3:13 am
by brill