---------------------- DLX - Assembler [ asmdlx v0.1 ] by Sylvain VIART February 2000 User's Guide ---------------------- ( dimanche 27 février 2000, 10:57:34 Est ) Overview : ---------- This document presents the features of [ asmdlx ] a DLX assembler. This file is user oriented, we mostly speak about program use and assembly file syntax. To modify program's behavior or understand some internal features refer to developer's guide (file: developer.txt) [ asmdlx ] is an assembler for the DLX instruction set. Instruction set can be found in [Refs]. The instructions are assembled refering to a static instruction table. (to change it you must recompile the assembler, See: developer.txt) Version 0.1 provides those features : ------------------------------------- - reserved words are case insensitive - identifiers are case sensitive - all integer instructions are supported - branch label computation (PC+4) - all labels or identifiers are global - only ONE source file can be assembled (no include mechanism available) - user can define global immediate constant - simple constant arithmetic computation is provided - user can reserve memory WORD storage at end of code - [ asmdlx ] use standard input (Cf. command line below) Index : ------- * Assembly File grammar * Delayed Branch and Jump * Program invocation on command line Assembly File grammar : ----------------------- Here follows the syntax of a assembler source file. This is not a valid source file, we attempt to show how the file content is organized. Capitalized text are part of reserved word, remember that they are case insensitive. We capitalize them to introduce them. > ; this is a comment, until end of line > > immed EQU 123 ; a constant in decimal > immed2 EQU X"3412_30AF" ; another constant in hexadecimal > > ; some '_' can be put in constant for readability, deci and hex are the only > ; allowed interger format > > label: > ADDI R31, immed > SW defines(R0), R31 > > ORG x"2000" ; code memory (re)positionning > instructions > ... > > DATA ORG X"8000" ; memory data positionning > defines _DWORD [65535] ; memory reservation, without initialisation > ; 65 Ko > define2 _DWORD 10 ; memory reservation, with initialisation = 10 > ... Integer constant arithmetic can be performed where integer constant is a valid parameter. (i.e: addi r3, r0, (5+label1)*4 ) Branch and Jump computation : ----------------------------- When branch destination are computed, the relative distance (address computation) to be added to PC (Program Counter) are calculated with the base of PC+4. Here an example : org 0 ; PC sw (r1), r4 ; 0x00 loop: addi r1, r1, 1 ; 0x04 seqi r1, r2, 20 ; 0x08 bnez r2, loop ; 0x0C (-distance) = 0x10 - 0x04 = 0x0C nop ; 0x10 Here is the generated code (form program output) : #code 3;0x000;AC240000; sw ( r1 ) , r4 4;0x004;20210001;loop : addi r1 , r1 , 1 5;0x008;60410014; seqi r1 , r2 , 20 6;0x00C;1440FFF4; bnez r2 , loop 7;0x010;00000000; nop #data Here the corresponding binary cutting out, in regard with DLX instruction encoding (I: immediate, R: register to register, J: jump) opcode rs1 rd immed_16 I:101011_00001_00100_0000_0000_0000_0000 -- sw ( r1 ) , r4 I:001000_00001_00001_0000_0000_0000_0001 -- loop : addi r1 , r1 , 1 I:011000_00010_00001_0000_0000_0001_0100 -- seqi r1 , r2 , 20 I:000101_00010_00000_1111_1111_1111_0100 -- bnez r2 , loop -- nop Program invocation on command line : ------------------------------------ [ asmdlx v0.1 ] don't support command line argument : - '1' on command line set debug mode - any other argument is opened as a source file for reading. [ asmdlx v0.1 ] reads its source file from the specified file and produce its output on stdout. Error message, if any, are on stderr. Errors don't stop assembling process. Error will be reported and a wrong assembly output will be generated. Here is the assembly text result format : ----------------------------------------- #code line_number;hexaddress;hex_code;text #data line_number;hexaddress;hex_code;text Here follows the description of each field : -------------------------------------------- '#code' and '#data' are spécial markers which introduce code and data segment. line_number: source file instruction line number in decimal. hexaddress : is instruction address in hexadecimal (multiple of 4 0,4,8,C) the size of this field is variable hex_code : is the 32 bits instruction code (4 bytes, 8 digits) text : is the parsed valid source corresponding to the assembled instruction vim: ts=8 sw=8 tw=78 et: