icasm : Retargetable IcpuED ASSEMBLERVersion 5.2 - 6/12/2000 - A. K. Uht1. IntroductionThis page describes the syntax and semantics of the icasm assembler used to generate the equivalent of machine code for the ICED Canned CPU. An ASCII hex code file suitable for downloading to the ICED protosys hardware (main memory) is created by the assembler. A listing file is also generated, consisting of the source lines prefixed with instruction addresses and opcodes (or data). Listing file example.icasm allows the use of symbolic names for instruction labels or constants. Address computations to determine relative or absolute addresses for branches are automatically performed by icasm. Regular decimal and hexadecimal numbers may also be used, of course. A symbol table may also optionally be created. This file is expressly for use with a ICED HP-1662CS logic analyzer. The analyzer uses it to recognize addresses and display the source labels with their corresponding instructions. The analyzer also uses it with the HP Software Analyzer to map (static) program source lines to (dynamic) executed instructions.
Retargeting the Assemblericasm is retargetable, i.e., it can be modified to be used for any set of mnemonics or Assembly language. Of course, the closer the new language to the old the easier it is. Adding an instruction can be done in many cases with the addition of only two lines of code and the modification of a third. Instructions are in the source files themselves.
Click here to obtain the icasm code. (It's in C.)
|
name.src | - source file, input to icasm | |
name.hex | - assembler output, IcpuED hex file, input to host monitor program, loaded into ICED main memory by monitor. This file is deleted by icasm if any errors are detected in name.src | |
name.lst | - listing file, output of icasm | |
name.gpa | - symbol table file, output of icasm |
3. icasm command lineicasm <source file> <output file> {-l <listing file>} {-s <symbol table file>}
ic alias 'icasm \!*.src \!*.hex -l \!*.lst'
ic name 4. Source file formatEach line not starting with a "*" has the format: field 1 field 2
field 3 field 4
5. Pseudo-ops, i.e., assembler directives
6. Assembler misc. and examplesSpecial characters:
Constants:Decimal numbers may be negative or positive, hex numbers positive only, although they may be interpreted as negative if their msb is a 1. Not all numbers may be negative: offsets and absolute word addresses must be positive; in these cases hex numbers are treated as unsigned integers.Character constants are not supported at this time, except in their
numeric representation (of course).
Examples:
Other:Macros are not supported at this time.7. Assembler mnemonicsFor a full list of valid IcpuED mnemonics, see IcpuED Instruction Set.icasm also recognizes the directives given above: pc,
equ, ds, dw
8. Suggested programming conventions
Example of subroutine calling and return assuming above conventions:brl r14, subrt3 branch to subroutine subrt3. . . . subrt3 st 0(r14),r15 store the old value of the PC on the stack sub r15,r15,r4 decrement stack pointer . . body of subroutine, with other calls . add r15,r15,r4 increment stack pointer ld r14,0(r15) restore link bri r14 return from the subroutine call 9. Complete example program.This is the benchmark program appearing elsewhere in ICED (or ELE 405) documentation. This is the listing file output of icasm; the source file is bmk.src. The source file does not contain the first three columns. Column one is just a line number. Column two contains the data or instruction data address. Column three contains the data or instruction machine code.IcpuED Assembler icasm.c Version 5.0
Appendix. Hex file formatYou may never need to know the following details, but they are here for your reference should you ever want to hack the binary or create interfaces for ICED memory loading or retrieval.The output hex file format of icasm consists of a series of ASCII characters interpreted as hex numbers, one number per line, no blank lines. There may be multiple blocks in a file, with no blank lines between the blocks. Each block consists of a 3-word header followed by the data. The header
entries are:
Example:There are two blocks in the following example, the first composed of 5 bytes to start at location 1000 and the second consisting of 2 32-bit words to start at location 2000. Therefore, when this code is loaded into ICED protosys memory, address 1002 holds 03, address 2004 holds 9abcdef0 (all numbers are hex), etc. 1000
|