No exact or substring matches. trying for part
PICList
Thread
'sublw opcode & blown up PIC'
1997\11\20@063503
by
David BALDWIN
Hi everybody,
I was away for a while, but I am now back. Don't matter, nobody knew
me...:(
I am back because I need your help. I have an ASM file that contains:
sublw .3
and it is not working properly. When I am replacing it with addlw 0xFD,
everything is working! I though the assembler was translating a sublw
into the right addlw?! Is it the same opcode?
Another BIG problem:
I am reading a byte 0xAD in EEPROM, with:
EEREAD bsf STATUS,RP0
bsf EECON1,RD
bcf STATUS,RP0
movf EEDATA,w
return
In my main program I am doing the following code:
call EEREAD
btfsc w,2
goto OK
....
OK "Send to LCD that I have been here"
The problem is that I never go to OK!!! BUT when doing the following:
call EEREAD
btfsc EEREAD,2
goto OK
....
OK "Send to LCD that I have been here"
Everithing is working! I really don't understand what's happening!
Please ... help me.
David
1997\11\20@081147
by
Dmitry Kiryashov
Hello David .
> Hi everybody,
> I was away for a while, but I am now back. Don't matter, nobody knew me...:(
Don't cry i remember you. ;)
> I am back because I need your help. I have an ASM file that contains:
>
> sublw .3
>
> and it is not working properly. When I am replacing it with addlw 0xFD,
> everything is working! I though the assembler was translating a sublw
> into the right addlw?! Is it the same opcode?
David, look carefully in your PIC manual. I think you will be surprised
because sublw K mean K-W result to W not W-K as you think !
But addlw -K works as you expect: W-K result to W .
It's the Greate Microchip joke . ;)))
WBR Dmitry.
1997\11\20@103213
by
myke predko
|
Hi Dave,
> I was away for a while, but I am now back. Don't matter, nobody knew
>me...:(
We're glad you're back anyways...
> I am back because I need your help. I have an ASM file that contains:
>
> sublw .3
>
>and it is not working properly. When I am replacing it with addlw 0xFD,
>everything is working! I though the assembler was translating a sublw
>into the right addlw?! Is it the same opcode?
Dmitry answered your question.
{Quote hidden}>Another BIG problem:
>
> I am reading a byte 0xAD in EEPROM, with:
>
>EEREAD bsf STATUS,RP0
> bsf EECON1,RD
> bcf STATUS,RP0
> movf EEDATA,w
> return
>
>
>In my main program I am doing the following code:
>
> call EEREAD
> btfsc w,2
> goto OK
> ....
>OK "Send to LCD that I have been here"
The problem is, you aren't "btfsc w,2" - you are actually executing:
btfsc INDF, 2
"w" is evaluated to Zero in MPASM and Register Zero is actually "INDF" (the
register pointed to by FSR.
In this case, you can either use the working code exchange:
btfsc w,2
with
andlw 4 ; Isolate Bit 2
btfss STATUS, Z
But, I would stick with the working example (not only is it easier to
understand, but it doesn't change the value in "w").
Good luck,
myke
PICList Etiquette at:
http://www.myke.com/piclist
1997\11\20@104307
by
Bob Fehrenbach
David BALDWIN <spam_OUTdbTakeThisOuT
SDM.BEL.ALCATEL.BE> wrote:
> sublw .3
>
>and it is not working properly. When I am replacing it with addlw 0xFD,
>everything is working! I though the assembler was translating a sublw
>into the right addlw?! Is it the same opcode?
sublw .3 does: 3 - w
addlw h'fd' does: h'fd' + w = - 3 + w = w - 3
BTW this is a very handy trick to reverse the subtraction order.
>
> call EEREAD
> btfsc w,2 <- Illegal. Can't test bits in w.
> goto OK This is actually testing the register
pointed to by the FSR register
> call EEREAD
> btfsc EEREAD,2 <- ?? EEREAD is a label in your program.
> goto OK The register actually being tested
depends on the address of EEREAD.
--
Bob Fehrenbach Wauwatosa, WI .....bfehrenbKILLspam
@spam@execpc.com
1997\11\20@122112
by
Mike Keitz
|
On Thu, 20 Nov 1997 12:28:25 +0100 David BALDWIN <db
KILLspamSDM.BEL.ALCATEL.BE>
writes:
> I am back because I need your help. I have an ASM file that
>contains:
>
> sublw .3
>
>and it is not working properly. When I am replacing it with addlw
>0xFD,
>everything is working! I though the assembler was translating a sublw
>into the right addlw?! Is it the same opcode?
No they are not equivalent.
sublw computes W = L - W
addlw computes W = L + W
They have different opcodes, and different uses. sublw negates W in the
process, addlw doesn't. If you use addlw with a negative literal
(constant) to effect a subtraction, the result is W - L.
> I am reading a byte 0xAD in EEPROM, with:
>
>EEREAD bsf STATUS,RP0
> bsf EECON1,RD
> bcf STATUS,RP0
> movf EEDATA,w
> return
>
Before using this routine, you have to store the EEPROM address of the
byte to be read in the EEADR special register. I don't think EEADR is
set to any particular known value after a reset.
There are only 64 bytes of EEPROM, so EEADR must be set within 0x00 to
0x3F. Attempting to use illegal EEPROM addresses will read 0 (and
increase the power consumption somewhat, according to the F84 data).
>
>In my main program I am doing the following code:
>
> call EEREAD
> btfsc w,2
> goto OK
> ....
>OK "Send to LCD that I have been here"
Except on the PIC17CXX, the btfsc instruction can't work on W. (w and f
are predefined to 0 and 1 to use as indications for the instructions that
accept either destination, thus this doens;t generate an error. I don't
like this very much, I would rather have the assembler parse these
instructions looking for either 0,1, or a letter explicitly).
Anyway to test a bit in W, you can do a logical AND instruction to
isolate the bit, then test the Z flag. But this zeros the other bits in
W. Another way is to store the value to RAM, then use a btfs instruction
on the bit.
If EEADR is beyond 0x3F, then the chip will read zero, and the skip will
always skip.
>
>The problem is that I never go to OK!!! BUT when doing the following:
>
> call EEREAD
> btfsc EEREAD,2
> goto OK
> ....
This, though technically legal, is programming gibberish. The assembler
defines EEREAD as the address of your EEREAD routine in ROM. Trying to
use it as an address in RAM will have unpredictable results.
1997\11\21@200702
by
Alex I. Torres
|
Hi All!
m> I have an ASM file that contains:
m>
m> sublw .3
m>
m> and it is not working properly.
What do you want ? W-3 ? It's wrong! sublw .3 means W=3-W
m> When I am replacing it with addlw 0xFD, everything is working!
Of course! 0xFD = .-3, and addlw 0xFD == W-3
m> Another BIG problem:
m>
m> I am reading a byte 0xAD in EEPROM, with:
m>
m> EEREAD bsf STATUS,RP0
m> bsf EECON1,RD
m> bcf STATUS,RP0
m> movf EEDATA,w
m> return
m>
m>
m> In my main program I am doing the following code:
m>
m> call EEREAD
m> btfsc w,2
m> goto OK
m> ....
m> The problem is that I never go to OK!!! BUT when doing the
m> following:
m>
m> call EEREAD
m> btfsc EEREAD,2
m> goto OK
m> ....
m> OK "Send to LCD that I have been here"
m>
m> Everithing is working! I really don't understand
m> what's happening! Please ... help me.
It's very simple :-)
When you write "btfss W,2" it's the same, as "btfsc 0,2" - you
test the 2nd bit of register, which address=0 - it is INDF, so
you test the 2nd bit of register, which address is in FSR.
Alex Torres, .....altorKILLspam
.....cook.kharkov.ua
Kharkov,Ukraine
--- GoldED 2.50.A0531+
'[PIC]: addlw -(.10+1) versus sublw .11'
2002\01\10@120408
by
Simon-Thijs=20de=20Feber?=
Hello all,
I have found the following piece of code which is
included in a delay routine (delay X cycles (11-256)
by Regulus Berdin ) :
addlw -(.10+1)
addlw -4
can i replace it with
sublw .11
sublw .4
cause as written literally the compiler did no accept
it !
grtz
Simon
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUT
TakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body
2002\01\10@131712
by
Andrew Warren
Simon-Thijs de Feber <PICLIST
spam_OUTmitvma.mit.edu> wrote:
> addlw -(.10+1)
> addlw -4
>
> can i replace it with
>
> sublw .11
> sublw .4
Simon:
No, you can't do that. "ADDLW -11" subtracts 11 from W; "SUBLW 11"
subtracts W from 11.
Instead, you can replace it with:
addlw .256-(.10+1) ; or addlw 245
addlw .256-.4 ; or addlw 252
-Andy
=== Andrew Warren -- @spam@aiwKILLspam
cypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspam
mitvma.mit.edu with SET PICList DIGEST in the body
2002\01\10@150528
by
Simon-Thijs=20de=20Feber?=
Hello,
OK i understand.
But somehow CC5x does not accept the following inline
assembly :
addlw -(.10+1)
This it accepts :
addlw .256 - 11
Why it did not accept the firts line of assembly.
grtz
Simon
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuT
mitvma.mit.edu with SET PICList DIGEST in the body
2002\01\11@042326
by
Dag Bakken
|
I must admit ... I've never tried that, but I ran your problem through
CC5X, and found two distingt problems. Minus and parentheses.
This is not accepted: addlw -11
This is accepted: addlw 0-11
This is not accepted: addlw (-11)
This is not accepted: addlw (0-11)
It won't take parentheses at all, and it looks like it won't evaluate
immediate negative numbers.
On the other hand, CC5X will generate the same code in assembler if
you do this in C:
W+=-11;
Dag S
STdF> Hello,
STdF> OK i understand.
STdF> But somehow CC5x does not accept the following inline
STdF> assembly :
STdF> addlw -(.10+1)
STdF> This it accepts :
STdF> addlw .256 - 11
STdF> Why it did not accept the firts line of assembly.
STdF> grtz
STdF> Simon
STdF> __________________________________________________
STdF> Do You Yahoo!?
STdF> Everything you'll ever need on one web page
STdF> from News and Sport to Email and Music Charts
STdF> http://uk.my.yahoo.com
STdF> --
STdF> http://www.piclist.com#nomail Going offline? Don't AutoReply us!
STdF> email spamBeGonelistservspamBeGone
mitvma.mit.edu with SET PICList DIGEST in the body
--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseME
spam_OUTmitvma.mit.edu
'[PIC]: SUBLW'
2002\05\15@184611
by
Thomas C. Sefranek
2002\05\15@191942
by
M. Adam Davis
2002\05\16@024905
by
Dmitriy A. Kiryashov
2002\05\16@091113
by
Eoin Ross
2002\05\16@093303
by
Alan B. Pearce
2002\05\16@093650
by
Douglas Wood
2002\05\16@103233
by
Bob Ammerman
2002\05\16@121853
by
Dwayne Reid
At 10:23 AM 5/16/02 -0400, Bob Ammerman wrote:
>But why waste the opcode space when you can just use "register
>plus -(literal) instead".
Note that ADDLW and SUBLW don't exist in the 12 bit core parts. I have to
be careful when porting existing code written for the 14 bit parts over to
the 12 bit family.
dwayne
Dwayne Reid <.....dwaynerspam_OUT
planet.eon.net>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 18 years of Engineering Innovation (1984 - 2002)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-request.....
TakeThisOuTmitvma.mit.edu
2002\05\17@005329
by
Tal Dayan
My 2c is that they wanted to provide us one more option:
w = w - K ==> addlw -K
w = k - w ==> sublw K // also w = -w ==> sublw 0
Otherwise, sublw would be practically redundant.
Does this makes sense ?
Tal
> {Original Message removed}
More... (looser matching)
- Last day of these posts
- In 2002
, 2003 only
- Today
- New search...