I need help with a Assembly code. I know this is a C++ forum, but if anyone can help me I would very much appreciate it.

I complied this code, but there is an error message indicating there is a problem with the code. Please anybody help me fix it.

SAMPLE program for arithmetic operation:

ORG 0100H
MOV AL,X ; Move X into AL
MOV BL,02H ; Move 2 into BL
MUL BL ; Multiply AL by BL, the result will be in AX
MOV CX,AX ; Store the answer in CX

MOV AL,Y ; Move Y into AL
MOV BA,05H ; Move 5 into BL
MUL BL ; Multiply AL by BL, the result will be in AX


ADD AX,CX ; ADD first arithmetic result to second one

MOV CL,W ; Move the dividend (W) into CL
DIV CL ; Divide CL into AX, the result will be in AH,AL

RET

X DB 04H
Y DB 03H
W DB 02H
I complied this code, but there is an error message

How exactly did you compile it, and what exactly is the error message.

Note that this program is written for 16-bit x86 platform and expects to be executed by MS-DOS operating system (or compatible), it may take some work to find an assembler and an emulator to run this today.
Well the complier indicates a problem in the seventh line form the code, which is MOV BA,05H. It states that is probably not defined and a wrong parameter in the code. And I found a program online that runs it.

Do you think you can help me fix the problem?
The comment says BL but the code says BA ?
Did changing this:

MOV BA,05H ; Move 5 into BL

To this:

MOV BL, 05H ; Move 5 into BL

fix it?
If I remember you can use command LA instead of MOV. For example

MOV AL,X ; Move X into AL
LA BX,02H ; Move 2 into BL
MUL BL ; Multiply AL by BL, the result will be in AX
MOV CX,AX ; Store the answer in CX

MOV AL,Y ; Move Y into AL
LA BX,05H ; Move 5 into BL
MUL BL ; Multiply AL by BL, the result will be in AX


Also I would advice to use old Borland's TASM 4.01 or TASM 5.0 and write programs in the IDEAL mode.
Last edited on
Registered users can post here. Sign in or register to post.