Search code examples
assemblynasmx86-16bootloaderosdev

how can i display a number in my boot sector


I'm trying to display a number on my boot, but nothing is displayed. In fact I'm trying to determine the memory size from int 12h, have I done something not normal?

that's my boot code :

    bits 16
    org 0x0

    jmp start

    %include "display.INC"

    start : 
        mov ax , 0x07c0
        mov ds , ax
        mov es , ax

        mov ax , 0x8000
        mov ss , ax
        mov sp , 0x7000

        int 12h
    mov cx , 0
    call digit
    mov si ,  buffer_string 
    call afficher

digit : 
    div 10
    test al , 0
    jz end_digit
    mov bx , al
    add bx , 0x30
    mov byte [buffer_string+cx] , byte [bx]
    inc cx
    jmp digit

end_digit : ret

    end :
        jmp end

    times 510-($-$$) db 144
    dw 0xaa55

And there is the file to display :

afficher :
    push ax
    push bx

debut :
    lodsb
    cmp al , 0
    jz fin
    mov ah ,0x0e
    mov bx  ,0x07
    int 10h
    JMP debut

fin :
    pop bx
    pop ax
    ret

Can you help me please ??


Solution

  • I found what I needed, see above .

    bits 16
    org 0x0
    jmp start
    %include "display.INC"
    start : 
        mov ax , 0x07c0
        mov ds , ax
        mov es , ax
    
        mov ax , 0x8000
        mov ss , ax
        mov sp , 0x7000
    
        int 12h
        mov bx, 10
        mov di, tab
        mov si, reste
        xor cx, cx
    digit:
        xor dx, dx
        div bx
        cmp ax, 0
        jz copystr
        add dx, 0x30
        mov byte [si], dl
        mov dx, ax
        xchg ax, dx
        inc cx
        inc si
        jmp digit
    copystr:
        dec cx
            dec si
            mov al, byte [si]
            mov byte [di], al
            inc di
            cmp cx, 0
            jnz copystr
    end:
        mov byte [di], 0
        mov si , tab
        call afficher
    end_boot :
        jmp end_boot
    tab times 30 db 0
    reste times 30 db 0
    
    
    times 510-($-$$) db 144
    dw 0xaa55
    

    I wait some suggestion