flat assembler
Message board for the users of flat assembler.
Index
> Windows > How implement ring buffer on fasm ? |
Author |
|
bitRAKE 16 Oct 2022, 16:36
It's possible to create a circular mapping of memory.
This should greatly simplify algorithms to avoid boundary logic. If the buffer is to be used by external libraries, this method also make the least assumption of them. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Oct 2022, 16:36 |
|
Roman 16 Oct 2022, 19:59
My variant:
Code: macro RingApply v,b { local .a,.b,.up mov eax,v movd xmm1,eax mov rax,RingBuffer mov r14,rax add eax,[Ring_w] mov r13,[rdx] ;input float data xor r11,r11 .up: movss xmm0,[r13+r11*4] mulss xmm0,xmm1 movss [rax+r11*4],xmm0 inc r11 cmp r11d,200 jb .up add [Ring_w],256*4 cmp [Ring_w],256*4*b jb .a mov [Ring_w],0 .a: add r14d,[Ring_r] add [Ring_r],256*4 cmp [Ring_r],256*4*b jb .b mov [Ring_r],0 .b: } Ring_start = 60;1 to Ring_Max-2 Ring_Max = 62 RingApply 0.94,Ring_Max-2 ;data RingBuffer dd 256*Ring_Max dup(0) Ring_r dd 0 Ring_w dd 256*4*Ring_start |
|||
16 Oct 2022, 19:59 |
|
Furs 17 Oct 2022, 13:29
bitRAKE wrote: It's possible to create a circular mapping of memory. To be fair you can create ring buffer without it as well. The only issue is that you'll have a race so it's possible for the second alloc to fail, and you'll have to retry (possibly infinitely). I guess not a big problem if you suspend all threads or something, but not doable if not (or if you use it in a library). |
|||
17 Oct 2022, 13:29 |
|
bitRAKE 17 Oct 2022, 22:49
Allocating under 4GB addresses is the same way - could have been done before - just more reliable on Win10+ with VirtualAlloc2.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
17 Oct 2022, 22:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.