I have written a small 16-bit assembly program that writes some values in some memory locations.Is there a way I can test it in 32-bit protected mode on Linux?
Asked
Active
Viewed 2,212 times
3

Ciro Santilli OurBigBook.com
- 347,512
- 102
- 1,199
- 985

vjain27
- 3,514
- 9
- 41
- 60
-
2what instruction set architecture? avr? msp430? 8088? 8086? thumb? 16 bit mips?... – old_timer Oct 20 '11 at 00:52
-
8086. I was trying to write real mode code.It contains only some movw statements. – vjain27 Oct 20 '11 at 16:48
-
ad pcemu to the list that Yahn provided. – old_timer Oct 20 '11 at 17:17
2 Answers
7

Yann Ramin
- 32,895
- 3
- 59
- 82
-
Concrete examples: https://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system/32483545#32483545 – Ciro Santilli OurBigBook.com May 07 '18 at 09:29
4
Yes, 16-bit code is supported in user processes in Linux. The system call to do it is called vm86()
(there's a man page, but there's not much in it). It is, naturally, only works on x86 platforms (and 32-bit only).
If you want an example, the ELKS project has a complete tool for running ELKS 8086 binaries on Linux, which uses it:
https://github.com/lkundrak/dev86/tree/master/elksemu
Look for the run_elks()
function. It's pretty straightforward.

David Given
- 13,277
- 9
- 76
- 123
-
-
3@CiroSantilli包子露宪六四事件法轮功 v86 mode isn't supported inside x86-64 native mode. To implement this syscall, Linux would have to switch to 32-bit mode, only then to v86, which would be too much of an overhead for small benefit. But then, there's a [V86-64](http://v86-64.sourceforge.net/) patch (last updated in 2008). – Ruslan May 08 '18 at 13:40