Beruflich Dokumente
Kultur Dokumente
MEEC - 519
Masters Of Technology
First Year
Prepared By: Saourbh Singh Mehra 1st Semester Roll No. 16 M. Tech - ECE
INDEX
S. No.
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.
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.
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:
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
Program No. :- 3 ( B ) Aim: Write an ALP for block move of bytes using Repeat Instructions.
Assembly Code:
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
-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
Program No. :- 4 Aim: Write an ALP to convert Binary to Gray code using Look Up table.
Assembly Code:
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
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
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
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
Result : 4369