"Don't tell me how hard you work. Tell me how you get done."
- James J. Ling

Convert Binary to Hexadecimal

August 25, 2006

lea si, input
xor cx,cx

mov cl, 4

check:
    mov ah, 00
    int 16h

    cmp al, ‘0′
    jb check
   
    cmp al, ‘1′
    ja check
   
    mov [si], al
    inc si
   
loop check

call convert
   

int 20h

input db 5 dup (’$')

;——————–convert——————–
convert:

    dec si

    mov ah, 09
    lea dx, input
    int 21h
   
    mov ah, 02h
    mov dl, 0ah
    int 21h
    mov dl, 0dh
    int 21h
   
    xor bx,bx
    mov cl,0

    xxx:

    mov al, [si]        ; al contains character not value
    sub al,30h          ; convert to value

    shl al, cl
    add bl,al

   
    dec si
    inc cl
   
    cmp cl,4
    jne xxx

   
    add bl,30h        ; 0-9

    cmp bl,’9′       
    jbe print

    add bl, 7h        ; A-F   

print:
    mov ah, 02
    mov dl,bl
    int 21h
   
ret

Posted by phengpheng at 4:18 pm | permalink

All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.

Add a comment








     

August 2006
M T W T F S S
« Jul   Sep »
 123456
78910111213
14151617181920
21222324252627
28293031  

About Me

A Computer Science graduate who is a fanatic in assembly, java, and j2me programming. Developed BlueVoice system (Direct Voice Communication in Mobile Phones), this system allows mobile users to experience FREE VOICE CALLS

Subscribe

Technorati
Bloglines

Tagboard

Jun Mark:

hoW tO creaTE a PrOGram thAT woULD oUTpuT ascii table???

Jun Mark:

pLZ anSwer mY qUEstions

cutieGurl:

how to convert binary to hexadecimal, decimal and octal?????????please. answer me??????????

mary ann:

kuya, ung binary to decimal converter nyo. mali man? ung sa mga compare mo. ung may 0,9,A,F etc… bad character lumalabaspls rep asap po. tnx

carol:

how to convert decimal to binary to octal and hexadecimal

Galwin:

been here!

galwin:

nice site. hope you could visit mine, too.

pathy:

FRIENDS FOREVER!! Miss you na!!!

ridvan:

aus, i seldom see lady programmers. hehe. keep it up. and oh yeah, i guess i saw you during the MICT Quiz Show held in cdo. :)
keep up the codes!

phengpheng:

I miss updating this blog… Sana may time and pc ako to learn new stuffs aside from my work…

support:

Congratulations, you’ve just completed the installation of this shoutbox.

pheng:

uy! you’re here again!

Jay:

Woooohhhh orange…sweat… nakakasilaw! hehe :)

jay:

tagboard flood hehe sensya… had nothing fun to do. :)

pheng:

jaaaaayyyyy….:) ketal man?:)

niel:

no spamming please :p hehehe joke lang jay.

Jay:

Uyyyyyy!!!! Grraaaaaaaiiiinnnneeee
:)
Sssshhhh, el sikret! :)
Niiiiiiiiiiiiieeeeeel
Sup dude!!!!
Paaaaaaaaaaaaaathy
Ketal!?

niel:

ei pheng! :D slick-elegant layout! love it!

yue:

phengpheng!

pheng:

ur welcome!:)

Leave a message ▼