Help with PASM Data Table
Drone
Posts: 433
Hello,
Awhile back when perusing this forum I scraped a snippet of code by Mike Green (thanks Mike) on how to handle a data table in cog RAM with PASM. Something's coming up where I need to do just that. So I stuck Mike's code in a wrapper (see attached files), and took it for a "spin". It works fine.
The problem is I don't understand how it works. I'm really not good in PASM, but I'm trying. I don't understand how this part works:
Especially the mov idx_,0-0 line. This looks like re-entrant code. I searched the forum and manual, and I'm still not getting it. Can someone please explain what's going on here in plain language.
Thank You,
David
Awhile back when perusing this forum I scraped a snippet of code by Mike Green (thanks Mike) on how to handle a data table in cog RAM with PASM. Something's coming up where I need to do just that. So I stuck Mike's code in a wrapper (see attached files), and took it for a "spin". It works fine.
The problem is I don't understand how it works. I'm really not good in PASM, but I'm trying. I don't understand how this part works:
[b]add[/b] Idx_,#table 'Long word index, add table address [b]movs[/b] :inline,Idx_ 'Use instruction modification [b]nop[/b] 'Pause for pipelining :inline [b]mov[/b] Idx_,0-0 'Get long value from table [b]wrlong[/b] Idx_,[b]par[/b] 'Return result to Idx_
Especially the mov idx_,0-0 line. This looks like re-entrant code. I searched the forum and manual, and I'm still not getting it. Can someone please explain what's going on here in plain language.
Thank You,
David
Comments
movs fills the source (bits 8 to 0) of the destination with the value in the source (either literal or from memory).
What you do is: you have a table in COG memory. To read it you need an address to the start and an index. table is your start address, top of the table. idx_ is your index. The resulting value is your source address to read from the table. So you move (using movs) this address to the instruction (@ :inline) that will actually read the table.
See what happens, see the images in order from 9 to 13.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH
pPropQL: propeller.wikispaces.com/pPropQL
pPropQL020: propeller.wikispaces.com/pPropQL020
OMU for the pPropQL/020 propeller.wikispaces.com/OMU
Post Edited (Ale) : 8/11/2009 10:58:12 AM GMT
I think I understand your explanation. Allow me parrot - please point out any mistakes:
Question: Where did Mike come up with the "0-0" in ":inline mov idx_, 0-0"? This is just a source place-holder that gets overwritten right? Why "0-0" and not something else? What else can be used in-place of 0-0.
Thanks Ale, David
Edit: your understanding is ok.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH
pPropQL: propeller.wikispaces.com/pPropQL
pPropQL020: propeller.wikispaces.com/pPropQL020
OMU for the pPropQL/020 propeller.wikispaces.com/OMU
-Phil
I'd never given it any thought prior to this, and for what you are doing it probably does not matter, but
$-$, 0_0, 0-0, 0 all equal zero (either as a constant - 0_0 - or evaluation - 0-0 / $-$), where $ is the current cog address.
The PASM Here ($) was a late entry into the compiler and happened after the manual was written. In the 1.1 version it's documented on P298 in the last paragraph. Not the most logical place to find it as its not exclusive to the JMP instruction, but it's there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
my 2 cents
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, RamBlade, TwinBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80), MoCog (6809)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Cluso99, Thanks for the reply. I agree with your approach. I will use 0-0 and document/comment in-detail what's going on if I release any PASM to the Wild.
Phil, For what it's worth - I actually dealt with the IBM 1130 decades ago. I was asked to design and implement a parallel bus interface for the beast at a radio astronomy observatory. It wasn't too bad given the carts of excellent IBM hardware and software documentation at-hand. I implemented a discrete transistor design (really no other way back then). I seem to remember initially testing the interface by programming the 1130 in machine code via the switches on the front panel to ensure fastest bus speed; even though the 1130 had a keyboard/selectric ball-printer, removable HDD (8KB if memory serves), and huge page printer (stomper) plus card reader peripherals.
Best Regards, David