-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_world_arm.s
More file actions
41 lines (33 loc) · 1.52 KB
/
hello_world_arm.s
File metadata and controls
41 lines (33 loc) · 1.52 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
// hello.s: hello world in ARM assembler
//
// How to compile:
//
// as -o hello.o hello.s
// gcc -o hello hello.o
//
.global main
// ************************ Starting variable definition *****************
.data
// ***********************************************************************
HelloStr: // Label marking this location in memory
.asciz "Hello World\n" // ASCII codes for the string
// ************************ Starting computer instruction ****************
.text
// ***********************************************************************
main:
push {lr} // Save the return address on the stack
push {fp} // Save the frame pointer on the stack
// Explained later in CS255
/* ----------------------------------------
Pass the string to printf function
---------------------------------------- */
movw r0, #:lower16:HelloStr
movt r0, #:upper16:HelloStr
/* ----------------------------------------
Call the printf function
---------------------------------------- */
bl printf // Call printf function with input string
pop {fp} // Pop the frame pointer
pop {pc} // Pop the return address into PC
// Explained later in CS255
.end