Professional Documents
Culture Documents
PL 5
PL 5
Rollno:- 151
Batch:- B4
Practical 5
Write Menu driven program for Multiplication using successive addition and shift and
add method
CODE:-
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
db "3. Exit", 10
section .bss
num resb 17
choice resb 2
buff resb 16
no resq 1
ccnt resq 1
no1 resq 1
no2 resq 1
A resq 1
B resq 1
Q resq 1
n resq 1
section .text
global _start
_start:
main_menu: ; label
read choice, 2
je op1
je op2
cmp byte [choice], 33h
je op3
read num, 17
dec rax
read num, 17
dec rax
mov rbx, 00
l1:
jne l1
call disp
jmp main_menu
read num, 17
dec rax
read num, 17
dec rax
above:
jne shift
shift:
shr rbx, 01
cmp rax, 01
jne shift_a
or rbx, rdx
shift_a:
jnz above
call disp
call disp
jmp main_menu
op3:
mov rax, 60
mov rdi, 0
syscall
accept:
mov rbx, 00
up1:
jbe sub_30
sub_30:
inc rsi
jnz up1
ret
disp:
mov rsi, buff
mov rcx, 16
mov rdx, 00
up2:
rol rbx, 04
mov dl, bl
cmp dl, 09
jbe mc
mc:
mov [rsi], dl
inc rsi
dec rcx
jnz up2
write buff, 16
ret
OUTPUT:-