소스 검색

Created HelloWorld.s

Foppe Hemminga 6 년 전
커밋
99d1758856
1개의 변경된 파일30개의 추가작업 그리고 0개의 파일을 삭제
  1. 30 0
      HelloWorld.s

+ 30 - 0
HelloWorld.s

@@ -0,0 +1,30 @@
+@
+@ Assembler program to print "Hello World!"
+@ to stdout
+@
+@ R0-R2 - parameters to Linux function services
+@ R7 - Linux function number
+@
+
+.global _start		@ Provide program starting
+			@ address to linker
+
+@ Set up the parameters to print hello world
+@ and then call Linux to do it.
+
+_start: mov R0, #1	@ 1 = StdOut
+	ldr	R1, =helloworld	@ string to print
+	mov	R2, #13	@length of our string
+	mov R7, #4	@ Linux write system call
+	svc	0	@ Call Linux to print
+
+@ Set up the parameters to exit the program
+@ and then call Linux to do it.
+	mov	R0, #0	@ Use 0 return code
+	mov	R7, #1	@ Sevice command code 1
+			@ terminates the program
+	svc	0	@ Call Linux to terminate
+
+.data
+helloworld: 	.ascii	"Hello World!\n"
+