-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPA5RunningExample.java.s
More file actions
105 lines (89 loc) · 1.99 KB
/
Copy pathPA5RunningExample.java.s
File metadata and controls
105 lines (89 loc) · 1.99 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.file "main.java"
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
.text
.global main
.type main, @function
main:
push r29
push r28
in r28,__SP_L__
in r29,__SP_H__
/* prologue: function */
call _Z18MeggyJrSimpleSetupv
/* Need to call this so that the meggy library gets set up */
# NewExp
ldi r24, lo8(4)
ldi r25, hi8(4)
# allocating object of size 4 on heap
call malloc
# push object address
# push two byte expression onto stack
push r25
push r24
# True/1 expression
ldi r22, 1
# push one byte expression onto stack
push r22
#### function call
# put parameter values into appropriate registers
# load a one byte expression off stack
pop r22
# receiver will be passed as first param
# load a two byte expression off stack
pop r24
pop r25
call C_foo
/* epilogue start */
endLabel:
jmp endLabel
ret
.size main, .-main
.text
.global C_foo
.type C_foo, @function
C_foo:
push r29
push r28
# make space for locals and params
ldi r30, 0
push r30
push r30
push r30
push r30
push r30
# Copy stack pointer to frame pointer
in r28,__SP_L__
in r29,__SP_H__
# save off parameters
std Y + 2, r25
std Y + 1, r24
std Y + 3, r22
/* done with function C_foo prologue */
# Load constant int 3
ldi r24,lo8(3)
ldi r25,hi8(3)
# push two byte expression onto stack
push r25
push r24
/* epilogue start for C_foo */
# handle return value
# load a two byte expression off stack
pop r24
pop r25
# pop space off stack for parameters and locals
pop r30
pop r30
pop r30
pop r30
pop r30
# restoring the frame pointer
pop r28
pop r29
ret
.size C_foo, .-C_foo