flat assembler
Message board for the users of flat assembler.
Index
> Windows > How do I read a file byte by byte? Goto page Previous 1, 2 |
Author |
|
Roman 27 May 2020, 12:39
I heard jmp and jr knocks down CPU conveyor
Good do one jr or jmp. Bad method do more then one jmp\jnz\jz\jae\jbe |
|||
27 May 2020, 12:39 |
|
bitRAKE 27 May 2020, 13:19
Study the BTB (Branch Target/Tag Buffer) it's how the processor predicts where to go next. Multiple Jcc close together can be a performance problem - as far as I can remember JMP has no penalty 100% predicted obviously.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 May 2020, 13:19 |
|
revolution 27 May 2020, 13:35
Forget about trying to predict what the BTB predictor will do. Really! It's a fools game to go down that path. It might give you a vague idea about things, but not much more. With over 100 instructions in flight at any one time inside the CPU there is just too much happening to predict any of this statically by simply looking at the code by eye and counting clock cycles or something. Hehe, well unless you are still using an old P3 system, then maybe you can get away with it there.
Test your code to see what happens when it runs for real. No need to guess, when you can know for sure by running it and seeing what happens. |
|||
27 May 2020, 13:35 |
|
bitRAKE 27 May 2020, 15:00
It was more about branch locality than trying to predict the processor. There are a limited number of bits to indicate where the Jcc instruction is. If there are too many branches in a small region of memory this can artificially slow things down.
All this is very academic at the extreme edge of optimization. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 May 2020, 15:00 |
|
bitRAKE 29 May 2020, 01:28
As a concrete example, assume we want to execute some function, but only if a file/folder exists:
Code: lea rcx,[folderW] call [GetFileAttributesW] test eax,FILE_ATTRIBUTE_DIRECTORY lea ecx,[rax+2] ; check for error INVALID_FILE_ATTRIBUTES loopnz execute_function_on_folder ; fall through for multiple error conditions _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
29 May 2020, 01:28 |
|
Roman 30 May 2020, 06:18
I read https://www.agner.org/optimize/instruction_tables.pdf
Call far take 16-22 CPU cycles (for modern CPU its about 16 nanoseconds) JMP far take 16-20 CPU cycles Jcc take 1-2 CPU cycles Question in Fasm 64 bit invoke do far Call ? |
|||
30 May 2020, 06:18 |
|
revolution 30 May 2020, 06:38
Roman wrote: I read https://www.agner.org/optimize/instruction_tables.pdf |
|||
30 May 2020, 06:38 |
|
Furs 30 May 2020, 15:00
Actually aren't far calls used to switch between 32-bit and 64-bit code?
|
|||
30 May 2020, 15:00 |
|
Ali.Z 30 May 2020, 18:36
Furs wrote: Actually aren't far calls used to switch between 32-bit and 64-bit code? so does far jmps. _________________ Asm For Wise Humans |
|||
30 May 2020, 18:36 |
|
Roman 30 May 2020, 19:21
|
|||
30 May 2020, 19:21 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.