230 likes | 250 Views
Learn how to emulate the Burroughs B220 on an Apple II, including addressing, memory, instructions, I/O, assembly with Merlin, and more.
E N D
A Blast From the Past:Emulating the Burroughs 220 Michael Mahon http://michaeljmahon.com
Or…Plan 9 From Outer Space:The Resurrection of the Dead (Ed Wood)
Simulating the B220on an Apple II • Apple II (6502) • 8-bit binary bytes • Binary addressing • 48KB memory • ASCII • Disk I/O • Burroughs 220 • 44-bit BCD words • BCD addressing • 5000 word memory • B220 code • Paper tape • Mag tape
B220 Memory S 1 2 3 4 5 6 7 8 9 0 • 5000 words, Sign digit + 10 BCD digits • Each word is simulated as 6 BCD bytes • To map a B220 address to an Apple II address: • Convert 4-digit BCD to 16-bit binary • Check for non-BCD digits • Multiply by 6 • Add MEM base address That’s a LOT!
B220 Addressing • BUT, it can all be done with tables! • Apple II address of B220 word is the 16-bit sum of two addresses in four tables indexed by the “raw” 2-byte BCD B220 address • Requires 36 cycles, including error checking! This made it practical to proceed.
B220 Addressing AD00 tables 00DR tables A D D R } } 00 00 + . . . . . . . . . . . . Address $49 $99 Just two indexed loads and adds!
B220 Architecture A R S 1 2 3 4 5 6 7 8 9 0 S 1 2 3 4 5 6 7 8 9 0 S V V V V O P A D D R B C P B220 Instructions: CAD, LDR, LDB; STA, STR, STB, STP IBB, DBB, IFL, DFL, DLB, BRP BFA, BFR; CFA, BCE, BCU, BCL, BCH; BUN ADD, SUB, MUL, DIV FAD, FSU, FMU, FDV PRD, PRB, PWR; MTR, MTW 7 8 9 0 7 8 9 0
B220 I/O in ProDOS • BASIC.SYSTEM’s BSAVE and BLOAD are extremely general. • Using the “B” parameter, a single file can be used as a byte-addressable virtual memory. • Since ProDOS files can be sparse, a single file can simulate a large number of pseudo-files, even from Applesoft. • B220 paper tape units are represented as ProDOS binary files: “PTUNITn”.
B220 Assembly in Merlin • Macros dramatically increase the versatility of assemblers. • Enough to permit a 6502 assembler to assemble code for a word-oriented BCD machine! • Even though Merlin’s macro capability is relatively weak: • No optional parameters • Peculiar variable scoping • No ability to manipulate strings, etc., etc.
B220 Assembly in Merlin 11 * Prime number sieve (03/30/64 - MJM) 12 13 start clb 14 test cad num ; Get next number. 15 srt 10 16 div -table ; Divide by prime. 17 bfr nxnum;00;0 ; Num isn't prime. 18 cfa -table ; Is quotient < divisor? 19 bcl addon ; -Yes, it's prime! 20 ibb test;1 ; -No, try next divisor. 21 addon cad tabln ; (Changed by quit) 22 cfaf hitab;04 23 bce quit ; Table full. 24 ifl tabln;00;1 ; Add prime to table. 25 ldb tabln 26 cad num 27 staw -table 28 xwrit cad num 29 call write 30 nxnum ifl num;00;2 ; Next odd number 31 bof stop 32 bun start ; Go again.
B220 Assembly in Merlin 50 addr mac ; Label 51 if -,]1 ; B-modification 52 ]adn equ ]1 ; -Yes, make positive. 53 ]ad equ 0-]adn-z/6 54 else 55 ]ad equ ]1-z/6 56 fin 57 err ]ad/5000 ; Address limit 58 ]a4 equ ]ad/1000 ; Thousands digit 59 ]a4m equ ]a4*1000 60 ]a4r equ ]ad-]a4m 61 ]a3 equ ]a4r/100 ; Hundreds digit 62 ]a3m equ ]a3*100 63 ]a3r equ ]a4r-]a3m 64 ]a2 equ ]a3r/10 ; Tens digit 65 ]a2m equ ]a2*10 66 ]a1 equ ]a3r-]a2m ; Units digit 67 exp on 68 db ]a4*16+]a3,]a2*16+]a1 69 exp off 70 eom
B220 Assembly in Merlin 11 * Prime number sieve (03/30/64 - MJM) 12 13 start clb 2000: 00 00 04 13 db ]sign,0,$4,$45 2003: 45 2004: 00 00 13 db ]a4*16+]a3,]a2*16+]a1 14 test cad num ; Get next number. 2006: 00 00 00 14 db ]sign,0,$0,$10 2009: 10 200A: 00 29 14 db ]a4*16+]a3,]a2*16+]a1 15 srt 10 200C: 00 00 01 15 db ]signs,0,$1,$48,0,$10 200F: 48 00 10 16 div -table ; Divide by prime. 2012: 01 00 00 16 db ]sign,0,$0,$15 2015: 15 2016: 01 42 16 db ]a4*16+]a3,]a2*16+]a1 17 bfr nxnum;00;0 ; Num isn't prime. 2018: 00 00 00 17 db ]sign,$00,$0,$37 201B: 37 201C: 00 18 17 db ]a4*16+]a3,]a2*16+]a1