Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 asm files, Program Terminating/looping, Dont know why

Status
Not open for further replies.

Badda

Programmer
Nov 27, 2004
2
US
all right the problem i have is this, i have 2 files

Code:
INCLUDE PCMAC.INC

.model small; 
.586
.stack 100h

.data;	
PUBLIC numarray1
EXTRN GETDEC:FAR, PUTDEC:FAR	
EXTRN fillarr:FAR, printarr:FAR;, printrev:NEAR

numarray1 dw 25 dup (?)
N	  dw ?

enterN	db	13, 10, "Please enter the size of the array: $"



.code
main proc			

     _Begin			

	_PutStr enterN
	call GetDec
	mov N, ax
	mov cx, N
	call fillArr
	mov cx, N
	call printarr

	_Exit 0

main endp;				Ends Procedure and then the main program
end main

and

Code:
INCLUDE PCMAC.INC
   
.model small; 	General start commands, use a small model
.586;		Allows for Pentium instructions

.data;		Data segmet
EXTRN numarray1:WORD
EXTRN GETDEC:FAR, PUTDEC:FAR
PUBLIC fillarr

fillmsg	  db	13, 10, 13, 10, "Please Enter a number within the range -25 and 25: $"
errmsg	  db	13, 10, "Number you entered is invalid, please enter another one: $"
index	dw	?

.code
fillarr PROC
        mov di, OFFSET numarray1
        mov ax, [di]
Loop1:
         mov ax, [di]
         call PutDec
         _PutCh (' ')
	_PutStr fillmsg
	call GetDec
	jmp RangeTest


OutRange:
	_Putstr errmsg
        call GetDec

RangeTest:
	cmp ax, -25		;if less then -25, get another number
	jl OutRange
	cmp ax, 25		;if more then 25, get another number
	jg OutRange
	mov [di], ax
	add di, 2
	_PutCh ('*')

loop Loop1


fillarr endp;
ret
end

Now the problem is that when i run it i get to the fillarr program but when its about to take the last digit it just crashes. I tried a lot of different ways i cant understand why would it crash all the time right after i input the last number.

The '*' char isnt outputed after i enter the last number
those PutCh thingies were entered for testing purpose only. i have Masm 6.1something
 
oops forgot to mention, when i changed (forgot which changed it was exactly sorry), something, the main program started looping for some reason.

I just moved the ret to above the endp statement, and my main looped twice for some reason, i am very confused at this point
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top