Re: What causes this infinite loop?
- From: Robert Redelmeier <redelm@xxxxxxxxxxxxxxx>
- Date: Wed, 09 Aug 2006 13:45:12 GMT
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
.
- References:
- What causes this infinite loop?
- From: Sam
- What causes this infinite loop?
- Prev by Date: Re: What causes this infinite loop?
- Next by Date: Re: Linking ASM Object File to C++ Program
- Previous by thread: Re: What causes this infinite loop?
- Next by thread: Re: What causes this infinite loop?
- Index(es):
Relevant Pages
|