1
\$\begingroup\$

Imagine you're submitting a full program (as opposed to a function) written in assembly / machine code. You'll want to submit it as machine code (with the appropriate processor and target system) because there's a 1:1 mapping, but the machine code format is much more concise.

In this answer, it's suggested to submit a function, because some executable format would add a lot of boilerplate. My question is: Does this boilerplate really count to the bytes for a machine code submission?

I recently submitted some C64 machine code and with the very simple executable format of the C64, the difference is only two bytes: The load address of the code is in the first two bytes of the executable file. Before finding the question I linked, I assumed those two bytes are not part of the program. Am I wrong here?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Depends on implementation

  • Yes, if they're required for your program to be valid in your implementation.

  • No, if removing them will not cause any harm while using your implementation.

That is, well, since a language is defined by its implementation. And yes, machine code may have different implementations across different CPUs, architectures and operating systems.

\$\endgroup\$
2
\$\begingroup\$

Yes.

To be a full program, it must contain all of the boilerplate required for your compiler to produce an executable or for your interpreter to run it. In the case of machine code submissions, the "interpreter" operates on executable files. Therefore you must include the boilerplate of the executable file.

\$\endgroup\$
4
  • \$\begingroup\$ The reason I'm not entirely convinced about this is: My tool for creating an executable file from the plain machine code is a linker, very much like the tool for creating the executable file from C source is a compiler. How would you draw the difference here? For the time being, I'll edit my submission to include the 2-byte load address anyways, thanks for your answer so far. \$\endgroup\$ Commented Aug 8, 2017 at 12:18
  • \$\begingroup\$ Hmm. Maybe the question is broader than it seems and the answer depends on the details of the toolchain. \$\endgroup\$ Commented Aug 8, 2017 at 12:48
  • 3
    \$\begingroup\$ @FelixPalmen This may seem pedantic, but there are really two languages here: One that is passed into your linker, and one that is passed into your computer. A similar example is with Java and the JVM. Java produces bytecode, which is then executed on the JVM. There are two languages here: Java and bytecode. If you program in Java, you don't count the bytecode bytes. \$\endgroup\$ Commented Aug 8, 2017 at 13:15
  • \$\begingroup\$ Maybe then it would make sense to say that you can submit the plain machine code if there is a tool that takes it as input and emits an executable file suitable for the target platform containing this machine code? \$\endgroup\$ Commented Aug 8, 2017 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .