1

I am building an LC3 Virtual Machine in C, but one problem that I am facing is that it takes in only .obj files as input. How am I to convert any file that I write in C into a .obj file in order to run it through the Virtual Machine

  • Hi, what compiler are you using ? Also, what do you understand of the compilation / building process (do you know what an `obj` file is) ? – limserhane Jun 15 '22 at 08:47
  • As long as the format is correct, you can simply rename a.o to a.obj, if we look only at the extensions. But as you say you want to run a program, you might need to rename the executable file. However, a.exe might not be the correct format. Make sure you understand the building process. – the busybee Jun 15 '22 at 09:00
  • Isn't the purpose of lc3 that you should write the assembly by hand? I guess you could read this though: [compiling C for LC3](https://www.cemgokmen.com/programming/2018-10-10-compiling-C-for-LC3/) – Ted Lyngmo Jun 15 '22 at 09:09
  • What is an .obj file? – user253751 Jun 15 '22 at 09:12
  • when you said "building a virtual machine" does that mean you are writing it, or someone else wrote it and you are compiling it? – user253751 Jun 15 '22 at 09:13
  • 1
    In order to run a C program on a machine (any machine), you need a C compiler that targets that machine. Do you have a C compiler that targets LC3? You probably can find one if you search hard enough. In order to run a binary program on a different kind of machine (e.g. run an .exe from your Windows machine on an LC3), you need a binary-to-binary translator or an emulator. I doubt you can find one that target LC3. – n. m. could be an AI Jun 15 '22 at 09:13

0 Answers0