I'm doing my homework in univ...
but I have problems in my source...
like this.
1>D:\9210039proj1.asm(49) : error A2101:cannot add two relocatable labels
1>D:\9210039proj1.asm(51) : error A2101:cannot add two relocatable labels
please help me..

I emphasized 49,51 line in my source
my source is

INCLUDE irvine32.inc

N TEXTEQU <16> ;the number of random numbers.

.data
string1 BYTE
string2 BYTE "ascending ordered numbers",0dh,0ah,0
string3 BYTE "sum of numbers",0dh,0ah,0
total_num DWORD 0
numbers WORD N dup(0)
temp DWORD 0
count DWORD ?
random_num DWORD ?

.code
main PROC

mov ecx,N
mov esi,0

random_generator:
call random32
mov random_num,eax
mov ax,WORD PTR random_num
mov numbers,ax
mov edx,OFFSET string1
call WriteString
MOVZX eax,numbers
call WriteHex
inc esi
loop random_generator


mov eax,0
mov ecx,N
mov esi,0

a:
mov count,ecx 
mov ax,numbers
mov temp,esi
inc esi
sub ecx,esi
dec esi
b:
inc temp
CMP ax,numbers
jl not_condition
CMPXCHG numbers,ax
not_condition:
loop b
mov numbers,ax
inc esi
mov ecx,count
loop a

mov ecx,N
mov esi,0
mov edx,OFFSET string2
call WriteString
print_numbers :
MOVZX eax,numbers
add total_num,eax
call WriteDec
inc esi
loop print_numbers

mov edx,OFFSET string3
call WriteString
mov eax,total_num
call WriteDec

exit
main ENDP
END main
Posted on 2010-04-24 03:49:11 by wiiji
wiiji,

[] in MASM is a shortcut of +. I understood that you're trying to index numbers array with temp variable value, this addressing mode is not supported by x86 (hint: register value can be used as index, and unlike C you have to scale it explicitly).

By the way, do you understand what cmpxchg does?

Use [code] [/code] BBCode, please.
Posted on 2010-04-24 06:04:44 by baldr