zifeer
March 27th, 2006, 05:14 AM
I've written this 32-bit assembly code:
(It's supposed to read 4 numbers from the keyboard and print the sum, product and average)
include irvine32.inc
.data
value1 dd ?
value2 dd ?
value3 dd ?
value4 dd ?
sum dd ?
prod dd ?
avg dd ?
.code
main PROC
call ReadInt
mov value1,eax
call ReadInt
mov value2,eax
call ReadInt
mov value3,eax
call ReadInt
mov value4,eax
mov sum,value1+value2+value3+value4
mov prod,value1*value2*value3*value4)
mov avg,sum/4
mov eax,sum
call WriteInt
mov eax,prod
call WriteInt
mov eax,avg
call WriteInt
exit
main ENDP
END main
After assembling:
Assembling: project1.asm
project1.asm(21) : error A2101: cannot add two relocatable labels
project1.asm(22) : error A2026: constant expected
project1.asm(23) : error A2026: constant expected
I'm confused, my assembly knowledge is very fresh and new; I've written this after looking at some functions in my book. I would appreciate it if somebody can tell me how to fix it.
Thanks.
(It's supposed to read 4 numbers from the keyboard and print the sum, product and average)
include irvine32.inc
.data
value1 dd ?
value2 dd ?
value3 dd ?
value4 dd ?
sum dd ?
prod dd ?
avg dd ?
.code
main PROC
call ReadInt
mov value1,eax
call ReadInt
mov value2,eax
call ReadInt
mov value3,eax
call ReadInt
mov value4,eax
mov sum,value1+value2+value3+value4
mov prod,value1*value2*value3*value4)
mov avg,sum/4
mov eax,sum
call WriteInt
mov eax,prod
call WriteInt
mov eax,avg
call WriteInt
exit
main ENDP
END main
After assembling:
Assembling: project1.asm
project1.asm(21) : error A2101: cannot add two relocatable labels
project1.asm(22) : error A2026: constant expected
project1.asm(23) : error A2026: constant expected
I'm confused, my assembly knowledge is very fresh and new; I've written this after looking at some functions in my book. I would appreciate it if somebody can tell me how to fix it.
Thanks.