remove unnecessary instructions

This commit is contained in:
Tibo Ulens 2021-10-08 14:21:20 +02:00
parent 6f971cf6c7
commit e2747fc424

View file

@ -167,7 +167,7 @@ beep:
;; interrupt 0x16, ah=0 returns the read scancode in ah ;; interrupt 0x16, ah=0 returns the read scancode in ah
;; so ah must be reset ;; so ah must be reset
mov ah, 0 mov ah, 0
push ax ; store on stack mov cx, ax ; save ax into cx temporarily
;; move 182 (0b10 11 011 0) into al ;; move 182 (0b10 11 011 0) into al
;; bit 7-6 = channel select (2, PC speaker) ;; bit 7-6 = channel select (2, PC speaker)
@ -196,12 +196,9 @@ beep:
;; mov bx, 50000 ; Pause for duration of note. ;; mov bx, 50000 ; Pause for duration of note.
;; multiply duration by 3125 ;; multiply duration by 3125
pop bx ; pull duration value from stack into bx ;; (duration is in cx)
push ax ; save ax (contains garbage?)
mov ax, 3125 mov ax, 3125
mul bx mul cx ; multiply ax <- ax * cx
mov bx, ax ; move dur * 3125 into bx
pop ax ; restore ax
;; play note for a certain duration ;; play note for a certain duration
.pause1: .pause1:
@ -210,7 +207,7 @@ beep:
dec cx ; count down dec cx ; count down
jne .pause2 ; if not zero keep counting down jne .pause2 ; if not zero keep counting down
dec bx ; decrement duration counter dec ax ; decrement duration counter
jne .pause1 ; keep doing that until it is 0 jne .pause1 ; keep doing that until it is 0
in al, 0x61 ; Preserve previous value in al, 0x61 ; Preserve previous value
@ -235,7 +232,8 @@ nonewline:
int 0x10 int 0x10
;; Get current cursor position ;; Get current cursor position
;; dh = row, dl = col ;; bh already contains page number
;; returns dh = row, dl = col
mov ah, 0x03 ; get cursor position and shape mov ah, 0x03 ; get cursor position and shape
int 0x10 int 0x10
@ -252,7 +250,9 @@ nonewline:
.noeol: .noeol:
;; Move cursor forward ;; Move cursor forward
inc dl ;; bh already contains page number
;; dh already contains row
inc dl ; go to next col
mov ah, 0x02 ; set cursor position, dh (row) already set, dl (col) updated on prev line mov ah, 0x02 ; set cursor position, dh (row) already set, dl (col) updated on prev line
int 0x10 int 0x10