Wednesday, August 15, 2018

--> 6800/6802

The 6800 was released in 1974.  An operating system similar to CP/M called Flex became the standard for the first 6800 based systems.

The 6800 was the CPU in the Imagination Machine, but not many "personal" type computers.

The 6802 is a 6800 with simpler design requirements.  A Japanese version of the 6802 was the basis of the Panasonic JR-200 personal computer, which benchmarked quite fast in spite of having such an early processor.

The example code below was written just for this post so it's likely to buggy and or inefficient.
I've never written strait 6800 code before so I'm not well versed in tricks coding for it.
The screen address is off by 8 since we start at top byte and push bytes to the screen.
Not fixing it... you get the idea.

*edit 8/29/2018*
Changed the code to use both accumulators when writing characters to the screen.  It isn't as fast as the 6803 change, but it cuts the number of index register changes in half.
It's only 12 clock cycles, but for a screen full of characters it adds up to 9,216.
At 124 clock cycles, writing to the screen is faster than the 6502's 152 clock cycles.  The address calculations are where the 6502 has the upper hand due to the use of tables.


;**************************************************
; write two characters at once
;**************************************************
print_642:
 ; a contains left character on entry
 ; calculate address of left character font data
 tab       ;       2
 subb #28     ; adjust for first character in the font 2
 clra      ;       2
 ; adjust for 8 bytes per character by adding (offset * 8) to address of font
 andb #%11111110
 aslb      ; x 2  (we can only left shift once.  Max of 128 characters in font 0-127 %01111111) 2
 aslb      ; x 4   2
 aslb      ; x 8   2
 rola      ;       2
 addb >#leftfont   ; address of left character bytes in font 3
 adca <#leftfont
 staa leftchar
 stab leftchar+1

 ;calculate screen address
 ldx  row     ; put row in X
 ldab col     ; put col in LSB
 lslb      ; * 4
 lslb      ; * 8 bytes per character between columns
 adab #screenLSB,x  ; Screen address + 7 LSB
 adca #screenMSB,x  ; Screen address + 7 MSB
 pshb      ; transfer to x, then s for our screen pointer
 psha
 pulx
 sts  stacktmp   ; save the stack pointer
 txs       ; point s to the screen address we want to start writing to 4

 ;calculate address of right character font data
 ldab 1,x     ; get right character
 subb #28     ; adjust for first character in the font
 clra      ;       2
 ; adjust for 8 bytes per character by adding 8 times offset to address of font
 aslb      ; x 2  (we can only left shift once.  Max of 128 characters in font 0-127 %01111111) 2
 aslb      ; x 4   2
 aslb      ; x 8   2
 rola      ;       2
 addb >#rightfont   ; address of left character bytes in font 3
 adca <#rightfont
 staa rightchar
 stab rightchar+1
 ldx  rightchar
 
 ; print characters to screen
 ldab 7,x     ; get byte of right character 5
 ldaa 6,x     ; get byte of left character
 ldx  leftchar   ; point to left char 4
 eorb 7,x     ; add the left character to the byte 5
 eora 6,x     ; add the right character to the byte
 pshb      ; write to the screen 4
 psha      ; write to the screen


 ldab 5,x     ; get byte of right character
 ldaa 4,x     ; get byte of left character
 ldx  rightchar   ; point to right char
 eorb 5,x     ; add the left character to the byte
 eora 4,x     ; add the right character to the byte
 pshb      ; write to the screen
 psha      ; write to the screen


 ldab 3,x     ; get byte of right character
 ldaa 2,x     ; get byte of left character
 ldx  leftchar   ; point to left char
 eorb 3,x     ; add the left character to the byte
 eora 2,x     ; add the right character to the byte
 pshb      ; write to the screen
 psha      ; write to the screen


 ldab 1,x     ; get byte of right character
 ldaa 0,x     ; get byte of left character
 ldx  rightchar   ; point to right char
 eorb 1,x     ; add the left character to the byte
 eora 0,x     ; add the right character to the byte
 pshb      ; write to the screen
 psha      ; write to the screen

 rts

No comments:

Post a Comment