Hello, world!
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build
|
18
Makefile
Normal file
18
Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
.PHONY: all clean
|
||||
|
||||
SRC := $(wildcard *.asm)
|
||||
OBJDIR := build
|
||||
OBJS := $(SRC:%.asm=$(OBJDIR)/%.o)
|
||||
BINS := $(SRC:%.asm=$(OBJDIR)/%)
|
||||
|
||||
all: $(BINS)
|
||||
|
||||
$(OBJDIR)/%: $(OBJDIR)/%.o
|
||||
ld -m elf_i386 $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o: %.asm
|
||||
mkdir -p $(OBJDIR)
|
||||
nasm -f elf $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)
|
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# asm
|
||||
|
||||
Build x86_64 assembly examples from [asmtutor.com](https://asmtutor.com)
|
17
helloworld.asm
Normal file
17
helloworld.asm
Normal file
@@ -0,0 +1,17 @@
|
||||
; Hello World Program - asmtutor.com
|
||||
; Compile with: nasm -f elf helloworld.asm
|
||||
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld.o -o helloworld
|
||||
; Run with: ./helloworld
|
||||
|
||||
SECTION .data
|
||||
msg db 'Hello World!', 0Ah ; assign msg variable with your message string
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov edx, 13 ; number of bytes to write - one for each letter plus 0Ah (line feed character)
|
||||
mov ecx, msg ; move the memory address of our message string into ecx
|
||||
mov ebx, 1 ; write to the STDOUT file
|
||||
mov eax, 4 ; invoke SYS_WRITE (kernel opcode 4)
|
||||
int 80h
|
Reference in New Issue
Block a user