Shop OBEX P1 Docs P2 Docs Learn Events
Assembly question — Parallax Forums

Assembly question

S1976S1976 Posts: 6
edited 2010-03-29 09:37 in Propeller 1
Hi all,

first a "hello" to you all, i´m Stefan from Germany, 33yrs old.

I have difficulties to understand some things what´s going on on the Propeller using Assembly language. I am a former (good) AVR Assembly programmer and i want to avoid (cause of speed issues) using only SPIN. For example, i understand what is DIRA (=DDR# on the AVR) and outa (=out port# on the AVR), but are on the Propeller these two I/O-Ports 32 bits long and how to access them correctly/directly? I guess, when i do a mov dira,#XX or mov outa,#xx it sets a Value into the registers, but that ends up in nothing, it sets something, sometimes all ports, sometimes nothing, sometimes half of them, but with each increment. Now somewhere i read that i should perform a logical shift with the output register and a mask register, which works so far. Is there any possible way to set the IO-Pins directly without the need of a mask register? Because i remember that the complier complains that "a value exceeds $1FF" if i try to perfrom a direct mov into a output register, buf if the Register is 32 Bits long, why it complatins about that? See, i know two ways on the AVR: setting a value on the port by a former mov into a register, or set(reset) a pin directly on the port by using sbi(cbi) port,pin, all 8 bit wide, and that was all. It is proably (for sure) my misktake, because i sure misunderstand here the Propeller with "byte" and "bit", but why it does not accept loading directly a 32 Bit value into a output register before "merging" it with a mask register??

Other question - is there any debugger aside Ppropellersim, which does not use the hardware for real time debugging and without being limited to pure machine code (something like AVR Studio)?

Many thanks!
Greetings
Stefan

Post Edited (S1976) : 3/29/2010 3:59:30 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-29 03:47
    As you've noticed, immediate values (#XX) are limited to 9 bits. You can use immediate values to change the I/O registers (OUTA / DIRA) for I/O pins 0-8. For other I/O pins, you will need a 32-bit mask in another location for a direct value. For example:
            OR    DIRA,IOMASK         ' Turn on bit
    '...
            ANDN DIRA,IOMASK        ' Turn off bit
    '...
            TEST  IOMASK,INA   WZ  ' Test bit (note that INA must be in the source field)
    '...
    IOMASK  LONG   1<10            ' Bit 10 (I/O pin 10) is a 1
    


    Note that IOMASK doesn't have to be a compile-time constant. You can use a shift instruction to produce it given a pin number like:
            MOV  IOMASK,#1           ' Set LSB to a 1
            SHL   IOMASK,#10         ' The "10" can also come from somewhere else, say a control block in main (hub) memory
    
  • S1976S1976 Posts: 6
    edited 2010-03-29 03:55
    Ah, ok, a 9-bit wide immediate value explains a lot, i guessed that this could be proably also 32 bits long.

    Many thanks!
    Stef
  • S1976S1976 Posts: 6
    edited 2010-03-29 05:18
    Hell, i thought "what´s going on?", because setting a Port over #18 caused two LED´s to light up at the same time on my Dev-Board, before switched the VGA-connector off....
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-03-29 09:37
    You don't give the pin number, you always have to give the mask. If you want p0 to be set, mov outa, #1 will do the job. For p1 it's mov outa, #2, for p2 it's mov outa, #4 for p3 it's #8 ..... for setting pin 18 youd do

    mov outa, p18mask
    ...
    p18mask long |<18

    By the way ... there is another way to use pins above p8 with an immediate. You can also use movd outa, # $1 - $1ff
    and MOVI can be used to set the 9 most significant port pins.

    The operation which can be compared to set end clear pin instructions available on AVR are

    or for setting
    and
    andn for clearing just one pin

    But there you need pin-masks for all pins above p8 again.

    The immediate can't be 32 bits long as the instruction opcode, the flags and·the destination address also need som bits of the 32 bit a PASM instruction has. By the way ... 9 bits is the reason·for the COG-RAM size being 512 longs. With 9 bits you can address each long in COG RAM.

    Post Edited (MagIO2) : 3/29/2010 9:48:45 AM GMT
Sign In or Register to comment.