• Please review our updated Terms and Rules here

Help with Z80 Machine language program

vbriel

Experienced Member
Joined
Aug 3, 2003
Messages
332
Location
SoCal
I'm trying to write a loader for some new hardware I designed but I don't use a Z80 much and I need some help. My program doesn't work correctly, it loads every other byte. I thought I needed a delay in the dumping of the code through the serial port but that isn't it because I tried 500ms and it still skips every other byte.

I know the serial port works because I can do a simple read character, send it back out the serial port and that works without data loss. Here's my code:

LD A,03H ;RESET 6850 PORT
OUT 20 (OCTAL)
LD A,25(OCTAL) ;SET UP PORT 8,1
OUT 20
LD HL,0000H ;LOAD HL REGISTER PAIR WITH 0000 (STARTING ADDRESS)
LOOP:
IN 20 ;READ STATUS REGISTER OF 6850
RRC ;IS THERE DATA TO READ?
JNC LOOP ;LOOP IF CARRY NOT SET
IN 21 ;YES, READ DATA
LD (HL),A ;STORE DATA AT MEMORY LOCATION OF HL
INC L ;INCREASE REGISTER L
JMP LOOP ;CONTINUE THIS LOOP FOREVER UNTIL HARDWARE STOPPED

What is wrong with the code? It should continue to read data, dump it in memory, then increase the memory storage location. Thanks for any help.

Vince
 
Been a while since I have done any Z80 programming but if you copyed and pasted your code this may be your problem-

IN 20 ;READ STATUS REGISTER OF 6850
RRC ;IS THERE DATA TO READ? - Shouldn't this be RRC A (assuming status is read into A)
JNC LOOP ;LOOP IF CARRY NOT SET
IN 21 ;YES, READ DATA
LD (HL),A ;STORE DATA AT MEMORY LOCATION OF HL
INC L ;INCREASE REGISTER L Also I would think you would want to "INC HL"

Hope this helps

Jim
 
Been a while since I have done any Z80 programming but if you copyed and pasted your code this may be your problem-

IN 20 ;READ STATUS REGISTER OF 6850
RRC ;IS THERE DATA TO READ? - Shouldn't this be RRC A (assuming status is read into A)
JNC LOOP ;LOOP IF CARRY NOT SET
IN 21 ;YES, READ DATA
LD (HL),A ;STORE DATA AT MEMORY LOCATION OF HL
INC L ;INCREASE REGISTER L Also I would think you would want to "INC HL"

Hope this helps

Jim

Yeah, it is RRC A, typo. I'll try INC HL but it didn't work at all first time I tried that command.
 
Actually, I've found a pattern and it is strange. It appears that anything under hex value $20 does not get stored, very strange. I'm going to look into this more.
 
Maybe it is not your program maybe it is the program you are using to send the data, everything under hex 20 in ASCII is a control type code (bell, CR, LF etc.) maybe your Comm program is filtering them out so to speak.

Jim
 
Yeah, that was it, I forgot to select binary, duh. It's the little things, thanks.

Vince
 
Back
Top