So, do you think it would be better to trap overrun, too?
Took some time to get focused but no, the two types can't be combined. An overwrite could happen during the empty test. In particular, following the POLLQMT. That's not compatible.
PS: Here's what I'm using for my debug hexadecimal ascii emits. It has a tidy compare and add:
itohl
rev pa 'least significant first
itoh
mov bcdi, #7 'most significant nibble first (zero extended)
.emit
altgn bcdi, #pa '(instruction prefix)
getnib char 'retrieve next hex digit from pa register: char = pa[bcdi]
cmp char, #10 wcz 'test if below 10, C = borrow of (D - S)
if_c add char, #"0" 'ASCII encode 0-9
if_nc add char, #"a"-10 'ASCII encode a-f
call #putch
djnf bcdi, #.emit
ret wcz 'restore C/Z flags of calling routine
I think the rev is wrong as you are reversing the bits, not bytes. Try a MOVBYTS instruction. I need the check my ROM code.
Your conversion to ASCII above uses 3 instructions here, same as mine. I suggest here you only need a CMP CHAR,#10 WC (rather than WCZ). Saves using the Z flag.
As for your prior post, I think you're right. Should be GETNIB X,Y,#0
Code to convert a nibble to an ASCII character "0".."9" "A".."F" using just the C flag...
' convert nibble to ASCII hex char
getnib x,value,#7 '\ either instruction extracts only the lower nibble
and x,#$0F '/
or x,#"0"
cmp x,#";" wc ' : -> A etc
if_nc add x,#7
";" typo as well as GETNIB to correct:
' convert nibble to ASCII hex char
getnib x,value,#0 '\ either instruction extracts only the lower nibble
and x,#$0F '/
or x,#"0"
cmp x,#":" wc ' : -> A etc
if_nc add x,#7
REV was correct for the purpose - which was to represent the sigma-delta bitstream in received bit order. Not the digit significance within an integer.
Although, I suspect this could be a valid way of displaying little endian too. We have a bad habit of calling something's LE when they're just a mishmash. LE hurts to think about sometimes.
Your conversion to ASCII above uses 3 instructions here, same as mine. I suggest here you only need a CMP CHAR,#10 WC (rather than WCZ). Saves using the Z flag.
I always restore the flags. Gives more options further up.
I just realised the implications of having 4 bits each for setting/clearing the C and Z flags.
While it's been documented for quite a long time, I missed it. It's in the document that starts with Instruction Timing, and near the end of the doc... (not sure when/where I found the doc)
The gem is the 4 bits each for setting/clearing the C and/or Z flag(s) is the same as the conditional execution bits EEEE found in each instruction.
Further down in that document are some instruction aliases...
Good idea. Having some aliases will help cement understanding of MODCZ too. An excellent example of this occurs in the google doc with the simplified list of basic inc/dec of PTRA/B.
I just realised the implications of having 4 bits each for setting/clearing the C and Z flags.
While it's been documented for quite a long time, I missed it. It's in the document that starts with Instruction Timing, and near the end of the doc... (not sure when/where I found the doc)
The gem is the 4 bits each for setting/clearing the C and/or Z flag(s) is the same as the conditional execution bits EEEE found in each instruction.
Further down in that document are some instruction aliases...
getct timeout '\ set timeout value
add timeout, ##delay1s '/
and code to test if the timeout has been exceeded
getct timenow '\ timeout ?
cmpm timeout, timenow wc '| c if timenow > timeout
if_c jmp #timed_out '/ y: timed out
Note the use of the CMPM D,#/S {wc/wz/wcz} instruction!!!
C = MSB of the result of D-S
or
pollct1 wc
if_c jmp #timed_out
However, that is not the whole story for using POLLCTn. Rather than polute that thread, perhaps you can edit your post. Thanks Brian Postedit: I meant me poluting the thread with discussion
Example shown for using CT1 (CT1, 2 &3 are available)
getct timeout '\ set timeout value
addct1 timeout, ##delay1s '/ set CT1 event to trigger when CT=timeout+delay1s
Rather than polute that thread, perhaps you can edit your post.
Never had one of my posts refered to as "pollution" before.
Not sure why my post doesn't qualify as reference, but does as general discussion?
Why do I even bother!
I didn't mean it that way Really bad choice of words on my part
I didn't want to clutter that thread with general discussion (by me asking/correcting) and as I cannot edit your post, I thought I would ask if you would mind doing that. It was just missing the bit setting up the ct1 which may have caused confusion.
I have found that the SETQ value remains persistent for multiple MUXQ instructions.
Here is an example...
setq ##$0000FFFF
muxq x,y ' x -> 1122CCDD
muxq a,b ' a -> 556600FF
or v,w
muxq y,b ' y -> AABB00FF
muxq b,x ' b -> 99EECCDD
x long $11223344
y long $AABBCCDD
a long $55667788
b long $99EE00FF
Hey, I didn't know MUXQ existed. I've wanted to do that operation too.
No, it won't work like that Cluso. Easy enough to test ...
Oh, I'm wrong. Yes, you can issue as many additional MUXQ's as you like. And can be interspersed with other instructions as well.
That's quite revealing. SETQ, the instruction, must be doing two things. One is moving the specified data to special Q register. The other is arming a special flag for telling certain other instructions they can use the value in Q.
MUXQ is different to the rest of those Q using instructions because it ignores that flag and always uses the value in Q irrespective of if a SETQ has been executed or not.
Here's a coupe of code snippets that might be useful.
The first one returns information of cog usage/count.
'get active cog information
mov pa,#7
.loop cogid pa wc 'get cog status
rcl active,#1 'rotate into mask
djnf pa,#.loop
and active,#$ff 'active cog mask
ones inuse,active 'number of cogs in use
and the second shows an example of inverting the output state of the pins used on the P2-ES board for true led indication.
'invert outputs on 56-63 for true led operation
mov pa,#56
.loop wrpin ##%1000000_00_00000_0,pa
incmod pa,#63 wz
if_nz jmp #.loop
'
'BTW This will be done in one instruction in Rev B silicon with it's range option.
'
wrpin ##%1000000_00_00000_0,#56 + 7 << 6 'Rev. B silicon only
What justification is there for excluding fastspin bugs from the reference Traps/Tips thread - the duplicate
label issue I just reported wasted hours of my time and is definity a nasty trap for the prop1->prop2 newcomers
till its fixed, at which point the posting can be edited to reflect that point?
The point of the thread is to alert people to issues that could bite them, whatever they are, surely?
What justification is there for excluding fastspin bugs from the reference Traps/Tips thread - the duplicate
label issue I just reported wasted hours of my time and is definity a nasty trap for the prop1->prop2 newcomers
till its fixed, at which point the posting can be edited to reflect that point?
The point of the thread is to alert people to issues that could bite them, whatever they are, surely?
Because it's a temporary problem, one that if reported gets rather rapidly fixed.
You have to ask, how relevant is this information let's say a month, or a year from now?
Whereas a trick or trap is for example forgetting that blasted # before a label, something that won't change and something we always have to look out for.
When you spend an hour trying to understand bizarre program behaviour which is very heisenbuggy, the
notion of temporary v. permanent trap is not so useful - the thread is surely a working document that
will be subject to update?
In case anyone's missed it, the spin2ui 1.3.6 version at least fails to give any warning about duplicate
labels leading to unpredictable behaviour if you accidentally create duplicates (copy and paste for example).
Comments
Took some time to get focused but no, the two types can't be combined. An overwrite could happen during the empty test. In particular, following the POLLQMT. That's not compatible.
It would need its own event.
You might want to make a change to recent posted code - https://forums.parallax.com/discussion/comment/1461959/#Comment_1461959
I'm pretty certain that GETNIB ,,#7 is the most significant nibble of a longword.
I think the rev is wrong as you are reversing the bits, not bytes. Try a MOVBYTS instruction. I need the check my ROM code.
Your conversion to ASCII above uses 3 instructions here, same as mine. I suggest here you only need a CMP CHAR,#10 WC (rather than WCZ). Saves using the Z flag.
As for your prior post, I think you're right. Should be GETNIB X,Y,#0
Always good to have someone keep me on my toes
";" typo as well as GETNIB to correct:
Although, I suspect this could be a valid way of displaying little endian too. We have a bad habit of calling something's LE when they're just a mishmash. LE hurts to think about sometimes.
I always restore the flags. Gives more options further up.
I just realised the implications of having 4 bits each for setting/clearing the C and Z flags.
While it's been documented for quite a long time, I missed it. It's in the document that starts with Instruction Timing, and near the end of the doc... (not sure when/where I found the doc)
The gem is the 4 bits each for setting/clearing the C and/or Z flag(s) is the same as the conditional execution bits EEEE found in each instruction.
Further down in that document are some instruction aliases...
Might these be better aliases for simple setting/clearing the C and/or Z flag(s)? (Just a compiler addition)
There are separate aliases already for MODC c and MODZ z.
CLRSET and SETCLR are rather like DOWNUP and UPDOWN, i.e. most confusing!
Postedit: I meant me poluting the thread with discussion
Example shown for using CT1 (CT1, 2 &3 are available) and code to test if the timeout has been exceeded
Not sure why my post doesn't qualify as reference, but does as general discussion?
Why do I even bother!
I didn't mean it that way Really bad choice of words on my part
I didn't want to clutter that thread with general discussion (by me asking/correcting) and as I cannot edit your post, I thought I would ask if you would mind doing that. It was just missing the bit setting up the ct1 which may have caused confusion.
BTW It absolutely qualifies as a reference!
Indeed, I had forgotten about using the pollctx.
I'll edit it all later tonight.
No worries.
I have found that the SETQ value remains persistent for multiple MUXQ instructions.
Here is an example...
Chip,
Is this a legitimate use of SETQ and MUXQ ?
No, it won't work like that Cluso. Easy enough to test ...
Oh, I'm wrong. Yes, you can issue as many additional MUXQ's as you like. And can be interspersed with other instructions as well.
That's quite revealing. SETQ, the instruction, must be doing two things. One is moving the specified data to special Q register. The other is arming a special flag for telling certain other instructions they can use the value in Q.
MUXQ is different to the rest of those Q using instructions because it ignores that flag and always uses the value in Q irrespective of if a SETQ has been executed or not.
Q is maintained indefinitely.
I did test it. These are the results. It is persistent for the MUXQ instructions
The first one returns information of cog usage/count.
and the second shows an example of inverting the output state of the pins used on the P2-ES board for true led indication.
label issue I just reported wasted hours of my time and is definity a nasty trap for the prop1->prop2 newcomers
till its fixed, at which point the posting can be edited to reflect that point?
The point of the thread is to alert people to issues that could bite them, whatever they are, surely?
Because it's a temporary problem, one that if reported gets rather rapidly fixed.
You have to ask, how relevant is this information let's say a month, or a year from now?
Whereas a trick or trap is for example forgetting that blasted # before a label, something that won't change and something we always have to look out for.
notion of temporary v. permanent trap is not so useful - the thread is surely a working document that
will be subject to update?
In case anyone's missed it, the spin2ui 1.3.6 version at least fails to give any warning about duplicate
labels leading to unpredictable behaviour if you accidentally create duplicates (copy and paste for example).