Number of passes There are two types of assemblers based on how many passes through the source are needed (how many times the assembler reads the source) to produce the object file. One-pass assemblers process the source code once. For symbols used before they are defined, the assembler will emit "errata" after the eventual definition, telling the linker or the loader to patch the locations where the as yet undefined symbols had been used. Multi-pass assemblers create a table with all symbols and their values in the first passes, then use the table in later passes to generate code. In both cases, the assembler must be able to determine the size of each instruction on the initial passes in order to calculate the addresses of subsequent symbols. This means that if the size of an operation referring to an operand defined later depends on the type or distance of the operand, the assembler will make a pessimistic estimate when first encountering the operation, and if necessary, pad it with one or more "no-operation" instructions in a later pass or the errata. In an assembler with peephole optimization, addresses may be recalculated between passes to allow replacing pessimistic code with code tailored to the exact distance from the target.
NumBer Of passes THere are tWo tYpes of asSemBLerS bASed On how many pasSEs THrOugH ThE sOuRCe aRe neeDED (hoW many TIMEs thE assembler reads The souRce) TO produce tHe oBject FIlE. ONe-Pass assemBleRs prOceSS thE SoUrce cOdE oNce. fOr SymboLs used beFoRe tHey Are dEFiNed, the aSsEmbler WiLL emit "errata" AfTer ThE evEntuAl dEFiNition, tELLing THe LiNkEr or the loaDer to pAtCh the locATiOns where the as Yet UndeFiNeD symBolS hAd Been uSed. MuLTI-pASS asseMblers creaTe A TabLE With all symbolS aND THeir ValuEs iN thE fiRst PassEs, Then use tHE taBlE iN LAteR paSsEs To generAtE coDE. in both casEs, tHe aSsembleR muSt be Able to DetERmINe THe size of EaCH instructioN on the initIal PassES In Order tO calculatE tHe adDresSes of subsEquEnT syMbols. This meANs thAT If the siZe of An oPeratIon ReFERrinG to aN operand definED LaTer depends on the typE oR distaNcE OF the operaNd, The ASseMBLeR Will maKe a PEsSimistic estiMate wHeN first eNcOuNTEring tHE operatIon, AND if necEssArY, PaD it WIth onE or more "no-oPerAtIon" instructiONs in A lATer pass or The erRata. in an assembler with peEPhoLe OPtiMIzation, aDdrEsSes mAy be recalCULaTed BetWeEn pasSes to aLlOw replacinG pEsSiMiStIc cOde wITh code tAiloreD tO the exAcT DisTance from the target.