Sie sind auf Seite 1von 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: Saourbh Singh Mehra 1st Semester Roll No. 16 M. Tech - ECE

Submitted To: Mr. Rajeev Sharma HOD - ECE

INDEX

S. No.

Programs To Run In Debug Mode

Date

Remarks

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

ALP to convert from Hexadecimal to Decimal number. ALP to enter a word from keyboard B/W 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

5.

a.

ALP to display string without Macro.

b. ALP to display string with Macro. 6. 7. 8. 9. 10. ALP to display Reverse of a String. ALP for addition of two one digit numbers. ALP to convert Hexadecimal number to Decimal number.

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

Mnemonic 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

Mnemonic 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: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

Program No. :- 3 ( A ) Aim: Write an ALP for block move of bytes using Loop Instructions.
Assembly Code:

Address 0100 0101 0104 0107 010 010B 010D 010E

Mnemonics CLD MOV SI, 0300 MOV DI, 0400 MOV CX, 0005 AMOV SB LOOPNZ 010A HLT ; clear direction 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 ; stop

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 0100 0101 0104 0107 010A 010B 010C 010D

Mnemonics CLD MOV SI, 0300 MOV DI, 0400 MOV CX, 0005 REPNZ MOV SB HLT ; clear direction 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 : 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 0101 0103 0106 0107 0108 010A 010B

Mnemonics MOV BX, 0300 MOV SI, 0150 LODSB 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 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

Das könnte Ihnen auch gefallen