20
LatticeMico
8
Microcontroller
Lattice Semiconductor
User’s Guide
Building Assembler from Source
Although Lattice provides precompiled binary files, the source is available for compilation. The following commands
should be used in the Unix and Windows environments.
•
Unix and Cygwin Environments:
gcc -o isp8asm isp8asm.c
•
Windows Environment:
cl -o isp8asm_win isp8asm.c
Instruction Set Simulator
The software tools for LatticeMico8 include an Instruction Set Simulator for the microcontroller which allows pro-
grams developed for the microcontroller to be run and debugged on a host platform. The Simulator can also be
used to generate a disassembly listing of a LatticeMico8 program. The Simulator takes as input the memory output
file of the Assembler. It emulates the instruction execution of the LatticeMico8 in software. Please note that the
Simulator does not handle interrupts.
Command Line
<executable filename> -option1 -option2 ... <input filename>
Command Line Option
Option
Comment
-p <Program Rom Size>
Default is 512 bytes.
-x
Use external scratch pad memory. Refer to the Functional Description section of
this document for details.
-ix
Program file is in hexadecimal format (default). This is the file generated by the
Assembler with the -vx options (default).
-ib
Program file is in binary format. This is the file generated by the Assembler with the
-vb option.
-t
Trace the execution of the program. The Simulator will generate a trace as it exe-
cutes each instruction. It will also print the modified value of any register (if the
instruction modifies a register value).
-d
Generate a disassembly of the program specified by the PROM file.
Simulator Interactions
The
import
,
importi
and
export
,
exporti
instructions can be used to interact with the simulator. When an
export
,
exporti
instruction is executed, the simulator will print the value of the port number as well as the con-
tents of the exported register. If the port number is 0xFF, the simulator will terminate with an exit code identical to
the value of the exported register. When an
import
,
importi
instruction is executed, the simulator will issue a
prompt containing the port number and read in values from the standard input (stdin). The following figure shows
an example of a traced simulation.
Figure 5. Example of Trace Simulation
0x00001
0x10000
mov R00,R00
0x00002
0x12055
movi R00,0x55
R00 = 0x55
0x00003
0x12105
movi R01,0x05
R01 = 0x05
0x00004
0x12203
movi R02,0x03
R02 = 0x03
0x00005
0x08110
add R01,R02