Well I am trying to get a number with a power like if the user enters 2 and 15 it would turn out as 2^15 or 32768 and I have tested it to see if it works I then print the value 32768 push it onto the stack then pass it to r8 and move the actual number to it here is my number to it I didn't post the full code because i didn't think it was relevant but here it is:
section .data
PowerMsg: dq "Input a power",10
PowerMsg_L: equ $ - PowerMsg
newLine: dq "",10
newLine_L: equ $ - newLine
section .bss
power resq 255
number resq 255
section .text
%include "functions.asm"
global _start:
_start:
mov rax, 1
mov rdi, 1
mov rdx, MSG_L
mov rsi, MSG
syscall
mov rax, 0;
mov rdi, 0
mov rdx, 255
mov rsi, number
syscall
mov rax, 1
mov rdi, 1
mov rdx, PowerMsg_L
mov rsi, PowerMsg
syscall
mov rax, 0
mov rdi, 0
mov rdx, 255
mov rsi, power
syscall
mov r8, power
call atoi
mov rcx, rax; the power
push rcx
mov r8, number
call atoi
pop rcx
call PowerSum
mov rax, 60
mov rdi, 0
syscall
ret
PowerSum:
;power is passed in rcx
;number is passed in rax
push rbx
mov rbx, rax
.forLoop:;calculates the n^x power
xor rdx, rdx
mul rbx
dec rcx
cmp rcx, 1
jne .forLoop
mov qword[x_number], rax
push rax
mov r8, qword[x_number]
call itoa
mov rsi, newLine
mov rdx, newLine_L
mov rax, 1
mov rdi, 1
syscall
xor r8, r8
pop r8;mov the number into r8
pop rbx;restore rbx
mov qword[x_number], r8
mov r8, x_number;mov the adress into r8
add r8, 80
mov byte [r8], 0;put a zero after the number
sub r8, 80
xor rcx, rcx;clear out rcx for use
;add individual digits together
.forLoop2:
add cl, byte[r8]
add r8, 1;get ready for the next number
cmp byte[r8], 0;if this digit is equal not equal to zero then jump back to the top
jne .forLoop2
;print out the result stored in rcx
mov qword[x_number], rcx
mov r8, qword[x_number]
call itoa
;print out a new Line
mov rsi, newLine
mov rdx, newLine_L
mov rax, 1
mov rdi, 1
syscall
.done:
ret