User Tools

Site Tools


features

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
features [2020/02/16 19:12]
adminz
features [2020/02/26 17:15] (current)
jtwine [Enhanced Semantic Checks and Warnings]
Line 25: Line 25:
  
 ==== Enhanced Semantic Checks and Warnings ==== ==== Enhanced Semantic Checks and Warnings ====
-9LC already supported the use of symbolic identifiers for things ​like Program Names and Labels. ​ Howevertheir use was somewhat limited +like to think that 10LC is a little smarter than 9LC and because of thatthere some additional checks that 10LC can perform during the compilation and post-compile steps that might help spot bugs in your code.
  
-As an example, ​because 9LC did not prefix hexadecimal values ​(see above), you could not create symbolic identifiers that consisted solely of hexadecimal digits. ​ Also, 9LC's symbolic names only used 8 characters of significance,​ so it could not disambiguate identifiers like ''​**THISNAME**0'' ​and ''​**THISNAME**5''​. ​ With 10LC, the length of symbol names is effectively //​unbounded//​and all characters ​are significant.  ​+For example, ​if you have a the Z80 Pod specified ​(an 8-bit CPU), and perform a ''​Write'' ​operation that writes a value greater than 0x100 (255) to a memory location, a warning will now be emitted because that value is too large for an 8-bit word. 
 + 
 +Alsoaddress ranges are validated against ​the specified Pod as well. 
 + 
 +The 10LC compiler will also check for things like ProgramsLabels, Constants or Aliases that are never referenced, helping you look for bugs like cut-n-paste errors where you may have forgotten to change something.  ​Here are some example diagnostic warnings: 
 + 
 +<​code>​ 
 +ScriptFile.s(45,​1):​ Warning L0525: A global Constant named Speech1 was created but was never referenced 
 +ScriptFile.s(51,​1):​ Warning L0529: A global Alias named Unused was created but was never referenced 
 +ScriptFile.s(74,​5):​ Warning L0518: Program Main contains a defined Label UnusedLabel which was never referenced 
 +ScriptFile.s(230,​5):​ Warning L0519: Program TestSound contains a constant named None which was never referenced 
 +ScriptFile.s(231,​5):​ Warning L0519: Program TestSound contains a constant named Mute1 which was never referenced 
 +ScriptFile.s(237,​5):​ Warning L0519: Program TestSound contains a constant named Enable2 which was never referenced</​code>​
  
 +You can check out the full list of [[Warnings]] and [[Errors]] that can be emitted by 10LC.
  
 ==== Enhanced Symbolic Names for Programs and Labels ==== ==== Enhanced Symbolic Names for Programs and Labels ====
Line 35: Line 48:
 As an example, because 9LC did not prefix hexadecimal values (see above), you could not create symbolic identifiers that consisted solely of hexadecimal digits. ​ Also, 9LC's symbolic names only used 8 characters of significance,​ so it could not disambiguate identifiers like ''​**THISNAME**0''​ and ''​**THISNAME**5''​. ​ With 10LC, the length of symbol names is effectively //​unbounded//,​ and all characters are significant.  ​ As an example, because 9LC did not prefix hexadecimal values (see above), you could not create symbolic identifiers that consisted solely of hexadecimal digits. ​ Also, 9LC's symbolic names only used 8 characters of significance,​ so it could not disambiguate identifiers like ''​**THISNAME**0''​ and ''​**THISNAME**5''​. ​ With 10LC, the length of symbol names is effectively //​unbounded//,​ and all characters are significant.  ​
  
-Lastly, note that all symbols in 10LC are case-insensitive. ​+Lastly, note that all symbols in 10LC are //case-insensitive// so ''​displaytest'',​ ''​DisplayTest'',​ and ''​DISPLAYTEST''​ all refer to the same symbol.
  
 <code c> <code c>
-Program CodeToTestInputs +Program CodeToTestInputs; 
-Program DisplayTest +Program DisplayTest; 
-Program DeadBeef+Program DeadBeef;
  
 :​DammitJimImADoctorNotATechnician ​ :​DammitJimImADoctorNotATechnician ​
Line 51: Line 64:
 Additionally,​ if you specify a specific program number, you will not create "​holes"​ in the numbering system. Unlike 9LC, 10LC numbers Programs dynamically in the order they are encountered during compilation,​ and they draw from a pool of available program numbers so that there are no limitations on the numbers chosen. Additionally,​ if you specify a specific program number, you will not create "​holes"​ in the numbering system. Unlike 9LC, 10LC numbers Programs dynamically in the order they are encountered during compilation,​ and they draw from a pool of available program numbers so that there are no limitations on the numbers chosen.
  
-For example, in 9LC, the third Program below would have a value of 6, but in 10LC it will have a value of 1.  Also, if you continue and create another five dynamically numbered ​programs, they will be numbered 2, 3, 4, **6**, and 7.  The manually-specified program number will not mess up the numbering.+For example, in 9LC, the third Program below would have a value of 6, but in 10LC it will have a value of 1.  Also, if you continue and create another five dynamically numbered ​Programs, they will be numbered 2, 3, 4, **6**, and 7.  The manually-specified program number will not mess up the numbering.
  
 <code c> <code c>
-Program TestInputs ​    // Create Program TestInputs, Defaults To Program 0  +Program TestInputs    // Create Program TestInputs, Defaults To Program 0  
-Program TestDisplay 5  // Create Program TestDisplay,​ Sets Program Number To 5  +Program TestDisplay 5 // Create Program TestDisplay,​ Sets Program Number To 5  
-Program DEADBeef ​      // Create Program DEADBeef, Defaults To Program **1**, Not 6  +Program DEADBeef      // Create Program DEADBeef, Defaults To Program **1**, Not 6 
-</​code>​ +
- +
-==== Constant Values ====  +
-You can create constant values that work like register Aliases but are strictly for constant numeric values and can be used anywhere a numeric value would be allowed. ​ Once a Const has been defined in a Program, it cannot be undefined nor redefined to another value. ​ Constants are not global and are scoped to the Program in which they are defined. +
- +
-<code c> +
-Const JoystickNone ​ = 0;  +
-Const JoystickUp ​   = 0x01;  +
-Const JoystickDown ​ = 0x02;  +
-Const JoystickLeft ​ = 0x04;  +
-Const JoystickRight = 0x08; +
-</​code>​ +
- +
-==== Global Constant Values ====  +
-You can also create //global// constant values that work like the above normal constant values, but are visible to **all** programs being compiled after the global constant has been declared. +
- +
-They work the same as ''​Const''​ values but must be declared //outside// the scope of a Program. As with Const values, once defined they cannot be undefined nor redefined to another value. +
- +
-<code c> +
-Global MemMapCtrlsP1 = 0x3400; +
-Global MemMapCtrlsP2 = 0x3401; +
-Global VideoMemStart = 0x2800; +
-Global ColorMemStart = 0x2C00;+
 </​code>​ </​code>​
  
 ==== Register Aliases ====  ==== Register Aliases ==== 
-Aliases allow you to refer to the standard register set (''​REG0''​-''​REGF''​) using symbolic names. ​ This is similar to existing 9LC functionality but without its restrictions. ​ Unless disabled by the ''​[[Command Line#​Compiler Options|NoPreDefines]]''​ compiler option, 10LC will automatically create the following legacy register ​aliases+Aliases allow you to refer to the standard register set (''​REG0''​-''​REGF''​) using symbolic names. ​ This is similar to existing 9LC functionality but without its restrictions. ​ Unless disabled by the ''​[[Command Line#​Compiler Options|NoPreDefines]]''​ compiler option, 10LC will automatically create the following legacy register ​Aliases
   * **BITMASK** = ''​REGA''​   * **BITMASK** = ''​REGA''​
   * **ROMSIG** = ''​REGB''​   * **ROMSIG** = ''​REGB''​
Line 92: Line 82:
   * **PDBAT** = ''​REG0''​   * **PDBAT** = ''​REG0''​
  
-One of the differences between 10LC's Alias statement and 9LC's ASSIGN statement is that an Alias can be created anywhere within a Program - they do not have to be all grouped together in a dedicated section at the top of the file.  Once an Alias has been defined ​in a Program, it cannot be undefined nor redefined to another Register.  Like Constants, Aliases are not global and are scoped to the Program in which they are defined. ​ Also, you cannot create a global alias in 10LC.+One of the differences between 10LC'​s ​''​Alias'' ​statement and 9LC's ASSIGN statement is that an Alias can be created anywhere within a Program ​(or globally, see below) ​- they do not have to be all grouped together in a dedicated section at the top of the file.  Once an Alias has been defined, it cannot be undefined nor redefined to another Register.
  
 <code c> <code c>
Line 98: Line 88:
 Alias Control2Bits = Reg2; Alias Control2Bits = Reg2;
 </​code>​ </​code>​
 +
 +Aliases can be //Global// or //​Local//​. ​ A Global Alias is created by setting an ''​Alias''​ statement outside of a Program. ​ Global Aliases are visible to all other Programs being compiled. ​ Local Aliases are created within a Program and are only visible to that specific Program.
 +
 +==== Constant Values ==== 
 +You can create constant values that work like register Aliases but are strictly for constant numeric values and can be used anywhere a numeric value would be allowed. ​ Once a Const has been defined in a Program, it cannot be undefined nor redefined to another value. ​ Constants are not global and are scoped to the Program in which they are defined.
 +
 +Like Aliases, Constants can be //Global// or //​Local//​. ​ A Global Constant is created by setting a ''​Const''​ statement outside of a Program. ​ Global Constants are visible to all other Programs being compiled. ​ Local Constants are created within a Program and are only visible to that specific Program.
 +
 +<code c>
 +Const JoystickNone ​ = 0; 
 +Const JoystickUp ​   = 0x01; 
 +Const JoystickDown ​ = 0x02; 
 +Const JoystickLeft ​ = 0x04; 
 +Const JoystickRight = 0x08;
 +</​code>​
 +
  
 ==== Less-Than and Less-Than-Or-Equals Tests ====  ==== Less-Than and Less-Than-Or-Equals Tests ==== 
Line 139: Line 145:
 Read From 0x3200 Into Control1Bits; ​ Read From 0x3200 Into Control1Bits; ​
 Read From 0x3201 Into Control2Bits;​ Read From 0x3201 Into Control2Bits;​
 +</​code>​
 +
 +
 +==== Sequence Reading Shortcut ====
 +If you need to read a small block of contiguous memory into a set of registers, you normally have to create a block of ''​Read''​ and register copy statements. ​ 10LC has a ''​ReadEx''​ statement that provides a shortcut way of doing this.  This statement allows you to set a starting place in memory followed by a list of registers. ​ 10LC will automatically //unroll// this ''​ReadEx''​ statement into multiple ''​Read''​ and register copy statements (essentially ''​Read Into''​ statements),​ automatically incrementing the address as it goes.  Aliases and Registers can all be used for the target registers. ​ For example:
 +
 +<code c>
 +ReadEx From 0x2000 Into RegA RegB Control2Bits Reg1;
 +</​code>​
 +
 +The above code will compile into the equivalent of the following discrete ''​Read Into''​ statements:
 +
 +<code c>
 +Read From 0x2000 Into RegA;
 +Read From 0x2001 Into RegB;
 +Read From 0x2002 Into Reg2;
 +Read From 0x2003 Into Reg1;
 +</​code>​
 +
 +
 +==== Sequence Writing Shortcut ====
 +If you need to fill small block of contiguous memory with specific values, you have to create a block of ''​Write''​ statements. ​ 10LC has a ''​WriteEx''​ statement that provides a shortcut way of doing this.  This statement allows you to set a starting place in memory followed by a list of values. ​ 10LC will automatically //unroll// this ''​WriteEx''​ statement into multiple ''​Write''​ statements, automatically incrementing the address as it goes.  Numeric values, Aliases and Registers can all be used.  For example:
 +
 +<code c>
 +WriteEx @ 0x1000 = 1 2 4 0x10 0x20 0x40 Control2Bits Reg4;
 +</​code>​
 +
 +The above code will compile into the equivalent of the following discrete ''​Write''​ statements:
 +
 +<code c>
 +Write @ 1000 = 1;
 +Write @ 1001 = 2;
 +Write @ 1002 = 4;
 +Write @ 1003 = 0x10;
 +Write @ 1004 = 0x20;
 +Write @ 1005 = 0x40;
 +Write @ 1006 = Reg2;
 +Write @ 1007 = Reg4;
 </​code>​ </​code>​
  
Line 164: Line 208:
  
 ==== Debugging Steps ==== ==== Debugging Steps ====
-A "step over pause" can be simulated by inserting code in-between each compiled statement that calls a program ​that shows the source code line number and pauses ​execution until you press Yes/Enter.  This feature is enabled and disabled by compiler directives in your code.  For example, the following code would cause cause a pause and the line number to be shown before the execution of each of the last two ''​WRITE''​ operations.+A "step over pause" can be simulated by inserting code in-between each compiled statement that calls a program ​which shows the source code line number and stops execution until you press **<​Cont>​** on the 9010A.  This feature is enabled and disabled by compiler directives in your code.  For example, the following code would cause cause a pause and the line number to be shown before the execution of each of the last two ''​WRITE''​ operations.
  
 <code c> <code c>
features.1581901967.txt.gz · Last modified: 2020/02/16 19:12 by adminz