Posts: 896
Threads: 183
Joined: Jul 2005
I need to execute an address in C[6:3] instead of simply jump to it like I would with a GOTO ADR (h1E0) instruction. Håkan, Angel or any other MCODE wiz have any idea of how to best accomplish this?
I could perhaps push the next address onto the return stack before I execute a GOTO ADR, but how do I get that address?
Edited: 4 Jan 2010, 9:23 a.m.
Posts: 297
Threads: 25
Joined: Nov 2006
GOSUB 0097
This mainframe location (0097) contains GOTOC. So the subroutine call to this location will jump to the address in C[6:3] and the return at the end of the function will return to the instruction after the GOSUB?
Monte
Edited: 4 Jan 2010, 2:17 p.m. after one or more responses were posted
Posts: 528
Threads: 85
Joined: Jul 2005
Geir,
This is really simple as you thought. Just build the address and do the GOTO ADR.
The create a return address, first do a ?NC XQ PCTOC [00D7]. I will leave it to you to study the VASM listings as an exercise how this works ;)
Add a bit to this address you have been given, and then use PUSHADR to get this on the return stack, get the target address back and do your GOTO ADR.
Meindert
Posts: 896
Threads: 183
Joined: Jul 2005
Excellent! Just what I needed.
Posts: 896
Threads: 183
Joined: Jul 2005
Yes. The hex word for GOTO ADR is 1E0, there is no GOSUB ADR.
Posts: 412
Threads: 40
Joined: Mar 2006
The method given by Monte in his (edited) post is much simpler. I used a similar trick on several microprocessors that do not have indirect gosub or call.
J-F
Posts: 528
Threads: 85
Joined: Jul 2005
I made it too complex, I must admit that I did not read Monte's first reply in too much detail, the instruction is indeed a ?NC XQ 0097 after putting the needed address in C. The GOSUB that Monte mentioned took me off guard, as I use this mnemonic typically for a 3-byte relocatable call.
Meindert
Posts: 896
Threads: 183
Joined: Jul 2005
0097? That's one address before the function RSTKB... Makes little sense. Sure about the address?
Posts: 528
Threads: 85
Joined: Jul 2005
The trick is that you are calling this address as a subroutine, so the return address is pushed on the stack when executing ?NC XG 0097.
With the target address in C, your program jumps to the GOTO ADR function it finds at 0097, and will then immediately jump to your desired address, with the stack loaded with your return address (the line after your ?NC XQ 0097)
Meindert
Posts: 297
Threads: 25
Joined: Nov 2006
The address is correct. The GOTOC at this address immediately
jumps to C[6:3], which is the entry to your subroutine. The
fact that the next in-line instruction is the first in the
RSTKB routine has nothing to do with anything. This is just
a convenient, known address that contains a GOTOC. Think of
it as a waypoint that you have to go through to get to your
final destination. Getting to the waypoint via a subroutine
call takes care of getting the return address on the stack.
Monte
Posts: 896
Threads: 183
Joined: Jul 2005