From 1ca2ba1e6b4994ef1ef66bac9ab447646b553485 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Thu, 19 Sep 2019 00:37:09 +0200 Subject: [PATCH] Add beep when escape is sent --- messages.asm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/messages.asm b/messages.asm index 2d2c35b..ed6b635 100644 --- a/messages.asm +++ b/messages.asm @@ -37,6 +37,8 @@ int 0x10 je .newline cmp al, 0x08 ; delete character je .change_color_mode + cmp al, 0x1b ; escape character + je .beep jmp .nonewline .change_color_mode: @@ -80,6 +82,32 @@ int 0x10 jmp .loop +.beep: + mov al, 182 ; Prepare the speaker for the + out 43h, al ; note. + 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 + in al, 61h ; Turn on note (get value from + ; port 61h). + or al, 00000011b ; Set bits 1 and 0. + out 61h, al ; Send new value. + mov bx, 5000 ; Pause for duration of note. +.pause1: + mov cx, 65535 +.pause2: + dec cx + jne .pause2 + dec bx + jne .pause1 + in al, 61h ; Turn off note (get value from + ; port 61h). + and al, 11111100b ; Reset bits 1 and 0. + out 61h, al ; Send new value. + jmp .loop + .nonewline: