PL 6
PL 6
Rollno:- 151
Batch:- B4
Practical 6
Write Menu driven program for Multiplication using successive addition and shift and
add method
CODE:-
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
db "8. Exit",10
msg11 db "Substring",10
string1 resb 20
string2 resb 20
string3 resb 40
l1 resq 1
l2 resq 1
l3 resq 1
choice resb 2
buff resb 16
section .text
global _start
_start:
read string1, 20
dec rax
read string2, 20
dec rax
printmenu:
read choice, 2
je strlen
je strrev
je strcmp
je strcat
je strpalindrome
je strsub
je exit
jmp printmenu
strlen:
call display
jmp printmenu
strcpy:
cld
rep movsb
jmp printmenu
strrev:
dec rsi
up:
dec rsi
inc rdi
dec rcx
jnz up
jmp printmenu
strcmp:
jne nonequal
cld
repe cmpsb
jne nonequal
jmp printmenu
nonequal:
write msg7, len7
jmp printmenu
strcat:
cld
rep movsb
rep movsb
jmp printmenu
strpalindrome:
read string1, 20
dec rax
dec rsi
up1:
dec rsi
inc rdi
dec rcx
jnz up1
cld
repe cmpsb
jne notequal1
jmp printmenu
notequal1:
jmp printmenu
strsub:
read string1, 20
dec rax
read string2, 20
dec rax
up3:
je same
same:
inc rsi
inc rdi
dec rbx
cmp rbx, 0
je st
jne up3
jmp printmenu
st:
jmp printmenu
exit:
mov rax, 60
syscall
display:
mov rcx, 16
up2:
rol rbx, 4
mov dl, bl
add30:
inc rsi
dec rcx
jnz up2
write buff, 16
ret
OUTPUT:-