Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16f628A how to convert Hex to Decimal

Status
Not open for further replies.

Hakachukai

New Member
Does anyone know any good, simple way to do this?

I just need to take hex values and convert them to decimal for display purposes.

I'm hoping that there is a simple way to do it. I can think of a few not so simple... not efficient ways to do it. :eek:

Also... how can I multiply or divide a number by 1.8 ??? I need to do this for the conversion between DegC and DegF for my temperature readout.
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
I normally do this,
Code:
PutDecimal	clrf	Decimal100
Count100s	incf	Decimal100,F
		addlw	100h-.100;	-100
		btfsc	STATUS,C
		goto	Count100s
		addlw	.100
		clrf	Decimal10
Count10s	incf	Decimal10,F
		addlw	0f6h;		-10
		btfsc	STATUS,C
		goto	Count10s
		movwf	Units
		movfw	Decimal100
		addlw	2fh
		call	PutChar
		movfw	Decimal10
		addlw	2fh
		call	PutChar
		movfw	Units
		addlw	30h+0ah
		goto	PutChar

Call it with the value in W.

As for multiplying by 1.8, you don't. You multiply by 9 (shift left 3 times and add the original) and divide by 5. See Piclist for 8 bit divide code.

Mike.
 
Last edited:

Anekwudoh

New Member
converting binary to hex implies you to do the followings;
1.multiply the individual numbers by that given base i.e base 16.
2.raise their bases by begining from the last i.e.from zero to where ever the base has ended.
3.addup all the multiples by so doing a result is gotting
Good luck.
 

Hakachukai

New Member
So, I'm working on making a long hand multiplication routine for floating point numbers.

Is there a way that I can just reserve memory and have an indexable pointer to it?
Right now I'd like to use 17bit's of storage for each floating point number.

1 bit for sign
8 bits for the integer portion
8 bits for the fractional portion

That would allow me to have numbers between 1/128 and 255.9921875 ( + and - )

anyway... it's all pretty easy to do... I just need to figure out a way that I can index through the memory in a loop, instead of having to call my File reg's by name. I could do it even calling them by name... but it would be ugly and probably end up using more code space.
 

Pommie

Well-Known Member
Most Helpful Member
That is not floating point, that is known as fixed point.

To access your variables you use the FSR and INDF registers. Load FSR with the address of your variable and any read or writes to INDF will access the register pointed to by the FSR register.

Mike.
 

Hakachukai

New Member
Thanks! That will come in very handy!

Good point... floating point would kind of suggest that the point moves... and mine never does.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top