\\ch03\\AddSub.asm(45): fatal error A1010: unmatch

2019-08-15 17:48发布

问题:

INCLUDE Irvine32.inc
.code
main PROC
.REPEAT
mov edx, OFFSET fPrompt ;display a prompt
call WriteString
call ReadInt ;recordes users number
mov var1, eax           ;gives var1 the users number
.IF var1 == -1       ;jumps to L3 if the user want's to quit
jmp L3
.ENDIF
call IsPrime       ;calls the IsPrime procedure
L3:
.UNTIL var1 == -1       ;jumps up to repeat if var1 != -1
ret
main ENDP
mov ebx, 2   ; sets minimum divisor
mov eax, var1 ; set dividend
cdq ; converts to 64-bit edx:eax
mov ecx, ebx ; stores divisor in ecx
div ecx ; Proformes division
mov b, eax   ; Gets remainder, b is half var2
.WHILE ebx != b   ;loops until ebx has reached var1/2
mov eax, var1 ; set dividend
cdq ; converts to 64-bit edx:eax
mov ecx, ebx ; stores divisor in ecx
div ecx ; Proformes division
mov a, edx   ; Gets remainder
.IF a == 0 ;if there was no remainder, then var1 is not prime
jmp L1       ;jumps out of the loop if above is correct
.ENDIF
inc ebx       ;increments until ebx reaches b
.ENDW
mov edx, OFFSET pPrompt   ;tells the user their number was prime
call WriteString
jmp L2
L1:
mov edx, OFFSET cPrompt ;tells the user their number was not prime
call WriteString
L2: ret
IsPrime ENDP
END main

Can anyone help with the error msg im getting?

回答1:

You have a IsPrime ENDP line but no corresponding IsPrime PROC.

That's why it's complaining about the nesting.

You need to work out where the PROC line should go (probably immediately before mov ebx, 2 ; sets minimum divisor) and, ... well, put it there :-)