Rectangular Concentric Spiral Ring

Source: Internet
Author: User
Tags clear screen
D_seg segment
Row_u db 0; boundary above the row-> r
Row_d dB 25; boundary below the row-> L
Col_l db 0; boundary on the left of the column-> U
Col_r dB 80; boundary on the right of the column-> d
End_flag db 0; 1 indicates end, 0 indicates continue
Direction direct dB 'R'; current forward direction, initially to the right
D_seg ends
;
Code segment
Assume Cs: code, DS: d_seg
Start:
;**
;*
Main program segment code
Main proc far
PUSH DS
XOR ax, ax
PUSH AX
;
MoV ax, d_seg
MoV ds, ax
;
Call clear; clear screen
;
MoV dx, 0; 0 rows and 0 columns with Cursor
MoV BH, 0
MoV ah, 2
Int 10 h
;
Call drawdirect; output image
; Press any key to exit
Magain:
MoV ah, 7
Int 21 h
CMP Al, 'Q'
Je mexit
JMP magain
Mexit:
Call clear
RET
Main endp
;-----
;**
;*
; Drawing direction control
Drawdirect proc near
D_continue:
; Compared with col_l, if col_l> = DL, then explain direct = 'U'
CMP export direct, 'L'; whether it is left
Jnz no_left; no
Coll_next:
Call char_disp; output character
Dec dl; move one column to the left
CMP col_l, DL; compare whether this direction is used
Jl coll_next; no need to switch, continue output
INC dl; roll back a column to the right
INC col_l; add one to the left boundary
INC col_l
MoV ready direct, 'U'; turn to upward
Jmp dcmp; exit
;
No_left:
; Compared with col_r, if col_r <= DL, then sort direct = 'D'
CMP export direct, 'R'; whether it is the right side
Jnz no_right; no
Colr_next:
Call char_disp; output character
INC dl; move one column to the right
CMP col_r, DL; compare whether this direction is to be switched
JG colr_next; no need to switch, continue to output
Dec dl; roll back one column to the left
Dec col_r; minus one on the right boundary
Dec col_r
MoV forward direct, 'd; turn downward
Jmp dcmp; exit
;
No_right:
; Compared with row_u, if row_u> = DH, then dircet = 'R'
CMP forward direct, 'U'; indicates whether to go up
Jnz no_up; no
Rowu_next:
Call char_disp; output character
Dec DH; move up a row
CMP row_u, DH; compare whether the direction has been changed
Jl rowu_next; no need to switch, continue output
Inc dh; roll back a row
INC row_u; add one on the upper boundary
; INC row_u
MoV ready direct, 'R'; turn to the right
Jmp dcmp; exit
;
No_up:
; Compared with row_d, if row_d <= DH, then direction direct = 'l'
Rowd_next:
Call char_disp
Inc dh; move down a row
CMP row_d, DH; compare whether the direction is changed
JG rowd_next; no need to switch, continue output
Dec DH; roll back a row
Dec row_d; lower boundary minus one
; Dec row_d
MoV ready direct, 'L'; turn to left
DCMP:
Push ax; save al
MoV Al, row_u
INC al; add one on the upper boundary
CMP Al, row_d; whether the upper boundary is coincident with the lower boundary
Pop ax; restore al
Jge d_exit; exit if it is to overlap
Push ax; save al
MoV Al, col_l
INC al; add one on the left border
CMP Al, col_r; exit if it is to overlap
Pop ax; restore al
Jge d_exit; exit if it is to overlap
JMP d_continue; then output
D_exit:
RET
Drawdirect endp
;--------
;**
;*
Char_disp proc near
Push CX; save CX
;
MoV ah, 2
MoV BH, 0; 0 page display
Int 10 h; cursor position
;
MoV Al, 2; placement of smiley ASCII code
MoV BL, 07; black and white characters
MoV CX, 1; output character 1
MoV ah, 9
Int 10 h; Output smiling face
Pop CX
RET
Char_disp endp
;--------
;**
;*
Clear proc near
MoV ax, 0600 h; full screen Blank
MoV BH, 7; normal display
Sub CX, CX; Start Point (0, 0)
MoV dx, 184fh; endpoint (24, 79)
Int 10 h
RET
Clear endp
;--------
Code ends
End start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.