User Tools

Site Tools


intrinsic_statements

Intrinsic Statements

10LC includes some new intrinsic, or built-in, statements. Currently three of them are defined:

  • __Delay - standard delay routine, causes a real-time delay in the execution of a program
  • __Fill - fill a range of memory with a specific byte
  • __FillRamp - fill a range of memory with a byte whose value keeps increasing (and resets to 0x00 after 0xFF)

__Delay

The __Delay statement causes statement execution to pause for a specified amount of time. Internally, a special program is called and a counter value is decremented and tested against zero. If the value is greater than zero, the value is decremented and tested again, etc. until the value reaches zero and processing resumes.

The syntax of the statement is: __Delay <count>;

The counter value is a 32-bit value and a value of 25 is about 1 second.

__Delay 50;    // Delay For About 2 Seconds
__Delay Reg2;  // Delay For Whatever Value Is In REG2

__Fill

The __Fill statement fills a range of memory with a specific byte. During the fill operation, the byte value remains static.

The syntax of the statement is: __Fill From <address> To <address> With <byte>;

__Fill From Reg1 To Reg2 With 0xAA;

__FillRamp

The __FillRamp statement fills a range of memory with a byte value, and increments the byte value during the fill operation. After the byte reaches 0xFF (255) it is reset back to zero.

The syntax of the statement is: __FillRamp From <address> To <address> With <byte>;

__FillRamp From Reg1 To Reg2 With 0x42;

Implementation

The intrinsic statements are implemented via a custom program (Program #99, __IP__P99) that is added internally and compiled near the end of the compilation phase. Its implementation is as follows:

Program __IP__P99;
    Alias Command=RegF;                     // First Parameter  - Intrinsic Command
    Alias FromOrDelay=RegE;                 // Second Parameter - Start Of Fill Range or Delay Counter/Value
    Alias To=RegD;                          // Third Parameter  - End Of Fill Range
    Alias FillChar=RegC;                    // Fourth Parameter - Character to use for Fill/FillRamp      
 
    If Command == 1 Goto Delay;             // RegF == 1 - Delay
    If Command >= 2 Goto Fill;              // RegF == 2 - Fill, RegF == 3 - FillRamp
    Goto End;
 
    :Delay                                  // Delay Routine
        --FromOrDelay;
        If FromOrDelay > 0 Goto Delay;
        Goto End;
 
    :Fill                                   // Fill/FillRamp Routine
        Write @ FromOrDelay = FillChar;     // Write Fill Character Into Address
        ++FromOrDelay;                      // Increment Address
        If Command == 3 Goto RampInc;       // If RampFill, Goto RampInc
 
    :FillReturn                         
        If To >= FromOrDelay Goto Fill;     // If Not At End OF Fill Range, Goto Fill
        Goto End;
 
    :RampInc
        ++FillChar;                         // Increment Fill Character
        If FillChar > 0xFF Goto WrapChar;   // If Character Greater Than 0xFF, Goto WrapChar
        Goto FillReturn;                    // Go Back To Fill Routine
 
    :WrapChar
        FillChar = 0;                       // Reset Fill Character To Zero
        Goto FillReturn;                    // Go Back To Fill Routine
 
    :End                                        
EndProgram;                                 // End Of Program 99

When a intrinsic statement is encountered, the statement is replaced with code to populate the necessary registers with the necessary parameters and a call to Program 99 is made. For example, the following call to the __Delay intrinsic:

__Delay 50;

-Is replaced with the equivalent of the following code:

RegF = 1;
RegE = 50;
Execute 99;
intrinsic_statements.txt · Last modified: 2020/03/03 21:35 by jtwine