flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM write failed message (possibly bug in X86_64.INC)

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
I have problems while compiling many times with error messages.
I get the error "write failed" after several compilations with errors and cleaning and new errors and new cleaning.
As I found this could be caused by an open file but also when there are problems with memory (compiled file sizes).

Maybe there is also a problem with heap, I found this code snippet in X86_64.INC):

Code:
basic_instruction:
    mov     [base_code],al
      lods    byte [esi]
  call    get_size_operator
   cmp     al,10h
      je      basic_reg
   cmp     al,'['
        jne     invalid_operand
      basic_mem:
     call    get_address
 push    edx ebx ecx
 lods    byte [esi]
  cmp     al,','
    jne     invalid_operand
     lods    byte [esi]
  call    get_size_operator
   cmp     al,'('
        je      basic_mem_imm
       cmp     al,10h
      jne     invalid_operand
      basic_mem_reg:
 lods    byte [esi]
  call    convert_register
    mov     [postbyte_register],al
      pop     ecx ebx edx
 mov     al,ah
       cmp     al,1
        je      instruction_ready
   call    operand_autodetect
  inc     [base_code]
    


As you can see, second line of basic_mem: pushes 3 registers on stack and releases with pop about 20 lines of code later. In the meanwhile there is a error handling and jump to error handler without cleaning the stack.

Maybe this could cause the problem ?
Sometimes I have to restart FASM, sometimes it won't help but killing the thread in task manager. After restart FASM compiles the same file without any changes without problems (no write failed message).

Does anyone had this kind of problem ?
I think is only showing up when there are many errors processed.
I use trial and error while adapting to Z80 instruction set.
I took several functions of X86_64 code and wonder if the jumps between push and pop are wanted ? Shocked
Post 26 Nov 2011, 23:16
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
fasm's error handling is exception-like, the error can be signaled at any time, the stack cleanup is usually not necessary because the compiling process or thread is ended, and where the single-threaded program needs to continue, as in FASMD, the stack pointer is restored manually to its initial state.

As for the "write error", it is usually related to something locking the output file (like the program still running), I don't know what could be the reason in your case. Are you able to find some steps to reproduce it consistently? Is the problem happening with FASMW?

As a side note: If this is a problem specific to FASMW, then the report should go to "IDE development".
Post 26 Nov 2011, 23:52
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

shutdownall, upload your file.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 27 Nov 2011, 00:08
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
It usually happens when you forget to call PostQuitMessage in your WM_DESTROY case. If you writing for Windows.
Post 27 Nov 2011, 11:29
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
1. The problem is with FASMW (IDE version) - I will open a new thread there.
2. I thought that maybe stack would be restored in another way after stopping program but was not sure. I just found this while porting the code to Z80 instructions.

Quote:
shutdownall, upload your file.


I think this is not really a necessary step because it's an internal error of FASMW. The maybe interesting point is that I compile a FASMW source file with modified components which has the same name FASMW but is in another directory. Only changed components are tables.inc and load a z80.inc instead of a x86_64.inc. Anyway this error should not happen regardless which software I compile because it's in the inside of FASMW and don not must happen at all.

It's not very stable, I can reproduce it when it happens till I close the FASMW compiling the other FASMW but can not reproduce stable. Sometimes it is working after restart, sometimes I have to kill FASMW in the task manager because after a new start of FASMW the error is still there. When stopped over task manager the Z80 version of FASMW is compiled without change of my source without error. So I would say there is not an error in my source.

Of course I close always the Z80 version of FASMW. So maybe FASMW is still thinking FASMW Z80 version is still running but is always closed via right mouse click "close" which should be similar to ALT-F4.

I thought it has to do with size of code but as I stripped many lines from x86_64.inc (which is about 143kB, z80.inc is about 99kB). I also changed memory in options => compiler setup => memory from 16kB to maximum 64kb but this does not affect the problem.

Maybe any more ideas ?
Post 27 Nov 2011, 14:23
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Post 27 Nov 2011, 14:26
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.