How to write compiled code to a file

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 185
Joined: Thu Dec 28, 2023 9:04 pm

How to write compiled code to a file

Post 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:
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: How to write compiled code to a file

Post 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.
Post Reply