section .bss
digitSpace resb 100
digitSpacePos resb 8
section .text
global _start
_start:
mov rax, 123
call _printRAX
mov rax, 60
mov rdi, 0
syscall
_printRAX:
mov rcx, digitSpace
mov rbx, 10
mov [rcx], rbx
inc rcx
mov [digitSpacePos], rcx
_printRAXLoop:
mov rdx, 0
mov rbx, 10
div rbx
push rax
add rdx, 48
mov rcx, [digitSpacePos]
mov [rcx], dl
inc rcx
mov [digitSpacePos], rcx
pop rax
cmp rax, 0
jne _printRAXLoop
_printRAXLoop2:
mov rcx, [digitSpacePos]
mov rax, 1
mov rdi, 1
mov rsi, rcx
mov rdx, 1
syscall
mov rcx, [digitSpacePos]
dec rcx
mov [digitSpacePos], rcx
cmp rcx, digitSpace
jge _printRAXLoop2
ret
compile:
nasm -f elf64 test.asm -o test.o
ld test.o -o test
vi test.asm
_start:
mov rax, 변경한다. 1339
call _printRAX
compile:
nasm -f elf64 test.asm -o test.o
ld test.o -o test
댓글 없음:
댓글 쓰기