程序设计项目十二
编写字符雨程序。参看demo6.gif示例。
提示:
(1)每列是一个单独的单元,在数据段中定义的数据要保证各列要显示的字符和开始显示的时机不一样。
(2)每一滴雨完全移出屏幕后,该雨滴所在列生成一个新的雨滴。
分析:
题目的提示感觉不怎么明了,故就照着图和别人的代码写的代码。
参考代码:
效果感觉不咋地
1 assume cs:code 2 data segment 3 db 0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0 4 db 0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,1,0,1,0,0,1,0,0,0,0 5 db 0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0 6 db 0,1,0,0,0,0,0,1,0,1,1,1,0,0,0,1,0,0,0,0,1,0,1,1,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,0 7 db 0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,1,0,1,0,1,1,1,0,0,0 8 db 1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,1,0,1,1,1,0,0,0 9 db 1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,1,0,0,0 10 db 1,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,0,0,0 11 db 1,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,1,1,0,0,0 12 db 1,1,1,0,1,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,1,1,0,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0,1,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0 26 db 0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0 27 db 0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0 28 data ends 29 30 stack segment 31 dw 8 dup(0) 32 stack ends 33 34 code segment 35 start: 36 mov ax,data 37 mov ds,ax 38 mov ax,0b800h 39 mov es,ax 40 mov di,0 41 mov ax,stack 42 mov ss,ax 43 mov sp,10h 44 45 call clear_screen 46 call draw_rain 47 48 mov cx,5h 49 again: 50 push cx 51 call run_rain 52 pop cx 53 loop again 54 55 call over 56 57 run_rain: 58 mov di,0 59 mov cx,25 60 rrs0: 61 push cx 62 push di 63 mov cx,80 64 rrs1: 65 push cx 66 push di 67 mov ax,es:[di] 68 mov cx,24 69 rrs2: 70 add di,160 71 mov bx,es:[di] 72 mov es:[di],ax 73 mov ax,bx 74 loop rrs2 75 pop di 76 mov es:[di],ax 77 add di,2 78 pop cx 79 loop rrs1 80 call sleep_1s 81 pop di 82 pop cx 83 loop rrs0 84 ret 85 86 draw_rain: 87 mov di,0 88 mov si,0 89 mov bx,12h 90 mov cx,25 91 drs0: 92 push cx 93 push di 94 mov cx,40 95 drs1: 96 mov al,ds:[si] 97 cmp al,1 98 jne drpass 99 mov byte ptr es:[di],bl 100 mov byte ptr es:[di+1],02h 101 mov byte ptr es:[di+78],bh 102 mov byte ptr es:[di+79],02h 103 add bx,093h 104 drpass: 105 inc si 106 add di,2 107 loop drs1 108 pop di 109 add di,160 110 pop cx 111 loop drs0 112 ret 113 114 clear_screen: 115 push cx 116 push di 117 mov di,0 118 mov cx,25 119 cses0: 120 push cx 121 mov cx,80 122 cses1: 123 mov word ptr es:[di],0 124 add di,2 125 loop cses1 126 pop cx 127 loop cses0 128 pop di 129 pop cx 130 ret 131 132 sleep_1s: 133 push cx 134 mov cx,05h 135 sp10: 136 push cx 137 mov cx,0ffffh 138 sp11: 139 loop sp11 140 pop cx 141 loop sp10 142 pop cx 143 ret 144 145 over: 146 mov ax,4c00h 147 int 21h 148 code ends 149 end start
hj12.asm
时间: 2024-11-05 10:45:45