;1)
; write an X86/64 ALP to accept five 64 bit hexadecimal numbers from user and store them in an
array and display the accepted numbers.
; Akhilesh Kumar Dudi
; 20173
%macro write 2 ; creating a macro for write
mov rax, 1 ; system call number for write
mov rdi, 1 ; system file descripter
mov rsi, %1 ; moving message to rsi
mov rdx, %2 ; moving message_length to rdx
syscall
%endmacro ; ending macro
%macro read 2 ; creating a macro for read
mov rax, 0 ; system call number for read
mov rdi, 0 ; system file descripter
mov rsi, %1 ; moving message to rsi
mov rdx, %2 ; moving message_length to rdx
syscall
%endmacro ; ending macro
section .data
msg1 db "Number : " ; msg1 variable with content "Number : " created
msg1len equ $-msg1 ; msg1 length stored to msg1len
endl db 10 ; for new line
section .bss
hexnum resq 5 ; variable hexnum with lengh 5 generated
num1 resb 17 ; variable temp with lengh 17 generated
temp resb 16 ; variable temp with lengh 16 generated
section .text
global _start ; declaring start
_start :
mov rcx, 5 ; moving 5 to rcx
mov rsi, hexnum ; moving hexnum to rsi
nextnum : ; declaring nextnum to loop through
push rcx ; pushing rcx to stack
push rsi ; pushing rsi to stack
write msg1, msg1len ; calling macro_write with message as msg1 and
message_length as msg1len
read num1, 17 ; calling macro_read with num1 and length 17
call ascii_hex ; calling ascii_hex method
pop rsi ; poping rsi from stack
pop rcx ; poping rcx from stack
mov [rsi], rbx ; moving rbx to rsi
add rsi, 8 ; adding 8 byte to rsi to get next number
loop nextnum ; pointing to nextnum
mov rsi, hexnum ; moving hexnum to rsi
mov rcx, 5 ; moving 5 to rcx
next2: ; declaring next2 to loop through
push rcx ; pushing rcx to stack
push rsi ; pushing rsi to stack
mov rbx, [rsi] ; moving rsi to rbx
call display ; calling display method
pop rsi ; poping rsi from stack
pop rcx ; poping rcx from stack
add rsi, 8 ; adding 8 byte to rsi to get next number
loop next2 ; ponting to next2
mov rax, 60 ; system call for exit
mov rsi, 0 ; exit code 0
syscall
ascii_hex: ; declaring ascii_hex method
mov rbx, 0 ; moving 0 to rbx
mov rsi, num1 ; moving num1 to rsi
mov rcx, 16 ; moving 16 to rcx
next : ; declaring next to loop through
rol rbx, 4 ; rotaing left rbx through 4 byte
mov al, [rsi] ; moving rsi to al
cmp al, '9' ; comparing al with '9'
jbe sub30h ; jump to sub30h
sub al, 7h ; subtracting 7h to al
sub30h : ; declaring sub30h
sub al, 30h ; subtracting 30h to get hex value
add bl, al ; adding al to bl
inc rsi ; incrementing rsi by 1
loop next ; pointing to next
ret ; returning from method
display : ; declaring display method
mov rsi, temp ; moving temp to rsi
mov rcx, 16 ; movng 16 to rcx
next1 : ; declaring next1 to loop through
rol rbx, 4 ; rotating left to rbx by 4byte
mov al, bl ; moving bl to al
and al, 0Fh ; performing and between al and 0Fh
cmp al, 9 ; comparing al with 9
jbe add30h ; jump to add30h
add al, 7h ; adding 7h to al
add30h : ; declaring add30h
add al, 30h ; adding 30h to al
mov [rsi], al ; moving al to rsi
inc rsi ; incrementing rsi by 1
loop next1 ; pointing to next1
write temp, 16 ; calling write macro with temp as message and 16 as its
length
write endl, 1 ; calling macro write for new line
ret ; returning from display method
;2)
; write an X86/64 ALP to accept a string and to display its length
; Akhilesh Kumar Dudi
;20173
%macro write 2 ; creating a macro for write
mov rax, 1 ; system call number for write
mov rdi, 1 ; system file descripter
mov rsi, %1 ; moving message to rsi
mov rdx, %2 ; moving message_length to rdx
syscall
%endmacro ; ending macro
%macro read 2 ; creating a macro for read
mov rax, 0 ; system call number for read
mov rdi, 0 ; system file descripter
mov rsi, %1 ; moving message to rsi
mov rdx, %2 ; moving message_length to rdx
syscall
%endmacro
; ending macro
section .data
msg1 db "Enter a String : " ; msg1 variable with content "Enter a string : " is
created
msg1len equ $-msg1 ; msg1 length stored to msg1len
endl db 10 ; for new line
section .bss
string resb 30 ; string with length 30 created
temp resb 2 ; temp variable of 2 length created
section .text
global _start ; declaring start
_start :
write msg1, msg1len ; calling macro_read with msg1 and
msg1len as parameter
write endl, 1 ; for new line
read string, 30 ; calling macro_read with string and 30 as
parameter
dec rax ; decrementing rax by 1
mov rbx, rax ; moving rax to rbx
call display ; calling display method
mov rax, 60 ; moving 60 in rax
mov rsi, 0 ; moving 0 in rsi
syscall
display : ; declaring display procedure
mov rsi, temp ; moving temp to rsi
mov rcx, 2 ; movng 2 to rcx
next1 : ; declaring next1 to loop through
rol bl, 4 ; rotating left to rbx by 4byte
mov al, bl ; moving bl to al
and al, 0Fh ; performing and between al and 0Fh
cmp al, 9 ; comparing al with 9
jbe add30h ; jump to add30h
add al, 7h ; adding 7h to al
add30h : ; declaring add30h adding 30h to
al
add al, 30h
mov [rsi], al ; moving al to rsi
inc rsi ; incrementing rsi by 1
loop next1 ; pointing to next1
write temp, 2 ; calling write macro with temp as message and
16 as its length
write endl, 1 ; calling macro write for new line
ret ; returning from display method
; 3)
; Name : Akhilesh Kumar Dudi
; Roll No : 20173
; Write a switch case driven X86/64 ALP to perform 64-bit hexadecimal arithmetic
operations(+,-,*,/) using suitable macros. Define procedure for each operation.
; Macro for write operation
%macro write 2
mov rax, 1 ; system call for write
mov rdi, 1 ; file handle for std out
mov rsi, %1; buffer address
mov rdx, %2; buffer length
syscall
%endmacro
; Macro for read operation
%macro read 2
mov rax, 0 ; system call for read
mov rdi, 0 ; file handle for std out
mov rsi, %1; buffer address
mov rdx, %2; buffer length
syscall
%endmacro
section .data
msg db "------------------MENU------------------", 10
db " 1. Addition ", 10
db " 2. Subtraction ", 10
db " 3. Division ", 10
db " 4. Multiplication ", 10
db " 5. Exit ", 10
db "Enter your choice : "
msglen equ $-msg
msg1 db "Number : "
len equ $-msg1
endl db 10
section .bss
choice resb 2
num resb 17
num1 resq 1
num2 resq 1
temp resb 16
section .text
global _start:
_start:
main_menu :
write msg, msglen
read choice, 2
cmp byte[choice], "1"
je case1
cmp byte[choice], "2"
je case2
cmp byte[choice], "3"
je case3
cmp byte[choice], "4"
je case4
cmp byte[choice], "5"
je case5
jmp main_menu
case1 :
call addition
jmp main_menu
case2 :
call subtraction
jmp main_menu
case3 :
call division
jmp main_menu
case4 :
call multiplication
jmp main_menu
case5 :
mov rax, 60
mov rdi, 0
syscall
; Procedure for addition
addition :
write msg1, len
read num, 17 ; reading number1
call ascii_hex ; converting it to hexadecimal
mov [num1], rbx ; storing it
write msg1, len
read num, 17 ; reading number2
call ascii_hex ; converting it to hexadecimal
mov [num2], rbx ; storing it
mov rax, [num1]
mov rbx, [num2]
add rbx, rax ; performing addition using add instruction
call display ; displaying the result
ret
; Procedure for subtraction
subtraction :
write msg1, len
read num, 17
call ascii_hex
mov [num1], rbx
write msg1, len
read num, 17
call ascii_hex
mov [num2], rbx
mov rax, [num1]
mov rbx, [num2]
sub rax, rbx ; performing subtraction using sub instruction
mov rbx, rax
call display
ret
; Procedure for multiplication
multiplication :
write msg1, len
read num, 17
call ascii_hex
mov [num1], rbx
write msg1, len
read num, 17
call ascii_hex
mov [num2], rbx
mov rax, [num1]
mov rbx, [num2]
mul rbx ; multiplying rax by rbx the resultant's first half is stored in rdx and the
remaining in rax
mov rbx, rdx
push rax
call display ; for displaying rdx value after mul
pop rbx ; for displaying rax value after mul
call display
ret
; Procedure for division
division :
write msg1, len
read num, 17
call ascii_hex
mov [num1], rbx
write msg1, len
read num, 17
call ascii_hex
mov [num2], rbx
mov edx, 0
mov eax, [num1]
mov ecx, [num2]
div ecx ; the quotient is stored in the accumulator while the remainder is stored in the
data register.
mov rbx, 0
mov ebx, eax
push rdx
call display
pop rbx
call display
ret
; Procedure for converting ascii value into hexadecimal
ascii_hex:
mov rbx, 0
mov rsi, num
mov rcx, 16
next :
rol rbx, 4
mov al, [rsi]
cmp al, '9'
jbe sub30h
sub al, 7h
sub30h :
sub al, 30h
add bl, al
inc rsi
loop next
ret
; Procedure for converting hexadecimal number into ascii characters and displaying them.
display :
mov rsi, temp
mov rcx, 16
next1 :
rol rbx, 4
mov al, bl
and al, 0Fh
cmp al, 9
jbe add30h
add al, 7h
add30h :
add al, 30h
mov [rsi], al
inc rsi
loop next1
write temp, 16
write endl, 1
ret
4)
;Akhilesh Kumar Dudi
;20173
%macro print 2
mov rax,1 ;sys call to read
mov rdi,1 ;assigning 1 to file descripter(stdout)
mov rsi,%1 ;assigning address of array(buffer)
mov rdx,%2 ;assigning length array
syscall
%endmacro
%macro input 2
mov rax,0 ;sys call to write
mov rdi,0 ;assigning 0 to file descripter(stdin)
mov rsi,%1 ;assigning address of array(buffer)
mov rdx,%2 ;assigning length array
syscall
%endmacro
section .data ;section for data
msg1 db "Enter Number " ;variable msg1 of string data type
msg1_len:equ $-msg1 ;length of msg1
msg2 db "Negative count : " ;variable msg2 of string data type
msg2_len:equ $-msg2 ;length of msg2
msg3 db "Positive count : " ;variable msg3 of string data type
msg3_len:equ $-msg3 ;length of msg3
newLine db 10 ;variable newLine with ascii value 10 for newline
section .bss ;section for uninitialised data
num1 resb 17 ;array num1 of 17 bytes
pc resb 1 ;variable pc of 1 byte
nc resb 1 ;variable nc of 1 byte
temp resb 2 ;buffer temp of 2 bytes
section .text ;section for actual code
global _start ;program starts here
_start:
mov rcx, 5 ;intialising 5 to counter register
fl:
push rcx
print msg1, msg1_len ;displaying msg1 string
input num1, 17 ;taking input
call ascii_hex ;converting input to hexadecimal 64 bit
bt rbx , 63 ;check 63rd Bit of rax
jc nci ;Jump Carry Checks if carry gen is 1 or not
inc byte[pc] ;increase count of pcount by 1 byte
jmp skip
nci:
inc byte[nc] ;increase count of ncount by 1 byte
skip:
pop rcx
loop fl ;Loop goto fl
mov rbx,[nc] ;moving value in nc to rbx
print msg2,msg2_len ;printing msg2
call display_8 ;call to display_8
mov rbx,[pc] ;moving value in pc to rbx
print msg3,msg3_len ;printing msg3
call display_8 ;call to display_8
mov rax,60 ;sys call for exit
mov rdi,0
syscall
ascii_hex: ;converting ascii to hex
mov rcx,16 ;intialising 16 to counter register
mov rsi,num1 ;pointning rsi to num1
mov rbx,0 ;clearing rbx
next1:
rol rbx,4 ;rotating left 4 bits of rbx
mov al, [rsi] ;moving value in rsi to al register
cmp al,29h ;comparing value in al with 29h
cmp al,47h ;comparing value in al with 47h
cmp al,30h ;comparing value in al with 30h
jge op ;if value is greater than or equal then op will be called
cmp al, 40h ;comparing value in al with 40h
op:
cmp al,39h ;comparing value in al with 39h
jbe minus30h ;if value is less than or equal then minus30h will be called
sub al, 7h ;subtracting 7h from al
minus30h:
sub al, 30h ;subtracting 30h from al
ADD bl,al ;adding al to bl
inc rsi ;pointing rsi to next index
loop next1
ret ;returning from procedure
display_8: ;displaying hex
mov rcx,2 ;intialising 2 to counter register
mov rsi,temp ;pointing rsi to temp
next:
rol bl,4 ;rotating left 4 bits of bl
mov al,bl ;moving bl to al
and al ,0Fh ;reseting all bits except lower nibble
cmp al,9h ;comparing value in al with 9h
jbe addition30h ;if value is less than or equal then addition30h will be called
add al,7h ;adding 7h to al
addition30h:
add al ,30h ;adding 30h to al
mov [rsi],al ;moving value in al to rsi
inc rsi ;pointing rsi to next index
loop next
print temp,2 ;displaying temp
print newLine,1 ;printing newline
ret ;returning
; 5)
; Name : Akhilesh Kumar Dudi
; Roll NO : 20173
; Write X86/64 ALP to convert 4-digit Hex number into its equivalent BCD number and 5- digit
BCD number into its equivalent HEX number. Make your program user friendly to accept the choice
from user for: (a) HEX to BCD b) BCD to HEX (c) EXIT.
; Display proper strings to prompt the user while accepting the input and displaying the result.
(Wherever necessary, use 64-bit registers).
; Date : 19/04/2022
; Macro for write
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; Macro for read
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
msg db "------------------MENU------------------", 10
db " 1. Hex to BCD ", 10
db " 2. BCD to Hex ", 10
db " 3. Exit ", 10
db "Enter your choice : "
msglen equ $-msg
msg1 db "Number : "
len equ $-msg1
endl db 10
section .bss
num resd 1
choice resb 2
a_hex resb 5
a_bcd resb 6
buffer resb 5
temp resb 4
section .text
global _start
_start :
main_menu :
write msg, msglen
read choice, 2
cmp byte[choice], "1"
je case1
cmp byte[choice], "2"
je case2
cmp byte[choice], "3"
je case3
jmp main_menu
case1 :
write msg1, len
read a_hex, 5
call hex_bcd
jmp main_menu
case2 :
write msg1, len
read a_bcd, 6
call bcd_hex
jmp main_menu
case3 :
mov rax, 60
mov rdi, 0
syscall
; Procedure to convert a hexadecimal number to bcd number
hex_bcd:
call ascii_hex ; first convert the number to hex form
mov ax, bx ; move the hex number into accumualtor
mov bx, 0AH ; move 0AH ie (10 in deccimal)
mov rcx, 5
convert :
mov rdx, 0 ; initialize rdx with 0
div bx ; div ax with bx
push dx ; store the remainder in the stack, while the quotient remains in the
accumualator
loop convert
mov rcx, 5
mov rsi, buffer
print_bcd :
pop ax ; pop the remainder(reverse order)
add ax, 30h ; add 30h to it
mov [rsi], ax ; move that value in the buffer
inc rsi ; increment the pointer
loop print_bcd
write buffer, 5 ; print the answer (BCD number)
write endl, 1
ret
; Procedure to convert a bcd number to a hexadecimal number
bcd_hex :
mov rsi, a_bcd
mov rcx, 5
mov bx, 0AH
mov rax, 0 ; initialize rax with 0
b_convert :
mul bx ; multiply the rax with 0Ah(10 in decimal)
mov dl, [rsi] ; move the digit stored in buffer in dl
sub dl, 30h ; subtract 30h from the digit
add al, dl ; add the number obtained to al
inc rsi ; increment the pointer
loop b_convert
mov bx, ax
call display
ret
; Procedure to convert ascii to heaxadecimal number
ascii_hex:
mov rbx, 0
mov rsi, a_hex
mov rcx, 4
next :
rol bx, 4
mov al, [rsi]
cmp al, '9'
jbe sub30h
sub al, 7h
sub30h :
sub al, 30h
add bl, al
inc rsi
loop next
ret
; Procedure to convert hexdecimal number to ascii
display :
mov rsi, temp
mov rcx, 4
next1 :
rol bx, 4
mov al, bl
and al, 0Fh
cmp al, 9
jbe add30h
add al, 7h
add30h :
add al, 30h
mov [rsi], al
inc rsi
loop next1
write temp, 4
write endl, 1
ret
; 6)
; Name : Akhilesh Kumar Dudi
; Roll NO : 20173
; Write X86/64 ALP to perform non-overlapped block transfer without string specific
instructions. Block containing data can be defined in the data segment.
; Date : 26/04/2022
; Macro for write
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; Macro for read
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
msg db "------------------MENU------------------", 10
db " 1. Without string instruction ", 10
db " 2. With string instruction ", 10
db " 3. Exit ", 10
db "Enter your choice : "
msglen equ $-msg
msg1 db "Number : "
len equ $-msg1
endl db 10
src dq 10h, 20h, 30h, 40h, 50h ; Source
dest dq 0h, 0h, 0h, 0h, 0h ; Destination
tab db 20h
source db " Source Destination", 10
sourcelen equ $-source
b db "Before : ", 10
a db "After : ", 10
l equ $-a
section .bss
temp resb 16
choice resb 2
section .text
global _start
_start :
main_menu :
write msg, msglen
read choice, 2
cmp byte[choice], "1"
je case1
cmp byte[choice], "2"
je case2
cmp byte[choice], "3"
je case3
case1 :
; Initializing the destination block with zeroes
write b, l
mov rcx, 5
mov rsi, dest
mov rax, 0
init1 :
mov [rsi], rax
add rsi, 8
loop init1
; Displaying the Blocks (source and destination) as well as the addresses
call displayBlock
write endl, 1
write a, l
; Logic for transferring the blocks
mov rcx, 5
mov rsi, src
mov rdi, dest
next :
mov rax, [rsi]
mov [rdi], rax
add rsi, 8
add rdi, 8
loop next
call displayBlock
write endl, 1
jmp main_menu
case2 :
; Initializing the destination with zeroes
write b, l
mov rcx, 5
mov rsi, dest
mov rax, 0
init2 :
mov [rsi], rax
add rsi, 8
loop init2
call displayBlock
; Logic for transferring the blocks
write endl, 1
write a, l
mov rcx, 5
mov rsi, src
mov rdi, dest
cld
next2 :
movsq
loop next2
call displayBlock
write endl, 1
jmp main_menu
case3 :
mov rax, 60
mov rdi, 0
syscall
displayBlock :
mov rcx, 5
mov rsi, src
mov rdi, dest
nextD :
push rcx
push rsi
push rdi
mov rbx, [rsi]
call display
write tab, 1
pop rax
mov rbx, [rax]
push rax
call display
write endl, 1
pop rdi
pop rsi
pop rcx
add rdi, 8
add rsi, 8
loop nextD
write endl, 1
mov rcx, 5
mov rsi, src
mov rdi, dest
nextA :
push rcx
push rsi
push rdi
mov rbx, rsi
call display
write tab, 1
pop rax
mov rbx, rax
push rax
call display
write endl, 1
pop rdi
pop rsi
pop rcx
add rdi, 8
add rsi, 8
loop nextA
ret
display :
mov rsi, temp
mov rcx, 16
next1 :
rol rbx, 4
mov al, bl
and al, 0Fh
cmp al, 9
jbe add30h
add al, 7h
add30h :
add al, 30h
mov [rsi], al
inc rsi
loop next1
write temp, 16
ret
; 7)
; Name : Akhilesh Kumar Dudi
; Roll NO : 20173
; Write X86/64 ALP to perform overlapped block transfer with string specific instructions Block
containing data can be defined in the data segment.
; Date : 26/04/2022
; Macro for write
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; Macro for read
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
msg db "------------------MENU------------------", 10
db " 1. Without string instruction ", 10
db " 2. With string instruction ", 10
db " 3. Exit ", 10
db "Enter your choice : "
msglen equ $-msg
msg1 db "Number : "
len equ $-msg1
endl db 10
src dq 10h, 20h, 30h, 0h, 0h, 0h
tab db 20h
b db "Before : ", 10
a db "After : ", 10
l equ $-a
section .bss
temp resb 16
choice resb 2
section .text
global _start
_start :
main_menu :
write msg, msglen
read choice, 2
cmp byte[choice], "1"
je case1
cmp byte[choice], "2"
je case2
cmp byte[choice], "3"
je case3
case1 :
; Initialize the destination with zeroes
write b, l
mov rcx, 3
mov rdi, src
add rdi, 18h
mov rax, 0
init1 :
mov [rdi], rax
add rdi, 8
loop init1
call displayBlock
write endl, 1
; Logic for transferring the blocks
write a, l
mov rcx, 3
mov rsi, src
mov rdi, src
add rdi, 18h
next :
mov rax, [rsi]
mov [rdi], rax
add rsi, 8
add rdi, 8
loop next
call displayBlock
write endl, 1
jmp main_menu
case2 :
; Initializing the destination with zeroes
write b, l
mov rcx, 3
mov rdi, src
add rdi, 18h
mov rax, 0
init2 :
mov [rdi], rax
add rdi, 8
loop init2
call displayBlock
write endl, 1
; Logic for transferring the blocks
write a, l
mov rcx, 3
mov rsi, src
mov rdi, src
add rdi, 18h
cld
next2 :
movsq
loop next2
call displayBlock
write endl, 1
jmp main_menu
case3 :
mov rax, 60
mov rdi, 0
syscall
displayBlock :
mov rcx, 6
mov rsi, src
nextD :
push rcx
push rsi
mov rbx, [rsi]
call display
write tab, 1
pop rbx
push rbx
call display
write endl, 1
pop rsi
pop rcx
add rsi, 8
loop nextD
write endl, 1
ret
display :
mov rsi, temp
mov rcx, 16
next1 :
rol rbx, 4
mov al, bl
and al, 0Fh
cmp al, 9
jbe add30h
add al, 7h
add30h :
add al, 30h
mov [rsi], al
inc rsi
loop next1
write temp, 16
ret
; 8)
; Name : Akhilesh Kumar Dudi
; Roll NO : 20173
; Write X86/64 ALP to perform multiplication of two 8-bit hexadecimal numbers. Use
successive addition and add and shift method. (Use of 64-bit registers is expected).
; Date : /04/22
; Macro for write
%macro write 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
; Macro for read
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
section .data
msg db "------------------MENU------------------", 10
db " 1. Successive Addition ", 10
db " 2. Add and Shift ", 10
db " 3. Exit ", 10
db "Enter your choice : "
msglen equ $-msg
msg1 db "Number : "
len equ $-msg1
endl db 10
section .bss
choice resb 2
num resb 3
num1 resb 1
num2 resb 1
temp resd 1
section .text
global _start
_start :
main_menu :
write msg, msglen
read choice, 2
cmp byte[choice], "1"
je case1
cmp byte[choice], "2"
je case2
cmp byte[choice], "3"
je case3
jmp main_menu
case1 :
write msg1, len
read num, 3
call ascii_hex
mov [num1], bl
write msg1, len
read num, 3
call ascii_hex
mov [num2], bl
call successive_addition
jmp main_menu
case2 :
write msg1, len
read num, 3
call ascii_hex
mov [num1], bl
write msg1, len
read num, 3
call ascii_hex
mov [num2], bl
call add_shift
jmp main_menu
case3 :
mov rax, 60
mov rdi, 0
syscall
; Procedure to perform Successive Addition to compute multiplication of two numbers
successive_addition:
mov cl, [num2]
mov rbx, 0
mov al, [num1]
next_add :
add bx, ax
loop next_add
call display
ret
; Procdure to perform Add and Shift method to compute multiplication of two numbers
add_shift:
mov rbx, 0
mov al, [num1]
mov dl, [num2]
mov cl, 8
next_shift :
bt rdx, 0
jnc ahead
add bx, ax
ahead :
rol ax, 1
ror dl, 1
loop next_shift
call display
ret
; Procedure to convert ascii to heaxadecimal number
ascii_hex:
mov bl, 0
mov rsi, num
mov rcx, 2
next :
rol bl, 4
mov al, [rsi]
cmp al, '9'
jbe sub30h
sub al, 7h
sub30h :
sub al, 30h
add bl, al
inc rsi
loop next
ret
; Procedure to convert hexdecimal number to ascii
display :
mov rsi, temp
mov rcx, 4
next1 :
rol bx, 4
mov al, bl
and al, 0Fh
cmp al, 9
jbe add30h
add al, 7h
add30h :
add al, 30h
mov [rsi], al
inc rsi
loop next1
write temp, 4
write endl, 1
ret