Mosa.Platform.x86.MachineCodeEmitter.EmitRelativeBranchTarget C# (CSharp) Method

EmitRelativeBranchTarget() private method

Emits the relative branch target.
private EmitRelativeBranchTarget ( int label ) : void
label int The label.
return void
        private void EmitRelativeBranchTarget(int label)
        {
            // The relative offset of the label
            int relOffset = 0;

            // The position in the code stream of the label
            int position;

            // Did we see the label?
            if (TryGetLabel(label, out position))
            {
                // Yes, calculate the relative offset
                relOffset = position - ((int)codeStream.Position + 4);
            }
            else
            {
                // Forward jump, we can't resolve yet - store a patch
                AddPatch(label, (int)codeStream.Position);
            }

            // Emit the relative jump offset (zero if we don't know it yet!)
            codeStream.Write(relOffset, Endianness.Little);
        }