GEAR does not seem to emulate SUBS correctly. (Now resolved/fixed)
Bob Anderson
Posts: 122
If "answer"·contains 00000005
and GEAR executes the instruction:···· SUBS answer,#1
answer then contains FFFFFFFC· (which is -4)
instead of 00000004.
Is this a GEAR emulation problem, or am I misinterpreting how SUBS is supposed to operate?
Post Edited (Bob Anderson) : 10/30/2009 6:05:40 AM GMT
and GEAR executes the instruction:···· SUBS answer,#1
answer then contains FFFFFFFC· (which is -4)
instead of 00000004.
Is this a GEAR emulation problem, or am I misinterpreting how SUBS is supposed to operate?
Post Edited (Bob Anderson) : 10/30/2009 6:05:40 AM GMT
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
I just had a look at the source code, and the bug may affect a number of instructions:
SUBX, SUBS, SUBSX, CMPX, CMPSX
All of them seem to have the source and destination registers swapped around (when compared with SUB, SUBABS and CMP).
Unless there was some "magic" that was used in the calculation, my proposal would be to swap all of these instructions.
Unfortunately, I'm not the original author, but have been maintaining (fixing, improving) the code for the last 18 months.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
I've attached a "fixed" version of GEAR. It "fixes" all the instructions indicated. Hopefully nothing gets broken!
Could you please test it before I repackage it for upload at: http://forums.parallax.com/showthread.php?p=701256
That took care of SUBS. I don't have a test for the others yet. I'll be away for a couple of hours, but when I return, I'll gen up some.
Bob
A bunch of test cases for these instructions would be appreciated. I don't mind fixing GEAR, I'm just a bit short of time at the moment.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have attached a snap of the SUBS manual.
I have also attached the test code that I stepped through.· The comment on the SUBS commands is what the result should have been.
I'll continue developing test cases using the same protocol of testing all the cases from the Concise Truth Table.
Here are the test files I used for SUBS.
The file with the extension spin-aac will not be familiar to you.· I am working on a tool to help people (like me) that are writing assembly code.· AAC stands for Augmented Assembly Code.· I hope to find a few beta testers in about a week.· The code is done, but I have not completed the built in Manual.
'Gear gen test.spin' is the output of my tool.· 'Gear gen test.spin-aac' is the input to the tool.
'Gear gen test.binary' is the output of Propeller Tool v1.2.6
It now fairly easy to generate test code for any instructions that you wish me to test.·
Now I just have to find some time...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You should be able to load the binary into GEAR and press run.· Switch to cog 1 and navigate to the ans[noparse]/noparse array.· This process is documented by the attached pictures.
Attached are the relevant files.
SUBX passes all 4 test cases!
Attached are the relevant files.
CMPX passes all 18 + 8 cases.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
I tested REV.· There where 9 case in the Concise Truth Table.
Cases 1..9 all got an incorrect result.· Majorly wrong actually.
Case 1 also had an incorrect Z flag (because the result was wrong and would have been 0)
Cases 1..9 had correct C flags.· A bit of a surprise since case 6..9 had C = 1.· So much else seemed to wrong, it's a wonder the C flag turned out right.
Attached are relevant files.
Can I use Yours program snipets in my Stress program for Propeller/COG's
Regards
ChJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
Would you explain your "Stress program" a little more?
I tested the SUBSX instruction.· There are 10 cases in the Concise Truth Table.
There are a number of cases where the input Z flag is shown as an x (don't care).· I entered these cases as Z = 0 and did NOT test the corresponding case with Z = 1
Summary: Cases 1..10 are correct as to dest value and Z flag output.· Cases 1..6 are correct for C flag output.· Cases 7..10 have inverted C flag outputs.
I work on program to stress Propeller with overclocking.
In all posible way from simple COG to entire Propeller.
And must test every instruction/Flag in COG and every Counter with possibility to place results in HUB to send them to VGA else Simple terminal
That can give me possibility to real test Frequency Propeller fail its stable state.
Regards
ChJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
I have tested the CMPSX instruction emulation.· There are 20 cases in the Concise Truth Table.· I treated Z = x as Z = 0
Summary: Cases 1..20 are correct for dest value and Z flag.· But cases 9..12 have inverted C flags.
Here are all the files involved in testing CMPSX, REV, SUBS, SUBSX, SUBX, and CMPX.
I hope this helps you with pPropellerSim.
Bob
The attached zip takes care of the empty 'Gear SUBS test.spin' file.
It also changes all org statements from:
entry·· ORG· 0
to:
········· ORG· 0
entry
I found that the first version sometimes gave problems.
I'm reasonably certain that there will be simple fixes for the majority of the issues raised. I'll post again once I have a release candidate.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I would love third party verification of the results for SUBX, CMPX, SUBS, SUBSX, CMPSX and REV before I turn this into an official release.
I did run all the test files on a real chip to validate the test code itself. I assume that you're asking me to run Gear on the test files and verify that all cases worked.
Will do.
Bob
I reran the tests on CMPSX, CMPX, REV, SUBS, SUBSX, and SUBX.
All ran perfectly through all the cases.
I was gratified at how quickly this could be done.
Congrats to you on the fixes.
Bob