asm

x86 Assembly programs.
Log | Files | Refs

commit 8d8b93a828f7b88825421fbd54a9769c51dc65f4
parent 8db222397eebaececbb1adff41404a65fb474e45
Author: dwrz <dwrz@dwrz.net>
Date:   Thu, 16 Mar 2023 00:54:04 +0000

Add hello-world

Diffstat:
Ahello-world/hello.s | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/hello-world/hello.s b/hello-world/hello.s @@ -0,0 +1,27 @@ +# PURPOSE: Print "Hello, World!", then exit. +# INPUT: None. +# OUTPUT: Prints a string to stdout. +# Returns a status code of 0. +# VARIABLES: +# %rax holds the system call number +# %rbx holds the return status +.section .data +hw: + .ascii "Hello, World!" + +.section .text + .globl _start + +_exit: + mov $1, %rax # System call number for exit. + mov $0, %rbx # Exit code. + int $0x80 # Call the kernel. + +_start: + mov $4, %rax # System call number for write. + mov $1, %rbx # stdout. + mov $hw, %rcx # Address of the buffer. + mov $15, %rdx # Number of bytes to write. + int $0x80 # Call the kernel. + +call _exit # Call the _exit macro.