
 Pocket LilC and Vi/C version 1.10 (c) 2001,2002 by Jim Steuert

 jsteuert@hotmail.com



ViC 1.10 Version:
=================

      1) Added gets( char * ) and  int getch() functions.

      2) Fixed cd .. and added abbreviations:

          cd sc    ===>  cd "Storage Card"
          cd md    ===>  cd "My Documents"
          cd ..    works properly now

      3) Note that program to compile must be loaded into
         the vi buffer first, and have a "start <prog>" line
         at the beginning and an "end" line to delimit the
         end of the c program. Unlike my mipslcc program, the
         compile is done only on the program in the vi buffer,
         not on a txt file in storage. Any c program must
         be brought into the vi buffer (using the >vi command
         or the OPEN menu option) and then compiled.


ViC 1.09 Version:
=================


NOTE:  Vi works for both MIPS and ARM versions.
       The c-subset compiler works ONLY on the ARM (and PocketPC 2002) version.

NOTE: AFTER UNZIPPING pocket vi/c PUT THE .c and .txt FILES
      IN THE "My Documents" DIRECTORY IN YOUR MACHINE OR
      ON A STORAGE CARD. THIS IS NECESSARY FOR THE STANDARD
      MICROSOFT FILE CHOOSER TO FIND THE FILES.


      The viarm.exe application (with both vi and c) may run
	  from any directory on your pocket pc or storage card.
	  Put it into your "\Windows\Start Menu\Programs"
	  directory and it will appear in your start menu.
	  You can also put it into your "\Program Files" directory
	  and it will show up in your "Programs" application.


      THE riscc.exe is a WIN32 command-line compiler, which
	  is invoked using the syntax from your win32 command prompt:

         riscc <filename>

      or 

         riscc -S <filename>    (which generates a listing)

     IT DOES NOT GENERATE A COMPILED PROGRAM (YET). HOWEVER,
	 IT IS A GOOD WAY OF CHECKING YOUR PROGRAM FROM THE PC,
	 BEFORE PUTTING IT ON THE POCKETPC AND DEBUGGING IT.



Pocket Vi/C (c) 2002 by Jim Steuert
===================================


   type > to enter console mode


console mode commands:
=====================

  =    keystroke scrolls screen back 5 lines
  tab  keystroke scrolls screen forward 5 lines

Note: unlike keystrokes, commands require
an enter at end of line

 help   - displays console mode help
 help vi - displays vi refernce card

 more   <filename> [ <search-string> ]
 ls     [<file>/*.xxx/xxx.*/... ]
 ls *.c           all .c files ...
 ls ..\*.txt      all .txt file in \
 pwd
 copy/cp   <filename>  <filename>
 rename/mv <filename>  <filename>
 del/rm    <filename>
 cd/mkdir/rmdir  <dirname>
 cd  "storage card"  - cd's to storage card
 cls
 vi <filename> - invokes vi from console
 cc [-S  [<name>] ] - compile with listing
 run                - runs compiled c pgm
 gen  <file> <recl> <seed> <nrecs> [r/x]
 hex  <filename> [<start-offset> [len] ]
 q   quits shell and goes back to main vi


vi editing keystrokes
=====================

 =     scroll cursor back 5 lines
 tab   scroll cursor forward 5 lines

 ]-shift screen right
 [-shift screen left
 h-left one char
 j-down one line
 k-up one line
 l-right
 x-delete char
 rc-replace c
 dd delete line
 d2 delete 2 lines
 dn delete n lines (n from 1 to 9)
 P-paste lines which were last deleted
 o-open a new line after current line
 i-insert before cursor
 a-append after cursor
 `  (back single quote) escape from any of o, i, or a (insert mode)
 /<string>  search for string
 n  next search again starting at line after cursor
 N  reverse search starting at line before cursor
 0 beginning of line
 $ end of line
 1 goto first line
 G goto last line
 g print current line number
 2-9  scroll down n lines (n from 2 to 9)
 mc   mark current line named c
 tc   goto mark named c
 -2 to -9 go up that many lines
 %  goes to matching brace in a c program (but not parens)


vi ex commands:
==============

   :e <file>                  edit <file> in current directory
   :w                         write to replace same file
   :w <file>                  write <file> in current directory
   :q                         quit with no write
   :g                         print current line
   :g<linenumber>             goto line <linenumber>


Note: the ex and vi mode escape is the
single back quote (key below z and x on soft keybd)


INITIALLY PUT ALL FILES IN "My Documents"
TO USE THE MENU FILE CHOOSER

FIRST, READ IN TEXT FILE example.c USING THE READ MENU PICK

THEN GET INTO console mode BY TYPING THE GREATER-THAN SYMBOL  >

NOW COMPILE IT BY TYPING cc AND HIT ENTER

  >cc

YOU WILL SEE

  Compile ok

NOW YOU CAN TYPE run AT THE CONSOLE PROMPT >

  >run

IT WILL ASK FOR ARGUMENTS WITH A USAGE STATEMENT

THEN TYPE

  >run  556  8000

YOU WILL SEE IT WORK


NOTE: THE COMPILER cc and run COMMANDS ONLY WORK
ON ARM PROCESSORS:  ***NOT*** ON MIPS PROCESSORS.


IF YOU TYPE  cc test2

 >cc test2         compiles the text buffer subfile "test2"
                   test2 is demarked by the 
                   text buffer lines

             start test2
              ...
              ...
             end

 >run

      will run the program if compiled ok

 >run -args-

      (see example below for argc,argv usage)

 >cc  ( compiles the first program delimited by start/end )

 >cc -S    ( compiles the first program and generates a listing )

 >cc test2  ( compiles program test2 but with no listing )

 >cc -S test2  ( compiles program test2 with a listing )

 >q         goes back to vi mode



Note that the printf program output goes to
the vi edit buffer, appended at the end.
You can delete everything after the cc test2
line by

1. using q to go into vi mode
2. just hit the 1 key to go to the top of the file
3. hit other digits 2 through 9 to cursor down
4. cursoring to that line (using j, k, or arrow keys,
5. typing dG  (which deletes to the end of the vi buffer)




start test2

char result[120];
long seed = 1;
long mulconst = 0x015a4e35;
long maskconst = 0x7fff;
long numwithocc;

main
{
reg long t;
reg long *avp;
reg long tablelongs;
reg long count;
reg char *array;
reg long i;

dialog("enter seed","788778",&result);
set t = strtoul(&result,0,0);
seed = t;
dialog("enter count","2000",&result);
set count = strtoul(&result,0,0);
set array = malloc(32768);

for (i=0 ;i<32768 ;i++)
{
    array[i] = 0;
}

for (i=0;i<count;i++)
{
  set t = myrand();
  array[t] = array[t] + 1;
}

for ( t = 1; t < 8 ; t++ )
{
  numwithocc = 0;
  for (i=0;i<32768;i++)
  {
    if ( array[i] == t )
    {
       numwithocc = numwithocc + 1;
    }
  }
  printf("occ=%2d  num=%9d\n",t,numwithocc);
}
free(array);
printf("done\n");
}



subroutine myrand
{
    reg long temp;
    seed = seed * mulconst;
    seed = seed + 1;
    temp = seed;
    temp >> 16;
    temp = temp & maskconst;
    return( temp );
}
end





Available C Runtime Functions:
=============================

printf
strtoul
memcpy
memcmp
strcpy
strcat
strcmp
sprintf
open
lseek
read
write
close
malloc
free
dialog    -- see dialogs.txt for usage





