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
xor functionality
Moderator: frank
Hi Tupelo,
I cannot reproduce the error, below is my test code and a comment that may help:
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.
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
Frank Thomson
Experimental Noize
Experimental Noize
xor help
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
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
Re: xor help
Actually, the smallest value greater than 0 is 0x000001 not 0x100000. Otherwise all correct.tupelo wrote: $7FFFFF = .999...
$100000 = smallest value greater than 0
$000000 = 0
$FFFFFF = smallest negative value
$800000 = -1
Frank Thomson
Experimental Noize
Experimental Noize
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
Experimental Noize