Implementation Details
5-62
_iprtc
in a0, 0x10 ; read from PortC
ret
_iprtd
in a0, 0x18 ; read from PortD
ret
_iprte
in a0, 0x20 ; read from PortE
ret
_iprtf
in a0, 0x28 ; read from PortF
ret
_in_port_access ; table for table lookup
DATA _iprta
DATA _iprtb
DATA _iprtc
DATA _iprtd
DATA _iprte
DATA _iprtf
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
; called from C––
; void cport(char Port, int Control)
; Writes Control bits for the I/O port specified by the letter Port.
; Example:
; cport(’B’, 0xFF); //Configure all bits of Port B as output
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
_cport
mov a0, *r7 – 4 ; port address
mov a0~, *r7 – 2 ; data
add a0, _cont_port_access – ’A’ ; find the location in the table
mov a0, *a0 ; get the value of the label in the table
jmp *a0 ; jump to the label from the table
_cprta
out 0x04, a0~ ; write to PortA control
ret
_cprtb
out 0x0C, a0~ ; write to PortB control
ret
_cprtc
out 0x14, a0~ ; write to PortC control
ret
_cprtd
out 0x1C, a0~ ; write to PortD control
ret
_cprte
out 0x24, a0~ ; write to PortE control
ret
_cont_port_access ; table for table lookup
DATA _cprta
DATA _cprtb
DATA _cprtc
DATA _cprtd