Data Transfer Instructions
MOV (#|&|@|R|@R)op1 (#|&|@|R|@R)op2- Opcode: 0x76
- Addresses: 3
- Flags: none
- Registers: none
- Function: Move op2 into op1
Copies the value of op2 into the memory address pointed to by op1. Note that if the addressing mode of op1 is immediate, the value of op2 will overwrite the current value of op1.
XCH (#|&|@|R|@R)op1 (#|&|@|R|@R)op2- Opcode: 0xF6
- Addresses: 3
- Flags: none
- Registers: none
- Function: Exchange op1 and op2
Exchanges the values of op1 and op2.
SEND (#|&|@|R|@R)op1 (#|&|@|R|@R)op2- Opcode: 0xF0
- Addresses: 3
- Flags: none
- Registers: none
- Function: Send op2 to external port op1
Sends the value of op2 to the External Port identified by the value of op1. Bear in mind that data transfer from external ports is not immediate, and it will take the external port some time to receive the data. If there is no valid External Port that can be identified by the value of op1, or if there is no hardware component connected to External Port op1, then nothing happens.
POLL (#|&|@|R|@R)op1 (#|&|@|R|@R)op2- Opcode: 0xE0
- Addresses: 3
- Flags: XI0, XI1, XI2, XI3, XI4, XI5, XI6 or XI7
- Registers: P0, P1, P2, P3, P4, P5, P6 or P7
- Function: Poll external port op1 for data at op2
Polls the hardware component connected to the External Port identified by the value of op1 for the data stored at that hardware component's internal memory address that matches the value of op2. The value returned from the port will be stored at the corresponding Port Input Register (P0, P1, P2, P3, P4, P5, P6 or P7). Bear in mind that data transfer from External Ports is not immediate, and it will take the External Port some time to get the data and write it to the corresponding register. You should check the corresponding Data-Received Flag (XI0, XI1, XI2, XI3, XI4, XI5, XI6 or XI7) or use an interrupt with that flag to validate when the data has been received before operating on it. If there is no valid External Port that can be identified by the value of op1, or if there is no hardware component connected to External Port op1, then nothing happens.
The hardware component connected at External Port op1 might not have an internal memory address that matches op2. What it sends back to its External Port (if it sends something back) is hardware-dependant, and you should check the documentation for the proper hardware component connected to that port. Nonetheless, most hardware components will simply ignore the request and not send anything back. In that case, the Data-Received Flag will never be set and an interrupt for that port will never be triggered. Take care not to enter an infinite loop while waiting for the Data-Received Flag to be set, and instead use interrupts or set up a Timer Interrupt to timeout the program waiting for the flag to be set.