(Processor Intel x86)
.MODEL SMALL
Print EQU 2
Exit EQU 4Ch
.DATA ;------------------------------------------------------
a DW 8
b DW 2
.CODE ;------------------------------------------------------
Start PROC
mov ax, SEG DGROUP
mov ds, ax
mov ax, a
;div b <---- uncommenting it makes program hang
mov dx, ax
add dx, '0'
mov ah, Print
int 21h
mov ah, Exit
int 21h
; -----------------------------------------------------------
Start ENDP
.STACK 512
END Start
If compiled with Turbo Assembler, the code outputs 8. If i uncomment the DIV command, the code hangs.
Looking at the registers with Turbo Debugger, I saw that the DIV command sends the result of division into the AX register -- the same register which stored the number 8 and which will be sent to DX to be printed.
What did cause in DIV to hang my program? Did I oversee DIV putting data into registers which were to be used by some important background functions or... something?