So, here is an example of what can happen with a messed up stack pointer.
The code segments below were run under Plato as Release WIN32 with the options: /SAVE /WIDE_SOURCE /EXPLIST /FPP /CFPP
The two include files are:
save_stack.ins:
code
mov stack_at_entry,esp%
edoc
and current_stack.ins:
code
mov current_stack,esp%
edoc
The main body (forumtesting.for) is:
! winapp
use mswin
use opengl$
integer ctrl,window_handle
integer stack_at_entry,current_stack
stack_at_entry = 0
current_stack = 0
include 'save_stack.ins'
i=winio@('%es%ca[Simple OpengGL Sample]&')
i=winio@('%sp%ww[not_fixed_size]%og[static]%hw%lw',0, 0, 400, 400,window_handle,ctrl)
CALL glClearColor (0.0, 0.0, 0.0, 0.0)
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glColor3f(1.0, 1.0, 1.0)
CALL glMatrixMode(GL_PROJECTION)
CALL glLoadIdentity()
CALL glOrtho(0d0, 10d0, 10d0, 0d0, -1d0, 1d0)
call glnewlist(1,gl_compile)
call glBegin(GL_LINE_STRIP)
call glVertex2f(0.,0.)
call glVertex2f(10.,10.)
call glEnd()
call glEndlist()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
pause
end
Running this yielded the following output:
&')
i=winio@('%sp%ww[not_fixed_size]%og[static]%hw%lw',0, 0, 400, 400,window_handle,ctrl)
CALL glClearColor (0.0, 0.0, 0.0, 0.0)
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glColor3f(1.0, 1.0, 1.0)
CALL glMatrixMode(GL_PROJECTION)
CALL glLoadIdentity()
CALL glOrtho(0d0, 10d0, 10d0, 0d0, -1d0, 1d0)
call glnewlist(1,gl_compile)
call glBegin(GL_LINE_STRIP)
call glVertex2f(0.,0.)
call glVertex2f(10.,10.)
call glEnd()
call glEndlist()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
pause
end
Running this yielded the following output:
&')
i=winio@('%sp%ww[not_fixed_size]%og[static]%hw%lw',0, 0, 400, 400,window_handle,ctrl)
CALL glClearColor (0.0, 0.0, 0.0, 0.0)
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glColor3f(1.0, 1.0, 1.0)
CALL glMatrixMode(GL_PROJECTION)
CALL glLoadIdentity()
CALL glOrtho(0d0, 10d0, 10d0, 0d0, -1d0, 1d0)
call glnewlist(1,gl_compile)
call glBegin(GL_LINE_STRIP)
call glVertex2f(0.,0.)
call glVertex2f(10.,10.)
call glEnd()
call glEndlist()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
pause
end
Running this yielded the following output:
&')
i=winio@('%sp%ww[not_fixed_size]%og[static]%hw%lw',0, 0, 400, 400,window_handle,ctrl)
CALL glClearColor (0.0, 0.0, 0.0, 0.0)
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glColor3f(1.0, 1.0, 1.0)
CALL glMatrixMode(GL_PROJECTION)
CALL glLoadIdentity()
CALL glOrtho(0d0, 10d0, 10d0, 0d0, -1d0, 1d0)
call glnewlist(1,gl_compile)
call glBegin(GL_LINE_STRIP)
call glVertex2f(0.,0.)
call glVertex2f(10.,10.)
call glEnd()
call glEndlist()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
call glCalllist(1)
call glFinish()
call swap_opengl_buffers@()
include 'current_stack.ins'
print *,'Stack values',stack_at_entry,current_stack
print *,'Negative means likely corrupted stack:',stack_at_entry-current_stack
pause
end
Running this yielded the following output:
[quote:da5bdd8644]Stack values 56687648 56687656
Negative means likely corrupted stack: -8
Stack values 56687648 56687736
Negative means likely corrupted stack: 269709653
Note that the last calculation shown is NOT the proper value (shown as 269709653, S/B -88). This is the example of how the stack pointer can affect the results. If I restore the stack pointer just prior to this last set of statements, the results show:
[quote:da5bdd8644]
Stack values 56687648 56687656
Negative means likely corrupted stack: -8
Stack values 56687648 56687648
Negative means likely corrupted stack: 0