Re: What causes this infinite loop?



Sam <spamtrap@xxxxxxxxxx> wrote in part:
Is it always the case that a program with "blow up" if
something is left on the stack? -- Sam

This is entirely OS dependant, and the pgm entry and exit
section match the OS requirements. For simple MS-DOS *.COM
pgms, the loader pushes 0000h onto the stack, and loads the
PSP with `int 20h` at CS:0 so the pgm can be conveniently
terminated with `ret` if the stack is kept aligned. But notice
the `ret` doesn't terminate anything even under this most
rudimentary of OSes. `int 20h` does the work.

This is generally true for more advanced [modern] OSes.
There is a syscall for terminating a pgm. This does
important things like close files and free memory.

In general, the stack can be left with garbage so
long as `ret` is not used. Some people use no stack,
often to use [E]SP as a general purpose register.

-- Robert

.



Relevant Pages