Compare commits
4 Commits
22f1cae833
...
testing
| Author | SHA1 | Date | |
|---|---|---|---|
| 5709c50700 | |||
|
33175e2c19
|
|||
|
5685ac6e67
|
|||
|
3360f1976c
|
1
Makefile
1
Makefile
@@ -1,6 +1,7 @@
|
||||
.PHONY: all clean
|
||||
|
||||
SRC := $(wildcard *.asm)
|
||||
SRC := $(filter-out functions.asm, $(SRC))
|
||||
OBJDIR := build
|
||||
OBJS := $(SRC:%.asm=$(OBJDIR)/%.o)
|
||||
BINS := $(SRC:%.asm=$(OBJDIR)/%)
|
||||
|
||||
0
functions.asm
Normal file
0
functions.asm
Normal file
@@ -1,17 +1,22 @@
|
||||
; 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
|
||||
; %include 'functions.asm'
|
||||
|
||||
SECTION .data
|
||||
msg db 'Hello World!', 0Ah ; assign msg variable with your message string
|
||||
SYS_EXIT equ 1
|
||||
SYS_WRITE equ 4
|
||||
STDOUT equ 1
|
||||
|
||||
SECTION .text
|
||||
section .data
|
||||
msg db "Hello, world!", 0Ah
|
||||
|
||||
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
|
||||
mov edx, 14
|
||||
mov ecx, msg
|
||||
mov ebx, STDOUT
|
||||
mov eax, SYS_WRITE
|
||||
int 0x80
|
||||
|
||||
mov ebx, 0
|
||||
mov eax, SYS_EXIT
|
||||
int 0x80
|
||||
|
||||
Reference in New Issue
Block a user