indirect addressing in assembly?
Harley
Posts: 997
I'm trying to do something new (to me) in assembly. I have a table of bytes I wish to get the address of to begin to pick up values for a D/A.
Looking at what's happening in PASD, at ':dloop' I get an address of 68BE4AFD, yet that location is 01B!
I'm obviously something is not proper here. Anyone got a clue?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Looking at what's happening in PASD, at ':dloop' I get an address of 68BE4AFD, yet that location is 01B!
I'm obviously something is not proper here. Anyone got a clue?
DAT org 0 ' entry ' --- Debugger Kernel add this at 'entry' --- MUST BE LAST COG IF USE 'PASD' long $34FC1202,$6CE81201,$83C120B,$8BC0E0A,$E87C0E03,$8BC0E0A long $EC7C0E05,$A0BC1207,$5C7C0003,$5C7C0003,$7FFC,$7FF8 ' -------------------------------------------------------------- D2A or DIRA,DAmsk ' make A16.A19 outputs or OUTA,DAmsk ' and at HI level mov indx,#15 ' set for 16 samples :dloop mov tmp,@D_A add tmp,#15 sub tmp,indx mov tmp,@tmp mov wait,D2Ams add wait,cnt waitcnt wait,D2Ams ' wait for next sample time xor tmp,OUTA ' alter just D2A pins xor OUTA,tmp djnz indx,#:dloop jmp #D2A ' run forever ' Initialized data D_A BYTE $02,$06,$0E,$0F,$0A,$03,$00,$03,$02,$02,$02,$02,$02,$02,$02,$02 D2Ams LONG 5_000_000 ' for 16 samples at 60 bpm DAmsk LONG $000F_0000 ' uses pins A16..A19 for D/A ' Uninitialized data indx RES 1 wait RES 1 tmp RES 1
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Comments
In order to do indexed addressing in PASM you have to use self-modifying code. PASM has statements especially for this that make it easy.
For a good tutorial on PASM, check out deSilva's excellent Machine Language Tutorial
http://forums.parallax.com/showthread.php?p=668559
Ken
P.S. Chapter 5 in the tutorial is where you'll find info you need.
Post Edited (Ken Peterson) : 9/15/2009 7:01:47 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Is there a a short, concise description of what one has to do to accomplish what's needed for self modifying code. To me deSilva's document is great, but think he didn't complete what he started on pg 21. Certainly didn't describe sufficiently for someone who'd never worked with such code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
The "0-0" is just a placeholder. By convention, that implies that the instruction field will be modified somewhere else in the code.
Perhaps this might make some since... another problem outside of needing to create self modifying code, your 'D_A' table is setup in BYTES
The line that reads...
...is justified in LONGS, and thus reads an entire long.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/16/2009 2:29:30 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have a look at Mike Green's post Posted around 8/23/2006 or 8/22/2006 (look about two thirds the way down the page) at:
http://forums.parallax.com/showthread.php?p=601870
This shows how to do do table look-up in PASM cog RAM; bytes as well as longs [noparse][[/noparse]note the comments and lines commented at the end with (*)]. Mike's post may provide some insight. Also 0-0 is apparently legacy nomenclature from assembler in early IBM machines. It means the "here" PASM address, which is actually the $ character in the latest prop manual. so you may use something like $-$ instead. But 0-0 is prolific in propeller example code, so my recommendation is to stick with 0-0. There was a short thread about this 0-0 thing I started not too long ago not knowing what 0-0 was with excellent feedback; but I can't find the URL right now.
Regards, David
When there's time I'll need to look into the references to self-modifying code. Sounds like magic, slight of hand as a newcomer to such coding.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko