Mercurial > hg > ede
view doc/general/ede.lyx @ 29:83e80c2c489c
seperated working emu code from broken emu code.
wrote dbg interface
author | james <jb302@eecs.qmul.ac.uk> |
---|---|
date | Sun, 13 Apr 2014 22:42:57 +0100 |
parents | a542cd390efd |
children | c0c2e99b6bb0 |
line wrap: on
line source
#LyX 2.0 created this file. For more info see http://www.lyx.org/ \lyxformat 413 \begin_document \begin_header \textclass article \use_default_options true \maintain_unincluded_children false \language english \language_package default \inputencoding auto \fontencoding global \font_roman lmodern \font_sans lmss \font_typewriter lmtt \font_default_family sfdefault \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \default_output_format default \output_sync 0 \bibtex_command default \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry false \use_amsmath 1 \use_esint 1 \use_mhchem 1 \use_mathdots 1 \cite_engine basic \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \use_refstyle 1 \index Index \shortcut idx \color #008000 \end_index \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \end_header \begin_body \begin_layout Title EDE: ELB816 Development Environment \end_layout \begin_layout Author James Bowden (110104485) \end_layout \begin_layout Abstract The ELB816 Development Environment consists of an assembler, emulator and debugger for the ELB816 microprocessor system. This report details the design and usage of each of its elements. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Standard \begin_inset CommandInset toc LatexCommand tableofcontents \end_inset \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Part Introduction and Specification \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Section Motivations \end_layout \begin_layout Standard The ELB816 architecture is designed to be a \begin_inset Quotes eld \end_inset simple to understand 8-bit microprocessor system to help learn about microproces sor electronics. \begin_inset Quotes erd \end_inset \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard The combination of an ELB816 emulator, debugger and assembler could be used as a set of tools for learning or teaching microprocessor programming without the intricacies of real-world commercial microprocessors getting in the way of a fundamental understanding of the subject. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard A PC based emulator would allow students to quickly develop and debug programs written in a simple assembly language on any modern desktop or laptop and an MCS-51 port running on an 8052 would allow students to test programs in an actual circuit. \end_layout \begin_layout Section Project Aims \end_layout \begin_layout Itemize Develop an assembler for the ELB816 assembly language. \end_layout \begin_layout Itemize Develop an emulated programmable microprocessor system based on the ELB816 architecture. \end_layout \begin_layout Itemize Develop a debugger that allows interactive debugging of programs running on the emulator. \end_layout \begin_layout Section Methodology \end_layout \begin_layout Subsection Assembler \end_layout \begin_layout Description Language: Python \end_layout \begin_layout Description Priority: First \end_layout \begin_layout Standard The assembler will be developed before anything else so that it can subsequently be used to assemble test programs during development of the emulator. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection Emulator \end_layout \begin_layout Description Language: C \end_layout \begin_layout Description Priority: Second \end_layout \begin_layout Standard The emulator will use only standard libraries in order to ensure it is portable between compilers and platforms. Specifically GCC for x86 and Keil C51 for Intel MCS-51. The emulator will first be developed on Linux to facilitated rapid development. It will be ported to MCS-51 once it is complete \end_layout \begin_layout Subsection Debugger \end_layout \begin_layout Description Language: C/Python \end_layout \begin_layout Description Priority: Second \end_layout \begin_layout Standard The debug interface will be developed along side the emulator. It will consist of a simple text based interface built into the emulator that will read commands using C's \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout stdio.h \end_layout \end_inset library. This means that on Linux the commands will be issued using \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout STDIN \end_layout \end_inset and on the MCS-51 version they will be issued over a serial interface. Python will be used to provide a cleaner interface for common debug procedures such as writing programs to memory and setting break-points. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard The remainder of this report is split into three parts, one for each component of the project, and will attempt to demonstrate the design and usage of each of these components. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Part Assembler \end_layout \begin_layout Standard The assembler is written in pure Python 2 using only the standard library. It assembles the assembly the language described in the ELB816 specification with a few minor differences. These differences are: \end_layout \begin_layout Itemize In-line arithmetic must be wrapped in curved brackets eg. start with '(' and end with ')'. This is a limitation of the design of the program and to change it would require a large amount of code to be re-written. \end_layout \begin_layout Itemize The only directives that have been implemented are \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout ORG \end_layout \end_inset , \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout EQU \end_layout \end_inset , \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout DB \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout DS \end_layout \end_inset . The other directives listed in the specification have not been implemented, but there omission is only due to time constraints and they could easily be implemented in a later version. \end_layout \begin_layout Itemize Macros have not been implemented also due to time constraints. \end_layout \begin_layout Standard The assembler consists of two files: \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout language.py \end_layout \end_inset which contains the language definition in an index and some functions to help encode instructions. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout assembler.py \end_layout \end_inset which contains the first and second pass functions and handles opening source files and writing binary files. \end_layout \begin_layout Standard The following sections details the design and behavior of the assembler. However it must be noted that these are abstract and high level descriptions that do not fully explain minor routines, but give an overview of the entire process. The full source code is attached in the Appendix and should be referenced for a deeper understanding of the program's operation. The final section is a short programmers manual demonstrating the assembler's features. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Section Data Structures \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout reserved arguments \end_layout \end_inset \end_layout \begin_layout Standard This structure contains a list of string representations of the reserved word arguments for the instruction set. These all equate to registers or register pointers. The full list is as follows: \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\ttfamily},captionpos=b,frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},tabsize=4" inline false status open \begin_layout Plain Layout a, c, bs, ie, flags, \end_layout \begin_layout Plain Layout r0, r1, r2, r3, \end_layout \begin_layout Plain Layout dptr, dpl, dph, \end_layout \begin_layout Plain Layout sp, sph, spl, \end_layout \begin_layout Plain Layout @a+pc, @a+dptr, @dptr \end_layout \end_inset \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout relative instructions \end_layout \end_inset \end_layout \begin_layout Standard This structure contains a list of string representations of the mnemonics of instructions that use relative addressing. The full list is as follows: \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\ttfamily},captionpos=b,frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},tabsize=4" inline false status open \begin_layout Plain Layout djnz, cjne, sjmp, jz, \end_layout \begin_layout Plain Layout jnz, jc, jnc, jpo, \end_layout \begin_layout Plain Layout jpe, js, jns \end_layout \end_inset \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout instruction index \end_layout \end_inset \end_layout \begin_layout Standard This structure contains an index of all possible instructions in the instruction set, along with the the corresponding opcode and instruction width. This is implemented using a combination of Python's dictionary, tuple and list objects. Its structure is demonstrated below: \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\ttfamily},captionpos=b,frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},tabsize=4" inline false status open \begin_layout Plain Layout mnemonic: (arg type, arg type, ...): [opcode, width] \end_layout \end_inset \end_layout \begin_layout Standard Each mnemonic has an entry in the parent index which returns another index of possible argument formats for that mnemonic with their corresponding opcode and length. Argument types can be either be one of the reserved arguments or one of the following values: \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout address \end_layout \end_inset , \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout pointer \end_layout \end_inset , \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout data \end_layout \end_inset or \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout label \end_layout \end_inset . Width is represented in number of bytes, ie. \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout width = 3 \end_layout \end_inset means 1 byte of opcode and 2 bytes of arguments. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout label index \end_layout \end_inset \end_layout \begin_layout Standard This structure is used to store an index of label definitions. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout equate index \end_layout \end_inset \end_layout \begin_layout Standard This structure is used to store an index of equated strings. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Section Functions \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout first_pass(source file) \end_layout \end_inset \end_layout \begin_layout Standard This function pre-processes a source file and stores it in a format containing the necessary data for the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout second_pass() \end_layout \end_inset function to assemble it. It processes labels and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout EQU \end_layout \end_inset directives by storing strings and their corresponding values in indexes and replacing any subsequent appearances of the string with the value. It prepares \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout ORG \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout DB \end_layout \end_inset statements for the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout second_pass() \end_layout \end_inset . It uses the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout tokenize() \end_layout \end_inset function to determine the argument symbols and operand bit string. Finally it uses the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout instruction index \end_layout \end_inset to determine the instruction width. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout second_pass(asm, label index) \end_layout \end_inset \end_layout \begin_layout Standard This function takes the pre-processed assembly code and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout label index \end_layout \end_inset output by \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout first_pass() \end_layout \end_inset as input. First it checks for \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout ORG \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout DB \end_layout \end_inset statements and handles them if necessary. Then it replaces any labels that were used before they were defined and therefore not replaced on by \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout first_pass() \end_layout \end_inset . It uses the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout instruction index \end_layout \end_inset to determine the opcode and the width of the instruction, then it writes the opcode and operand to the file. If the combined width of the opcode and operand is greater than the instruction width the function raises an error. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout tokenize(mnemonic, arguments) \end_layout \end_inset \end_layout \begin_layout Standard This function processes an instruction in order to produce a hashable symbol that represents the format of its arguments. This symbol is used to look up opcodes in the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout instruction index \end_layout \end_inset . It also detects string representations of numbers in the arguments and stores a C type struct representation of the operands to be returned along with the symbol. It does this with the help of the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout stoi() \end_layout \end_inset function and Python's \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout struct \end_layout \end_inset module . \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout stoi(string) \end_layout \end_inset \end_layout \begin_layout Standard This function is a general purpose function that is actually used throughout the code, although mainly in the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout tokenize() \end_layout \end_inset function. It takes a string as an input and tries to convert it to an integer using Pythons integer representation syntax. It can recognize decimal, octal, hexadecimal and binary numbers which are denoted with different prefixes. If it receives a string it can not represent as an integer it returns the string 'NaN', (Not a Number) \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard Below is an abstract representation of each functions logical process. The \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout first_pass() \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout second_pass() \end_layout \end_inset are represented in pseudo-code, however \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout stoi() \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout tokenize() \end_layout \end_inset are more easily understood when represented as flowcharts. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout first_pass \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\small\ttfamily},captionpos=b,frame=tb,framexbottommargin=3em,framextopmargin=3em,keywordstyle={\color{blue}},language=Python,showstringspaces=false,tabsize=4" inline false status open \begin_layout Plain Layout first_pass(source file): \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout address = 0 \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout for statement in source file: \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout remove comments \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout for word in statement: \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout if word is in equate index: \end_layout \begin_layout Plain Layout replace word with equated value \end_layout \begin_layout Plain Layout else if word is in label index: \end_layout \begin_layout Plain Layout replace word with address at label \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout if first word == 'org' \end_layout \begin_layout Plain Layout address = second word \end_layout \begin_layout Plain Layout else if last character of first word == ':': \end_layout \begin_layout Plain Layout remove ':' \end_layout \begin_layout Plain Layout add word = address to label index \end_layout \begin_layout Plain Layout next statement \end_layout \begin_layout Plain Layout else if second word == 'equ' \end_layout \begin_layout Plain Layout add first word = third word to equate index \end_layout \begin_layout Plain Layout next statement \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout mnemonic = first word \end_layout \begin_layout Plain Layout arguments = [second word ... last word] \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout symbol, constant = tokenize(arguments) \end_layout \begin_layout Plain Layout if mnemonic == 'db': \end_layout \begin_layout Plain Layout address = address + width of constant \end_layout \begin_layout Plain Layout next statement \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout width = instruction index[mnemonic][symbol][width] \end_layout \begin_layout Plain Layout address = address + width \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout append [mnemonic, argument, symbol, constant] to asm \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout return asm, label index \end_layout \end_inset \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout second_pass \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\small\ttfamily},breaklines=true,captionpos=b,frame=tb,framexbottommargin=3em,framextopmargin=3em,keywordstyle={\color{blue}},language=Python,tabsize=4" inline false status open \begin_layout Plain Layout second_pass(file, asm, label index): \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout address = 0 \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout for line in asm: \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout file offset = address \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout mnemonic, arguments, symbol, constant = line \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout if mnemonic == 'org': \end_layout \begin_layout Plain Layout address = first argument \end_layout \begin_layout Plain Layout next line \end_layout \begin_layout Plain Layout else if mnemonic == 'db': \end_layout \begin_layout Plain Layout write constant to file \end_layout \begin_layout Plain Layout address = address + width of constant \end_layout \begin_layout Plain Layout next line \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout for argument in arguments: \end_layout \begin_layout Plain Layout if argument is a label: \end_layout \begin_layout Plain Layout replace argument with address at label \end_layout \begin_layout Plain Layout symbol, data = tokenize(argument) \end_layout \begin_layout Plain Layout append data to constant \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout op, width = instruction index[mnemonic][symbol] \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout write op to file \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout if width of constant - width + 1 > 0: \end_layout \begin_layout Plain Layout raise error \end_layout \begin_layout Plain Layout else if: \end_layout \begin_layout Plain Layout write constant to file \end_layout \begin_layout Plain Layout address = address.+ width \end_layout \begin_layout Plain Layout \end_layout \begin_layout Plain Layout return file \end_layout \end_inset \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout tokenize \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Graphics filename /home/jmz/qm/ede/doc/images/assembler/tokenize.svg scale 57 \end_inset \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout stoi \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Description \begin_inset Graphics filename /home/jmz/qm/ede/doc/images/assembler/stoi.svg scale 70 \end_inset \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Section Assembly language manual \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Part Emulator \end_layout \begin_layout Section Core microprocessor emulation \end_layout \begin_layout Standard The core of the emulator is written in C using only standard libraries. It executes the machine code output by the assembler according to the ELB816 specification. It consists of the following files: \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout iset.c \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout iset.h \end_layout \end_inset \end_layout \begin_layout Standard These files contain the emulator instruction functions and function look-up table. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.c \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.h \end_layout \end_inset \end_layout \begin_layout Standard These files contain the emulators memory structure and memory access functions. \end_layout \begin_layout Itemize \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout emu.c \end_layout \end_inset \end_layout \begin_layout Standard This file contains the program's \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout main() \end_layout \end_inset function. It initializes the emulator and executes the programs fetch/decode/execute cycle. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard Below is a high level description of the content of each of these files which should demonstrate how the emulator works. There is also a large amount of material relevant to the emulator's design in the appendix, which will be referenced when applicable. \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout iset.c \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout iset.h \end_layout \end_inset \end_layout \begin_layout Standard Each mnemonic in the ELB816 instruction set has a function defined in these files. Each function is responsible for execution of all the instructions that use its corresponding mnemonic. The function look-up table is an array of pointers to these functions, where a pointer's position in the list corresponds to the opcode of the instruction to be executed. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.c \end_layout \end_inset and \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.h \end_layout \end_inset \end_layout \begin_layout Standard The figures bellow illustrate the emulator's memory layout as defined in the \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.h \end_layout \end_inset header file. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout mem.c \end_layout \end_inset contains functions that can be used to access this memory from the rest of the code. \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Subsection \begin_inset listings lstparams "basicstyle={\ttfamily}" inline true status open \begin_layout Plain Layout emu.c \end_layout \end_inset \end_layout \begin_layout Standard This file contains the emulator's set-up and control procedures. It includes all of the projects header files and controls the execution of the functions contained in them. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard It first executes a number of initialization procedures and then passes control over to the main fetch/decode/execute cycle. This procedure is shown below as a flowchart. To understand this it you must be familiar with C's function pointer syntax. \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash bigskip \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash centerline{ \end_layout \end_inset \begin_inset Graphics filename /home/jmz/qm/ede/doc/images/emulator/fetch_decode_exe.svg scale 70 \end_inset \begin_inset ERT status open \begin_layout Plain Layout } \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \begin_layout Section Peripherals \end_layout \begin_layout Standard \begin_inset Newpage newpage \end_inset \end_layout \end_body \end_document