Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Function to find the largest numeric digit

find_largest_digit:

mov bl, byte [esi] ; Load first digit

.find_loop:

cmp byte [esi], 0 ; Check for null terminator

je .find_done ; If null terminator, exit loop

mov al, byte [esi] ; Load current digit

cmp al, bl ; Compare with largest digit found so far

jg .update_largest ; If greater, update largest digit

inc esi ; Move to next digit

jmp .find_loop

.update_largest:

mov bl, al ; Update largest digit

inc esi ; Move to next digit

jmp .find_loop

.find_done:

mov [largest_digit], bl ; Store largest digit

ret

You might also like