程序设计项目九
将ASCII码按顺序在屏幕上竖列显示。参看demo3.gif示例。
要求:
(1)逐个显示字符,相邻的两个字符之间显示要有时间间隔。
(2)字符颜色为绿色。
(3)每列显示20个字符,列间距为5个字符。显示完128个ASCII码,共需7列。
参考代码:
1 assume cs:code 2 3 stack segment 4 dw 16 dup (0) 5 stack ends 6 7 code segment 8 start: 9 mov ax,0b800h 10 mov es,ax 11 mov ax,stack 12 mov ss,ax 13 mov sp,20h 14 mov dh,02h 15 mov dl,0 16 mov di,280 17 mov cx,7 18 s0: 19 push cx 20 push di 21 mov cx,20 22 s1: 23 mov es:[di],dx 24 cmp dl,127 25 je over 26 inc dl 27 add di,160 28 call sleep 29 loop s1 30 pop di 31 sub di,10 32 pop cx 33 loop s0 34 jmp over 35 36 sleep: 37 push cx 38 mov cx,2 39 ssl: 40 push cx 41 mov cx,0ffffh 42 ssl1: 43 loop ssl1 44 pop cx 45 loop ssl 46 pop cx 47 ret 48 49 over: 50 mov ax,4c00h 51 int 21h 52 code ends 53 end start
hj9.asm
程序设计项目十
在屏幕上斜着显示三个‘happy spring festival!’,字符串的颜色分别为蓝色、绿色和红色,并且各个字符串的颜色按规律变换。参看demo4.gif示例。
参考代码:
1 assume cs:code 2 3 data segment 4 db ‘happy spring festival! ‘ 5 db 01h,02h,04h,01h,02h 6 data ends 7 8 stack segment 9 dw 8 dup (0) 10 stack ends 11 12 code segment 13 start: 14 mov ax,data 15 mov ds,ax 16 mov ax,0b800h 17 mov es,ax 18 mov ax,stack 19 mov ss,ax 20 mov sp,10h 21 again: 22 mov si,0 23 mov bp,23 24 mov di,500 25 mov cx,3 26 main: 27 push cx 28 push si 29 push di 30 mov cx,23 31 s0: 32 mov al,ds:[si] 33 mov ah,ds:[bp] 34 mov es:[di],ax 35 mov ah,ds:[bp+1] 36 mov es:[di+6],ax 37 mov ah,ds:[bp+2] 38 mov es:[di+12],ax 39 add di,164 40 inc si 41 loop s0 42 43 inc bp 44 call sleep 45 pop di 46 pop si 47 pop cx 48 loop main 49 50 ; jmp again 51 jmp over 52 53 sleep: 54 push cx 55 mov cx,20 56 sslp: 57 push cx 58 mov cx,0ffffh 59 ssl: 60 loop ssl 61 pop cx 62 loop sslp 63 pop cx 64 ret 65 66 over: 67 mov ax,4c00h 68 int 21h 69 code ends 70 end start
hj10.asm
时间: 2024-10-09 23:43:23