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