Page 1 of 1

How to write compiled code to a file

Posted: Sat Dec 30, 2023 1:35 pm
by rndrei
This is code not worked!?

Code: Select all

If CreateFile(0, "dump.obj")
  WriteData(0, ?ObjfileDataStart, ?ObjfileDataEnd - ?ObjfileDataStart)
  CloseFile(0)
Else
  MessageRequester("Error creating file", "Unable to create included data")
EndIf
End

ObjfileDataStart:
msg.s="Hello world!"
! mov rax,1 
! mov rdi,1
! mov rsi,[v_msg]
! mov rdx,24
! syscall
End
ObjfileDataEnd:

Re: How to write compiled code to a file

Posted: Sat Dec 30, 2023 2:21 pm
by infratec
It works. There is no error message and a file is created and filled.

But it depends what you expect.

The stuff in a datasection is not 'compiled'.
You can not expect to create a working code.
Or yoiu have to use data.a and the opcodes of your assembler commands.