Easier way to access table of data in COG?
Rayman
Posts: 14,658
I just got something working, but thinking there has to be an easier way...
For this USB stuff, I want to send a series of bytes.
Maybe what I should do is put those bytes in a hub table and use that ptra thing
But, decided to store them as a series of longs in cog for now.
Anyway, first long is #of entries in table, following longs are table entries.
Here's the code I came up with. It works, but seems very awkward to do something so simple:
Self-modifying code hurts my brain...
For this USB stuff, I want to send a series of bytes.
Maybe what I should do is put those bytes in a hub table and use that ptra thing
But, decided to store them as a series of longs in cog for now.
Anyway, first long is #of entries in table, following longs are table entries.
Here's the code I came up with. It works, but seems very awkward to do something so simple:
DAT 'init Mouse InitMouse 'Send Setup mov x2,#1 'SeO call #TransmitByte waitx ##50 mov x2,#0 call #TransmitByte waitx ##5000 sets SendPacket,#Setup nop call #SendPacket testz jmp #testz ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Setup long 3,$2D,$00,$10 GetDeviceD long 11,$C3,$80,$06,$00,$01,$00,$00,$40,$00,$DD,$94 DAT 'SendPacket Sub SendPacket mov i2,0-0 mov tx_out,i2 call #OutputByteSub sets SendByte,SendPacket add SendByte,#1 nop nop SendByte mov x2,0-0 add SendByte,#1 mov tx_out,x2 call #OutputByteSub djnz i2,#SendByte RET
Self-modifying code hurts my brain...
Comments
Sends the byte out over serial port, so I can see what's going on.
It's wasn't easy for me to figure out whether to use #0-0 or just 0-0 or whether the SETS arguments should have a # in front of them or not.
In then end, I just figured it out by trial and error...
Andy uses it in his all cog char driver. Fast, simple. I'm not on a machine where I have a code snippet.
We should start a snippet pile. There is so much here. I know I'm not using it all very well yet. That is due to treating P2 like a P1.
It appears to be called alti now.
https://docs.google.com/document/d/1O27nO2tMjBTvUNblFFRtEp5DHvcvsSGXcPvH9FaJ9u8/pub#h.8eh0m9l68srf
There is some explanation at the bottom, but it's still called ALTDS there.
I tried using it, but couldn't make it work so did something else...