section .data
    array db 12, 36            ; 배열 데이터

section .bss
    gcd resd 1                ; gcd를 저장할 공간
    temp_divisor resd 1       ; temp_divisor를 저장할 공간
    buffer resb 10            ; 출력할 결과를 저장할 공간

section .text
    global _start

_start:
    ; 초기 값 설정
    mov dword [gcd], 1
    mov dword [temp_divisor], 2

gcd_loop:
    mov eax, [temp_divisor]
    movzx ebx, byte [array]
    cmp eax, ebx
    jg end_gcd_loop

    movzx ecx, byte [array+1]
    cmp eax, ecx
    jg end_gcd_loop

    mov edx, 0
    mov eax, ebx
    div dword [temp_divisor]
    cmp edx, 0
    jne gcd_index_increase

    mov edx, 0
    mov eax, ecx
    div dword [temp_divisor]
    cmp edx, 0
    jne gcd_index_increase

    ; gcd = temp_divisor
    mov eax, [temp_divisor]
    mov [gcd], eax

gcd_index_increase:
    ; temp_divisor += 1
    add dword [temp_divisor], 1
    jmp gcd_loop

end_gcd_loop:
    mov eax, [gcd]
    lea rsi, [buffer + 10]  
    mov byte [rsi], 0       

convert_to_string:
    dec rsi
    xor edx, edx
    mov ebx, 10
    div ebx
    add dl, '0'
    mov [rsi], dl
    test eax, eax
    jnz convert_to_string

    mov rdx, buffer + 10
    sub rdx, rsi

    mov rax, 1             
    mov rdi, 1             
    mov rsi, rsi            
    syscall

    mov rax, 60            
    xor rdi, rdi          
    syscall

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: