16-bit asm instruction set

What set of instructions is used in COM files? I assumed that it was 8086, but it seems that I was wrong. In the 8086 manual I found, shl can only take 1 or cl for its second argument, while immediate values โ€‹โ€‹other than 1 work fine for me. In case that matters, I use NASM.
Thank you for your time.

+7
source share
3 answers

This is one of those fun questions, and, as always, the answers are misleading.

a true DOS COM file has no headers and should fit inside one memory segment because it did not have moving information, DOS had to put the file where it was needed, and therefore the only true way to be compatible (with x86) was to use assembly compatible with 8086. Edit: To clarify this, this is because the 8086 did not have memory pages.

You could compile on operands 286/386, as soon as the program is launched, there is no runtime in DOS to stop you and say "no, you cannot do this, this is instruction 386".

Which, oddly enough, is part of the reason COM files do not work very often on Windows7 x32, or even on Windows7 x64.

Because DOS worked, command.com was unloaded during the execution of your .com file and subsequently reloaded, so essentially your .com file could access all system memory, and theoretically use DOS memory extensions such as Phar lap DOS / 4GW and CWSDPMI.

In short; you can use any commands that the current system could support, but you should only use 16-bit x86 compatible commands.

If the above sounds like PITA, this is because it was, I remember :) This is also why the .EXE format is very popular very quickly.

+9
source

Real COM (I will not go into COM, which are actually EXE, etc.) just means that it is a simple DOS executable. Any set of instructions is available. I used to do DOS programming (both COM and EXE) on 8088 to i486 in one day, and any instructions are legal in this mode, you can use. For example, I often used 32-bit string instructions and immediate clicks when my target was โ€œ16-bitโ€ (technically should be called โ€œreal modeโ€) DOS.

+7
source

There are two main types of COM files. One of them was developed to work in MS-DOS, the other was developed to work in CP / M. As far as I know, DOS COM files should be x86 based. CP / M COM files can be 8085, 8080 or Z80 instructions according to Wikipedia. As another answer mentioned, COM is just a simple executable format and can use any supported basic set of commands.

As for the SHL team, it seems that modern x86 hardware (possibly x64) supports immediate value for this instruction. I could not find a link to it, looking only at 8086 documents, so maybe it was added at some point. Here are a few links that describe this manual in detail:

http://siyobik.info/main/reference/instruction/SAL%2FSAR%2FSHL%2FSHR

http://ref.x86asm.net/coder32.html

+4
source

All Articles