\ch03\AddSub.asm(45): fatal error A1010: unmatched block nesting : IsPrime

依然范特西╮ 提交于 2019-12-11 04:41:04

问题


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 :-)



来源:https://stackoverflow.com/questions/37561264/ch03-addsub-asm45-fatal-error-a1010-unmatched-block-nesting-isprime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!