So I have a macro code from help of the teacher (this worked previously)
%macro aBin2int 2
push rbp
mov rbp, rsp
sub rsp, 8
push rcx
push rdx
mov dword [%2], 0
mov dword [rbp - 4], 0
mov dword [rbp - 8], 2
mov rax, 0
mov rdx, 0
mov rcx, 0
mov r10, 0
%%nxtCR:
movzx eax, byte [%1 + r10]
cmp eax, NULL
je %%controlDone
cmp eax, "0"
jae %%adding
%%adding:
sub eax, "0"
mov dword [rbp - 4], eax
mov eax, dword [%2]
mul dword [rbp - 8]
add eax, dword [rbp - 4]
mov dword [%2], eax
inc r10
jmp %%nxtCR
%%completed:
pop rdx
pop rcx
mov rsp, rbp
pop rbp
%endmacro
Now I have to call a function that calls another function.
; ******************************************************************
; Function getIterations()
; Performs error checking, converts ASCII/binary to integer.
; Command line format (fixed order):
; "-it <binaryNumber> -rs <binaryNumber>"
; -----
; Arguments:
; 1) ARGC, double-word, value
; 2) ARGV, double-word, address
; 3) iterations count, double-word, address
; 4) rotate spped, double-word, address
So this getIteration calls
; *******************************************************************************
; Simple function to convert ternary string to integer.
; Reads string and converts to intger
; -----
; HLL Call
; bool = ternary2int(&str, &int);
; -----
; Arguments passed:
; 1) string, address, rdi
; 2) integer, address, rsi
; -----
; Returns
; 1) integer value (via passed address)
; 2) bool, TRUE if valid conversion, FALSE for error
aBin2int function (this read binary strings into a decial digit)
This is working okay as macro, but I am troubling with changing it into a function.
mov rbx, qword[rsi + 16]
mov r10, 0
binaryCheck:
mov rax, 0
mov al, byte[rbx + r10]
cmp al, NULL
je convertBinary
cmp al, "2"
jae itsNoBinary
cmp al, "0"
jb itsNoBinary
inc r10
jmp binaryCheck
convertBinary:
mov r15, 0
mov rdi, rbx
mov rsi, r15
call aBin2int
Could anyone please help me with this?