DIRA,OUTA,INA,shl in PASM
Microcontrolled
Posts: 2,461
I have some questions about the I/O control in ASM. For example, in the following:
what is setting the pin and what is setting the status? Does the OR set the status and the binary set the pin? If so what command (OR, AND, XOR, NOR, etc.) sets dira to in and which to out? If you wanted to turn on pin 10 would you do it:
Do·you use the same sign as you did for the dira to choose the -/+ of the outa?!?
That and is there an ina in PASM? If so, how·do you use it?
Thanks,
Micro
P.S. I am also curious: what is the purpose of shr and shl? Shifting bits doesn't seem to be all·that useful......
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.
Robots are microcontrolled.
I am microcontrolled.
SX Spinning light display·
http://designedbymemicros.blogspot.com/
or dira, #%10
what is setting the pin and what is setting the status? Does the OR set the status and the binary set the pin? If so what command (OR, AND, XOR, NOR, etc.) sets dira to in and which to out? If you wanted to turn on pin 10 would you do it:
and outa, #%11
Do·you use the same sign as you did for the dira to choose the -/+ of the outa?!?
That and is there an ina in PASM? If so, how·do you use it?
Thanks,
Micro
P.S. I am also curious: what is the purpose of shr and shl? Shifting bits doesn't seem to be all·that useful......
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.
Robots are microcontrolled.
I am microcontrolled.
SX Spinning light display·
http://designedbymemicros.blogspot.com/
Comments
The or dira,#%10 is merely making P1 an output without altering any other pin. See the OR instruction.
The and outa,#%11 makes all output pins zero except P0 & P1. See the AND instruction.
Shifting bits is extremely useful. It is used to compile bit patterns, extract bit patterns and other useful things. Take a look at FullDuplexSerial to see how the character input and output routines use shl & shr.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
If, by status, you mean input mode state, that's set only by the state of the I/O pin itself. The INA bits correspond to the I/O pin states. You can't really set them except by changing the I/O pin state. They (the INA bits) even reflect the output state if the I/O mode (DIRA bit) is set to output.
To set a bit of any memory location (say OUTA) to one (say bit 3 of 31-0 for example), you do
OR OUTA,ioMask
To clear a bit, you'd do
ANDN OUTA,ioMask
To check if a bit is true (copy it to the zero flag), you'd do
TEST ioMask,INA wz
where
ioMask LONG %1000
Note that you need ioMask as a separate location because of how the TEST and INA work. INA is a source location only and must come in the source field of the instruction which is where the immediate value normally goes. If you put INA in the destination field, you're really manipulating a "shadow" memory location rather than the I/O hardware and the instruction won't do what you expect it to.
Shifting right divides by powers of two; to get the high byte of a 16-bit value you could do this:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA