# Not understanding C, DC, & Z flags from my homework?

Discussion in 'Electronics Homework Help' started by AndreeU17, Jul 16, 2016.

1. ### AndreeU17

42
1
Apr 23, 2014
I have a homework assignment i cant begin because i simply don't know how to approach it. I will post 1 question in hopes that someone will either help me solve it, provide information, outside sources or anything really.

1) Find the value of the C, DC, and Z flags after the execution of the following code:
MOVLW 0x85

2. ### NorthGuy

53
16
Mar 24, 2016
C flag is set when the result wouldn't fit in 8-bit register. Will (0x85 + 0x9f) fit in 8-bit register?
DC is the same, but only for the low nibble. Will (0x5 + 0xf) fit in 4-bit nibble?
Z is set when the result is zero, Is it?

AndreeU17 likes this.
3. ### Minder

3,016
640
Apr 24, 2015
If you look in almost any Picmicro manual in the Instruction list section for any μp it explains exactly how an instruction affects the C,Z,DC etc.
M.

AndreeU17 likes this.
4. ### AndreeU17

42
1
Apr 23, 2014
Okay that makes sense, however, what about the assembly code MOVLW and ADDLW? What does that in itself mean?

I'm assuming that MOV is simply a move command that moves the address 0x85 into the LW. ADD then adds the 0x85 and 0x9F and the result will be placed within the LW? right?

5. ### AndreeU17

42
1
Apr 23, 2014
I don't have. This is all pulled out from the textbook and hw assignment.

6. ### AndreeU17

42
1
Apr 23, 2014
So correct me if im wrong but (0x85 + 0x9F = 0x124) and (0x5 + 0xf = 0x14), how do i know if it will fit into an 8-bit register or 4-bit nibble?

5,164
1,081
Dec 18, 2013
MOVLW mean move a literal value like say 10 into the working register. And ADDLW mean adding a value to what's in the working register. So you move 10 into the working register and add 10 to it to make 20.

MOVLW b'1010' ; this is 10

Thanks

8. ### Minder

3,016
640
Apr 24, 2015
Last edited: Jul 16, 2016
9. ### NorthGuy

53
16
Mar 24, 2016
What is the biggest number that can fit into 8-bit register?
What is the biggest number that can fit into 4-bit nibble?