-
Notifications
You must be signed in to change notification settings - Fork 23
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
Native ARM Co Pro: OSBYTE SWI returns unexpected value in R1 #120
Comments
this change: |
This seems to be at odds with the behaviour of the ARM7TDMI co-processor's OS_Byte return values, which simply returns the values of X and Y in R1 and R2. This tripped me up when I tried to implement reading the mouse values in BQUAKE using OS_Byte 128 to read the ADVAL values from the host. Reading the values in BeebEm in the ARM7TDMI co-processor was returning a different result to the PiNative co-processor. |
I would suggest just anding the result with &FF in each case., i.e. treat the contents of bits 8-31 as undefined. @jgharston would you care to explain what's going on here? |
This is what I did in my code, I'd tested under BeebEm with the ARM7TDMI and was wondering why my mouse coordinates seemed wrong, which led me to looking at the code and spotting it was doing this. The funny thing is I was already doing this in my keyboard scanning code so I must have noticed it before, presumably at that point I didn't realise BeebEm was behaving differently. I'm not sure which way is the correct way, if RISC OS does it this way then perhaps that's why the change was made. |
Just to be clear, if you do AND with &FF, does the same code work on both platforms? |
That's odd, I was sure RISC OS returned R1=x OR (y<<8) so that R1 returned the full value so the caller didn't need to do R1 OR (R2<<8), and I have a memory rattling around about "ADVAL returning full 32 bits" from somewhere.
So, change it to reg[1] = x; "This tripped me up when I tried to implement reading the mouse values in BQUAKE using OS_Byte 128 to read the ADVAL values from the host." How did it trip up? ORR R1,R1,R2,LSL#8 gives the same result regardless of whether R1 already has R2 in bit 8 upwards or not. |
Yes it did.
I was writing in C, so I used x + (y<<8), because I tend to think in terms of regular maths rather than bitwise maths. |
Yep, ARM CoPro, 1984ish: RISC OS Kernel (end of BUFFV called by OSBYTE &80), 1997ish: ...but I'm sure I've seen somewhere some OSBYTE calls returning larger values in R1. But BASIC does ORR dest,R1,R2,LSL #8 when reading a large OSBYTE (eg ADVAL and USR&FFF4) and AND dest,R1,#255 when reading a byte value (eg VPOS) anyway. |
Change-Id: Iafd3a9e32d9bbb94b03cfc91a760ee2c51151c89
Fixed in hognose-dev. |
Result from PiTubeDirect is different to the ARM7TDMI Co Pro, likely due to this:
The text was updated successfully, but these errors were encountered: