0

This is my source code:

mov byte [gs:0x00],'h'
mov byte [gs:0x01],0x04
mov byte [gs:0x02],'e'
mov byte [gs:0x03],0x04
mov byte [gs:0x04],'l'
mov byte [gs:0x05],0x04
mov byte [gs:0x06],'l'
mov byte [gs:0x07],0x04
mov byte [gs:0x08],'o'
mov byte [gs:0x09],0x04

jmp near $

I put it in MBR.

When I execute this with qemu-system-i386 -m 32 -smp 2 -enable-kvm -hda $(DISK) -nographic, I cannot find the string printed on the terminal.

But I can find it on Windows using gvncviewer to see QEMU's window when I start it without -nographic.

My qemu-system-i386 is version 7.2.0.


Ok, maybe I'm misunderstanding what -nographic does. Then how do I print text directly on the terminal?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
MEssa
  • 21
  • 2
  • The way I read it, `-nographic` explicitly turns off video output, not sure why you expect to get it printed. The serial port is redirected to the console in this case. – Jester Feb 22 '23 at 12:50
  • 1
    Doing some creative guessing, I assume you're trying to write those values directly to the (text-mode) graphics memory to be displayed. If you disable graphical display with `-nographic` then why would you expect to see the result? AFAIK with `-nographic` you will only see the serial port output. – Joachim Sauer Feb 22 '23 at 12:50
  • Your code is missing the part where you set up `GS` to point to the frame buffer. Please post a [mcve] that doesn't leave out any bits needed to reproduce the problem. – fuz Feb 22 '23 at 12:52
  • Yeah, maybe I misunderstood what "-nographic" does. Then how do I print text directly on the terminal. – MEssa Feb 22 '23 at 13:39
  • 1
    Try `-display curses`. Note that you will be unable to quit the VM from its terminal, you will have to kill the process from another terminal. – ecm Feb 22 '23 at 13:43
  • 1
    @MEssa Either use `-display curses` or write text to the serial console (using the [INT 14h](http://www.techhelpmanual.com/206-int_14h__serial_port_i_o.html) family of calls). – fuz Feb 22 '23 at 15:49

1 Answers1

2

Use -display curses, but you will be unable to quit the VM from its terminal, only with kill.


or use Alt-2 change to qemu command line then enter quit.

Thank you @ecm.

MEssa
  • 21
  • 2
  • 1
    Actually I found you can enter Alt+2 then the command `quit` to quit from the qemu terminal. Searching I first found https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui which links to https://stackoverflow.com/questions/14165158/how-to-switch-to-qemu-monitor-console-when-running-with-curses where a comment states "Note: Alt+1, Alt+2 still work," – ecm Feb 22 '23 at 14:04