Wednesday, March 20, 2019

Write X86/64 ALP to perform overlapped block transfer (with and without string specific instructions). Block containing data can be defined in the data segment

section .data
msg db "enter an offset:",10
len: equ $-msg

arr1 db "se computer",0ah
len1: equ $-arr1

section .bss
n resb 2
len4 resb 2

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

%macro inn 2
mov rax,00
mov rdi,00
mov rsi,%1
mov rdx,%2
syscall
%endmacro

section .text
global _start
_start:

disp msg,len
inn n,2

cmp byte[n],39h
jng skip
sub byte[n],07h
skip:
sub byte[n],30h

mov rsi,arr1+len1-1
mov rdi,rsi
mov rcx,len1
xor rax,rax
mov al,[n]

add rdi,rax

;up:
;mov al,[rsi]
;mov [rdi],al
;dec rdi
;dec rsi
;dec cl
;jnz up
;mov al,[n]
;mov len4,al

std
rep movsb

disp arr1,len1+len4
mov rax,3ch
mov rdi,00
syscall

No comments:

Post a Comment