Assembly 8086汇编语言创建矩阵屏幕保护程序
我必须创建一个矩阵屏幕保护程序的简单实现,就像电影中的一样,在汇编中,只使用视频内存(文本)。除了用于获取随机字符的随机数生成器之外,我已经列出了大部分结构,但是我希望能得到一些帮助来缩小这些过程及其实现的范围 我必须使用与此类似的代码:Assembly 8086汇编语言创建矩阵屏幕保护程序,assembly,matrix,procedure,screensaver,Assembly,Matrix,Procedure,Screensaver,我必须创建一个矩阵屏幕保护程序的简单实现,就像电影中的一样,在汇编中,只使用视频内存(文本)。除了用于获取随机字符的随机数生成器之外,我已经列出了大部分结构,但是我希望能得到一些帮助来缩小这些过程及其实现的范围 我必须使用与此类似的代码: ;Matrix ;This program displays a matrix wallpaper .model small .386 .stack 100h .data .code main proc mov ax, 0b800h mov
;Matrix
;This program displays a matrix wallpaper
.model small
.386
.stack 100h
.data
.code
main proc
mov ax, 0b800h
mov es, ax
mov bx, 39 ; row
mov cx, 12 ; colum
mov ax, 160
mul cx
shl bx,1
add bx, ax
mov al, 'A'
mov ah, 0ah
mov es:[bx], ax
mov ax, 4c00h
int 21h
main endp
end main
但到目前为止,我得到的是:
;Matrix
;This program creates a matrix wallpaper
.model small
.386
.stack 100h
.data
speed dword 2147483647
X dw, ?
Y dw, ?
ch dw, ?
att dw, ?
.code
main proc
mov ax, @data
mov ds, ax
; setup interrupt
push ds
mov ax, @code
mov ds, ax
mov ah, 25h
mov al, 9
mov dx, offset My_int
int 21h
pop ds
; matrix program, makes the rain effect
Loo2:
; for(y = 23; y > 0; y--)
L1:
; for(x = 0; x <= 79; x++)
L2:
; SgetCh(x, y, ch, attribute)
call SgetCh
; SputCh(x, y, ch, attribute)
call SgetCh
; BusyWait
call BusyWait
jmp Loo2
mov ax, 4c00h
int 21h
main endp
;***************
My_int proc
;cli ; diable interrupts
;mov ax, mystack ; reset SS
;mov ss, ax
;mov sp, 100h ; reset SP
;sti ; reenable interrupt
mov ax, 4c00h
int 21h
iret
My_int endp
;***************
BusyWait proc
ret
BusyWait endp
;***************
SgetCh proc
ret
SgetCh endp
;***************
SputCh proc
ret
SputCh endp
;***************
end main
;矩阵
;这个程序创建一个矩阵墙纸
.小型模型
.386
.烟囱100小时
.数据
速度dword 2147483647
X dw?
Y-dw?
总数据仓库?
att dw?
.代码
主进程
mov-ax,@data
mov-ds,ax
; 设置中断
推送ds
mov-ax,@code
mov-ds,ax
mov-ah,25小时
莫夫·艾尔,9岁
mov dx,偏移My_int
int 21h
流行音乐
; 矩阵程序,使雨的效果
第2条:
; 对于(y=23;y>0;y--)
L1:
; 对于(x=0;x这是我很久以前写的一段代码。也许你可以使用它:
mov ax, 19
int 10h ; 320x200 with 256 colors
mov ax, 0a000h
mov es, ax ;set the di segment to the graphics memory
xor bl, bl ;bl will be used to store the number of the picture
new:
inc bl
hlt ;here the processor will wait (very shortly and in an unregular period)
xor cx, cx
xor dx, dx ;cx and dx represent the coordinates
xor di, di ;set di to offset of the begin of the screen.
a:
mov al, cl
xor al, dl
add al, dl
add al, bl ;create a color
stosb ;write pixel
inc cx
cmp cx, 320 ;refresh coordinates
jne a
xor cx, cx
inc dx
cmp dx, 200
jne a
mov ah, 1 ;check whether a key had been pressed
int 16h
jz new ;If no key had been pressed, show next picture
mov ax, 3
int 10h
mov ax, 4c00h
int 21h
当您从键盘中断处理程序中终止程序时,您希望发生什么?它肯定不会恢复中断向量
由于屏幕上的所有绘图都是在主程序中完成的,您不需要更改任何中断。只要在BIOS功能“读取键盘状态”(将插入jmp Loo2)返回且ZF=0时退出程序即可
这些线
mov bx, 39 ; row
mov cx, 12 ; colum
与下面的代码不符。您混淆了列和行的含义。这是一个很好的答案,但我不能使用dram的图形部分。我必须使用“mov ax,0b800h”和“mov es,ax”。