[A86] Re: Using hex values in strings?


[Prev][Next][Index][Thread]

[A86] Re: Using hex values in strings?



On Sat, 06 Sep 2003 17:54:53 -0400, Andy Gombos wrote:

> Never mind, I had printf("%s", str) so an entire area of memory was 
> dumped out.  Is there some way to keep the format string the same by 
> adding a null terminator to the value (0x1B for the exponent E)?
Huh?  The format string is always going to be the same: "%s".  I'll assume 
you want to actually want to print the base-10 exponent E symbol and are 
having trouble.
using zcc +ti86 -v -startup=10

   char c = '\x1b';
   putchar (c);

works for me, as does

   const char *s = "1.2\x1b5";
   puts (s);

as does

   const char *s = "1.2\x1b5";
   printf ("%s",s);

The output for the last two is "1.2E5".  Not quite sure what you were 
doing.

>>   I'm using the z88dk cross-compiler to develop an ASM program, being 
>> reasonably proficient at C and only enough to understand what is
    ^^^  hmm.

Then again, we could give you your first lesson in asm just to show how 
easy it is.

#include "ti86asm.inc"          ;   ROM, RAM, character and key equates
.org            _asm_exec_ram
         ld      hl,str
         call    _puts
         ret
str:    .db     "1.2",Lexponent,"5",0
.end

(again, output is "1.2E5").

Cheers,
Dean Scarff



Follow-Ups: References: