binary to decimal - NEW OS

I made this tiny program but failed (where?) or is there someone that post another method? (NON DOS METHOD PLEASE):

compile: nasm boot.asm -f bin -o boot
usage:
insert a formatted floppy
debug boot
-w 100 0 0 1
-q
and reboot your computer with the floppy


; this program is a boot program that tryes to print a number
; in the screen (in this case 220), waits for a keypress and
; reboot
START:
MOV AX,0x0003
INT 0x10

MOV DX, number
ADD DX, 0x7C00
MOV CX, MSG
ADD CX, 0x7C00
CALL SET_NUMBER ; [DX]->[CX]

CALL PRINT_STRING

JMP WAIT_FOR_KEY_PRESS

PRINT_STRING:
MOV AX,0x1301
MOV BX,0x0007
MOV CX,0x23

MOV BP,MSG
ADD BP,0x7C00

INT 0x10

RET

WAIT_FOR_KEY_PRESS:
MOV AH,0x00
INT 0x16

REBOOT:
DB 0xEA
DW 0x0000
DW 0xFFFF

SET_NUMBER:
MOV BX, DX
MOV AX, [BX]
MOV BH, 10
MOV BL, '0'
MOV DX, 0

START_NUMBER:
DIV BH
ADD AH, BL
PUSH AX
INC DL
MOV AH, 0
CMP AL, 0
JNZ START_NUMBER

SET_STRING_NUMBER:
ADD CX, DX
MOV BX, CX
MOV AL, 0
MOV [BX], AL

POP_NUMBER:
DEC BX
POP AX
MOV [BX], AH
DEC DX
CMP DX, 0
JNZ POP_NUMBER

END_NUMBER:
RET


number DB 220
MSG DB 0,0,0,0,0,0,0,13,10,0

TIMES 510-($-$$) DB 0

SIGNATURE DW 0xAA55



Comments

  • I fixed it

    START:
    MOV AX,0x0003
    INT 0x10

    MOV DX, number
    ADD DX, 0x7C00
    MOV CX, MSG
    ADD CX, 0x7C00
    CALL SET_NUMBER ; [DX]->[CX]

    CALL PRINT_STRING

    JMP WAIT_FOR_KEY_PRESS

    PRINT_STRING:
    MOV CX,BX
    MOV AX,0x1301
    MOV BX,0x0007

    MOV BP,MSG
    ADD BP,0x7C00

    INT 0x10

    RET

    WAIT_FOR_KEY_PRESS:
    MOV AH,0x00
    INT 0x16

    REBOOT:
    DB 0xEA
    DW 0x0000
    DW 0xFFFF

    SET_NUMBER:
    MOV BX, DX
    MOV AX, [BX]
    MOV BH, 10
    MOV BL, '0'
    MOV DX, 0

    START_NUMBER:
    DIV BH
    ADD AH, BL
    PUSH AX
    INC DL
    MOV AH, 0
    CMP AL, 0
    JNZ START_NUMBER

    SET_STRING_NUMBER:
    MOV BX, CX
    POP_NUMBER:
    POP AX
    MOV [BX], AH
    INC BX
    DEC DX
    CMP DX, 0
    JNZ POP_NUMBER
    MOV WORD [BX],$0a0d
    SUB BX,MSG+$7bfe
    END_NUMBER:
    RET


    number DB 220
    MSG DB 0,0,0,0,0,0,0,13,10,0

    TIMES 510-($-$$) DB 0

    SIGNATURE DW 0xAA55


  • It didnt work, the screen is empty :(, maybe because the stack is bad (not) initialized

    Please, someone help us




  • : It didnt work, the screen is empty :(, maybe because the stack is bad (not) initialized
    :
    : Please, someone help us
    :
    :
    :
    :
    It Worked for me

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories