📄 start.s
字号:
/* Start.s * Assembly language assist for user programs running on top of Nachos. * * Since we don't want to pull in the entire C library, we define * what we need for a user program here, namely Start and the system * calls. */#define IN_ASM#include "syscall.h" .text .align 2/* ------------------------------------------------------------- * __start * Initialize running a C program, by calling "main". * * NOTE: This has to be first, so that it gets loaded at location 0. * The Nachos kernel always starts a program by jumping to location 0. * ------------------------------------------------------------- */ .globl __start .ent __start__start: jal main move $4,$0 jal Exit /* if we return from main, exit(0) */ .end __start/* ------------------------------------------------------------- * System call stubs: * Assembly language assist to make system calls to the Nachos kernel. * There is one stub per system call, that places the code for the * system call into register r2, and leaves the arguments to the * system call alone (in other words, arg1 is in r4, arg2 is * in r5, arg3 is in r6, arg4 is in r7) * * The return value is in r2. This follows the standard C calling * convention on the MIPS. * ------------------------------------------------------------- */ .globl Halt .ent HaltHalt: addiu $2,$0,SC_Halt syscall j $31 .end Halt .globl Add .ent AddAdd: addiu $2,$0,SC_Add syscall j $31 .end Add .globl Exit .ent ExitExit: addiu $2,$0,SC_Exit syscall j $31 .end Exit .globl Exec .ent ExecExec: addiu $2,$0,SC_Exec syscall j $31 .end Exec .globl ExecV .ent ExecVExecV: addiu $2,$0,SC_ExecV syscall j $31 .end ExecV .globl Join .ent JoinJoin: addiu $2,$0,SC_Join syscall j $31 .end Join .globl Create .ent CreateCreate: addiu $2,$0,SC_Create syscall j $31 .end Create .globl Remove .ent RemoveRemove: addiu $2,$0,SC_Remove syscall j $31 .end Remove .globl Open .ent OpenOpen: addiu $2,$0,SC_Open syscall j $31 .end Open .globl Read .ent ReadRead: addiu $2,$0,SC_Read syscall j $31 .end Read .globl Write .ent WriteWrite: addiu $2,$0,SC_Write syscall j $31 .end Write .globl Close .ent CloseClose: addiu $2,$0,SC_Close syscall j $31 .end Close .globl Seek .ent SeekSeek: addiu $2,$0,SC_Seek syscall j $31 .end Seek .globl Delete .ent DeleteDelete: addiu $2,$0,SC_Delete syscall j $31 .end Delete .globl ThreadFork .ent ThreadForkThreadFork: addiu $2,$0,SC_ThreadFork syscall j $31 .end ThreadFork .globl ThreadYield .ent ThreadYieldThreadYield: addiu $2,$0,SC_ThreadYield syscall j $31 .end ThreadYield .globl ThreadExit .ent ThreadExitThreadExit: addiu $2, $0, SC_ThreadExit syscall j $31 .end ThreadExit .globl ThreadJoin .ent ThreadJoinThreadJoin: addiu $2, $0, SC_ThreadJoin syscall j $31 .end ThreadJoin .globl getSpaceID .ent getSpaceIDgetSpaceID: addiu $2,$0,SC_getSpaceID syscall j $31 .end getSpaceID .globl getThreadID .ent getThreadIDgetThreadID: addiu $2,$0,SC_getThreadID syscall j $31 .end getThreadID .globl Ipc .ent IpcIpc: addiu $2,$0,SC_Ipc syscall j $31 .end Ipc .globl Clock .ent ClockClock: addiu $2,$0,SC_Clock syscall j $31 .end Clock/* dummy function to keep gcc happy */ .globl __main .ent __main__main: j $31 .end __main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -