当前位置:网站首页>用汇编实现爱心特效【七夕来袭】
用汇编实现爱心特效【七夕来袭】
2022-08-02 09:20:00 【timerring】
七夕来袭!是时候展现专属于程序员的浪漫了!你打算怎么给心爱的人表达爱意?鲜花礼物?代码表白?还是创意DIY?或者…无论那种形式,快来一起分享吧!当然,首先你得有个对象。
创意代码表白
运行环境
程序环境为DOS汇编,若在Windows上虚拟DOS环境下运行,配以Masm for windows即可。
效果展示
1.首先是用绿线围住这颗爱心
2.然后用绿线对爱心周围进行填充
3.填充过后再复原这颗爱心
4.最后展示一下爱心复原的过程
- 源码放到下面啦,程序的基本思路就是写出每个功能的子程序,然后调用绘图。
- 大家可以在恰当的节日里向Ta表达自己的爱心。
Source Code
Data segment
full db 0
buff1 db ' Welcome to the special effects of the juejin hearts!'
db ' '
db ' *****Please press any key*****$'
buff2 db ' Beating Heart'
db ' ***** Please q to quit *****$'
Data ends
code segment
assume cs: code , ds: Data
start:
push ds
sub ax,ax
push ax
mov ax, Data
mov ds, ax
mov ah, 0
mov al, 4
int 10h
mov ah,0bh
mov bh, 0
mov bl, 1
int 10h
mov ah,0bh
mov bh, 1
mov bl, 2
int 10h
mov dx,offset buff1 ;显示提示信息
mov ah, 9
int 21h
mov ah, 8
int 21h
call clear ;cls
sss:
call text ;display the text
mov di, 2
mov al,1 ;draw the big box
mov cx, 70
mov dx, 20
mov bx, 160
Call box
mov cx, 71
mov dx, 21
mov bx, 158
again:
mov al, 1
mov di, 0
Call box
Call delay
mov al, 0
mov di, 0
Call box
inc cx
inc dx
sub bx,2
cmp cx, 94
jnz again
mov di,0 ;draw the 2nd box
mov cx, 95
mov dx, 45
mov al, 1
mov bx, 110
Call box
mov cx, 96
mov dx, 46
mov bx, 108
again_00:
mov al, 1
mov di, 0
Call box
Call delay
Call delay
mov al, 0
mov di, 0
Call box
inc cx
inc dx
sub bx,2
cmp cx, 114
jnz again_00
mov cx,115 ;draw the 3rd box
mov dx, 65
mov al, 1
mov bx, 70
Call box
mov cx, 116
mov dx, 66
mov bx, 68
again_01:
mov al, 1
mov di, 0
Call box
Call delay
Call delay
mov al, 0
mov di, 0
Call box
inc cx
inc dx
sub bx,2
cmp cx, 129
jnz again_01
mov di, 2
mov al,1 ;draw the small box
mov cx, 130
mov dx, 80
mov bx, 40
Call box
mov di, 2
mov al,3 ;对角线
mov si, 0
mov cx, 71
mov dx, 21
mov bx, 59
Call xie_line
mov cx, 171
mov dx, 121
mov bx, 59
Call xie_line
mov si, 1
mov cx, 71
mov dx, 179
mov bx, 59
Call xie_line
mov cx, 171
mov dx, 79
mov bx, 59
Call xie_line
mov cx,150 ;十字线
mov dx, 20
mov si, 0
mov bx, 60
Call draw_line
mov cx, 150
mov dx, 120
mov bx, 60
Call draw_line
mov cx, 70
mov dx, 100
mov si, 1
mov bx, 60
Call draw_line
mov cx, 170
mov dx, 100
mov bx, 60
Call draw_line
mov si, 1
mov cx, 70
mov dx, 60
mov bx, 60
Call mid_line
mov cx, 170
mov dx, 110
mov bx, 60
Call mid_line
mov si, 2
mov cx, 110
mov dx, 20
mov bx, 30
Call mid_line
mov cx, 160
mov dx, 120
mov bx, 30
Call mid_line
mov si, 3
mov cx, 70
mov dx, 140
mov bx, 60
Call mid_line
mov cx, 170
mov dx, 90
mov bx, 60
Call mid_line
mov si, 4
mov cx, 110
mov dx, 180
mov bx, 30
Call mid_line
mov cx, 160
mov dx, 80
mov bx, 30
Call mid_line
mov di, 0
mov al,1 ;draw the big box again
mov cx, 70
mov dx, 20
mov bx, 160
Call box
mov di, 0
mov al,1 ;draw the small box again
mov cx, 130
mov dx, 80
mov bx, 40
Call box
mov di, 0
mov cx, 95
mov dx, 45
mov al, 1
mov bx, 110
Call box
mov cx, 115
mov dx, 65
mov al, 1
mov bx, 70
Call box
mov di,1 ;fill
Call fill
Call fill_2
Call fill_3
mov cx,149 ;bold
mov dx, 120
mov al, 2
mov bx, 60
mov si, 0
Call draw_line
mov cx, 151
mov dx, 120
mov al, 2
mov bx, 60
mov si, 0
Call draw_line
heart_: ;draw the heart
Call cls_box
Call heart
mov ah, 8
int 21h
cmp al,'q'
jz ok
cmp al,20h
jz heart_
Call Clear
jmp sss
ok:
ret
fill proc near ;the procedure of fill
mov full, 0
mov al, 5
mov cx, 160
mov dx, 121
mov si, 0
mov bx, 60
fill_Y:
push cx
push dx
push bx
Call draw_line
pop bx
pop dx
pop cx
sub bx,2
inc cx
Add dx, 2
inc full
cmp full, 30
jne fill_Y
ret
fill endp
fill_2 proc near
mov full, 0
mov al, 5
mov cx, 140
mov dx, 121
mov si, 0
mov bx, 60
fill_Y1:
push cx
push dx
push bx
Call draw_line
pop bx
pop dx
pop cx
sub bx,2
dec cx
Add dx, 2
inc full
cmp full, 30
jne fill_Y1
ret
fill_2 endp
fill_3 proc near
mov al, 1
mov full, 0
mov si, 0
mov cx, 140
mov dx, 121
mov bx, 60
re_fill:
push bx
push cx
push dx
Call draw_line
pop dx
pop cx
pop bx
inc cx
inc full
cmp full, 9
jne re_fill
mov full, 0
mov cx, 159
mov dx, 121
mov bx, 60
re_fill2:
push bx
push cx
push dx
Call draw_line
pop dx
pop cx
pop bx
dec cx
inc full
cmp full, 9
jne re_fill2
ret
fill_3 endp
draw_Line proc near ;the procedure of draw a line
push bx
cmp si, 0
jz V_line1
Add bx, cx
H_line:
mov ah,0ch
int 10h
cmp di, 0
jz aa0
cmp di, 1
jz aa1
Call delay
aa1:
Call delay
aa0:
inc cx
cmp cx, bx
jne H_line
jmp exit_line
V_line1:
Add bx, dx
V_line:
mov ah,0ch
cmp di, 0
jz bb0
cmp di, 1
jz bb1
Call delay
bb1:
Call delay
bb0:
int 10h
inc dx
cmp dx, bx
jne V_line
exit_line:
pop bx
ret
draw_line endp
xie_line proc near ;the procedure of draw a xie_line
Add bx, cx
cmp si, 1
jz xieline_1
xieline_0:
mov ah,0ch
int 10h
inc dx
inc cx
cmp cx, bx
jne xieline_0
jmp exit_xie
xieline_1:
mov ah,0ch
int 10h
dec dx
inc cx
cmp cx, bx
jne xieline_1
exit_xie:
ret
xie_line endp
Mid_line proc near ;draw a xie_line
Add bx, cx
cmp si, 2
jz midline_2
cmp si, 3
jz midline_3
cmp si, 4
jz midline_4
midline_1:
mov ah,0ch
int 10h
inc dx
Add cx, 2
cmp cx, bx
jne midline_1
jmp exit_lines
midline_2:
mov ah,0ch
int 10h
Add dx, 2
inc cx
cmp cx, bx
jne midline_2
jmp exit_lines
midline_3:
mov ah,0ch
int 10h
dec dx
Add cx, 2
cmp cx, bx
jne midline_3
jmp exit_lines
midline_4:
mov ah,0ch
int 10h
sub dx,2
inc cx
cmp cx, bx
jne midline_4
exit_lines:
ret
mid_line endp
box proc near ;draw a box
push cx
push dx
push cx
push dx
push cx
push dx
push cx
push dx
mov si, 1
call draw_line ;top
pop dx
pop cx
Add cx, bx
mov si, 0
call draw_line ;right
pop dx
pop cx
mov si, 0
call draw_line ;left
pop dx
pop cx
mov si, 1
Add dx, bx
call draw_line ;bottom
pop dx
pop cx
ret
box endp
space proc near ;display a space
mov ah, 2
mov dl,' '
int 21h
ret
Space endp
return proc near ;回车
mov ah, 2
mov dl,0ah
int 21h
mov dl,0dh
int 21h
ret
return endp
text proc near ;显示文本信息
mov bh, 0
mov dh, 0
mov dl, 0
mov ah, 2
int 10h
mov dx,offset buff2
mov ah, 9
int 21h
Text endp
heart proc near
mov cx,136 ;draw_heart
mov dx, 93
mov si, 0
mov bx, 5
mov al, 2
Call draw_line
mov cx,137 ;draw_heart
mov dx, 91
mov si, 0
mov bx, 9
Call draw_line
mov cx,138 ;draw_heart
mov dx, 90
mov si, 0
mov bx, 12
Call draw_line
mov cx,139 ;draw_heart
mov dx, 89
mov si, 0
mov bx, 14
Call draw_line
mov cx,140 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 16
Call draw_line
mov cx,141 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 17
Call draw_line
mov cx,142 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 19
Call draw_line
mov cx,143 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 20
Call draw_line
mov cx,144 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 21
Call draw_line
mov cx,145 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 21
Call draw_line
mov cx,146 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 22
Call draw_line
mov cx,147 ;draw_heart
mov dx, 89
mov si, 0
mov bx, 22
Call draw_line
mov cx,148 ;draw_heart
mov dx, 90
mov si, 0
mov bx, 22
Call draw_line
mov cx,149 ;draw_heart
mov dx, 91
mov si, 0
mov bx, 22
Call draw_line
mov cx,150 ;1draw_heart
mov dx, 91
mov si, 0
mov bx, 22
Call draw_line
mov cx,151 ;draw_heart
mov dx, 90
mov si, 0
mov bx, 22
Call draw_line
mov cx,152 ;draw_heart
mov dx, 89
mov si, 0
mov bx, 22
Call draw_line
mov cx,153 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 22
Call draw_line
mov cx,154 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 21
Call draw_line
mov cx,155 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 21
Call draw_line
mov cx,156 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 20
Call draw_line
mov cx,157 ;draw_heart
mov dx, 87
mov si, 0
mov bx, 19
Call draw_line
mov cx,158 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 17
Call draw_line
mov cx,159 ;draw_heart
mov dx, 88
mov si, 0
mov bx, 16
Call draw_line
mov cx,160 ;draw_heart
mov dx, 89
mov si, 0
mov bx, 14
Call draw_line
mov cx,161 ;draw_heart
mov dx, 90
mov si, 0
mov bx, 12
Call draw_line
mov cx,162 ;draw_heart
mov dx, 91
mov si, 0
mov bx, 9
Call draw_line
mov cx,163 ;draw_heart
mov dx, 93
mov si, 0
mov bx, 5
Call draw_line
ret
heart endp
delay proc near ;the procedure of delay
push cx
push dx
mov dx, 25
dl2:
mov cx, 2801
dl3:
loop dl3
dec dx
jnz dl2
pop dx
pop cx
ret
delay endp
clear proc near ;clear
mov al, 0
mov bx, 0
mov cx, 0
mov dx, 0
line:
mov ah,0ch
int 10h
inc cx
cmp cx, 320
jne line
mov cx, 0
inc dx
cmp dx, 200
jne line
ret
Clear endp
cls_box proc near
mov al, 0
mov bx, 0
mov cx, 131
mov dx, 81
s_line:
mov ah,0ch
int 10h
inc cx
cmp cx, 170
jne s_line
mov cx, 131
inc dx
cmp dx, 120
jne s_line
ret
cls_box endp
code ends
end start
边栏推荐
- AutoJs学习-实现谢尔宾斯基三角
- 新起点丨MeterSphere开源持续测试平台v2.0发布
- nacos项目搭建
- location对象,navigator对象,history对象学习
- HCIP笔记十六天
- MySQL读写分离与主从延迟
- 【Flink 问题】Flink 如何提交轻量jar包 依赖该如何存放 会遇到哪些问题
- [Must read] Mylander valuation analysis, electrical stimulation products for pelvic and postpartum rehabilitation
- C Language Basics_Union
- What is the function of the import command of the page directive in JSP?
猜你喜欢
It's time for bank data people who are driven crazy by reporting requirements to give up using Excel for reporting
每天花2小时恶补腾讯T8纯手打688页SSM框架和Redis,成功上岸美团
使用scrapy 把爬到的数据保存到mysql 防止重复
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一:解题思路
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
MySQL安装与卸载详细教程
1对1视频源码——快速实现短视频功能提升竞争力
Tencent T8 architect, teach you to learn small and medium R&D team architecture practice PDF, senior architect shortcut
Navicat连接MySQL时弹出:1045:Access denied for user ‘root’@’localhost’
破解wifi密码 暴力破解 保姆式教学
随机推荐
HCIA动态主机配置协议实验(dhcp)
【Redis】通用命令
破解wifi密码 暴力破解 保姆式教学
【微信小程序2】事件绑定
Bigder:41/100生产bug有哪些分类
你有了解过这些架构设计,架构知识体系吗?(架构书籍推荐)
How to use postman
PyQt5 (a) PyQt5 installation and configuration, read from the folder and display images, simulation to generate the sketch image
Postman download localization of installation and use
Worship, Alibaba distributed system development and core principle analysis manual
在 QT Creator 上配置 opencv 环境的一些认识和注意点
node制作一个视频帧长图生成器
练习40,小蓝的旅行【最短路】
sql concat(),如何才能拼接表的名字
UVM事务级建模
The use of thread pool and analysis of ThreadPoolExecutor source code
day——05 迭代器,生成器
Jenkins--基础--07--Blue Ocean
【打新必读】麦澜德估值分析,骨盆及产后康复电刺激产品
四字节的float比八字结的long范围大???