Convert kernel library asm s to c#857
Conversation
|
I'm fine with this, @rickgaiser ? |
rickgaiser
left a comment
There was a problem hiding this comment.
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.
| "\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" |
| .globl UModeCallbackDispatcher | ||
| .ent UModeCallbackDispatcher | ||
| UModeCallbackDispatcher: | ||
| lui $sp, 0x0008 | ||
| jalr $v1 | ||
| addiu $sp, $sp, 0x1fc0 | ||
| addiu $v1, $zero, -8 | ||
| syscall | ||
| .end UModeCallbackDispatcher |
|
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 The C version can also participate in rearrangement and dropping of code (without needing |
|
I guess it's a matter of taste, becouse this makes it harder for me to read. The line count has increased slightly (added 1.730, removed 1.651) from: to: Is there no better, more 'C' like, way to handle syscalls? Perhaps in examples from other devices or operating systems? |
|
Some example of linux mips syscalls: https://github.com/kraj/musl/blob/kraj/master/arch/mips/syscall_arch.h Stuff writing to sp/k0/k1 may be too prone to breakage, so I'll leave those, but I plan to clean up the rest in successive PRs. |
Makes it easier to read, especially with all the C preprocessor macros