ASMPSX Header and Opcodes

General help for the PSY-Q SDK, such as setting the SDK up, compiling correctly, linking and debugging
Post Reply
The_Dude
What is PSXDEV?
What is PSXDEV?
Posts: 1
Joined: Nov 20, 2024

ASMPSX Header and Opcodes

Post by The_Dude » November 20th, 2024, 10:30 pm

Hello everyone,

This is my first time posting, so here goes...

I'm trying to learn to code MIPS assembly programs for the PS1 using the ASMPSX compiler (from the Psy-Q SDK). However, I can't seem to get the header right, meaning that emulators won't run the program.

On top of that, many opcodes aren't recognised. For example,

Code: Select all

.org 0x80010000
(setting the entry point) produces:

Code: Select all

 Error : Op-code not recognised
Does anyone have a correct ASM header, or a library of opcodes and syntax for this assembler?

I've had some success with other compilers, such as ARMIPS, but would really like to learn on the OG of PS1 assembly tools.

Any help would be greatly appreciated.

The Dude abides.

-----

In case it matters, I'm using the PCSX-Redux and DuckStation emulators (up-to-date as of today).

My assemble command is:

Code: Select all

asmpsx /z main.asm,main.ps-exe
Here's an example of some code which doesn't work, attempting to set the screen to a blue colour:

Code: Select all

	section .text

_start:
	; Initialize GPU Display Mode
	lui r16, 0x1000       ; Load upper immediate (GP1: 640x480i NTSC)
	ori r16, r16, 0x0000  ; OR with lower bits
	sw r16, 0x1f801814    ; Write to GP1

	; Set Background Color to Blue
	lui r16, 0xe100       ; Load upper immediate (GP0: Fill VRAM with blue)
	ori r16, r16, 0x00ff  ; OR with lower bits
	sw r16, 0x1f801810    ; Write to GP0

loop:
	j loop                ; Infinite loop
	nop                   ; No operation (delay slot)
This assembles but doesn't run, producing this error in DuckStation:

Code: Select all

Failed to load main.ps-exe. Executable does not contain a header.

User avatar
nocash
Verified
PSX Aficionado
PSX Aficionado
Posts: 634
Joined: Nov 12, 2012
Contact:

Post by nocash » November 21st, 2024, 12:25 am

Assemblers are called assemblers, not compilers.
Things like .org (or more commonly just org, without leading dot) are directives, not opcodes.

The header, that's simple and documented, it's easy to create it yourself using data directives in front of the source file, or manually inserting it after creating the binary file.

But, I would assume the psyq tools can generate such headers. Maybe there is a linker to create the final binary with exe header? Or do already have the binary as such (as opposed to only having an obj file with whatever obj headers). In case of doubt, use a hex editor to see what is in your binary file.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests