Results 1 to 9 of 9

Thread: ASM includes broken in fpc 3.0.4 / x86_64

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sorry, I delayed investigating this problem for much later, when I have 32-bit version of my engine running many real tasks without glitching or crashing.

    Add to that I install my own SEH handler for Win32, which I had to change to VEH handler for Win64...
    Add to that that I use pointer arithmetics in many places and had since weeded out several coding horrors via simple search for "cardinal" keyword...
    No, this was probably stupid me crying wolf because of trashed memory elsewhere

  2. #2
    No need to apologize, glad you managed to fix the issue - one sad panda less in the world

  3. #3
    PGDCE Developer de_jean_7777's Avatar
    Join Date
    Nov 2006
    Location
    Bosnia and Herzegovina (Herzegovina)
    Posts
    287
    Quote Originally Posted by Chebmaster View Post
    No, this was probably stupid me crying wolf because of trashed memory elsewhere
    Too often this is the case for me too, where weird behavior is because I trashed memory due to the hacks I employ. A lot less of these nowadays, but still can cause a lot of hours wasted because of memory mismanagement
    Existence is pain

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •