Question for PASM Guru
RS_Jim
Posts: 1,768
I am a bit unsure about the correctness of the following asm instructions:
[code]
if_z movi lable1,#%0010_0100_1 'rol
if_nz movi lable1,#%0010_0000_1 'ror
[code/]
Have I interpreted the book correctly? and yes there are interveining lines of code before the instruction is exicuted.
Jim
[code]
if_z movi lable1,#%0010_0100_1 'rol
if_nz movi lable1,#%0010_0000_1 'ror
[code/]
Have I interpreted the book correctly? and yes there are interveining lines of code before the instruction is exicuted.
Jim
Comments
FWIW, if those two are the only instructions ending up there you could also use a muxz and just un/set bit 26.
This is an example where muxz could come in (though would still use up two longs)
replace those two lines with this:
muxz lable1,_bit26
_bit26 long |<26
I never thought to use MUXZ! Yes those are the only two instructions that end up at that lable.Code it as ROR and use muxz bit 26 to make it ROL. Thanks for the pointers.
Jim
Muxz is not doing a 'or' (or 'andn'), as a long streatch maybe you can say it's doing one of them based on z
So you can either code lable1 it with rol or ror, it does not mater
Unless you come to this part of the code first and you want a default state.
muxz lable1,_bit26 will change it to ror/rol each time this line is run independent of that the lable1 was already a ror/rol
I was making some notes prior to coding and I realized that, yes I need to hard code it to ror and then at the end of the routine, before exiting back to the calling code, I will have to code in an andn lable,b_26 to return the code to ror for the next time the routine is called. I will use the shl intruction in my set up routine at the begining to establish b_26.I am not sure if I will be usint MUXZ or MUXNZ until I actually start coding.
Jim
Example:
code wc
muxc lable1,_confield {turn it in to a NOP or back to non-NOP}
_confield long %1111<<18 {adjust it if you use a if_ x at lable1} or auto adjust it before cognew by: _confield := lable1 & %1111<<18 {'<<' has higher priority}
Or you could just turn the intermediate value at source in to a zero (example ror dest, #1)
this will make it a NOP in its behavior: muxc lable1,#%000000001
You don't have to turn value in to a zero, if you want 3 in to 1 vs 1 it to a 3: mask = %10
Values that change two bits in opposite directions like 2 to a 1 can not be done with a single mux,
in those cases might as well use:
if_c movs lable1, #1
if_nc movs lable1, #2
At the moment, I have no reason to tristate the instruction. My thought was to hard code the ROR instruction. Next in a set up that invokes the loop containing the ror/rol instruction code the MUXZ b_26 instruction to change it to ROL. Next, when I exit the loop use ANDN b_26 to turn the instruction back to ROR. This being done, the next time I envoke the loop, the process then makes the decision of ROR or ROL again before invoking the loop. In my mind using MUXZ to toggle the bit at the end of the loop requires an extra step and is confusing to this old brain. It seems to me that the ANDN instruction to turn the bit off is the better way to go. Agree/disagree?
Jim
got it! thanks for the explaination of muxz as andn,or . I eliminate a step and always endup with the state of ror/rol that matches the input data!
Jim