What's Known: -For all non-label instructions: on the first pass the instruction is checked for errors and if none are found, the instruction is assembled into a small buffer. These instruction buffers are later combined in build(). -Every branch (Bcc and BRA) is set to 2 bytes during the first pass. The 2nd byte is set equal to $00. -On the second pass the label is checked to make sure that it exists. -If a branch occurs between the current branch and it's target label, the size of the current branch is dependent upon the size of encountered branch. In other words, the encountered branch can cause the current branch's displacement field to be off by 2, depending on whether the encountered branch was resized to a 16-bit displacement. -Consider the following: label1: bra label2 ;branchA bra label1 ;branchB label2: [...] Since build() starts at the top of the file structure, "bra label2" will be encountered first. We'll call this branchA. Next, we determine the location of its target label label2 and then work ahead to it. The next instruction read between branchA and label2 is "bra label1", or branchB. This is where things get crazy. The distance from branchA to label2 depends on the size of branchB. Let's say we assume that branchB is 2 bytes, so we add 2 to the distance variable for branchA. Then let's say that later when we calculate the distance from branchB to label1, it's deteremined that branchB needs to be resized to 4 bytes because the distance to label1 is more than 1 byte can hold. But remember earlier when the distance from branchA to label2 was being calculated, we assumed that branchB was 2 bytes, NOT 4 bytes. But since it is 4 bytes, the distance from branchA to label2 will be off by 2. One way to approach this is to calculate the distance for any branch we encounter. In the above example that would mean we would calculate the distance between branchB and label1 and then once that's known, come back and finish calculating the distance from branchA to label2. Let's say we do that: we begin at branchA and start working our way towards label2. Along the way we encounter branchB and begin calculating the distance from branchB to label1. Since label1 occurs before branchB in the file, we begin there and work forward. But a problem arises. branchA is encountered before we reach label1. Essentially we're back where we started. We know that the size of branchA is contingent upon the size of branchB, but in order to determine the size of branchB, we must know the size of branchA. And we now find ourselves stuck in an infinite loop. I've spent who knows how many hours wrestling with this problem, and the only workable solution I've managed to come up with is require the size of the branch be specified by the user: bra.b or bra.w or something similar. While it might come to that, I'd really prefer the displacement to be determine on the fly whether or not a 16-bit displacement is absolutely necessary.