Advertisement
bladamson

Untitled

Jun 23rd, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <peekpoke.h>
  5.  
  6. extern void logRegisterA( void );
  7.  
  8. void main()
  9. {
  10.     char hello[] = "Hello, world!";
  11.     char i;
  12.  
  13.     static char hello_static[] = "Hello, world!";
  14.     static char i_static;
  15.     static char len_static = 13;
  16.  
  17.     goto skip_the_broken_stuff_that_makes_an_endless_loop;
  18.  
  19.     // This block, using a normal local variable, does not work.
  20.     // I have tried many variations, and come to these conclusions:
  21.     //  - assignments to / incrementing 'i' seems to have no effect; it is always zero.
  22.     //  - hello's address is near the end of ZP ($00F2).  Everything that deep in the ZP is zeroed.
  23.     //  - strlen(hello) returns 0, which is unsurprising given the above.
  24.     __AX__ = strlen(hello);
  25.     logRegisterA(); // This is an asm routine that executes a custom opcode that logs A to the emulator's logfile.
  26.     for( i=0; i<strlen(hello); ++i )
  27.     {
  28.         POKE( 0x310+i, hello[i] );
  29.         //cputc( hello[i] );
  30.         __AX__ = hello[i];
  31.         logRegisterA();
  32.     }
  33.  
  34.     skip_the_broken_stuff_that_makes_an_endless_loop:
  35.  
  36.     // This block, using all static variables, /does/ work.
  37.     for( i_static=0; i_static<len_static; ++i_static )
  38.     {
  39.         POKE( 0x310+i_static, hello_static[i_static] );
  40.         //cputc( hello_static[i] );
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement