| ??? 05/04/06 12:46 Read: times |
#115567 - Labels as parameters? |
Hi.
I have a feeling that I'm not going to be able to do this the way I want to, but I thought I'd see if anyone here had any suggestions. I'm building a unit that sends various commands to another piece of hardware after having formatted them. Currently the commands to send are stored within code, and are selected as below by hard-coded mov dptr statements. What I would like to be able to do is to send the unit itself commands which it then interprets and selects the relevant command (I want to obfuscate the interface, so I still want to store the commands in code, just change the way I select them). To clarify, in the code below where it has the line mov dptr, #COMMAND1 If I could I would send COMMAND1 to the unit and it would format and send COMMAND1. If I sent it COMMAND2 it would format and send COMMAND2. Of course, I can't use a label in that way, but is there an alternative? Thanks, Rob.
snip-----------------------------snip
mov dptr, #COMMAND1 ;This is the line I want to change
call FORMAT_DATA_BLOCK
call SEND_DATA
snip-----------------------------snip
snip-----------------------------snip
FORMAT_DATA_BLOCK:
CLR A
mov R1, #SEND_BUFFER ;location in databuffer
movc a,@a+dptr
mov R0, a ;R0 is length of data
inc dptr
LOOP:
clr A
movc a,@a+dptr
mov @R1, a
Inc R1
inc dptr
djnz R0, LOOP
... ;Code here to format data
...
RET
snip-----------------------------snip
snip-----------------------------snip
COMMAND1: db 6, 00h, 01h, 02h, 03h, 04h, 05h
COMMAND2: db 7, 00h, 02h, 04h, 06h, 08h, 0Ah, 0Ch
snip-----------------------------snip
|
| Topic | Author | Date |
| Labels as parameters? | 01/01/70 00:00 | |
| a sketch | 01/01/70 00:00 | |
| Thanks | 01/01/70 00:00 | |
| Superb. | 01/01/70 00:00 | |
| amazingly enough | 01/01/70 00:00 | |
| my last use of this sketched | 01/01/70 00:00 | |
Aha! | 01/01/70 00:00 |



