6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Sep 30, 2024 8:18 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: help!
PostPosted: Wed May 23, 2018 8:01 am 
Offline

Joined: Fri May 18, 2018 3:50 am
Posts: 1
Can I edit the program counter value ?
help me!


Top
 Profile  
Reply with quote  
 Post subject: Re: help!
PostPosted: Wed May 23, 2018 8:29 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8407
Location: Midwestern USA
tuanbusku wrote:
Can I edit the program counter value ?
help me!

What exactly are you attempting to accomplish?

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


Top
 Profile  
Reply with quote  
 Post subject: Re: help!
PostPosted: Wed May 23, 2018 8:30 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
Welcome.

Please give a little more context. Do you mean in assembly-language source code? Most assemblers use ORG ____ , where the parameter tells what value you want. "ORG" stands for "origin." Some assemblers need a dot before it, like ".ORG" or similar. Other ones will use the asterisk, like *=____. What assembler are you using? You can use these many times in your code, even for the same program, to pick up at another address. (There may be several reasons to do this, which I may get into later.)

Or, if you mean to jump or branch, use the JMP or JSR or B__ (ie, the BNE, BEQ, BMI, BPL, BCC, BCS, BVC, BVS, BRA, BBS, or BBR instructions). RTS returns from a subroutine, and RTI from an interrupt-service routine (ISR), also affecting the program counter. Actually, these can be used in other contexts too, not just subroutines and interrupts.

Also, giving the topic a title that's descriptive and gets people's interest will give you more success at getting answers.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: help!
PostPosted: Wed May 23, 2018 10:08 am 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
Welcome.

There is no direct way to modify the program counter arithmetically at run-time which is what a lot of people would like to be able to do. There are several indirect methods.
The desired value of the program counter minus one can be pushed on the stack then an RTS executed. Or the desired value could be stored in memory then a memory indirect jump JMP ($addr) performed. Or a jump instruction may be stored in memory then self modifying code used as modifying the jump instruction to point to the desired address.

_________________
http://www.finitron.ca


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 1 guest


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: