What set of instructions is used in COM files? I assumed it was 8086, but it seems that I was wrong. In a 8086 manual I found, shl can only accept 1 or cl for its second argument, while immediate values other than 1 work fine for me. In case it matters, I'm using NASM.
Thanks for your time.
This is one of those funny questions and as always the answers are misleading.
a true DOS COM file has no headers and has to fit inside a single segment of memory, because it had no relocation information, DOS had to put the file where it needed, and so the only true way of being compatible (with x86) was to use 8086 compatible assembly. Edit: To clarify the above, this is because the 8086 didn't have memory pages.
You could certainly compile in 286/386 operands in, as once the program is running, there's no executive runtime in DOS to stop you and say 'no you can't do that, it's a 386 instruction'.
Which, funnily enough, is part of the reason why COM files don't work very often in Windows7 x32 or at all in Windows7 x64.
Because of way DOS worked, command.com was unloaded when you execute your .com file, and reloaded afterwards, so essentially your .com file could access all memory of the system, and in theory use DOS memory extenders like Phar lap's DOS/4GW and CWSDPMI come to mind.
Long story short; you could use any sort of commands that the current system could support, but you should only use 16-bit x86 compatible commands to be sure.
If the above sounds like a PITA, it's because it was, I remember :) It's also why the .EXE format got very popular very quickly.
A true COM (I won't get into COMs that are actually EXEs, etc) just means it's a simple DOS executable. Whatever instruction set is supported is available. I used to do DOS programming (both COM and EXE) on 8088 up through i486 back in the day, and whatever instructions are legal in that mode, you can use. For example, I often used 32-bit string instructions and immediate pushes when my target was "16-bit" (technically should be called "real mode") DOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With