HP Forums

Full Version: MCODE: Bright idea for executing an address instead of a GOTO ADR (h1E0)?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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.

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?


Edited: 4 Jan 2010, 2:17 p.m. after one or more responses were posted


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.


Excellent! Just what I needed.

Yes. The hex word for GOTO ADR is 1E0, there is no GOSUB ADR.

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.


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.


0097? That's one address before the function RSTKB... Makes little sense. Sure about the address?

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)


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.


Ah, get it. Cool.