because I don't have a very good command of assembler although I need it often for my OS I've decided to become acquintated with it. I've just written a mini-RM program that should simply print a string to the screen using BIOS interrupts. Assembling and starting in QEMU works well but the program behaves strange when I try to put a string to the screen (he puts out small delta signs in an endless loop. Following code:
Code: Select all
[BITS 16] ; generate 16bit real mode code
[ORG 0x700] ; start address of code is 0x700
; jump to start label (without segment prefix -> 0x0:)
jmp 0x00:start
start:
cli ; clear interrupt flag
; setup working stack
mov ax,0x9000
mov ss,ax ; set stack base address to 0x9000
mov sp,0 ; set stack pointer to 0
sti ; set interrupt flag
mov dx,msg
push dx
call printstr
jmp short $
msg db 'Welcome to simpleOS!',10,0 ; welcome message
; print string
printstr:
pop dx
mov si,dx
_loop:
mov al,[si]
mov ah,0x0E ; move attribute byte to 0x0E
int 0x10
mov al,[si] ; just in case the BIOS interrupt modifies the register
inc si
cmp al,0 ; compare al and 0
jne _done ; if they are equivalent, jump to the 'done' label
jmp _loop
_done:
ret
times 512-($-$$)-2 db 0 ; $ stands for the current line offset
; $$ stands for the offset into the section
dw 0xAA55
Thanks
jkrug