Skip to content

Convert kernel library asm s to c#857

Open
uyjulian wants to merge 1 commit into
ps2dev:masterfrom
uyjulian:kernel_s_to_c
Open

Convert kernel library asm s to c#857
uyjulian wants to merge 1 commit into
ps2dev:masterfrom
uyjulian:kernel_s_to_c

Conversation

@uyjulian
Copy link
Copy Markdown
Member

Makes it easier to read, especially with all the C preprocessor macros

@fjtrujy
Copy link
Copy Markdown
Member

fjtrujy commented May 25, 2026

I'm fine with this, @rickgaiser ?

Copy link
Copy Markdown
Member

@rickgaiser rickgaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for moving thing away from assembly and towards more readable 'C' code, but a large part of this PR just places complete assembly functions inside C and that makes no sense to me.

Comment on lines +19 to +27
"\t" ".globl UModeCallbackDispatcher" "\n"
"\t" ".ent UModeCallbackDispatcher" "\n"
"\t" "UModeCallbackDispatcher:" "\n"
"\t" "\t" "lui $sp, 0x0008" "\n"
"\t" "\t" "jalr $v1" "\n"
"\t" "\t" "addiu $sp, $sp, 0x1fc0" "\n"
"\t" "\t" "addiu $v1, $zero, -8" "\n"
"\t" "\t" "syscall" "\n"
"\t" ".end UModeCallbackDispatcher" "\n"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this more readable?

Comment on lines -15 to -23
.globl UModeCallbackDispatcher
.ent UModeCallbackDispatcher
UModeCallbackDispatcher:
lui $sp, 0x0008
jalr $v1
addiu $sp, $sp, 0x1fc0
addiu $v1, $zero, -8
syscall
.end UModeCallbackDispatcher
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this more readable?

@uyjulian
Copy link
Copy Markdown
Member Author

The C version looks better to my eyes since it actually has syntax highlighting. (If there is a syntax plugin for mips asm+C preprocessor that would be nice)

I also separated each function into its own asm block for improved readability / separation, and added .ent / .end so that it will disassemble properly.

The C version can also participate in rearrangement and dropping of code (without needing -ffunction-sections).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants