MIC Unit 4
MIC Unit 4
Microprocessors (22415)
.model small
2. ALP to Subtract two 8-bit numbers.
.data
Ans:
Page 1 of 8
Program: Computer Engineering
Microprocessors (22415)
A db 02h Div bl
B db 02h Int 03h
Ends Ends
.code End
Mov ax,@data
Mov ds,ax
Mov al,a
Mov bl,b
Possible Corrections
Mul bl
changes
Int 03h
Multiplication Change Data: 02h to 1111h
Ends Two 16-Bit 02 to 2222h
End number Registers: Al to AX
Possible Corrections Bl to BX
changes
Multiplication Change Data: 02h to 1111h Singed
Use IDIV instruction
Two 16-Bit 02 to 2222h Numbers
number Registers: Al to AX For BCD After Division use AAD
Bl to BX number instruction
.data
4. ALP to divide two numbers.
Array db 02h,04h,06h,01h,05h
Ans:
Ends
.model small
.code
.data
A dw 2222h Start:Mov ax,@data
B db 02h Mov ds,ax
Ends
.code Mov cl,04h
Mov ax,@data Lea si,array
Mov ds,ax
Mov ax,a Mov al,[si]
Mov bl,b
Page 2 of 8
Program: Computer Engineering
Microprocessors (22415)
Ends DEC BL
Possible Corrections
6. Write an ALP for 8086 to sort the array changes
in ascending order. For 16-Bit Change Data: 8-bit with 16-
number bit
Ans:
For
.model small Descending Use JNC instruction
Number
.DATA
MOV CX, ONES ;move result in cx register. Mov di, offset block2
Mov [di],al
ENDS
Inc si
END ; end of program.
Inc di
Possible Corrections
changes Loop back
Find number
Change Instruction: JNC to JC Int 03h,
of Zeros
Find Positive Ends
Change Instruction: ROR to
number or
ROL End start
Negative
number
Block2 db 00h,00h,00h,00h,00h
Page 4 of 8
Program: Computer Engineering
Microprocessors (22415)
Int o3 h, Inc di
UP:MOV AL,[SI]
11.Write an ALP to find length of string MOV [DI],AL
Data Segment INC SI
STRG DB 'GOOD MORNING$' DEC DI
LEN DB ? LOOP UP
DATA ENDS MOV AH,4CH
CODE SEGMENT INT 21H
START: CODE ENDS
ASSUME CS: CODE, DS : DATA END START
MOV DX, DATA
MOV DS,DX
LEA SI, STRG
MOV CL,00H
MOV AL,'$'
NEXT: CMP AL,[SI]
JZ EXIT
ADD CL,01H
INC SI
Page 6 of 8
Program: Computer Engineering
Microprocessors (22415)