Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 17

Advanced Microprocessor & Microcontroller Lab

MEEC - 519

Masters Of Technology

First Year

Department
Of
Electronics And Communication Engineering

Vaish College Of Engineering


ROHTAK

Prepared By: Submitted To:


Saourbh Singh Mehra Mr. Rajeev Sharma
1st Semester HOD - ECE
Roll No. – 16
M. Tech - ECE
INDEX

S. No. Programs Date Remarks

To Run In Debug Mode

1. ALP to convert from Hexadecimal to Decimal number.

2. ALP to enter a word from keyboard B/W 0 to 9 and


display.
3. a. ALP for block move of bytes using Loop Instructions.

b. ALP for block move of bytes using Repeat Instructions.

4. ALP to convert Binary to Gray code using Look Up


table and XLAT instruction.

To Run In MASM

5. a. ALP to display string without Macro.

b. ALP to display string with Macro.

6. ALP to display Reverse of a String.

7. ALP for addition of two one digit numbers.

8. ALP to convert Hexadecimal number to Decimal


number.
9.

10.
To Run

In

Debug Mode
Program No. :- 1

Aim: Write an ALP to convert from Hexadecimal to Decimal number.

Assembly Code:

Address Mnemonic

0100 MOV AX,0F


0103 MOV BX,0A
0106 MOV CX,00
0109 MOV DX,00
010C DIV BX
010E PUSH DX
0110 MOV DX,00
0113 CMP AX,0A
0116 JGE 010C
0119 ADD AL,30
011A MOV DL,AL
011C MOV AH,02
011E INT 21
0120 POP DX
0123 ADD DL,30
0126 MOV AH,02
0128 INT 21
012A LOOP 0120
012C MOV AX,4C
012E INT 21

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

0100 MOV AH,08


0102 INT 21
0104 MOV DL,AL
0106 CMP DL,30
0109 JL 0100
010B CMP DL,39
010E JG 0100
0110 MOV AH,02
0112 INT 21
0114 MOV AX,4C
0117 INT 21
0119 INT 3

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

0100 CLD ; clear direction flag


0101 MOV SI, 0300 ; source address is SI
0104 MOV DI, 0400 ; destination address is DI
0107 MOV CX, 0005 ; count value loaded in CX
010 AMOV SB ; 8 bit data copied from memory ( SI to DI )
010B LOOPNZ 010A ; loop unless count value CX = 0
010D HLT ; stop
010E

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

0100 CLD ; clear direction flag


0101 MOV SI, 0300 ; source address is SI
0104 MOV DI, 0400 ; destination address is DI
0107 MOV CX, 0005 ; count value loaded in CX
010A REPNZ ; Repeat data unless CX = 0
010B MOV SB ; 8 bit data copied from memory ( SI to DI )
010C HLT ; stop
010D

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 )

Aim: Write an ALP to display string without Macro.

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 )

Aim: Write an ALP to display string without Macro.

2. To Display Welcome World

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 )

Aim: Write an ALP to display string with Macro.

Assembly Code:

print macro msg


mov ah,09h
mov dx,offset msg
int 21h
endm
data segment
msg1 db 0ah,0dh,'hello$'
msg2 db 0ah,0dh,'welcome$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
print msg1
print msg2
mov ah,4ch
mov al,00h
int 21h
code ends
end start

Result :

hello
welcome
Program No. :- 6

Aim: Write an ALP to display Reverse String.

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 :

enter a string, 1234567


7654321
Program No. :- 7

Aim: Write an ALP for addition of two one digit numbers.

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 :

Enter 1st digit: 4


Enter 2nd digit: 2
Result after addition: 6
Program No. :- 8

Aim: Write an ALP to convert Hexadecimal to Decimal number.

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

You might also like