carson myers -5 Unverified User

I'm playing with assembler trying to get it figured out and I wrote this program that was supposed to have two values, 0 and 10, and add to the 1 and subtract from the 10 and loop, each time displaying both values, until both of them are equal...

0 -- 10
1 -- 9
2 -- 8
3 -- 7
4 -- 6
5 -- 5
Looping finished: both values are equal

anyways I ran this, but the first time it just output a bunch of blank lines (too many for what it should have). The second time, it started writing random characters and then my screen got ruined, with some lines and color on the top and bottom, and then it looked like dust started appearing and getting brighter and brighter until my whole screen was almost gray, then I turned off my computer since I couldn't do anything with it.

.model small
.stack
.data

num1	dw 0
num2   	dw 10
delm   	db " -- ","$"
endl   	db 0Dh,0Ah,"$"
finmsg 	db "Looping finished: both values are equal","$"

.code

main 	proc

	doloop:
	mov		ax,seg num1
	mov  	ds,ax
	lea  	dx,num1
	mov  	ah,09h
	int  	21h
	
	push 	ax
	mov 	ax,seg delm
	mov		ds,ax
	lea		dx,delm
	pop		ax
	int 	21h
	
	push 	ax
	mov		ax,seg num2
	mov		ds,ax
	lea		dx,num2
	pop		ax
	int		21h
	
	push 	ax
	mov		ax,seg endl
	mov		ds,ax
	lea		dx,endl
	pop		ax
	int		21h
	
	push 	ax
	mov		ax,[num1]
	mov		dx,[num2]
	cmp 	ax,dx
	inc		num1
	dec		num2
	jnz 	doloop
	
	push 	ax
	mov		ax,seg finmsg
	mov		ds,ax
	lea		dx,finmsg
	pop		ax
	int		21h
	
	mov		ax,4c00h
	int		21h
	
main	endp
end main

compiled with TASM and TLINK
...what did I do wrong? How can I fix it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.