Files
assembly/x86_64/3_homework_highest.asm

35 lines
646 B
NASM

global _start
; Program that finds the highest number in the byte array declared below
section .data
data: db 0, 15, 57, 2, 43, 87, 2
dataSize: equ 7
section .bss
section .text
_start:
xor rbx, rbx
xor rcx, rcx
mov rax, 1 ; iterator value
mov cl, byte [data] ; default value for the result
loop_start:
cmp rax, dataSize
jge loop_end
mov bl, byte [rax + data] ; load next candidate
cmp cl, bl ; compare to (default) value
jge loop_inc ; skip if cl >= bl
mov cl, bl ; set higher value
loop_inc:
inc rax
jmp loop_start
loop_end:
mov rax, 60
mov rdi, rcx ; return the highest number as exit code
syscall