RSTS/E .BAC file format Conventions: SP = stack pointer addresses are actually address/2-256 Byte(s) Description ------- ----------- 0-1 Checksum (add words 1-end). This is word 0. 2-3 Corresponds to memory position 514. SP+1 Internal version # (upper byte). RSTS/E revision level (lower byte) SP+2 RSTS/E vesion level (CVT%$ format) SP+4 CSR area pointer SP+6 Count of saved CSR's pointer (CSCSR) SP+8 Pointer to saved CSRs (each CSR is 2 words) SP+8+(CSCSR*2) Math package description (upper byte) if < 128, then 4-word. If >127, negate and that is the scale factor (word size is upper byte). SP+28 Data area pointer (SPDA) SP+30 Text area pointer (SPTA) SP+38 Math package (2 or 4) SP+39 Scale factor. Take 256-(@(SP+39)), AND it with 255. Then get 10^value. SPDA+1214 Start of variable table SPDA+1152 STATUS SPDA+1156 ERL SPDA+1160 RECOUNT SPDA+1180 NUM2 SPDA+1184 NUM SPDA+1188 ERR SPDA+1190 DET SPDA+1198 PI SPDA+@SPDA Header to line 0 address The variable table is 26 entries long (1 for each letter). Each entry is a word position. 0 means no variables by that name. Otherwise, add value to SPDA+1214+entry number (0-23). Variable is stored backwards, byte-wise, from that address (-1) until you find a bye value > 127. That value is a flag with the following meanings (bit 128 is always set): AND 1 = integer AND 2 = floating AND 4 = string AND 8 = array AND 16 = function Note that if the variable type flag is on an odd byte, then the previous (even) byte is also that variable flag. For instance, if you had a variable "EXIT", you would look at the "E" entry in the table, take that pointer and search backwards for "XIT". After the variable type are the following: size (words) Description ------------ ----------- 1 Pointer to next type with same name (offset from this address) 1 Second permanent dimension if array. Value for integer. Top wrod of floating. Link for string. 1 First permanent dimension if array. Pointer for string. 1 Length if string. String size / 2 if virtual. 3 ? 1 Channel number * 2 (if virtual) Run-time environment Address Meaning ------- ------- 16-39 Last open file 16 (upper byte) = MSB of file size (or else 377) 18 PPN 20-24 Name 26 LSW of file size 28 Buffersize 30 Mode 32 Status 34 clustersize (0 means 256) 35 Protection code 36 Device name 38 Unit # & flags 46 Pointer to break flags (if <0 then break on all lines) 122 Break line 1 124 Break line 2 . . . 140 Break line 16 440 SCTH 442 SPTA 444 SPDA 446 Pointer to bottom (top) of SP stack #SP+40 Top (bottom) of traceback info. If = @446, then end of traceback information. @(SP+40) Return address for first block @(SP+42) Offset from SPTA for header pointer @(SP+46) >0 if function rather than SUB, and next 4 words are context info @(@(SP+42)+10) Line number Editor flag word: AND 16 = Check bit 32 AND 32 = Not compiled AND 128 = CONTinue allowed AND 2048 = EXTEND mode AND 8192 = default is EXTEND mode Key: AND 1 = BREAK enabled AND 8 = TRACE enabled To find contents of string, take pointer value and add link. Arrays: Take location of variable type - 28 as the base address Offset Description ------ ----------- 0 Link (add thsi value to memory pointed to by pointer) 2 Pointer to data (offset) 4 True if referenced 6 First current dimension 8 Second current dimension 10 I/O channel * 2 (0 if none) 22 Second permanent dimension 24 First permanent dimension I/O Channels: Address Description ------- ----------- @(SPDA+44+16) IOCHAN @(IOCHAN+x*16) IOINFO @IOINFO+2 0 if not open, otherwise offset from IOCHAN @IOINFO+4 Buffersize @IOINFO+6 Bytes in buffer @IOINFO+10 CHannel # * 2 (lower byte) @IOINFO+12 MSB of filesize (high byte) CCPOS (low byte) @IOINFO+14 LSW of filesize @(IOINFO+8)-@(IOINFO+2) is current pointer