section .data
    buf db 0, 0     ; 最大2桁 → 2バイト確保

section .text
    global _start

_start:
    ; ---- 例: rax = 42 ----
    mov rax, 2
    imul rax, 2
    imul rax, 2
    imul rax, 2
    imul rax, 2
    imul rax, 2

    ; --- 10で割って「十の位」と「一の位」に分解 ---
    mov rbx, 10
    xor rdx, rdx     ; div の前は rdx = 0(重要)
    div rbx          ; rax ÷ 10 →  rax = 商,  rdx = 余り

    ; 商 → 十の位
    add al, '0'
    mov [buf], al

    ; 余り → 一の位
    add dl, '0'
    mov [buf+1], dl

    ; --- 出力(2文字) ---
    mov rax, 1
    mov rdi, 1
    mov rsi, buf
    mov rdx, 2
    syscall

    ; exit
    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: