Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Binary to BCD and BCD to Binary

Status
Not open for further replies.

Pagli007

Newbie level 3
Newbie level 3
Joined
Jul 1, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
33
Hey guys, I'm using a pic16F690 and I need assembly code for to convert an 8 bit binary to bcd and bcd to binary. I have to use the w register. Also, I only want to display numbers from 0 - 99, how do I write a default or error message in mplab? Thanks for the help :)
 

The project requires the production of two conversion modules to convert either way between 8 bit Binary Code and BCD code.

The two modules will be implemented as assembly code functions that receive the input value in the W register and exits with the result in the same W register.

The main emphasis here is to get MPLAB X configured and running on your workstations and to get to understand the PIC instruction set. You can find datasheets on the course website or online.

Also important however is that you decide on a decent code template and use it for both routines. You must also pay very close attention to comments and code development.
 

Hey guys, I'm using a pic16F690 and I need assembly code for to convert an 8 bit binary to bcd and bcd to binary. I have to use the w register. Also, I only want to display numbers from 0 - 99, how do I write a default or error message in mplab? Thanks for the help :)

Here is a simple code you can use !

unsigned char BCD2Bin(unsigned char data)
{
return ((((data & 0xF0 )>>4) * 10) + (data&0xF));
}

unsigned char D2BCD(unsigned char data)
{
return (((data/10)<< 4) | (data%10));
}

Regards,
Raady.
 
Hey Raady, thank you so much :)
Unfortunately, I found out that the entire thing has to be in asm, but I will keep this for future reference, thank you :)
 


Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top