![]() | ![]() ![]() |
| ![]() |
|
PicPuter features many different addressing modes and most commands allow you to use any type of addressing. This helps make PicPuter BASIC a very flexible and rich language. There is two types of memory that a variable can access, internal ram, or flash memory. These types access the internal ram. There are 26 user variables A-Z and are treated 16 bit signed values. examples: A,B,C...Z Kernel variables are treated 16 bit signed values. examples: CONFIGURATOR, EVENTS, ADC0, ADC7, USAGE,RND The upper 8 bits of a 16bit varaible may be accessed by including the sufix 'h' it is read as an 8 bit unsigned value. examples: Ah, Bh, ADC0h, RNDh Internal registers are treated 8 bit unsigned values. examples: INTCON, PIE1, PIR1, PORTB, TRISB Kernel registers are treated 8 bit unsigned values. examples: HOUR,SEC,TICK,RESET All of the above data types can be used in an Array. Arrays allow you access a group of related data using an index. The index may be a contant , variable, or register. The expression A[1] would access B, A[2] access C. There is 31-26 unused variables after the variable Z, this would be a good location for a small array. examples: A[1], A[B], A[ADC0h], A[RND], SEC[Ah] A flash location is accessed by preceeding the variable with and *. The flash memory is only 14 bits wide. The 14 bit value is treated as a signed value on read, and the upper two bits are dropped on write. Since flash memory can wear out, care should be taken not to write a single location too many times. Reads do not wear out the flash. When a variable is preceeded by an asterisk its contents is treated as the address. So if A=$600 then *A would access the flash location at $600. This location can also be accessed by the constant expression *$600. examples: *10, *$A, *A, *Ah, *RND Arrays that access flash are also possible. When accessing flash, the index of the array is added to the address. If a=$600 then the expression *A[2] would access the flash location $602. examples: *A[0], *A[1] *A[B], *A[Bh], *Ah[RNDh], *RND[RND] |