어셈블리어로 반복문 구현하기
nano loop.s 로 파일 하나 만들어주자
section .data
msg db "A"
section .text
gloabl _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 1
syscall
mov rax, 60
syscall
하고 파일로 만들어주고 실행하게되면 A를 출력한다
section .data
msg db "A"
section .text
gloabl _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 1
mov r10, 1
again:
cmp r10, 100
je done
syscall
mov rax, 1
inc r10
jmp again
done:
mov rax, 60
mov rdi, 0
syscall
cmp는 compare함수로 두개를 비교하는 함수
je done에서 je는 둘이 동일할 때를 의미 즉 동일하면 done이라는 함수로 이동
inc r10은 r10에 1씩 더하는 것
jmp again은 다시 함수를 반복시키는 것