tgrysztar / fasmg

flat assembler g - adaptable assembly engine
https://flatassembler.net/
216 stars 29 forks source link

duplicate lines? #10

Closed bitRAKE closed 2 years ago

bitRAKE commented 2 years ago

https://github.com/tgrysztar/fasmg/blob/e6f827d605b42ec8bd3be39d83aeb5ec65125f64/core/source/malloc.inc#L213-L218

Duplicate lines look superfluous?

bitRAKE commented 2 years ago

In hindsight this might be to catch a corner case I'm not seeing.

ghost commented 2 years ago

Do you want it to be optimized in this way?

macro mov_ecx_mov_edx_value_offset_ebx_plus_FreeMemory_left_right {
    mov ecx,[ebx+FreeMemory.left] 
    mov edx,[ebx+FreeMemory.right] 
}

; ...

    mov_ecx_mov_edx_value_offset_ebx_plus_FreeMemory_left_right
    mov [ecx+FreeMemory.right],eax 
    mov [edx+FreeMemory.left],eax 
    mov_ecx_mov_edx_value_offset_ebx_plus_FreeMemory_left_right
bitRAKE commented 2 years ago

I was thinking that loading ECX/EDX again was not needed. I guess there is a situation where the nodes pointed to by ECX/EDX could also be the node pointed to by EBX?

ghost commented 2 years ago

I think this was done because of some technical quirk. Try compiling and running without the second pair and see what happens.