sfl-examples/slide-examples/assembly/ex33.asm

69 lines
1.0 KiB
NASM

; strlen
bits 64
; program being used for Pin exercise
SECTION .data
mystr1: db 'string1',0
mystr2: db 'string2',0
mystr3: db 'string3',0
SECTION .text
myfun1:
push rbp
mov rbp, rsp
xor rax, rax
lea rax, [rax]
leave
ret
myfun2:
push rbp
mov rbp, rsp
mov rcx, rsi ; second param, len in bytes
test rcx, rcx
jz .done
.encrypt:
xor byte [rdi], 0x42 ; first param, pointer to byte array that needs en- or decryption
inc rdi
loop .encrypt
.done:
leave
ret
myfun3:
push rbp
mov rbp, rsp
xor rax, rax
add rax, rdi ; first param
add rax, rsi ; second param
leave
ret
global _start
_start:
%include "macros.asm.inc"
;%include "header.asm.inc"
mov rdi, 5
mov rsi, 10
call myfun3
call myfun1
call myfun1
call myfun1
call myfun1
call myfun1
; encrypt
mov rdi, mystr1
mov rsi, 7
call myfun2
; write mystr1 to stdout
sys_write 1, mystr1, 7
%include "sysexit.asm.inc"