Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC Microcontroller Instruction set Problem

Status
Not open for further replies.

emhawkable

Junior Member level 1
Joined
Jun 24, 2011
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,417
I am learning PIC assembly programming . I have came across DECF and COMF instruction . But i havent found any DECw and COMW instruction .My question is Why are their no DECW and COMW instruction which could be pretty useful in programming.
 

For DECW think in terms of two's compliment numbers, just add -1. So use ADDLW h'FF'.

For COMW you can XORLW h'FF'.

Brian.
 

Thank You brian!! but actually i am asking Y is their no COMW instruction ! IS it because of pic architecture. I knw their are other ways of complementing value in work register . Actually i am not asking alternatives of COMW and DECF. I am searching for the reason that Y is their no COMF and DECF at the first place.

---------- Post added at 03:24 ---------- Previous post was at 03:18 ----------

Thank You Brian!! but actually i am asking WHY is their no COMW instruction ! IS it because of pic architecture. I know their are other ways of complementing value in work register . Actually i am not asking for alternatives of COMW and DECF. I am searching for the reason thatWHY is their no COMF and DECF at the first place.
 

I am searching for the reason that Y is their no COMF and DECF at the first place.
In case of missing COMW, there are two reasons, I think.
Brian has given the first reason. If a single cycle instruction exists, that is able to e.g. complement the work register, you don't need a second instruction with different opcode that does exactly the same. You can #define COMW as XORLW FF, if you like to.

The second reason reveals when you look at the full opcode table.

In case of missing DECW, ADDLW FF isn't an exact equivalent related to carry bit handling. But in a typical DECW operation, modifying the carry bit won't mind.
 
I suppose it would be posible to implement them as instructions in their own right but the extra silicon probably isn't worth it. You may notice that PIC architecture is orthogonal (the same instructions can be used on all registers) but W isn't a directly accessible register anyway. As FvM states, you can either #define the missing instructions or implement a macro to do the same functions.
The bigger PIC devices (some 18F, 24F and dsPICs) do have instructions to modify the working registers but there are more of them in those devices.

Brian.
 
Thank you FVM. BUT kindly can u explain your second reason regarding carry bit handling .
 

I mentioned carry bit handling as a reason, that ADDLW is not fully functionally equivalent to the hyphenated DECW instruction. Because DEC only affects Z bit, but ADD also C and DC.

Brian is probably right about the extra silicon argument for not implementing additional instructions. There's in fact a number of potential free instructions with opcode 00 0000 in the matrix.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top