December 16th, 2008, 11:46 AM
Procedure size? Need halp
so I have this working procedure that is basically like function 09h of int 21h except it terminates at 00h, and it uses 01h-04h as control characters that determine the style of the text.
I wrote it in the main procedure of a test program to get it working, and then I put it in its own procedure in a larger program. When I run it from the larger program, I get this error:
"title: 16 bit MS-DOS Subsystem
Command Prompt - cmp
NTVDM has encountered a System Error
Access is denied.
Choose 'Close' to terminate the application
Close | Ignore"
I can't really ignore it. Anyways, I narrowed the cause of this error down to a procedure without a "RET" statement. But it has a return statement at the end. If I just put RET in the procedure, it runs, if I put all of the code back into the test program (main procedure), it runs. So I'm thinking maybe there's a maximum size for a procedure that is called? It is quite long, I haven't tried to slim it down at all, I'm not sure if I really can. Anyway, here's the procedure:
I'm using TASM, and the model of the program is small... I tried making it "Large" and "Huge" to see how that would affect it but it said there was a problem with my call statement in the main procedure (Forward reference needs override). Has anyone run into something similar to this? How can I fix it and make it work?
nexch: mov si,dx
nndpr: cmp al,0dh ;LINE FEED
scwin: mov ax,0601h
not0d: cmp al,0ah ;CARRIAGE RETURN
not0a: cmp al,01h ;WHITE
not01: cmp al,02h ;GREEN
not02: cmp al,03h ;YELLOW
not03: cmp al,04h ;EDIT/HEADER
not04: mov ah,09h
gnext: pop cx
endpr: pop bx
Oh, and I tried doing something like this:
the procedure did its job but it wouldn't return afterward, the cursor just sat there blinking and I couldn't input anything (text, ctrl-c, etc)
December 16th, 2008, 01:01 PM
Re: Procedure size? Need halp
so I figured out if I pop the stack into ax at the very beginning of the procedure (the return pointer), move that value into a variable I have saved, then push it back, then at the end of the procedure, move the variable into ax and push it again, then it will return properly, so I suppose I'm just not unwinding the stack correctly... Still I wonder why access to the procedure is denied if the RET statement is too far away? I'd like to just put it at the end and save all those unnecessary jumps
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!