6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 3:35 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Pointers
PostPosted: Tue Dec 28, 2010 7:54 pm 
Offline

Joined: Fri Dec 24, 2010 7:14 am
Posts: 1
Heyo

I'm working on learning on some 6502 assembler and there's something i'm having a little trouble with.
I want to write a sub routine (for my c64) that will display a box in the screen. (Text only)
I want to position the box with x, y, w, h.
I'm just wondering what the easiest/most common way to access the video memory would be. I want to store a 16bit pointer to the current position I'm writing to so that I may increase both the lsB and msB.

Also if you happen to have a link or some code laying around that shows the basic way to work with 16 bit addition. That's be awesome. I don't understand where the data to add to the msB with a ADC instruction codes. I understand that the Carry bit is set, but this alone isn't enough to complete an Add.

Thanks a ton! It's awesome there's such a popular forum on the web for this classic CPU


Top
 Profile  
Reply with quote  
 Post subject: Re: Pointers
PostPosted: Tue Dec 28, 2010 8:50 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
dirk103 wrote:
Heyo

I'm working on learning on some 6502 assembler and there's something i'm having a little trouble with.
I want to write a sub routine (for my c64) that will display a box in the screen. (Text only)
I want to position the box with x, y, w, h.
I'm just wondering what the easiest/most common way to access the video memory would be. I want to store a 16bit pointer to the current position I'm writing to so that I may increase both the lsB and msB.

Also if you happen to have a link or some code laying around that shows the basic way to work with 16 bit addition. That's be awesome. I don't understand where the data to add to the msB with a ADC instruction codes. I understand that the Carry bit is set, but this alone isn't enough to complete an Add.

Thanks a ton! It's awesome there's such a popular forum on the web for this classic CPU

There is all sorts of stuff around here that can help you out. Like finding Blackbeard's treasure, you need to do a little digging. As for using the 65xx instructions themselves, enough paper has been printed about that to sink a small ship.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 28, 2010 9:04 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
Quote:
Also if you happen to have a link or some code laying around that shows the basic way to work with 16-bit addition.

I thought we had something in the source code repository or in the wiki but I guess it's too basic.

Code:
        CLC
        LDA  <first_number_low_byte>
        ADC  <second_number_low_byte>
        STA  <result_low_byte>
        LDA  <first_number_high_byte>
        ADC  <second_number_high_byte>
        STA  <result_high_byte>

On the 65816 you can handle both bytes at once, cutting out half the steps or more.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jan 01, 2011 11:25 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
Hi Dirk
I thought it would be very easy to just google for the details of multi-byte arithmetic, but I didn't come up with any exact snippets for your question.

Two resources worth looking through: the tutorials section on this very site, and the responses to "I want to learn 6502 assembly" on metafilter.

You'd normally store a pointer in zero page, because of the various addressing modes which treat two adjacent bytes in zero page as a pointer, and because code to access zero page is shorter and faster.

Cheers
Ed

Edit: might also be worth looking at the pdf manual to 'the visible computer' which I posted about earlier - page 73 or so of the PDF.


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: John West and 7 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: