PDA

View Full Version : What's the fastest way to...



CannibalRobotics
03-17-2009, 10:16 PM
What's the fastest way to set the Z or C flag in assembly? I'm using the following to toggle a clock line but it's taking too long when you couple it with the cycle overhead of the CALL statement.


'-------------------------------------------------------------------------------------------
CL_ON MOV s,#0 '
TEST s,#0 wz ' Sets Z flag to 1
muxz dirA,CL_Mask ' Set CL to 1
muxz OUTA,CL_Mask ' Set CL to 1
CL_ON_Ret ret
'-------------------------------------------------------------------------------------------
CL_Off MOV s,#0 '
TEST s,#0 wz ' Sets Z flag to 1
muxz dirA,CL_Mask ' Set CL to output
muxnz OUTA,CL_Mask ' Set CL to 0
CL_Off_Ret ret
'-------------------------------------------------------------------------------------------


It's imbedded in a driver for an ADC088S052. The usage is this:



'.....
CALL #CS_Off ' Chip Select Low, wake up ADC
CALL #CL_Off ' 3 clock pulses to initiate conversion
CALL #CL_On '
CALL #CL_Off '
CALL #CL_On '
CALL #CL_Off '

SHR t2,#2 ' Shift it right 2 places (MSB out first)
AND t2,#%0_0000_0001 wz wc ' Test LSB
muxz OUTA,DI_mask ' Put a 1 on data line
muxnz OUTA,DI_mask ' Pot a 0 on data line

CALL #CL_On ' Clock High

MOV t2,ADChan ' Get ADChan again
SHR t2,#1 ' Shift it right once for middle bit
'.....

All these clock calls are driving up the time but I can't seem to figure out a way to directly toggle the port without doing a flag related operation.
Any ideas?

Thanks,
Jim-

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.

heater
03-17-2009, 10:47 PM
Why do you want to set DIRA all the time? Just do it once at start up.

Use:

or outa, CL_Mask

to set the output high. Use:

andn outa, CL_Mask

to set it low.

Neither of these will upset other bits in outa.

No calls required.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

CJ
03-17-2009, 10:48 PM
OR outa, bitmask to set port bit
ANDN outa, bitmask to clear port bit

bitmask long |< pin 'creates a long that has a single bit high that corresponds to the pin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.