6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Sep 24, 2024 8:33 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Feb 19, 2013 7:53 pm 
Offline

Joined: Tue Feb 19, 2013 7:51 pm
Posts: 1
Hi guys, just wondering how could we increment PC using ALU?

Thanks beforehand,

Michelle


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 19, 2013 10:17 pm 
Offline

Joined: Tue Nov 18, 2003 8:41 pm
Posts: 250
michelle.nat wrote:
Hi guys, just wondering how could we increment PC using ALU?

Thanks beforehand,

Michelle


generally
do a jsr to get it on the stack where you can get at it
pull it off the stack and do whatever you're going to do to it
push it back on the stack and do a rts to put it back in the PC

I think that's usually considered more trouble than it's worth

What are you trying to do?

edit you don't have to literally pull it off the stack
you can point to it on the stack with the x register
using tsx


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 20, 2013 1:14 am 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
In the event that you are not aware, the PC on the stack points to the last byte of the jsr instruction, i.e. the high byte of the subroutine address. During the subroutine return process, the low byte of the address on the stack is incremented by one. If there is a carry out, the carry is propagated to the high byte of the address.

To arithmetically modify the PC as bogax has indicated, you will need to take into consideration the behavior of the jsr and rts instructions.

BigEd has taken the Easy 6502 and extended it to support the 65Org16 and 65Org32 6502 derivatives being developed by some of the members of this forum. You can use the Easy 6502 or BigEd's 6502js JavaScript implementation to write and test small code samples.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 21, 2013 2:37 pm 
Offline

Joined: Fri Sep 28, 2012 12:27 pm
Posts: 25
Location: Boulogne Billancourt, France
A simpler way (than playing with JSR/RTS) could be:
STA :0+1
:0 BRA * ;or use another relative branch opcode if NMOS 6502

If you don't care about auto modifying code (and thus non ROMable code)...
The relative branch opcode will add a ALU 8bit signed value to the 16bits PC.

HTHTATS,
BenoƮt


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: Google [Bot] and 20 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: