Quazi Irfan
Quazi Irfan

Reputation: 2599

shl instruction throws 'error A2070 : invalid instruction operands'

I am learning Assembly Programming Language, and I've started using macros to shorten my program. One of the macro isn't working as expected.

This the bare bone program I am trying to run,

include pcmac.inc

.model small

.stack 100h

.data

.code

Hello PROC
    _Begin     ;Line 12
    _Exit 0
Hello ENDP

END Hello

Inside the pcmac.inc file the _Begin macro has the following definition,

_Begin  MACRO
        mov     ax, @data
        mov     ds, ax
        mov     bx, ss
        sub     bx, ax
        shl     bx, 4
        mov     ss, ax
        add     sp, bx
        ENDM

When I run this program I get the following error,

file.asm(12) : error A2070 : invalid instruction operands
    _Begin(5)   :   Macro Called From
    file.asm(12):   Main Line Code

If I replace _Begin macro with the original assembly code, the program works as expected,

    mov ax, @data
    mov ds, ax

Can anyone tell me why the _Begin macro isn't working, and what does the error mean?

I am using masm on Windows 8 on iMac.


Edit: I've just found that if I comment out the following line in the _Begin macro the program works.

shl     bx, 4

But this PCMAC.INC file is provided by the book we are following for the class, and we aren't supposed to modify this file.

Upvotes: 3

Views: 1955

Answers (1)

rkhb
rkhb

Reputation: 14409

shl bx, 4 causes the error. To shift with a shift count larger than 1 was introduced with the 80186 processor. MASM accepts by default only 8086 instructions, but you can direct it to accept later instruction sets.

TL;DR: Place a .186 directive to the top of the source. Better is .386.

Upvotes: 5

Related Questions