Coal Assignment 3 Name: Faizan Tariq Roll No: 22F-3858 Section: 3D
Coal Assignment 3 Name: Faizan Tariq Roll No: 22F-3858 Section: 3D
Assignment 3
Name : Faizan Tariq
Roll No: 22F-3858
Section: 3D
TASK 1:
CODE:
org 0x100
; to check if number is palidrome or not
num dw 1221 ; Replace with your input number (16-bit)
OUTPUT:
TASK 2:
[org 0x0100]
jmp start
num : dw 6
fact: dw 0
mov dx,ax
sub dx,1
mov cx,dx
multiply: shr cx,1
jnc skipaddition
add bx,ax
skipaddition:
cmp cx,0
jz next
shl ax,1
jmp multiply
next: sub dx,1
mov ax,dx
cmp ax,1
jle fact0
mov ax,bx
mov bx,0
mov cx,dx
jmp multiply
fact0: cmp bx,0
jnz movebx
mov word [fact],1
jmp end
OUTPUT:
TASK 3:
Code:
[org 0x100]
jmp start
decimal_num dw 15
binaryArray db 0, 0, 0, 0, 0, 0, 0, 0
start:
mov cx,2 ; for divide by 2
mov ax, [decimal_num] ; Move the decimal number into the AX register
mov bx,binaryArray+7
exit:
mov ax,[binaryArray]
mov ax, 0x4c00
int 21h
OUTPUT:
TASK 4:
org 100h
jmp start
num4 : dw 60,55,-55,60,-60,58,-58,-58,25,15,34,87,90,12,65
swap : db 0
start:
mov bx, 0
mov byte[swap], 0
loop1:
mov ax, [num4 +bx]
mov dx,[num4+bx+2]
cmp dx,ax
jge noswap
mov [num4+bx+2] ,ax
mov [num4+bx],dx
mov byte[swap],1
noswap: add bx,2
cmp bx, 28
jne loop1
cmp byte[swap],1
je start
mov ax,num4
mov ax, 0x4c00
int 21h
OUTPUT: