Getting infinite loop or hang in 8086 asm using tasm 1.0 and mame mc1502 emulator (XT semi-compatible)

35 Views Asked by At

I'm trying to write program in 8086 asm for XT emulator which draws random pixels on screen (1 coordinate axis for now).

10 pixels are drawn along (x=random(),y=100), then delay is run. I'm getting a hang or infinite loop.

I've tried pushing and popping the cx register for loop. Also I've tried executing the built .com file in dos 3.3 debug.com, but as soon as program hits the graphics mode, nothing can be seen on the screen. I understand that when I scale the random number by 5 it may produce pixel coordinate out of screen. But the problem is in hang or infinite loop. The delay part was tested separately and works fine, delay is about 3 seconds on my emulator.

Additional info: mc1502 8086 machine for mame emulator, os environment - sigma dos for mc1502 (msdos 3.3 clone), asm - turbo asm 1.0.

;configure for com file
.model tiny
.code
org 100h

start:

;set graphics mode
mov ax, 0004h ;cga 320*200 color on mc1502
int 10h

;put pixel line by coords (rnd)
;start random gen
mov dx, 0abbah  ;init
mov cx, 000ah ;10 times
rnd:
mov ax, dx
mov bx, 001fh
mul bx
add ax, 000dh
mov bx, 4ce3h
div bx ;dx now has a random number

;draw pixel
push cx ;save counter
mov cx, 0064h ;x 2-byte
push dx ;save dx
mov ax, dx ; scaling dx 
mov bl, 5
div bl
mov dx, 0 ;scaled y
mov dl, al ;dl is y
mov ax, 0c02h ;0c drawfunc, 02 color
int 10h ;video int
pop dx
pop cx
loop rnd

;delay
mov cx, 0ffffh
delay:
push cx
mov cx, 000ah
indelay:
nop
loop indelay
pop cx
loop delay

;set text mode 80x25 bw
mov ax, 0000h
int 10h

;exit to dos
mov ax, 4c00h
int 21h
end start

0

There are 0 best solutions below