Best way to write a Byte using PASM
I'm working on a parallel LCD interface driver. I want to write a byte to 8 contiguous pins.
I also want the driver to have the first pin be definable.
I'm just not sure what is the most efficient way to update all 8 lines at the same time.
I've tried the following code, but did not see any outputs change on my Logic Analyzer.
Here I define my vars...
Here is where I pass the first pin at the start up of the driver...
Then here is where I try to write a byte to the port...
Not sure what I'm doing wrong. Or maybe there is some better way to do this.
Thanks,
Jim Fouch
I also want the driver to have the first pin be definable.
I'm just not sure what is the most efficient way to update all 8 lines at the same time.
I've tried the following code, but did not see any outputs change on my Logic Analyzer.
Here I define my vars...
DB0 Res 1 DBMask Res 1 ' Used for Masking the out port Byte2Write Res 1
Here is where I pass the first pin at the start up of the driver...
Mov Par_,Par ' Grab Par pointer
RDLong DB0, Par_
MOV DBMask, #$FF ' Create an 8 Bit Mask
SHL DBMask, DB0 ' Shift Left this many pins
OR DIRA, DBMask ' Define as an output
Then here is where I try to write a byte to the port...
WriteByte ' This sub will write out 8 bits that are in Byte2Write
MOV Temp4, Byte2Write ' Place Byte to Write in
SHL Temp4, DB0 ' Shift Left to Align with DB0
ANDN OUTA, #DBMask ' Set OUTA using DBMask (make all pins Low)
OR OUTA, #TEMP4 ' Copy Byte2Write into Temp2
WriteByte_ret RET
Not sure what I'm doing wrong. Or maybe there is some better way to do this.
Thanks,
Jim Fouch

Comments
SHL Temp4, DB0 ANDN OUTA, DBMask OR OUTA, Temp4Alternatively you could have:SHL Temp4, DB0 MOV Temp5, Temp4 XOR Temp5, DBMask ' Make complement of data ANDN OUTA, Temp5 ' Turn off any zero bits OR OUTA, Temp4 ' Turn on any one bitsI always seem to mess up on the #. Either forget it when I need it or put it there when I don't....lol
I'm stuck in airports or on an airplane for the next 10 hours, so I'll have to try soon as I get back to my lab.
SHL Temp4, DB0 AND OUTA, Temp4 ' Turn off any zero bits OR OUTA, Temp4 ' Turn on any one bitsNote that the AND will turn off other bits in OUTA (outside of the 8-bit mask). If no other OUTA bits are used in this cog, that won't be an issue. This will also work if another OUTA bit is only used as a 0->1->0 strobe so forcing it to zero at this point won't cause problems.