Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 147 lines (100 sloc) 2.959 kb
fc763ca @dharmatech initial checkin
authored
1
2 # ----------------------------------------------------------------------
3
4 .macro prepare_stack
5 push %rbp
6 mov %rsp , %rbp
7 .endm
8
9 # ----------------------------------------------------------------------
10
11 .macro print_int var
12
13 .section .rodata
14
15 1:
16 .string "%i"
17
18 .text
19
20 mov $1b , %rdi
21 mov \var , %rsi
22 mov $0 , %rax
23
24 call printf
25
26 .endm
27
28 # ----------------------------------------------------------------------
29
30 .macro print_double var
31
32 .section .rodata
33
34 1:
35 .string "%f"
36
37 .text
38
39 mov $1b , %rdi
40 movsd \var , %xmm0
41 mov $1 , %rax
42
43 call printf
44
45 .endm
46
47 # ----------------------------------------------------------------------
48
49 .macro print_literal_string str
50 .section .rodata
51 1:
52 .string "\str"
53
54 .text
55 mov $1b , %rdi
56 mov $0 , %rax
57 call printf
58 .endm
59
60 # ----------------------------------------------------------------------
61
62 .macro print_string var
63 mov \var , %rdi
64 mov $0 , %rax
65 call printf
66 .endm
67
68 # ----------------------------------------------------------------------
69
70 .macro print_nl
71 .section .rodata
72 1:
73 .string "\n"
74 .text
75 mov $1b , %rdi
76 mov $0 , %rax
77 call printf
78 .endm
79
80 # ----------------------------------------------------------------------
81
82 .macro ref8 var , i , dst
83
84 mov \var(%rbp) , %rax
85 mov \i*8(%rax) , %rax
86 mov %rax , \dst
87
88 .endm
89
90 # ----------------------------------------------------------------------
91
92 .macro set1 src , var , i
93 mov \var(%rbp) , %rax
94 movb \src , \i(%rax)
95 .endm
96
97 # ----------------------------------------------------------------------
98
99 .macro stack_allocate var , size
100
101 .set offset , offset - \size
102
103 .set \var , offset
104
105 sub $\size , %rsp
106
107 .endm
108
109 # ----------------------------------------------------------------------
110
111 .macro literal_double num , dst
112 .section .rodata
113 .align 8
114 1:
115 .double \num
116 .text
117 movsd 1b , \dst
118 .endm
119
120 # ----------------------------------------------------------------------
121
122 .macro literal_string str , dst
123 .section .rodata
124 1:
125 .string "\str"
126 .text
127 mov $1b , \dst
128 .endm
129
130 # ----------------------------------------------------------------------
131
132 .macro global_text name
133 .text
134 .global \name
135 \name:
136 .endm
137
138 # ----------------------------------------------------------------------
139
140 .macro return_integer val
141 mov \val , %rax
142 leave
143 ret
144 .endm
145
146 # ----------------------------------------------------------------------
147
Something went wrong with that request. Please try again.