0% found this document useful (0 votes)
15 views18 pages

Lecture 5 2

The document provides an introduction to embedded systems including course details and covers various arithmetic, logical, shift and rotate instructions. Examples are given to demonstrate how to add, subtract, multiply, divide and perform logical, shift and rotate operations on 16-bit numbers using microcontroller registers. Serializing data and the SWAP instruction are also discussed.

Uploaded by

Jawad shah Sayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views18 pages

Lecture 5 2

The document provides an introduction to embedded systems including course details and covers various arithmetic, logical, shift and rotate instructions. Examples are given to demonstrate how to add, subtract, multiply, divide and perform logical, shift and rotate operations on 16-bit numbers using microcontroller registers. Serializing data and the SWAP instruction are also discussed.

Uploaded by

Jawad shah Sayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Introduction to

Embedded System

Semester : 5th
Course Code : ES314
TP Sr No: 16, CLO:2, PLO 2, C4
Fair Use Notice

The material used in this presentation i.e., pictures/graphs/text, etc. is solely


intended for educational/teaching purpose, offered free of cost to the students for
use under special circumstances of Online Education due to COVID-19 Lockdown
situation and may include copyrighted material - the use of which may not have
been specifically authorized by Copyright Owners. It’s application constitutes Fair
Use of any such copyrighted material as provided in globally accepted law of many
countries. The contents of presentations are intended only for the attendees of the
class being conducted by the presenter.
Arithmetic Instructions
Write a program to add two 16 bit numbers. The numbers are 3CE7H
and 3B8DH. Assume that R1=8D, R2=3B, R3=E7 and r4=3C. Place the
sum in R3 and R4; R3 should have a lower byte.
Solution:
;R1=8D
;R2=3B
;R3=E7
;R4=3C
ADD R3,R1
ADC R4,R2
Subtraction of unsigned numbers
Steps in subtraction
Example-5-6
Multiplication
Division of unsigned numbers
Example 5-1
Logical Instructions

◉ EX-OR ( Excusive OR)


◉ COM (COMPLEMENT)
◉ NEG(NEGATE)
◉ CP (COMPARE)
e.g CP Rd,Rr
CPI Rd,k
Example-5-25
Rotate instructions (through carry)

◉ ROR Rd

◉ROL Rd
Serializing data
Shift Instructions
◉LSL Rd ( Logical shift Left)
CLC
LDI R20,0X26; 38
LSL R20; 76 C=0
LSL R20; 152 C=0
LSL R20; 48 C=1
Can LSL be used as multiplication by 2
instruction? If yes then under what condition
Shift Instructions
◉ LSR Rd ( Logical shift Right)

LDI R20,0X26; 38
LSR R20; 19 C=0
LSR R20;9 C=1
LSR R20; 4 C=1
Can LSR be used as division by 2 instruction for
unsigned numbers? If yes then what carry flag will
hold?
Shift Instructions
◉ ASR Rd ( Arithmetic shift Right)
◉ Divide sign numbers by 2
◉ Bits are shifted from left to right
◉ MSB is held constant but copied to D6
SWAP instruction

◉ SWAP Rd; swap nibbles


Thanks!
Any questions ?

You might also like