How to use pointer in assembly?
Daniel Nagy
Posts: 26
Hello everybody!
I must miss something, or left a piece of my brain, but I can't figure out how to use a register as a pointer.
In x86 assembly (if I remember correctly):
How to do it in propeller assembly?
I've something like this:
How?
I must miss something, or left a piece of my brain, but I can't figure out how to use a register as a pointer.
In x86 assembly (if I remember correctly):
1. mov ax, bx //means move the value stored in BX to AX. 2. mov [noparse][[/noparse]ax],bx //means write the value of BX to the addresse that AX stores.
How to do it in propeller assembly?
I've something like this:
mov pointer, #pin0 mov pointer, something //want to write to the address that pointer stores, not to pointer itself, since i'd like to increase the value of pointer to reach the other pinx-es. pointer res 1 pin0 res 1 pin1 res 1 pin2 res 1 . . .
How?
Comments
We use self modifying code to do this...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Can you explain why is it better or necessary over the "good old" x86 [noparse][[/noparse]pointer] syntax? Seems very complicated for the first blink to me.
Thanks for the answer, anyway!
Post Edited (Daniel Nagy) : 1/4/2010 2:22:05 PM GMT
For an interesting and informative alternative, have a look at PropBASIC which takes a simple subset of Basic and translates it into assembly language (http://forums.parallax.com/showthread.php?p=867134).
The alternative is to store the data in HUB RAM. This avoids self modifying code, allows for (unsigned) byte and word access and is almost as fast when synchronized.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum
And thanks for all the help again!
Long answer:
You might have noticed that a lot of details are different from usual microprocessors/microcontrollers:
No set of registers - or let's better say: no difference between COG-RAM and registers
No stack
No indirect addressing
No interrupts
All this is due to one simple goal : keep the things simple to allow max. speed and min. size.
Indirect adressing mode problems start with the instructions machine code itself. Where do you want to put the additional parameter for the instruction? You need the source, the destination and additionaly an offset. All 32 bits are used! Other micros simply add a byte or a word or whatever - having variable lenght instructions. Makes things more complex.
Next problem is the execution. You need an additional step to calculate the resulting address. How you wanna do that? Add another stage in the execution pipeline? In general or conditional? Makes execution slower or you have instructions with different execution speed. 5 cycles instead of 4 for example.
And what's the advantage? Of course one stage in the pipeline is executed faster than one instruction for self-modifying code. But usually you do such things in a loop and it's no difference in adding 1 to the source address from increasing the offset.
It would be really interesting to see how much memory a SPIN interpreter would need on a different architecture!
PS: guess I mixed up indirect addressing with indirect addressing with offset. Of course you don't have to calculate something·for indirect addressing. But you need an additional fetch. So, the indirect addressing itself has no problem with instruction-size as stated above. That's only true for indirect addressing with offset. ... it's late ... maybe to late to post something useful ;o)
Post Edited (MagIO2) : 1/5/2010 10:22:46 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.