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

AndreeU17

Apr 23, 2014
42
Joined
Apr 23, 2014
Messages
42
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
ADDLW 0x9F


How do i go about that? If you need more information please let me know and ill provide more necessary information.
 

NorthGuy

Mar 24, 2016
53
Joined
Mar 24, 2016
Messages
53
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?
 

Minder

Apr 24, 2015
3,561
Joined
Apr 24, 2015
Messages
3,561
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

Apr 23, 2014
42
Joined
Apr 23, 2014
Messages
42
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?
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?
 

AndreeU17

Apr 23, 2014
42
Joined
Apr 23, 2014
Messages
42
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.
I don't have. This is all pulled out from the textbook and hw assignment.
 

AndreeU17

Apr 23, 2014
42
Joined
Apr 23, 2014
Messages
42
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?
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?
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
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
ADDLW b'1010' ; Add 10 to W makes 20

Thanks
Adam
 

NorthGuy

Mar 24, 2016
53
Joined
Mar 24, 2016
Messages
53
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?

What is the biggest number that can fit into 8-bit register?
What is the biggest number that can fit into 4-bit nibble?
 
Top