AS8 assembler for intel 8008, t.e.jones Version 1.0 Options: listfile=1 debug=0 binaryout=0 singlelist=0 octalnums=1 markascii=0 Infile=cmon_w_keyboard_scope.asm Assembly Performed: Mon Dec 31 16:34:32 2018 Line Addr. CodeBytes Source Line ---- ------ ----------- ---------------------------------- 1 ROMPAGE: EQU 017 2 RAMPAGE: EQU 016 3 JMPADDR: EQU 333 4 RSAVADR: EQU 336 5 CURADR: EQU 337 6 BUFADDR: EQU 340 7 8 CR: EQU 015 9 PROMPT: EQU 076 10 DASH: EQU 055 11 COLON: EQU 072 12 SPACE: EQU 040 13 ZERO: EQU 060 14 EIGHT: EQU 070 15 16 KEYIN: EQU 004 17 KEYOUT: EQU 014 18 19 OUTWR: EQU 010 ; S3 (WR = 0) 20 OUTLOAD: EQU 011 ; S2 (LOAD = 1) 21 OUTOSC: EQU 012 ; S1 (OSC = 0) 22 OUTCHAR: EQU 013 23 24 ;ram layout 25 26 JMPINSTR: ORG RAMPAGE#JMPADDR 27 REGSAVE: ORG RAMPAGE#RSAVADR 28 CURPTR: ORG RAMPAGE#CURADR 29 BUFFER: ORG RAMPAGE#BUFADDR 30 31 ORG ROMPAGE#0 32 ; 33 ; get character from INPUT device and parse 34 ; 260 - 267 = equal octal character - shift into LS 3 bits of reg B 35 ; otherwise look for single character command (scan command table at end of listing) 36 ; 37 START: 38 17-000 006 103 LAI 103 ; display current HL and contents 39 ; it's a command 40 CMD: 41 17-002 106 260 017 CAL CLROUT ; first clear buffer 42 43 ; table search routine. start at H:L address 44 ; and go to end of page. each table entry has 45 ; two words: character and lwo adr. if a char is 46 ; found in table Z=0 and jmp to low adr in this 47 ; page 48 17-005 056 017 LHI \HB\TTBL ;loop pointers 49 17-007 066 362 LLI \LB\TTBL ; 50 CMD2: 51 17-011 277 CPM 52 17-012 150 104 017 JTZ CMDFND ; found match 53 17-015 060 INL ; 54 17-016 060 INL 55 17-017 110 011 017 JFZ CMD2 ; not found, continue searching 56 57 ; illegal command falls through to here 58 ILLCMD: 59 NXTCMD: 60 17-022 006 040 LAI SPACE ; insert space 61 17-024 106 306 017 CAL OUTPUT ; 62 17-027 006 076 LAI PROMPT ; send prompt 63 17-031 106 306 017 CAL OUTPUT ; 64 GETCHAR: 65 17-034 111 INP KEYIN ; read keyboard 66 17-035 240 NDA ; is a new character present 67 17-036 120 034 017 JFS GETCHAR 68 17-041 131 OUT KEYOUT ; ack character read 69 17-042 044 177 NDI 177 ; clear MSB 70 17-044 106 306 017 CAL OUTPUT ; 71 17-047 074 070 CPI EIGHT 72 17-051 120 002 017 JFS CMD 73 74 ; It's a number - cycle through buffer 75 NUM: 76 17-054 074 060 CPI ZERO ; is it less than 0? 77 17-056 160 022 017 JTS ILLCMD ; yes, then is an ASCII control char 78 17-061 044 007 NDI 007 79 17-063 320 LCA 80 17-064 301 LAB ; get current data from buffer 81 17-065 002 RLC 82 17-066 002 RLC ; shift left 3 bits 83 17-067 002 RLC 84 17-070 044 370 NDI 370 ; clear low 3 bits 85 17-072 262 ORC ; or in 3 new bits 86 17-073 310 LBA ; put back in buffer 87 17-074 104 034 017 JMP GETCHAR ; continue without PROMPT 88 EX: 89 17-077 304 LAE 90 17-100 323 LCD 91 17-101 104 107 017 JMP JMPIND ; execute it 92 93 94 ; found valid command, jump to execute it 95 CMDFND: 96 17-104 060 INL 97 17-105 307 LAM ; get vector for L 98 17-106 325 LCH ; vector for H is ROMPAGE (already in H) 99 JMPIND: 100 17-107 066 333 LLI \LB\JMPINSTR ; construct JMP instruction at 101 17-111 056 016 LHI \HB\JMPINSTR ; RAMPAGE 102 17-113 076 104 LMI 104 ; insert JMP op code 103 17-115 060 INL 104 17-116 370 LMA ; save vector (L is cached in E) 105 17-117 060 INL 106 17-120 372 LMC ; high address (H is cached in D) 107 17-121 104 333 016 JMP JMPINSTR ; execute it 108 ; 109 ; Command X - execute routine at address HL 110 ; user routine call: all registers could be in play 111 CX: 112 17-124 104 077 017 JMP EX 113 ; 114 ; Command H - copy BUFFER to H 115 17-127 331 CH: LDB ; put B into H (H is cached in D) 116 17-130 104 161 017 JMP DHL ; and display current value of HL 117 ; 118 ; Command L - copy BUFFER to L 119 17-133 341 CL: LEB ; Buffer B into L (L is cached in E) 120 17-134 104 161 017 JMP DHL ; DUMP PTR and CONTENTS 121 ; 122 ; Command W - write BUFFER through HL to memory 123 ; auto increment and display next location 124 17-137 353 CW: LHD ; ptr to memory (H is cached in D) 125 17-140 364 LLE ; ptr to memory (L is cached in E) 126 17-141 371 LMB ; write B at address in memory 127 ; 128 ; Command I - increment HL 129 17-142 040 CI: INE ; increment L 130 17-143 110 161 017 JFZ DHL ; no wrap, display memory 131 17-146 030 IND ; if L=0 increment H 132 17-147 104 161 017 JMP DHL ; continue to display memory 133 ; 134 ; Command D - decrement HL 135 ; destroys A 136 17-152 304 CD: LAE ; save in A, (use to check for wrap) 137 17-153 041 DCE ; decrement L (cached in E) 138 17-154 240 NDA ; check for wrap 139 17-155 110 161 017 JFZ DHL ; no wrap, now display memory 140 17-160 031 DCD ; wrap, decrement H (cached in D) 141 ; 142 ; Command C - current memory contents to serial port 143 ; destroys D (= A), E 144 CC: 145 DHL: 146 17-161 006 040 LAI SPACE ; insert space 147 17-163 106 306 017 CAL OUTPUT ; 148 17-166 303 LAD ; H is cached in D 149 17-167 106 221 017 CAL POCTAL ; display H 150 17-172 006 055 LAI DASH ; dash between high and low 151 17-174 106 306 017 CAL OUTPUT ; 152 17-177 304 LAE ; L is cached in E 153 17-200 106 221 017 CAL POCTAL ; display L 154 17-203 006 072 LAI COLON ; colon between address and data 155 17-205 106 306 017 CAL OUTPUT 156 17-210 353 LHD ; move ptr to HL 157 17-211 364 LLE 158 17-212 307 LAM ; display contents 159 17-213 106 221 017 CAL POCTAL ; print octal 160 17-216 104 022 017 JMP NXTCMD ; get next command 161 ; 162 ; print octal number 163 ; call this routine, don't jump to it 164 ; 165 ; destroys A (mangled), H (= RAMPAGE), L (= REGSAVE) 166 ; 167 POCTAL: 168 17-221 056 016 LHI \HB\REGSAVE ; ptr to reg save area 169 17-223 066 336 LLI \LB\REGSAVE 170 17-225 370 LMA ; save input char 171 17-226 002 RLC 172 17-227 002 RLC 173 17-230 044 003 NDI 003 174 17-232 106 251 017 CAL POCTAL2 ; display MSB 2 bits 175 17-235 066 336 LLI \LB\REGSAVE ; ptr to reg save area 176 17-237 307 LAM ; restore original char 177 17-240 032 RAR 178 17-241 032 RAR 179 17-242 032 RAR 180 17-243 106 251 017 CAL POCTAL2 ; display middle 3 bits 181 17-246 066 336 LLI \LB\REGSAVE ; ptr to reg save area 182 17-250 307 LAM ; restore original char 183 POCTAL2: 184 17-251 044 007 NDI 007 ; mask 3 bits 185 17-253 064 060 ORI ZERO ; make ASCII 186 17-255 104 306 017 JMP OUTPUT ; send it 187 188 ; clear output (memory and shift register) 189 ; destroys C (=A), H(=RAMPAGE), L(=0) 190 ; CURPTR - output ptr is initialized 191 ; initialize scopewriter output flip flops 192 ; 193 CLROUT: 194 17-260 320 LCA ; save A register 195 17-261 056 016 LHI \HB\CURPTR ; buffer address 196 17-263 066 337 LLI \LB\CURPTR ; buffer ptr address 197 17-265 006 340 LAI \LB\BUFFER ; pt to beggining of buffer 198 17-267 370 LMA ; buffer ptr - exit with it initialized 199 17-270 360 LLA ; pt to buffer 200 201 17-271 006 040 LAI SPACE ; space char (LSB is zero, used to init FF) 202 ; initialize output flip flops 203 17-273 123 OUT OUTLOAD ; clear load - initialize 204 17-274 127 OUT OUTCHAR ; output blanks 205 17-275 125 OUT OUTOSC ; oscillator selected 206 17-276 121 OUT OUTWR ; write mode left selected as character output call expected soon 207 208 17-277 370 CLROUT2: LMA ; save space to memory 209 17-300 060 INL 210 17-301 110 277 017 JFZ CLROUT2 ; done clearing buffer? 211 17-304 302 LAC ; restore A 212 17-305 007 RET 213 214 ; 215 ; HERE IS THE USER DEFINED PRINT ROUTINE FOR SCOPEWRITER OUTPUT 216 ; input:A, H must = RAMPAGE 217 ; destroys C (= A), L(=CURPTR) 218 ; 219 ; 220 OUTPUT: 221 17-306 056 016 LHI \HB\CURPTR 222 17-310 066 337 LLI \LB\CURPTR 223 17-312 327 LCM ; current output ptr 224 17-313 362 LLC ; to "L" 225 17-314 370 LMA ; save new character to memory 226 17-315 066 337 LLI \LB\CURPTR ; current ptr to ptr 227 17-317 020 INC ; bump ptr 228 17-320 150 324 017 JTZ OTPT2 ; check for wrap 229 17-323 372 LMC ; save updated ptr, skip if wrap 230 OTPT2: 231 17-324 320 LCA ; save character to "C" 232 ; saved new char, now display line of output 233 17-325 060 INL ; Point to beginning of buffer 234 17-326 006 001 LAI 001 ; 235 17-330 125 OUT OUTOSC ; turn off oscillator 236 17-331 250 XRA 237 17-332 121 OUT OUTWR ; enable write mode 238 239 17-333 307 DSPLY2: LAM ; fetch character 240 17-334 127 OUT OUTCHAR ; OUTPUT character 241 17-335 006 001 LAI 001 ; write 242 17-337 123 OUT OUTLOAD ; pulse load 243 17-340 250 XRA ; clear accumulator 244 17-341 123 OUT OUTLOAD ; finish load pulse 245 17-342 060 INL 246 17-343 110 333 017 JFZ DSPLY2 ; next char or end 247 248 17-346 006 001 LAI 001 249 17-350 121 OUT OUTWR ; turn off write mode 250 17-351 250 XRA ; 251 17-352 125 OUT OUTOSC ; enable oscillator/display 252 253 17-353 302 LAC ; restore A (newest char) from "C" 254 17-354 007 RET 255 256 ; 257 ; this table has octal charctets, control 258 ; characters and addres of control subroutine 259 ; note that first tabel entry is also ret 260 ; above, I E overlap is OK 261 ORG ROMPAGE#362 262 TTBL: 263 17-362 114 DATA 'L' 264 17-363 133 DATA \LB\CL ; put buffer in low adr 265 17-364 110 DATA 'H' ; H 266 17-365 127 DATA \LB\CH ; put buffer in high adr 267 17-366 111 DATA 'I' ; I 268 17-367 142 DATA \LB\CI ; increment adr pointer 269 17-370 127 DATA 'W' ; M 270 17-371 137 DATA \LB\CW ; write buffer in memory 271 17-372 130 DATA 'X' ; X 272 17-373 124 DATA \LB\CX ; execute loaded program 273 17-374 104 DATA 'D' ; D 274 17-375 152 DATA \LB\CD ; decrement address pointer 275 17-376 103 DATA 'C' ; C 276 17-377 161 DATA \LB\CC ; display memory on panel Symbol Count: 49 Symbol Oct Val DecVal ------ ------- ------ ROMPAGE 017 15 RAMPAGE 016 14 JMPADDR 333 219 RSAVADR 336 222 CURADR 337 223 BUFADDR 340 224 CR 015 13 PROMPT 076 62 DASH 055 45 COLON 072 58 SPACE 040 32 ZERO 060 48 EIGHT 070 56 KEYIN 004 4 KEYOUT 014 12 OUTWR 010 8 OUTLOAD 011 9 OUTOSC 012 10 OUTCHAR 013 11 JMPINSTR 16 333 3803 REGSAVE 16 336 3806 CURPTR 16 337 3807 BUFFER 16 340 3808 START 17 000 3840 CMD 17 002 3842 CMD2 17 011 3849 ILLCMD 17 022 3858 NXTCMD 17 022 3858 GETCHAR 17 034 3868 NUM 17 054 3884 EX 17 077 3903 CMDFND 17 104 3908 JMPIND 17 107 3911 CX 17 124 3924 CH 17 127 3927 CL 17 133 3931 CW 17 137 3935 CI 17 142 3938 CD 17 152 3946 CC 17 161 3953 DHL 17 161 3953 POCTAL 17 221 3985 POCTAL2 17 251 4009 CLROUT 17 260 4016 CLROUT2 17 277 4031 OUTPUT 17 306 4038 OTPT2 17 324 4052 DSPLY2 17 333 4059 TTBL 17 362 4082