If I put 00 on the data lines (basically I grounded them all for now so they are always set at 00) when the Z80 fetches the next instruction, it will read 00 and execute the NOP (No Operation) instruction, and do nothing. This is a valid instruction for the Z80. As each instruction byte takes 4 clock tics to process, a processor running at 1MHz will take 4us (4 micro seconds) to do nothing. This is very useful for timing, because like in the real world when you're waiting for something to happen, you might just sit there and do nothing.
Anyway, it not easy knowing all the values of all the commands, its much easier to know an instruction by name such as NOP.
Consider the following Z80 program:
LD A,1 ; Load A with 1 LD B,2 ; Load B with 2 ADD A,B ; Add B to A HALT ; Stop
This converts into the following values in hex machine code:
3E 01 ; Load A with 1 06 02 ; Load B with 2 80 ; Add B to A 76 ; StopNow as you can see the program was easier to understand than the 6 bytes that the Z80 needs to receive to make it happen. What we need is something that will assemble the bytes from the written commands. As it happens there is a Z80 Assembler program called z80asm which will do it for you. So this is what I am going to use to create the bytes that I will store in the EEPROM to instruct the Z80 what to do.
No comments:
Post a Comment