6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Oct 06, 2024 9:25 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: port lights
PostPosted: Thu May 20, 2004 11:56 am 
Offline

Joined: Thu May 20, 2004 11:47 am
Posts: 1
as part of a assignment at college i need write a program which will

enter two numbers into locations 0470 and 0471, then add the two numbers together to give the result.

if the result is greater than 2a, the port lights should look like below (1=lights on) (0 lights off)
11000011

if the result is less than 2a the lights should be
00111100

can anyone help me out cos i aint gotta clue how to start
thax :?: [/code]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 20, 2004 12:44 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Just break the problem into stages and then figure out how to do each bit with the 6502's instruction set.

So by my reckoning you have to:

1. Initialise two memory locations with values

2. Load and add the two values

3. Compare the result

4. Load one of two bit pattens depending on the result

5. Store the pattern to turn the lights on/off.

6. Terminate

Each of those stages is only a few machine instructions. Go and look up LDA, STA, CLC, ADC, CMP, BCC, BCS, BNE, BEQ and BRK. Try putting some code together and post again when you get stuck.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Last edited by BitWise on Thu May 20, 2004 12:47 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 20, 2004 12:44 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
You can find an online reference guide to 6502 instructions here:

http://www.obelisk.demon.co.uk/6502/reference.html

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 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: