I happen to use
Code: Select all
call label
label: pop eax
If it is 16 bit code it's pop ax.
Code: Select all
call label
label: pop eax
80x86 does have "[esp]" addressing modes, and will even handle something like "mov eax,[esp+ebx*4+12345]".LoseThos wrote:The x86 does not have [esp] addressing modes. That's on VAXs and stuff. x86 has [RBP]
This is about branch prediction - think of a RET instruction as "jmp [esp]; add esp,4" and you'll realize that RET *is* an unconditional branch. You won't find a pipeline stall or anything where this code is, but you will find problems later. For example:LoseThos wrote:I happen to useI have had problems with pipelining in similar situations on older pentium series machines, but this call/pop hasn't presented problems. I don't remember if I stuck code between the call and label. I think I did, but I don't think it matters.Code: Select all
call label label: pop eax
Code: Select all
main:
call foo
ret ;Branch mis-prediction here because CPU's "return address stack" was trashed
foo:
call bar
ret ;Branch mis-prediction here because CPU's "return address stack" was trashed
bar:
nop
nop
call .label
.label:
pop eax ;No problem here
nop
nop
nop
ret ;Branch mis-prediction here because CPU's "return address stack" was trashed
Intel wrote:Inlining, Calls and Returns
The return address stack mechanism augments the static and dynamic predictors to optimize specifically for calls and returns. [Some stuff skipped]
To enable the use of the return stack mechanism, calls and returns must be matched in pairs. If this is done, the likelihood of exceeding the stack depth in a manner that will impact performance is very low.
Assembler/Compiler Coding Rule 4. (MH impact, MH generality) Near calls must be matched with near returns, and far calls must be matched with far returns. Pushing the return address on the stack and jumping to the routine to be called is not recommended since it creates a mismatch in calls and returns.
y beginning to enliven the
valleys again, and no doubt the marriage will take place in the cool of
the morning, and not in the heat of the afternoon."
Sancho did as his master bade him, and putting the saddle on Rocinante
and the pack-saddle on Dapple, they both mounted and at a leisurely pace
entered the arcade. The first thing that presented itself to Sancho's
eyes was a whole ox spitted on a whole elm tree, and in the fire at which
it was to be roasted there was burning a middling-sized mountai
Intel's 80x86 CPUs have had a return address stack since Pentium (1993) and possibly earlier. Other 80x86 CPU manufacturers do the same thing, including AMD and Cyrix (who stopped making CPUs a long time ago). I didn't bother doing much research though - it's an obvious optimization that I'd expect all current CPU manufacturers for all CISC CPUs use. IMHO it's also an obvious optimization that will never disappear.LoseThos wrote:What this really is about is you trying to trap me into something. I wrote my own bootloader and used call pop. It relocates itself. You are some paranoid person of bare metal hardware and feel threatened by my boot loader doing bare metal.
You are trying to entrap me. I said x86. On the first generations, call pop worked. Intel changed the rules. They can change them in the future.
LoseThos wrote:I experienced problems with an indirect call mechanism which placed the funcation address on the stack and called indirectly
For the record, I've never downloaded any version of your OS. My original comments were about consequences anybody can expect - it's like seeing someone standing in the rain and telling them they'll get wet - some things are easy to predict.LoseThos wrote:You downloaded some of the old versions of losethos and saw that.
God says that if you're not smart enough to write a rational response, just make up stuff that has nothing to do with anything...LoseThos wrote:God says...
Code: Select all
call .label
.label:
pop eax
Code: Select all
.eip2eax:
pop eax
push eax
ret
; ...
call .eip2eax
Pwned.Brendan wrote:God says that if you're not smart enough to write a rational response, just make up stuff that has nothing to do with anything...LoseThos wrote:God says...
Funny enough, this is actually a passage from the English translation of Don Quixote. Chapter 20, paragraph 7.LoseThos wrote: y beginning to enliven the
valleys again, and no doubt the marriage will take place in the cool of
the morning, and not in the heat of the afternoon."
Sancho did as his master bade him, and putting the saddle on Rocinante
and the pack-saddle on Dapple, they both mounted and at a leisurely pace
entered the arcade. The first thing that presented itself to Sancho's
eyes was a whole ox spitted on a whole elm tree, and in the fire at which
it was to be roasted there was burning a middling-sized mountai
Or copy paste it from the internet.Brendan wrote: God says that if you're not smart enough to write a rational response, just make up stuff that has nothing to do with anything...
Oh dear "God" he's quoting the bible again. Good thing it was split and it's not in my thread.Love4Boobies wrote:Pwned.Brendan wrote:God says that if you're not smart enough to write a rational response, just make up stuff that has nothing to do with anything...LoseThos wrote:God says...
ROFLMAO!Funny enough, this is actually a passage from the English translation of Don Quixote. Chapter 20, paragraph 7.