Professional Documents
Culture Documents
MP Lab
MP Lab
MP Lab
Assume cs:code,ds:data
Data segment
Org 50h
n1 dw 1234h
n2 dw 1234h
res dw ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov ax,n1
mov bx,n2
add ax, bx
MOV RES, AX
hlt
code ends
end start
MICROPROCESSOR LAB
Result:
Input Output
Memory data Memory Data
location
2000 34h location
2004 68h
2001 12h 2005 24h
2002 34h
2003 12h
Assume cs:code,ds:data
Data segment
Org 2000h
n1 db 34h
n2 db 23h
res db ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov al,n1
mov bl,n2
add al,bl
mov res,al
hlt
code ends
end start
Input Output
Memory data Memory Data
location
2000 34h location
2002 57h
2001 23h
Assume cs:code,ds:data
Data segment
Org 2000h
n1 dw 1234h
n2 dw 1234h
res dw ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov ax,n1
mov bx,n2
sub ax,bx
mov res,ax
hlt
code ends
end start
Assume cs:code,ds:data
Data segment
Org 2000h
n1 db 34h
n2 db 23h
res db ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov al,n1
mov bl,n2
sub al,bl
mov res,al
hlt
code ends
end start
Assume cs:code,ds:data
Data segment
Org 2000h
n1 dw 1111h
n2 dw 1111h
res dw ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov dx,0000h
mov ax,n1
mov bx,n2
mul bx
mov res,ax
mov [res+2],dx
hlt
code ends
end start
Assume cs:code,ds:data
Data segment
Org 2000h
n1 db 11h
n2 db 11h
res dw ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov al,n1
mov bl,n2
mul bl
mov res,ax
hlt
code ends
end start
Input Output
Memory data Memory Data
location
2000 11h location
2002 21h
2001 11h 2003 01h
Assume cs:code,ds:data
Data segment
Org 2000h
n1 dw 0042h
n2 dw 0007h
res dw ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov ax,n1
mov bx,n2
div bx
mov res,ax
hlt
code ends
end start
Assume cs:code,ds:data
Data segment
Org 2000h
n1 db 04h
n2 db 02h
res db ?
Data ends
Code segment
Start: mov ax,data
mov ds,ax
mov ax,0000h
mov al,n1
mov bl,n2
div bl
mov res,al
hlt
code ends
end start
Input Output
Memory data Memory Data
location
2000 04h location
2002 02h
2001 02h
assume cs:code,ds:data
data segment
Org 2000h
no1 dd 12344321h
no2 dd 42224444h
result dd ?
data ends
code segment
start: mov ax,data
mov ds,ax
xor ax,ax
mov ax,word ptr no1
add ax,word ptr no2
mov dx,ax
mov ax,word ptr[no1+2]
adc ax,word ptr[no2+2]
mov word ptr result,ax
mov word ptr [result+2],dx
hlt
code ends
end start
Input Output
Memory Data Memory Data
location
2000 21h location
2008 65h
2001 43h 2009 87h
2002 34h 200A 56h
2003 12h 200B 54h
2004 44h
2005 44h
2006 22h
2007 42h
assume cs:code,ds:data
data segment
Org 2000h
no1 dd 84326444h
no2 dd 42224444h
result dd ?
data ends
code segment
start: mov ax,data
mov ds,ax
xor ax,ax
mov ax,word ptr no1
sub ax,word ptr no2
mov dx,ax
mov ax,word ptr[no1+2]
sbb ax,word ptr[no2+2]
mov word ptr result,ax
mov word ptr [result+2],dx
hlt
code ends
end start
Input Output
Memory Data Memory Data
location
2000 44h location
2008 00h
2001 64h 2009 20h
2002 32h 200A 10h
2003 84h 200B 42h
2004 44h
2005 44h
2006 22h
2007 42h
assume cs:code,ds:data
data segment
org 2000h
no1 dd 11111111h
no2 dd 11111111h
result dd ?
data ends
code segment
start:mov ax,data
mov ds,ax
xor ax,ax
mov ax,word ptr no1
mul word ptr no2
mov word ptr result,ax
mov word ptr [result+2],dx
xor ax,ax
xor dx,dx
mov ax,word ptr no1
mul word ptr[no2+2]
add ax,word ptr[result+2]
mov word ptr[result+2],ax
mov word ptr[result+4],dx
xor ax,ax
xor dx,dx
mov ax,word ptr[no1+2]
mul word ptr no2
add ax,word ptr[result+2]
mov word ptr[result+2],ax
Input Output
Memory Data Memory Data
location
2000 11h location
2008 21H
2001 11h 2009 43H
2002 11h 200A 65H
2003 11h 200B 87H
2004 11h 200C 67H
2005 11h 200D 45H
2006 11h 200E 23H
assume cs:code,ds:data
data segment
org 2000h
list db 05h,12h,99h,68h,50h
result db 05h dup(0)
data ends
code segment
start: mov ax,data
mov ds,ax
mov cx,05h
mov si,offset list
mov di,offset result
back:mov al,[si]
mov [di],al
inc si
inc di
loop back
hlt
code ends
end start
assume cs:code,ds:data
data segment
org 2000h
n1 dw 0305h,0901h,0102h
n2 db ?
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,03
mov si,offset n1
mov di,offset n2
back:mov ax,[si]
rol ah,1
rol ah,1
rol ah,1
rol ah,1
add al,ah
mov [di],al
inc si
inc si
inc di
loop back
hlt
code ends
end start
Result:
Input Output
Memory Data Memory Data
location
2000 05h location
2006 35h
2001 03h 2007 91h
2002 01h 2008 12h
2003 09h
2004 02h
2005 01h
assume cs:code,ds:data
data segment
org 0000h
n1 db 05h
res db ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov ax,0000
mov cl,05
mov al,01h
mov bl,n1
back:mul bl
dec bl
loop back
mov res,al
hlt
code ends
end start
Input Output
Memory Data Memory Data
location
2000 05h location
2001 78h
assume cs:code,ds:data
data segment
org 2000h
n1 db 05h
res db ?
data ends
code segment
start: mov ax,data
mov ds,ax
mov al,01h
mov bl,01h
mov si,offset res
mov [si],al
inc si
mov [si],bl
mov cl,n1
l1:inc si
mov dl,bl
add bl,al
mov al,dl
mov [si],bl
loop l1
hlt
code ends
end start
Result:
Input Output
Memory 2000 2001 2002 2003 2004 2005 2006
location
Data 01h 01h 02h 03h 05h 08h 0Dh
ASSUME DS:DATA,CS:CODE
DATA SEGMENT
STRING1 DB 99H,12H,56H,45H,36H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CH,04H
UP2: MOV CL,04H
LEA SI,STRING1
UP1: MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JC DOWN
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START
RESULT
19. 8086 ASSEMBLY
PROGRAM TO PRINT ‘HELLO’
USING 09H
data segment
msg1 db 'hello$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov sp,0d00h
mov ah,09h
int 21h
mov ax,4c00h
int 21h
int 3
code ends
end start
RESULT:
20. 8086 ASSEMBLY
PROGRAM TO SEARCH AN
ELEMENT IN AN ARRAY
DATA SEGMENT
STRING1 DB 11H,22H,33H,44H,55H
MSG1 DB "FOUND$"
MSG2 DB "NOT FOUND$"
SE DB 33H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, SE
LEA SI, STRING1
MOV CX, 04H
UP:
MOV BL,[SI]
CMP AL, BL
JZ FO
INC SI
DEC CX
MICROPROCESSOR LAB
JNZ UP
PRINT MSG2
JMP END1
FO:
PRINT MSG1
END1:
INT 3
CODE ENDS
END START
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, STR1
LEA DI, STR2+4
MOV CX, 05H
BACK: CLD
MOV AL, [SI]
MOV [DI], AL
INC SI
DEC DI
DEC CX
JNZ BACK
INT 3
CODE ENDS
END START
RESULT:
22. 8086 ASSEMBLY
PROGRAM TO FIND LARGEST
NUMBER FROM GIVEN
NUMBERS
data segment
STRING1 DB 08h,14h,05h,0Fh,09h
res db ?
data ends
code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax
mov cx, 04h
mov res,bl
int 3
code ends
end start
RESULT:
RE23. 8086 ASSEMBLY
PROGRAM TO COUNT NUMBER
OF 0’S AND 1’S FROM A
NUMBER
DATA SEGMENT
NO DW 5648H
Z DW ?
O DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AX, NO
MOV BX, 00H
MOV CX, 10H
MOV DX, 00H
UP:
ROL AX,1
JC ONE
INC BX
JMP NXT
ONE:
INC DX
NXT:
DEC CX
JNZ UP
MICROPROCESSOR LAB
MOV Z, BX
MOV O, DX
INT 3
CODE ENDS
END START
UP1:MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JNC DOWN
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START
25. 8086 ASSEMBLY
PROGRAM TO CHECK IF
STRING IS PALINDROME OR
NOT
DATA SEGMENT
BLOCK1 DB 'MALAYALAM'
MSG1 DB "IT IS PALINDROME $"
MSG2 DB "IT IS NOT PALINDROME $"
PAL DB 00H
DATA ENDS
MOV AH,09H
LEA DX,MSG
INT 21H
INT 3H
ENDM
EXTRA SEGMENT
BLOCK2 DB 9 DUP(?)
EXTRA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
START: MOV AX,DATA
MOV DS,AX
MICROPROCESSOR LAB
MOV AX,EXTRA
MOV ES,AX
LEA SI,BLOCK1
LEA DI,BLOCK2+8
MOV CX,00009H
BACK: CLD
LODSB
STD
STOSB
LOOP BACK
LEA SI,BLOCK1
LEA DI,BLOCK2
MOV CX,0009H
CLD
REPZ CMPSB
JNZ SKIP
PRINT MSG1
SKIP: PRINT MSG2
CODE ENDS
END START