# converting from hex to 7segment

Heya all
is there any way (sure shot) to convert a hex value to 7 segment
say for eg. i get the sytem date and it stores it in dx in hex (11/25 stored as 0B19) i would need each digit in the date as a sep 7seg code..
Thnx ppl!
Tyron

• : Heya all
: is there any way (sure shot) to convert a hex value to 7 segment
: say for eg. i get the sytem date and it stores it in dx in hex (11/25 stored as 0B19) i would need each digit in the date as a sep 7seg code..
: Thnx ppl!
: Tyron
[green]
I take it your using INT 21h function AH=2Ah returning
DH = month
DL = day
I don't understand your question, DH or DL returned isn't returned in hex form.
It's just a value, which you can print in an ASCII hex form,
but you don't say your trying to print it to the screen or memory.
There is no 7 segment or segment 7 & numbers aren't divided into segments.
Are you looking for a procedure that will print the value in a register to the screen in ASCII hex form ?
What assembler are you using ?
What opperateing system are you using ?
[/green]

• : : Heya all
: : is there any way (sure shot) to convert a hex value to 7 segment
: : say for eg. i get the sytem date and it stores it in dx in hex (11/25 stored as 0B19) i would need each digit in the date as a sep 7seg code..
: : Thnx ppl!
: : Tyron
: [green]
: I take it your using INT 21h function AH=2Ah returning
: DH = month
: DL = day
: I don't understand your question, DH or DL returned isn't returned in hex form.
: It's just a value, which you can print in an ASCII hex form,
: but you don't say your trying to print it to the screen or memory.
: There is no 7 segment or segment 7 & numbers aren't divided into segments.
: Could you clearify your question.
: Are you looking for a procedure that will print the value in a register to the screen in ASCII hex form ?
: What assembler are you using ?
: What opperateing system are you using ?
: [/green]
:
:
[blue] yes iam using the int21H, heres the dilema.. i need to display the current date on 4 x seven segment . the ony way the 7 segs will display the date is if it is 7seg code that is 0 = 3fH, 1 = 6H, 2= 5BH and so on.... heres how the above values come
for 0,
0 g f e d c b a
0 0 1 1 1 1 1 1 = 3FH
so i need a way to convert the hex i reviece into this 7 seg code so that i can display them on the leds
x86/x88 assembler
[/blue]
Tyron
• : Heya all
: is there any way (sure shot) to convert a hex value to 7 segment
: say for eg. i get the sytem date and it stores it in dx in hex (11/25 stored as 0B19) i would need each digit in the date as a sep 7seg code..
: Thnx ppl!
: Tyron
:
[yellow] i think i found a way.. but its real long kinda.. involves converting hex to decimal and then to 7 seg code.... not to long i hope.. but thats the only method i know i can think of rite now...
[/yellow]

• for what i understand you want to put a value in a display with 7 segments like the calculater :

my sugestinon is this , you have 7 leds , the leds could be on or off
so this means that you can representate this with a byte .
Now you can do a table whit the codes for all your digits .
eg: for hexnumber you can do this table

_0_
5|_6_|1
4|_3_|2 bit 6..0 , dont need bit 7

now correspond every segement to a bit in the byte and you do this table :

hexTable byte 00111111b -> code for '0'
byte 00000011b -> 1
...
byte 01111000b -> "F"

• : for what i understand you want to put a value in a display with 7 segments like the calculater :
:
:
: my sugestinon is this , you have 7 leds , the leds could be on or off
: so this means that you can representate this with a byte .
: Now you can do a table whit the codes for all your digits .
: eg: for hexnumber you can do this table
:
: _0_
: 5|_6_|1
: 4|_3_|2 bit 6..0 , dont need bit 7
:
: now correspond every segement to a bit in the byte and you do this table :
:
: hexTable byte 00111111b -> code for '0'
: byte 00000011b -> 1
: ...
: byte 01111000b -> "F"
:
[red] thats what i will be doing using xlat .. but i wont be doing that for hex to 7 seg code but i will need to convert the hex to decimal and then to 7seg code.. coz i dont want the date to dipayed in hex format rather i want it in deciamal format and the in21h, ah = 2ah gives it to me in hex :-)
any i was wonder if there was any shorter method rather than this long one...
thnx
Tyron[/red]

• any ones got hex to dec converter? consider the hex value is already in dx :-)
thnx tyron
• : any ones got hex to dec converter? consider the hex value is already in dx :-)
: thnx tyron
[green]
Convert ASCII hex to value, then convert value to ASCII decimal & print.
I made a Nasm environment help thingie fer beginners, & in
C:NASMINC16 there are lots of converters and other procedures.
http://bitdog.home.att.net/files/nasmenv.zip
and look through the directory. Hopefully you will find lots of stuff that should easily convert to your assembler since it's basicly simplifyed commented include files.
Look for GMEMHEX.INC GINNUM.INC GMEMDEC.INC WRITDIGT.INC WRITHEX.INC
stuff like that. G=Get W=Write MEM=MEMory DEC=DECimal HEX=HEXidecimal INC=INClude proc's, etc.

Also you can do a string search through old posts using the advanced search to the left. Everything you want is probably already in a post here.

Bitdog
[/green]

• Thnx bitdog...
i found a better way to convert, since what i wanted were stored in each 1/2 of a register all i had to do was play around with just those register and i need not convert seems to have worked qute well... thnx tho!
Tyron

#### Howdy, Stranger!

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