hi,
I'm trying to complete my project in assembly 8051 , and thanks to all of you I completed the 1st phase
now I'm stuck in the 2nd phase
I should convert a number to its letters --->> for example if I put R3 = #31 it should print thirty one
I know I had to make an arrays:
1. single digit (one to nine)
2. double digit (eleven to nineteen)
3. tens digit (ten , twenty, thirty, ..........., ninety)
since the range from 1 - 99
and I know this function involve with division , but I don't know how to begin with it and check for each state
I need an explanation for the procedures ---> so please don't think I came here just to have the code
if the code is provided it will help alot, but if not it's ok since I need to understand it
Hi Greital! I try to help but you don't seem to give feedback!! You didn't respond to my last help... There are exmples in my article list... R3 = #31 will only print ascii '1' if you are in hex radix otherwise use R3 = #31h or R3 = #0x31..
As for printing ascii representation of numbers.. Take 0~999:
out (number / 100) + 0x30
out (number%100)/10 + 0x30
out (number % 10)
% = modulus.... When dividing AB.. A holds the Number and B holds the modulus!!
I'm really sorry for that, I just saw it after your reply to this thread
alot of things I need to do at the same time --->>> I hope you can accept my apology
thanks for your reply
I know I should divide and A holds the number an B the remain (module)
but what is the next step , how I can pick a specific string from the ROM of the specific number I put in R3 for example
please any help is appreciable and forgive me for what happen last time
thanks for your reply, appreciate it
in this phase I have to show a number stored in R3 for example as letters
for example if I put R3=#31 ---> it should print thirty one in the LCD -->> I don't know how to generate the letters out of the numbers that's my problem
in your code, which part is involved getting the letters from the ROM for the number provided ??
Hi,
In the code results are stored in R1 (tens) and R2,(units) all are in ASCII format it is not numerical i.e., R1 holds #35 and R2 holds #36 ( it is not 5 tens and 6 units) in the ASCII table 0 to 9 equals to 30 to 39 in the ASCII format. Now if you already made LDC initialization, it is very easy to show content of R1,R2 LCD like this
MOV LCD_data_port,R1 ; tens first
MOV LCD_data_port,R2 ; the units first
the above data transfer only as data not as command