I am having trouble displaying simple text. I am trying to do it all in machine code with INT 10h, but:

  1. I can't find the binary opcode for INT 10h anywhere in the Intel Manual.

  2. I can't figure out how to load the binary ASCII representation of "Hello world!" in to the data segment register (DS, which needs 12 bytes of data to represent the full text data).

I considered doing it by writing directly to memory-mapped VGA memory, but that appeared harder than using interrupts from BIOS. And I'm not fully knowledgeable on this full scope of how that'd work.

Can anyone help me sort this out here, please? I don't need help with x86 instructions per se, but with how I'd encode this all in binary properly, and where to find all interrupts' opcodes.

  • You might want to read: wiki.osdev.org/Main_Page Grab an Ascii table for figuring out the binairy code for the ascii string. Also, the title is a bit weird. As there have been 16-bit bootloaders, remember windows3.11 for example. Lastly, this should be on stack overflow. For RE-SE (this one) I'd recommend you try to reverse a 16-bit bootloader :)
    – Stolas
    Jan 29, 2014 at 8:13

2 Answers 2

  1. To call an interrupt, you'll probably want to use int imm8 which is encoded as 0xcd, 0xnn (0x10 in this case).

  2. For bootloaders, it's pretty common to stick the data in between the jmp at the start of the bootloader and its target. You don't really need to mess around with ds unless you're making a very large bootloader (which loads additional sectors from disk).

For an interrupt reference, should you need such a thing, I'd probably suggest Ralph Browns Interrupt List.


Regarding (2), you don't load the entire string into the segment register, you take the selector for the memory region that holds the string, and place that into the segment register. For 16-bit bootloader environment, it's probably going to be the same as CS, so you just push cs, pop ds (though usually cs=ds=es=ss already on startup, anyway).

To write to the video memory, just load 0xb800 into es, and then the brute-force way to write to the screen looks like:

mov es:[0], 'H'
mov es:[2], 'e'
mov es:[4], 'l'
mov es:[6], 'l'
mov es:[8], 'o'

And, so on. This is not the optimal way, of course. Normally, you would use a loop and a string operation, or just use the BIOS calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.