Examples:
’Read I/O after an OUTn instruction
PUSH 85 ’Bit pattern 01010101 (bits 7–0)
OUT 7 ’output pattern to port
IN 7 ’P OP data f r om por t to argument s t ack
POP A ’get data from argument stack. (01010101)
? A ’prints 85 unless bit 6,4,2 or 0 were pulled low.
’Bits that are 0 in this case were read from the output LATCH.
’Bits that are 1 in this case were read from the output PINS.
’Outpu t t ing an d Inputti ng data from Ports 4– 7 an d PORT1.
PUSH 39 ’push argument onto stack
OUT 4 ’output data to PORT 4 (Z80–PIO U4 P ort A ,
’which is pins 17–24 on P1 connector . see table
’The OUT also fixes the argument stack
A= 10: B= 20: C= 30: D= 40: E= 50
PUSH A,B,C,D ’Push arguments onto stack (LIFO)
OUT 4,5,6,7 ’Output arguments to ports 4, 5, 6, 7
PORT1= E ’output to PORT1
’PORT1= 50, Port 4= D, 5= C, 6= B, 7= A
IN 4,5,6,7 ’Push data from ports 4, 5, 6, 7. The data
’is "Pushed" onto the argument stack
E= PORT1 ’"Read" PORT1 data
POP A,B,C,D ’Pop data f r om stack ( LIFO)
’A= Port 4, B= 5, C= 6, D= 7
? A,B,C,D,E ’prints 10 20 30 40 50. Note the order is not
’reversed, because of the "Last In First Out"
’nature of the stack.
On a 2010M (machine Language board), and a 2010B, P1.0 – P1.7 is
PORT1 on the 8031 U2. On a 2010M, P80.0 – P80.7 refers to the
Z80–PIO U3 Port A data bits. The 80 refers to the memory map address 80xxH where you can address the A data port. The control
port would be 8 1xxH. The 8 2 refers to the m emory map address
82xxH where you can address the B data port. Control is 83xxH.
The .7 in P80.7 refers to the bit number 7 in that data port. PA0.7 –
P A 0.0 is the Z80–PIO U4 port A. P A 2.7 – PA2.0 refers to the Z80–PIO
U4 port B.
P139 – P132 corresponds to P1.7 through P1.0 on U2. P131 – P124
corresponds to U3 port B bits 7–0. P123–P116 corresponds to U3
Model 2010B Appendix A
Page 28