Assembly pushbutton?
Hello can somebody post some assembly code to mirror a pushbutton to an LED(Pushbutton positive when pressed)? Or even better seven pushbuttons to seven leds and record the lengths of the button presses to variables? I was thinking maybe using the counters or something but I am just starting in parallax assembly and really need to learn how to use the IO more efficiently. Is there a way to address single pins in assembly? I am surprised that all I have found for pin IO requires bit masking the entire port. I have been using assembly for phillips and si labs chips, (in which case I know how to do this), but it seems complicated to me right now on the propeller. Anyways thanks for your help.

Comments
You should also consider the needs of software/hardware debouncing of the signal. Usually this introduces enough of a delay that the timing becomes spin compatible anyway. Search the forum, there have been some threads recently on this.
Cheers!
Paul Rowntree
Asm has no individual bit adressing, so you must use masks.
To set a pin use
or REGISTER, Mask
To clear a pin use
andn REGISTER, Mask
EDIT : Hey it works. Here is the full version
Con _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 InputPinNum = 0 LedPinNumber = 1 Var Long AsmVar Pub Run Cognew(@Start, @AsmVar) repeat 'Repeat forever Dat org Start andn DIRA, InputMask ' Make sure InputPin is an input Or DIRA, LedPinMask ' Set led to output andn OUTA, LedPinMask ' Make output Low Main mov State, INA 'Get the current pin state set shr State, inputPin wc ' Move it to the right to place in D[noparse][[/noparse]0] and write in C flag field. if_c or OUTA, LedPinMask ' If input == 1 then c flag was set so make ledpin high if_nc andn OUTA, LedPinMask' Turn off the pin if input == 0 jmp #main 'Jump back and do it all over again InputPin long InputPinNum InputMask Long |< InputPinNum LedPinMask Long |< LedPinNumber state res 1 'A long for state of inputThis should get you·started on the right track.
TJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I owe everyone here a bunch, So thanks again for answering my dumb questions.
Projects. RG500 ECU system. PropCopter. Prop CanSat. Prop Paste Gun.
Suzuki RG500 in a RGV 250 frame.
Bimota V-Due (Running on the fuel injection system)
Aprilia RS250
Post Edited (TJHJ) : 4/9/2009 4:36:16 PM GMT