一个字符图形程序

这是一个使用汇编语言完成的小程序,通过存储器映射法在DOS环境下制作字符图形,并用光标控制键在画图区移动,选择不同字符图形进行绘制。按下ESC键退出程序。
部署运行你感兴趣的模型镜像

  

  这个是学完汇编后,做的第一个小程序.程序很小,当时却对此颇为满意.自认为是自己做的第一个成型的程序.为缅怀那份得意的心情,先把这个勉为其难称为程序的程序放在这:).

  简介:制作图形元素表,表中将所需的各种字符图形编上号码,并用存储器映射法将其显示在屏幕的左上部分。将光标定位在屏幕的右半部分画图区。上、下、左、右光标控制键控制光标在四个方向上移动,不显示其轨迹同时要控制光标位置不超出画图区的边界。当按动某一数字键时,在光标位置处显示出相应编号的字符图形,然后移动光标,再显示一个字符图形,最后绘制出一幅由字符组成的图形。按动ESCape键,退出程序,返回DOS

 

data  segment

buffer  db   200 dup(?)                                            

db1   db   1

db2   db   0

db3   db   00h

msg1 db 'THE TABLE:  THE DRAWING AREA:(press "esc" key to exit)','$'

data ends

program  segment

main      proc    far

        assume cs:program,ds:data 

start:

     push ds

     sub ax,ax

     push ax

mov ax,data

mov ds,ax

 

     mov ah,09

lea dx,msg1               ;显示信息

int 21h 

                         

mov bx,26

     mov db1,0                ;显示分界线

     mov db2,36

op:

     mov ah,2

     mov bh,0  

     mov dh,db1              ;初始化光标

     mov dl,db2

     int 10h

mov bh,0

     mov cx,1

     mov al,2ah

     mov ah,0ah

     int 10h

     inc db1

     dec bx

     jnz op

 mov db1,1

     mov db2,0

     mov si,0

op1:                          ;制作图形元素表

     mov ah,2

     mov bh,0  

     mov dh,db1                   ;定位光标

     mov dl,db2

     int 10h

 

     mov al,db3

     mov buffer[si],al               ;显示数字并存入ASCII

     push si

     add si,30h

     mov bh,0

     mov ax,si

     and ax,00ffh

     mov cx,1

     mov ah,0ah

     int 10h

    

     inc db2

     cmp db2,39                   ;判断是否过界

     jna  op2

     inc  db1

     mov db2,0

 

op2:  mov ah,2

     mov bh,0  

     mov dh,db1                   ;重定位光标

     mov dl,db2

     int 10h

    

     mov ah,0ah     

     mov bh,0                     ;显示字符

 

     mov al,db3

     mov cx,1

     int 10h

 

     pop si

     inc si

     inc db3

     cmp db3,09h

     ja over

add db2,7                   

  cmp db2,39              ;判断是否过界

     jna  op1

     inc  db1

      mov db2,0

     jmp op1

over:       

   mov db1,1

   mov db2,38

 

   mov ah,2

   mov bh,0  

   mov dh,1

   mov dl,38                ;初始化光标

   int 10h

  

opp0: 

  mov ah,0

  int 16h                   ;判断输入键

  cmp ah,48h               ;方向键

  je up                  

  cmp ah,50h

  je down

  cmp ah,4dh

  je right

  cmp ah,4bh

  je left

  cmp ah,01h                ESC

 

  jnz rr

     ret

rr:  cmp al,30h              ;数字键

  jnb opp2

  jmp opp0

opp2:

  cmp al,39h

  ja  opp0

  and ax,00ffh

  sub ax,30h

  mov si,ax

  mov al,buffer[si]           ;显示相应字符

  mov bh,0

  mov cx,1

  mov ah,0ah

  int 10h

jmp opp0

up:

   dec db1

   jz  edg_up

   jmp opp1               ;定界线

edg_up:

   mov db1,1

   jmp opp1

down:

   inc db1

   cmp db1,24

   ja  edg_down

   jmp opp1

edg_down:

   mov db1,24

   jmp opp1

right:

   inc db2

   cmp db2,78

   ja edg_right

   jmp opp1

edg_right:

   mov db2,78

   jmp opp1

left:

   dec db2

   cmp db2,38

   jb  edg_left

   jmp opp1

edg_left:

   mov db2,38

opp1:  

   mov ah,2

   mov bh,0                ;重定位光标

   mov dh,db1

   mov dl,db2

   int 10h

   jmp opp0

exit:

   ret                      ;返回DOS

main endp

program  ends

   end start

 

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

data segment<br>car db 133 ;定义字符图形表<br> db 05h,122,0,0<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1 <br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,0,3<br> db 05h,122,1,0<br> db 05h,122,2,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,-8,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,0,7<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0 <br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0 <br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1 <br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,2,2<br> db 05h,122,0,1<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,0,-1 <br> db 05h,122,-2,0<br> db 05h,122,2,2<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-2,0<br> db 05h,122,0,6<br> db 05h,122,3,0<br> db 05h,122,0,1 <br> db 05h,122,-3,0<br> db 05h,122,-3,1<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,0,2<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,-1,-2<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,-1,-2<br> db 05h,122,-1,0<br> db 05h,122,-1,0<br> db 05h,122,0,9 <br> db 05h,122,1,-3 <br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,0,1<br> db 05h,122,2,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,1,0<br> db 05h,122,0,4<br> db 05h,122,1,0<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,0,-1<br> db 05h,122,1,2<br> db 05h,122,1,0 <br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,1,0<br> db 05h,122,-3,-1<br> db 05h,122,0,2<br> db 05h,122,1,1<br> db 05h,122,0,-4<br> db 05h,122,1,-1<br> db 05h,122,0,6<br>char_cnt dw ? <br>pointer dw ?<br>line_on db ?<br>col_on db ?<br>data ends<br>stack segment<br> db 2000 dup (0)<br>stack ends<br>code segment<br> assume cs:code,ds:data,ss:stack<br>main proc far<br> push ds<br> sub ax,ax<br> push ax<br> mov ax,data<br> mov ds,ax<br> <br>   mov ah,0<br> mov al,4<br> int 10h<br> <br> mov ah,0bh<br> mov bh,0<br> mov bl,2<br> int 10h<br> <br> mov ah,0bh<br> mov bh,01<br> mov bl,00<br> int 10h<br> <br> call clear_screen ;调用清屏子程序<br> lea di,car<br> mov dh,10<br> mov dl,2<br> call move_shape <br> mov ah,8<br> int 21h<br> cmp al,'q'<br> jz exit<br> main endp <br><br>clear_screen proc near<br> push ax<br> push bx<br> push cx<br> push dx<br> mov ah,6<br> mov al,0<br> mov ch,0<br> mov cl,0<br> mov dh,120<br> mov dl,200<br> mov bh,7<br> int 10h<br> pop dx<br> pop cx<br> pop bx<br> pop ax<br> ret<br>clear_screen endp<br><br>move_shape proc near<br> push ax<br> push bx<br> push cx<br> push dx<br> push di<br> mov ah,0fh<br> int 10h<br> sub ch,ch<br> mov cl,[di]<br> inc di<br> mov char_cnt,cx<br> mov pointer,di<br> mov line_on,dh<br> mov col_on,dl<br>mov_crsr: <br> add dh,[di+2]<br> add dl,[di+3]<br> mov ah ,2<br> int 10h<br> mov al,[di]<br> mov bl,[di+1]<br> push cx<br> mov cx,1<br> mov ah,09<br> int 10h<br> pop cx<br> add di,4<br> loop mov_crsr<br> call dly_qrtr     ;调用延时子程序<br> pop di <br> pop dx<br> pop cx<br> pop bx<br> pop ax<br> ret<br>move_shape endp<br><br>dly_qrtr proc near <br> push cx<br> push dx<br> mov dx,5000<br> d11:mov cx,25000 <br> d12:loop d12<br> dec dx<br> jnz d11<br> pop dx<br> pop cx<br> ret<br>dly_qrtr endp<br>exit:mov ah,4ch<br> int 21h<br>code ends<br> end main<br><br><br><br>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值