Fixed problem of nasm defaulting all conditional branches to short which often generates an error. Now all jumps are near.

This commit is contained in:
kudzu_cp 2008-09-17 00:45:25 +00:00
parent 1e9de4bb90
commit 65381e63a5

View file

@ -8,13 +8,19 @@ namespace Indy.IL2CPU.Assembler.X86 {
public readonly string Address; public readonly string Address;
protected JumpBase(string aAddress) { protected JumpBase(string aAddress) {
if (aAddress.StartsWith(".")) {
aAddress = Label.LastFullLabel + "__DOT__" + aAddress.Substring(1);
}
// If it has a :, then its a far call so dont add near
if (aAddress.Contains(':')) {
Address = aAddress; Address = aAddress;
if (Address.StartsWith(".")) { } else {
//string xPrefix = (from item in Assembler.CurrentInstance.Instructions // Nasm by default issues conditional branches as short
// where !Label.GetLabel(item).StartsWith(".") // and we often exceed the distance
// select Label.GetLabel(item)).Last(); // For now we go for simplicity. Later when we optimize and have
string xPrefix = Label.LastFullLabel; // our own assembler, we should consider using short jumps
Address = xPrefix + "__DOT__" + Address.Substring(1); // if they are faster
Address = "near " + aAddress;
} }
} }
} }