Discussion:
[PIC]: DAW
Anthony Nixon
2018-11-07 08:11:08 UTC
Permalink
Hi all,

The DAW instruction for 18F series states in the data sheet...

If [W<3:0> > 9] or [DC = 1] then
(W<3:0>) + 6 ? W<3:0>;
else
(W<3:0>) ? W<3:0>;
If [W<7:4> + DC > 9] or [C = 1] then
(W<7:4>) + 6 + DC ? W<7:4> ; ???????????
else
(W<7:4>) + DC ? W<7:4>

After simulating with MPLAB X IDE v5.05, it appears that the
questioned line is not correct.

On simulation, it appears to be...

(W<7:4>) + 6 ? W<7:4> ;

ie It doesn't actually add the DC bit, which seems correct.

Anyone have experience here. The manual or the SIM could be wrong.

cheers

Tony
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Anthony Nixon
2018-11-07 23:13:56 UTC
Permalink
Hi all,

My application talks to the PIC via the PC serial port so it was easy
to run the DAW instruction through 0-255 with carry set/clear and DC
set/clear.

Using a PIC18F47K40

It appears that the data manual text

If [W<7:4> + DC > 9] or [C = 1] then
(W<7:4>) + 6 + DC ? W<7:4> ; <<<<<<<

is incorrect, and...

If [W<7:4> + DC > 9] or [C = 1] then
(W<7:4>) + 6 ? W<7:4> ;

appears to be correct.

Z=1 if Wreg=0 after DAW executes

if Carry = 0 prior to DAW then
if Wreg < 99, then after DAW C=0, else C = 1 (DC can be 0 or 1)

if Carry = 1 prior to DAW then
if DC=0, then C stays = 1, DC stays 0
if DC=1, then C stays = 1, DC stays 1

cheers

Tony
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Anthony Nixon
2018-11-08 00:15:47 UTC
Permalink
Hi all,

Appologies,

My statement
Z=1 if Wreg=0 after DAW executes (is wrong)
My original PIC code was corrupting the STATUS bit prior to the DAW executing

This new code was used for testing...

movlw 0xFF
movwf TempB
call GetByte ; 0-255 from PC
movf TempB ; make sure Z bit is clear
bcf STATUS,C ; bcf bcf bsf bsf
bcf STATUS,DC ; bcf bsf bcf bsf
daw
call PutByte ; to PC
movf STATUS,W
call PutByte ; to PC

cheers

Tony
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Loading...