So I've found *yet another* chunk of assembly code I botched porting from i386 to x86_64. Which compiles and works in 64-bit compatibility mode (all addresses limited to the lower 4Gb) that is only only generated using fpc 2.6.4 when you set debugging info to stabs) but trashes memory happily in true 64-bit addressing mode (because, as I was informed, most of MOV variations silently clip the address to its lower 32 bits unless the register you move to/from memory is RAX/EAX).
Namely, instead of
Code:
asm
mov rax, [pes]
mov rbx, rax
mov rax, qword[rbx + TMotherSEHState.tlitsc]
mov rcx, rax
xor rax, rax
rdtsc
shl rdx, 32
or rax, rdx
mov qword[rbx + TMotherSEHState.tlitsc], rax;
sub rax, rcx
mov rdx, rax
xor rax, rax
mov eax, dword[rbx + TMotherSEHState.tlic]
mov ecx, eax
mov rax, rdx
add qword[rbx + rcx * 8 + TMotherSEHState.tli], rax
end ['rax', 'rcx', 'rdx', 'rbx'];
I had this heresy:
Code:
asm
mov rbx, [pes]
mov rcx, qword[rbx + TMotherSEHState.tlitsc]
mov eax, 0
rdtsc
mov dword[rbx + TMotherSEHState.tlitsc], eax;
mov dword[rbx + 4 + TMotherSEHState.tlitsc], edx;
shl rdx, 32
add rdx, rax
sub rdx, rcx
xor rcx, rcx
mov ecx, dword[rbx + TMotherSEHState.tlic]
add qword[rbx + rcx * 8 + TMotherSEHState.tli], rdx
end ['rax', 'rcx', 'rdx', 'rbx'];
I hope this compiles and works when my project compiles again.
Bookmarks