print a number

Hell guys,
I need some help, how i can print a value stored in a register,e.g

mov bx,246

how i can print this value 246.
thanks,

PUNJABIAN263

Comments

  • this prints the hex velue of DX if you want to print a difernt register besides DX just move it to DX then call this routine

    print_hex:
    mov cx, 4
    print_digit:
    rol dx, 4
    mov ax, 0x0E0F
    and al, dl
    add al, 0x90
    daa
    adc al, 0x40
    daa
    int 0x10
    loop print_digit
    ret
  • Hello lordblix,
    Please tell me how it excutes as line by line,
    thanks,

    PUNJABIAN263

  • print_hex:
    mov cx, 4 ; print 4 digits
    print_digit:
    rol dx, 4 ; rotate so the number to print is in the low part of dl
    mov ax, 0x0E0F ; ah = TTY print character Video service, al = number mask
    and al, dl ; mask dl into al
    add al, 0x90 ; 4 instruction hex to ascii conversion
    daa
    adc al, 0x40
    daa
    int 0x10 ; call video service ah is already pointing to tty print character
    loop print_digit ; get next character
    ret ; return to calling program
  • title check
    .model small
    .stack 100h
    .code
    main proc
    mov ax,@data
    mov ds,ax
    mov dx,45
    print_hex:
    mov cx, 4
    print_digit:
    rol dx,4
    mov ax, 0x0E0F
    and al, dl
    add al, 0x90
    daa
    adc al, 0x40
    daa
    int 0x10
    loop print_digit
    mov ah,4c00h
    int 21
    main endp
    end main

    I have write this program but it gives error messages

    print.asm(21): error A2070: invalid instruction operands
    print.asm(13): error A2206: missing operator in expression
    print.asm(15): error A2206: missing operator in expression
    print.asm(17): error A2206: missing operator in expression
    print.asm(19): error A2206: missing operator in expression

    and 1 more thing
    the instructions daa what its mean
    thanks

  • on line 21 change ah to ax im not sure what the rest of the errors are what assembler are you using the code i originaly posted was written in nasm and daa is decimal adjust al after addition
  • i am using masm6.1 version
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