0

For example, the following code FASM will assemble successfully.

USE16
MOV [ECX+0FEh], BX

Assembler's stdout:

flat assembler  version 1.73.25  (1048576 kilobytes memory)
1 passes, 7 bytes.

In my mind, 32-bit addresses are not allowed in 16-bit addressing mode. So why does this code get assembled?

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
iEPCBM
  • 211
  • 3
  • 6
  • 2
    Presumably `use16` just sets the default mode, so the assembler knows to emit the appropriate prefixes if you use 32 bit stuff. There may be a directive that disables 32 bit support in case you really have a 16 bit only cpu. I haven't checked. – Jester Oct 17 '21 at 21:45
  • 2
    "In my mind, 32-bit addresses are not allowed in 16-bit addressing mode." If your cpu is 32 (or 64) bit then it does allow 32 bit addresses in 16 bit mode, the instructions just need an address size override prefix which the assembler will emit for you. – Jester Oct 17 '21 at 21:51
  • 3
    386 extensions to register widths and addressing-mode formats work in 16-bit mode, using the operand-size and/or address-size prefixes. Also related: https://en.wikipedia.org/wiki/X86-64#Operating_modes and [Is there a default operand size in the x86-64 (AMD64) architecture?](https://stackoverflow.com/q/68289333) for more about the valid combinations of default operand-sizes for machine code, via CS. (And SS for the default SS:SP vs. SS:ESP for push/pop/call/ret etc). – Peter Cordes Oct 17 '21 at 22:21

0 Answers0