Start New Discussion within our Software Development Community

I am trying to do this: z=(5*a-b/7)/(3/b+a*a) in assembly code and I keep getting some errors.
Here is the code & the errs.

assume cs:code,ds:data 
data segment
a dw 5
b dw 6
z dw 10


intermed dw ?
rez db ?
data ends
code segment
start: 

mov ax,data
mov ds,ax
mul 5  ; ERROR Argument needs type override & Illegal immediate
; in ax we will have a*5;
mov bx,ax ; we move the ax data in the bx register bx:ax
mov ax,b; we move the b in the ax register ax:b
cwd ; ERROR Argument needs type override& Illegal immediate ;we convert the word from ax in doubleword, in dx:ax
idiv 7 ; ax=b/7
sub bx,ax; we substract ax out of bx ( ax: ax-bx <=> 5*a-b/7 )
mov intermed, ax ;we move all the data from ax to interm=(5*a-b*7)

mov al,3 
idiv b; ax:3/b
mov bx,a; bx:a
mul a; bx:a*a
add ax, bx; ax=ax+bx;
mov bx,intermed; Err. Undefined symbol Intermed
idiv ax; we obtain the result in al and the reminder in ah

mov rez,al

mov ax, 4C00h
int 21h
code ends
end start

Where are my sins? Thank you !

Where are my sins?

As a general recommendation, you should read some technical documentation on the x86 instructions... this page is a good start, but the Intel processor manuals are the real deal.

As for your specific questions:

mul 5  ; ERROR Argument needs type override & Illegal immediate

operands to mul are either registers or memory locations; immediate values aren't supported.

cwd ; ERROR Argument needs type override& Illegal immediate ;we convert the word from ax in doubleword, in dx:ax
idiv 7 ; ax=b/7

cwd should be fine... this error might be for your idiv , which has the same restriction as mul --only registers or memory locations.

mov bx,intermed; Err. Undefined symbol Intermed

Not sure what's wrong off the top of my head.

This article has been dead for over six months. Start a new discussion instead.