汇编语言--运用迭代和递归的方式按照要求输出

本文介绍如何使用汇编语言编写程序,以迭代和递归的方式生成螺旋矩阵,并按要求输出。程序从左上角开始,以螺旋形状打印'x',每次打印两个符号之间暂停10毫秒。文章通过三个执行示例展示程序效果,矩阵边长为偶数。
摘要由CSDN通过智能技术生成

write a program to print square matrices of ‘x’. The printing job starts with the left-most corner and proceeds in a spiral way. The program should be paused for 10 milliseconds between printing each two symbols. Below are three snapshots of an execution of the program. (Note the edge length of square is an even number.)

 

TITLE Example of Procedures
INCLUDE Irvine32.inc

.data
symbol= 'x'
delay_time = 10
space = ' '

iterative byte "ITERATIVE",0
recursive byte "RECURSIVE",0

.code

main PROC
	; displays "ITERATIVE"
	mov dh, 3
	mov dl, 12
	call gotoxy
	mov edx, offset iterative
	call writestring

	; prints the square using iteration
	mov bl, 10		; top-left x
	mov bh, 6		; top-left y
	mov al, 25		; bottom-right x
	mov ah, 21		; bottom-right y
	

	call spiral_print

	; displays "RECURSIVE"
	mov dh, 3
	mov dl, 32
	call gotoxy
	mov edx, offset recursive
	call writestring
	
	mov dh,3					;find the size of x
	mov dl,29					;find the size of y
	call gotoxy				;go to the start location for recurive

	; prints the square using recursion
	mov bl, 30		; top-left x
	mov bh, 6		; top-left y
	mov al, 45		; bottom-right x
	mov ah, 21		; bottom-right y
	call spiral_print_recurs

	; moves the cursor for "Press any key to continue"
	mov dh, 22
	mov dl,
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值