rand : jmp short sr
seat db 0,0,0,0,0 ;第一个是列的随机数表的指向位置,四为果子x,五为果子y
table1 db 5,2,7,1,8,0,5,9,4,3,6,7,8,1,9,2,6,0,3,4 ;x坐标的个位
table2 db 0ah,14h,0,14h,1dh,0ah,1dh,0ah,0,14h,0,1dh ;x坐标的十位,0,10,20,30
table3 db 2,15,22,16,13,0,12,9,19,11,1,7,21,18,6,16,17,8,4,12,14,20,3,10,5,18 ;y坐标
sr : push ax
push ds
push bx
push cx
push es
mov ax,cs
mov ds,ax ;这是写在代码段的
mov al,0
out 70h,al
in al,71h ;获取时间秒,下面处理秒
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
mov cl,seat[0]
mov bl,cl
add bl,al
cmp bl,13h
jna bz1
sub bl,14h
bz1:mov seat[0],bl
mov bh,0
mov bh,table1[bx]
mov cl,seat[1]
mov bl,cl
add bl,ah
cmp bl,0bh
jna bz2
sub bl,0ch
bz2:mov seat[1],bl
mov cl,bh
mov bh,0
mov bh,table2[bx]
add bh,cl
cmp bh,25h
jna bz3
sub bh,al
sub bh,ah
sub bh,al
bz3:mov seat[3],bh
mov al,2
out 70h,al
in al,71h ;获取时间分,下面处理分
and al,00001111b
mov cl,seat[2]
mov bl,cl
add bl,al
cmp bl,16h ;判断是否超过16h
jna bz4
sub bl,17h
bz4:mov seat[2],bl
mov bh,0
mov bh,table3[bx]
mov seat[4],bh
mov ax,0b800h ;下面是显示$
mov es,ax
mov al,seat[4]
add al,1
mov ah,0
mov bl,160 ;y坐标*160
mul bl
mov bl,seat[3]
mov bh,0
add bx,bx
add bx,bx
add ax,bx
add ax,4
mov bx,ax
mov al,'
mov ah,46h
mov es:[bx],al
mov es:[bx+1],ah
mov es:[bx+2],al
mov es:[bx+3],ah
pop es
pop cx
pop bx
pop ds
pop ax
ret