Question about Long Jump in MCode

Question about Long Jump in MCode

Postby Khan-Dam » Wed Feb 15, 2017 11:14 pm

Hi,

I'm new here, i had a 41C in 80's now i use the very good i41Cxplus emulator on iPhone.

Since i found this forum i decide to work again in programation.

It's my Job for 30 years now. I use generaly C language but i used for long time ASM for Z80 808.. 6809 and lot of Microcontroler.

i found on this site the SDK v6 and i begin to study the MCode. i write some little thing who is working in SDK under Win XP and in rom format ob i41CX

but i've and issue with long Jump

I write a litle code where i made a Test for Long Jump i trywith JC ( Displacement < 64) it's work perfectly but when i replace JC by CGO to realize a long Jump the program don't jump if the OP on label targeted by CGO or NCGO is NOP

does it make sense ??????

Code: Select all
* MYROM.SRC
* Assembled by A41
* Thu Feb 16 00:02:06 2017
            .TITLE   "MYROM"
            .ZENCODE
;**********************************
;*  FAT for MYROM 11 ROM          *
;**********************************
 0000 001         XROM   1   ;XROM number
 0001 002         FCNS   2   ;Header + 1 function
 0002 00008B         DEFR4K   [Header] 008B   ;first executable of header
 0004 00008E         DEFR4K   [T2] 008E   ;second executable : function T2
 0006 000         NOP      ;FAT termination
 0007 000         NOP      ;FAT termination
;***********************************
            .FILLTO   0081
;**** Header
            .NAME   "*MYROM 11"
*0082 0B1         #0B1      ; "1"
*0083 031         #031      ; "1"
*0084 020         #020      ; " "
*0085 00D         #00D      ; "M"
*0086 00F         #00F      ; "O"
*0087 012         #012      ; "R"
*0088 019         #019      ; "Y"
*0089 00D         #00D      ; "M"
*008A 02A         #02A      ; "*"
 008B 3E0   [Header]   RTN
;************************************************************
;* Just for Test Purpose
;************************************************************
            .NAME   "T2"
*008C 0B2         #0B2      ; "2"
*008D 014         #014      ; "T"
 008E 260   [T2]      SETHEX      ; INIT Hex Mod
 008F 0A0         PT=P      ; Pt = P
 0090 04E         C=0   ALL   ; Clear
 0091 2DC         PT=   13   ; Load - in S
 0092 250         LC   9
 0093 2FE         ?C#0   S   ; Check if + in S
 0094 00500B         CGO   (T2ER) 0201
 0096 13000F         LDI   00F   ; Just to show Not Jump   
 0098 3E0   [T2E]      RTN
            .FILLTO   0200
 0201 04E   (T2ER)      C=0   ALL   ; Set User Flag 0
 0202 2DC         PT=   13
 0203 210         LC   8
 0204 10E         A=C   ALL
 0205 3B8         C=REG   14(d)
 0206 370         C=CORA
 0207 3A8         REG=C   14(d)
 0208 2DC         PT=   13   ; Load - in S
 0209 250         LC   9
 020A 2FE         ?C#0   S   ; Check if + in S
 020B 005013         CGO   (T2ER1) 0401
 020D 13000F         LDI   00F   ; Just to show Not Jump
 020F 3E0         RTN
            .FILLTO   0400
 0401 000   (T2ER1)      NOP
 0402 04E         C=0   ALL   ; Set User Flag 1
 0403 2DC         PT=   13
 0404 110         LC   4
 0405 10E         A=C   ALL
 0406 3B8         C=REG   14(d)
 0407 370         C=CORA
 0408 3A8         REG=C   14(d)
 0409 3E0         RTN


Second thing i work with MCODE for Beginners - Ken Emery it's a good book but does exist a real Processor OP Sheet with all OP in the 3 Form of ASM Zencode, HP, and JDA with all explaination of OP ?

Regards from France

Cheers

Khan-Dam
Khan-Dam
.
.
 
Posts: 3
Joined: Wed Feb 15, 2017 10:08 pm

Re: Question about Long Jump in MCode

Postby gjmcclure » Tue Feb 28, 2017 4:46 am

Hi Khan-Dam,

CGO and NCGO can't be used directly within a module, as they go to the absolute addressed referred to (unless you are calling an O/S routine, in which case you probably meant to do an CXQ or NCXQ instead, so you can return from the O/S). For example, CGO 0201 goes to Hex address 0201, which is smack in the middle of SYSTEM space (the HP41 O/S ROMs). I think you wanted to go to address 201 relative to the location of your module (i.e. if located at A000 then you wanted to go to A201). To do this regardless of where you put the module (A000, B000, C000, etc), you need to do CGOREL instead. This will compile into a three byte instruction (it calls an O/S routine that calculates the offset and jumps to the actual address needed inside the module).

So if you replace your CGOs with CGORELs and recompile, you should be able to jump to any byte in your module, even if that is a NUL. The only time NUL is important is at the very BEGINNING of your routine (where you specify the FAT to jump to). Then it is interpreted by the O/S as something special to be done for the function. Since this is not the case in your example, you should be okay.

Greg
gjmcclure
....
....
 
Posts: 14
Joined: Thu Jan 15, 2009 10:31 pm
Location: Colorado

Re: Question about Long Jump in MCode

Postby Khan-Dam » Tue Feb 28, 2017 9:15 am

Hi,

Thank you for this intersesting answer but in my case i do not have problems it's just a study case of mnemonic i already understand relativ jump. That just to be sure a jump on nop place do nothing !.


so one more time thank you for uoyr answer

regards from france

Cheers
Khan-Dam
.
.
 
Posts: 3
Joined: Wed Feb 15, 2017 10:08 pm

Re: Question about Long Jump in MCode

Postby jeffcalc » Wed Mar 22, 2017 9:31 pm

Bonjour :-)

I'm more used with the HP mnemonics, but I will try to use yours.
Long XQ don't jump if the target destination holds a NOP (null word). This is a desired and documented feature of the processor to ignore calls to non existing ROM.
My understanding of the Coconut is that this feature applies only to calls to subroutines (XQ), not to jumps (GO). This is the way I implemented it in my Emu41 emulator.

I'm not sure for the i41Cxplus emulator, however if this emulator is more or less based on V41, then this feature is implemented also for jumps (GO), as can be seen in the V41 sources:
>> if (pPage->Image[addr&0x0fff]==0) // long jumps dont jump to NOP

Maybe somebody can confirm?
User avatar
jeffcalc
.
.
 
Posts: 3
Joined: Fri Aug 28, 2009 8:57 pm

Re: Question about Long Jump in MCode

Postby dlachieze » Tue Apr 11, 2017 9:38 am

Khan-Dam wrote:Second thing i work with MCODE for Beginners - Ken Emery it's a good book but does exist a real Processor OP Sheet with all OP in the 3 Form of ASM Zencode, HP, and JDA with all explaination of OP ?

Bonjour,
You'll find such a table in the SDK41 Manual - Appendix H.
dlachieze
....
....
 
Posts: 13
Joined: Wed Mar 11, 2009 9:39 am

Re: Question about Long Jump in MCode

Postby Khan-Dam » Wed Apr 12, 2017 7:35 am

i take look as soon as possible

Thanks for the information
Khan-Dam
.
.
 
Posts: 3
Joined: Wed Feb 15, 2017 10:08 pm


Return to Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron