I got the solution yesterday. I shifted the data segment (ie the RAM location at 4000h)to the end of the file and the miniprog loaded the code space but gave out of device memory error when it encountered the data space...but it is ok I can now program the eprom.
Just a background...
I am modifying an 1988 design based on z80 CPU to include a serial interface using 16c550. The original assembly programs were developed using X80 assemblers which can run only on win98 desktops. The hexfile is the linker output of the following program
UART_BaseAddr equ 0E000h
.code
org 0
nop
nop
nop
jp main
nop
nop
;*****************************************************************************
org 40h
main:
ld sp,4400h
im 2
DI ;diable interrupts
ld a,04h
ld i,a
ld a,30h
out (p0),a
call UART_INIT ; Initialise the 16C550 here
TransmitAgain: nop
call UART_Transmit ; send initialised serial data to Arduino
jr TransmitAgain
;*****************************************************************************
; Subroutine Serial Initialisation
; Input: none
; Task: Initialise the UART for baud rate of 9600
; Output:
;*****************************************************************************
UART_INIT: nop
ld ix,UART_BaseAddr
ld (ix+03),80h ; enable DLAB bit to program divisor for 4800 baudrate
ld (ix+00),18h ; 16 bit divisor LSB = 18H ie 24Decimal
ld (ix+01),00 ; divisor MSB = 00
ld (ix+03),03 ; now turn off the DLAB bit and program for 8 bitdata, 1 stop bit and no parity
set 1,(ix+04) ; Modem_Control_reg[1] = 1, ie RTS bit = 1 indicates UART is not ready to transmitting
ld ix,SrBuffer ; initialise the 32 byte serial buffer to 55h value
ld b,32
NxtBuffLoc: ld (ix+00),55h
inc ix
djnz NxtBuffLoc
ld ix,SrErrorFlag
ld (ix+00),00h ; reset all serial error flags
ret
;*****************************************************************************
; Subroutine: Serial data Transmission
; Input: none
; Task: Serial Data transmission
; Output:
;*****************************************************************************
UART_Transmit: nop
push af
push bc
push de
push hl
push ix
ld hl,SrBuffer
ld b,32
ld ix,SrErrorFlag
res 0,(ix+00)
ld ix,UART_BaseAddr
res 1,(ix+04) ;Modem_Control_reg[1], ie RTS bit = 0 indicates UART is ready to send information
ld de,0FFFEh
Chk_RecReady: bit 4,(ix+06) ; Modem_Status_reg[4] ie CTS bit = 0, indicates that modem or external device is ready to exchange data.
jr z,StartTransmit
dec de
jr nz,Chk_RecReady
ld ix,SrErrorFlag
set 1,(ix+00) ; bit 1 denotes improper termination of serial transmission
jr SrErr
StartTransmit: ld a,(hl)
ld (ix+00),a ;send buffer contents to transmit FIFO
inc hl
djnz StartTransmit ; loop until the 32 bytes are sent
chk_TrRegEmpty: bit 6,(ix+05) ; check if transmit buffer and transmit register are empty
jr nz,chk_TrRegEmpty
SrErr: set 1,(ix+04) ;set rts bit to 1 to indicate end of transmission
nop
pop ix
pop hl
pop de
pop bc
pop af
ret
;************************************************
; Data Segment
;************************************************
.data
org 4800h
;Serial interface with GM16C550
SrBuffer: defs 32 ;reserve 32 bytes of ram for incomming data
SrRecBuff: defs 32 ; reserve 32 bytes for outgoing data.
SrErrorFlag: defs 1
;*****************************************************************************
END