flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Weird problem while testing OS

Author
Thread Post new topic Reply to topic
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo 27 Nov 2005, 22:15
I've been working on my OS project, Metropolis (see http://512dev.us.tt for details once it's back up - changing webhosts now). It compiles right, but I can't get it to run. I don't get a PANIC or an error, but this is what the screen looks like:
Image
And the second underscore kinda flickers on and off O_o .

The source is at http://512net.juleos.co.uk/metro_dev/001source/
Bootloader is boot.asm
Kernel is kernel.asm (duh)
Command routines are in commands.inca
It's all realmode x86 ASM compiled with Win32 FASM 1.64

I make an image for bochs using this script:
Code:
fasm boot.asm boot.bin
fasm kernel.asm kernel.bin
copy /b boot.bin+kernel.bin osdisk.img
    

I then load osdisk.img into bochs with 8MB RAM, no hard drives, and 1 floppy drive...everything else is default values.

This is the bochsout.txt log:
Quote:

00000000000i[ ] Bochs x86 Emulator 2.2.1
00000000000i[ ] Build from CVS snapshot on July 8, 2005
00000000000i[ ] System configuration
00000000000i[ ] processors: 1
00000000000i[ ] A20 line support: yes
00000000000i[ ] APIC support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] fpu support: yes
00000000000i[ ] paging support: yes, tlb enabled: yes
00000000000i[ ] mmx support: yes
00000000000i[ ] sse support: 1
00000000000i[ ] v8086 mode support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] PAE support: yes
00000000000i[ ] PGE support: yes
00000000000i[ ] PSE support: yes
00000000000i[ ] x86-64 support: no
00000000000i[ ] SEP support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] Guest2HostTLB support: yes
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Icache support: yes
00000000000i[ ] Host Asm support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[MEM0 ] allocated memory at 00C40020. after alignment, vector=00C41000
00000000000i[MEM0 ] 8.00MB
00000000000i[MEM0 ] rom at 0xf0000/65536 ('../BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/32768 ('../VGABIOS-lgpl-latest')
00000000000i[APIC?] local apic in initializing
00000000000i[APIC?] set APIC ID to 0
00000000000i[APIC0] 80686
00000000000i[APIC0] local apic in CPU apicid=00 initializing
00000000000i[IOAP ] initializing I/O APIC
00000000000i[IOAP ] set APIC ID to 1
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Sun Nov 27 17:06:59 2005 (time0=1133129219)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[FDD ] fd0: 'osdisk.img' ro=0, h=2,t=80,spt=18
00000000000i[WGUI ] Number of Mouse Buttons = 3
00000000000i[WGUI ] IME disabled
00000000000i[CLVGA] VBE Bochs Display Extension Enabled
00000000000i[CLVGA] interval=300000
00000000000i[CLVGA] CL-GD5430 ISA initialized
00000000000i[ ] init_mem of 'harddrv' plugin device by virtual method
00000000000i[ ] init_mem of 'keyboard' plugin device by virtual method
00000000000i[ ] init_mem of 'serial' plugin device by virtual method
00000000000i[ ] init_mem of 'parallel' plugin device by virtual method
00000000000i[ ] init_mem of 'extfpuirq' plugin device by virtual method
00000000000i[ ] init_mem of 'gameport' plugin device by virtual method
00000000000i[ ] init_mem of 'speaker' plugin device by virtual method
00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] Using boot sequence floppy, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[ ] init_dev of 'gameport' plugin device by virtual method
00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[ ] reset of 'gameport' plugin device by virtual method
00000000000i[ ] reset of 'speaker' plugin device by virtual method
00000004447i[BIOS ] rombios.c,v 1.138.2.1 2005/07/06 19:30:36 vruppert Exp $
00000318004i[KBD ] reset-disable command received
00000420033i[VBIOS] VGABios $Id: vgabios.c,v 1.62 2005/07/02 18:39:43 vruppert Exp $

00000420104i[CLVGA] VBE known Display Interface b0c0
00000420136i[CLVGA] VBE known Display Interface b0c3
00000423061i[VBIOS] VBE Bios $Id: vbe.c,v 1.47 2005/05/24 16:50:50 vruppert Exp $
00000450000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8
00000825000i[WGUI ] dimension update x=360 y=400 fontheight=16 fontwidth=9 bpp=8
00421251750p[WGUI ] >>PANIC<< Window closed, exiting!
00421251750i[SYS ] Last time is 1133130904
00421251750i[CPU0 ] real mode
00421251750i[CPU0 ] CS.d_b = 16 bit
00421251750i[CPU0 ] SS.d_b = 16 bit
00421251750i[CPU0 ] | EAX=0fff0030 EBX=00000050 ECX=00110000 EDX=00000014
00421251750i[CPU0 ] | ESP=00006262 EBP=00000000 ESI=00000030 EDI=00000119
00421251750i[CPU0 ] | IOPL=0 NV UP DI PL ZR NA PE NC
00421251750i[CPU0 ] | SEG selector base limit G D
00421251750i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00421251750i[CPU0 ] | CS:2700( 0000| 0| 0) 00027000 0000ffff 0 0
00421251750i[CPU0 ] | DS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00421251750i[CPU0 ] | SS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00421251750i[CPU0 ] | ES:2700( 0000| 0| 0) 00027000 0000ffff 0 0
00421251750i[CPU0 ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00421251750i[CPU0 ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00421251750i[CPU0 ] | EIP=00000048 (00000048)
00421251750i[CPU0 ] | CR0=0x00000010 CR1=0 CR2=0x00000000
00421251750i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00421251750i[ ] restoring default signal behavior
00421251750i[CTRL ] quit_sim called with exit code 1


Any help to why this is failing to run correctly would be GREATLY appreciated.

Thanks,
Anthony
Post 27 Nov 2005, 22:15
View user's profile Send private message Visit poster's website AIM Address Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 28 Nov 2005, 14:31
first replace ' org 7c0h ' by 'org 7c00h'
second make that your code prints messages to know what is happening.
and donĀ“t try to do a lot of things with the boot sector, just load the kernel
or a second stage loader in real mode.
and also read other OS sources to learn.
Post 28 Nov 2005, 14:31
View user's profile Send private message Visit poster's website Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 28 Nov 2005, 17:41
Wow... Runned it through the debugger. Result: 13 bugs.
Here is the correct code, corrections marked with ;###

In the boot.asm put 7c00 instead of 7c0 (typo?).

Also i reccomend this function, if you using the Bochs emulator, it prints the debug in the bochs console:

Code:
print2e9: ;ds:si 0-string addres
nop
push    ax si

lp2e9:
lodsb
cmp     al,0
je      endpr2e9
out     0e9h,al
jmp     lp2e9

endpr2e9:
pop     si ax
ret
;###endp        print2e9
    


kernel.asm:
Code:
use16
org 0x0000
command_length equ 3   ;###Constants better be before all (to be available for all)

jmp     begin           ;### Otherwise the cls code will be executed before setup

include 'commands.inc'

;====================
;Main kernel program
;====================

begin:
;reset segment registers
mov ax, cs
mov ds, ax
mov es, ax

main:
mov si, welcomemsg
call kprint
jmp loadprompt

;====================
;Kernel routines
;====================
kprint:         ;string output, SI = string
mov ah,0x0E
mov bh,0x00
mov bl,0x15
nextchar:
lodsb
or al,al
jz return
int 0x10
jmp nextchar
return:
ret

kputchar:       ;char output, al = char code ;##Absent from the original
mov ah,0x0E
mov bh,0x00
mov bl,0x15
int 0x10
ret

kscanf:         ;string input, DX = max length, if CX != 0, then string isnt echoed
xor bx, bx
start:

xor ax, ax
int 0x16        ;##Input with wait - int 16h, AX=0000h
cmp al, 0x0D
je return_press
mov [es:di+bx], al
inc bx
cmp bx, dx
je return_press
push bx
xor bx,bx
cmp bx,cx
je putchar

putreturn:
pop bx          ;##Stack async - multiple problems, when amount of push not equals amount of pop's
jmp start

putchar:
pop bx
push bx         ;##Stack async (2)
xor ah,ah

call kputchar   ;##Originally it calls the putchar label above, while there was no putchar function
jmp putreturn

return_press:
xor al,al
mov [es:di+bx],al
ret

loadprompt:     ;display the command prompt
mov si, loadpromptmsg   ;##Was loadprompt - loaded the addres of loadprompt ael instead of msg (typo?)
call kprint
mov si, prompt_title
call kprint
commandready:
mov si, prompt
call kprint
xor cx, cx
mov dx, 20

mov di, cmdbuffer
call kscanf


;routines to compare inputs to builtin commands
;will also compare to disk files once FAT12 support is implemented

compare_command_cls:    ;##locating the variable after the labeb makes the transfer in the label, instead of the code.
mov di, cmdbuffer
mov si, command_cls
mov cx, command_length
repe cmpsb              ;##cmpsw compares words, while yoou got bytes
                        ;##cmp cx,0 is useless, since rep cmpsb returns zf flag.
je cls
jmp invalid_cmd

invalid_cmd:
mov si, invalidcmd
call kprint
jmp commandready


;====================
;Data
;====================

welcomemsg db 'Metropolis 0.01 Codename Infinity: Kernel Loaded',13,10,0
loadpromptmsg db 'Starting shell...',13,10,0
prompt_title db 'MetroShell 0.1',13,10,0
command_cls db "cls",0  ;##Movedthe command there - better location
invalidcmd db 'The command entered was not recognized',13,10,0
prompt db '>',0
cmdbuffer db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

times 1024-$ db 0
    
Post 28 Nov 2005, 17:41
View user's profile Send private message Visit poster's website Reply with quote
Rohan



Joined: 14 Jul 2005
Posts: 13
Rohan 01 Jan 2006, 18:42
can you help me with my bootsector it doesn't work
Code:


        use16

        org 0x7C00
        jmp start

;-------------------------------------
OSName          db  'noname'  ;
BytsPerSec       dw   512       ;
ReservedSec       dw   1         ;
SecPerFAT          db   2         ; 
SecPerClus          db   1         ;
TotalSect            dw   2880      ;
RootEntriesSize       dw   511       ;
MediaType              db   0xf0      ;
FatSize                dw   9         ;
TrackSect             dw   18        ;
Heads                dw  2          ;
FATCopy             db   1         ;
SecPerPartit       db   2         ;
HidenSec          dd   0         ; ?-4
SecPerTrack      db   2         ;
LargeSec        dd   0         ;
;--------------------------------------
Reserved        db      0     ;
Signatured      db      0     ;
FddNumber       db   1        ;
FSType          db   'FAT12'  ;


start:

                mov cx,3
read:

      _loop:    mov ah,0         ; 
                int 13h
                mov ah,2         ; 
                int 13h
                xor cx,cx        ; 
                xor dl,dl        ; ffd A
                mov dh,1         ; 
                mov cl,4         ; 
                int 13h
                je  ok           ; 
                dec cx
                jz error         ; 
                jmp read

ok:
        mov al,3
        mov bh,0
        mov cx,8
        mov dh,12
        mov dl,45
        mov bp,Name
        int 13h

error:
        mov al,3
        mov bh,0
        mov cx,12
        mov bp,ermsg
        int 13h



ermsg db 'Error$'
Name   db 'Test'

int 20h
rb 7C00h+512-2-$
dw 0xAA55

    
Post 01 Jan 2006, 18:42
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.