Mercurial > hg > ede
changeset 42:792da050d8c4 tip
more dox
author | james <jb302@eecs.qmul.ac.uk> |
---|---|
date | Tue, 22 Apr 2014 14:25:14 +0100 |
parents | a9bf262f557b |
children | |
files | bin/emu docs/.~lock.elb816_opcodes.csv# docs/elb816_opcodes.csv docs/lyx/#appendix.lyx# docs/lyx/#asm.lyx# docs/lyx/#dbg.lyx# docs/lyx/#ede.lyx# docs/lyx/#emu.lyx# docs/lyx/#final_report.lyx# docs/lyx/#review.lyx# docs/lyx/appendix.lyx docs/lyx/appendix.lyx~ docs/lyx/asm.lyx docs/lyx/asm.lyx~ docs/lyx/dbg.lyx docs/lyx/dbg.lyx~ docs/lyx/ede.lyx docs/lyx/ede.lyx~ docs/lyx/emu.lyx docs/lyx/emu.lyx~ docs/lyx/final_report.lyx docs/lyx/final_report.lyx~ docs/lyx/intro.lyx docs/lyx/intro.lyx~ docs/lyx/review.lyx docs/lyx/review.lyx~ emu/iset.c out |
diffstat | 27 files changed, 938 insertions(+), 7645 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/.~lock.elb816_opcodes.csv# Tue Apr 22 14:25:14 2014 +0100 @@ -0,0 +1,1 @@ +,jmz,xthUnk,22.04.2014 14:14,file:///home/jmz/.config/libreoffice/4; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/elb816_opcodes.csv Tue Apr 22 14:25:14 2014 +0100 @@ -0,0 +1,259 @@ +ELB816 instruction set V1.0 + +Dec HEX Binary Mnemonic Register transfer description Comments +0 00 00000000 NOP PC = PC+1 No Operation +1 01 00000001 reserved currently unallocated opcode - treat as NOP +2 02 00000010 reserved currently unallocated opcode - treat as NOP +3 03 00000011 reserved currently unallocated opcode - treat as NOP +4 04 00000100 reserved currently unallocated opcode - treat as NOP +5 05 00000101 reserved currently unallocated opcode - treat as NOP +6 06 00000110 reserved currently unallocated opcode - treat as NOP +7 07 00000111 reserved currently unallocated opcode - treat as NOP +8 08 00001000 SET C 1 -> CY Set carry bit to 1 +9 09 00001001 CLR C 0 -> CY Set carry bit to 0 +10 0A 00001010 SET BS 1 -> BS Switch to register bank 1 +11 0B 00001011 CLR BS 0 -> BS Switch to register bank 0 +12 0C 00001100 SET IE 1 -> IE Enable interrupts +13 0D 00001101 CLR IE 0 -> IE Disable interrupts +14 0E 00001110 CPL C not CY -> CY Complement carry bit +15 0F 00001111 CPL A not A -> A Complement accumulator +16 10 00010000 XCSD SP -> DPTR : DPTR -> SP Exchange SP with DPTR +17 11 00010001 SFA FLAGS -> A store flags to accumulator +18 12 00010010 LAF A -> FLAGS load accumulator to flags +19 13 00010011 MOV DPTR, SP SP -> DPTR move word SP to DPTR +20 14 00010100 MOV SP, DPTR DPTR -> SP move word DPTR to SP +21 15 00010101 MOV A, #data8 data8 -> A move immediate byte to accumulator +22 16 00010110 MOV SP, #data16 data16 -> SP move immediate word to SP +23 17 00010111 MOV DPTR, #data16 data16 -> DPTR move immediate word to DPTR +24 18 00011000 MOV A, addr16 main[addr16] -> A move data from direct address to accumulator +25 19 00011001 MOV addr16, A A -> main[addr16] move data from accumulator to direct address +26 1A 00011010 MOV A, @A+DPTR main[DPTR+A] -> A indexed move relative to DPTR to accumulator +27 1B 00011011 MOV A, @A+PC main[PC+A] -> A indexed move relative to PC to accumulator +28 1C 00011100 MOV A, @addr16 main[main[addr16]] -> A move data from indirect address to accumulator +29 1D 00011101 MOV @addr16, A A -> main[main[addr16]] move data from accumulator to indirect address +30 1E 00011110 MOV A, @DPTR main[DPTR] -> A register indirect move to accumulator +31 1F 00011111 MOV @DPTR, A A -> main[DPTR] register indirect move from accumulator +32 20 00100000 MOV @DPTR, R0 R0 -> main[DPTR] +33 21 00100001 MOV @DPTR, R1 R1 -> main[DPTR] +34 22 00100010 MOV @DPTR, R2 R2 -> main[DPTR] +35 23 00100011 MOV @DPTR, R3 R3 -> main[DPTR] +36 24 00100100 MOV @DPTR, DPH DPH -> main[DPTR] +37 25 00100101 MOV @DPTR, DPL DPL -> main[DPTR] +38 26 00100110 MOV @DPTR, SPH SPH -> main[DPTR] +39 27 00100111 MOV @DPTR, SPL SPL -> main[DPTR] +40 28 00101000 MOV R0, #data8 data8 -> R0 +41 29 00101001 MOV R1, #data8 data8 -> R1 +42 2A 00101010 MOV R2, #data8 data8 -> R2 +43 2B 00101011 MOV R3, #data8 data8 -> R3 +44 2C 00101100 MOV DPH, #data8 data8 -> DPH +45 2D 00101101 MOV DPL, #data8 data8 -> DPL +46 2E 00101110 MOV SPH, #data8 data8 -> SPH +47 2F 00101111 MOV SPL, #data8 data8 -> SPL +48 30 00110000 MOV R0, A A -> R0 +49 31 00110001 MOV R1, A A -> R1 +50 32 00110010 MOV R2, A A -> R2 +51 33 00110011 MOV R3, A A -> R3 +52 34 00110100 MOV DPH, A A -> DPH +53 35 00110101 MOV DPL, A A -> DPL +54 36 00110110 MOV SPH, A A -> SPH +55 37 00110111 MOV SPL, A A -> SPL +56 38 00111000 MOV A, R0 R0 -> A +57 39 00111001 MOV A, R1 R1 -> A +58 3A 00111010 MOV A, R2 R2 -> A +59 3B 00111011 MOV A, R3 R3 -> A +60 3C 00111100 MOV A, DPH DPH -> A +61 3D 00111101 MOV A, DPL DPL -> A +62 3E 00111110 MOV A, SPH SPH -> A +63 3F 00111111 MOV A, SPL SPL -> A +64 40 01000000 MOV R0, @DPTR main[DPTR] -> R0 +65 41 01000001 MOV R0, R1 R1 -> R0 +66 42 01000010 MOV R0, R2 R2 -> R0 +67 43 01000011 MOV R0, R3 R3 -> R0 +68 44 01000100 MOV R0, DPH DPH -> R0 +69 45 01000101 MOV R0, DPL DPL -> R0 +70 46 01000110 MOV R0, SPH SPH -> R0 +71 47 01000111 MOV R0, SPL SPL -> R0 +72 48 01001000 MOV R1, R0 R0 -> R1 +73 49 01001001 MOV R1, @DPTR main[DPTR] -> R1 +74 4A 01001010 MOV R1, R2 R2 -> R1 +75 4B 01001011 MOV R1, R3 R3 -> R1 +76 4C 01001100 MOV R1, DPH DPH -> R1 +77 4D 01001101 MOV R1, DPL DPL -> R1 +78 4E 01001110 MOV R1, SPH SPH -> R1 +79 4F 01001111 MOV R1, SPL SPL -> R1 +80 50 01010000 MOV R2, R0 R0 -> R2 +81 51 01010001 MOV R2, R1 R1 -> R2 +82 52 01010010 MOV R2, @DPTR main[DPTR] -> R2 +83 53 01010011 MOV R2, R3 R3 -> R2 +84 54 01010100 MOV R2, DPH DPH -> R2 +85 55 01010101 MOV R2, DPL DPL -> R2 +86 56 01010110 MOV R2, SPH SPH -> R2 +87 57 01010111 MOV R2, SPL SPL -> R2 +88 58 01011000 MOV R3, R0 R0 -> R3 +89 59 01011001 MOV R3, R1 R1 -> R3 +90 5A 01011010 MOV R3, R2 R2 -> R3 +91 5B 01011011 MOV R3, @DPTR main[DPTR] -> R3 +92 5C 01011100 MOV R3, DPH DPH -> R3 +93 5D 01011101 MOV R3, DPL DPL -> R3 +94 5E 01011110 MOV R3, SPH SPH -> R3 +95 5F 01011111 MOV R3, SPL SPL -> R3 +96 60 01100000 MOV DPH, R0 R0 -> DPH +97 61 01100001 MOV DPH, R1 R1 -> DPH +98 62 01100010 MOV DPH, R2 R2 -> DPH +99 63 01100011 MOV DPH, R3 R3 -> DPH +100 64 01100100 MOV DPH, @DPTR main[DPTR] -> DPH +101 65 01100101 MOV DPH, DPL DPL -> DPH +102 66 01100110 MOV DPH, SPH SPH -> DPH +103 67 01100111 MOV DPH, SPL SPL -> DPH +104 68 01101000 MOV DPL, R0 R0 -> DPL +105 69 01101001 MOV DPL, R1 R1 -> DPL +106 6A 01101010 MOV DPL, R2 R2 -> DPL +107 6B 01101011 MOV DPL, R3 R3 -> DPL +108 6C 01101100 MOV DPL, DPH DPH -> DPL +109 6D 01101101 MOV DPL, @DPTR main[DPTR] -> DPL +110 6E 01101110 MOV DPL, SPH SPH -> DPL +111 6F 01101111 MOV DPL, SPL SPL -> DPL +112 70 01110000 MOV SPH, R0 R0 -> SPH +113 71 01110001 MOV SPH, R1 R1 -> SPH +114 72 01110010 MOV SPH, R2 R2 -> SPH +115 73 01110011 MOV SPH, R3 R3 -> SPH +116 74 01110100 MOV SPH, DPH DPH -> SPH +117 75 01110101 MOV SPH, DPL DPL -> SPH +118 76 01110110 MOV SPH, @DPTR main[DPTR] -> SPH +119 77 01110111 MOV SPH, SPL SPL -> SPH +120 78 01111000 MOV SPL, R0 R0 -> SPL +121 79 01111001 MOV SPL, R1 R1 -> SPL +122 7A 01111010 MOV SPL, R2 R2 -> SPL +123 7B 01111011 MOV SPL, R3 R3 -> SPL +124 7C 01111100 MOV SPL, DPH DPH -> SPL +125 7D 01111101 MOV SPL, DPL DPL -> SPL +126 7E 01111110 MOV SPL, SPH SPH -> SPL +127 7F 01111111 MOV SPL, @DPTR main[DPTR] -> SPL +128 80 10000000 ANL A, R0 A and R0 -> A +129 81 10000001 ANL A, R1 A and R1 -> A +130 82 10000010 ANL A, R2 A and R2 -> A +131 83 10000011 ANL A, R3 A and R3 -> A +132 84 10000100 ANL A, DPH A and DPH -> A +133 85 10000101 ANL A, DPL A and DPL -> A +134 86 10000110 ANL A, #data8 A and data8 -> A +135 87 10000111 ANL A, @DPTR A and main[DPTR] -> A +136 88 10001000 ORL A, R0 A or R0 -> A +137 89 10001001 ORL A, R1 A or R1 -> A +138 8A 10001010 ORL A, R2 A or R2 -> A +139 8B 10001011 ORL A, R3 A or R3 -> A +140 8C 10001100 ORL A, DPH A or DPH -> A +141 8D 10001101 ORL A, DPL A or DPL -> A +142 8E 10001110 ORL A, #data8 A or data8 -> A +143 8F 10001111 ORL A, @DPTR A or main[DPTR] -> A +144 90 10010000 XRL A, R0 A xor R0 -> A +145 91 10010001 XRL A, R1 A xor R1 -> A +146 92 10010010 XRL A, R2 A xor R2 -> A +147 93 10010011 XRL A, R3 A xor R3 -> A +148 94 10010100 XRL A, DPH A xor DPH -> A +149 95 10010101 XRL A, DPL A xor DPL -> A +150 96 10010110 XRL A, #data8 A xor data8 -> A +151 97 10010111 XRL A, @DPTR A xor main[DPTR] -> A +152 98 10011000 RL A rotate accumulator left +153 99 10011001 RLC A rotate accumulator left through carry +154 9A 10011010 RR A rotate accumulator right +155 9B 10011011 RRC A rotate accumulator right through carry +156 9C 10011100 INC DPTR DPTR + 1 -> DPTR Increment DPTR +157 9D 10011101 DEC DPTR DPTR -1 -> DPTR Decrement DPTR +158 9E 10011110 INC A A + 1 -> A Increment accumulator +159 9F 10011111 DEC A A - 1 -> A Decrement accumulator +160 A0 10100000 ADD A, R0 A + R0 -> A +161 A1 10100001 ADD A, R1 A + R1 -> A +162 A2 10100010 ADD A, R2 A + R2 -> A +163 A3 10100011 ADD A, R3 A + R3 -> A +164 A4 10100100 ADD A, DPH A + DPH -> A +165 A5 10100101 ADD A, DPL A + DPL -> A +166 A6 10100110 ADD A, #data8 A + data8 -> A +167 A7 10100111 ADD A, @DPTR A + main[DPTR] -> A +168 A8 10101000 ADDC A, R0 A + R0 + CY -> A +169 A9 10101001 ADDC A, R1 A + R1 + CY -> A +170 AA 10101010 ADDC A, R2 A + R2 + CY -> A +171 AB 10101011 ADDC A, R3 A + R3 + CY -> A +172 AC 10101100 ADDC A, DPH A + DPH + CY -> A +173 AD 10101101 ADDC A, DPL A + DPL + CY -> A +174 AE 10101110 ADDC A, #data8 A + data8 + CY -> A +175 AF 10101111 ADDC A, @DPTR A + main[DPTR] + CY -> A +176 B0 10110000 SUB A, R0 A - R0 -> A +177 B1 10110001 SUB A, R1 A - R1 -> A +178 B2 10110010 SUB A, R2 A - R2 -> A +179 B3 10110011 SUB A, R3 A - R3 -> A +180 B4 10110100 SUB A, DPH A - DPH -> A +181 B5 10110101 SUB A, DPL A - DPL -> A +182 B6 10110110 SUB A, #data8 A - data8 -> A +183 B7 10110111 SUB A, @DPTR A - main[DPTR] -> A +184 B8 10111000 SUBB A, R0 A - R0 - CY -> A +185 B9 10111001 SUBB A, R1 A - R1 - CY -> A +186 BA 10111010 SUBB A, R2 A - R2 - CY -> A +187 BB 10111011 SUBB A, R3 A - R3 - CY -> A +188 BC 10111100 SUBB A, DPH A - DPH - CY -> A +189 BD 10111101 SUBB A, DPL A - DPL - CY -> A +190 BE 10111110 SUBB A, #data8 A - data8 - CY -> A +191 BF 10111111 SUBB A, @DPTR A - main[DPTR] - CY -> A +192 C0 11000000 PJMP addr11 Page Jump [PC(15:11) 0 0 0 addr8] +193 C1 11000001 PJMP addr11 Page Jump [PC(15:11) 0 0 1 addr8] +194 C2 11000010 PJMP addr11 Page Jump [PC(15:11) 0 1 0 addr8] +195 C3 11000011 PJMP addr11 Page Jump [PC(15:11) 0 1 1 addr8] +196 C4 11000100 PJMP addr11 Page Jump [PC(15:11) 1 0 0 addr8] +197 C5 11000101 PJMP addr11 Page Jump [PC(15:11) 1 0 1 addr8] +198 C6 11000110 PJMP addr11 Page Jump [PC(15:11) 1 1 0 addr8] +199 C7 11000111 PJMP addr11 Page Jump [PC(15:11) 1 1 1 addr8] +200 C8 11001000 PCALL addr11 Page Call [PC(15:11) 0 0 0 addr8] +201 C9 11001001 PCALL addr11 Page Call [PC(15:11) 0 0 1 addr8] +202 CA 11001010 PCALL addr11 Page Call [PC(15:11) 0 1 0 addr8] +203 CB 11001011 PCALL addr11 Page Call [PC(15:11) 0 1 1 addr8] +204 CC 11001100 PCALL addr11 Page Call [PC(15:11) 1 0 0 addr8] +205 CD 11001101 PCALL addr11 Page Call [PC(15:11) 1 0 1 addr8] +206 CE 11001110 PCALL addr11 Page Call [PC(15:11) 1 1 0 addr8] +207 CF 11001111 PCALL addr11 Page Call [PC(15:11) 1 1 1 addr8] +208 D0 11010000 DJNZ R0, rel8 Decrement R0 and jump if not zero +209 D1 11010001 DJNZ R1, rel8 Decrement R1 and jump if not zero +210 D2 11010010 DJNZ R2, rel8 Decrement R2 and jump if not zero +211 D3 11010011 DJNZ R3, rel8 Decrement R3 and jump if not zero +212 D4 11010100 CJNE R0, #data, rel8 Compare R0 with data8 and jump if not equal +213 D5 11010101 CJNE R1, #data, rel8 Compare R1 with data8 and jump if not equal +214 D6 11010110 CJNE R2, #data, rel8 Compare R2 with data8 and jump if not equal +215 D7 11010111 CJNE R3, #data, rel8 Compare R3 with data8 and jump if not equal +216 D8 11011000 LJMP addr16 Long jump to addr16 +217 D9 11011001 LCALL addr16 Long call to subroutine at addr16 +218 DA 11011010 RET return from subroutine +219 DB 11011011 RETI return from interrupt +220 DC 11011100 SJMP rel8 short (relative) jump +221 DD 11011101 JMP @A+DPTR Indexed indirect jump relative to DPTR +222 DE 11011110 JMP @DPTR jump indirect to DPTR +223 DF 11011111 CJNE A, #data8, rel8 Compare A with data8 and jump if not equal +224 E0 11100000 JZ rel8 Jump if zero +225 E1 11100001 JNZ rel8 Jump if not zero +226 E2 11100010 JC rel8 Jump if carry +227 E3 11100011 JNC rel8 Jump if not carry +228 E4 11100100 JPO rel8 Jump if parity odd +229 E5 11100101 JPE rel8 Jump if parity even +230 E6 11100110 JS rel8 Jump if sign (negative) +231 E7 11100111 JNS rel8 Jump if not sign (positive) +232 E8 11101000 PUSH R0 Push R0 to the stack +233 E9 11101001 PUSH R1 Push R1 to the stack +234 EA 11101010 PUSH R2 Push R2 to the stack +235 EB 11101011 PUSH R3 Push R3 to the stack +236 EC 11101100 PUSH DPH Push DPH to the stack +237 ED 11101101 PUSH DPL Push DPL to the stack +238 EE 11101110 PUSH A Push Accumulator to the stack +239 EF 11101111 PUSH FLAGS Push Flags register to the stack +240 F0 11110000 POP R0 Pop top off stack to R0 +241 F1 11110001 POP R1 Pop top off stack to R1 +242 F2 11110010 POP R2 Pop top off stack to R2 +243 F3 11110011 POP R3 Pop top off stack to R3 +244 F4 11110100 POP DPH Pop top off stack to DPH +245 F5 11110101 POP DPL Pop top off stack to DPL +246 F6 11110110 POP A Pop top off stack to Accumulator +247 F7 11110111 POP FLAGS Pop top off stack to Flags register +248 F8 11111000 MUL R0, R1 R0 * R1 -> {R0 R1} unsigned integer multiply R0 by R1, 16-bit result left in R0 and R1, R0 holds most significant byte +249 F9 11111001 DIV R0, R1 R0 / R1 -> {R0 R1} unsigned integer division R0 by R1, 16-bit result left in R0 and R1, R0 holds most significant byte +250 FA 11111010 DA A Decimal adjust accumulator +251 FB 11111011 reserved currently unallocated opcode - treat as NOP +252 FC 11111100 IN A, port_addr Input value on I/O port 'port_addr' to accumulator +253 FD 11111101 OUT port_addr, A Output accumulator value to I/O port 'port_addr' +254 FE 11111110 INT vect8 Software interrupt at vector vect8 +255 FF 11111111 HLT Halt processor
--- a/docs/lyx/#appendix.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -#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 default -\font_sans default -\font_typewriter default -\font_default_family default -\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 -\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 Part -External References -\end_layout - -\begin_layout Part -Supporting Material Index -\end_layout - -\end_body -\end_document
--- a/docs/lyx/#asm.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1733 +0,0 @@ -#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 default -\font_sans default -\font_typewriter default -\font_default_family default -\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 -\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 Part -The Assembler -\end_layout - -\begin_layout Section -Assembler Design -\end_layout - -\begin_layout Standard -The assembler will take assembly source code as input and produce two output - files: A binary executable and a debug 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 Graphics - filename /home/jmz/qm/ede/docs/img/asm/assembler.svg - display false - -\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 binary executable will be a simple raw binary file in big-endian format. - The debug file will be a tabulated text file with the following format: -\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 Tabular -<lyxtabular version="3" rows="1" columns="5"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PC -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -OPCODE -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DATA -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -MNEMONIC -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -ARGUMENTS -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\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 -This file will essentially be the plain text source side by side with the - binary machine code and address for each instruction (represented as hexadecima -l for greater readability). - This file will provide the information needed for setting break pointers - with the debugger later, it will also be generally useful for debugging - programs written in the assembler, and the assembler it self. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsection -Language design in BNF syntax -\end_layout - -\begin_layout Standard -The ELB816 specification defines an assembly language in Backus Naur form, - however the assembler designed for this project differs slightly (more - details in Assembler Implementation below). - Here is the language definition for this assembler: -\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},tabsize=4" -inline false -status open - -\begin_layout Plain Layout - -<assembly_code> ::= <line> <assembly_code> | <line> <EOF> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<EOF> ::= <end of file> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<line> ::= [<statement> [";"<comment>]] <EOL> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<EOL> ::= <end of line character> -\end_layout - -\begin_layout Plain Layout - - -\end_layout - -\begin_layout Plain Layout - -<statement> ::= [<label> ":"] <mnemonic> [<arguments>] -\end_layout - -\begin_layout Plain Layout - - | [<label>] <directive> [<arguments>] -\end_layout - -\begin_layout Plain Layout - - | <label> ":" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<character> ::= <any ASCII character> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<mnemonic> ::= "MOV" | "NOP" | "XCSD" | "SFA" | "LAF" | "ANL" -\end_layout - -\begin_layout Plain Layout - - | "ORL" | "XRL" | "RL" | "RLC" | "RR" | "RRC" - -\end_layout - -\begin_layout Plain Layout - - | "INC" | "DEC" | "SET" | "CLR" | "CPL" | "ADD" -\end_layout - -\begin_layout Plain Layout - - | "ADD" | "ADDC" | "SUB" | "SUBB" | "PJUMP" -\end_layout - -\begin_layout Plain Layout - - | "PCALL" | "LJMP" | "LCALL" | "DJNZ" | "CJNE" -\end_layout - -\begin_layout Plain Layout - - | "RET" | "RETI" | "SJMP" | "JMP" | "JZ" | "JNZ" -\end_layout - -\begin_layout Plain Layout - - | "JC" | "JNC" | "JPO" | "JPE" | "JS" | "JNS" -\end_layout - -\begin_layout Plain Layout - - | "PUSH" | "POP" | "IN" | "OUT" | "HLT" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<directive> ::= "ORG" | "EQU" | "DB" | "DS" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<arguments> ::= <argument> | <arguments> "," <argument> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<argument> ::= <register> | <reg_pair> | ["@"] <address> -\end_layout - -\begin_layout Plain Layout - - | <flag> | ["#"] <aggregate> -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<register> ::= "A" | "FLAGS" | "R0" | "R1" | "R2" | "R3" -\end_layout - -\begin_layout Plain Layout - - | "DPH" | "DPL" | "SPH" | "SPL" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<reg_pair> ::= "DPTR" | "SP" | "PC" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<flag> ::= "C" | "IE" | "BS" -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -<aggregate> ::= ["("] <python arithmetic> [")"] | <python integer> -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Section -Assembler Implementation -\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 commented source code is attached provided with the supporting - and should be referenced for a deeper understanding of the program's operation. - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsection -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},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 Subsection -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 major components of the assembler 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, -\begin_inset listings -lstparams "basicstyle={\ttfamily}" -inline true -status open - -\begin_layout Plain Layout - -tokenize() -\end_layout - -\end_inset - - is more easily understood when represented as flowcharts. - -\end_layout - -\begin_layout Standard -\begin_inset Newpage newpage -\end_inset - - -\end_layout - -\begin_layout Subsubsection -\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 - - if mnemonic == 'ds': -\end_layout - -\begin_layout Plain Layout - - address = address + first argument -\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 Subsubsection -\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 - - if mnemonic == 'ds': -\end_layout - -\begin_layout Plain Layout - - address = address + first argument -\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 - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Graphics - filename /home/jmz/qm/ede/docs/img/asm/assembler.svg - display false - -\end_inset - - -\end_layout - -\begin_layout Section -Assembler Testing -\end_layout - -\end_body -\end_document
--- a/docs/lyx/#dbg.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1684 +0,0 @@ -#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 default -\font_sans default -\font_typewriter default -\font_default_family default -\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 -\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 Part -The Debugger -\end_layout - -\begin_layout Section -Design -\end_layout - -\begin_layout Standard -The debugger is designed to issue commands to and receive data from an instant - of the emulator running either as a process or on a micro-controller. -\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/docs/img/dbg/debugger_overview.svg - display false - -\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 debugger will implement the protocol described under the Emulator Design - section of this report. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Section -Implementation -\end_layout - -\begin_layout Subsection -dbg.py -\end_layout - -\begin_layout Standard -The debugger has been implemented as a Python class with the following functions -\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 Tabular -<lyxtabular version="3" rows="17" columns="3"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="2cm"> -<column alignment="center" valignment="top" width="7cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Function -\end_layout - -\end_inset -</cell> -<cell multicolumn="1" alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Arguments -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -snd -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -byte -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -send a byte to the emulator via a serial or file buffer -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -rcv -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -length -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -receive length number of bytes from a serial or file buffer -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -step -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute instruction at PC -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute instructions from PC until a break point is reached -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_reg -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register address, value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set a register (register address between 0 and 16 as described under Memory - Design in the Emulator Design section) -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_reg -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register address -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_flag -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag bit, 0 or 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Turn a flag bit on or off. - LSB = 0, MSB =7 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_flag -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag bit -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a flag bit -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_block -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -address high, address low, length high, length low, [byte array] -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set a block of memory of arbitrary length with the bytes in the byte array -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_block -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -address high, address low, length high, length low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Read a block of memory of arbitrary length -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_a -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get value of A -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_flags -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get value of flags -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_ir -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get Value of IR -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run_len -\end_layout - -\end_inset -</cell> -<cell multirow="3" alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -length high, length low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Run for length number of instruction -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -free_run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Run forever - Bypass controller -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_bp -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -break point index, address high, address low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set 1 of 8 possible break points -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Standard -The class also has the attribute 'Emu' which can be set to point the debugger - at either an emulator process or a serial port. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -The rcv function needs to check that the emulator's output buffer is the - correct length before returning the data to the user. - Below is a pseudo-code representation of how this is achieved. -\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 - -rcv ( length ): -\end_layout - -\begin_layout Plain Layout - - while output buffer size != length: -\end_layout - -\begin_layout Plain Layout - - wait -\end_layout - -\begin_layout Plain Layout - - return output buffer -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Subsection -cli.py -\end_layout - -\begin_layout Standard -This file offers the user a text based interface to the debug class. - It implements the following commands: -\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 Tabular -<lyxtabular version="3" rows="16" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="2cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Command -\end_layout - -\end_inset -</cell> -<cell multicolumn="1" alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Function -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -step -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -step -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -sr -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_reg -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -gr -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_reg -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -sf -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_flag -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -gr -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_flag -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -sb -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_block -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -gb -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_block -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -ga -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_a -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -gf -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_flags -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -gir -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_ir -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -runl -\end_layout - -\end_inset -</cell> -<cell multirow="3" alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run_length -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -frun -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -free_run -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -sbp -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_bp -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -exc -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -exc -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\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 -Commands are issued at a terminal followed by any arguments separated by - a space. - The exc function enables the interpreter mode described in the EDE Use - Cases section above. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -Symbols are defined which map parts of the emulators memory to the encoding - used in the control functions. - Tables are provided below. -\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 Tabular -<lyxtabular version="3" rows="17" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Encoding -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R0_0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R1_0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R2_0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R3_0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -4 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -5 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PCH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -6 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -TMPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -7 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R0_1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -8 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R1_1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -9 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R2_1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -10 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R3_1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -11 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -12 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -13 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PCL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -14 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -TMPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -15 -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\begin_inset Tabular -<lyxtabular version="3" rows="9" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Flag -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Encoding -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -BS -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -IE -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -OV -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -S -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -P -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -4 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -AC -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -5 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Z -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -6 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -C -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -7 -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Section -Debugger Testing -\end_layout - -\begin_layout Standard -The debugger was tested with an automated test method using python scripting. - The script uses the debug controller class to fill all of the emulators - memory structures with known values. - It then requests these values back and compares the results, if the values - are not the same the test fails. - The test then steps through the emulators entire memory space, and then - checks the program counter to see if it has reached the end. - The test files and results can be found in the Supporting Material. -\end_layout - -\end_body -\end_document
--- a/docs/lyx/#ede.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -#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 default -\font_sans default -\font_typewriter default -\font_default_family default -\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 -\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 Part -The ELB816 Development Environment -\end_layout - -\begin_layout Section -EDE Overview -\end_layout - -\begin_layout Standard -EDE is a software implementation of the ELB816 micro-processor along with - a basic tool chain to develop and debug code for it. - The block diagram below depicts the system that this project aims to implement. -\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/docs/img/ede/system_overview.svg - display false - -\end_inset - - -\end_layout - -\begin_layout Section -EDE Use Cases -\end_layout - -\begin_layout Standard -EDE is highly modular. - Each it's components, with the exception of the UI, is written as a stand - alone programs and works independently. - Because of this design strategy EDE can be used in a number of different - ways. - This section details the use cases experimented with so far. -\end_layout - -\begin_layout Subsection -Assemble/Upload/Execute/Debug -\end_layout - -\begin_layout Standard -Using the tool chain in this manner is analogous to programming and run-time - debugging a real-world micro-controller. - Source code is assembled and written into the emulator's memory. - The user can then use the debug prompt to step through program and probe - the emulator internals. -\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/docs/img/ede/aued.svg - display false - -\end_inset - - -\end_layout - -\begin_layout Standard - -\end_layout - -\begin_layout Subsection -Interpreter Mode -\end_layout - -\begin_layout Standard -Source code does not have to be pre-assembled. - Since the command-line interface, the assembler and the debugger are all - written in python, the assembler's functions can be imported into the interface - code. - This has been done to create a mode where the user enters assembly code - at a prompt, and then that code is immediately assembled and executed on - an instance of the emulator. -\end_layout - -\begin_layout Standard -\begin_inset ERT -status open - -\begin_layout Plain Layout - - -\backslash -bigskip -\end_layout - -\end_inset - - -\end_layout - -\end_body -\end_document
--- a/docs/lyx/#emu.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3713 +0,0 @@ -#LyX 2.0 created this file. For more info see http://www.lyx.org/ -\lyxformat 413 -\begin_document -\begin_header -\textclass article -\begin_preamble -\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox -% Resize figures that are too wide for the page. -\let\oldincludegraphics\includegraphics -\renewcommand\includegraphics[2][]{% - \oldincludegraphics[#1,max width=\linewidth,max height=\textheight]{#2} -} -\end_preamble -\use_default_options true -\maintain_unincluded_children false -\language english -\language_package default -\inputencoding auto -\fontencoding global -\font_roman default -\font_sans default -\font_typewriter default -\font_default_family default -\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 Part -The Emulator -\end_layout - -\begin_layout Section -Emulator Design -\end_layout - -\begin_layout Standard -\begin_inset Graphics - filename /home/jmz/qm/ede/docs/img/emu/ELB816_system.svg - display false - -\end_inset - - -\end_layout - -\begin_layout Standard -Above is a block diagram of a micro-controller with the ELB816 micro-processor - at it's core. - This is taken from the original ELB816 specification. - Implementing a system similar to this as a piece of software is the goal - of this section of the project. -\end_layout - -\begin_layout Subsection -Memory and Registers -\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/docs/img/emu/memory.svg - display false - -\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 micro-controller is based on a Von Neumann architecture and has: -\end_layout - -\begin_layout Itemize -A single block of up to 64k byte addressable memory for storing both data - and code. -\end_layout - -\begin_layout Itemize -Two banks of four 8-bit general purpose registers (R0 to R3). -\end_layout - -\begin_layout Itemize -Four 16-bit content specific (PC, SP, DPTR and TMPA) -\end_layout - -\begin_layout Itemize -Three 8-bit content specific registers (A, flags and IR) -\end_layout - -\begin_layout Standard -The general purpose 8-bit registers and the 16-bit registers can exist as - a single sixteen byte block of memory spaces with the following encoding: -\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 Tabular -<lyxtabular version="3" rows="10" columns="5"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -MSB -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -MSB -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -LSB -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -User Accessible? -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -000 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R0 bank 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R0 bank 0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -General Purpose -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -001 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R1 bank 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R1 bank 0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -General Purpose -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -010 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R2 bank 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R2 bank 0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -General Purpose -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -011 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R3 bank 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R3 bank 0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -General Purpose -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -100 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Data Pointer -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -101 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Stack Pointer -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Yes -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -110 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PCH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PCL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Program Counter -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -No -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -111 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -TPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -TPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Temp Address Register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -No -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -The 8-bit flag register can exist as a single byte with the following format: -\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 Tabular -<lyxtabular version="3" rows="9" columns="3"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="10cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Bit -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Flag -\end_layout - -\end_inset -</cell> -<cell multicolumn="1" alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -BS -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -User Accessible: Select register bank -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -IE -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -User Accessible: Enable Interrupts when 1 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -OV -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set to 1 when result of arithmetic operation has even parity -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -S -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set to 1 when result of arithmetic operation is negative -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -4 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -P -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set to 1 when result of arithmetic operation has even parity -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -5 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -AC -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set to 1 when result of arithmetic operation generates a carry or borrow - from bit 3 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -6 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Z -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set to 1 when result of arithmetic operation is Zero -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -7 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -C -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -User Accessible: Set to 1 when result of arithmetic operation generates - a carry or borrow from bit 7. - Used in rotate through carry operations -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\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 -There is also an 8-bit accumulator register for storing the result of various - operations and an 8-bit instruction register for the storing the instruction - currently being executed. -\end_layout - -\begin_layout Subsection -Control and Execution -\end_layout - -\begin_layout Standard -The emulator needs to be controlled externally. - This could be via a serial or a file buffer depending on the platform. -\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/docs/img/emu/controller.svg - display false - -\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 Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -Below is a control protocol which allows and control of the emulators memory - and execution. -\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 Tabular -<lyxtabular version="3" rows="15" columns="5"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="2cm"> -<column alignment="center" valignment="top" width="1cm"> -<column alignment="center" valignment="top" width="1cm"> -<column alignment="center" valignment="top" width="3cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Function -\end_layout - -\end_inset -</cell> -<cell multicolumn="1" alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Arguments -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -CMD byte -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Length -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -step -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x00 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute instruction at PC -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x01 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute instructions from PC until a break point is reached -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set register -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register address, value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x02 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set a register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get register -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register address -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x03 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set flag -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag bit, 0 or 1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x04 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Turn a flag bit on or off. - LSB = 0, MSB =7 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get flag -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag bit -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x05 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a flag bit -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -write memory block -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -address high, address low, length high, length low, [byte array] -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x06 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -6+ -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set a block of memory of arbitrary length with the bytes in the byte array -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -read memory block -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -address high, address low, length high, length low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x07 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -5 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Read a block of memory of arbitrary length -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get A -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x08 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get value of A -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get flags -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x09 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get value of flags -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get IR -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x0A -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get Value of IR -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run for length -\end_layout - -\end_inset -</cell> -<cell multirow="3" alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -length high, length low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x0B -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -3 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Run for length number of instruction -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -free run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x0C -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Run forever - Bypass controller -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set break point -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -break point index, address high, address low -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0x0D -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -4 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set 1 of 8 possible break points -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\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 Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -Here are pseudo-code representations of the execution control functions. -\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},frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},tabsize=4" -inline false -status open - -\begin_layout Plain Layout - -step ( ) -\end_layout - -\begin_layout Plain Layout - - get PC -\end_layout - -\begin_layout Plain Layout - - IR = byte in memory at PC -\end_layout - -\begin_layout Plain Layout - - decode and execute instruction -\end_layout - -\begin_layout Plain Layout - - end -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -run ( ) -\end_layout - -\begin_layout Plain Layout - - while PC is not a break point: -\end_layout - -\begin_layout Plain Layout - - step( ) -\end_layout - -\begin_layout Plain Layout - - end -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -run for length ( length ) -\end_layout - -\begin_layout Plain Layout - - counter = 0 -\end_layout - -\begin_layout Plain Layout - - while counter != length: -\end_layout - -\begin_layout Plain Layout - - step( ) -\end_layout - -\begin_layout Plain Layout - -\end_layout - -\begin_layout Plain Layout - -free run ( ): -\end_layout - -\begin_layout Plain Layout - - loop forever: -\end_layout - -\begin_layout Plain Layout - - step( ) -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Section -Emulator Implementation -\end_layout - -\begin_layout Standard -The Emulator is written in pure C89 to ensure as much cross compiler compatibili -ty as possible. - It source code consists of the following files: -\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 Tabular -<lyxtabular version="3" rows="6" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="8cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -File -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -main.c -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Initializes the emulator at boot and controls execution -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -iset.h -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Declares a function for each mnemonic in the instruction set. - Declares a 256 byte function pointer table -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -iset.c -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Contains a function for each mnemonic in the instruction set -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -mem.h -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Declares variables for the various memory structures. - Declares memory access function definitions -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -mem.c -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Contains memory access functions -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\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 Subsection -main.c -\end_layout - -\begin_layout Standard -In this file the 256 byte instruction table is filled with pointers to the - functions in iset.c. - This file also contains the control interface function and execution control - functions. - None of these functions take any arguments or return any data. -\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 list of the functions that appear in this file. -\end_layout - -\begin_layout Standard -\begin_inset Tabular -<lyxtabular version="3" rows="7" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="8cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Function -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -snd -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Puts a character into the serial or file output buffer -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -rcv -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get a character from the serial or file input buffer -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -step -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute the instruction pointed to by PC -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -run -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Execute instructions until a break point is reached -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -controller -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get character from input buffer and deal with accordingly -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -main -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Make sure free run isn't enabled at boot, call controller function forever -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -Below is the format of the instruction pointer table initialized in this - file. - Each item in the table is a pointer to a function. -\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 -According to the program Cdecl, in -\begin_inset Quotes eld -\end_inset - -human language -\begin_inset Quotes erd -\end_inset - -, it's declaration is: -\begin_inset Quotes eld -\end_inset - -declare ops as array 256 of pointer to function (void) returning void -\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 number of the pointers position in the table is the opcode for the instructi -on that the function being pointed to deals with. -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},tabsize=4" -inline false -status open - -\begin_layout Plain Layout - -void (*ops[256])(void) = { -\end_layout - -\begin_layout Plain Layout - - NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, -\end_layout - -\begin_layout Plain Layout - - SET, CLR, SET, CLR, SET, CLR, CPL, CPL, -\end_layout - -\begin_layout Plain Layout - - XCSD, SFA, LAF, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - MOV, MOV, MOV, MOV, MOV, MOV, MOV, MOV, -\end_layout - -\begin_layout Plain Layout - - ANL, ANL, ANL, ANL, ANL, ANL, ANL, ANL, -\end_layout - -\begin_layout Plain Layout - - ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, -\end_layout - -\begin_layout Plain Layout - - XRL, XRL, XRL, XRL, XRL, XRL, XRL, XRL, -\end_layout - -\begin_layout Plain Layout - - RL, RLC, RR, RRC, INC, DEC, INC, DEC, -\end_layout - -\begin_layout Plain Layout - - ADD, ADD, ADD, ADD, ADD, ADD, ADD, ADD, -\end_layout - -\begin_layout Plain Layout - - ADDC, ADDC, ADDC, ADDC, ADDC, ADDC, ADDC, ADDC, -\end_layout - -\begin_layout Plain Layout - - SUB, SUB, SUB, SUB, SUB, SUB, SUB, SUB, -\end_layout - -\begin_layout Plain Layout - - SUBB, SUBB, SUBB, SUBB, SUBB, SUBB, SUBB, SUBB, -\end_layout - -\begin_layout Plain Layout - - PJMP, PJMP, PJMP, PJMP, PJMP, PJMP, PJMP, PJMP, -\end_layout - -\begin_layout Plain Layout - - PCALL, PCALL, PCALL, PCALL, PCALL, PCALL, PCALL, PCALL, -\end_layout - -\begin_layout Plain Layout - - DJNZ, DJNZ, DJNZ, DJNZ, CJNE, CJNE, CJNE, CJNE, -\end_layout - -\begin_layout Plain Layout - - LJMP, LCALL, RET, RETI, SJMP, JMP, JMP, CJNE, -\end_layout - -\begin_layout Plain Layout - - JZ, JNZ, JC, JNC, JPO, JPE, JS, JNS, -\end_layout - -\begin_layout Plain Layout - - PUSH, PUSH, PUSH, PUSH, PUSH, PUSH, PUSH, PUSH, -\end_layout - -\begin_layout Plain Layout - - POP, POP, POP, POP, POP, POP, POP, POP, -\end_layout - -\begin_layout Plain Layout - - MUL, DIV, DA, NOP, IN, OUT, INT, HLT -\end_layout - -\begin_layout Plain Layout - -}; -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsection -iset.c/h -\end_layout - -\begin_layout Standard -For every mnemonic in the ELB816 instruction set there is a function in - these files. - These are the functions that are pointed to in the instruction table that - is filled in main.c. - The functions behave according to their description in the ELB816 specification. -\end_layout - -\begin_layout Subsection -mem.c/h -\end_layout - -\begin_layout Standard -In mem.h the memory structure of the emulator is defined in accordance with - how it was described in the previous section. - mem.c contains the following functions to facilitate access to this memory. -\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 Tabular -<lyxtabular version="3" rows="11" columns="4"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<column alignment="left" valignment="top" width="6cm"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Function -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Arguments -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Returns -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Description -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_flag -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 byte -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a flag (can be 0 or 1) -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_flag -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -flag, on -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set a flag to 0 if on == 0, else set flag to 1 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_zp -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set zero and parity flags based on value -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_wide -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 bytes -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of a 16-bit register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_wide -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register, value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set the value of a 16-bit register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -inc_pc -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -n -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Increment the PC by n -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -fetch -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 byte -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -return the byte in memory at PC, increment PC -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -fetch_wide -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -2 bytes -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -return the 2 bytes in memory at PC, increment PC by 2 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -get_reg -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1 byte -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Get the value of an 8-bit register -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -set_reg -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -register, value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -- -\end_layout - -\end_inset -</cell> -<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Set the value of an 8-bit register -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -The various register access functions use different register encoding schemes. - These are in the tables below. -\end_layout - -\begin_layout Itemize -get_wide/set_wide -\end_layout - -\begin_layout Standard -\begin_inset Tabular -<lyxtabular version="3" rows="5" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Encoding -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPTR -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -00 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SP -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -01 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -PC -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -10 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -TMPA -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -11 -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Itemize -get_reg/set_reg - These values correspond to the way registers are encoded - into the last 3-bits of many of the ELB816 instructions. -\end_layout - -\begin_layout Standard -\begin_inset Tabular -<lyxtabular version="3" rows="9" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top" width="0"> -<column alignment="center" valignment="top" width="0"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Register -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Encoding -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R0 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -000 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R1 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -001 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R2 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -010 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R3 -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -011 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -100 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -DPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -101 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPH -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -110 -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -SPL -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -111 -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Section -Porting to Intel MCS-51 -\end_layout - -\begin_layout Standard -In order make this code compile for an 8052 using Keil C51 a few changes - to were needed. - These are detailed below. -\end_layout - -\begin_layout Subsection -main.c -\end_layout - -\begin_layout Standard -In the PC version of the emulator, the function table is declared as: -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -FUNCTION_TABLE const iset -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Since the instruction set is 256 bytes long and the 8052 only has 256 bytes - of internal RAM, this data structure must be redeclared to exist in code - memory space. -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -FUNCTION_TABLE const code iset -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Standard -The PC version of the emulator uses a file buffer to communicate with the - debugger. - On the 8052 communication uses a serial interface. - Because of this the snd() functions differ. -\end_layout - -\begin_layout Standard -On the PC -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -snd(BYTE c) { -\end_layout - -\begin_layout Plain Layout - - fp = fopen("out", "a"); -\end_layout - -\begin_layout Plain Layout - - fputc(c, fp); -\end_layout - -\begin_layout Plain Layout - - fclose(fp); -\end_layout - -\begin_layout Plain Layout - -} -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Becomes on the 8052, simply: -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -snd(BYTE c) { -\end_layout - -\begin_layout Plain Layout - - putchar(c); -\end_layout - -\begin_layout Plain Layout - -} -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -The 8052's serial point also needs to be configures at the start of main - execution like this: -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -SCON = 0x50; * SCON - mode 1, 8-bit UART, enable rcvr -\end_layout - -\begin_layout Plain Layout - -TMOD |= 0x20; * TMOD - timer 1, mode 2, 8-bit reload -\end_layout - -\begin_layout Plain Layout - -TH1 = 0xE8; * TH1 - reload value for 1200 baud@12MHz -\end_layout - -\begin_layout Plain Layout - -TR1 = 1; * TR1 - timer 1 run -\end_layout - -\begin_layout Plain Layout - -TI = 1; * TI - set TI to send first char of UART -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Subsection -mem.h -\end_layout - -\begin_layout Standard -The 8052 development board available during this project had 32K of external - RAM available. - This meant the size of the emulators Von Neumann memory space had to be - halved and declared to exist in external data memory. -\end_layout - -\begin_layout Standard -On the PC: -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},language=C" -inline false -status open - -\begin_layout Plain Layout - -BYTE mem[0x10000]; -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -On the 8052 -\end_layout - -\begin_layout Standard -\begin_inset listings -lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,keywordstyle={\color{blue}},language=C" -inline false -status open - -\begin_layout Plain Layout - -BYTE xdata mem[0x8000]; -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Section -Emulator Testing -\end_layout - -\begin_layout Standard -The assemblers memory structures and access functions were tested by using - the access function to set the memory structures to know values, and then - request the values back and write them to a file. - The file was then inspected by hand. - The test files and results can be found in the Supporting Material. - -\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 emulator could be more rigorously tested in conjunction with the debugger - and assembler. - Below is a pseudo-code representation of an automated test procedure that - could be implemented with the debug class in python. -\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},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" -inline false -status open - -\begin_layout Plain Layout - -for instruction in instruction set: -\end_layout - -\begin_layout Plain Layout - - get PC -\end_layout - -\begin_layout Plain Layout - - assemble instruction -\end_layout - -\begin_layout Plain Layout - - write instruction at PC -\end_layout - -\begin_layout Plain Layout - - execute instruction -\end_layout - -\begin_layout Plain Layout - - -\end_layout - -\begin_layout Plain Layout - - if expected -\end_layout - -\begin_layout Plain Layout - - -\end_layout - -\end_inset - - -\end_layout - -\end_body -\end_document
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/lyx/#final_report.lyx# Tue Apr 22 14:25:14 2014 +0100 @@ -0,0 +1,198 @@ +#LyX 2.0 created this file. For more info see http://www.lyx.org/ +\lyxformat 413 +\begin_document +\begin_header +\textclass article +\begin_preamble +\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox +% Resize figures that are too wide for the page. +\let\oldincludegraphics\includegraphics +\renewcommand\includegraphics[2][]{% + \oldincludegraphics[#1,max width=\linewidth,max height=\textheight]{#2} +} +\end_preamble +\use_default_options true +\maintain_unincluded_children false +\language english +\language_package default +\inputencoding auto +\fontencoding global +\font_roman default +\font_sans default +\font_typewriter default +\font_default_family default +\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 Description +Programme: Electrical and Electronic Engineering +\end_layout + +\begin_layout Description +Supervisor: Dr Christopher Andrew Harte +\end_layout + +\begin_layout LyX-Code +\begin_inset Newpage pagebreak +\end_inset + + +\end_layout + +\begin_layout Abstract +ELB816 is an imagined processor design used for teaching micro-processor + electronics. + The ELB816 Development Environment project aims create to a working software + emulator implementation of this micro-processor, along with a basic tool + chains, consisting on an assembler and a debugger, for writing and debugging + code for it. + This report first outlines the the motivation for implementing these tools + and the methodology used to realize them. + This is followed by an overview for the development environment and various + way in which it can be used. + Designs for each component and then presented, along with implementation + details that will aid the reader in understanding the source code provided + in the Supporting Material. + +\end_layout + +\begin_layout Standard +\begin_inset Newpage pagebreak +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset toc +LatexCommand tableofcontents + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "intro.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "ede.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "asm.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "emu.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "dbg.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "review.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include +filename "appendix.lyx" + +\end_inset + + +\end_layout + +\end_body +\end_document
--- a/docs/lyx/#review.lyx# Tue Apr 22 00:57:06 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -#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 default -\font_sans default -\font_typewriter default -\font_default_family default -\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 -\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 Part -Review and Improvements -\end_layout - -\begin_layout Standard -The diagram below shows an overview of the goal of this project with the - completed components and interfaces highlighted in green. -\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/docs/img/ede/state_of_ede.svg - display false - -\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 Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Section -Strategy for the completion of EDE -\end_layout - -\begin_layout Enumerate -Complete debugger interface code. -\end_layout - -\begin_deeper -\begin_layout Enumerate -Both the PC and 8052 versions have fully implemented control interface functions. - However the Python debug class can currently only interact with a file - buffer for I/O. - The debuggers send and receive functions need to be modified to deal with - a serial buffer -\end_layout - -\begin_layout Enumerate -An option to enable this mode needs to be added to the command line interface - code -\end_layout - -\end_deeper -\begin_layout Enumerate -Complete testing of emulator. -\end_layout - -\begin_deeper -\begin_layout Enumerate -Before any more emulator code is added, the instructions that have already - been implemented should be tested using something similar to the test method - outlined in the Emulator Testing section -\end_layout - -\end_deeper -\begin_layout Enumerate -Develop emulated peripheral and peripheral driver code. -\end_layout - -\begin_deeper -\begin_layout Enumerate -Emulated peripherals such as an interrupt controller, timer and parallel - port I/O need to be developed. - They should be introduced as new modules to the PC build of the emulator. - The emulators main.c file will need to be updated to add them to the main - execution loop. -\end_layout - -\begin_layout Enumerate -Peripheral drivers need to be developed for the Intel MCS-51 build, These - drivers could be quite specific to the exact development board and/or 8052 - implementation that is being used. - The current Intel MCS-51 build of the emulator uses 4135 bytes of code - memory and 56 bytes of RAM. - 8k ROM and 256 bytes of RAM this leaves almost half the available ROM and - 200 bytes of RAM for peripheral drivers to be integrated. -\end_layout - -\end_deeper -\begin_layout Enumerate -Add the ability to handle segments and macros to the assembler. -\end_layout - -\begin_deeper -\begin_layout Enumerate -The ELB816 specification document details how these should work, there is - no reason the assembler could not be modified to deal with them. -\end_layout - -\end_deeper -\end_body -\end_document
--- a/docs/lyx/appendix.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/appendix.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -63,9 +63,118 @@ External References \end_layout +\begin_layout Enumerate +ELB816 Project Home Page: http://code.google.com/p/elb816/ +\end_layout + \begin_layout Part Supporting Material Index \end_layout +\begin_layout Standard +Below is an index of the supporting material +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +asm/ +\begin_inset Quotes erd +\end_inset + + directory: Python source for the assembler +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +dbg/ +\begin_inset Quotes erd +\end_inset + + directory: Python source for the debugger class +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +emu/ +\begin_inset Quotes erd +\end_inset + + directory: C source for the PC build of the emulator +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +emu52/ +\begin_inset Quotes erd +\end_inset + + directory: C source files for the 8052 build of the emulator and Keil C51 + build files +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +tests/ +\begin_inset Quotes erd +\end_inset + + directory: Various test files used through out the projct +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +docs/ +\begin_inset Quotes erd +\end_inset + + directory: Source file for this document, and a tabulated file containing + the entire ELB816 instruction set and a description of each instruction +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +bin/ +\begin_inset Quotes erd +\end_inset + + directory: Contains Linux executable of the PC version of the emulator +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +cli.py +\begin_inset Quotes erd +\end_inset + + file: Text based user interface python script +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +build.sh +\begin_inset Quotes erd +\end_inset + + file: Builds the PC version of the emulator +\end_layout + \end_body \end_document
--- a/docs/lyx/appendix.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/appendix.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -60,11 +60,102 @@ \begin_body \begin_layout Part +External References +\end_layout + +\begin_layout Enumerate +ELB816 Project Home Page: http://code.google.com/p/elb816/ +\end_layout + +\begin_layout Part Supporting Material Index \end_layout -\begin_layout Part -References +\begin_layout Standard +Below is an index of the supporting material +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +asm/ +\begin_inset Quotes erd +\end_inset + + directory: Python source for the assembler +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +dbg/ +\begin_inset Quotes erd +\end_inset + + directory: Python source for the debugger class +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +emu/ +\begin_inset Quotes erd +\end_inset + + directory: C source for the PC build of the emulator +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +emu52/ +\begin_inset Quotes erd +\end_inset + + directory: C source files for the 8052 build of the emulator and Keil C51 + build files +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +tests/ +\begin_inset Quotes erd +\end_inset + + directory: Various test files used through out the projct +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +docs/ +\begin_inset Quotes erd +\end_inset + + directory: Source file for this document, and a tabulated file containing + the entire ELB816 instruction set and a description of each instruction +\end_layout + +\begin_layout Itemize +\begin_inset Quotes eld +\end_inset + +bin/ +\begin_inset Quotes erd +\end_inset + + directory: Contains Linux executable of the PC version of the emulator +\end_layout + +\begin_layout Itemize + \end_layout \end_body
--- a/docs/lyx/asm.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/asm.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -69,7 +69,7 @@ \begin_layout Standard The assembler will take assembly source code as input and produce two output - files: A binary executable and a debug file. + files: a binary executable and a debug file. \end_layout \begin_layout Standard @@ -220,7 +220,7 @@ l for greater readability). This file will provide the information needed for setting break pointers with the debugger later, it will also be generally useful for debugging - programs written in the assembler, and the assembler it self. + programs written in the assembler, and the assembler itself. \end_layout \begin_layout Standard @@ -235,9 +235,9 @@ \end_layout \begin_layout Standard -The ELB816 specification defines an assembly language in Backus Naur form, - however the assembler designed for this project differs slightly (more - details in Assembler Implementation below). +The ELB816 specification [1] defines an assembly language in Backus Naur + form, however the assembler designed for this project differs slightly + (more details in Assembler Implementation below). Here is the language definition for this assembler: \end_layout @@ -454,7 +454,7 @@ \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. + [1] with a few minor differences. These differences are: \end_layout @@ -571,8 +571,8 @@ 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 commented source code is provided with the supporting and should - be referenced for a deeper understanding of the program's operation. + The full commented source code is provided with the Supporting Material + and should be referenced for a deeper understanding of the program's operation. \end_layout @@ -1713,8 +1713,8 @@ at the same time testing labels and directives. The test file was assembled and then the binary and .dsm files were inspected manually by checking their size and content. - None of the this testing is automated and files are inspected by hand. - The test files and results can be found in the Supporting Material + None of this testing is automated and files are inspected by hand. + The test files and results can be found in the Supporting Material. \end_layout \end_body
--- a/docs/lyx/asm.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/asm.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -69,7 +69,7 @@ \begin_layout Standard The assembler will take assembly source code as input and produce two output - files: A binary executable and a debug file. + files: a binary executable and a debug file. \end_layout \begin_layout Standard @@ -220,7 +220,7 @@ l for greater readability). This file will provide the information needed for setting break pointers with the debugger later, it will also be generally useful for debugging - programs written in the assembler, and the assembler it self. + programs written in the assembler, and the assembler itself. \end_layout \begin_layout Standard @@ -571,8 +571,8 @@ 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 commented source code is provided with the supporting and should - be referenced for a deeper understanding of the program's operation. + The full commented source code is provided with the Supporting Material + and should be referenced for a deeper understanding of the program's operation. \end_layout @@ -1708,5 +1708,14 @@ Assembler Testing \end_layout +\begin_layout Standard +The assembler was tested by assembling the entire instruction table, while + at the same time testing labels and directives. + The test file was assembled and then the binary and .dsm files were inspected + manually by checking their size and content. + None of this testing is automated and files are inspected by hand. + The test files and results can be found in the Supporting Material. +\end_layout + \end_body \end_document
--- a/docs/lyx/dbg.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/dbg.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -1671,11 +1671,11 @@ \begin_layout Standard The debugger was tested with an automated test method using python scripting. - The script uses the debug controller class to fill all of the emulators + The script uses the debug controller class to fill all of the emulator's memory structures with known values. It then requests these values back and compares the results, if the values are not the same the test fails. - The test then steps through the emulators entire memory space, and then + The test then steps through the emulator's entire memory space, and then checks the program counter to see if it has reached the end. The test files and results can be found in the Supporting Material. \end_layout
--- a/docs/lyx/dbg.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/dbg.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -1669,5 +1669,16 @@ Debugger Testing \end_layout +\begin_layout Standard +The debugger was tested with an automated test method using python scripting. + The script uses the debug controller class to fill all of the emulators + memory structures with known values. + It then requests these values back and compares the results, if the values + are not the same the test fails. + The test then steps through the emulators entire memory space, and then + checks the program counter to see if it has reached the end. + The test files and results can be found in the Supporting Material. +\end_layout + \end_body \end_document
--- a/docs/lyx/ede.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/ede.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -105,8 +105,8 @@ \begin_layout Standard EDE is highly modular. - Each it's components, with the exception of the UI, is written as a stand - alone programs and works independently. + Each of it's components, with the exception of the UI, is written as a + stand alone program and works independently. Because of this design strategy EDE can be used in a number of different ways. This section details the use cases experimented with so far.
--- a/docs/lyx/ede.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/ede.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -105,8 +105,8 @@ \begin_layout Standard EDE is highly modular. - Each it's components, with the exception of the UI, is written as a stand - alone programs and works independently. + Each of it's components, with the exception of the UI, is written as a + stand alone programs and works independently. Because of this design strategy EDE can be used in a number of different ways. This section details the use cases experimented with so far. @@ -119,9 +119,9 @@ \begin_layout Standard Using the tool chain in this manner is analogous to programming and run-time debugging a real-world micro-controller. - Source code is assembled and the written into the emulator's memory, the - user can then use the debug prompt to step through program and probe the - emulator internals. + Source code is assembled and written into the emulator's memory. + The user can then use the debug prompt to step through program and probe + the emulator internals. \end_layout \begin_layout Standard @@ -151,6 +151,27 @@ \end_layout \begin_layout Standard +\begin_inset Newpage pagebreak +\end_inset + + +\end_layout + +\begin_layout Subsection +Interpreter Mode +\end_layout + +\begin_layout Standard +Source code does not have to be pre-assembled. + Since the command-line interface, the assembler and the debugger are all + written in python, the assembler's functions can be imported into the interface + code. + This has been done to create a mode where the user enters assembly code + at a prompt, and then that code is immediately assembled and executed on + an instance of the emulator. +\end_layout + +\begin_layout Standard \begin_inset ERT status open @@ -166,5 +187,15 @@ \end_layout +\begin_layout Standard +\begin_inset Graphics + filename /home/jmz/qm/ede/docs/img/ede/interpreter.svg + display false + +\end_inset + + +\end_layout + \end_body \end_document
--- a/docs/lyx/emu.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/emu.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -2578,7 +2578,8 @@ these files. These are the functions that are pointed to in the instruction table that is filled in main.c. - The functions behave according to their description in the ELB816 specification. + The functions behave according to their description in the ELB816 specification + [1]. \end_layout \begin_layout Subsection
--- a/docs/lyx/emu.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/emu.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -3616,6 +3616,7 @@ request the values back and write them to a file. The file was then inspected by hand. The test files and results can be found in the Supporting Material. + \end_layout \begin_layout Standard @@ -3635,7 +3636,8 @@ \end_layout \begin_layout Standard -The emulator could be more rigorously tested in conjunction with the debugger. +The emulator could be more rigorously tested in conjunction with the debugger + and assembler. Below is a pseudo-code representation of an automated test procedure that could be implemented with the debug class in python. \end_layout @@ -3656,5 +3658,95 @@ \end_layout +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\ttfamily},frame=tb,framexbottommargin=1em,framextopmargin=1em,language=C" +inline false +status open + +\begin_layout Plain Layout + +for instruction in instruction set: +\end_layout + +\begin_layout Plain Layout + + reset emulator memory state +\end_layout + +\begin_layout Plain Layout + + assemble instruction +\end_layout + +\begin_layout Plain Layout + + write instruction to memory +\end_layout + +\begin_layout Plain Layout + + execute instruction +\end_layout + +\begin_layout Plain Layout + + +\end_layout + +\begin_layout Plain Layout + + get all registers +\end_layout + +\begin_layout Plain Layout + + get all flags +\end_layout + +\begin_layout Plain Layout + + get any affected memory cells +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + + if and only if expected register changes occoured: +\end_layout + +\begin_layout Plain Layout + + register test passed +\end_layout + +\begin_layout Plain Layout + + if and only if expected flag changes occoured: +\end_layout + +\begin_layout Plain Layout + + flag test passed +\end_layout + +\begin_layout Plain Layout + + if expected memory modification occoured: +\end_layout + +\begin_layout Plain Layout + + memory test passed +\end_layout + +\end_inset + + +\end_layout + \end_body \end_document
--- a/docs/lyx/final_report.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/final_report.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -73,7 +73,35 @@ \end_layout \begin_layout Author -James Bowden (110104485) +James Bowden (110104485) +\end_layout + +\begin_layout Description +Programme: Electrical and Electronic Engineering +\end_layout + +\begin_layout Description +Supervisor: Dr Christopher Andrew Harte +\end_layout + +\begin_layout Abstract +ELB816 is an imagined processor design used for teaching micro-processor + electronics. + The ELB816 Development Environment project aims create to a working software + emulator implementation of this micro-processor along with a basic tool + chains, consisting on an assembler and a debugger, for writing and debugging + code for it. + This report first outlines the the motivation for implementing these tools + and the methodology used to realize them. + This is followed by an overview of the development environment and various + way in which it can be used. + Designs for each component and then presented, along with implementation + details that will aid the reader in understanding the source code provided + in the Supporting Material. + The progress made and state of the project is then reviewed, and a strategy + for completing the project is outlined. + Finally there is an index of the supporting material provided, along with + a short description of each of the included files. \end_layout \begin_layout Standard
--- a/docs/lyx/final_report.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/final_report.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -73,7 +73,35 @@ \end_layout \begin_layout Author -James Bowden (110104485) +James Bowden (110104485) +\end_layout + +\begin_layout Description +Programme: Electrical and Electronic Engineering +\end_layout + +\begin_layout Description +Supervisor: Dr Christopher Andrew Harte +\end_layout + +\begin_layout Abstract +ELB816 is an imagined processor design used for teaching micro-processor + electronics. + The ELB816 Development Environment project aims create to a working software + emulator implementation of this micro-processor along with a basic tool + chains, consisting on an assembler and a debugger, for writing and debugging + code for it. + This report first outlines the the motivation for implementing these tools + and the methodology used to realize them. + This is followed by an overview for the development environment and various + way in which it can be used. + Designs for each component and then presented, along with implementation + details that will aid the reader in understanding the source code provided + in the Supporting Material. + The progress made and state of the project is then reviewed, and a strategy + for completing the project is outlined. + Finally there is an index of the supporting material provided, along with + a short description of each of the included files. \end_layout \begin_layout Standard @@ -105,6 +133,16 @@ \begin_layout Standard \begin_inset CommandInset include LatexCommand include +filename "ede.lyx" + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand include filename "asm.lyx" \end_inset @@ -135,16 +173,6 @@ \begin_layout Standard \begin_inset CommandInset include LatexCommand include -filename "ede.lyx" - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset CommandInset include -LatexCommand include filename "review.lyx" \end_inset
--- a/docs/lyx/intro.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/intro.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -68,7 +68,7 @@ \end_layout \begin_layout Standard -The ELB816 architecture is designed to be a +The ELB816 architecture [1] is designed to be a \begin_inset Quotes eld \end_inset
--- a/docs/lyx/intro.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/intro.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -80,7 +80,7 @@ . The combination of an ELB816 emulator, debugger and assembler could be used as a set of tools for learning or teaching micro-processor programming - without the intricacies of real-world commercial microprocessors getting + without the intricacies of real-world commercial micro-processors getting in the way of a fundamental understanding of the subject. 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,
--- a/docs/lyx/review.lyx Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/review.lyx Tue Apr 22 14:25:14 2014 +0100 @@ -122,26 +122,26 @@ \end_layout \begin_layout Enumerate -Complete debugger interface code. +Complete debugger interface code: \end_layout \begin_deeper \begin_layout Enumerate Both the PC and 8052 versions have fully implemented control interface functions. - However the Python debug class can currently only interact with a file + However, the Python debug class can currently only interact with a file buffer for I/O. - The debuggers send and receive functions need to be modified to deal with - a serial buffer + The debugger's send and receive functions need to be modified to deal with + a serial buffer. \end_layout \begin_layout Enumerate An option to enable this mode needs to be added to the command line interface - code + code. \end_layout \end_deeper \begin_layout Enumerate -Improve testing +Improve testing: \end_layout \begin_deeper @@ -149,7 +149,7 @@ Complete testing of emulator. Before any more emulator code is added, the instructions that have already been implemented should be tested using something similar to the test method - outlined in the Emulator Testing section + outlined in the Emulator Testing section. \end_layout \begin_layout Enumerate @@ -159,7 +159,7 @@ \end_deeper \begin_layout Enumerate -Develop emulated peripheral and peripheral driver code. +Develop emulated peripheral and peripheral driver code: \end_layout \begin_deeper @@ -183,12 +183,12 @@ \end_deeper \begin_layout Enumerate -Add the ability to handle segments and macros to the assembler. +Add the ability to handle segments and macros to the assembler: \end_layout \begin_deeper \begin_layout Enumerate -The ELB816 specification document details how these should work, there is +The ELB816 specification document details how these should work; there is no reason the assembler could not be modified to deal with them. \end_layout
--- a/docs/lyx/review.lyx~ Tue Apr 22 00:57:06 2014 +0100 +++ b/docs/lyx/review.lyx~ Tue Apr 22 14:25:14 2014 +0100 @@ -122,38 +122,44 @@ \end_layout \begin_layout Enumerate -Complete debugger interface code. +Complete debugger interface code: \end_layout \begin_deeper \begin_layout Enumerate Both the PC and 8052 versions have fully implemented control interface functions. - However the Python debug class can currently only interact with a file + However, the Python debug class can currently only interact with a file buffer for I/O. - The debuggers send and receive functions need to be modified to deal with - a serial buffer + The debugger's send and receive functions need to be modified to deal with + a serial buffer. \end_layout \begin_layout Enumerate An option to enable this mode needs to be added to the command line interface - code + code. \end_layout \end_deeper \begin_layout Enumerate -Complete testing of emulator. +Improve testing: \end_layout \begin_deeper \begin_layout Enumerate -Before any more emulator code is added, the instructions that have already +Complete testing of emulator. + Before any more emulator code is added, the instructions that have already been implemented should be tested using something similar to the test method - outlined in the Emulator Testing section + outlined in the Emulator Testing section. +\end_layout + +\begin_layout Enumerate +Implement automated testing for the assembler to remove the need to inspect + files by eye. \end_layout \end_deeper \begin_layout Enumerate -Develop emulated peripheral and peripheral driver code. +Develop emulated peripheral and peripheral driver code: \end_layout \begin_deeper @@ -177,7 +183,7 @@ \end_deeper \begin_layout Enumerate -Add the ability to handle segments and macros to the assembler. +Add the ability to handle segments and macros to the assembler: \end_layout \begin_deeper
--- a/emu/iset.c Tue Apr 22 00:57:06 2014 +0100 +++ b/emu/iset.c Tue Apr 22 14:25:14 2014 +0100 @@ -898,19 +898,28 @@ /* 0xF8 - MUL R0, R1 */ void MUL(void) { - /* implement me */ + tmpw = regs[R0] * regs[R1]; + regs[R0] = GHIGH(tmpw); + regs[R1] = GLOW(tmpw); } /* 0xF9 - DIV R0, R1 */ void DIV(void) { - /* implement me */ + tmpw = regs[R0] / regs[R1]; + regs[R0] = GHIGH(tmpw); + regs[R1] = GLOW(tmpw); } /* 0xFA - DA A */ void DA(void) { - /* implement me */ + if (((A & 0xF) > 9) | get_flag(AC) == 1) { + A = A + 6; + } + if (((A & 0xF0) > 9) | get_flag(C) == 1) { + A = A + 0x60; + } } /* 0xFC - IN port_addr */ @@ -934,5 +943,5 @@ /* 0xFF - HLT */ void HLT(void) { - /* implement me */ + exit(0); }