Page 1 of 1

Need help for a project to an assembly emulator!!!!!!HELP!!!

Posted: Thu Dec 11, 2003 1:00 am
by toni
Sorry for the inconvinience.I need to do this project till Thursay night.The project is the following

>>
Build a program in machine language 6502.
You put a date in a specific address (dd-mm-yy)(3 byte,the year
must be two digits and>2000)and one number of days as 16bit
number in a specific address and will calculate the date that
results in form(dd-mm-yy) if add in the first date the days that we
put.
Months have 30 days and years have 365 days.The result must be
put in specific addresses.
<<

I must build this project to a 6502 assembly emulator.
I need your help!!!It is very important for me and i believe that you have the knowledge to help me.
With respect

Toni

Posted: Thu Dec 11, 2003 7:25 am
by GARTHWILSON
To avoid clutter in the forum archives that will be referred back to for years, please don't start a new subject every time you want to post with more on the same subject. Thanks.

What Mike no doubt meant in his response to your first post was that we're happy to help, but we don't want to just do everyone's homework for them. Go ahead and start, and ask questions when you get stumped, showing what you have so far. If I understand you right, you want to take a date, add some number of days to it, and tell what the resulting date is.

As for helps to get you started-- There are several ways you could do this. Actually putting the right number of days in each month is not too big a deal either. But one way you might approach your assignment is to first convert the initial date to a number of days past 12/31/99. If you're not ready for multiplication and division routines yet, you could do it this way:
1. Set up a 16-bit variable and initialize it as 0.
2. Set up a loop to add 365 ($16D) for each year,
3. another loop to add 30 ($1E) days for each month past January,
4. and then add the day of the month to get the number.
5. Now add the number of days you want to advance it, to get another 16-bit number.
That result will need to be converted back to a date.
6. Set up another loop to count how many times you can subtract 365 without going negative. That's the year.
7. Set up another loop to count how many times you can subtract 30 from the retult without going negative. That, plus one, is the month.
8. Then the remainder, plus one, is the day of month.

You'll generally use the X register as a loop index.

We're glad to see that there are many schools teaching microprocessors and assembly language using the 6502. It has an excellent power-to-complexity ratio, and is going into modern products at the rate of about 200,000,000 per year-- far more than twenty years ago.

Posted: Thu Dec 11, 2003 8:05 am
by bogax
and you might want to ask yourself what month does (for example) the
363 day of the year fall into.

Posted: Thu Dec 11, 2003 4:35 pm
by Nightmaretony
That approach works for the 30 days only per month rule. If it was for a real date calculator, I would have used index table for the monthly amounts, and a calculation for leap year...