This repository was archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.S
More file actions
50 lines (49 loc) · 1.75 KB
/
Copy pathstart.S
File metadata and controls
50 lines (49 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <asm/asm.h>
.data
str:
.asciiz "Hello World\n" # Null-terminated string "Hello World" stored at label 'str'
.align 2 # align to 4-byte boundary (2^2)
var:
.byte 3 # correctly aligned byte: 3
/* '<x>' in the comments is the part to be replaced. */
/* use '.align <x>' to align the following words to 1-byte boundary (disabling word-alignment) */
/* so that the byte 3 and word 7 is "connected" */
/* Your code here. (1/6) */
.align 0
.word 7, 8, 9
.text
/* We define '_start_mips' here as the entry of our program. */
EXPORT(_start_mips)
.set at
.set reorder
mtc0 zero, CP0_STATUS
li sp, 0x84000000
/* Load the address of the string 'str' into the first parameter register. */
la a0, str
/* use 'addiu sp, sp, <x>' to push a proper-sized frame onto the stack for Nonleaf function 'print_str'. */
/* Your code here. (2/6) */
addiu sp, sp,-4
jal print_str
/* use 'addiu sp, sp, <x>' to restore stack pointer. */
/* Your code here. (3/6) */
addiu sp, sp,4
/* Set the first four parameters. */
li a0, 0
li a1, 1
li a2, 2
li a3, 3
/* use 'addiu sp, sp, <x>' to push a proper-sized frame onto the stack for Nonleaf function 'hello'. */
/* Your code here. (4/6) */
addiu sp, sp, -24
lw t1, var
li t2, 5
/* use 'sw t1, <x>(sp)' to store t1 at the proper place of the stack */
/* so that t1 is 5th argument of function hello. */
/* Your code here. (5/6) */
sw t1, 16(sp)
/* use 'sw t2, <x>(sp)' to store t2 at the proper place of the stack */
/* so that t2 is 6th argument of function hello. */
/* Your code here. (6/6) */
sw t2, 20(sp)
/* use 'j' to call the function 'hello', we use 'j' instead of 'jal' because 'hello' is 'noreturn' */
j hello