Help wanted with a ⎕NA call

No need to worry about going "off topic" here
Forum rules
This forum is for general chit-chat, not necessarily APL-related. However, it's not for spam or for offensive or illegal comments.

Help wanted with a ⎕NA call

Postby ray on Wed May 17, 2017 3:39 pm

Ray Cannon
User avatar
ray
 
Posts: 118
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Help wanted with a ⎕NA call

Postby petermsiegel on Wed May 17, 2017 10:12 pm

See if this helps...

bVal is declared in C as an unsigned integer at the default width, typically 4-bytes (or 2-bytes, depending on the system), not 1-byte. So I'd expect you'd declare it as U (for the default width), not U1. Similarly for i2cReg.

C automatically (and obligatorily) promotes single-byte arguments to the default width, when pushing them onto the function call stack, as the receiving function expects. That function then chooses to ignore the "extra" C-generated bits beyond the first 8 as part of its semantics.

My recollection is that ⎕NA needs patterns like U1 for accessing packed objects, e.g. via structures or pointers/arrays.
petermsiegel
 
Posts: 52
Joined: Thu Nov 11, 2010 11:04 pm

Re: Help wanted with a ⎕NA call

Postby ray on Thu May 18, 2017 12:37 am

Thank you, replacing the "U1" by "U" works.

I had incorrectly assumed that because the value being written was a single byte, and the definition was "unsigned bVal", an unsigned integer of width one should provide the correct format.

Thank you once again.
Ray Cannon
User avatar
ray
 
Posts: 118
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Help wanted with a ⎕NA call

Postby Geoff|Dyalog on Thu May 18, 2017 7:41 am

Hmm. U1 gives you range checking on the APL side. This feels more like a problem with sign extension as it goes from 1 byte to 4. I will log an issue. Since the work around is easy (whilst sacrificing range checking) it might not get high priority.
Geoff|Dyalog
 
Posts: 43
Joined: Wed May 13, 2009 12:36 pm

Re: Help wanted with a ⎕NA call

Postby petermsiegel on Fri May 19, 2017 6:33 am

petermsiegel
 
Posts: 52
Joined: Thu Nov 11, 2010 11:04 pm

Re: Help wanted with a ⎕NA call

Postby Geoff|Dyalog on Fri May 19, 2017 10:17 am

Peter:

Did you see that bit pattern with other values than 128? It still feels to me like a sign extension problem. Be patient - I will get to it. It is logged as issue 14591.
Geoff|Dyalog
 
Posts: 43
Joined: Wed May 13, 2009 12:36 pm

Re: Help wanted with a ⎕NA call

Postby petermsiegel on Sun May 21, 2017 4:09 am

petermsiegel
 
Posts: 52
Joined: Thu Nov 11, 2010 11:04 pm


Return to Chat

Who is online

Users browsing this forum: No registered users and 1 guest