Add beep with ESC with frequencies

This commit is contained in:
redfast00 2019-09-20 18:48:46 +02:00
parent 1ca2ba1e6b
commit 26f7032808
No known key found for this signature in database
GPG Key ID: 5946E0E34FD0553C
1 changed files with 28 additions and 21 deletions

View File

@ -27,6 +27,7 @@ mov dl, 0x00
mov bh, 0x00
mov ah, 0x02
int 0x10
mov sp, 0x2000
.loop:
;; Read character
@ -42,21 +43,7 @@ int 0x10
jmp .nonewline
.change_color_mode:
;; Read character
mov ah, 0x00
int 0x16
;; Read character is in al
sub al, 'a'
mov bl, al
shl bl, 0x4
;; Read character
mov ah, 0x00
int 0x16
;; Read character is in al
sub al, 'a'
or al, bl
call .readbyte
mov [color_mode], al
jmp .loop
@ -85,8 +72,12 @@ int 0x10
.beep:
mov al, 182 ; Prepare the speaker for the
out 43h, al ; note.
mov ax, 4560 ; Frequency number (in decimal)
; for middle C.
call .readbyte
mov ah, 0
sal ax, 5 ; multiply by 32
add ax, 1140
;mov ax, 4560 ; Frequency number (in decimal)
; ; for middle C.
out 42h, al ; Output low byte.
mov al, ah ; Output high byte.
out 42h, al
@ -94,7 +85,7 @@ int 0x10
; port 61h).
or al, 00000011b ; Set bits 1 and 0.
out 61h, al ; Send new value.
mov bx, 5000 ; Pause for duration of note.
mov bx, 50000 ; Pause for duration of note.
.pause1:
mov cx, 65535
.pause2:
@ -142,8 +133,7 @@ int 0x10
mov dl, 0x00
mov ah, 0x02
int 0x10
jmp .loop
jmp .loop
.noeol:
@ -151,8 +141,25 @@ int 0x10
inc dl
mov ah, 0x02
int 0x10
jmp .loop
jmp .loop
.readbyte:
;; Read character
mov ah, 0x00
int 0x16
;; Read character is in al
sub al, 'a'
mov bl, al
shl bl, 0x4
;; Read character
mov ah, 0x00
int 0x16
;; Read character is in al
sub al, 'a'
or al, bl
ret
halt: hlt