From 26f703280847120380c3fca82d4fab1a6849b8e3 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Fri, 20 Sep 2019 18:48:46 +0200 Subject: [PATCH] Add beep with ESC with frequencies --- messages.asm | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/messages.asm b/messages.asm index ed6b635..d337561 100644 --- a/messages.asm +++ b/messages.asm @@ -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