I've done everything I know, and even asked a crap load of people, but I can't seem to get rid of this error. can any one tell me why it's appearing?



.model small
.stack 100h

.data
numberPrompt db "Enter a number between 0 and 999: ", 0
sumRow1Msg db "The sum of row 1 is: ", 0
sumCol2Msg db "The sum of column 2 is: ", 0
numGtr100Msg db "The number of values > 100 is: ", 0
notInRangePrompt db "The value in not in the range: ", 0
matrix dw 16 dup (?)
count = 16

.code
extrn Writestring:proc, Readint:proc, Writeint:proc, Crlf:proc

main proc
mov ax, @data
mov ds, ax

call GetNums
call DisplayMatrix
call sumRow1
call sumCol2
call Greater100
call Swap1W2

mov ax,4c00h
int 21h

main endp

GetNums proc
push cx
mov ax,@data
mov es,ax
mov di, offset matrix
mov cx, count

GetData:
mov dx, offset numberPrompt
call Writestring
call Readint

;if (ax > 999) or (ax < 0) then jump to NOTINRANGE else jump to INRANGE

cmp ax, 999
jg NOTINRANGE
cmp ax, 0
jl NOTINRANGE
jmp INRANGE

NOTINRANGE:
mov dx, offset notInRangePrompt
dec cx
loop GetData

INRANGE:
call Crlf
stosw ; stosw = es:[di]=ax; di+=2
loop GetData

pop cx
ret
GetNums endp


DisplayMatrix proc
mov si, offset matrix
mov cx, count
Display:
lodsw ;(equivalent to mov ax,ds:[si]; add si,2)
mov bx,10
push cx ; (make sure WriteInt does not modify it)
call WriteInt
pop cx
dec cx ;(decrease cx by one, and check if lowest 2 bits are zero,
;which means 4*k items have been printed, where k is integer)
test cx,3
jnz short NotEndOfLine
push cx
call Crlf
pop cx
NotEndOfLine:
or cx,cx ;(if cx is not zero jump back to Display)
jnz Display
ret
DisplayMatrix endp

;get sum row 1
sumRow1 proc
mov si, offset matrix
mov bx, [si]
mov cx, 3
Sum1:
add si, 2
add bx, [si]
loop Sum1

mov dx,offset sumRow1Msg
push bx
call Writestring
pop bx

mov ax,bx ; get the sum(in BX)
mov bx,10
call Writeint ; display it
call Crlf
ret
sumRow1 endp

;get sum col 2
sumCol2 proc
mov si, offset matrix+2
mov bx, [si]
mov cx, 3
Sum2:
add si, 8
add bx, [si]
loop Sum2

mov dx, offset sumCol2Msg
push bx
call Writestring
pop bx
mov ax,bx ; get the sum(in BX)
mov bx,10
call Writeint ; display it
call Crlf
ret
sumCol2 endp

; count display number vals > 100
;while (cx < count)
;{
; if ([si] < 100)
; count = count + 1
; cx++
; si = si +2
;}
Greater100 proc
mov si, offset matrix
xor bx, bx ; set bx to zero

mov cx, 1
While:
cmp cx, count
jg Enddo
cmp [si], 100
jl L2
inc bx
L2:
inc cx
add si, 2
jmp While
Enddo:
mov dx, offset numGtr100Msg
push bx
call Writestring
pop bx
mov ax,bx ; get the sum(in BX)
mov bx,10
call Writeint ; display it
call Crlf
ret
Greater100 endp

;swap rows 1 and 2
Swap1W2 proc
mov si, offset matrix
mov di, offset matrix+8
mov cx, 4
rowSwap:
mov bx, [si]
xchg bx, [di]
mov [si], bx
add si, 2
add di, 2
loop rowSwap
call DisplayMatrix
ret
Swap1W2 endp

end main
Posted on 2002-04-25 12:43:35 by Zombiefreak
main shouldn't be a PROC. Just do:
main:
You don't need any of those PROC/ENDP stuff - just create labels.

This line doesn't look correct?
extrn Writestring:proc, Readint:proc, Writeint:proc, Crlf:proc
Try:
extrn Writestring:near, Readint:near, Writeint:near, Crlf:near
Haven't tried the code attached, but it might work?
Posted on 2002-04-25 13:10:28 by bitRAKE
Shouldn't really matter if main is a proc - but I'd just use a raw label.
Posted on 2002-04-25 13:16:09 by f0dder