;write a program to implement multiplication using successive addition method  
global _start
_start:

%macro disp 2
mov rax,1
mov rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endm

%macro accept 2
mov rax,0
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endm

disp msg1,len1
accept num,length1
call convert
mov [num1],al
disp msg2,len2
accept num,length1
call convert
mov [num2],al
mov bx,0000h
l3:
add bx,[num1]
dec byte[num2]
jnz l3
disp msg3,len3
mov ax,bx
call display
disp msg4,len4

mov rax,60
mov rdi,0
syscall

convert:
mov rsi,num
mov al,[rsi]
cmp al,39h
jbe l1
sub al,07h
l1:
sub al,30h
rol al,04
mov bl,al
inc rsi
mov al,[rsi]
cmp al,39h
jbe l2
sub al,07h
l2:
sub al,30h
add al,bl
ret

display:
mov rsi,disparr+1;
mov rcx,02;
a2:
mov rdx,0;
mov rbx,10h;
div rbx;
cmp dl,09h;
jbe a1;
add dl,07h;
a1:
add dl,30h;
mov [rsi],dl;
dec rsi
dec rcx;
jnz a2

mov rax,1;
mov rdi,1;
mov rsi,disparr;
mov rdx,02
syscall

ret

section .data
msg1 db "Enter first number"
len1 equ $-msg1
msg2 db "Enter second number"
len2 equ $-msg2
msg3 db "result:"
len3 equ $-msg3
msg4 db ""
len4 equ $-msg4

section .bss
num1 resb 10
num resb 10
num2 resb 10
length1 resb 02

disparr resb 32

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: