kindly please, this drives me crazy, I am unable to block copy 4kB ROM to RAM, when I copy single byte, its okay ... (first ASCI0 sent is "R")
I tried it at 18MHz, then slowed down to 9MHz, usually using LDIR first, then rewrite it as routine, ... NO, I am LOST ... totally.... :-(
ORG 0
DI ; disable interrupts
LD A, ROFF ; relocate I/O register to 0xC0
OUT0 (ICR), A
LD A, 00h ; Clock Multiplier OFF
OUT0 (CMR), A
;LD A, 80h ; Clock Divider OFF
LD A, 00h ; Clock Divider 2
OUT0 (CCR), A
LD A, 64H ; transmit, receive enable, 8-bit 1 stop
OUT0 (CNTLA0),A
;LD A, 22H ; divided by 1920, 9600 with 18.432MHz clock
LD A, 21H ; divided by 960, 9600 with 9.216MHz clock (CCR divider 2)
OUT0 (CNTLB0),A
LD A, 60H
OUT0 (ASEXT0),A ;
LD A, 8Bh ; map RAM physical base, so page $8B mapped to logical 0xc000
OUT0 (CBR), A ; write to common base reg
LD A, 00h ; map ROM physical base, so page $00 mapped to logical 0x0000
OUT0 (BBR), A ; write to common base reg
LD A, 0C0h ; common area is 0xc000-0xffff (RAM $8B)
OUT0 (CBAR), A ; set common/bank register
LD HL, 0B000h ; ROM source
LD DE, 0C000h ; RAM destination
LD BC, 1000h ; copy 4K from EPROM into RAM
;THIS DOES NOT WORK!!! - "R" expected at 0C002h !!!!!!!!!!!!!
;LDIR
COPY: LD A,(HL)
LD (DE),A
INC HL
INC DE
DEC BC
LD A,B
OR C
JP NZ, COPY
;LD A, 50h ; by changing mapping of RAM physical base, I move copied program to 0xb000
;LD A, 80h ; by changing mapping of RAM physical base, I move copied program to 0xb000
;OUT0 (CBR), A ;
; LD A, 80h ; by changing mapping of RAM physical base, I move copied program to 0xb000
; OUT0 (CBR), A ;
; LD A, 00h ; map RAM physical base, so page $00 mapped to logical 0x0000
; OUT0 (BBR), A ; write to common base reg
; LD A, 00H ; all memory are now RAM
; OUT0 (CBAR),A
;THIS WORKS, COPIES ONLY 0B002h to 0C002h
;BY COMMENTING THIS OUT, THE BLOCK LDIR/ROUTINE DOEST COPY 0B002h to 0C002h ???????
LD HL, 0B002h ; ROM source
LD DE, 0C002h ; RAM destination
LD A,(HL)
LD (DE),A
;EXPECTING "R" HERE BY COPY
LD HL, 0C002h ; "R"
;LD (HL), 67
LD A, (HL)
OUT0 (TxData), A
;STOP: JP STOP
;JP 100h