汇编圣诞树

汇编版圣诞树

先附上截图:

汇编代码如下:分辨率320*200

 1 dseg segment
 2       x_label dw ?             ;每层空格数 
 3       y_label dw ?             ;每层高度
 4       axis    equ 30
 5 dseg ends
 6 cseg segment
 7       assume cs:cseg , ds:dseg
 8 start:       
 9       mov ah , 0               ;设置图形显示模式4
10       mov al , 04h            
11       int 10h
12       
13       mov al , 04              ;color
14           
15       mov dx , 60              ;y
16       mov y_label , 30
17       mov x_label , 30
18 floor:
19       cmp y_label , 0
20       je  exit
21       mov x_label , 30
22       sub y_label , 10
23       add al , 1               ;每层变换颜色
24       inc dx
25 column:
26       mov cx , x_label         ;x
27       inc dx
28       mov bx , axis            ;圣诞树轴线
29       sub bx , x_label
30       add bx , bx              ;圣诞树每层宽度
31       add bx , cx
32 row:        
33       mov ah , 0ch             ;0c号子功能        
34       int 10h
35       inc cx
36       cmp cx , bx 
37       jbe row
38       
39       push bx
40       mov bx , y_label
41       dec x_label
42       cmp x_label , bx
43       pop bx
44       jge column
45       jb  floor
46      
47 exit:
48       mov al , 05
49       mov cx , axis            ;树根
50       mov bx , 26      
51 next:
52       inc dx     
53       mov ah , 0ch             ;0c号子功能        
54       int 10h
55       dec bx
56       jnz next
57       
58       mov ax , 4c00h                  
59       int 21h 
60 
61 cseg ends
62 end  start                

 

posted on 2015-01-02 14:05  Karma_wjc  阅读(471)  评论(0编辑  收藏  举报