Geek Help!

Sep. 20th, 2005 08:21 am
bethlakshmi: (Default)
[personal profile] bethlakshmi
OK guys,

The OS class is giving me a pointer problem that's making me nuts. I'm sure some of this is that I'm so damn rusty at C coding. Here's the deal:

The calling function passes an argument (Z509_REG1 which is an INT32 type) to the function GET_TIME_OF_DAY

GET_TIME_OF_DAY assigns it's own "argument register" to the space allocated to that argument (which it accepted as arg1):

Z502_REG_ARG1.PTR = (void *)arg1;

This is a union, whose declaration looks like this:

typedef union
{
void *PTR;
INT32 VAL;
} Z502_ARG;

Now... I have a service call underneath all this that actually uses our 'hardware' to get the time of day (no problem, got it - as an INT32). And I need to send this information back - via Z502_REG_ARG1.

Since the original call expects a specific address, the challenge is - getting the value into the Z502_REG_ARG1 pointer, without changing the location of the pointer's address. I'd have thought that would be:

(INT32 *)Z502_REG_ARG1.PTR = os_get_time();

Where os_get_time() is the function I'm using to get the time from the hardware.

But that doesn't get the value where it needs to go. I've tried a couple other permutations, but I'm out of ideas.

And the answer is...

Date: 2005-09-20 01:01 pm (UTC)
From: [identity profile] lakshmi-amman.livejournal.com
*(INT32 *)Z502_REG_ARG1.PTR = os_get_time();

Apparently by doing just (INT32 *) I was casting, but not dereferencing the pointer, I need to dereference it too.

That's just evil.

Why is it that you only get the answer after you've raised your hand to ask for help? :)

Re: And the answer is...

Date: 2005-09-20 01:47 pm (UTC)
From: [identity profile] suba-al-hadid.livejournal.com
Happens to me all the time. I discovered to my great joy that I can explain my problem even to folks who know *nothing* about computers, and as a result of trying to explain it, I get the insight I needed. I say, "Thank you!" and the other person is left saying cautiously, "You're welcome?"

February 2021

S M T W T F S
 123456
78910111213
14151617181920
212223 24252627
28      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 27th, 2026 05:55 am
Powered by Dreamwidth Studios