RBJ (Redcode oBJect)
(Added note about Endianess) |
Dan Tobias (Talk | contribs) (→Structure Descriptions: Link page on endianness) |
||
Line 25: | Line 25: | ||
== Structure Descriptions == | == Structure Descriptions == | ||
− | Int = 2 bytes in Little-endian format. | + | Int = 2 bytes in [[Endianness|Little-endian]] format. |
=== Header === | === Header === |
Latest revision as of 02:00, 14 December 2016
RBJ format belongs to XRK - Extra Redcode Kit, a complete Core Wars system for DOS by Marco Pontello. RBJ files contains an assembled binary version of a Redcode Warrior, usually written by the XRA - Extra Redcode Assembler. RBJ files also contains info about the warrior's author, name and version of the assembler used, date & time.
Contents |
[edit] File structure overview
An RBJ file is composed of 3 sections: Header, Code, Tail
The Tail is represented by 1 byte used as a checksum. To verify the integrity of a RBJ file, simply compare this value to the calculated checksum of the first (filesize - 1) bytes (that is Header + Code).
[edit] Structure Descriptions
Int = 2 bytes in Little-endian format.
[edit] Header
The Header is 75 bytes long, and is composed as follow:
Pos Field Len Data --------------------------------- 0 Version ID 1 Byte - decimal 1 Author 30 Chars 31 Made with 30 Chars 61 Serial Date&Time 8 FP64 69 Split Flag 1 Byte 70 Reserved 1 Byte 71 Program Len 2 Int 73 Start 2 Int
[edit] Code
The Code block is a sequence of (Program Len) blocks as follow:
Field Len Data --------------------------------- 0 Command 1 Byte +1 Mode A / B 1 Byte +2 Operand A 2 Int +4 Operand B 2 Int
[edit] Tail
One Byte as a checksum:
Field Len Data --------------------------------- 0 CheckByte 1 Byte ---------------------------------
[edit] Fields Descriptions
[edit] Header
[edit] Version ID
Decimal (Major ver. * 10 + Minor ver.) Ex: 12 = v1.2
[edit] Author
Warrior's programmer Name/Nick
[edit] Made with
Assembler used
[edit] Serial Date&Time
Floating Point value: Dec * 86400 = seconds from midnight / Int = days from some date
[edit] Split Flag
0 = No SPL opcode used (program doesn't split) !0 = Program may use SPL
[edit] Reserved
Not used
[edit] Program Len
Instructions count, length of the code block
[edit] Start
Point to the instruction where execution start
[edit] Code
[edit] Command
0 DAT 1 MOV 2 ADD 3 SUB 4 JMP 5 JMZ 6 JMN 7 DJN 8 CMP 9 (not used) 10 SPL
[edit] Mode A / B
Field A = low nibble Field B = high nibble 0 "#" Immediate 1 "$" Direct 2 "@" Indirect 3 "<" Indirect autodecremented
[edit] Operand A & B
2 bytes signed integer
[edit] Tail
[edit] CheckByte
Here's how to calc the checksum byte (in BASIC-like pseudocode):
Sum = 0 FOR i = 1 TO BufferLen STEP 1 Sum = Sum + BufferByte(i) NEXT i FOR i = 1 TO BufferLen STEP 2 Sum = Sum + BufferByte(i) NEXT i FOR i = 1 TO BufferLen STEP 3 Sum = Sum + BufferByte(i) NEXT i FOR i = 1 TO BufferLen STEP 4 Sum = Sum + BufferByte(i) NEXT i Sum = Sum AND 255