Assembly Graphics in Starfruit

B

bashcommando

Guest
I am attempting to write a OS for fun. I got a error compiling this code using this command. Help?
Code(main.asm):
Code:
    BITS 64

section .bss
    bootmsg db 'Booting...', 0

section .text
    global _start
_start:
    mov si, bootmsg
    call kprintln
    mov ax, 0x07C0
    mov ds, ax
    add ax, 288
    mov ss, ax
    mov sp, 4096
    call setmem
    call setscreenmode
   
   
setmem:
    cli
    call a20wait
    mov al, 0xAD
    out 0x64, al
    call a20wait
    mov al, 0xD0
    out 0x64, al
    call a20wait2
    in al, 0x60
    push eax
    call a20wait
    mov al, 0xD1
    out 0x64, al
    call a20wait
    pop eax
    or al, 2
    out 0x60, al
    call a20wait
    mov al, 0xAE
    out 0x64, al
    call a20wait
    sti
    ret

a20wait:
    in al, 0x64
    test al, 2
    jnz a20wait
    ret

a20wait2:
    in al, 0x64
    test al, 1
    jz a20wait2
    ret

kprintln:
    mov ah, 0x0E

.kprintrep:
    lodsb
    cmp al, 0
    je .kdone
    int 0x10
    jmp .kprintrep

.kdone:
    ret

setscreenmode:
    out 0x13, 0xA0000
    int 0x10
    ret

kputpixel:
    push rbp
    mov rbp, rsp
    mov -24(rbp), rdi
    mov -28(rbp), esi
    mov -32(rbp), edx
    mov -36(rbp), ecx
    mov edx, -28(rbp)
    mov eax, edx
    add eax, eax
    add edx, eax
    mov eax, -32(rbp)
    imul eax, eax, $2400
    add eax, edx
    mov -4(rbp), eax
    mov eax, -4(rbp)
    add eax, 1
    mov edx, eax
    mov rax, -24(rbp)
    add rdx, rax
    mov eax, -36(rbp)
    sar eax, 16
    mov (rdx), al
    mov eax, -4(rdp)
    add eax, 2
    mov edx, eax
    mov rax, -24(rbp)
    add rdx, rax
    mov eax, -36(rbp)
    sar eax, 16
    mov (rdx), al
    pop rbp
    ret

.bootstrap:
    cli
    hlt
    jmp $
    times 4096-($-$$) db 0
    dw 0xAA55
The command:
Code:
nasm -f bin -o test boot.asm
The output:
Code:
boot.asm:78: error: comma, colon or end of line expected
boot.asm:79: error: comma, colon or end of line expected
boot.asm:80: error: comma, colon or end of line expected
boot.asm:81: error: comma, colon or end of line expected
boot.asm:82: error: comma, colon or end of line expected
boot.asm:86: error: comma, colon or end of line expected
boot.asm:89: error: comma, colon or end of line expected
boot.asm:90: error: comma, colon or end of line expected
boot.asm:93: error: comma, colon or end of line expected
boot.asm:95: error: comma, colon or end of line expected
boot.asm:98: error: comma, colon or end of line expected
boot.asm:101: error: comma, colon or end of line expected
boot.asm:103: error: comma, colon or end of line expected
 


You mean the bootloader? Actually you can use Grub to load your (C or assembly) kernel.

It has some syntax errors on those lines, but dont know exactly on top of my head
 
You mean the bootloader? Actually you can use Grub to load your (C or assembly) kernel.

It has some syntax errors on those lines, but dont know exactly on top of my head
This is the kernel/bootloader(If it needs one). I believe that the origin of the errors are from ksetpixel.
 
It's been a while since I used nasm, I'll try to assemble it.
These lines cause some trouble:
Code:
    mov -24(rbp), rdi
    mov -28(rbp), esi
    mov -32(rbp), edx
    mov -36(rbp), ecx
I'm not sure what exactly you are trying to do here, maybe you want -24 in a register? It's been more than 10 years ago since I last used nasm

Indeed, some bugs in ksetpixel, but when I removed this function it seems there are some other errors too. Try to make it in an infinite loop first, see if that works.
 

Staff online

Members online


Top