From Swordfish Wiki

SwordfishUser: SFIDF

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.

Sample Code

// 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"

Debug Output

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

Overview

Please note the following is preliminary and is likely to change.

.exe Section

The first section is the .exe block. For example,

F0F1F2F3F4F5
$00000A$0E0A0000000058 
$000012$C0190000000045I00001

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..."

.file Section

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"

.module Section

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.

.import

The .import keyword denotes modules that have been included. The .import keyword is followed by a unique module ID and module name.

.proc, .func, .event and .isr Section

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

F0F1F2F3F4F5F6F7F8
Scope00001$0000C00010$001900050004500046MyFunc

.con

All information pertaining to a .con debug item is held on a single line and consists of the following fields

F0F1F2F3F4F5
Scope$000001A00110000U08CString

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.

.var

All information pertaining to a .var debug item is held on a single line and consists of the following fields

F0F1F2F3F4F5F6
Scope$00190000000000U08pIndex

.structure Section

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

F0F1F2F3
Scope00001002TXY

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

F1F2F3F4F5
000000000000U08MyVar
Retrieved from http://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.SFIDF
Page last modified on May 19, 2008, at 11:45 AM