程序设计项目六
在屏幕中间显示:“中华”两个字。参看demo0.png示例。
提示:
通过字模提取工具,可以提取字的显示信息。
分析:
跟lcd12864自定义图形差不多吧
直接用字模提取软件
参考代码:
1 assume cs:code 2 data segment 3 ; -- zhong -- 4 db 00h, 1Ch, 00h, 00h, 1Ch, 00h, 00h, 1Ch, 00h 5 db 00h, 1Ch, 00h, 00h, 1Ch, 00h, 1Fh,0FFh,0FCh 6 db 1Fh,0FFh,0FCh, 1Fh,0FFh,0FCh, 1Ch, 1Ch, 1Ch 7 db 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Ch 8 db 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Ch, 1Fh,0FFh,0FCh 9 db 1Fh,0FFh,0FCh, 1Fh,0FFh,0FCh, 1Ch, 1Ch, 1Ch 10 db 00h, 1Ch, 00h, 00h, 1Ch, 00h, 00h, 1Ch, 00h 11 db 00h, 1Ch, 00h, 00h, 1Ch, 00h, 00h, 1Ch, 00h 12 13 ; -- hua -- 14 db 03h, 0Eh, 00h, 03h, 8Eh, 10h, 07h, 0Eh, 38h 15 db 0Eh, 0Eh,0F8h, 0Eh, 0Fh,0F0h, 1Eh, 0Fh,0C0h 16 db 3Eh, 1Fh, 00h, 7Eh,0FEh, 00h, 6Eh,0FEh, 00h 17 db 2Eh,0CEh, 1Ch, 0Eh, 0Fh,0FCh, 0Eh, 0Fh,0FCh 18 db 0Eh, 07h,0F8h, 0Eh, 38h, 00h, 00h, 38h, 00h 19 db 00h, 38h, 00h, 7Fh,0FFh,0FEh, 7Fh,0FFh,0FEh 20 db 00h, 38h, 00h, 00h, 38h, 00h, 00h, 38h, 00h 21 db 00h, 38h, 00h, 00h, 38h, 00h, 00h, 00h, 00h 22 data ends 23 24 stack segment 25 dw 16 dup (0) 26 stack ends 27 28 code segment 29 start: 30 31 mov ax,0b800h 32 mov es,ax 33 mov ax,data 34 mov ds,ax 35 mov ax,stack 36 mov ss,ax 37 mov sp,20h 38 mov si,0 39 call clear_scr 40 mov bh,100b 41 mov bl,03h 42 mov ah,0 43 mov dh,0 ;三个一循环 44 mov di,16 45 jmp get_bmp 46 47 get_bmp: 48 mov al,ds:[si] 49 inc si 50 inc dh 51 jmp do_16to2 52 doom: 53 mov cx,8 54 ss1: 55 pop ax 56 cmp ax,0 57 je next 58 mov es:[di],bx 59 next: 60 add di,2 61 loop ss1 62 63 cmp si,72 ;判断是否输出完中 64 jne nn 65 mov di,136 66 nn: 67 cmp si,144 ;同上,判断是否输出完 68 je over 69 cmp dh,3 70 jne get_bmp 71 mov dh,0 72 add di,112 73 jmp get_bmp 74 75 over: 76 mov ax,4c00h 77 int 21h 78 79 do_16to2: ;16进制转换 80 push cx 81 mov cx,8 82 sd0: 83 mov dl,2 84 div dl 85 mov dl,al 86 mov al,0 87 push ax 88 mov al,dl 89 loop sd0 90 jmp doom 91 92 clear_scr: 93 push cx 94 push bp 95 push di 96 mov bp,0 97 mov cx,16h 98 cs1: 99 mov di,0 100 push cx 101 mov cx,50h 102 cs2: 103 mov word ptr es:[di+bp],0 104 add di,2 105 loop cs2 106 107 add bp,0a0h 108 pop cx 109 loop cs1 110 pop di 111 pop bp 112 pop cx 113 ret 114 115 code ends 116 end start
因为字模不同:
程序设计项目七
在屏幕上显示一个兔子图形。参看demo1.gif示例。
参考代码:
1 assume cs:code 2 3 data segment 4 db '.....*........*.......' ;22row ,15line 5 db '....*..*.....*.*......' 6 db '.....*..*....*..*.....' 7 db '......*..*..*.*.*.....' 8 db '.....*.........*......' 9 db '...*.............*....' 10 db '..*...............*...' 11 db '.*.................*..' 12 db '*...................*.' 13 db '*...................*.' 14 db '*.....*.......*.....*.' 15 db '*...................*.' 16 db '*...@.....U.....@...*.' 17 db '.*.................*..' 18 db '..**.............**...' 19 data ends 20 21 stack segment 22 dw 8 dup(0) 23 stack ends 24 25 code segment 26 start: 27 mov ax,data 28 mov ds,ax 29 mov ax,0b800h 30 mov es,ax 31 mov ax,stack 32 mov ss,ax 33 mov sp,10h 34 again: ;无限循环下去 35 mov ah,0 36 mov cx,6 37 main: 38 push cx 39 call clear_scr ;清屏 40 add ah,1 41 mov di,320 42 mov si,0 43 mov cx,15 44 s0: 45 push cx 46 push di 47 mov cx,22 48 s1: 49 mov al,ds:[si] 50 mov es:[di],ax 51 add di,2 52 inc si 53 loop s1 54 55 pop di 56 add di,160 57 pop cx 58 loop s0 59 60 call sleep_ ;延迟 61 pop cx 62 loop main 63 ; jmp again 注释掉,只循环一次 64 mov ax,4c00h 65 int 21h 66 67 sleep_: 68 push cx 69 mov cx,1fh 70 slp0: 71 push cx 72 mov cx,0ffffh 73 slp1: 74 loop slp1 75 pop cx 76 loop slp0 77 pop cx 78 ret 79 80 clear_scr: 81 push cx 82 push bp 83 push di 84 mov bp,0 85 mov cx,16h 86 cs1: 87 mov di,0 88 push cx 89 mov cx,50h 90 cs2: 91 mov word ptr es:[di+bp],0 92 add di,2 93 loop cs2 94 95 add bp,0a0h 96 pop cx 97 loop cs1 98 pop di 99 pop bp 100 pop cx 101 ret 102 103 code ends 104 end start
程序设计项目八
实现笑脸阶梯走效果。参看demo2.gif示例。
参考代码:
1 assume cs:code 2 3 stack segment 4 dw 8 dup(0) 5 stack ends 6 7 code segment 8 start: 9 mov ax,0b800h 10 mov es,ax 11 mov di,18*160 12 mov dh,2 13 mov dl,'.' ;画点 14 mov cx,3 15 s0: 16 push cx 17 mov cx,20 18 s1: 19 mov es:[di],dx 20 add di,2 21 loop s1 22 pop cx 23 sub di,960 24 loop s0 25 26 smile: 27 mov di,17*160 28 mov dl,2 ;笑脸 29 mov cx,3 30 s2: 31 push cx 32 mov cx,20 33 s3: 34 mov es:[di],dx 35 call sleep 36 mov word ptr es:[di],0 37 add di,2 38 loop s3 39 pop cx 40 sub di,960 41 loop s2 42 jmp over ; 循环一次结束 43 jmp smile ;笑脸一直跳 44 45 sleep: ;休眠 46 push cx 47 mov cx,0ah 48 slp0: 49 push cx 50 mov cx,0ffffh 51 slp1: 52 loop slp1 53 pop cx 54 loop slp0 55 pop cx 56 ret 57 58 over: 59 mov ax,4c00h 60 int 21h 61 code ends 62 end start