问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

汇编语言 实现图形颜色变换

发布网友 发布时间:2022-05-18 06:37

我来回答

3个回答

热心网友 时间:2023-10-10 11:32

DATAS SEGMENT
COLOR DW 02
BKCOLOR DW 15
X DW 280,
Y DW 240,
RADIUS DW 150
DATAS ENDS

STACKS SEGMENT
DW 100 DUP(0)
STACKS ENDS

CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV AX,0A000H
MOV ES,AX
MOV AX,0012H
INT 10H ;设置640*480*16图形模式
MOV AL,2
CALL SET_WRITE_MODE ;将写模式设为写模式2
again:
MOV AX,BKCOLOR
CALL CLEAR ;将背景清成白色
MOV AX,WORD PTR [X]
PUSH AX
MOV AX,WORD PTR [Y]
PUSH AX
MOV AX,WORD PTR [RADIUS]
PUSH AX
CALL CIRCLE
MOV AH,0
INT 16H
cmp al,0dh ;回车退出
jz exit
cmp ah,2eh;Key 'C or c'
jnz skip
inc color
skip:
jmp again
quit:
mov ah,4ch
int 21h

exit:
MOV AX,4C00H
INT 21H
;******************************************
;640*480*16模式下的画点函数
;******************************************
PIXEL PROC
PUSH BP
PUSH BX
PUSH CX
PUSH DS
MOV BP,SP
MOV AX,80
MOV BX,WORD PTR[BP+12] ;BX<=Y
MUL BX ;(DX:AX)<=80*Y
MOV BX,AX ;
MOV AX,WORD PTR[BP+14] ;AX<--X
MOV CL,8 ; | |
DIV CL ;AL<=商(X/8),AH<=余数(X%8) SP-> | |
MOV CL,AH ;CL<=AH | DS |<-BP
MOV AH,0 ; | CX |<-BP+2
ADD BX,AX ;BX(OFFSET)<=80*Y+X/8 | BX |<-BP+4
MOV AL,80H ; | BP |<-BP+6
SHR AL,CL ;AL(MASK)<=(80H>>CL) |返回地址|<-BP+8
PUSH AX ; | COLOR |<-BP+10
MOV DX,3CEH ; | Y |<-BP+12
MOV AL,8 ; | X |<-BP+14
OUT DX,AL ; | |
MOV DX,3CFH ; PIXEL堆栈结构
POP AX
OUT DX,AL
MOV AL,ES:[BX]
MOV AX,WORD PTR[BP+10] ;AX<=COLOR
MOV BYTE PTR ES:[BX],AL
POP DS
POP CX
POP BX
POP BP
RET 6
PIXEL ENDP
;********************************
;清屏函数
;********************************
CLEAR PROC NEAR
MOV BX,0
CLR1: MOV ES:[BX],AL
INC BX
CMP BX,9600H;80*480
JNB CLR2
JMP CLR1
CLR2: RET
CLEAR ENDP
;***************************************
;Bresenham算法实现的画圆函数
;***************************************
CIRCLE PROC NEAR
PUSH BP
MOV BP,SP
SUB SP,6
MOV WORD PTR[BP-2],0 ;X<=0 | |
MOV AX,WORD PTR[BP+4] ; | |
MOV WORD PTR[BP-4],AX ;Y<=R SP-> | |
MOV AX,0FFFEH ; | P |<-BP-6
IMUL WORD PTR[BP+4] ;AX<=RADIUS*(-2) | Y |<-BP-4
ADD AX,3 ;AX<=3-2*RADIUS | X |<-BP-2
MOV WORD PTR[BP-6],AX ;P=3-2*RADIUS | BP |<-BP
C0: MOV AX,WORD PTR[BP-2] ;AX<=X |返回地址|<-BP+2
CMP AX,WORD PTR[BP-4] ;IF X<Y,JMP C00 | RADIUS |<-BP+4
JL C00 ; | YC |<-BP+6
JMP C3 ; | XC |<-BP+8
C00: PUSH WORD PTR[BP+8] ; CIRCLE堆栈结构
PUSH WORD PTR[BP+6] ;
PUSH WORD PTR[BP-2]
PUSH WORD PTR[BP-4]
CALL CIRCLE_POINT
CMP WORD PTR[BP-6],0
JGE C1
MOV AX,4
MUL WORD PTR[BP-2]
ADD AX,6
ADD AX,WORD PTR[BP-6]
MOV WORD PTR[BP-6],AX
JMP C2
C1: MOV AX,WORD PTR[BP-2]
SUB AX,WORD PTR[BP-4]
MOV BX,4
IMUL BX
ADD AX,10
ADD AX,WORD PTR[BP-6]
MOV WORD PTR[BP-6],AX
DEC WORD PTR[BP-4]
C2: INC WORD PTR[BP-2]
JMP C0
C3: MOV AX,WORD PTR[BP-2]
CMP AX,WORD PTR[BP-4]
JNE C4
PUSH WORD PTR[BP+8]
PUSH WORD PTR[BP+6]
PUSH WORD PTR[BP-2]
PUSH WORD PTR[BP-4]
CALL CIRCLE_POINT
C4: MOV SP,BP
POP BP
RET 6
CIRCLE ENDP

CIRCLE_POINT PROC NEAR
PUSH BP
MOV BP,SP
SUB SP,16
MOV AX,WORD PTR[BP+10] ;
ADD AX,WORD PTR[BP+6] ;
MOV WORD PTR[BP-2],AX ;XC+X
MOV AX,WORD PTR[BP+10] ;
SUB AX,WORD PTR[BP+6] ;
MOV WORD PTR[BP-4],AX ;XC-X
MOV AX,WORD PTR[BP+10] ; | |
ADD AX,WORD PTR[BP+4] ; | |
MOV WORD PTR[BP-6],AX ;XC+Y | |
MOV AX,WORD PTR[BP+10] ; SP-> | |
SUB AX,WORD PTR[BP+4] ; | YC-Y |<-BP-16
MOV WORD PTR[BP-8],AX ;XC-Y | YC+Y |<-BP-14
MOV AX,WORD PTR[BP+8] ; | YC-X |<-BP-12
ADD AX,WORD PTR[BP+6] ; | YC+X |<-BP-10
MOV WORD PTR[BP-10],AX ;YC+X | XC-Y |<-BP-8
MOV AX,WORD PTR[BP+8] ; | XC+Y |<-BP-6
SUB AX,WORD PTR[BP+6] ; | XC-X |<-BP-4
MOV WORD PTR[BP-12],AX ;YC-X | XC+X |<-BP-2
MOV AX,WORD PTR[BP+8] ; | BP |<-BP
ADD AX,WORD PTR[BP+4] ; |返回地址|<-BP+2
MOV WORD PTR[BP-14],AX ;YC+Y | Y |<-BP+4
MOV AX,WORD PTR[BP+8] ; | X |<-BP+6
SUB AX,WORD PTR[BP+4] ; | YC |<-BP+8
MOV WORD PTR[BP-16],AX ;YC-Y | XC |<-BP+10
PUSH WORD PTR[BP-2] ; | |
PUSH WORD PTR[BP-14] ; CIRCLE_POINT堆栈结构
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-4]
PUSH WORD PTR[BP-14]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-2]
PUSH WORD PTR[BP-16]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-4]
PUSH WORD PTR[BP-16]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-6]
PUSH WORD PTR[BP-10]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-8]
PUSH WORD PTR[BP-10]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-6]
PUSH WORD PTR[BP-12]
PUSH COLOR
CALL PIXEL
PUSH WORD PTR[BP-8]
PUSH WORD PTR[BP-12]
PUSH COLOR
CALL PIXEL
MOV SP,BP
POP BP
RET 8
CIRCLE_POINT ENDP
;********************************
;设置写模式的函数
;********************************
SET_WRITE_MODE PROC NEAR
PUSH AX
MOV DX,3CEH
MOV AL,5
OUT DX,AL
MOV DX,3CFH
POP AX
OUT DX,AL
MOV DX,3CEH
MOV AL,8
OUT DX,AL
MOV DX,3CFH
MOV AL,0FFH
OUT DX,AL
RET
SET_WRITE_MODE ENDP
CODES ENDS
end start

热心网友 时间:2023-10-10 11:33

DATAS
SEGMENT
COLOR
DW
02
BKCOLOR
DW
15
X
DW
280,
Y
DW
240,
RADIUS
DW
150
DATAS
ENDS
STACKS
SEGMENT
DW
100
DUP(0)
STACKS
ENDS
CODES
SEGMENT
ASSUME
CS:CODES,DS:DATAS,SS:STACKS
START:
MOV
AX,DATAS
MOV
DS,AX
MOV
AX,0A000H
MOV
ES,AX
MOV
AX,0012H
INT
10H
;设置640*480*16图形模式
MOV
AL,2
CALL
SET_WRITE_MODE
;将写模式设为写模式2
again:
MOV
AX,BKCOLOR
CALL
CLEAR
;将背景清成白色
MOV
AX,WORD
PTR
[X]
PUSH
AX
MOV
AX,WORD
PTR
[Y]
PUSH
AX
MOV
AX,WORD
PTR
[RADIUS]
PUSH
AX
CALL
CIRCLE
MOV
AH,0
INT
16H
cmp
al,0dh
;回车退出
jz
exit
cmp
ah,2eh;Key
'C
or
c'
jnz
skip
inc
color
skip:
jmp
again
quit:
mov
ah,4ch
int
21h
exit:
MOV
AX,4C00H
INT
21H
;******************************************
;640*480*16模式下的画点函数
;******************************************
PIXEL
PROC
PUSH
BP
PUSH
BX
PUSH
CX
PUSH
DS
MOV
BP,SP
MOV
AX,80
MOV
BX,WORD
PTR[BP+12]
;BX<=Y
MUL
BX
;(DX:AX)<=80*Y
MOV
BX,AX
;
MOV
AX,WORD
PTR[BP+14]
;AX<--X
MOV
CL,8
;
|
|
DIV
CL
;AL<=商(X/8),AH<=余数(X%8)
SP->
|
|
MOV
CL,AH
;CL<=AH
|
DS
|<-BP
MOV
AH,0
;
|
CX
|<-BP+2
ADD
BX,AX
;BX(OFFSET)<=80*Y+X/8
|
BX
|<-BP+4
MOV
AL,80H
;
|
BP
|<-BP+6
SHR
AL,CL
;AL(MASK)<=(80H>>CL)
|返回地址|<-BP+8
PUSH
AX
;
|
COLOR
|<-BP+10
MOV
DX,3CEH
;
|
Y
|<-BP+12
MOV
AL,8
;
|
X
|<-BP+14
OUT
DX,AL
;
|
|
MOV
DX,3CFH
;
PIXEL堆栈结构
POP
AX
OUT
DX,AL
MOV
AL,ES:[BX]
MOV
AX,WORD
PTR[BP+10]
;AX<=COLOR
MOV
BYTE
PTR
ES:[BX],AL
POP
DS
POP
CX
POP
BX
POP
BP
RET
6
PIXEL
ENDP
;********************************
;清屏函数
;********************************
CLEAR
PROC
NEAR
MOV
BX,0
CLR1:
MOV
ES:[BX],AL
INC
BX
CMP
BX,9600H;80*480
JNB
CLR2
JMP
CLR1
CLR2:
RET
CLEAR
ENDP
;***************************************
;Bresenham算法实现的画圆函数
;***************************************
CIRCLE
PROC
NEAR
PUSH
BP
MOV
BP,SP
SUB
SP,6
MOV
WORD
PTR[BP-2],0
;X<=0
|
|
MOV
AX,WORD
PTR[BP+4]
;
|
|
MOV
WORD
PTR[BP-4],A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R[BP-8]
PUSH
WORD
PTR[BP-10]
PUSH
COLOR
CALL
PIXEL
PUSH
WORD
PTR[BP-6]
PUSH
WORD
PTR[BP-12]
PUSH
COLOR
CALL
PIXEL
PUSH
WORD
PTR[BP-8]
PUSH
WORD
PTR[BP-12]
PUSH
COLOR
CALL
PIXEL
MOV
SP,BP
POP
BP
RET
8
CIRCLE_POINT
ENDP
;********************************
;设置写模式的函数
;********************************
SET_WRITE_MODE
PROC
NEAR
PUSH
AX
MOV
DX,3CEH
MOV
AL,5
OUT
DX,AL
MOV
DX,3CFH
POP
AX
OUT
DX,AL
MOV
DX,3CEH
MOV
AL,8
OUT
DX,AL
MOV
DX,3CFH
MOV
AL,0FFH
OUT
DX,AL
RET
SET_WRITE_MODE
ENDP
CODES
ENDS
end
start

热心网友 时间:2023-10-10 11:33

不要找答案了 刚刚验证过了 DIDIDU1515 代码超棒
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
为什么来大姨妈胸会胀 少儿学什么舞蹈 青年学什么舞蹈好 成年人学什么舞蹈 福州企业最低工资标准 2013年厦门的底薪是多少 生产要素的需求有哪些性质 生产要素的需求有何特点? 什么是生产要素需求 微观经济学要素需求什么是条件要素需求?它和要素需求有什么不同?_百度... MOV BYTE PTR[BP],20H和MOV WORD PTR[BX],2000H什么意思?有区别吗? mov word ptr [bp], word ptr [bx] mov word ptr 2[bp], word ptr 2[bx] 哪里错了?不正确的操作数类型 如何选择轮滑鞋呢? 如何选择轮滑鞋 小朋友该怎么选择轮滑鞋呢? 轮滑鞋怎么选择 法务会计 哪所大学招收法学在职研究生? 哪个学校的在职研究生比较好?法学方向的、 在职研究生有什么类型?有什么具体用途?在职研究生哪个专业好一些? 报读法大在职研有年龄限制吗? 请问有谁知道“法务会计”的在职研究生究竟有没有用处呀?都能学些什么?能有什么收获呢?谢啦! 法务会计在职研究生报考简单吗 中国政法大学法务会计在职研究生怎么样? 如何多加人 如何多加人 很瘦的女生该怎么锻炼 特别瘦的女生对别人说自己有点体力不足,别人听了会怎么想这个女生? 很瘦的女生会让人有保护欲吗 这么瘦的女孩子还多见吗? INC BYTE/word PTR [BX] 是什么意思?和inc bx的区别? 淘宝上出现金牌卖家是什么意思? 淘宝金牌卖家有什么作用 淘宝“金牌卖家”有哪些特权 乾清宫简 中式花格cad图库 中式花格一般厚度 fzxkjw gb1 0是什么字体 MSP430仿真器出问题了 怎么办 求大神帮助 新手,如何进行MSP430的程序仿真和调试?我使用的是USB的仿真器 msp430仿真器仿真的内容是什么,有些程序使用仿真器,但是开发板上就没有相应的动作 msp430 usb仿真器怎么用啊,都设置好了,程序还是下不进去。看网上说插上去时,电脑会显示驱动 msp430仿真器怎样才算链接到开发板? msp430怎么写、下程序? 一个单片机程序从写程序,仿真,到烧到单片机里都要用哪些软件,(msp430单片机) 乐扣乐扣是什么意思 乐扣乐扣是啥 乐扣用英语怎么说 什么是乐扣 乐扣乐扣拼音是lekoulekou?