Shop OBEX P1 Docs P2 Docs Learn Events
ASM and the |< operator — Parallax Forums

ASM and the |< operator

MightorMightor Posts: 338
edited 2007-08-29 19:22 in Propeller 1
Hey there,

I noticed that for single PIN DIRA output assignments, the |< operator is used a lot. This wouldn't really work if you have to assign multiple values to DIRA, would it?
DAT
         org
entry    mov dira, diraval

diraval long %11



This would assign both pins 0 and 1 as outputs, right? This may be a total noob Q, but I'm still busy learning.

Gr,
Mightor

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| To know recursion, you must first know recursion.

Comments

  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-08-29 08:41
    correct

    You can also use OR to set pins in dira, especially useful if some vary:

    mov dira, diraval ' lets say this sets up the basic pins
    or dira, pins ' lets say pins is a mask that varies depending on the program.
  • MightorMightor Posts: 338
    edited 2007-08-29 08:43
    Excellent, thanks!

    Gr,
    Mightor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    | To know recursion, you must first know recursion.
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-29 18:48
    Mightor said...
    I noticed that for single PIN DIRA output assignments, the |< operator is used a lot.
    This is not a machine code instruction, but a constant manipulation at compile time. It has to be used with one of many possible assigment instructions, as mentioned above: MOV, OR - or many others e.g. MUX*, ANDN,...
    But when you want to set pin x and y it's easy to write:
        MOV  DIRA, pinpattern
    ...
    pinpattern LONG |<x + |< y
    


    x and y are constants, of course!

    Note also, why they chose this funny glyph "|<": It resembles 1 <<
    You could as well write:
    ...
    pinpattern LONG 1<<x + 1<<y
    
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-29 19:18
    Because there are several instructions and configuration registers that use pin numbers, it's the most useful commonly to define the name for a pin as the pin number. Some Spin and assembly uses require a bit mask and either |< or 1<< provide a clear way to produce a bit mask from the name of a pin at compile time.
  • MightorMightor Posts: 338
    edited 2007-08-29 19:22
    Yeah, I have noticed the ASM instructions are cryptic enough without resorting to HEX numbers and binary as well [noparse]:)[/noparse] I really like the |< X + | <Y shifts to assign PINs in DIRA.
    ASM is quite fun to learn but I still have a long way to go [noparse]:)[/noparse]

    Gr,
    Mightor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    | To know recursion, you must first know recursion.
Sign In or Register to comment.