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.

math assembler functions

Status
Not open for further replies.

Ilia Gildin

Junior Member level 3
Joined
Sep 27, 2014
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
hello
I need to convert 10 bits and more binary numbers to decimal numbers in order to show them in the LCD (In C its a lot easier as you can just make it as 1*2^10+1*2^9.....) how can I make a similar line in assembler and to make the number like 4096 to be '4' '0' '9' '6' in order to write it again in C I can simply divide and use mod but how to make assembler to do the job
 

Take C function like this:
Code:
void uLongToStr (unsigned long Value, char * String)
{
  char zero=0;
  char tmp=0;
  unsigned long cnt=1000000000;
  while (cnt!=1)
  {
    while (Value>=cnt)
    {
      Value-=cnt;
      tmp++;
    }
    if (tmp) zero=1;
    if (zero) * String++ = tmp+48;
    tmp=0;
    cnt/=10;
  }
  * String = Value+48;
}
Compile it and see assembler listing ))) This is not more funny that use assembler today.
 

If value is 12 then you split it into 1 and 2 and add 48 to each to convert to ascii character and then send the converted data to LCD.
 

hi,
This assembler bin to ASCII works OK. You need ASCII characters for the LCD display.
Change the .txt extension to .asm

E
 

Attachments

  • Bin2Asc1.txt
    2.6 KB · Views: 43

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top