16 Bit Assembler Vertical Bar Loop

Click For Summary
SUMMARY

The forum discussion centers on creating a 16-bit assembler program that displays a vertical bar character ‘|’ moving across the screen in both directions. The provided code utilizes DOS interrupts for character display and includes a timing mechanism through a procedure named "waste." A critical bug was identified where the loop for reversing direction incorrectly jumps to the wrong label, which prevents the intended functionality of the program. Correcting this jump is essential for achieving the desired left-to-right and right-to-left movement of the vertical bar.

PREREQUISITES
  • Understanding of 16-bit Assembly Language programming
  • Familiarity with DOS interrupts, specifically INT 21h
  • Knowledge of data segment and stack segment management in Assembly
  • Basic debugging skills in Assembly code
NEXT STEPS
  • Review the use of INT 21h for character output in Assembly language
  • Learn about loop constructs and control flow in 16-bit Assembly
  • Investigate timing mechanisms in Assembly programming
  • Explore debugging techniques for Assembly language programs
USEFUL FOR

This discussion is beneficial for students learning 16-bit Assembly language, hobbyists interested in low-level programming, and educators teaching computer architecture concepts.

Babiloo
Messages
1
Reaction score
0

Homework Statement


Create a program that displays a vertical bar character ‘|’ moving left to right in 79 positions across the screen, then back right to left across the screen.


Homework Equations


(16 bit Assembler)


The Attempt at a Solution


Code:
	.model small
	.stack 100h
	.data
bar	db	8,' ','|','$'
bar2	db	8,' ',8,8,'|','$'
		x dw 500

	.code
bars 	proc
	mov 	AX, @data
	mov 	ds, AX

	mov 	dl,'|'	
	mov	ah,2h
	int	21h

	mov	cl,79

	again:

	mov	ah,9h
	lea 	dx,bar
	int	21h

	call	waste
	dec	cl
	Jnz again

	mov	ah,9h
	lea 	dx,bar2
	int	21h

	call	waste
	dec	cl
	Jnz again

bars	endp
	waste	proc

	push	ax
	push	bx
	push 	cx
	push	dx

	again2:

	mov	cx,79
	
	again3:

	mov	ax,79
	mul	x
	dec	cx
	jnz	again3
	dec	ax
	jnz	again2
	
	pop	dx
	pop 	cx
	pop	bx
	pop 	ax

	ret
waste 	endp
	end 	waste
	end 	bars
 
Physics news on Phys.org
So "waste" just wastes time.
You do have a bug. Your loop for reversing the direction goes to "again" instead of the top of the second "mov ah,9h".
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
1
Views
2K
Replies
20
Views
10K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 13 ·
Replies
13
Views
6K