Start to rearrange archetecture specific code
This commit is contained in:
43
arch/mips.c
Normal file
43
arch/mips.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#if defined(__mips__)
|
||||
#include <stdint.h>
|
||||
|
||||
void exit(int8_t status){
|
||||
asm (
|
||||
"move $a0, %0\n"
|
||||
"li $v0, 4001\n"
|
||||
"syscall\n"
|
||||
:
|
||||
: "r" (status)
|
||||
: "a0", "v0"
|
||||
);
|
||||
}
|
||||
|
||||
intptr_t write(int32_t fd, const void* buf, intptr_t size){
|
||||
intptr_t n_written = 0;
|
||||
asm (
|
||||
"li $a0, 1\n"
|
||||
"move $a1, %0\n"
|
||||
"move $a2, %1\n"
|
||||
"li $v0, 4004\n"
|
||||
"syscall\n"
|
||||
: //TODO: n_written
|
||||
: "r"(buf), "r"(count)
|
||||
: "a0", "a1", "a2", "v0" //TODO: temp registers clobbered by syscall should probably also be listed but this fn returns right away so it should be fine?
|
||||
);
|
||||
return n_written;
|
||||
}
|
||||
//intptr_t read(int32_t fd, const void* buf, intptr_t size);
|
||||
|
||||
uint32_t fork(){
|
||||
int rtn;
|
||||
asm (
|
||||
"li $v0, 4002\n"
|
||||
"syscall\n"
|
||||
"move %0, $v0"
|
||||
:"=r" (rtn)
|
||||
:
|
||||
: "a0", "v0"
|
||||
);
|
||||
return (uint32_t)rtn;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user