Howdy, Stranger!

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

Categories

base convert

biranbiran Member Posts: 3
hi expertise,
how to convert decimal to hexa.
i did like this.

mov ax,12d ;ax=12 decimal
mov ah, 6 ; for output
mov dl, ax ;dl=ax
int 21h

but not work

please help me with example


Comments

  • 3y3ty3y3ty Member Posts: 15
    Simply to convert the binary value in memory,
    into the printable ascii values,
    one has but to
    bit shift the operand by 4 to the right and left
    for the low half-byte operand << 4 : operand >> 4,
    and to the right 4 bits to get the high half-byte.
    It is then used as and index into a string of printable
    characters.

    Here is an example using runtime code modification:
    jmp whocares
    therewego db '0123456789ABCDEF'
    ; get low half-byte....
    whocares:
    mov ah,101 ; move the decimal value 101 into AH
    mov cx,2
    doagain:
    rtcm db 088h,0E0h ; optionally move ah into al
    ; and vice versa
    ; using runtime code modification
    xor byte [rtcm],2 ; Change destination bit
    cmp cx,2
    je skip_bits_dot
    shl ah,4 ; bitshift left by 4
    skip_bits_dot:
    shr ah,4 ; bitshift right by 4
    mov dx,0
    mov dl,ah
    mov si,dx ; put into index register
    mov bx,offset therewego
    mov dl,[bx+si]
    push ax
    mov al,dl
    int 29h
    pop ax
    dec cx
    jcxz leaving_please
    jmp doagain
    leaving_please:
    mov ax,4c00h
    int 21h

Sign In or Register to comment.