Skip to content
Solved Examples · Example 5

Q.Write a program to add two 8-bit number, and store it in R5. The numbers are 0F1H and 0DH

Karnataka PUCTextbookLongImportance★★★★★est
26% · 30/115 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

[!TLDR]

Load 0F1H0F1H into A, add 0DH0DH, copy A to R5. 241+13=254=0FEH241 + 13 = 254 = 0FEH, so R5 holds 0FEH0FEH.

This Karnataka 2nd PUC Electronics microcontroller example uses the 8051 ADDA,sourceADD A, source instruction, whose form is A=A+sourceA = A + source. The destination of an ADD is always the accumulator A, so both operands are brought through A before the result is moved to the required register R5.

8051 program:

MOV A, #0F1H   ; load F1H (241) into the accumulator
ADD A, #0DH    ; add 0DH (13); now A = A + 0DH
MOV R5, A      ; store the sum in register R5
NOP
END

Working out the addition:

  1111 0001    (0F1H = 241)
+ 0000 1101    (0DH  =  13)
-----------
  1111 1110    (0FEH = 254)
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.