0

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 ??

ledoux
  • 91
  • 9
  • You have to convert a number to a string before you can display it. – Michael Petch Jul 14 '19 at 20:16
  • yes i try to convert it like this : `mov [length] , ax mov si , length ` but nothing has done – ledoux Jul 15 '19 at 22:38
  • yes , @MichaelPetch , i try to divide each number by 10 and add 0x30 and conserve all in the array . – ledoux Jul 16 '19 at 12:10
  • There are several problems with your conversion loop. First you are resetting CX to 0 in your loop, so the effect of `INC CX` is lost. Then the `DIV 10` instruction is changing AX. For example, if AX = 12, `DIV 10` will make AH = 2 and AL = 1 and therefore AX will be 0x21 or 33 decimal when the loop repeats. You need to set AH to 0 to avoid this. You should try out the code in a debugger. This is *very* helpful for programming in assembly especially. – pcarter Jul 16 '19 at 12:38
  • Correction, AX would not be 0x21 above, it would 0x0201 or 513 decimal since the 16-bits of AX is the combination of the two 8-bit registers, AH and AL. – pcarter Jul 16 '19 at 12:45
  • There is no `DIV` that takes immediate value like `10` and does division. You can't mov one memory operand to another in the same instruction so this isn't valid `mov byte [buffer_string+cx] , byte [bx]` . In 16-bit mode CX can't be used to form part of a memory operand so `[buffer_string+cx]` isn't even valid. You can use BX, SI, DI. You can use BP but the default segment is SS not DS. – Michael Petch Jul 16 '19 at 13:31

1 Answers1

0

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

ledoux
  • 91
  • 9