[MASM] Other "cannot use 16-bit register with 32-bit address"
I am learning assembler using MASM assembler and I get stuck when trying to assemble a simple file using this command: ml /c test.asm
and the file test.asm
looks like this:
.386
.model flat
.code
MOV BP,WORD PTR[BP+4]
END
then the problem arises:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembly: test.asm
test.asm (4): error A2155: cannot use 16-bit register with 32-bit address
the question arises:
32-bit address? I didn't tell the assembler to use a 32-bit address.
and how can i get my code?
source to share
I did some research and here's what I found out.
.MODEL
directive
- allows for simplified segments
- controls the name of the code segment
- controls the default distance for procedures.
syntax:
.MODEL memorymodel, options-optional
and memory can be
TINY, SMALL, COMPACT, MEDIUM, LARGE, HUGE,or FLAT
A flat model is like a tiny model in that all code and data goes into one 32-bit block of memory.
To write a program with a flat model, specify the .386 or .486 directive before.
so the directive .386
is optional if I don't want to use flat model (see here )
here are some links
source to share