Skip to content

"test" instruction with "ina" as first operand does not work #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rstemmer opened this issue Jul 17, 2019 · 2 comments
Open

"test" instruction with "ina" as first operand does not work #43

rstemmer opened this issue Jul 17, 2019 · 2 comments

Comments

@rstemmer
Copy link

rstemmer commented Jul 17, 2019

I once again spent days of debugging a problem a simple warning or an error could have avoided.

Description of the Problem

I had the following code in a function that should read data from an SPI device:

test    ina,  :pin_miso   WZ

My problem was that I got no data from that device, I always received 0-Bytes.
I then connected an FPGA between the SPI Device and the Propeller to observe the communication and figured out, that the whole communication worked.
After flipping the operands I finally got the valid response in the Propeller:

test    :pin_miso,  ina   WZ

Investigation of the Problems Origin

The documentation explicitly writes about the test command that it does not perform writing, so I was not concerned about the order of operands.:

Explanation
TEST is similar to AND except it doesn’t write a result to Value1; [..]

Anyway, in the description of the ina register, the following warning was spoken:

[..] Do not use INA as the destination operand; that only results in reading and modifying the shadow register whose address INA occupies. [..]

Suggestion as Solution

Obviously the assembler knows that this was an invalid use of the test instruction to access the ina register.
A warning like: "WARNING: Invalid use of ina register. ina should only be used as source register." would have helped a lot.

Environment

Version 1.00.81 Compiled on Jul  5 2019 09:30:36
@PropGit
Copy link

PropGit commented Jul 17, 2019

Thank you for the report @rstemmer.

I agree, this is something we should improve. It should be a warning and will require a proper warning system to be implemented in the compiler first before implementing this (and other) warnings. It should not be an error because it actually does perform a task, though it is utilizing an odd behavior that is not typically utilized and certainly not what you intended.

@drawkula
Copy link

Just for having a reference:
—▷ Add warning system #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants