[A86] Re: Using hex values in strings?


[Prev][Index][Thread]

[A86] Re: Using hex values in strings?



On Tue, 09 Sep 2003 19:32:36 -0400, Andy Gombos wrote:

> I was writing a test input routine to get a feel for using the z88dk.  
> Using
> the format string "%s" would dump some given amount of memory, since 0x1B
> doesn't have a null terminator attached.  Using "%c" fixed the problem.
> Using the above method of embedding the character in the string would 
> have
> worked, had I known it.  On x86 systems, you don't normall have to enter
> characters as hex. ;)

That depends on what character you want and what compiler you're using.  
C99 only requires alphanumerics, whitespace and 29 other common 
characters, you'd still have to use '\xff' to get ÿ.  In any case you 
still have to null-terminate your strings, that isn't anything z88dk 
specific.

> I don't particularly want to write out four or five lines of assembly for
> each line of C code (normally).  Besides, if I see any major memory waste
> going on (printf for example, at ~1K) I'll rewrite the appropriate

If you're just experimenting, that's cool, but I'd strongly encourage you 
to use asm over the code z88dk emits.  There's not much you can do (for 
the TI-86) in small C that isn't almost as easy in asm.  Admittedly, C has 
its attractions:

char 
m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r;
r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c==
'+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(2,p,1),c-','||read(2,p,1));}

but I got the same functionality, with additional error checking, in 283 
bytes of TI-86/z80 object code (should be in ticalc.org archives RSN).

Cheers,
Dean Scarff



References: