I have a function in assembly called "test" a subfunction in another file called "shift" and a c function called "shiftLetter". My shiftLetter function has two parameters a char with the letter to be shifted and an integer which is the number of shifts. I am trying to send a message to my "shift" function and this function calls my c function to change each letter in this message. However, I am having trouble making this work:
test.asm
extern printf, scanf
extern shift
global _start
section .data
format3 db "%s ",0
message1: db "This is the Message: ",10,0
original: db "Hello World.",10,0
len1: equ $ - original
section .text
global main
main:
mov rsi, message1
call messages
mov rdi,original ;message to change
mov rsi, len1 ;size of message
mov rbx, 3 ;number of shifts
call shift
mov rsi, original
call messages
ret
; end main
messages
mov rdi,format3
mov rdx,rsi
mov rax,0
call printf
ret
shift.asm
global shift
extern shiftLetter
section .text
shift:
mov rdx, rsi ;rdx length of string
mov rcx,0
loop: cmp rcx, rdx
jge done
mov rax, byte [rdi+rcx] ;getting letter to change (I am sure this is wrong)
mov r8, rbx ;number of shifts
call shiftLetter
mov byte [rdi+rcx], rax
inc rcx
jmp loop
done:
ret