Search code examples
linuxassemblyx86nasm32-bit

Why do I get an error in NASM when running this StackExchange codereview program?


I believe my question is very simple so I am hoping you can help me:

From this codereview post, I wanted to run the NASM portion of his / her code (2nd big block of code on that page there). Yet I get an error when running it. Specifically:

file.asm: error: Can't find valid values for all labels after 1003 passes, giving up.

file.asm: error: Possible causes: recursive EQUs, macro abuse.

I am running it on a Linux machine, with NASM 32 Bit x86 Assembly, which are precisely the parameters used in creating this program according to the user who originally posted that code review.

I looked up this error and found some, albeit little resources to help. It seems that if a label is pronounced twice in the code, it gets that error. However, I have been searching through this code for hours now and I cannot seem to find any duplicate labels or any reasoning as to why this error would pop up. Additionally, it seems that the users on the site did not bring up this error, indicating that it probably ran fine for them.

Why is this the case?


Solution

  • There are two obvious errors. Line 5 (1-based) should be badNumL equ $-badNum, and line 7 should be gcdL equ $-gcdiv. Once those are fixed, there are a whole slew of other errors and warnings, but it will get you past the original error.