MICROPROCESSOR PROGRAMMING (314321)
---------------×------------------××--------------------×---------------
---------------×------------------××--------------------×---------------
Unit 1 :- 8086 16-bit Microprocessor
Unit 2 :- The Art of assembly Language Programming
Unit 3 :- Instruction Set of 8086 Microprocessor
Unit 4 :- 8086 Assembly Language Programming
Unit 5 :- Procedure and Macro in Assembly Language Program
|
include
'emu8086.inc' .model small .data num db 12h .code mov ax,@data mov ds,ax mov al,num mov ah,13h add ah,al
mov ah,4CH INT 21h
ENDS |
Write an ALP to perform addition of two 16 bit numbers.
|
include
'emu8086.inc' .model small .data num1 dw 6753h num2 dw 2020h sum dw ? .code mov ax,@data mov ds,ax mov ax,num1 mov bx,num2 add ax,bx mov sum,ax mov ah,4ch int 21h ends |
Write an ALP to perform subtraction of two 8 bit
numbers.
|
include
'emu8086.inc' .model small .data a db 52h b db 12h c db ? .code mov ax,@data mov ds,ax mov al,a mov bl,b sub al,bl mov c,al mov ah,4ch int 21h ends |
Write an ALP to perform subtraction of two 16 bit
numbers.
|
include
'emu8086.inc' .model small .data a dw 0081h b dw 0011h c dw ? .code mov ax,@data mov ds,ax mov ax,a mov bx,b sub ax,bx mov c,ax mov ah,4ch int 21h ends |
Write an ALP to perform multiplication of two 8 bit
numbers.
|
include 'emu8086.inc' .model small .data a db 02h b db 03h c dw ? .code mov
ax,@data mov ds,ax mov al,a mov bl,b mul bl mov c,ax mov ah,4ch int 21h ends |
1. 1. ALP to perform addition and subtraction
of two given numbers.
|
include
'emu8086.inc' .model small .data a db 01h b db 02h c db 03h d db 04h
e db ? f db ? .code mov ax,@data mov ds,ax mov al,a mov bl,b add al,bl mov e,al mov al,d mov bl,c sub al,bl mov f,al mov ah,4ch int 21h ends |
2. 2. ALP to find largest and smallest number
from array of numbers.
|
include 'emu8086' .model small .stack 100h .data ARRAY DB 15H,45H,08H,56H,78H LARGEST DB 00H small db 00h .code MOV DX,DATA MOV DS,DX MOV CX,04H MOV SI,OFFSET ARRAY MOV AL,[SI] smallest: UP1: INC SI CMP AL,[SI] JC NEXT1 MOV AL,[SI] NEXT1: DEC CX JNZ UP1 MOV SMALL,AL MOV CX,04H MOV DI,OFFSET ARRAY MOV AL,[DI] Large:
UP: INC DI CMP AL,[DI] JNC NEXT MOV AL,[DI] NEXT: DEC CX JNZ UP MOV LARGEST,AL INT 21H ENDS |
3.
3. ALP to find the length of string and concatenate two strings.
|
include
'emu8086.inc' .model small .data msg db 'computer$' count db ? str1 db 'hello$' str2 db 'world$' .code mov ax,@data mov ds,ax
length: mov si,offset msg next1: mov al,[si] cmp al,'$' je exit2 inc count inc si jmp next1 exit2: mov dh,count concat: mov si,offset str1 next: mov al,[si] cmp al,'$' je exit: inc si jmp next exit: mov di,offset str2 up: mov al,[di] cmp al,'$' je exit1 mov [si],al inc si inc di jmp up exit1: mov al,'$' mov [si],al mov ah,4ch int 21h ends |
4. 4. ALP to check a given number is odd or
even
|
; Program to find
number is odd or even include
'emu8086.inc' .MODEL SMALL .STACK 100H .DATA MSG1 DB "ODD$" MSG2 DB "EVEN$" NUM DB ? .CODE MOV AX , @DATA MOV DS , AX MOV AH , 1h INT 21H MOV NUM , AL ROR AL , 1 JC EL LEA DX , MSG2 JMP EXIT EL: LEA DX , MSG1 EXIT: MOV AH , 09H INT 21H MOV AH , 4CH INT 21H ENDS |
5. 5. ALP for multiplication of two signed and
unsigned numbers.
|
include 'emu8086.inc' .model small .data a db 02h b db 04h c db -03h d db -05h sign dw ? unsign dw ? .code mov ax,@data mov ds,ax mov al,a mov bl,b mul bl mov unsign,ax mov al,d mov bl,c imul bl mov sign,ax mov ah,4ch int 21h end ends
|
6. 6. ALP to perform division of two unsigned
and signed numbers.
|
include
'emu8086.inc' .model small .data unsign db ? sign db ? .code mov ax,@data mov ds,ax mov ax,203 mov bl,4 div bl mov unsign,al mov ax,-203 mov bl,4 idiv bl mov sign,al mov ah,4ch int 21h end ends |
7. 7. ALP to find sum of series.
|
include
'emu8086.inc' .model small .data a db 1,2,3,4,5,6,7,8,9,10 sum db ? .code mov ax,data mov ds,ax mov cl,10 lea bx,a mov ah,00 mov al,00 l1: add al,byte ptr[bx] inc bx dec cl cmp cl,00 jnz l1 mov sum,al mov ah,4ch int 21h end ends
|
8. 8. ALP for string operations such as string
reverse and string copy.
|
include 'emu8086.inc' .model small .data STRING DB
"STUPID$" ARR DB 10
DUP('$')
destination DB 20 DUP(0) .code MOV
DX,@DATA MOV DS,DX copystring: LEA
SI,STRING LEA
DI,destination mov cx,7 mov al,0 copyloop: mov
al,[si] mov
[di],al inc si inc di dec cx cmp
cx,0 jnz
copyloop mov
ah,09h lea
dx,destination reversestring: MOV CL,00H LEA
SI,STRING MOV BL,'$' AGAIN: MOV AL,[SI] CMP
AL,BL JZ
REVERSE INC CL INC SI JMP
AGAIN REVERSE: LEA DI,ARR DEC
SI UP: MOV AL,[SI] MOV
[DI],AL INC DI DEC SI LOOP UP MOV
[DI],'$' LEA DX,ARR MOV AH,09H INT 21H MOV AH,4CH INT 21H end ends
|
9. 9. ALP to check a given number is odd or
even
|
include
'emu8086.inc' .MODEL SMALL .STACK 100H .DATA MSG1 DB "ODD$" MSG2 DB "EVEN$" NUM DB ? .CODE MOV AX , @DATA MOV DS , AX MOV AH , 1h INT 21H MOV NUM , AL ROR AL , 1 JC EL LEA DX , MSG2 JMP EXIT EL: LEA DX , MSG1 EXIT: MOV AH , 09H INT 21H MOV AH , 4CH INT 21H ENDS |
10 10. ALP
to perform arithmetic operations on given numbers using procedure Z=(A+B)*(C+D)
|
include 'emu8086.inc' .MODEL SMALL .STACK 100H .DATA A DB 2 B DB 2 C DB 4 D DB 4 Z DW ? RES DB ? .CODE MOV AX ,
@DATA MOV DS , AX MOV AL , A MOV AH , B CALL
ADD_BYTE MOV RES ,
AL ; STORING RESULT OF A+B MOV AL , C MOV AH , D CALL
ADD_BYTE MOV BL , RES MUL BL AAM ; ASCII ADJUST AFTER MULTIPLICATION MOV Z , AX
; PRINTING
RESULT MOV BH , AL MOV DL ,
AH ADD DL , 48 MOV AH , 02 INT 21H MOV DH , 00 MOV DL , BH ADD DL , 48 MOV AH , 02 INT 21H MOV AH ,
4CH ; Service Routine for exit INT 21H ; Creating
Procedure ADD_BYTE
PROC ADD AL ,
AH RET ENDP END |
11 11. ALP to perform arithmetic operations on given numbers using macro for equation P=(X2+Y2)
|
.MODEL SMALL PROG MACRO a,b MOV al,a MUL al MOV bl,al MOV al,b MUL al ADD al,bl ENDM .DATA x DB 02H y DB 03H p DB ? .CODE MOV
ax,data MOV ds,ax PROG x, y MOV p,al MOV ah,4Ch
int 21H END
|
2 Comments
MIC Practical Programs and Notes
ReplyDeleteIf you need more notes then comment on this page
ReplyDeleteHi, Viewers Do not Enter Spam Messages in comments