🚚 Moves from gnu assembler to netwide assembler
This commit is contained in:
parent
5acba466b4
commit
0190a14bd8
2
build.sh
2
build.sh
@ -2,6 +2,6 @@
|
||||
|
||||
gcc main.c -o a.out
|
||||
|
||||
gcc -c main.s -o b.o
|
||||
nasm -f elf64 main.s -o b.o
|
||||
ld b.o -o b.out
|
||||
rm b.o
|
||||
|
48
main.s
48
main.s
@ -1,18 +1,38 @@
|
||||
.global _start
|
||||
SYS_EXIT equ 0x1
|
||||
SYS_READ equ 0x3
|
||||
SYS_WRITE equ 0x4
|
||||
|
||||
STDIN equ 0x0
|
||||
STDOUT equ 0x1
|
||||
STDERR equ 0x2
|
||||
|
||||
section .data
|
||||
inputMsg db "> ", 0x0
|
||||
inputLen equ $ - inputMsg
|
||||
|
||||
section .bss
|
||||
char resb 1
|
||||
exitCode resb 1
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
.text
|
||||
_start:
|
||||
mov $1, %rax
|
||||
mov $1, %rdi
|
||||
mov $msg, %rsi
|
||||
mov $len, %rdx
|
||||
syscall
|
||||
mov r8, 0
|
||||
mov [exitCode], r8
|
||||
|
||||
mov $60, %rax
|
||||
mov $0, %rdi
|
||||
syscall
|
||||
mov rax, SYS_READ
|
||||
mov rbx, STDIN
|
||||
mov rcx, input
|
||||
mov rdx, 64
|
||||
int 0x80
|
||||
|
||||
.data
|
||||
msg:
|
||||
.ascii "Hello, world!\n"
|
||||
len = . - msg
|
||||
;mov rax, SYS_WRITE
|
||||
;mov rbx, STDOUT
|
||||
;mov rcx, inputMsg
|
||||
;mov rdx, inputLen
|
||||
;int 0x80
|
||||
|
||||
mov rax, SYS_EXIT
|
||||
mov rbx, [exitCode]
|
||||
int 0x80
|
||||
|
Loading…
x
Reference in New Issue
Block a user