Jump to content
IGNORED

Main Code revealed....sort of.


Gorf

Recommended Posts

What happens if each rule is individually broken?

 

It will fail every time. There is no room for error. Follow the rules and

the code never fails. Misalign one thing and it's 'game over man'.

 

 

Again the only exception is to rule #5. Owl says you can use certain single

register instructions as the first NOP. I think you need to make sure you are

not using a register that has been recently used before the jump. Owl can

clarify that though. I have never tried this yet so I can't honestly comment.

 

Welp, there you have it Seb. now think for a moment how difficult it would be to track

every address by hand with out having a tool like SMAC.

 

I can tell you, if I had SMAC, I could have written Surrounded! in a day or two.

Instead I had to globalize EVERY jump placement and destination and add nop's to

pad them to the proper alignment. I then would have ALN output a list of symbols

to track those addresses. Night mare indeed.

 

 

Its true, i routinely break rule 5. I'd have to check if its a recently modified reg, i would suspect not, its always been single reg operand commands too.

 

In addition as i mentioned on JSII theres and extra safeguard recommended to be used when jumping to/from local/main. There's a particular instruction which is known to affect pre-fetch and which somehow helps to align the pipeline. I've found it helpful to use this immediately prior to the Jump

 

In regards how i discovered the methods too, it was even less methodical than gorf, i found out completely by mistake because i wrote some code on the GPU which i transferred to the DSP, but i switched back and forth a bit and suddenly one day i noticed it was running slower, i looked for why and suddenly i saw that it was the GPU running from DSP Ram - from there it was possible to move it to main ram and from there i set up a few guidelines for myself and then just tried trial and error - there was a lot of stumbling about though and Gorf's rules are far more rigorous and useful than the ones i originally set myself.

Edited by Atari_Owl
Link to comment
Share on other sites

Yep, tricky little beast that Jag is.

 

Nonetheless: Congratulations to Seb for sticking with me and figuring it out on his own.

Rdemming got it on JSII as well. Nice job guys!

 

Well, we got some help.

But still, I am happy to have guessed the rules correctly.

 

Thanks for having been an oracle.

Edited by SebRmv
Link to comment
Share on other sites

Yep, tricky little beast that Jag is.

 

Nonetheless: Congratulations to Seb for sticking with me and figuring it out on his own.

Rdemming got it on JSII as well. Nice job guys!

 

Well, we got some help.

But still, I am happy to have guessed the rules correctly.

 

Thanks for having been an oracle.

 

 

Now let's see you put it to some good use. :)

Link to comment
Share on other sites

I am also glad that some of my (few) assumptions about the cause of the problems seem to have been correct :)

 

The great thing about these bugs are they are consistant. If it were truly a random fail

you would never be able to workaround it this easily....or at all for that matter. Now try

to write a useful app WITHOUT SMAC/SLN and you'll see it's not easy. Most of the

projects I have for the Jaguar are main coded written by hand. I suppose I could convert

them all over but Im too far in to too many. There are also still issues with SMAC/SLN that

yet need rectifying as well, but for the most part it will still work. In fact SubQMod is doing

that with Donkey Kong as we speak. (Easy now Walter.... ;) )

 

Im not sure how Owl feels about using SMAC as I am sure he did most if not all the GPU

main coding in his app by hand as well. I no for my self, If I were one of you, I'd be happy

with SMAC and not really even care why main code works or not. ;P

Edited by Gorf
Link to comment
Share on other sites

I am also glad that some of my (few) assumptions about the cause of the problems seem to have been correct :)

 

The great thing about these bugs are they are consistant. If it were truly a random fail

you would never be able to workaround it this easily....or at all for that matter. Now try

to write a useful app WITHOUT SMAC/SLN and you'll see it's not easy. Most of the

projects I have for the Jaguar are main coded written by hand. I suppose I could convert

them all over but Im too far in to too many. There are also still issues with SMAC/SLN that

yet need rectifying as well, but for the most part it will still work. In fact SubQMod is doing

that with Donkey Kong as we speak. (Easy now Walter.... ;) )

 

Im not sure how Owl feels about using SMAC as I am sure he did most if not all the GPU

main coding in his app by hand as well. I no for my self, If I were one of you, I'd be happy

with SMAC and not really even care why main code works or not. ;P

 

Hi I use SMAC sometimes, but Gorf is right, since my main code was already done by hand i haven't converted it to use the SMAC macros, though i really should as there are definitely more Main code sections to be done.

 

Mine is of the form though of a framework which runs in main and which calls subroutines which run from local.

Link to comment
Share on other sites

Yes I imagine perfectly the nightmare it should be to write this correct by hand.

 

Actually, I thought it was possible to write madmac macros and conditionnals to circumvent the bug but unfortunately, since it is a one-pass assembler, it cannot work completely.

Fortunately, now there is SMAC!

 

Thanks again for this thread.

Link to comment
Share on other sites

Yes I imagine perfectly the nightmare it should be to write this correct by hand.

 

Actually, I thought it was possible to write madmac macros and conditionnals to circumvent the bug but unfortunately, since it is a one-pass assembler, it cannot work completely.

Fortunately, now there is SMAC!

 

Thanks again for this thread.

 

Hopefully it does illustrate why it was thought that SMAC would be a more useful method to enable it to be used than just explaining - since even explained its irritatingly picky... and labour intensive

Link to comment
Share on other sites

Yes I imagine perfectly the nightmare it should be to write this correct by hand.

 

Actually, I thought it was possible to write madmac macros and conditionnals to circumvent the bug but unfortunately, since it is a one-pass assembler, it cannot work completely.

Fortunately, now there is SMAC!

 

Thanks again for this thread.

 

Hopefully it does illustrate why it was thought that SMAC would be a more useful method to enable it to be used than just explaining - since even explained its irritatingly picky... and labour intensive

 

Following the rules is what allows it to work but keeping track of everything by hand is quite a pain in the hind quarters.

My guess is it starts to get unpredictable when you try using some of those instructions after a jump.

Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

I'll post this in the programming section as well.

 

To jump around in main RAM.....

 

1 ) Within a 256 byte page boundary...ie..The address range of a page starts at $XXXXXX00 and ends at $XXXXXXFF.

 

a ) JR can jump from anywhere to anywhere within its range and inside the page.

b ) JUMP must be aligned on a long address and jump to a word offset long address...ie...adresses ending in 2,6,A and E

 

2 ) From one 256 byte page to another

 

a ) JR (if it can reach the destination) can jump from anywhere but MUST land on a long aligned address to the other page.

b ) JUMP must be aligned on a long address and jump to a long aligned address...ie...adresses ending in 0,4,8 and C.

 

3 ) To jump from main to local or local to main(from one way to the other is the same).

 

a ) The JUMP must be long aligned. The desination must be long aligned. However, phrase aligment is reccomended for saftey.

b ) Preceed the JUMP with a MOVEI not related to the JUMP register(although I've had success with, Owl says its not safe.)

c ) Obviously JR can not reach main RAM from the GPU local address so it will not work for this

 

JR/JUMP must be followed by 2 NOP's OR 1 single register instruction not associated with anything recent and then NOP.

I do not think the single instruction and 1 NOP will work between local to main

or main to local but I'll leave that up to Owl to answer.

  • Like 2
Link to comment
Share on other sites

Hello Gorf!

 

I'll post this in the programming section as well.

 

To jump around in main RAM.....

 

Thanks for the quick response!

 

Kind regards

Matthias

 

PS: I think we (all) should keep the discussion of this topic here, while using the sticky thread in the Programming Section for the results of the discussion (if there are any new results).

  • Like 1
Link to comment
Share on other sites

Hello Gorf!

 

I'll post this in the programming section as well.

 

To jump around in main RAM.....

 

Thanks for the quick response!

 

Kind regards

Matthias

 

PS: I think we (all) should keep the discussion of this topic here, while using the sticky thread in the Programming Section for the results of the discussion (if there are any new results).

 

 

My pleasure Matthias...but I fear you might be the only one outside of a handful that ever even attempt to use

the main code workaround. Lots of people like to talk the talk and bitch and moan that no one likes to share

this and that, but I have found out that the reason for this is those people are usually not coders and are

hoping some other coder makes use of it for their own greedy selfish desires, forgetting the hard work that

goes into these projects.

Link to comment
Share on other sites

 

 

a ) The JUMP must be long aligned. The desination must be long aligned. However, phrase aligment is reccomended for saftey.

b ) Preceed the JUMP with a MOVEI not related to the JUMP register(although I've had success with, Owl says its not safe.)

c ) Obviously JR can not reach main RAM from the GPU local address so it will not work for this

 

JR/JUMP must be followed by 2 NOP's OR 1 single register instruction not associated with anything recent and then NOP.

I do not think the single instruction and 1 NOP will work between local to main

or main to local but I'll leave that up to Owl to answer.

Its good to see the rules laid out again :)

 

To comment on specifics...

  • The preceding MOVEI can be the jump register or an independent register - i often use the jump register.
  • I've also used the single register instruction plus 1 NOP for jumps between local & main.

Even following the guidelines there can STILL be unexpected difficulties with Main/Local jumps if the jump to/from occurs many times in quick succession - try to space out the jumps as much as possible. My own code only jumps between main & local <5,000 times a second atm.

Edited by Atari_Owl
Link to comment
Share on other sites

Hopefully SubQ's assembler macros handle this more or less automatically.

 

Someone needs to put it through its paces.

Some of have and there are still bugs where it blows up but I think SubQ mod is moving on to the N64

so I see little hope of it ever being completed.

Link to comment
Share on other sites

I think SubQ mod is moving on to the N64 so I see little hope of it ever being completed.

 

That would truly be a great pity :(

 

 

Well I do believe the source is available to SLN and SMAC so that's some hope. Then again,

Who knows what direction SQM will take in his escapades. I wish him well either way. He's

a good dude.

Link to comment
Share on other sites

Hello Gorf!

 

 

My pleasure Matthias...but I fear you might be the only one outside of a handful that ever even attempt to use

the main code workaround. Lots of people like to talk the talk and bitch and moan that no one likes to share

this and that, but I have found out that the reason for this is those people are usually not coders and are

hoping some other coder makes use of it for their own greedy selfish desires, forgetting the hard work that

goes into these projects.

 

Even if it'll disappoint you, i am afraid it will take a while before i will start using the given RISC-Execution-In-Main-RAM-rules. I probably would try it out immediately, and i am a master of adding NOPs to code sequences, but the necessary adress-alignments (with differences for page/non-page jump) seem to be a too high hurdle for me.

 

 

But could you or AtariOwl (or who else has the necessary experience) please add some info about the speed advantages or disadvantages of running RISC-code in main RAM to the sticky thread in the Programming section? Thanks in advance!

 

 

Kind regards

Matthias

Link to comment
Share on other sites

Hello Gorf!

 

 

My pleasure Matthias...but I fear you might be the only one outside of a handful that ever even attempt to use

the main code workaround. Lots of people like to talk the talk and bitch and moan that no one likes to share

this and that, but I have found out that the reason for this is those people are usually not coders and are

hoping some other coder makes use of it for their own greedy selfish desires, forgetting the hard work that

goes into these projects.

 

Even if it'll disappoint you, i am afraid it will take a while before i will start using the given RISC-Execution-In-Main-RAM-rules. I probably would try it out immediately, and i am a master of adding NOPs to code sequences, but the necessary adress-alignments (with differences for page/non-page jump) seem to be a too high hurdle for me.

 

 

But could you or AtariOwl (or who else has the necessary experience) please add some info about the speed advantages or disadvantages of running RISC-code in main RAM to the sticky thread in the Programming section? Thanks in advance!

 

 

Kind regards

Matthias

 

 

Main code ram execution can run almost as fast as in the local or not depending on the bus activity. In its worse case

it is by far faster then the 68k. The idea is to run your AI out in main and do all your drawing in local in that order.

If you use tight loops you will notice a serious drop inperfromance so it is recommended to unroll loops so that each

iteration of a loop from begining to end has several instructions between them and the loop jump. If you abide by these

quidelines you will increase your perfomance greatly over using the 68k by leaps and bounds.

Link to comment
Share on other sites

Hello!

 

 

For relative jumps (JR):

 

Those jumps are calculated on the processor counter (PC) being already incremented,

so what if a JR is the very last command in a page?

 

Is it then a page-miss if the jump is backwards? (based on the PC)

 

Or is it a page-miss if the jump is forwards? (based on the address where the JR is placed)

 

 

Kind regards

Matthias

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...