-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathoutput-a-string.s
37 lines (27 loc) · 1001 Bytes
/
output-a-string.s
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
// ------------------------------------------------
// Porting Raspberry Pi ARM code to Apple Silicon
// 2023-01-08
// Jds
// ------------------------------------------------
// Print a string to the standard out (screen)
//
// NOTE: This example uses system and kernel calls
// to write to the screen, instead of using
// printf (shown in other examples).
//
// COMPILE --> make
// RUN --> ./filename ; echo $?
// ------------------------------------------------
.global _start
.align 2
_start:
MOV X0, 1 // Tell system to use StdOut (screen)
ADR X1, helloworld // Load address of our string
MOV X2, 13 // Length of message to print
MOV X16, 4 // Call system to write to StdOut
SVC 0 // Call kernel to write to StdOut
_end: // Split this off to a new label for clarity
MOV X0, 0 // Return 0
MOV X16, 1 // System call to terminate this program
SVC 0 // Kernel call to terminate the program
helloworld: .ascii "Hello World!\n"