Search code examples
c++assemblygccnasmbochs

bootloader _start VEZA video buffer


link the asm file to a kernel.c code.

in the bootloader.asm , i addit the video mode for a screen. that nead it 1024*800 but next in nead video memory to add the bitmap to to fonts or pixsel drawing but i get a error whet tiring to at the long mode the int to 0.

[video_buffer]

to i presume you nead to do in the boot loader file asm.

when using a long 0 , 32bits statemend.

start.asm:8: error: label or instruction expected at start of line.



bits 32                ' set to 32 Bits
global _start          ' the main star load code
extern kernel_early    ' LD . kernel.c void
extern main


'set video mode to 1024*800 VEZA.
    mov 0x4f02, ax
    mov 0x4118, bx
    int 0x10
    cmp 0x004f, ax

'make video buffer to bitmap fonts
global video_buffer
video_buffer:
    long    0   ; int 0
    long    0
    word    0
    word    0
    byte    0,0,0,0,0,0,0,0,0,0
    long    0
rept 190
    byte    0
endr




;  make a display , venor model interface.
struc VesaInfoBlock             ;   VesaInfoBlock_size = 512 bytes
    .Signature      resb 4      ;   must be 'VESA'
    .Version        resw 1
    .OEMNamePtr     resd 1
    .Capabilities       resd 1

    .VideoModesOffset   resw 1
    .VideoModesSegment  resw 1

    .CountOf64KBlocks   resw 1
    .OEMSoftwareRevision    resw 1
    .OEMVendorNamePtr   resd 1
    .OEMProductNamePtr  resd 1
    .OEMProductRevisionPtr  resd 1
    .Reserved       resb 222
    .OEMData        resb 256
endstruc


section .text
    align 4
    dd 0x1BADB002        ; magic
    dd 0x00          ; flags
    dd - (0x1BADB002 + 0x00) ; checksum



_start:
    cli
    mov esp, stack
    call kernel_early
    call main
    hlt



    
section .bss
resb 8192
stack:



`

Solution

  • In mov esp, stack you have the immediate source operand on the right. That is correct.

    But in the code lines from 8 downward, you have mistakenly put the immediate on the left side:

    mov 0x4f02, ax
    mov 0x4118, bx
    int 0x10
    cmp 0x004f, ax
    

    For NASM the leftmost operand is the destination and the rightmost operand is the source. Also, an immediate operand can never be the destination (for obvious reasons).
    Correct:

    mov ax, 0x4F02
    mov bx, 0x4118
    int 0x10
    cmp ax, 0x004F