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



#9

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.


#10

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


#11

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

#12

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


#13

Excellent! Just what I needed.


#14

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


#15

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


#16

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


#17

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

#18

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


#19

Ah, get it. Cool.


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

Forum Jump: