; THIS CODE HAS BEEN TESTED AND IS FULLY OPERATIONAL. ; Problem Statement: Write X86/64 ALP to perform overlapped block transfer (WITHOUT string specific instructions). Block containing data can be defined in the data segment. ; Code from Microprocessor (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/Microprocessor/ ; BEGINNING OF CODE %macro print 2 ; Defined macro for printing messages 2 stand for the parameters mov rax,1 ; For system write specifier mov rdi,1 ; Standard output mov rsi,%1 mov rdx,%2 syscall %endmacro section .data m1 db 10,"source block",10,13 ; 10 stands for new line and 13 stands for tab m1len equ $-m1 m2 db 10,"destination block after transfer:",10,13 m2len equ $-m2 space db " " spacelen equ $-space srcblk db 10h,20h,30h,40h,50h ; srcblk defined for the functioning count equ 05h ; count initialized to 5 section .bss ans resb 4 ; ans block is defined for storing the transformed value of the numbers from hexa to ascii dstblk resb 5 ; dstblk is our destination block section .text ; This section is necessary for assembler understanding global _start _start: print m1,m1len mov rsi,srcblk ; rsi now points to the first location of the source block call disp_block ; Calling the procedure for displaying the source block print m2,m2len mov rsi,srcblk ; Now the rsi points to the source block mov rdi,dstblk ; Now the destination pointer points to the first memory location of the destination block mov rcx,02 ; rcx is the register used for the counter purpose s1: mov al,[rsi] mov [rdi],al inc rsi inc rdi loop s1 mov rsi,srcblk mov rcx,03 s2: mov al,[rsi] mov [rdi],al inc rsi inc rdi loop s2 mov rsi,dstblk call disp_block mov rax,60 xor rdi,rdi syscall disp_block: mov rbp,count back: mov al,[rsi] push rsi call disp_8 print space,1 pop rsi inc rsi dec rbp jnz back ret disp_8: mov rsi,ans mov bl,al mov dl,bl rol dl,04 and dl,0fh cmp dl,09h jbe add30 add dl,07h add30: add dl,30h mov [rsi],dl inc rsi mov dl,bl and dl,0fh cmp dl,09h jbe add130 add dl,07h add130: add dl,30h mov [rsi],dl print ans,2 ret ; END OF CODE