Howdy, Stranger!

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

Categories

Beginner has question

Jr81Jr81 Member Posts: 16
I have to convert hex numbers to binary numbers. I was wondering would I use a look up table or is there another way to convert hex to binary. Such converting hex value to ascii and then ascii to binary. I must this using tasm based on the 8086.

Comments

  • programmerEXprogrammerEX Member Posts: 16
    : I have to convert hex numbers to binary numbers. I was wondering would I use a look up table or is there another way to convert hex to binary. Such converting hex value to ascii and then ascii to binary. I must this using tasm based on the 8086.
    :

    You don't need to have a table look up with this kind of prob. I had made a program for this before but I lost it. This only requires that you convert the ascii code being input on the console to its binary presentation and then applying a bit of math on it and then if you got that value you have to check the value of the result bit by bit and then output them accordingly. If you could find a book Advance Assembly Language by Holzner, I think there's a code included there related with that prob. When do you need this code? I'm willing to make you one. :)
  • Jr81Jr81 Member Posts: 16
    : : I have to convert hex numbers to binary numbers. I was wondering would I use a look up table or is there another way to convert hex to binary. Such converting hex value to ascii and then ascii to binary. I must this using tasm based on the 8086.
    : :
    :
    : You don't need to have a table look up with this kind of prob. I had made a program for this before but I lost it. This only requires that you convert the ascii code being input on the console to its binary presentation and then applying a bit of math on it and then if you got that value you have to check the value of the result bit by bit and then output them accordingly. If you could find a book Advance Assembly Language by Holzner, I think there's a code included there related with that prob. When do you need this code? I'm willing to make you one. :)
    :

    Hey thank you for your reply and your offer to write the code. But your suggestion was good enough for me as I was able to do the conversion by converting the ascii code to the binary equivalent.
    Thank you for your reply and your genorous offer.

  • humbleshumbles Member Posts: 2
    can you help me modify my code to have the ascii table convert to binary. i need it by wedsenday. here is my code
    .model small
    .stack 100h

    .data
    msg1 db ' Please Enter a character to be convert to binary. Press e for exit ' ,0dh, 0ah, ' $ '
    var1 db ?

    .code
    extrn clrscr:proc

    main proc

    mov ax, @data
    mov ds , ax

    call clrscr

    loop1:
    mov ah,9
    mov dx, offset msg1
    int 21h

    enternumber: ;just a label

    mov ah , 01h
    int 21h

    mov var1,al

    mov dx,3dh
    mov ah,06
    int 21h

    cmp var1, 65h
    jz fin
    cmp var1 , 41h


    sub var1, 30h
    sub var1, 08
    mov cl , 08

    call display

    sub var1, 04
    mov cl, 04

    call display

    sub var1, 02
    mov cl , 02

    call display

    sub var1, 0
    mov cl , 0

    call display

    jmp loop1

    letters:

    sub var1, 39h
    sub var1, 08
    mov cl , 08

    call display

    sub var1, 04
    mov cl, 04

    call display

    sub var1, 02
    mov cl , 02

    call display

    sub var1, 01
    mov cl , 01

    call display

    jmp loop1


    display proc

    sub var1, 01
    js send0

    mov dl , 31h
    mov ah, 06
    int 21h
    ret

    send0:
    mov dl , 30h
    mov ah , 06
    add var1 , cl
    int 21h
    ret

    display endp

    fin:

    mov ax,4c00h
    int 21h

    main endp
    end main
  • humbleshumbles Member Posts: 2
    can you help me modify my code to have the ascii table convert to binary. i need it by wedsenday. here is my code
    .model small
    .stack 100h

    .data
    msg1 db ' Please Enter a character to be convert to binary. Press e for exit ' ,0dh, 0ah, ' $ '
    var1 db ?

    .code
    extrn clrscr:proc

    main proc

    mov ax, @data
    mov ds , ax

    call clrscr

    loop1:
    mov ah,9
    mov dx, offset msg1
    int 21h

    enternumber: ;just a label

    mov ah , 01h
    int 21h

    mov var1,al

    mov dx,3dh
    mov ah,06
    int 21h

    cmp var1, 65h
    jz fin
    cmp var1 , 41h


    sub var1, 30h
    sub var1, 08
    mov cl , 08

    call display

    sub var1, 04
    mov cl, 04

    call display

    sub var1, 02
    mov cl , 02

    call display

    sub var1, 0
    mov cl , 0

    call display

    jmp loop1

    letters:

    sub var1, 39h
    sub var1, 08
    mov cl , 08

    call display

    sub var1, 04
    mov cl, 04

    call display

    sub var1, 02
    mov cl , 02

    call display

    sub var1, 01
    mov cl , 01

    call display

    jmp loop1


    display proc

    sub var1, 01
    js send0

    mov dl , 31h
    mov ah, 06
    int 21h
    ret

    send0:
    mov dl , 30h
    mov ah , 06
    add var1 , cl
    int 21h
    ret

    display endp

    fin:

    mov ax,4c00h
    int 21h

    main endp
    end main
Sign In or Register to comment.