MCODE: Bright idea for executing an address instead of a GOTO ADR (h1E0)?
#1

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.

#2

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

#3

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

#4

Excellent! Just what I needed.

#5

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

#6

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

#7

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

#8

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

#9

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

#10

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

#11

Ah, get it. Cool.



Possibly Related Threads…
Thread Author Replies Views Last Post
  HP-41 MCODE: The Last Function - at last! Ángel Martin 0 1,020 11-08-2013, 05:11 AM
Last Post: Ángel Martin
  New website address for Meindert Kuipers' MLDL2000? Garth Wilson 2 1,302 08-11-2013, 01:43 PM
Last Post: Meindert Kuipers
  HP41 Functions Address Table (F.A.T.) Antoine M. Couëtte 6 2,142 07-21-2013, 02:48 AM
Last Post: Antoine M. Couëtte
  41-MCODE: Auto XEQ+ALPHA possible? Ángel Martin 5 1,896 05-29-2013, 06:15 AM
Last Post: Ángel Martin
  HP 41 Mcode related Questions Michael Fehlhammer 4 1,911 05-10-2013, 07:09 PM
Last Post: Michael Fehlhammer
  Stupid idea of the day: 41-compatible watch bhtooefr 0 978 03-31-2013, 08:23 AM
Last Post: bhtooefr
  Idea for a 41C rom of "big" programs Gene Wright 7 2,365 10-05-2012, 04:29 AM
Last Post: Mike (Stgt)
  41-MCODE: Breaking the FAT barrier. Ángel Martin 0 895 09-03-2012, 06:31 AM
Last Post: Ángel Martin
  39GII -> 50G idea bluesun08 14 3,715 08-19-2012, 12:03 AM
Last Post: Dave Shaffer (Arizona)
  41-MCODE: Dr. Jekyll & Mr. Hyde Ángel Martin 9 2,939 07-09-2012, 09:41 AM
Last Post: Monte Dalrymple

Forum Jump: