Texas Instruments MSP50C614 Stereo System User Manual


 
Implementation Details
5-61
Code Development Tools
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
; called from C––
; void oport(char Port, int Data)
; Writes Data to the I/O port specified by the letter Port.
; Example:
; oport(’B’, 0xAA); //Write 0xAA to port B.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
_oport
mov a0, *r7 – 4 ; port address
mov a0~, *r7 – 2 ; data
add a0, _out_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
_prta
out 0x00, a0~ ; write to PortA
ret
_prtb
out 0x08, a0~; write to PortB
ret
_prtc
out 0x10, a0~ ; write to PortC
ret
_prtd
out 0x18, a0~ ; write to PortD
ret
_prte
out 0x20, a0~ ; write to PortE
ret
_out_port_access ; table for table lookup
DATA _prta
DATA _prtb
DATA _prtc
DATA _prtd
DATA _prte
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
; called from C––
; int iport(char Port)
; Reads data from the I/O port specified by the letter Port.
; Example:
; int data = iport(’F’); //Read port F.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––
_iport
mov a0, *r7 – 2 ; port address
add a0, _in_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
_iprta
in a0, 0x00 ; read from PortA
ret
_iprtb
in a0, 0x08 ; read from PortB
ret