Follow C calling convention (futureproofing) and utilize macros
This commit is contained in:
parent
32ccb3abd1
commit
7a22e4aed7
4 changed files with 115 additions and 156 deletions
|
@ -1,11 +1,19 @@
|
||||||
|
macro kputpixel x, y, r, g, b {
|
||||||
|
push b ;b
|
||||||
|
push g ;g
|
||||||
|
push r ;r
|
||||||
|
push y ;y
|
||||||
|
push x ;x
|
||||||
|
call putpixel
|
||||||
|
add esp, 4*5
|
||||||
|
}
|
||||||
|
|
||||||
;; x, y, r, g, b
|
;; x, y, r, g, b
|
||||||
putpixel:
|
putpixel:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
push eax
|
|
||||||
push ebx
|
push ebx
|
||||||
push ecx
|
|
||||||
push edi
|
push edi
|
||||||
|
|
||||||
; check pixel is in screen
|
; check pixel is in screen
|
||||||
|
@ -58,9 +66,7 @@ putpixel:
|
||||||
stosb
|
stosb
|
||||||
.done:
|
.done:
|
||||||
pop edi
|
pop edi
|
||||||
pop ecx
|
|
||||||
pop ebx
|
pop ebx
|
||||||
pop eax
|
|
||||||
|
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
mbootgetinfo:
|
mbootgetinfo:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push ebx
|
|
||||||
push esi
|
push esi
|
||||||
push edi
|
push edi
|
||||||
cld
|
cld
|
||||||
|
@ -10,23 +9,23 @@ mbootgetinfo:
|
||||||
cmp eax, 0x2badb002
|
cmp eax, 0x2badb002
|
||||||
jne mbootnomagic
|
jne mbootnomagic
|
||||||
|
|
||||||
mov ebx, [ebp+12]
|
mov edx, [ebp+12]
|
||||||
mov eax, [ebx]
|
mov eax, [edx]
|
||||||
mov [mbootinfo.flags], eax
|
mov [mbootinfo.flags], eax
|
||||||
|
|
||||||
;; Get memoryinformation
|
;; Get memoryinformation
|
||||||
test eax, 1b
|
test eax, 1b
|
||||||
jz mbootnomeminfo
|
jz mbootnomeminfo
|
||||||
mov eax, [ebx+4]
|
mov eax, [edx+4]
|
||||||
mov [mbootinfo.mem_lower], eax
|
mov [mbootinfo.mem_lower], eax
|
||||||
mov eax, [ebx+8]
|
mov eax, [edx+8]
|
||||||
mov [mbootinfo.mem_upper], eax
|
mov [mbootinfo.mem_upper], eax
|
||||||
|
|
||||||
;; Get videoinformation
|
;; Get videoinformation
|
||||||
test [mbootinfo.flags], (1 shl 02)
|
test [mbootinfo.flags], (1 shl 02)
|
||||||
jz mbootnovideoinfo
|
jz mbootnovideoinfo
|
||||||
|
|
||||||
mov esi, ebx
|
mov esi, edx
|
||||||
add esi, 88
|
add esi, 88
|
||||||
mov eax, [esi]
|
mov eax, [esi]
|
||||||
mov [mbootinfo.fb_addr], eax
|
mov [mbootinfo.fb_addr], eax
|
||||||
|
@ -64,13 +63,12 @@ mbootgetinfo:
|
||||||
.bytesppcalc:
|
.bytesppcalc:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov al, [mbootinfo.fb_bpp]
|
mov al, [mbootinfo.fb_bpp]
|
||||||
mov ebx, 8
|
mov edx, 8
|
||||||
div bl
|
div dl
|
||||||
mov [mbootinfo.fb_bytespp], al
|
mov [mbootinfo.fb_bytespp], al
|
||||||
.done:
|
.done:
|
||||||
pop edi
|
pop edi
|
||||||
pop esi
|
pop esi
|
||||||
pop ebx
|
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
SERIAL_PORT equ 0x3f8
|
SERIAL_PORT equ 0x3f8
|
||||||
serialinitialized db 0
|
serialinitialized db 0
|
||||||
|
|
||||||
serialinit:
|
; Write null terminated string in address str_pointer to serial
|
||||||
push ax
|
macro serw str_pointer {
|
||||||
|
push str_pointer
|
||||||
|
call serialwrite
|
||||||
|
add esp, 4
|
||||||
|
}
|
||||||
|
|
||||||
|
serialinit:
|
||||||
;Disable ints
|
;Disable ints
|
||||||
mov dx, SERIAL_PORT+1
|
mov dx, SERIAL_PORT+1
|
||||||
mov al, 0x00
|
mov al, 0x00
|
||||||
|
@ -54,7 +59,6 @@ serialinit:
|
||||||
out dx, al
|
out dx, al
|
||||||
mov [serialinitialized], 1
|
mov [serialinitialized], 1
|
||||||
.end:
|
.end:
|
||||||
pop ax
|
|
||||||
ret
|
ret
|
||||||
.errormsg db "Serial init failed", 0
|
.errormsg db "Serial init failed", 0
|
||||||
|
|
||||||
|
@ -64,7 +68,6 @@ serialwrite:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push esi
|
push esi
|
||||||
push ax
|
|
||||||
cld
|
cld
|
||||||
mov esi, [ebp+8]
|
mov esi, [ebp+8]
|
||||||
.loop:
|
.loop:
|
||||||
|
@ -80,7 +83,6 @@ serialwrite:
|
||||||
out dx, al
|
out dx, al
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.done:
|
.done:
|
||||||
pop ax
|
|
||||||
pop esi
|
pop esi
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
117
src/start32.asm
117
src/start32.asm
|
@ -29,6 +29,13 @@ multiboot:
|
||||||
dd VHEIGHT ; video height
|
dd VHEIGHT ; video height
|
||||||
dd VDEPTH ; video depth
|
dd VDEPTH ; video depth
|
||||||
|
|
||||||
|
; Includes yayyy
|
||||||
|
include "src/serial.asm"
|
||||||
|
include "src/mbootinfo.asm"
|
||||||
|
include "src/itoa.asm"
|
||||||
|
include "src/framebuffer.asm"
|
||||||
|
include "src/roskalogoraw.asm"
|
||||||
|
|
||||||
start:
|
start:
|
||||||
; Setup stack
|
; Setup stack
|
||||||
mov ebp, stack_top
|
mov ebp, stack_top
|
||||||
|
@ -38,16 +45,13 @@ start:
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
call serialinit
|
call serialinit
|
||||||
push stuff.bootmsg
|
|
||||||
call serialwrite
|
serw stuff.bootmsg
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
call mbootgetinfo
|
call mbootgetinfo
|
||||||
add esp, 2*4
|
add esp, 2*4
|
||||||
|
|
||||||
push stuff.fbaddrmsgpfx
|
serw stuff.fbaddrmsgpfx
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
sub esp, 36 ;Reserve stack for return
|
sub esp, 36 ;Reserve stack for return
|
||||||
push dword esp ;Destination address
|
push dword esp ;Destination address
|
||||||
|
@ -55,36 +59,24 @@ start:
|
||||||
push dword [mbootinfo.fb_addr] ;source
|
push dword [mbootinfo.fb_addr] ;source
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push stuff.fbdimensionsmsgpfx
|
serw stuff.fbdimensionsmsgpfx
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
push dword esp ;destination address
|
push dword esp ;destination address
|
||||||
push dword 10 ;base
|
push dword 10 ;base
|
||||||
push dword [mbootinfo.fb_width]
|
push dword [mbootinfo.fb_width]
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
serw stuff.x
|
||||||
add esp, 4
|
|
||||||
push stuff.x
|
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp ;destination address
|
push dword esp ;destination address
|
||||||
push dword 10 ;base
|
push dword 10 ;base
|
||||||
push dword [mbootinfo.fb_height]
|
push dword [mbootinfo.fb_height]
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
serw stuff.x
|
||||||
add esp, 4
|
|
||||||
push stuff.x
|
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp ;destination address
|
push dword esp ;destination address
|
||||||
push dword 10 ;base
|
push dword 10 ;base
|
||||||
|
@ -93,14 +85,10 @@ start:
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
|
|
||||||
push stuff.rpostxt
|
serw stuff.rpostxt
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp
|
push dword esp
|
||||||
push dword 10
|
push dword 10
|
||||||
|
@ -109,13 +97,9 @@ mov al, [mbootinfo.fb_rpos]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push stuff.gpostxt
|
serw stuff.gpostxt
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp
|
push dword esp
|
||||||
push dword 10
|
push dword 10
|
||||||
|
@ -124,13 +108,9 @@ mov al, [mbootinfo.fb_gpos]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push stuff.bpostxt
|
serw stuff.bpostxt
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp
|
push dword esp
|
||||||
push dword 10
|
push dword 10
|
||||||
|
@ -139,9 +119,7 @@ mov al, [mbootinfo.fb_bpos]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,9 +134,7 @@ mov al, [mbootinfo.fb_rmasksize]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push stuff.gmasksizetxt
|
push stuff.gmasksizetxt
|
||||||
call serialwrite
|
call serialwrite
|
||||||
|
@ -171,13 +147,9 @@ mov al, [mbootinfo.fb_gmasksize]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push stuff.bmasksizetxt
|
serw stuff.bmasksizetxt
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
push dword esp
|
push dword esp
|
||||||
push dword 10
|
push dword 10
|
||||||
|
@ -186,22 +158,14 @@ mov al, [mbootinfo.fb_bmasksize]
|
||||||
push dword eax
|
push dword eax
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
push esp
|
serw esp
|
||||||
call serialwrite
|
|
||||||
add esp, 4
|
|
||||||
|
|
||||||
|
|
||||||
add esp, 36 ;Clean reserved uitoa return string from stack
|
add esp, 36 ;Clean reserved uitoa return string from stack
|
||||||
|
|
||||||
; Draw a test pixel to bottom right corner
|
; Draw a green test pixel to bottom-right
|
||||||
push 0xff
|
kputpixel VWIDTH-1, VHEIGHT-1, 0x00, 0xff, 0x00
|
||||||
push 0xff
|
|
||||||
push 0xff
|
|
||||||
push VHEIGHT-1
|
|
||||||
push VWIDTH-1
|
|
||||||
call putpixel
|
|
||||||
add esp, 3*4
|
|
||||||
|
|
||||||
|
; Draw a predefined logo in magenta to top-left
|
||||||
rOSkalogodraw:
|
rOSkalogodraw:
|
||||||
mov esi, roskalogo
|
mov esi, roskalogo
|
||||||
mov eax, 0 ;Brightness
|
mov eax, 0 ;Brightness
|
||||||
|
@ -209,17 +173,12 @@ rOSkalogodraw:
|
||||||
mov ecx, 0 ;x
|
mov ecx, 0 ;x
|
||||||
.loop:
|
.loop:
|
||||||
lodsb
|
lodsb
|
||||||
push eax ;b
|
|
||||||
push eax ;g
|
push ecx
|
||||||
push eax ;r
|
push eax
|
||||||
push ebx ;y
|
kputpixel ecx, ebx, eax, 0x00, eax
|
||||||
push ecx ;x
|
pop eax
|
||||||
call putpixel
|
|
||||||
pop ecx
|
pop ecx
|
||||||
pop ebx
|
|
||||||
pop eax
|
|
||||||
pop eax
|
|
||||||
pop eax
|
|
||||||
|
|
||||||
inc ecx
|
inc ecx
|
||||||
cmp byte cl, [roskalogo.w]
|
cmp byte cl, [roskalogo.w]
|
||||||
|
@ -242,12 +201,6 @@ hang:
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.msg db 10, "Halting...", 10, 0
|
.msg db 10, "Halting...", 10, 0
|
||||||
|
|
||||||
include "src/serial.asm"
|
|
||||||
include "src/mbootinfo.asm"
|
|
||||||
include "src/itoa.asm"
|
|
||||||
include "src/framebuffer.asm"
|
|
||||||
include "src/roskalogoraw.asm"
|
|
||||||
|
|
||||||
stuff:
|
stuff:
|
||||||
.bootmsg db 10, "=== rOSka ===", 10, 0
|
.bootmsg db 10, "=== rOSka ===", 10, 0
|
||||||
.fbaddrmsgpfx db 10, "Framebuffer address: 0x", 0
|
.fbaddrmsgpfx db 10, "Framebuffer address: 0x", 0
|
||||||
|
|
Loading…
Reference in a new issue