讓你的計算機變成鋼琴。

2021-03-31 12:07:03 字數 2307 閱讀 4331

code segment

assume cs:code

d1=131

d2=147

d3=165

d4=175

d5=196

d6=220

d7=247

z1=262

z2=294

z3=330

z4=349

z5=392

z6=440

z7=494

g1=523

g2=587

g3=659

g4=714

g5=784

g6=880

g7=988

oldint8 dd ?

oldint9 dd ?

time    dw 0

ascii   db 10h,11h,12h,13h,14h,15h,16h

db 1eh,1fh,20h,21h,22h,23h,24h

db 2ch,2dh,2eh,2fh,30h,31h,32h

music   dw d1,d2,d3,d4,d5,d6,d7

dw z1,z2,z3,z4,z5,z6,z7

dw g1,g2,g3,g4,g5,g6,g7

newint8: dec  cs:word ptr time

jz closev

new8_0: jmp cs:oldint8

closev: push ax

in al,61h

and al,0fdh

out 61h,al

pop ax

jmp new8_0

voice: mov cx,ax

mov dx,12h

mov ax,34dch

div cx

push ax

mov al,0b6h

out 43h,al

pop ax

out 42h,al

xchg al,ah

out 42h,al

in al,61h

or al,03h

out 61h,al

retnewint9: in al,60h

push ax

in al,61h

or al,80h

out 61h,al

and al,7fh

out 61h,al

mov al,20h

out 20h,al

stipop ax

push ax

cmp al,80h

jb new90

mov  cs:word ptr time,04h

jmp quit

new90: push cs

pop  es

mov di,offset ascii

mov cx,22d

cldrepnz scasb

jcxz quit

sub di,offset ascii

dec di

shl di,1

mov ax,es:[di+music]

mov cs:word ptr time,0h

call voice

quit:  pop ax

cmp al,01h

jnz meun

lds dx,cs:oldint8

mov ax,2508h

int 21h

lds dx,cs:oldint9

mov ax,2509h

int 21h

mov ax,4c00h

int 21h

meun:    sti

jmp meun

start:mov ax,cs

mov ds,ax

mov ax,3508h

int 21h

mov cs:word ptr oldint8,bx

mov cs:word ptr oldint8+2,es

mov ax,3509h

int 21h

mov cs:word ptr oldint9,bx

mov cs:word ptr oldint9+2,es

mov ax,2508h

mov dx,offset newint8

int 21h

mov ax,2509h

mov dx,offset newint9

int 21h

jmp meun

code ends

end start

編譯執行一下 ,你會發現的計算機也能用來彈奏樂曲。:)

讓計算機思考

引言 從一個簡單的猜拳小遊戲來窺探 ai,人們對於 ai 的認知是從什麼角度出發的?又是從什麼角度對自己來認知的?本文參照於 程式是怎麼跑起來的 ai artificial intelligence 英 t f l 人造的 英 n tel d ns 智力 整體思路 1 直覺 想法 2 習慣 概率 3...

計算機變成常用長度單位

px 畫素 pixel 是一個相對單位長度,是相對於顯示器螢幕解析度而言的。一般的,windows平臺下使用者所使用的解析度是96畫素 英寸,mac平臺下使用者所使用的解析度是72畫素 英寸。pt 點 point 是一個絕對單位長度。in 英寸 inch 絕對長度。em 相對長度,相對於當前物件內文...

計算機變成常用長度單位

px 畫素 pixel 是一個相對單位長度,是相對於顯示器螢幕解析度而言的。一般的,windows平臺下使用者所使用的解析度是96畫素 英寸,mac平臺下使用者所使用的解析度是72畫素 英寸。pt 點 point 是一個絕對單位長度。in 英寸 inch 絕對長度。em 相對長度,相對於當前物件內文...

如何讓其他計算機訪問我的計算機上mysql資料庫

先判斷是不是在同 一個網路之間,你ping 一下它的ip 看能不能ping通.這樣就有兩種情況,第一種 能ping通,說明你們在同一個網路中,可以直接訪問.你只要在你的登入使用者中的帳號加上可外部訪問就可以了.也就是授權.比如你的帳號是root 你可以進入mysql後,你可以看到,每個帳號對應 的有...

C 讓計算機自動重啟

怎樣讓計算機重新啟動 關機登出 主要是利用win32裡面的函式呼叫.bool exitwindow uint uflags,dword dwreason 第一個引數關閉型別 有以下幾種型別 1 ewx logoff 關閉所有的程序 2 ewx poweroff 關閉電源 3 ewx reboot 關...