Professional Documents
Culture Documents
Advanced Microprocessor & Microcontroller Lab: Masters of Technology
Advanced Microprocessor & Microcontroller Lab: Masters of Technology
MEEC - 519
Masters Of Technology
First Year
Department
Of
Electronics And Communication Engineering
To Run In MASM
10.
To Run
In
Debug Mode
Program No. :- 1
Assembly Code:
Address Mnemonic
Result :
15
Program Terminated Normally
-GCS:0130
AX=000F BX=000A CX=0000 DX=0000 SP=FEEE BP=0000 SI=0151 DI=0000
DS=1091 ES=1091 SS=1091 CS=1091 IP=010A NV UP EI PL NZ NA PO NC
1091:010A F4 HLT
Program No. :- 2
Aim: Write an ALP to enter a word from keyboard between 0 to 9 and display.
Assembly Code:
Address Mnemonic
Result :
-GCS:010A
AX=0800 BX=0000 CX=0066 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0B13 ES=0B13 SS=0B13 CS=0B13 IP=0102 NV UP EI PL NZ NA PO NC
1091:010A CD 21 INT 21
8
Program No. :- 3 ( A )
Aim: Write an ALP for block move of bytes using Loop Instructions.
Assembly Code:
Address Mnemonics
Result :
- ECS : 300
0191 : 0300 00. 11. 22. 33. 44. 55. 66. 77.
-GCS:010D
AX=0000 BX=0300 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0305 DI=0405
DS=1091 ES=1091 SS=1091 CS=1091 IP=010A NV UP EI PL NZ NA PO NC
1091:010A F4 HLT
- ECS : 400
0191 : 0400 00. 11. 22. 33. 44. 55. 66. 77.
Program No. :- 3 ( B )
Aim: Write an ALP for block move of bytes using Repeat Instructions.
Assembly Code:
Address Mnemonics
Result :
- ECS : 0300
0191 : 0300 00. 11. 22. 33. 44. 55. 66. 77.
-GCS:010D
AX=0000 BX=0300 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0305 DI=0405
DS=1091 ES=1091 SS=1091 CS=1091 IP=010A NV UP EI PL NZ NA PO NC
1091:010A F4 HLT
- ECS : 0400
0191 : 0400 00. 11. 22. 33. 44. 55. 66. 77.
Program No. :- 4
Aim: Write an ALP to convert Binary to Gray code using Look Up table.
Assembly Code:
Address Mnemonics
0101 MOV BX, 0300 ; offset address in BX
0103 MOV SI, 0150 ; source address in SI
0106 LODSB ; load Al addressed by SI and SI = SI + 1
0107 XLAT ; contents addressed by (BX) + (AL) is moved to AL
0108 MOV [ SI ], AL ;( AL ) moved to memory addressed by SI
010A HLT ; stop
010B
Result :
- ECS:0300
1091: 0300 D3.00 A2.01 26.03 D7.02 F7.06 E2.07 B9.05 77.04
1091: 0308 A6.0C C8.0D F3.0F E9.0E 66.0A 33.0B BA.09 AA.08
- ECS:0150
1091: 0150 07
-GCS:010A
AX=0004 BX=0300 CX=0000 DX=0000 SP=FEEE BP=0000 SI=0151 DI=0000
DS=1091 ES=1091 SS=1091 CS=1091 IP=010A NV UP EI PL NZ NA PO NC
1091:010A F4 HLT
- ECS:0150
1091: 0150 07. 04.
To Run
In
MASM
Program No. :- 5 ( A )
1. To Display Hello
Assembly Code:
_data segment
msg db 'hello$'
_data ends
_code segment
assume cs:_code,ds:_data
start : mov ax,_data
mov ds, ax
mov ah,09h
mov dx,offset msg
int 21h
mov ah,4ch
mov al,00h
int 21h
_code ends
end start
Result :
Hello
Program No. :- 5 ( A )
Assembly Code:
_data segment
msg1 db 0ah,0dh,'Welcome $'
msg2 db 0ah,0dh,'World $'
_data ends
_code segment
assume cs:_code,ds:_data
start:
mov ax,_data
mov ds,ax
mov ah,09h
mov dx,offset msg1
int 21h
mov ah,09h
mov dx,offset msg2
int 21h
mov ah,4ch
mov al,00h
int 21h
_code ends
end start
Result :
Welcome
World
Program No. :- 5 ( B )
Assembly Code:
Result :
hello
welcome
Program No. :- 6
Assembly Code:
_data segment
msg db 'enter a string,$'
string db 30 dup ('$')
result db 30 dup ('$')
end1 db 0ah,0dh,30 dup('$')
_data ends
_stack segment
dw 100 dup(0)
_stack ends
_code segment
assume cs:_code,ds:_data,ss:_stack
start:
mov ax,_data
mov ds,ax
mov es,ax
cld
mov ah,09h
mov dx,offset msg
int 21h
mov ah,0ah
mov dx,offset string
int 21h
mov ah,00h
mov al,24h
push ax
lea dx,string
add si,02h
a: lodsb
push ax
cmp al,0dh
jnz a
pop ax
lea di,result
b: pop ax
stosb
cmp al,24h
jnz b
mov ah,09h
mov dx,offset end1
mov ah,09h
int 21h
mov dx,offset result
int 21h
Program No. :- 6 ( Continued )
mov ah,4ch
mov al,00h
int 21h
_code ends
end start
Result :
Assembly Code:
_data segment
msg1 db 0ah,0dh,'Enter 1st digit:$'
msg2 db 0ah,0dh,'Enter 2nd digit:$'
msg3 db 0ah,0dh,'Result after addition:$'
data1 dw 100 dup(0)
_data ends
_code segment
assume ds:_data,cs:_code
start:
mov ax,_data
mov ds,ax
mov ah,09h
mov dx,offset msg1
int 21h
mov ah,01h
int 21h
and ax,0fh
mov data1,ax
mov ah,09h
mov dx,offset msg2
int 21h
mov ah,01h
int 21h
and ax,0fh
add ax,data1
mov data1,ax
mov ah,09h
mov dx,offset msg3
int 21h
a: cmp data1,0ah
ja b
mov ax,data1
add al,30h
mov dl,al
mov ah,02h
int 21h
Program No. :- 7 ( Continued )
mov ah,4ch
mov al,00h
int 21h
b: sub data1,0ah
mov ax,data1
push ax
mov dl,01h
add dl,30h
mov ah,02h
int 21h
pop ax
mov data1,ax
jmp a
_code ends
end start
Result :
Assembly Code:
stack segment
db 100 dup(0)
stack ends
code segment
assume cs:code,ss:stack
start :
mov ax,1111h
mov bx,000ah
mov cx,00h
mov dx,00h
a: div bx
push dx
inc cx
mov dx,00h
cmp ax,0ah
jge a
mov dl,al
add dl,30h
mov ah,02h
int 21h
b: pop dx
add dl,30h
mov ah,02h
int 21h
loop b
mov ah,4ch
mov al,00h
int 21h
code ends
end start
Result :
4369