6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 08, 2024 11:51 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Wed Dec 10, 2003 12:38 pm 
Offline

Joined: Wed Dec 10, 2003 12:23 pm
Posts: 4
I need your help!I would like someone to give me the code of this program as soon as possible!The program is:

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.

Thans all very much!
I appreciate you help!

My email address is tomofrcu@hotmail.com


Top
 Profile  
Reply with quote  
 Post subject: Homework Help
PostPosted: Wed Dec 10, 2003 11:24 pm 
Offline
Site Admin
User avatar

Joined: Fri Aug 30, 2002 1:08 am
Posts: 280
Location: Northern California
Hi,

Send us your program so far and we'll be happy to help you debug it.

Regards,
Mike

_________________
- Mike Naberezny (mike@naberezny.com) http://6502.org


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 11, 2003 7:02 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I had gotten this email from Pantelis about this program.

Please my friend help me!I must give this project tomorrow!I dont know
to
use the commands of
assembly.I really ask you if you can do the project and send me the
solution.Then i would have much
time to study it and understand how it works.I know the thing that i
ask you
is too difficult but you
are my last chance.Thank you very much.
With respect
Pantelis

This is not a good sign. Dude, you SHOULD be cracking the books and understanding.

Out of pity, I will give you a program. I MUST WARN YOU that you MUST learn how it works. Crack open those books, because the teacher WILL be looking for your knowledge for thse class, and if you dont have the knowledge, it will hurt you.

; Program by Pantelis
; date code
; done by www.6502.org

DateTableOut = $00
ResultCode = $01


.ORG $2000
LDY #$00 ; data counter
Loop LDA Datatable, y ; Get the data
STA DateTableOut ; place answer where needed
INY
CMP #$FF
BNE Loop
STA ResultCode ; store the results here
RTS

Datatable ; This is the data table for the system used.
.DB $c4, $c5, $c1, $d2, $a0, $d4, $c5, $c1, $c3, $c8, $c5, $d2, $ba
.DB $d0, $c1, $ce, $d4, $c5, $cc, $c9, $d3, $a0
.DB $c7, $cf, $c5, $d3, $a0, $d4, $cf, $d7, $d7, $d7, $b6, $b5, $b0, $b2, $ae, $cf, $d2, $c7
.DB $d4, $cf, $a0, $c7, $c5, $d4, $a0, $cf, $d4, $c8, $c5, $d2, $d3, $a0, $d4, $cf
.DB $c4, $cf, $a0, $c4, $cf, $a0, $c8, $c9, $d3, $a0, $c8, $cf, $cd, $c5, $d7, $cf, $d2, $cb
.DB $c6, $cf, $d2, $a0, $c8, $c9, $cd, $ae
.DB $d0, $cc, $c5, $c1, $d3, $c4, $a0, $d4, $c1, $cb, $c5, $a0, $c1, $c3, $d4, $c9, $cf, $ce
.DB $c1, $c3, $c3, $cf, $d2, $c4, $c9, $ce, $ce, $c7, $cc, $d9, $ae
.DB $d4, $c8, $c1, $ce, $cb, $a0, $d9, $cf, $d5



So get to those books. As an alternate, on this website is all the commands and various examples of things.
Good luck. You will need it.

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 12, 2003 7:33 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Private message time reply to the program:

What is the datatable;
what is the .ORG and .DB;
Please if you can explain me in english what you do;
Thanx for your help!!!!!!!!!!!!
i appreciate!!!!!

Are all the emulators the same or not;
I have an emulator from patras university.I can send it to you if you can.


The .org is the origin command. IT is optional, but I prefer starting form $2000 for my programs. For my SBC, it all begins much higher since the eprom begins at $8000 and I have an identifier table.

.db is define byte. It use used for making the data table discussed previously.

I cannot answer on emulators. I use the Mike Kowalski editor. I have not used the others, so I cannot answer there, sorry. I have used Merlin in the past and cut my teeth on it.

Let us know how the assignment goes at school.

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 12, 2003 9:18 am 
Offline

Joined: Tue Nov 18, 2003 8:41 pm
Posts: 250
"pleasd" ?

marks off for spelling too !?

you're mean :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 15, 2003 4:59 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Welp, our budding programmer has been a no show since. Pehraps this is the way it all webnt down.
(Pantelis desperately copying my program line by line and turning it in, smug smile on his face).
Teacher: Pantelis, how does this program work?
Pantelis: uh...the datatable...uh....the db..."
Teacher: "What does your program loop do here?
"Pantelis: uh....uh....the datatable...
Teacher: Pantelis! My office after class!


Anyone want to take bets that he isnt in here because his computer at home got restricted or taken away?

Moral of the story: DO YOUR HOMEWORK and LEARN. If you are a student and are actually stuck, then please DO come in and we are happy to help. But when you have a sheer set of lame brained stuph like above...you can draw your own conclusions....

by the way for giggles, take my data table and convert the hex to its ASCII equivalents. Its another laugh for ya....

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 16, 2003 2:49 am 
Offline

Joined: Tue Sep 30, 2003 5:46 pm
Posts: 30
Location: Central Wisconsin
Nightmaretony wrote:
by the way for giggles, take my data table and convert the hex to its ASCII equivalents. Its another laugh for ya....


The datatable needs to be corrected for typos. :wink:

.DB $c4, $c5, $c1, $d2, $a0, $d4, $c5, $c1, $c3, $c8, $c5, $d2, $ba, $a0
.DB $d0, $c1, $ce, $d4, $c5, $cc, $c9, $d3, $a0
.DB $c7, $cf, $c5, $d3, $a0, $d4, $cf, $a0, $d7, $d7, $d7, $b6, $b5, $b0, $b2, $ae, $cf, $d2, $c7, $a0
.DB $d4, $cf, $a0, $c7, $c5, $d4, $a0, $cf, $d4, $c8, $c5, $d2, $d3, $a0, $d4, $cf, $a0
.DB $c4, $cf, $a0, $c4, $cf, $a0, $c8, $c9, $d3, $a0, $c8, $cf, $cd, $c5, $d7, $cf, $d2, $cb, $a0
.DB $c6, $cf, $d2, $a0, $c8, $c9, $cd, $ae, $a0
.DB $d0, $cc, $c5, $c1, $d3, $c5, $a0, $d4, $c1, $cb, $c5, $a0, $c1, $c3, $d4, $c9, $cf, $ce, $a0
.DB $c1, $c3, $c3, $cf, $d2, $c4, $c9, $ce, $ce, $c7, $cc, $d9, $ae, $a0
.DB $d4, $c8, $c1, $ce, $cb, $a0, $d9, $cf, $d5, $ae

I think that's right (no I didn't check it).
Bold = addition
Italic = alteration (tough to see - 7th line)
Underline = removal


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 16, 2003 6:07 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
I did it in 10 minutes and had no brain that morning....

thansk on the debug, though. Too bad we never got a response, so a fun hack was wasted...

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 16, 2003 5:43 pm 
Offline

Joined: Wed Dec 10, 2003 12:23 pm
Posts: 4
Hi my friend!I am here!My computer have never been restricted!
But i do have some questions!
I cant undestand what the table dows!
The first line is .DB $c4, $c5, $c1, $d2, $a0, $d4, $c5, $c1, $c3, $c8, $c5, $d2, $ba, $a0

But $c4,$c5 is in decimal 196,197
I cant understand what these numbers do.
Also why CMP #$FF
compare with 255
But the days are 365.I know that the last number in16 bit is 255 but
the days are 365.Can you explain me what we do?
I understand all the code but i cant understand how this table works.
And how can i do this in my assembly program.>>DateTableOut = $00
ResultCode = $01 <<
Please help me to understand!
THANX FOR YOUR HELP!!!!!!!!!!!!!!!I REAL WANT TO LEARN!!!!!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 16, 2003 6:38 pm 
Offline

Joined: Tue Sep 30, 2003 5:46 pm
Posts: 30
Location: Central Wisconsin
Nightmaretony wrote:
I did it in 10 minutes and had no brain that morning....


That isn't bad for a 10 minute hack. I think it would take me that long to find the appropriate charts (which I don't want to name..)

Nightmaretony wrote:
thansk on the debug, though.


De nada.

Nightmaretony wrote:
Too bad we never got a response, so a fun hack was wasted...


Well, even with a response, we need to be patient ... :lol:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 18, 2003 5:17 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Prvate email once again asking for help, but with a program.

0100->dd
0200->mm
0300->yy
0400->days that we give

months to days

ldy #30
lda 0200
sta 0500
lda #00
loop clc
adc 0500
dey
cpy #00
bne loop
sta 0600

years to days


ldy #365
lda 0300
sta 1000
lda #00
loop clc
adc 1000
dey
cpy #00
bne loop
sta 1100


Total days

lda 0100
clc
adc 0600
clc
adc 1100
clc
adc 0400
sta 2000 //total days

Total days to dd-mm-yy

lda #365
sta 0200
lda 2000//oi total days
ldy #00
cpa 0200
bcc loop
sec check
sbc 0200
iny
cpa 0200
bcs check
sty 0300//the years
sta 1500
loop sty 0300



lda #30
sta 1100
lda 1500//the days that remained
ldy #00
cpa 1100
bcc loop
sec check
sbc 1100
iny
cpa 1100
bcs check
sty 1800//months
sta 2100//days
loop sty 1800

_________________________________________________________________
Få alle de nye og sjove ikoner med MSN Messenger
http://messenger.msn.dk


My question is, WHERE ARE THE COMMENTS TELLING WHAT EACH SECTION DOES? I am not going to take the time to break down and undersatand it if you cannot even explain what you are doing here. Did you actually write this code or copied it form soneone else?

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 18, 2003 2:16 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 298
[code]
months to days

ldy #30
lda 0200
sta 0500
lda #00
loop clc
adc 0500
dey
cpy #00
bne loop
sta 0600
[/code]

Each of these sections looks like a multiply. To multiply N by 30, go through a loop 30 times adding N to the running total.

That's fine, but (as another post hints) there's a big problem with overflow. Registers and memory locations are only 8 bits, so they won't hold numbers greater than 255. This bit of code is going to start having problems in September. The one that multiplies by 365 won't even assemble.

The solution is to use two memory locations to store values. That gives 16 bits, which is enough to store the number of days in 179 years.

But there are no instructions to add 16 bit numbers. You can only do 8 bits at a time. This really should have been explained - have you (Toni) been skipping classes?

The answer is the carry flag - it acts as a 9th bit in the result of the addition. ADC will add it in to the next byte of your result. Adding some 16 bit numbers (in binary) by hand should give you the idea of how it works.

There's a lot of code at [url]http://www.6502.org/source/source.htm[/url]. A lot of them will use 16 (or more) bit arithmetic. And there's comments galore. Read and learn.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron