How to handle forward referencing when Label size is not fixed

  assembly, c++, emu8086, x86

I am trying to write 8086 Emulator in C++.
But I am facing a problem.

Suppose the code is:

MOV AL, BL
JMP X
MOV BL, CL
MOV DL, CL
.
.
.
X:
ADD AX, BX
HLT

Now the machine code for JMP X will depend on X, whether it is near location or short location

near: 8Bit Address[00-ff]

short: 16Bit Address(ff-ffff]

So if the size of the JMP instruction used to be constant(fixed size)than I can just move further and whenever I will find X I can just put it’s address back.
But here I can’t move further because next location is also depending on JMP X and whose size is not fixed.

I have no idea how to deal with it.

Source: Windows Questions C++

LEAVE A COMMENT