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

Simple Assembly

PliersPliers Posts: 280
edited 2010-09-30 07:01 in Propeller 1
I'm learning assembly, I think.
Would someone tell me why this does not work.
I have buttons for inputs on pins 4,5,6,and,7.
My LEDs are on pins:17,18,19, and 20.
I did a spin program, and it worked.
pub main
cognew(@IOtest,0)

dat
               org 0
 IOtest      mov dira, pin        
 loop        mov outa,ina
             jmp #loop
 pin   long  %00000000000011110000000000000000

I read Mr Potatohead's article " Assembly Language Primer".
Would someone suggest other readings covering assembly language?

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-09-30 06:38
    In SPIN you probably did something like outa[17..20] := ina[4..7]. You don't do this in PASM. Try this:
    pub main
    cognew(@IOtest,0)
    
    dat
                   org 0
     IOtest      mov dira, pin        
     loop        mov outa,ina
                 shl outa,#20-7
                 jmp #loop
     pin   long  %00000000_000[COLOR="Red"]1[/COLOR]111[COLOR="Red"]0[/COLOR]_00000000_00000000
    
    Do you really mean 17..20? If so your pin mask is off by 1.
  • PliersPliers Posts: 280
    edited 2010-09-30 06:48
    Thanks for the quick reply.
    I just barley understand why I need the shift left.
    I'll give it a good study.
    Thanks again.
  • kuronekokuroneko Posts: 3,623
    edited 2010-09-30 06:52
    Pliers wrote: »
    I just barley understand why I need the shift left.

    In PASM you read all 32bit of ina. Which means that the bits you're interested in are down here %00000000_00000000_00000000_????0000. Somehow you have to get them up to here %00000000_000xxxx0_00000000_00000000, so you have to shift them left a bit.
  • LukeHLukeH Posts: 22
    edited 2010-09-30 07:01
    Likewise, in asm, when you MOV something to OUTA, you write all 32 bits of the register (for the cog you're in). Thus if you want to control only one of several leds controlled by the same cog, you would need a different instruction. OR and MUXZ come to mind. Neither of them are needed for what you're immediately trying to do right now, but you will need those instructions soon for more advanced programming.

    Practice! ASM is hard to wrap your brain around at first, but once it "clicks," it's easy and fun. Check out the "Getting Started and Key Thread Index" thread near the top of this forum for links to some good ASM academics and examples.
Sign In or Register to comment.