求大神帮我给代码添加尽可能多的注释,哪怕是很弱智的注释也行,最好一眼看上去密密麻麻的!!!
其次请大神在原有功能不变的前提下,帮我改一下代码。(因为是copy别人的,怕交上去被发现)
就这两个要求!!!尽快呀!!!急要!!!可以追加点数!!!
proth equ 290h
protlr equ 298h
protly equ 2a0h
DATA SEGMENT
min1 DB 00h,01h,02h,03h,04h,05h,06h,07h
BUFF1 DB 15H, 09H, 15H, 11H, 55H, 0FFH, 5EH, 11H
BUFF2 DB 7bh, 49h, 0f1h, 41h, 0ffh, 28h, 0fch, 22h
FREQ_L DW 524,20,524,20,784,20,784,20,880,20,880,20
DW 784,20,698,20,698,20,660,20,660,20,588,20
DW 588,20,524,20,784,20,784,20,698,20,698,20
DW 660,20,660,20,588,20,784,20,784,20,698,20
DW 698,20,660,20,660,20,588,20,0
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
DB 32 DUP(?)
STACK ENDS
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,cs
mov ds,ax
mov dx,offset int3
mov ax,250bh
int 21h
in al,21h
and al,0f7h
out 21h,al
mov cx,3
sti
ll: jmp ll
int3:
mov ax,data
mov ds,ax
push cx
agn0: mov cx,80h
d0: mov ah,01h
push cx
mov cx,0008h
mov si,offset min1
next0: mov al,[si]
mov bx,offset buff1
xlat ;得到第一行码
mov dx,proth
out dx,al
mov al,ah
mov dx,protlr
out dx,al ;显示第一行红
mov al,0
out dx,al
shl ah,01
inc si
push cx
mov cx,0ffh;ffh
delay0: loop delay0 ;延时
pop cx
loop next0
pop cx
call delay
loop d0
mov al,00
mov dx,protlr
out dx,al
agn2: mov cx,80h ;agn1为显示黄色
d2: mov si,offset min1
mov ah,01
push cx
mov cx,0008h
next2: mov al,[si]
mov bx,offset buff2
xlat
mov dx,proth
out dx,al
mov al,ah
mov dx,protlr
out dx,al
mov al,0
out dx,al
shl ah,01
inc si
push cx
mov cx,0ffh;ffh
delay2: loop delay2
pop cx
loop next2
pop cx
call delay
loop d2
mov al,00
mov dx,protlr
out dx,al
jmp yinyue
DELAY PROC NEAR ;延迟子程序
push cx
mov cx,0ffh;ffh
ccc: loop ccc
pop cx
ret
DELAY ENDP
a2: MOV AH,4CH ;返回
INT 21H
pop cx
yinyue:
pop cx
push cx
mov dx,28bH ;设置8255 A口输出
mov al,10000000B
out dx,al
MOV AX,DATA
MOV DS,AX
MOV AL,0B6H
MOV DX,283H
OUT DX,AL
LEA DI,FREQ_L
NXT: MOV AX,34DEH
MOV DX,0012H
MOV BX,[DI]
CMP BX,0
JZ DONE
DIV BX
MOV DX,280H
OUT DX,AL
MOV AL,AH
OUT DX,AL
MOV DX,288H
IN AL,DX
MOV AH,AL
OR AL,3
MOV DX,288H
OUT DX,AL
INC DI
INC DI
MOV BX,[DI]
CALL DLAY
INC DI
INC DI
MOV AL,AH
OUT DX,AL
CALL DLAY2
JMP NXT
DONE: MOV AH,4CH
INT 21H
DLAY PROC
PUSH AX
AGAIN1: MOV CX,16578
AGAIN: IN AL,61H
AND AL,10H
CMP AL,AH
JE AGAIN
MOV AH,AL
LOOP AGAIN
DEC BL
JNZ AGAIN1
POP AX
RET
DLAY ENDP
DLAY2 PROC
MOV CX,1328
REPEAT1:
IN AL,61H
AND AL,10H
CMP AL,AH
JE REPEAT1
MOV AH,AL
LOOP REPEAT1
RET
DLAY2 ENDP
pop cx
mov al,20h
out 20h,al
loop next
in al,21h
or al,08h
out 21h,al
sti
mov ah,4ch
int 21h
next:
iret
code ends
end start
------解决思路----------------------
弱智注释即将来到.......
;这段程序到底是做什么的啊?
proth equ 290h
protlr equ 298h
protly equ 2a0h
DATA SEGMENT
min1 DB 00h,01h,02h,03h,04h,05h,06h,07h
BUFF1 DB 15H, 09H, 15H, 11H, 55H, 0FFH, 5EH, 11H
BUFF2 DB 7bh, 49h, 0f1h, 41h, 0ffh, 28h, 0fch, 22h
FREQ_L DW 524,20,524,20,784,20,784,20,880,20,880,20
DW 784,20,698,20,698,20,660,20,660,20,588,20
DW 588,20,524,20,784,20,784,20,698,20,698,20
DW 660,20,660,20,588,20,784,20,784,20,698,20
DW 698,20,660,20,660,20,588,20,0
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
DB 32 DUP(?)
STACK ENDS
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,cs
mov ds,ax
;设置中断向量表,0bh号中断指向程序int3
mov dx,offset int3
mov ax,250bh
int 21h
;将21h号端口输入的byte型数据第3位置0并输出
in al,21h
and al,0f7h ;1111 0111
out 21h,al
mov cx,3
sti ;中断允许
ll: jmp ll ;死循环?
;将要响应中断的程序
int3:
mov ax,data
mov ds,ax
push cx
agn0: mov cx,80h
;循环128次显示数据
d0: mov ah,01h
push cx
;循环8次显示数据
mov cx,0008h
mov si,offset min1
next0:mov al,[si]
;查表得到buff1中的数据
mov bx,offset buff1
xlat ;得到第一行码
mov dx,proth
out dx,al
mov al,ah
mov dx,protlr
out dx,al ;显示第一行红
mov al,0
out dx,al
shl ah,01
inc si ;si递增
;循环255次以延时,为什么不call delay
push cx
mov cx,0ffh;ffh
delay0: loop delay0 ;延时
pop cx
loop next0
pop cx
call delay
loop d0
;向protlr端口输出0
mov al,00
mov dx,protlr
out dx,al
agn2: mov cx,80h ;agn1为显示黄色
d2: mov si,offset min1
mov ah,01
push cx
mov cx,0008h
next2: mov al,[si]
mov bx,offset buff2
xlat
mov dx,proth
out dx,al
mov al,ah
mov dx,protlr
out dx,al
mov al,0
out dx,al
shl ah,01
inc si
push cx
mov cx,0ffh;ffh
delay2: loop delay2
pop cx
loop next2
pop cx
call delay
loop d2
mov al,00
mov dx,protlr
out dx,al
;跳转到yinyue
jmp yinyue
DELAY PROC NEAR ;延迟子程序
push cx
;循环255次
mov cx,0ffh;ffh
ccc: loop ccc
pop cx
ret
DELAY ENDP
a2: MOV AH,4CH ;返回dos
INT 21H
pop cx ;能运行到这里吗?
yinyue:
pop cx ;又pop又push,还不如不写
push cx
;向28bh端口输出80h
mov dx,28bH ;设置8255 A口输出
mov al,10000000B
out dx,al
MOV AX,DATA
MOV DS,AX
;向383h号端口输出0b6h
MOV AL,0B6H
MOV DX,283H
OUT DX,AL
LEA DI,FREQ_L
NXT: MOV AX,34DEH
MOV DX,0012H
;获得FREQ_L中的数据,若为0则直接结束(即到达数据结尾)
MOV BX,[DI]
CMP BX,0
JZ DONE
;将dxax除以bx,将得数按byte形式输出280h端口
DIV BX
MOV DX,280H
OUT DX,AL
MOV AL,AH
OUT DX,AL
;从288h端口获得数据,第0位第1位置1并输出
MOV DX,288H
IN AL,DX
MOV AH,AL
OR AL,3 ;0011b
MOV DX,288H
OUT DX,AL
;字形数据,一次加2
INC DI
INC DI
MOV BX,[DI]
CALL DLAY ;延时
INC DI
INC DI
;再输出
MOV AL,AH
OUT DX,AL
CALL DLAY2 ;延时函数2
JMP NXT
DONE: ;结束程序返回dos
MOV AH,4CH
INT 21H
;延时函数1
DLAY PROC
PUSH AX
AGAIN1: MOV CX,16578
AGAIN: IN AL,61H
AND AL,10H
CMP AL,AH
JE AGAIN
MOV AH,AL
LOOP AGAIN
;若bl减1后不为0则跳转到AGAIN1,重置循环次数
DEC BL
JNZ AGAIN1
POP AX
RET
DLAY ENDP
;延时函数2,从61h号端口获得数据,
;并判断上一次的数据的第4位于这一次数据的第四位是否相同,
;若不是则循环次数减一
DLAY2 PROC
MOV CX,1328
REPEAT1:
IN AL,61H ;从61h端口获取数据
AND AL,10H ;第除4位外全部置0
CMP AL,AH ;判断遇上一次的是否相同
JE REPEAT1 ;不减cx直接循环
MOV AH,AL
LOOP REPEAT1
RET ;返回
DLAY2 ENDP
pop cx
;向20h端口输出20h
mov al,20h
out 20h,al
loop next ;cx不为0则跳转next
;从21h端口获得数据,第3位置1,再输出
in al,21h
or al,08h ;1000b
out 21h,al
sti ;开中断
;结束程序返回dos
mov ah,4ch
int 21h
next:
iret ;返回
code ends
end start
d2和d0差不多,所以我就没写(话说怎么没有d1呢?)。程序中有些看不懂的位置我用注释写了,望解释一下。
至于你要把程序改的老师看不出来是抄个人建议有几种方法
1.mov ax,10h类的赋值语句你可以将后面的数的进制改改(比如16,10000b等),或者分开赋值,先赋值al再赋值ah。
2.更改顺序,比如设置循环次数的mov cx,xxxx可以适当提前几行,定义的子程序可以适当变换顺序,assum放开头,栈段放代码段后面。
3.把标号名,变量名,函数名给改了。
------解决思路----------------------
code segment;宏定义程序
assume cs:code,ds:data,ss:stack;说明对应关系,把段的首地址赋值给段寄存器(这样程序才能找到定义过的段)
start: ;段名
mov ax,cs;将代码段的首址复制到AX里
mov ds,ax;将通用寄存器AX中内容复制到段寄存器DX中;寻址方式为直接寻址;因为8086规定,不能直接对段寄存器操作,所以使用通用寄存器中转
mov dx,offset int3;取中断服务的偏移地址
mov ax,250bh;DOS调用25H,中断类型0BH
int 21h;设置中断矢量
in al,21h;读取中断屏蔽寄存器
and al,0f7h;释放中断
out 21h,al;允许写入
mov cx,3;记忆中断次数为3次
sti ;恢复中断
大爷的,我一个弄51单片机的,跟你分析到这,我都知道这是干嘛的了,靠,原来是运行在8086CPU上的啊,我这笨得,唉。。。。。
还是我,这该死的不能连续3次回帖,汗。。。。。