PDA

View Full Version : ASM and the |< operator

Mightor
08-29-2007, 03:36 PM
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.

Graham Stabler
08-29-2007, 03:41 PM
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.

Mightor
08-29-2007, 03:43 PM
Excellent, thanks!

Gr,
Mightor

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

deSilva
08-30-2007, 01:48 AM
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 Green
08-30-2007, 02:18 AM
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.

Mightor
08-30-2007, 02:22 AM
Yeah, I have noticed the ASM instructions are cryptic enough without resorting to HEX numbers and binary as well :) 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 :)

Gr,
Mightor

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