Я новичок в этом языке, и моя задача - создать программу из 3 процедур. Одна процедура, которая запрашивает у пользователя число, другая процедура, которая находит факториал этого числа, и заключительная процедура для печати информации.
Я написал первую процедуру, и теперь я приступил к трудной части, находя факториал.
Я считаю, что по большей части у меня правильный код, но при попытке пройти процедуру с вводом от пользователя я сталкиваюсь с ошибками.
Вот мой код(Я попытался разместить как можно больше заметок, чтобы вы могли видеть, где находится моя голова, на тот случай, если я на неправильном пути):
include c:\asmio\asm32.inc
includelib c:\asmio\asm32.lib
includelib c:\asmio\User32.lib
includelib c:\asmio\Kernel32.lib
input proto ; 0 parameters
Factorial proto nv: dword ; 1 parameter
; -------------------------------------------------------
.const
NULL = 0
; -------------------------------------------------------
.data
nvx dword ? ;
ask byte "Enter a number between 1-12: ", NULL
; -------------------------------------------------------
.code
main proc
invoke input ; gets input from user, see procedure below
mov nvx, eax ; after first procedure, moves given input from user into variable
invoke Factorial nvx: dword ; This is where my error is according to compiler
ret 0
main endp
; -------------------------------------------------------
input proc
mov edx, OFFSET ask
call WriteString
call ReadInt
ret
input endp
; -------------------------------------------------------
Factorial proc USES ECX EAX EBX nv: dword
mov ecx, nv ;start loop counter at value given by user because we need to multiply this many times to find the factorial.
mov ebx, nv ; hold value of nv as divisor
inc nv ; This is to account for 0! We increment by one and after the loop divide by nv
mov eax, nv ; stores the largest number for multiplication
L1:
dec nv ; becomes next largest number
mul nv ; multiplication
mov eax, edx ; stores product into eax for next multiplication
loop L1
cdq
idiv ebx ; divide final product by original number entered for the correct factorial
ret
Factorial endp
end main ; End of the entire program
; -------------------------------------------------------
Вот мой журнал ошибок:
[11:20:28] Build started...
[11:20:28] Warning! Errors have occurred in the build:
Assembling: C:\Users\yp0l0\AppData\Local\Temp\SASM\program.asm
C:\Users\yp0l0\AppData\Local\Temp\SASM\program.asm(30) : error A2206: missing operator in expression
LINK : fatal error LNK1181: cannot open input file "C:\Users\yp0l0\AppData\Local\Temp\SASM\program.o"
Спасибо за любую помощь!