Skip to content

Commit

Permalink
Add origins for all CHIPOS routines
Browse files Browse the repository at this point in the history
Should not change assembler output, but makes locations explicit and
consistent with CHIPOS manual. Will help with future modifications.
  • Loading branch information
tobiasvl committed Apr 22, 2020
1 parent f904f60 commit dea7bd7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 65 additions & 1 deletion CHIPOS68.asm
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ EXCALL: LDAB PIR ; GET INSTR REG
CMPA #$EE
BEQ RETDO
RTS ; NOP, FETCH
;
ORG $C079
;
ERASE: CLRA ; WRITE ZEROS TO SCREEN
LDX #DISBUF ; POINT TO DISPLAY BUFF
;
ORG $C07D
;
FILL: STAA 0,X ; FILL SCREEN WITH ACC-A
INX
CPX #ENDBUF ; DONE?
Expand Down Expand Up @@ -250,6 +256,8 @@ PUTVX: LDX VXLOC ; REPLACE VX
RTS
;
; RANDOM BYTE GENERATOR
;
ORG $C132
;
RANDOM: LDAA #$C0 ; HIGH-ORDER BYTE OF RNDX =
STAA RNDX ; =MSB OF CHIP8 START ADRS
Expand Down Expand Up @@ -313,6 +321,8 @@ LETIV: CLRB ; 16-BIT ADD VX TO I
;
; COPY COMPRESSED DIGIT PATTERN (FROM TABLE)
; TO 5-BYTE ARRAY (DDPAT), & SET I FOR 'SHOW',
;
ORG $C193
;
LETDSP: LDX #HEXTAB-2 ; POINT TO HEX DIGIT PATTERNS ,
ANDA #$0F ; ISOLATE LS DIGIT
Expand Down Expand Up @@ -358,6 +368,9 @@ HEXTAB: FDB $F6DF ; 0
FDB $934F ; F
;
LETDEQ: LDX I ; GET MI POINTER
;
ORG $C1E0
;
LDAB #100 ; N=100
BSR DECI ; CALC 100'S DIGIT
LDAB #10 ; N=10
Expand Down Expand Up @@ -399,7 +412,13 @@ MOVX1: PULA ; GET NEXT V
;
SHOW: LDAB PIR+1 ; GET N (OPCODE LSB)
CLR VF ; CLEAR OVERLAP FLAG
;
ORG $C224
;
SHOWI: LDX I ; POINT TO PATTERN BYTES
;
ORG $C226
;
SHOWX: LDAA #$01 ; SET DISPLAY ADRS MSB =
STAA BLOC ; = DISBUF HIGH-ORDER BYTE.
ANDB #$0F ; COMPUTE NO. OF BYTES (N)
Expand Down Expand Up @@ -444,6 +463,8 @@ SHOWUP: TAB ; UPDATE DISPLAY BYTE
SHOWR: RTS
;
; COMPUTE ADRS OF DISPLAY BYTE AT COORDS(B, VY):
;
ORG $C275
;
DISLOC: LDAA VY ; FETCH Y COORD
ANDA #$1F ; MASK TO 5 BITS FOR WRAP-ROUN
Expand All @@ -460,6 +481,8 @@ DISLOC: LDAA VY ; FETCH Y COORD
RTS
;
; KEYPAD ROUTINES
;
ORG $C287
;
PAINZ: LDAB #$F0 ; INITIALIZE PORT
PAINV: LDX #PIAA ; (ENTRY PT FOR INV. DDR)
Expand All @@ -471,6 +494,8 @@ PAINV: LDX #PIAA ; (ENTRY PT FOR INV. DDR)
RTS
;
; KEYPAD INPUT SERVICE ROUTINE
;
ORG $C297
;
KEYINP: BSR PAINZ ; RESET KEYPAD PORT
CLR BADRED ; RESET BAD-READ FLAG
Expand Down Expand Up @@ -501,6 +526,8 @@ KBILD1: INCA ; (A=RESULT)
RTS
;
; GETKEY WAIT FOR KEYDOWN, THEN INPUTS
;
ORG $C2C4
;
GETKEY: STX XTEMP ; SAVE X FOR CALLING ROUTINE
GETK1: BSR PAINZ ; RESET PORT, CLEAR FLAGS
Expand All @@ -518,10 +545,15 @@ HEXK1: BSR BLEEP ; O.K. ACKNOWLEDGE
RTS ; RETURN (WITH A<O FOR FN KEY)
;
; TONE GENERATING ROUTINES
;
ORG $C2DF
;
BLEEP: LDAB #4
BTONE: STAB TONE ; SET DURATION (RTC CYCLES)
LDAB #$41 ; TURN AUDIO ON
;
ORG $C2E5
;
STAB PIAB
BTON1: TST TONE ; WAIT FOR RTC TIME-OUT
BNE BTON1
Expand All @@ -530,8 +562,13 @@ BTON1: TST TONE ; WAIT FOR RTC TIME-OUT
RTS
;
; SOFTWARE DELAY ROUTINE FOR SERIAL I/O:
;
ORG $C2F3
;
DEL333: BSR DEL167 ; DELAY FOR 3.33 MILLISEC
;
ORG $C2F5
;
DEL167: PSHB
LDAB #200 ; DELAY FOR 1.67 MILLISEC
DEL: DECB
Expand All @@ -543,6 +580,8 @@ DEL: DECB
; TAPE INPUT/OUTPUT ROUTINES
; INITIALIZE TAPE, TONE, RTC, & DMA
; A=$3F FOR DISPLAY/DMA ON; A=$37 FOR OFF:
;
ORG $C2FE
;
PBINZ: LDX #PIAB
LDAB #$3B ; SELECT DDR (DMA ON)
Expand All @@ -555,6 +594,8 @@ PBINZ: LDX #PIAB
RTS
;
; INPUT ONE BYTE FROM TAPE PORT
;
ORG $C310
;
INBYT: BSR XCHG ; EXCHANGE X FOR PIA ADRS
IN1: LDAA 0,X
Expand All @@ -573,6 +614,8 @@ XCHG: STX XTEMP ; SAVE X-REG
RTS
;
; OUTPUT ONE BYTE TO TAPE PORT
;
ORG $C32B
;
OUTBYT: BSR XCHG
PSHA
Expand Down Expand Up @@ -611,6 +654,8 @@ LOAD1: BSR INBYT
; (BRA START)
;
; MONITOR ENTRY POINT
;
ORG $C360
;
START: LDS #STOP ; RESET SP TO TOP
LDX #RTC ; SETUP IRQ VECTOR FOR RTC
Expand All @@ -637,6 +682,9 @@ INADRS: BSR BYT1 ; BUILD ADRS MS BYTE
STAA ADRS+1
BSR SHOADR ; DISPLAY RESULTANT ADRS
BRA COMAND
;
ORG $C390
;
BYTIN: BSR GETKEE ; INPUT 2 HEX DIGITS
BYT1: ASLA ; LEFT JUSTIFY FIRST DIGIT
ASLA
Expand Down Expand Up @@ -671,20 +719,35 @@ SHOADR: LDAA #$10 ; SET CURSOR HOME POSITION
BSR SHODAT
BSR CURSR ; MOVE CURSOR RIGHT
RTS
;
ORG $C3C8
;
SHODAT: LDAA 0,X ; FETCH DATA @ X
;
ORG $C3CA
;
SHOBYT PSHA
LSRA ; ISOLATE MS DIGIT
LSRA
LSRA
LSRA
BSR DIGOUT ; SHOW ONE DIGIT
PULA
;
ORG $C3D2
;
DIGOUT: STX XTEMP ; SAVE X
JSR LETDSP ; POINT TO DIGIT PATTERN
LDAB #5 ; SHOW 5-BYTE PATTERN
JSR SHOWI
;
ORG $C3DC
;
CURSR: LDAA #4 ; SHIFT CURSOR RIGHT 4 DOTS
ADDA VX
;
ORG $C3E0
;
CURS1: STAA VX ; SET X COORD
LDAA #$1A ; SET Y COORD
STAA VY
Expand All @@ -699,9 +762,10 @@ RTC: DEC TIMER
RTI
IRQ: LDX IRQV ; INDIRECT JUMP VIA IRQV
JMP 0,X
FCB 0
;
; RESTART AND INTERRUPT TRAPS
;
ORG $C3F8
;
FDB IRQ ; (ALLOWS USER-WRITTEN ISR)
FDB $0080 ; SWI ROUIINE AT $0080 (OPTION)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ p2bin -l 0 CHIPOS68.p
```

The CHIPOS code in this repo is also available for download on [Michael J. Bauer's DREAM 6800 website](http://www.mjbauer.biz/DREAM6800.htm). Michael has stated to me in private correspondence that the code is in the public domain.

This version contains several origins. These are not needed for assembly (besides the last one that makes sure the interrupt vectors are located at the highest addresses), but they also serve to denote sections of the code that programs will expect to stay put, should you wish to edit it while still staying CHIPOS-compatible. These addresses were all found in the document "CHIPOS SUBROUTINES (& Calling Sequences)" from Michael J. Bauer's website.

0 comments on commit dea7bd7

Please sign in to comment.