flat assembler
Message board for the users of flat assembler.
Index
> Main > [fasmg] sad spinlock |
Author |
|
sylware 24 Jan 2023, 14:16
no "pause" machine instruction in the standard distribution or I did grep like an animal?
|
|||
24 Jan 2023, 14:16 |
|
sylware 24 Jan 2023, 14:39
Are you going to add "pause" to fasmg distribution?
|
|||
24 Jan 2023, 14:39 |
|
Tomasz Grysztar 24 Jan 2023, 14:46
I don't know, there's lot of things I could add, I focus on ones I personally find the most valuable. The idea was, once everything is easily customizable, then it should be relatively easy for others to implement instruction sets they require when I'm not up to the task.
|
|||
24 Jan 2023, 14:46 |
|
revolution 24 Jan 2023, 14:51
Code: pause equ db 0xf3, 0x90 |
|||
24 Jan 2023, 14:51 |
|
sylware 24 Jan 2023, 14:53
Well, if you don't use spin locks... that's not going to be very valuable
|
|||
24 Jan 2023, 14:53 |
|
sylware 24 Jan 2023, 14:59
@revolution I was thinking it was mistakenly missing from the official distribution. Because using spinlocks is quite common in parallel programming and the "right" implementation on x86_64 uses the pause machine instruction.
|
|||
24 Jan 2023, 14:59 |
|
revolution 24 Jan 2023, 15:07
PAUSE was first defined on the P4. So even 32-bit code can benefit from it.
Older CPUs just see rep nop, no benefit for them, but also no harm. |
|||
24 Jan 2023, 15:07 |
|
FlierMate11 24 Jan 2023, 15:45
I insert "rep nop" in FASM source file, but compiled program is disassembled as "pause".
So revolution is right.
|
||||||||||
24 Jan 2023, 15:45 |
|
macomics 24 Jan 2023, 15:54
Your debugger does not allow you to choose the disassembly mode. Open the program in IDA Pro and select different processors. Before Pentium 4, you will be issued a rep nop
ADD: You also assemble the sequence Code: rep xchg eax, eax |
|||
24 Jan 2023, 15:54 |
|
FlierMate11 24 Jan 2023, 16:12
macomics wrote:
Yeah, I see it now, is it designed this way?
|
||||||||||
24 Jan 2023, 16:12 |
|
revolution 24 Jan 2023, 16:23
Note that xchg eax,eax encoded as 0x90 is not valid for x64 code. It is a true nop and won't zero the upper 32-bits of rax.
In 64-bit code use db 0x87, 0xc0. |
|||
24 Jan 2023, 16:23 |
|
DimonSoft 26 Jan 2023, 08:11
revolution wrote:
Wouldn’t a macro be a better solution? pause probably shouldn’t be used everywhere, just in places where an instruction name is allowed. (I completely ignore the fasmg branch, so may miss something here.) |
|||
26 Jan 2023, 08:11 |
|
revolution 26 Jan 2023, 08:17
I suppose a macro would be better. But I don't know the fasmg syntax for macros so I just took the easy path and posted what I do know.
|
|||
26 Jan 2023, 08:17 |
|
Tomasz Grysztar 26 Jan 2023, 09:04
revolution wrote: I suppose a macro would be better. But I don't know the fasmg syntax for macros so I just took the easy path and posted what I do know. |
|||
26 Jan 2023, 09:04 |
|
revolution 26 Jan 2023, 09:11
Okay. I cheated to took the 8087.inc as a template and made this:
Code: macro pause? db 0xf3, 0x90 end macro What is the ? for? |
|||
26 Jan 2023, 09:11 |
|
Tomasz Grysztar 26 Jan 2023, 09:19
revolution wrote: I have no idea if it works or not. revolution wrote: What is the ? for? PS. Also, usually you can adapt fasmg to work the way you need: Code: pause? equ db 0xf3, 0x90 calminstruction ? line& transform line assemble line end calminstruction pause PPS. Actually, I forgot I have a better option now: Code: calminstruction ?? line& transform line assemble line end calminstruction pause? equ db 0xf3, 0x90 pause pause? equ db 0F3h, 90h pause Last edited by Tomasz Grysztar on 26 Jan 2023, 09:48; edited 2 times in total |
|||
26 Jan 2023, 09:19 |
|
revolution 26 Jan 2023, 09:25
Tomasz Grysztar wrote: You actually reproduced the macro I posted in the beginning of this thread. Tomasz Grysztar wrote:
|
|||
26 Jan 2023, 09:25 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.