Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .686
- .model flat, c
- includelib libcmt.lib
- includelib libvcruntime.lib
- includelib libucrt.lib
- includelib legacy_stdio_definitions.lib
- extern printf_s: proc, scanf_s: proc
- .data
- enterBaseNumber byte "Enter base number: ", 0
- enterExponent byte "Enter the exponent(positive integer): ", 0
- inputFormatString byte "%d", 0
- outputformatString byte "%d^%d = %d", 13, 10, 0
- .data?
- x dword ?
- y dword ?
- result dword ?
- .code
- main proc
- push offset enterBaseNumber
- call printf_s
- add esp, 4
- push offset x
- push offset inputFormatString
- call scanf_s
- add esp, 8
- push offset enterExponent
- call printf_s
- add esp, 4
- push offset y
- push offset inputFormatString
- call scanf_s
- add esp, 8
- push y
- push x
- call power
- add esp, 8
- mov result, eax
- push result
- push y
- push x
- push offset outputformatString
- call printf_s
- add esp, 16
- xor eax, eax
- ret
- main endp
- power PROC
- push ebp
- mov ebp, esp
- sub esp, 32
- cmp dword ptr [ebp + 12], 0 ; y
- mov esi, [ebp + 12]
- jne L1 ; [ebp + 12] x
- mov eax, 1
- jmp L2
- L1:
- ;mov eax, [ebp + 8]
- mov edi, [ebp + 8]
- mov ebx, [ebp + 12] ; return x * power(x, y - 1);
- dec ebx
- push ebx
- push edi
- call power
- add esp, 8
- mul dword ptr [ebp + 8]
- L2:
- mov esp, ebp
- pop ebp
- ret
- power ENDP
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement