1

I have an assembly language code where I switch to protected mode and print "Hello World " on the screen afterwards. I have saved this code in a file named boot2.asm. I need help in running and testing the code as I am unable to do so by the command given by the original coder himself.

The command I use is:

nasm -f bin boot2.asm && qemu-system-x86_64 -fda boot.bin

I should run this command in cmd, right? I have NASM and QEMU installed in my computer as well.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • `nasm` is going to produce an output file named `boot2.bin` I think, but you seem to boot a file named `boot.bin`. Are you sure this is correct? – fuz Dec 19 '20 at 18:30
  • I tried creating boot2.bin bit it says, "qemu-system-x86_64: -fda boot2.bin: Could not open 'boot2.bin': The system cannot find the file specified." I am using cmd to run this btw, after switching to the desktop folder where the file is – xxxxxxxxxxxxxx Dec 19 '20 at 18:38
  • it did make a file named boot2 without .bin extension, then I added the extension manually and executed qemu command, worked fine except the fact that it was supposed to print out two things instead of just one, I am adding the code to the question itself, see if you can help with it – xxxxxxxxxxxxxx Dec 19 '20 at 18:42
  • 1
    You need `-o boot2.bin` for NASM otherwise it outputs into `boot2` (no `.bin`). – ecm Dec 19 '20 at 18:42
  • 1
    @xxxxxxxxxxxxxx Please only ask one question per question. Your original problem has been resolved. Consider making a new question for your new question. Also, if you expect people to help you with your code, explain what the code is supposed to do and comment it! Without comments, it's very hard to understand your logic. – fuz Dec 19 '20 at 18:53
  • ok sir will do. @fuz – xxxxxxxxxxxxxx Dec 19 '20 at 18:57

1 Answers1

3

If you want to create a file named boot.bin from a file boot2.asm, nasm needs to be directed to do so by means of a -o boot.bin option. Otherwise, nasm just produces a file named boot2 which is not what you want. So the fixed command line is

nasm -f bin -o boot.bin boot2.asm && qemu-system-x86_64 -fda boot.bin

Refer to the nasm manual for further information.

fuz
  • 88,405
  • 25
  • 200
  • 352