Sie sind auf Seite 1von 25

1.Arithmetic Operations a) Multi Word addition ASM code: . Model small . Stack . Data .

Code Mov AX, 1234h Mov BX, 9874h ADD AX, BX Mov AX, 5678h Mov BX, 1234h ADC AX, BX Mov DX, AX INT 21h END INPUT 1: INPUT 2: OUTPUT: RESULT: Thus the program for addition of two double words has been executed successfully by using TASM & result is verified.

b) Multi Word subtraction ASM code: . Model small . Stack . Data . Code Mov AX, 0111h Mov BX, 1000h SUB AX, BX MOV CX, AX Mov AX, 5678h Mov BX, 1234h SUBB AX, BX Mov DX, AX INT 21h END INPUT 1: 56780111h INPUT 2: 12341000h OUTPUT: 4443F111h CX: F111 LSW of the result DX: 68AD MSW of the result RESULT: Thus the program for subtraction of two double words has been executed successfully by using TASM & result is verified.

c) Multiplication of two 16-bit numbers ASM code: . Model small . Stack . Data . Code Mov AX, 1234h Mov BX, 1234h MUL BX INT 21h END INPUT 1: 1234h INPUT 2: 1234h OUTPUT: 014B5A90h CX: 5A90 LSW of the result DX: 014B MSW of the result RESULT: Thus the program for multiplication of two 16-bit program executed successfully by using TASM & result is verified.

d) Multi Word Division (32-bit/16-bit) ASM code: . Model small . Stack . Data . Code Mov AX, 2786h Mov BX, 2334h Mov CX, 3552h DIV CX INT 21h END INPUT 1: 23342786h INPUT 2: 3552h OUTPUT: 303EA904h AX: A904 LSW of the result DX: 303E MSW of the result RESULT: Thus the multi word division of programs executed successfully by using TASM & result is verified.

2. Signed Operation a. Multiplication of two signed numbers ASM code: . Model small . Stack . Data . Code Mov AX, 8000h Mov BX, 2000h IMUL BX INT 21H END INPUT 1:8000h INPUT 2: 2000h OUTPUT: AX 0000h DX F000h RESULT: Thus the program for multiplication of two signed numbers has been executed successfully by using TASM & result is verified.

b. Division of two signed numbers ASM code: . Model small . Stack . Data . Code Mov AX, -0002h Mov BL, 80h IDIV BL INT 21H END INPUT 1:AX0002h BX 80h OUTPUT: AX 00C0h AlC0h Ah 00h RESULT: Thus the program for division of two signed numbers has been executed successfully by using TASM & result is verified.

4. ASCII Arithmetic Operation a) AAA ASM code: . Model small . Stack . Data . Code Mov AL, 35h Mov BL, 37h ADD AL, BL AAA Int 21h End INPUT 1: 35h INPUT 2: 37h OUTPUT: AX0102h RESULT: Thus the program for AAA has been executed successfully by using TASM & result is verified.

b) AAS ASM code: . Model small . Stack . Data . Code Mov AL, 37h Mov BL, 35h SUB AL, BL AAS Int 21h End INPUT 1: 37h INPUT 2: 35h OUTPUT: AX0002h RESULT: Thus the program for AAS has been executed successfully by using TASM & result is verified.

c) AAM ASM code: . Model small . Stack . Data . Code Mov AL, 06h Mov BL, 09h MUL BL AAM Int 21h End INPUT 1: 09h INPUT 2: 06h OUTPUT: AX0504h(un packed BCD) RESULT: Thus the program for AAM has been executed successfully by using TASM & result is verified.

d) AAD ASM code: . Model small . Stack . Data . Code Mov AX, 1264h Mov BL, 04h DIV BL AAD Int 21h End INPUT 1: 1264h INPUT 2: 04h OUTPUT: AX0499 RESULT: Thus the program for AAD has been executed successfully by using TASM & result is verified.

Logic Operation Shift Right


ASM code: . Model small . Stack . Data . Code Mov al, 46h Mov cl, 04h Shr al, cl Int 21h End Input: Al46 Cl04 Output: 04h RESULT: Thus the program for Shift right operation has been executed successfully by using TASM & result is verified.

Shift Left
ASM code: . Model small . Stack . Data . Code Mov al, 46h Mov cl, 04h Shl al, cl Int 21h End Input: Al46 Cl04 Output: 60h RESULT: Thus the program for Shift left operation has been executed successfully by using TASM & result is verified.

Rotate Right Without Carry


ASM code: . Model small . Stack . Data . Code Mov al, 68h Mov cl, 04h Ror al, cl Int 21h End Input: Al68h Cl04h Output: 86h RESULT: Thus the program for rotate right without carry has been executed successfully by using TASM & result is verified.

Rotate Left Without carry


ASM code: . Model small . Stack . Data . Code Mov al, 60h Mov cl, 04h Rol al, cl Int 21h End Input: Al60h Cl04h Output: 06h RESULT: Thus the program for rotate left without carry has been executed successfully by using TASM & result is verified.

Rotate Right With Carry


ASM code: . Model small . Stack . Data . Code Mov al, 56h Mov cl, 03h Rcr al, cl Int 21h End Input: Al56h Cl03h Output: Al= Bl RESULT: Thus the program for rotate right with carry has been executed successfully by using TASM & result is verified.

Rotate Left With Carry


ASM code: . Model small . Stack . Data . Code Mov al, 56h Mov cl, 03h Rcl al, cl Int 21h End Input: Al56h Cl03h Output: Al=8Ah RESULT: Thus the program for rotate left with carry has been executed successfully by using TASM & result is verified.

Packed BCD to UNPACKED BCD Conversion ASM Code: . Model small . Stack . Data . Code Mov BL, 57h Mov BH, 04h Mov AL, BL Mov CL, BH SHL AL, CL Mov CL, BH ROR AL, CL Mov DL, AL Mov AL, BL Mov CL, BH SHR AL, CL Mov DH, AL INT 21H END Input: BL (Packed BCD) = Output: DX (Unpacked BCD) = RESULT: Thus the program for conversion of packed to unpacked has been executed successfully by using TASM & result is verified.

UNPACKED BCD to Packed BCD Conversion ASM Code: . Model small . Stack . Data . Code Mov ax, 0207h Mov al, 04h Ror al, cl Shr ax, cl INT 21H END Input: AX0207(Unpacked BCD) Output: AX0027(packed BCD) RESULT: Thus the program for conversion of unpacked to packed has been executed successfully by using TASM & result is verified.

ASCII to BCD ASM Code: . Model small . Stack . Data . Code Mov ax, 3638h Mov bx, 3030h Mov cl, 04h Shl al, cl Ror ax, cl INT 21H END Input: AX3638h(Unpacked BCD) Output: AX0068(packed BCD) RESULT: Thus the program for conversion of ASCII to BCD value has been executed successfully by using TASM & result is verified.

BCD to ASCII ASM Code: . Model small . Stack . Data . Code Mov AL, 57h Mov CL, 04h SHL AL, CL ROR AL. 04H XOR AL, 30H MOV BL, AL MOV AL, 57H MOV CL, 04H SHR AL, CL XOR AL, 30H MOV BH. AL INT 21H END Input: AL (BCD) Output: BX (ASCII) RESULT: Thus the program for conversion of BCD TO ASCII value has been executed successfully by using TASM & result is

STRING OPERATIONS Strings Comparison: ASM CODE: . Model small . Stack . Data Strg1 db lab,$ Strg2 db lab, $ Res db strg are equal,$ Res1 db strg are not equal,$ Count equ 03h . Code Mov ax, @data Mov ds, ax Mov es, ax Mov cl,count Lea si, strg1 Lea di, strg2 Cld Rep cmpsb Jnz loop1 Mov ah, 09h Lea dx, res Int 21h Jmp a1 Loop1: mov ah, 09h Lea dx, res1 Int 21h A1: mov ah, 4ch Int 21h End Input: Strg1 Strg2 Output: Result: Thus the program of string comparison is executed successfully and the result is verified.

Data Transfer from one segment to another segment ASM CODE: . Model small . Stack . Data String dbcomputer String1 db 8 dup (?) . Code Mov ax, @data Mov ds, ax Mov es, ax Mov cl, 08h Mov si, offset string Mov di, offset string1 Cld Rep movsb Int 21h End Input: Output: Result: Thus the program to move a block of string from one memory location to another memory location is executed successfully.

Sorting a string in an ascending order ASM code: . Model small . Stack . Data List1 db 53h, 10h, 24h, 12h Count Equ, 04h . Code Mov AX, @data Mov DS, AX Mov Dx, 03h Again2: Mov CX, DX Mov SI, offset List1 Again1: Mov AL, [SI] CMP AL, [SI+1] JL PR1 XCHG [SI+1], AL XCHG [SI], AL PR1: ADD SI, 01H Loop Again1 DEC DX JNZ Again2 Mov AH, 4ch Int 21h End Input: Enter string: 53h, 10h, 24h, 12h Output: Sorted String: 10h, 12h, 24h, 53h Result: Thus the program for sorting a string in an ascending order is executed successfully by TASM & result is verified.

Sorting a string in an descending order ASM code: . Model small . Stack . Data List1 db 53h, 10h, 24h, 12h Count Equ, 04h . Code Mov AX, @data Mov DS, AX Mov Dx, Count-1 Again2: Mov CX, DX Mov SI, offset List1 Again1: Mov AL, [SI] CMP AL, [SI+1] Jg PR1 XCHG [SI+1], AL XCHG [SI], AL PR1: ADD SI, 01H Loop Again1 DEC DX JNZ Again2 Mov AH, 4ch Int 21h End Input: Enter string: 53h, 10h, 24h, 12h Output: Sorted String: 10h, 12h, 24h, 53h Result: Thus the program for sorting a string in an ascending order is executed successfully by TASM & result is verified.

Length of the string ASM Code: . Model small . Stack . Data S1 Label word Mx1 db 30 Al1 dw ? S2 db enter the string:$ S3 db Length of the string,$ . Code Mov ax, @data Mov ds, ax Mov ah, 09H Lea dx, S2 Int 21h Mov ah, 0ah Lea dx, S1 Int 21h Mov ah,09h Lea dx,s3 Int 21h Mov ah, 02h Mov dx, al1 Or dx, 3030h Int 21h End Input: Enter the string SVCET Output: length of the string DS: 0005 Result: Thus the program to find the length of the string is executed successfully by TASM & result is verified.

Das könnte Ihnen auch gefallen