So there was a problem with a program of mine, which led me to write the following code snippet and test it:
.MODEL TINY
.386p
Kod SEGMENT USE32
ORG 100h
ASSUME CS:Kod,DS:Kod,SS:Kod
Def: JMP Start
; space for data declaration
Start: MOV eax,00000010h
MOV ecx,0000000Ah
DIV ecx
MOV eax, 00004C00h
INT 21h
Kod ENDS
END Def
Suppose I name a file with the above code as test.asm
.
The compilation under DOSBox Portable using tasm test.asm
and tlink /t test.obj
is successful. And then comes the weird problem. Running the COM executable in debug mode using td test.com
(Turbo Debugger) proceeds succesfully. But then, I ask the Turbo Debugger to reload the program (after pressing F8 one more time) and when reaching the DIV instruction, the program jumps to a different set of instructions which eventualy leads to "Divide by zero". The beginning of this set of instructions is shown below:
[view the screenshot]. What is the reason of this quirky phenomenon, and how to make the DIV instruction do its work as in the first debugging cycle? (running test.com
directly results in DOS freezing). Is this maybe a DOSBox emulator issue?