Operand types do not match

From: Kim Gadecki (spamtrap_at_crayne.org)
Date: 10/26/04


Date: Tue, 26 Oct 2004 18:35:07 +0000 (UTC)

Hello everyone, can I have some help with inline assembly please (I
have only just begun studying it at university)

When I try to compile this example that was given to us on Borland C++
Compiler 5.5.1-

#include <stdio.h>

int main ( )
{
int n1, n2, sum;
printf("This program determines the sum of two numbers.\n");
printf("Please enter 2 numbers:\n");
scanf("%d%d", &n1, &n2);
asm MOV AX, n1; // in-line code
asm ADD AX, n2; // semicolon is optional
asm MOV sum, AX;
printf("\nThe sum of %d and %d is %d\n", n1, n2, sum);

return(0);
}

I get an error that reads:

C:\University\ICT106\Assignment2>bcc test.c

C:\University\ICT106\Assignment2>c:\borland\bcc55\bin\bcc32 -I -L
test.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
test.c:
Warning W8002 test.c 9: Restarting compile using assembly in function
main
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise
Corporation

Assembling file: test.ASM
**Error** test.ASM(41) Operand types do not match
**Error** test.ASM(42) Operand types do not match
**Error** test.ASM(43) Operand types do not match
Error messages: 2
Warning messages: None
Passes: 1

My machine is an AMD Athlon XP with Windows XP. When I try to place
the integer into the register EAX instead it seems to work but I do
not know why this should be the case.

Any assistance is greatly appreciated as I need to get this working
for an assignment due on Friday.

Thank you for your time,
Kim