Assembly differences between PNut and Flexgui
JGM
Posts: 9
in Propeller 2
Hi,
I noticed a difference between the instructions generated when using PNut v34r and flexgui 4.1.7. When assembling the following:
PNut assembles the last line to: 00 00 80 FD
flexgui ssembles the last line to: F0 FF 9F FD
The difference is in the form of jmp used. PNut is using ”JMP D” while Flexgui is
using “JMP #{\}A”.
Changing the program to:
PNut compiles the last line to: 00 00 80 FD
flexgui compiles the last line to: 00 00 80 FD
Now both of them use ”JMP D”. Is there a right and wrong here?
I noticed a difference between the instructions generated when using PNut v34r and flexgui 4.1.7. When assembling the following:
DAT ORG loop drvnot # 56 waitx ## 25_000_000/20 jmp # loop
PNut assembles the last line to: 00 00 80 FD
flexgui ssembles the last line to: F0 FF 9F FD
The difference is in the form of jmp used. PNut is using ”JMP D” while Flexgui is
using “JMP #{\}A”.
Changing the program to:
DAT ORG loop drvnot # 56 waitx ## 25_000_000/20 jmp #\ loop
PNut compiles the last line to: 00 00 80 FD
flexgui compiles the last line to: 00 00 80 FD
Now both of them use ”JMP D”. Is there a right and wrong here?
Comments
The the last four bytes show a relative jump. How can this be?
My debugger shows
It doesn't make any difference.
I am running it in a virtual machine using an ancient OS (parallels with windows XP). It does run without complaint however. I took all tabs and extra spaces out so that the program looks like this:
Doing that I get this list file:
I guess I will stick with flexgui for now.
With the code above, I get same output as you (an absolute jump).
If I insert a org after DAT, I get a relative jump.
If I insert a orgh instead of org, I get again the absolute jump.
That is with PNUT on real Windows 7.
Andy
The initial address is $00000 and ORGH mode is set, not ORG mode. When the jump to $00000 is assembled, it sees that the destination address is within cog space, not hubexec space, but it's in hubexec (ORGH) mode. So, it thinks it's going to cross from hubexec to cogexec, and therefore needs to use an absolute address to bridge from hub to cog space.
You need to ORGH $400, at least, to get into hubexec space. That will solve the problem. What you have here is a pure PASM file, not a Spin2 file.
Chip is right, I did drop the ORG in the original post when I ran on PNut. For completeness sake I methodically tested three cases and picked up another difference between PNut and flexgui as shown in the first case below. They both encode the same instruction but the addresses are different in bits 10 thru 19. All 1's versus 0's. Huh?
This results in the last line assembling to:
PNut: F0 03 90 FD
Flexgui: F0 FF 9F FD
This results in the last line assembling to:
PNut: F0 FF 9F FD
Flexgui:F0 FF 9F FD
This results in the last line assembling to:
PNut: 00 00 80 FD
Flexgui:F0 FF 9F FD
The first one, with ORGH $400, is also screwy. Only 10 of the 20 bits filled for the offset.
Omitting the ORG was definitely an error on my part in the original post. I am more confused by the differences in the instructions generated when I include ORGH $400. If I understand correctly, my syntax is correct but the instructions generated are different between PNut and Flexgui. I just ran it again and can verify that I am seeing F0 03 90 FD from PNut and F0 FF 9F FD from Flexgui.
now consider this change that inserts padding.
Note how much padding I had to insert before things started compiling correctly.
EDIT: It's off by $400 bytes I think. Which would also explain JGM's example.
In Spin2 mode, ORGH $400 will set the origin to $400, but assemble the code at the current address, which changes as objects are nested together.
I need to look into this bug of filling only the bottom 10 bits of address.
Today I discovered a bug where nested bitfields are not compiling correctly. This is delaying the parser I want to post.
Went back to earlier Pnit versions and issue starts appearing from Pnut V34n if that helps.
This was when I adopted the guidelines presented by Evanh, which made sense (at that time, anyway).
I need to find out what it's doing wrong now.
EDIT: Ah, that's not the case at all. It was back in early February and still a v33 Pnut - https://forums.parallax.com/discussion/comment/1488890/#Comment_1488890
And if I try to run my LOC bug test code from a v34r assembled, it outright crashes in the hubexec section.
Evanh, would you mind posting or pointing to an example of how it's erring? I haven't experienced any trouble, so I must be missing it.