The following represents the current state of the Swordfish Intermediate Debug File (IDF) which is currently being implemented. As such, it is work in progress. The IDF is a structured text based file which will enable the compiler to support simulation and debugging. In addition, information contained in the file would allow plugins to display both ROM and RAM usage for subroutines, functions, events and interrupt routines.
// simple xy structure... Structure TXY x,y As Byte End Structure // a type of TXY structure... Type TMyType = TXY // big structure... Structure TStructure a,b,c As Byte xy As TMyType Union Alias As c End Structure // a function that return a structure... Public Function MyFunc(pIndex As Byte) As TStructure Dim lValue As Byte lValue = pIndex result.a = lvalue End Function // module level variables... Dim MyStructure As TStructure Dim OK,NotOK As Boolean Dim Index As Byte Dim Str As String Dim AliasStr As Str Dim ch As Str(10) // main program... Index = 10 MyStructure = MyFunc(Index) OK = true NotOK = false ch = "a"
The following shows the IDF output for the above program.
.exe $000000 | $EF04 sys | $000002 | $F000 sys | $000008 | $8C18 sys | $00000A | $D005 sys | $00000C | $C019 000 | 000 00045 C00001 $00000E | $F01A 000 | $000010 | $C01A 000 | 000 00046 C00001 $000012 | $F01B 000 | $000014 | $0012 000 | $000016 | $0E0A 000 | 000 00058 $000018 | $6E22 000 | $00001A | $C022 000 | 000 00059 $00001C | $F019 000 | $00001E | $DFF6 000 | $000020 | $EE00 000 | $000022 | $F01F 000 | $000024 | $EE10 000 | $000026 | $F01B 000 | $000028 | $0E03 000 | $00002A | $CFE6 000 | $00002C | $FFEE 000 | $00002E | $2EE8 000 | $000030 | $D7FC 000 | $000032 | $801E 000 | 000 00060 $000034 | $921E 000 | 000 00061 $000036 | $0E61 000 | 000 00062 $000038 | $6E2D 000 | $00003C | $D7FE end | .end .file 001 SystemTypes "C:\Programming\Borland\Swordfish\Compiler\Swordfish\Includes\18F4680.BAS" 000 MAIN "C:\Programming\Borland\Swordfish\Compiler\Swordfish\TestPrograms\debug\Debug.bas" .end .module 001 SystemTypes .var PUB $0D79 00 0000 0000 U08 RXF6SIDH .var PUB $0D7A 00 0000 0000 U08 RXF6SIDL ... and so on .var PUB $0F99 00 0000 0000 U08 PORTA .end .module 000 .import 001 SystemTypes .structure PRI 00001 0002 TXY .var 0000 0000 0000 U08 x .var 0008 0000 0000 U08 y .end .structure PRI 00002 0003 TStructure .var 0000 0000 0000 U08 a .var 0008 0000 0000 U08 b .var 0016 0000 0000 U08 c .var 0000 0000 0000 *00001 xy .var 0016 0000 0000 U08 Alias .end .func PUB 00001 $0000C 00010 $0019 0005 C000 00045 00046 MyFunc .var VAL $0019 00 0000 0000 U08 pIndex .var PRI $001A 00 0000 0000 U08 lValue .ret PUB $001B 00 0000 0000 *00002 MyFunc .end .var PRI $001E 00 0000 0000 U01 OK .var PRI $001E 01 0000 0000 U01 NotOK .var PRI $001F 00 0000 0000 *00002 MyStructure .var PRI $0022 00 0000 0000 U08 Index .var PRI $0023 00 0024 0000 U08 Str .var PRI $002D 00 0000 0000 U08 ch .end
Please note the following is preliminary and is likely to change.
The first section is the .exe block. For example,
F0 | F1 | F2 | F3 | F4 | F5 |
$00000A | $0E0A | 000 | 000 | 0058 | |
$000012 | $C019 | 000 | 000 | 0045 | I00001 |
The next three fields are optional. If present, they give information relating to a high level instruction. For example, "a = 10" or "if index < 10 then..."
The file section gives a unique module ID, module name and a fully qualifies path to the source file. For example,
001 SystemTypes "C:\Programming\Borland\Swordfish\Compiler\Swordfish\Includes\18F4680.BAS"
The modules section begins with a unique module ID followed by the module name. Every module section terminates with .end. For example,
.module 002 MyModule .end
A module section can hold multiple debug types. For example, structures, variables and procedures.
The .import keyword denotes modules that have been included. The .import keyword is followed by a unique module ID and module name.
The procedure section is always terminated with .end. For example,
.func PUB 00001 $0000C 00010 $0019 0005 00045 00046 MyFunc .end
A procedure section can hold multiple debug types. For example, structures and variables. A procedure section consists of the following fields
F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 |
Scope | 00001 | $0000C | 00010 | $0019 | 0005 | 00045 | 00046 | MyFunc |
All information pertaining to a .con debug item is held on a single line and consists of the following fields
F0 | F1 | F2 | F3 | F4 | F5 |
Scope | $000001A | 0011 | 0000 | U08 | CString |
Please note that .con debug items will only be generated for constants that are held in the compilers constant ROM table. These are typically strings and arrays. Constant debug entries are not made for single constant values that are generated within the main executable block.
All information pertaining to a .var debug item is held on a single line and consists of the following fields
F0 | F1 | F2 | F3 | F4 | F5 | F6 |
Scope | $0019 | 00 | 0000 | 0000 | U08 | pIndex |
A structure section is always terminated with .end. For example,
.structure PRI 0001 002 TXY .end
A structure section can hold multiple .var types. A structure section consists of the following fields
F0 | F1 | F2 | F3 |
Scope | 00001 | 002 | TXY |
A structure .var item has a slightly different format from other .var items, as no address information is present. For structure .var items, the fields are
F1 | F2 | F3 | F4 | F5 |
0000 | 0000 | 0000 | U08 | MyVar |