MP Tutorial
MP Tutorial
Microcontrollers(15CS44)
1. Assume that DS = 5000, SS = 4000, BX = 2100,
SI = 1486, DI = 8500, BP=7814, and AX =2512
All values are in hex. Show the exact physical
memory location where AX is stored in each of
the following.
(a) MOV[BX],AX (b) MOV[SI],AX
(c)MOV [BX][SI],AX (d) MOV[DI],AX
(e) MOV[BP],AX
a)50000+2100=52100
b)50000+1486=51486
c)50000+(2100+1486)=53586
d)50000+8500=58500
e)40000+7814=47814
2.Identify the addressing modes in the
following cases
a)MOV AX,BX
b)MOV BX,BLOCK
{MOV BX, OFFSET BLOCK}
c)MOV AX,[BX]
a)REGISTER
b)DIRECT
c)REGISTER INDIRECT
3.Write an ALP to count number of
1’s in a given 8-bit data
.MODEL SMALL
.STACK 60H
.DATA
D1 DB 97H
COUNT DB ?
.CODE
MOV AX,@DATA
MOV DS,AX
SUB BL,BL
MOV DL,8
MOV AL,D1
AGAIN:ROL AL,1
JNC NXT
INC BL
NXT: DEC DL
JNZ AGAIN
MOV COUNT,BL
MOV AH,4CH
INT 21H
4.Write an ALP to find the smallest in a
given array of 5 numbers(byte data).
• Data
Array db …..
Lowest db ?
.code
Start:MOV AX,@data
MOV DS,AX
MOV CX,5 ;set up loop counter
MOV BX,OFFSET array ;BX points to arraydata
MOV AL,0FFH ;AL holds lowest number found
so far
AGAIN: CMP AL,[BX] ;compare next num to lowest
JB NEXT ;jump if AL still lowest
MOV AL,[BX] ;else AL holds new lowest
NEXT: INC BX ;point to next num
LOOP AGAIN ;continue search
MOV LOWEST,AL ;store lowest num
MOV AH,4CH
INT 21H ;go back to dos
5.Write an ALP to bubble sort the following data
(23h, 11h, 85h, 0fah,06h)
.model small
.stack 20
.data
list db 23h, 11h, 85h, 0fah,06h
count equ 05h
.code
start: mov ax,@data
mov ds,ax
mov dx,count-1
again0: mov cx,dx
mov si,offset list