What causes this infinite loop?
- From: "Sam" <spamtrap@xxxxxxxxxx>
- Date: 8 Aug 2006 10:14:47 -0700
I hope y'all don't mind my frequent questions, so here's another...
In emu8086 I wanted to see what would happen if I left some data on the
stack and exit the program with the following:
;begin
mov ax, 0ffh ; Is it a good practice to start all hex numbers with a
zero?
push ax
;pop ax ; If I pop ax, the program exits and all appears aok.
ret
end
;end
I thought the program would stop when IP reached ffffh, but it started
over at 0 and kept chugging along. The emulator jumps to "ret" and
starts executing, "ADD [BX + SI], AL". The memory locations start
incrementing filling with NULLs that look like this, "0E711: 00 000
NULL" (memory hex decimal ascii). BX and SI are both "0000", so the
code is trying put ffh into offset zero. IIRC, each zero offset of
every assembly program I have run has always been NULL (not sure why,
but it's probably important). So, since the code is trying to put a
value into what is probably an important memory location, there is a
disturbance in the force.
If I "pop ax" after the push, the program exits at "10F00: F4 244
<ascii character>" (memory hex decimal ascii) with the next memory
location being "10F01: 00 000 NULL" (memory hex decimal ascii) and
associated with the instruction "ADD [BX + SI], AL".
Is it always the case that a program with "blow up" if something is
left on the stack?
--
Sam
.
- Follow-Ups:
- Re: What causes this infinite loop?
- From: Robert Redelmeier
- Re: What causes this infinite loop?
- From: Bjarni Juliusson
- Re: What causes this infinite loop?
- Prev by Date: Re: MASM32 help
- Next by Date: Re: Linking ASM Object File to C++ Program
- Previous by thread: How to code directly in machine language?
- Next by thread: Re: What causes this infinite loop?
- Index(es):
Relevant Pages
|