xor functionality

Software questions and issues with the FV-1

Moderator: frank

Post Reply
tupelo
Posts: 6
Joined: Fri Dec 08, 2006 9:08 am

xor functionality

Post by tupelo »

I new at this, so please excuse my basic question. I want to toggle a variable between two states. The following code doesn't seem to work. What gives?

clr
or 1
wrax toggle, 0 ; toggle = 1
.
.
.
ldax toggle ; flip toggle
xor 1
wrax toggle, 0
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Hi Tupelo,

I cannot reproduce the error, below is my test code and a comment that may help:

Code: Select all

toggle equ reg0
skp run, start
clr
or 1
wrax toggle, 0 ; toggle = 1
;
start:
ldax toggle ; load toggle
skp zro, right; if toggle =0, output to right channel else left
;
ldax adcl; read left input
wrax dacl,0; write it to left
skp zro, flip; jump to end
;
right:
ldax adcl; read left input
wrax dacr,0; write it to right
flip:
ldax toggle
xor 1
wrax toggle, 0
Program operated as expected (left input ping-pongs between left and right output). One thing I noted (and did in my test code as well) you used "1" for the OR and XOR. While this will work it is recommended that you use hex values like 0x100000. Using an integer value should map into bits properly but may not have the result intended. In this case the "1" is mapped to the LSB of the mask so you have a reslt of 0x000001. If you use "toggle" as a coefficient it could be a problem.
Frank Thomson
Experimental Noize
tupelo
Posts: 6
Joined: Fri Dec 08, 2006 9:08 am

xor help

Post by tupelo »

Thanks for the help. I don't have a scope, so it may be time to invest in one. Apparently another part of my algorithm is suspect.

I appreciate the help on constants also. So if I understand this correctly, the following is true when loading the ACC with constants:
$7FFFFF = .999...
$100000 = smallest value greater than 0
$000000 = 0
$FFFFFF = smallest negative value
$800000 = -1
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: xor help

Post by frank »

tupelo wrote: $7FFFFF = .999...
$100000 = smallest value greater than 0
$000000 = 0
$FFFFFF = smallest negative value
$800000 = -1
Actually, the smallest value greater than 0 is 0x000001 not 0x100000. Otherwise all correct.
Frank Thomson
Experimental Noize
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Forgot to mention, if you're still having problems with the code, post it and I'll take a look at it or if you prefer to email it : frank at oct-distribution dot com
Frank Thomson
Experimental Noize
Post Reply