Writting to memory with assembly
electric550
Posts: 122
I have been using microcontrollers where there were assembly commands for the mov instruction that allow the user to write to a specific ram location like 40h, as well as read from the ram location, is that possible with the propeller in a single instruction?... or is the user limited to writing to variables without knowing the ram location? Sorry if this has been covered before I was not seeing it.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· 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)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
whereas in all other instructions you have the order 'destination', 'source' this is different in the wrlong/word/byte
wrlong someregister, HUB-RAM-Adress
this will write content of someregister into HUB-RAM-adress, which can be given by immediate when in range $-$1ff or has to be stored
inside a register.
mov $1FF, #$FFFF
1. So am I limited to 512 9 bit numbers with the ram address scheme in each cog. I apologize I am a little confused, so.
mov $1FF, #$1FF would be moving 512 into the to ram address 512 and this would be move the largest possible value to the highest ram location?
2. Also is there an assembly command to move a value from one ram address to another ram address like mov $1FF, @$02F...which would move the value at ram address 02F to the ram address location 1FF?
3. And this shared RAM between the cogs, does this require a hub operation or do the special commands write to the memory in 4 cycles like an assembly command/
Thanks for the help
2) MOV $1FF,$02F will move the contents of location $02F to location $1FF.
3) The shared memory is part of the "hub" so each cog gets one memory cycle every 16 system clock cycles to transfer one long word, word, or byte in either direction (read or write) using RDxxxx or WRxxxx where xxxx is LONG, WORD, or BYTE.
COG RAM holds program and data and some special registers. The 16? special registers are placed at the end of RAM. So you only have 496 longs for program and data.
One PASM instruction has 32bit and looks always the same. Some bits for the command, some for conditional execution, some for flags, 9 for destination and 9 for source. If you set the immediate flag (or the compiler does it for you because of the #) then this does not change anything in the command structure. So you only have the 9 bit of source for the immediate.
MOV $000, #$1FF
I would be writting ???????? ???????? ???????1 111111 to ram location 0? is there a way to address those ??? bits or are they not accessible due to the source and destination addressing, unless I go through the main hub?
2.So I looked at the SFR's and it looks like $1F2 is the address of the input pins and $1F4 is the address of the output pins...so there is no way I could write/read a 32bit number in the cog to the pins without going through the HUB???That is going to drive me crazy[noparse]:([/noparse] I was hoping to have quick 4 instruction access to the pins using the mov command.
3. So after thinking about it the only pins that I could read/write with a mov instruction from the cog without going though the hub are the bottom 0 through 8? or is there some way to treat the source and destination as regular bits or something funny like that?
for example this command reads the bottom 8 pins and puts them at ram address $000
mov $000, $1f2
this example writes to the bottom 8 pins.
mov $01F4, $1FF
?????
4. I guess this makes bit addressable cog ram out of the question?
Thanks for the info
1. The immediate value is zero extended to 32 bits so it will write 00_00_01_ff to th position 0. If you only want to modify the first 9 bits of a long, use the movs instruction instead. A movd and movi also exist for different fields. RTFM on propeller assembler instructions for clarifications. Be sure to read at least three times or till it makes sense, it can take a while, believe me .
2. Ports do not have anything to do with the HUB. You write and read using any instruction you want. Some can be used as destination and some others not. Reading from INA or writing to OUTA takes the normal 4 cycles. There is a diagram in the manual where a simple circuit for the wiring is shown.
3. To read a literal that is larger than 9 bits and write it some whenre do the following:
That way my_long_literal points to a long that contains a literal that is larger than 9 bits. Note the lack of a '#' indicating to use the contents of the memory position instead of the value itself!
I hope this clarifies your doubts. Did I recommend reading DeSilva's assembler manual ?, n ? I do now
Date Joined Aug 2008
Total Posts : 20
Posted Today 8:39 PM (GMT -7) Edit post Delete post
Thanks for all the help. I am trying to mirror 9 input pins to 9 output pins with as little error as possible(IE as fast as possible). I was hoping i could just read the value of the inputs and do a single mov to put the values on the ouput pins. For example if I used pins 0-8 as the inputs, and I want to write those values to pins 9-16 I was hoping for the code to be something like
PUB TransparentPINS
DIRA := %00000000_00000001_11111110_00000000
cognew(@Transparent,0)
DAT
'*********************
'* Assembly language *
'*********************
org
'
Transparent
MOVD $1F4,$1F2
jmp #Transparent
I tried it and it does not work but I am trying to figure out something along these line, move the values from the input pins ($1F2) to the output pins ($1F4)
Post Edited (kuroneko) : 4/12/2009 3:55:32 AM GMT