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

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: HELP HELP HELP . . .
PostPosted: Tue May 25, 2004 3:29 pm 
Offline

Joined: Tue May 25, 2004 3:07 pm
Posts: 1
Hello. I have a problem programming in assebly at 6502 processor. I have a project to give to my lecturer on Tuesday 28 May and I want your help.
Here is the deal:
I have a 2 dimensional table (8 bit) and I want to calculate the sum of it's diagonal and the sums of up and down triangular place. For example:

12 52 61
43 06 12
87 01 76

I want to calculate the sum of No -> 12+06+76
and the sum of the No -> 52+61+12
and also the No -> 43+87+01

I would be gratefull if anyone can help me to this. THANK YOU!!! :D


Top
 Profile  
Reply with quote  
 Post subject: Re: HELP HELP HELP . . .
PostPosted: Tue May 25, 2004 8:23 pm 
Offline
Site Admin
User avatar

Joined: Fri Aug 30, 2002 1:08 am
Posts: 281
Location: Northern California
zak wrote:
Hello. I have a problem programming in assebly at 6502 processor. I have a project to give to my lecturer on Tuesday 28 May and I want your help.

Please post your questions only once in the forum. Your duplicate question was deleted.

If you'd like to post your code and ask a specific question I'm sure there are people here who would like to help you.

Regards,
Mike

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed May 26, 2004 6:00 am 
Offline

Joined: Thu Jan 16, 2003 12:55 pm
Posts: 64
Location: Indianapolis
I'd use indirect addressing, I've done stuff sorta similar to that before. That way you have 2 axes, the Y register and the address in memory.

I'm sure there's other ways to handle it.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed May 26, 2004 5:32 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The simplest way would be to put the matrix at a fixed memory location (say somewhere on zero page) and access its values as offsets from the base location, for example
Code:
 M+0  M+1  M+2
 M+3  M+4  M+5
 M+6  M+7  M+8

If the values are guaranteed never to add up to a value over 255 then a sequence of CLC / LDA first cell / ADC second cell /ADC third cell will give you the sum for the diagonal or upper/lower triangle. If the sum can be bigger than 255 then keep the low big in the accumulator and use either X or Y to hold the high bytes (hint: after each ADC check for a carry and increment X/Y if needed - remember to clear the carry before the next ADC).

_________________
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  [ 4 posts ] 

All times are UTC


Who is online

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