Bump cpu level to 286 and use pusha/popa where possible

This commit is contained in:
Juhani Krekelä 2023-03-16 19:22:59 +02:00
parent 565fff50b4
commit 56d22db6e0
1 changed files with 16 additions and 42 deletions

View File

@ -1,4 +1,4 @@
cpu 8086
cpu 286
bits 16
org 0x7c00
@ -106,9 +106,7 @@ mainloop:
; ------------------------------------------------------------------
draw_wallpaper:
push ax
push bx
push cx
pusha
push es
mov bx, 0xb800
@ -120,15 +118,11 @@ draw_wallpaper:
rep movsw
pop es
pop cx
pop bx
pop ax
popa
ret
flip_mouse_cursor:
push ax
push bx
push cx
pusha
push es
mov bx, 0xb800
@ -153,9 +147,7 @@ flip_mouse_cursor:
mov [es:bx], al
pop es
pop cx
pop bx
pop ax
popa
ret
; ------------------------------------------------------------------
@ -168,10 +160,7 @@ flip_mouse_cursor:
; cx = number of sectors to read (must be at least 1)
; es:bx = output buffer
read_sectors:
push ax
push cx
push bx
push di
pusha
xor di, di
.loop:
@ -180,10 +169,7 @@ read_sectors:
add bx, 512
loop .loop
pop di
pop bx
pop cx
pop ax
popa
ret
; in:
@ -192,9 +178,7 @@ read_sectors:
; es:bx = output buffer
; di = 0x0100 for write, 0x0000 for read
modify_sector:
push ax
push cx
push dx
pusha
push ds
xor cx, cx
@ -226,9 +210,7 @@ modify_sector:
jc .error
pop ds
pop dx
pop cx
pop ax
popa
ret
.error:
@ -282,13 +264,9 @@ open_file:
inc di
inc di
push cx
push di
push si
pusha
repe cmpsb
pop si
pop di
pop cx
popa
je .success
add ax, FILE_MAX_SIZE
@ -340,9 +318,7 @@ X_MAX_VALUE equ 2*COLUMNS-1
Y_MAX_VALUE equ 4*ROWS-1
mouse_handler:
push ax
push bx
push bp
pusha
push ds
mov ax, cs
@ -350,12 +326,12 @@ mouse_handler:
mov bp, sp
mov bx, [bp+18] ; status
mov bx, [bp+2*9+10] ; status
test bl, X_OVERFLOW
jnz .x_end
.x:
mov ax, [bp+16] ; X
mov ax, [bp+2*9+8] ; X
test bl, X_NEGATIVE
jnz .x_negative
@ -376,7 +352,7 @@ mouse_handler:
test bl, Y_OVERFLOW
jnz .y_end
.y:
mov ax, [bp+14] ; Y
mov ax, [bp+2*9+6] ; Y
test bl, Y_NEGATIVE
jnz .y_negative
@ -399,9 +375,7 @@ mouse_handler:
mov [mouse_buttons], bl
pop ds
pop bp
pop bx
pop ax
popa
retf
; ------------------------------------------------------------------