Yeah, sorry... I'd been hacking on that all day with no success, and was more 
than a little cranky. Let me try again:
The global absolute label CSRX=0xF63A is the address of the X co-ordinate of 
the cursor on the screen. ("Im picking on it because it's the first variable to 
appear in m100.def.) A declaration of "extern char *CSRX" tells the compiler 
about it. So far so good right? 

(I don't know if writing to that value is a good plan? Never tried it?)

Anyway, the compiled smallc code can see the label CSRX. Unfortunately there 
seems to be no way to actually get it. :-(

The problem is that when smallc's generated code references a data label, it 
does so indirectly, both the data segment of the same source, and extern 
sources. Hence it emits "lhld CSRX" which loads HL with the  16-bit value 
pointed to by CSRX, and then treats   whatever the cursor X position and 
whatever the next byte is as a pointer. Not right!!!!!  What I need it to do is 
a simple "lxi h,CSRX" but that opcode is only generated when loading a constant 
from the source. :-(

So when an int foo is delcared, the label foo is treated as a pointer to a DW 
word. What I need, and the compiler has no way to offer, is a way to force that 
indirection to be skipped. :-(

Anyway, I've given up on that, I've got other stuff to test and more wrapper 
functions to write.

BTW it's going to look like main(char A, int HL) {}!!!! (Assuming it doeesn't 
find some weird way to screw with me there.I have to say, abandoning the 
standard library is a very liberating experience.... :-)

Willard
Sent from Samsung tablet

-------- Original message --------
From "John R. Hogerhuis" <[email protected]> 
Date: 03/23/2017  12:02 PM  (GMT-07:00) 
To Model 100 Discussion <[email protected]> 
Subject Re: [M100] Smallc tech note 
 


On Thu, Mar 23, 2017 at 1:55 AM, Willard Goosey <[email protected]> wrote:
Grrrr!!!!!!!

Ok, so. My m100.def has, for SmallC purposes,  3 classes of equates. ROM 
function that don't require arguments or return values, ROM functions that do 
require args or return values, and system variables.

Because I use sed to translate the ASM/ZMAC original equates into ASX syntax 
global equates, these all end up as global labels that are stored, name and 
value, in the .rel object files. This means that the first class of functions 
can be called with no further code from Small C. The second type of function 
requires wrapper functions. And that's. All good.

And I really really hoped that the system variables would be as easily used. 
Unfortunately it's not to be. A reference to extern char *CRSX (x=CRSX) 
generates "lhld CRSX \n mov a,m" when what I need is "lxi h, CRSX\n mov a,m" . 
I am very sad.

I've looked through the code generator already and there's no hope. It looks 
like the best I can do is have the system variable names as #defines. Anything 
else would result in a huge tabke of pointers in the .co file that might not 
even be used!


It's not clear to me how you're expecting it to work. You want it to derefence 
the pointer without you telling it to?

I'd think if you want to access the char referred to by the pointer at the 
address, you need to dereference the pointer.

extern char *CSRX;
char x;

x = *CSRX;
*CSRX = 0x65;

or are you talking about the address of a pointer

extern char **CSRX;

-- John. 

Reply via email to