Wednesday, August 15, 2018

--> HD64180/Z180

Runs Z80 code.  The addition of the multiply instruction, larger ALU, and microcoded/pipelined design make these CPUs over 20-30% faster than the Z80

;**************************************************
; write two characters at once
;**************************************************
print642:
  ; C contains left character, A contains right character
  ld  d,8    ; to multiply by 8
  ld  e,a    ; now E = right char, preserves it for later

  ; calculate screen address
  ld  a,(AT_COL)  ; get the column
  rra
  ld  h,d    ; ld h,8
  ld  l,a    ; ld l,(AT_COL)
  mlt  hl    ; hl = column offset  (8*(AT_COL>1))
  ld  a,l    ; because we can't  ld ixl,l  Saves it in IX LSB
  ld  ixl,a   ; screen address LSB
  ld  a,(AT_IROW)  ; get the row
  adD  a,70h   ; add screen MSB
  add  a,h    ; add carry from mlt
  ld  ixh,a   ; save it in MSB of IX

  ; Calculate location of the first character
  ld  h,8    ; to multiply by 8
  ld  l,c    ; now L = left char
  ld  bc,FONT_ADDRl-224 ;add font address  - correct for missing  sbc a,' '
  mlt  HL    ; multiply the left character by 8
  add  hl,bc   ; now hl = FONT_ADDR + 8 * INT(char)
  ex  de,hl   ; DE = left char
  
  ; Calculate location of the second character
  mlt  DE    ; multiply the right character by 8
  add  hl,bc   ; now hl = FONT_ADDR + 8 * INT(char); HL = right char
  
;start printing
  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+0),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+1),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+2),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+3),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+4),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+5),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+6),a  ; write result back to screen
  inc  de    ; next font1 data location
  inc  hl    ; next font2 data location

  ld  a,(de)   ; get byte of 1st char
  add  a,(hl)   ; get byte of 2nd char
  ld  (IX+7),a  ; write result back to screen

  ret

No comments:

Post a Comment