5.prog To Perform Bit Manipulation To Check If Bit Is Odd or Even and Positive or Negative
5.prog To Perform Bit Manipulation To Check If Bit Is Odd or Even and Positive or Negative
prog to find square and cube of a number 4.Program to find the factorial of a number 5.Prog to perform bit manipulation to check if bit is odd or even and positive or negative 6.Prog to check bitwise paliandrome 7.Prog to sort an array in ascending and descending order 8.prog to reverse a string 9.program to check if the string is a palindrome 10.prog to check the occurence of a character in a string 11.Prog to generate first 10 fibonacci numbers 13.prog to find LCM and GCD of two given numbers 14.Prog to convert BCD to binary equivalent
FACT DW ? DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX,DATA MOV DS,AX SUB DX,DX SUB CX,CX MOV AX,01H MOV CL,NUM CMP CL,00H JE STOP BACK: MUL CL LOOP BACK MOV FACT,AX MOV FACT+2,DX STOP: INT 3H CODE ENDS END START
assume cs:code,ds:data start:mov ax,data mov ds,ax mov ax,x test ax,01h jnz exit lea dx,msg1 mov ah,09h int 21h jmp last exit:lea dx,msg2 mov ah,09h int 21h last:mov ah,4ch int 21h code ends end start
6.Prog to check bitwise paliandrome DATA SEGMENT A DB 88H RES DB ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV BL,A MOV AL,A MOV CX,04H ABOVE:MOV DX,0 ROL AL,01H JNC NEXT INC DL NEXT: ROR BL,01H JNC LI
INC DH LI:CMP DH,DL JNZ OVER LOOP ABOVE MOV RES,0FFH JMP FINISH OVER:MOV RES,0AAH FINISH: MOV AH,4CH INT 21H CODE ENDS END START 7.Prog to sort an array in ascending and descending order
8.Prog to reverse a string DATA SEGMENT STR1 DB 'HELLO' STR2 DB 8 DUP(?) DATA ENDS code segment ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV SI,7 MOV CX,8 MOV DI,0
BACK: MOV AL,STR1[SI] MOV STR2[DI],AL DEC SI INC DI LOOP BACK MOV AH,4CH INT 21H CODE ENDS END START 9.program to check if the string is a palindrome
Data Segment str1 db 'MADAM','$' strlen1 dw $-str1 strrev db 20 dup(' ') str_palin db 'String is Palindrome.','$' str_not_palin db 'String is not Palindrome.','$' Data Ends Code Segment Assume cs:code, ds:data Begin: mov ax, data mov ds, ax mov es, ax mov cx, strlen1 add cx, -2 lea si, str1 lea di, strrev add si, strlen1 add si, -2 L1: mov al, [si] mov [di], al dec si inc di loop L1 mov al, [si] mov [di], al inc di mov dl, '$' mov [di], dl mov cx, strlen1 Palin_Check: lea si, str1 lea di, strrev repe cmpsb jne Not_Palin Palin: mov ah, 09h
Not_Palin:
lea dx, str_palin int 21h jmp Exit mov ah, 09h lea dx, str_not_palin int 21h mov ax, 4c00h int 21h
DAA XCHG AL,AH MOV [SI],AX MOV AX,BX MOV BX,[SI] LOOP RPT INT 3H CODE ENDS END START
DATA SEGMENT NUM DB 12H HEXNUM DB ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX LEA SI,NUM MOV AL,[SI] MOV BL,[SI] AND BL,0FH AND AL,0F0H MOV CL,04H SHR AL,CL MOV DL,0AH MUL DL ADD AL,BL INC SI MOV [SI],AL INT 3H CODE ENDS END START