I am stuck on the following code and don't have a basic understand of how it works?
Determine the decimal value of r22 after the following line of code is executed:
clr r22
dec r22
push r22
dec r22
pop r5
value of r22 = ?
I am stuck on the following code and don't have a basic understand of how it works?
Determine the decimal value of r22 after the following line of code is executed:
clr r22
dec r22
push r22
dec r22
pop r5
value of r22 = ?
Well, just work through each instruction one at a time and figure out what each one does.
So, unless I got something wrong, the answer is r22 = 254.
The register(in 8bit) goes from 0 to FF(dec r22) to FE(dec r22)
If r22 is 4 bit then E = 14
If r22 is 8 bit then FE = 254
if r22 is 16 bit then FFFE = 65534
and so on
A processor register is like a car mileometer When it reaches 99,999 miles it goes forwards to 00000
A register reaches F-F-F-F, 15-15-15-15 (not 9-9-9-9 because it's hex not decimal) and when we +1 it returns to 0-0-0-0