Hi,
I'm currently designing a PWM controller for PIC, I've explained my algorithm in another topic, however, it requires that I put the contents of 3 registers in order of size. Also, to keep track of which register the contents came from, a further 3 registers which have a value that represents the register its from....hope you're still with me
So, for example, say I have 3 registers, called, A, B and C. I have put a random 8-bit number in each one. I need to have 6 registers in the output.....I'll call them:
'smallest', 'middle' and 'largest'. Also, to keep track on whats contents belongs to which register (A,B or C) the other 3 registers in the output are 'smlreg' 'midreg' and 'lrgreg'. Say, the contents of the 'A' register, happens to be the smallest out of all 3, it contains the decimal value '23'. I would put d'23' in the 'smallest' register, and put '1' in the 'smlreg' register. Maybe the contents of 'C' would be the middle value, I would then put the contents of it in the 'middle' register, and put '3' in the 'midreg' register. (thus, contents of 'B' go in the 'largest' reg', with '2' in 'lrgreg' register.
Now, I realise that its really complicated, and any higher level languages could do this in spades (PICbasic, C etc..) but I would like to do this in assembly.
I've read a little on 'conditional' assembly, and I've seen code written in the form :
IF tempreg > 0x7F
[Do something]
ELSEIF tempreg < 0x26
[Do something else]
ELSE
[leave everything alone]
ENDIF
Now, I am unsure what I can do with this? Is it for 'bit operations' (like checking bit 7 of PORTA, and flags) or can it be used for comparing contents of registers? (like IF temp1 > temp2). The only context I've seen this used is calculating delays.
Now, I'm still fairly new to assembly, and I can only assume that this is a sort of 'macro' that MPASM uses, and the output code (hex) would in fact take more than 1 instruction cycle for 'IF' because the compiler would replace it with instructions that perform exactly what I want.
It would make my algorithm a whole lot easier since I could just:
IF A > B
movf A,W
movwf HIGHEST
movf B,W
movwf LOWEST
ELSEIF B < A
movf B,W
movwf HIGHEST
movf A,W
movwf LOWEST
ELSEIF A = B
you get the idea....
If anyone could help me with this algorithm, or explain if I can in fact use 'IF-THEN-ELSE' on registers and their contents I would be grateful. If not, then I'll have to write it all in pure asm, which frankly, I'm not looking forward to
Thanks,
BuriedCode.