汇编学习第十章[课程设计1]

对前面学习知识的总结,学习了ACSII转换方法,  十进制ASCII=十进制数码+30H

 

  1 assume cs:code,ds:data,ss:stack
  2 data segment
  3     db    '1975','1976','1977','1978','1979','1980','1981','1982'
  4     db    '1983','1984','1985','1986','1987','1988','1989','1990'
  5     db    '1991','1992','1993','1994','1995'
  6 
  7     dw    3,7,9,13,28,38,130,220
  8     dw    476,778,1001,1442,2258,2793,4037,5635
  9     dw    8226,11542,14430,15257,17800
 10 
 11     dw    5,3,42,104,85,210,123,111
 12     dw    105,125,140,136,153,211,199,209
 13     dw    224,239,260,304,333
 14 
 15     dd    16,22,382,1356,2390,8000,16000,24486
 16     dd    50065,97479,140417,197514,345980,590827
 17     dd    803530,1183000,1843000,2759000,3753000,4649000,5937000
 18     
 19 data ends
 20 
 21 stack segment
 22     dw 16 dup(0)
 23     
 24 code segment
 25 start:    mov ax,data
 26     mov ds,ax
 27     mov ax,stack
 28     mov ss,ax
 29     mov sp,32
 30     mov bx,0
 31     mov cx,21
 32     mov ax,0b800h
 33     mov es,ax
 34     mov ax,30
 35     mov bp,ax
 36 
 37 
 38 year:    
 39     push cx                ;year
 40     mov cx,4
 41 year1:
 42     mov al,[si]
 43     mov es:[bx+di],al
 44     mov ah,7
 45     mov es:[bx+di+1],ah
 46     add di,2 
 47     inc si
 48     loop year1
 49 
 50     mov di,0
 51     add bx,160
 52     pop cx 
 53     loop year
 54                     
 55     mov cx,21                                    
 56     mov bx,40*2
 57 
 58 a0:                    ;the fourth column
 59     push cx
 60     mov ax,[si]
 61 a1:    
 62     mov cx,10
 63     mov dx,0
 64     div cx
 65     mov cx,ax
 66     add dx,30H
 67     push dx
 68     jcxz a2    
 69     inc cx                ;防止商为1跳转
 70     loop a1
 71 a2:
 72     mov ax,[si]        
 73 popa:
 74     mov cx,10
 75     mov dx,0
 76     div cx
 77     pop dx
 78     mov es:[bx+di],dl
 79     mov dh,7
 80     mov es:[bx+di+1],dh
 81     add di,2
 82     mov cx,ax
 83     inc cx
 84     loop popa
 85     
 86     mov di,0
 87     add si,2
 88     add bx,160
 89     pop cx
 90     loop a0
 91     
 92     mov cx,21            ;The third column
 93     mov bx,30*2
 94 
 95 b0:    
 96     push cx
 97     mov ax,[si]
 98 b1:    
 99     mov cx,10
100     mov dx,0
101     div cx
102     mov cx,ax
103     add dx,30H
104     push dx
105     jcxz b2
106     inc cx                ;防止商为1跳转
107     loop b1
108 b2:
109     mov ax,[si]        
110 popb:
111     mov cx,10
112     mov dx,0
113     div cx
114     pop dx
115     mov es:[bx+di],dl
116     mov dh,7
117     mov es:[bx+di+1],dh
118     add di,2
119     mov cx,ax
120     inc cx
121     loop popb
122     
123     mov di,0
124     add si,2
125     add bx,160
126     pop cx
127     loop b0
128 
129     
130     mov cx,21            ;The second column
131 
132 c0:    
133     push cx
134     mov bx,[si]
135     mov dx,[si+2]
136 c1:    
137     mov ax,dx
138     mov dx,0
139     mov cx,10
140     div cx
141     push ax                ;保存 int(h/n)
142     
143     mov ax,bx
144     div cx
145     add dx,30H
146     pop cx                ;加载 int(h/n) cx=int(h/n)直接用商的高八位cx判断,并且不破坏dx的数值
147     push dx                ;保存 acsii
148     mov dx,cx
149     inc cx                ;防止商为1跳转
150     loop c1
151     mov cx,ax
152     mov bx,ax            ;保护商的低八位
153     inc cx
154     loop c1
155 c2:    
156     mov bx,[si]
157     mov dx,[si+2]
158 popc:    
159     mov ax,dx
160     mov dx,0
161     mov cx,10
162     div cx
163     push ax                ;保存 int(h/n)
164     
165     mov ax,bx
166     div cx
167     pop dx                ;加载 int(h/n)
168     mov cx,dx            ;使用cx加载商的高八位防止破坏dx并且做判断
169 
170     pop dx                ;加载 ascii
171 
172     mov es:[bp+di],dl
173     mov dl,7
174     mov es:[bp+di+1],dl
175     add di,2
176 
177     mov dx,cx            ;还原dx
178     inc cx                ;防止商为1跳转
179     loop popc
180     mov cx,ax
181     mov bx,ax            ;保护商的低八位
182     inc cx
183     loop popc
184 
185     add si,4
186     mov di,0
187     pop cx
188     add bp,160
189     loop c0
190     
191     mov ax,4c00h    
192     int 21h
193     
194 code ends
195 
196 end start

 

 

posted @ 2013-02-23 02:09  Bug Man  阅读(150)  评论(0)    收藏  举报