Math 总成功率返回错误值

Math 总成功率返回错误值,math,assembly,x86,exponentiation,Math,Assembly,X86,Exponentiation,我试图让用户输入两位数字,第一位是基数,第二位是指数 这两个值存储正确。我通过打印它们知道这一点(此打印代码目前已被注释掉)。 但是,我计算基指数答案的循环返回了错误的值 有人能给我指出正确的方向,甚至解决我的问题吗 这是我的代码: #/** #* The pow subroutine calculates powers of natural bases #* and exponents. #* #* Arguments: #* #* base - the exponential base #*

我试图让用户输入两位数字,第一位是基数,第二位是指数

这两个值存储正确。我通过打印它们知道这一点(此打印代码目前已被注释掉)。 但是,我计算基指数答案的循环返回了错误的值

有人能给我指出正确的方向,甚至解决我的问题吗

这是我的代码:

#/**
#* The pow subroutine calculates powers of natural bases
#* and exponents.
#*
#* Arguments:
#*
#* base - the exponential base
#* exp - the exponent
#*
#* Return value: 'base' raised to the power of 'exp'.
#*/

#int pow( int base, int exp )
# {
#  int total = 1;
#  while !(exp  <= 0){
#   total = total * base;
#   exp = exp -1;
#  }
#  return total;
# }

.bss
    EXP: .long 
    BASE: .long
    TOTAL: .long

.text
    FSTR: .asciz "%d"
    PSTR: .asciz "%d\n"

.global main

  inout:
    pushl %ebp      # Prolog: push the base pointer.
    movl  %esp, %ebp    # and copy stack pointer to EBP. 

    subl $4, %esp       # Reserve stack space for variable
    leal -4(%ebp), %eax     # Load address of stack var in eax


    pushl %eax      # Push second argument of scanf
    pushl $FSTR     # Push first argument of scanf
    call scanf      # Call scanf


    movl -4(%ebp), %eax     # Move result of scanf from stack to eax

    movl %ebp, %esp     # Clear local variables from stack.
    popl %ebp       # Restore caller's base pointer.
    ret             # return from subroutine.

  main:
    call inout
    movl %eax, BASE

    #pushl BASE
    #pushl $PSTR
    #call printf

    call inout
    movl %eax, EXP

    #pushl EXP
    #pushl $PSTR
    #call printf


    #subl $4, %esp
    #leal -4(%ebp), %eax
    #movl %eax, TOTAL

    movl $1, TOTAL

   loop:
    cmpl $0, EXP
    jle end
    movl TOTAL, %eax
    mull BASE
    movl %eax, TOTAL
    decl EXP
    jmp loop
    end:
    pushl %eax
    pushl $PSTR
    call printf
    #addl $4, %esp      #\
    pushl $0        #- Clean up and exit
    call exit       #/
#/**
#*pow子程序计算自然基的幂
#*和倡导者。
#*
#*论据:
#*
#*基数-指数基数
#*exp-指数
#*
#*返回值:“base”提升为“exp”的幂。
#*/
#int-pow(int-base,int-exp)
# {
#整数合计=1;

#while!(exp一种可能是在调试器中单步执行代码,并验证工作寄存器是否包含预期值。

您得到的值是什么?您的scanf是否提供数值或ascii值?