Вы находитесь на странице: 1из 15

Advanced Microprocessor & Microcontroller Lab

MEEC-519

Master of Technology
First Year (2013-14)

Department Of Electronics And Communication Engineering

AFSET DHAUJ, FARIDABAD,HARYANA

Prepared By:

Submitted To:

(Mr.Shuaib Alam) M.Tech (1st Semester-E&C) Roll No-MTE-13-47 Regn No13-AFED-

INDEX

S.No
To Run In Debug Mode

Programs

Date

Remarks

1. 2. 3. a. b. 4.

ALP to Convert from Hexadecimal to Decimal number. ALP to enter a word from keyboard between 0 to 9 and display ALP for block move of bytes using loop instructions. ALP for block move of bytes using repeat instructions. ALP to convert Binary to Gray code using Look Up table and XLAT instruction. To Run In MASM a.
b.

5.

ALP to display string without Macro. ALP to display string with Macro. ALP to display reverse of a string ALP for addition of two one digit numbers ALP to Convert from Hexadecimal to Decimal number.

6. 7. 8. 9. 10.

To Run In Debug Mode

Program No.:-1

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

Assembly Code:

Address
0100 0103 0106 0109 010C 010E 0110 0113 0116 0119 011A 011C 011E 0120 0123 0126 0128 012A 012C 012E

Mnemonics
MOV AX,0F MOV BX,0A MOV CX,00 MOV DX,00 DIV BX PUSH DX MOV DX,00 CMP AX,0A JGE 010C ADD AL,30 MOV DL,AL MOV AH,02 INT 21 POP DX ADD DL,30 MOV AH,02 INT 21 LOOP 0120 MOV AX,4C 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
0100 0102 0104 0106 0109 010B 010E 0110 0112 0114 0117 0119

Mnemonics
MOV AH,08 INT 21 MOV DL,AL CMP DL,30 JL 0100 CMP DL,39 JG 0100 MOV AH,02 INT 21 MOV AX,4C INT 21 INT 3

Result:
-GCS:0110A 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:010ACD 21 INT 21

Program No. :- 3 ( A )

Aim: Write an ALP for block move of bytes using Loop Instructions.

Assembly Code:
Address 0100 0101 0104 0107 010A 010B 010D Mnemonics CLD MOV SI, 0300 MOV DI, 0400 MOV CX, 0005 MOV SB LOOPNZ 010A HLT

; Clear destination flag ; Source address is SI ; Destination address is DI ; Count value loaded in CX ; 8 bit data copied from memory ( SI to DI ) ; loop unless count value CX = 0 ; HLT

Result:
-ECS : 300 1091 : 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
0100 0101 0104 0107 010A 010B 010C

Mnemonics
CLD MOV SI, 0300 MOV DI, 0400 MOV CX, 0005 REPNZ MOV SB HLT ; Clear destination flag ; Source address is SI ; Destination address is DI ; Count value loaded in CX ; Repeat data unless CX = 0 ; 8 bit data copied from memory ( SI to DI ) ; Stop

Result:
-ECS : 300 1091 : 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. :- 4

Aim: Write an ALP to convert Binary to Gray Code using Look Up table.

Assembly Code: Address


0101 0103 0106 0107 0108 010A

Mnemonics
MOV BX, 0300 MOV SI, 0150 LOAD SB XLAT MOV [ SI ], AL HLT ; Offset Address in BX ; Source Address in SI ; Load AL addressed by SI and SI = SI+1 ; Contents addressed by ( BX) + ( AL ) is moved to AL ; AL moved to memory addressed by SI ; Stop

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 0191: 0150 07. 04.

TO RUN IN MASM

Program No.:- 5 (A)


Aim: Write an ALP to disply string without Macro. 1. To Display Hello

Assembly Code:
_data segment Msg db helloS _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, WelcomeS Msg2 db 0ah,0dh, World S _data ends _code segment Assume cs:_code, ds:_data Start: Mov ax,_dat Mov ds,ax Mov ah, 09h Mov dx, offset msg1 Int 21 h 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 disply string with Macro. Assembly Code:


Print macro msg Mov ah,09h Mov dx ,offset msg Int 21h Endm Data segment Msg1 db 0ah ,odh,hello$ Msg2 db 0ah ,odh Welcome$ Data ends Code segment assume cs:de,ds:data start: mov ax,data mov ds ,ax print msg 1 print msg 2 mov ah,4ch mov al,00h int 21h code ends end start

Result :
HELLO WELCOME

Program No.:- 6

Aim: Write an ALP to disply reverse of a Sring.

Assembly code:
_Data segment Msg db enter a string , $ Sring 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 ,0ah Mov dx,offset string 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 lodsb push ax cmp al,0dh jnz a pop ax lea di ,result pop ax stosb cmpl al,24h jnz b mov ah,09h mov dx ,offset end 1 mov ah, 09h int dx21h mov dx,offset result int 21h mov ah,4ch mov al,00h int 21h _code ends end start

a:

b:

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:$ data 1 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 and ax,data1 mov data1,ax mov ah,09h mov dx, offset msg3 int 21h cmp data1,0ah ja b mov ax,data1 add al,30h mov dl,al mov ah,02h int 21h 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 end end start a:

Result: Enter 1st digit: Enter 2nd digit: Result after addition: 4 2 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 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 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

Вам также может понравиться