Os programmering

13»

Comments

  • i can see what you mean, but i ment the one in your tutorial.
    ...
    but since it wont work for me... i maby have to.

    :)


    Kmt
  • : i can see what you mean, but i ment the one in your tutorial.
    : ...
    : but since it wont work for me... i maby have to.
    :
    : :)
    :
    :
    : Kmt
    :
    The other code was not from my tutorial either;-)

    It was a small assembly conversation from my previous OS C Kernel's IVT code.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • Hi again.
    i have a little quistion,
    wehn using lodsb,(load al for ds:si), i can't make ds correct.


    kmt.
  • : Hi again.
    : i have a little quistion,
    : wehn using lodsb,(load al for ds:si), i can't make ds correct.
    :
    :
    : kmt.
    :

    What do you mean?
    [code]
    mov ax, 0x07c0
    mov ds, ax
    mov di, SomeLocation
    losb
    [/code]

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • well
    when i try to wrtie a 0 terminated strig. there happens nothing, unless i change ds.
    i hvae tryede du mov 7c00 into ds
    .......
    but thanks anyway,
    i well see if i find out of why.

    Kmt
  • : well
    : when i try to wrtie a 0 terminated strig. there happens nothing,
    : unless i change ds.
    : i hvae tryede du mov 7c00 into ds
    : .......
    : but thanks anyway,
    : i well see if i find out of why.
    :
    : Kmt
    :
    Hello,

    Its hard to answer your question without seeing any code. Considering you posted in this thread, I assume you are developing an OS?

    If so, and in pmode, you should not be changing DS like that. DS should point to the base address of the data descriptor of the GDT.

    If in real mode, please post your current source (For your text routine), and we can see if we could spot the problem.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • oki.....
    here it is.
    thanks for answering.

    (some time before you said something about irq .... could you not find one about the pic ??? THANKS:)
    one last quistion
    is it only you who owns BrokenThorn Entertainment ??)

    Kmt
  • There is a few things wrong with that code.

    First, some BIOS's REQUIRE a BIOS Parameter Block (BPB). Here is your code with a BPB:
    [code]
    bits 16 ; We are still in 16 bit Real Mode

    org 0x7c00 ; We are loaded by BIOS at 0x7C00

    ; This must be a 2 byte small jump
    jmp start


    ; BPB
    bpbOEM db "My OS "
    bpbBytesPerSector: DW 512
    bpbSectorsPerCluster: DB 1
    bpbReservedSectors: DW 1
    bpbNumberOfFATs: DB 2
    bpbRootEntries: DW 224
    bpbTotalSectors: DW 2880
    bpbMedia: DB 0xf0 ;; 0xF1
    bpbSectorsPerFAT: DW 9
    bpbSectorsPerTrack: DW 18
    bpbHeadsPerCylinder: DW 2
    bpbHiddenSectors: DD 0
    bpbTotalSectorsBig: DD 0
    bsDriveNumber: DB 0
    bsUnused: DB 0
    bsExtBootSignature: DB 0x29
    bsSerialNumber: DD 0xa0a1a2a3
    bsVolumeLabel: DB "MOS FLOPPY "
    bsFileSystem: DB "FAT12 "

    start:

    ; Everything else is the same...
    [/code]

    I also noticed that you failed to initialize all registers to 0, prior to using them. [b]ORG[/b] is for the assembler, not the code itself. Initialize all registers to 0 (Including segment) as soon as you enter your start routine, before doing anything.

    This may be why your
    [code]
    mov ax,vidmem
    [/code]
    fails to work, as DS contains who knows what. (This references DS:vidmem)

    Also:
    [code]
    call write
    [/code]
    The call instruction pushes CS and IP ontop the stack. The [b]ret[/b] pops the top two values from the stack into CS and IP. The problem? [b]You have not set up the stack[/b]. So, these values are getting pushed and popped to some random location in memory, which is bad.

    Here is an example of setting up the stack:
    [code]
    mov ax, 0x0000
    mov ss, ax
    mov sp, 0xFFFF
    [/code]
    This sets the pointer to grow download from the top of 0xffff.

    The final problem is more of a question about your logic. This is your code
    (I added comments here for questions):
    [code]
    xor ax,ax ;we are loaded at 0000:7c00,
    mov ds,ax ; so ds must be 0000 since.

    ; You have just zeroed out DS, so the following instruction now refrences
    ; 0:msg1--which contains who knows what. Zero out DS after this code

    mov si,msg1

    ; Now, both DS and SI contain 0 still...
    ; Also, remember to ste up the stack, so the call instruction
    ; des not cause a crash

    xor di,di ;0.0 screen
    call write
    cli
    hlt

    ;--------------------------------

    write:
    lodsb
    or al,al
    jz writef
    mov ah,01h
    mov [di],ax ;write char

    jmp write

    writef:
    ret
    [/code]

    I can probably see if I can modify your code to get it working for you (Im off work today, so...)

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • : oki.....
    : here it is.
    : thanks for answering.
    :
    : (some time before you said something about irq .... could you not
    : find one about the pic ??? THANKS:)
    : one last quistion
    : is it only you who owns BrokenThorn Entertainment ??)
    :
    : Kmt

    Don't worry about setting up IRQ's right now, it will be impossible to set them up in the 512 byte limitation of stage 1 bootloaders.

    When you are ready, [link=http://www.osdever.net/tutorials/interrupts.1.php]Here[/link] is a very good introduction to the 8259 PIC Microcontroller, and how to remap your own IRQ's. It does not cover everything, but will get you started. It does use some C.

    ---

    We are a partnership company, founded by me and a friend. We are fairly new, and young though. Im the editor and the writer of the OS Development Series of tutorials.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • hmm
    i can see what you mean. ( if stack not set = random nuber ->crash)
    i will try make it too.
    maby i sucessed, and maby not.

    Kmt
  • : hmm
    : i can see what you mean. ( if stack not set = random nuber ->crash)
    : i will try make it too.
    : maby i sucessed, and maby not.
    :
    : Kmt
    :

    I give you credit:

    That was the fastest response I ever seen on this site! :-D

    Let us know if yoou get it :-)
    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • well
    i cant make the code work .....
    can you ??

    Kmt

  • Ugh...I should get paid for this:
    [code]
    bits 16 ; We are still in 16 bit Real Mode

    org 0x7c00 ; We are loaded by BIOS at 0x7C00

    ; NEW: near jump over OEM (2 bytes). Do NOT
    ; Move. BPB Must be 3 bytes from start

    jmp start

    ; NEW: BPB starts 3 bytes from start. It looks like the
    ; new Bochs version REQUIRES it.

    bpbOEM db "My OS "
    bpbBytesPerSector: DW 512
    bpbSectorsPerCluster: DB 1
    bpbReservedSectors: DW 1
    bpbNumberOfFATs: DB 2
    bpbRootEntries: DW 224
    bpbTotalSectors: DW 2880
    bpbMedia: DB 0xf0 ;; 0xF1
    bpbSectorsPerFAT: DW 9
    bpbSectorsPerTrack: DW 18
    bpbHeadsPerCylinder: DW 2
    bpbHiddenSectors: DD 0
    bpbTotalSectorsBig: DD 0
    bsDriveNumber: DB 0
    bsUnused: DB 0
    bsExtBootSignature: DB 0x29
    bsSerialNumber: DD 0xa0a1a2a3
    bsVolumeLabel: DB "MOS FLOPPY "
    bsFileSystem: DB "FAT12 "

    vidmem equ 47104

    start:
    ; NEW: setup a basic stack and null segments
    cli
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov ss, ax
    mov sp, 0xffff ; stack grows downward from 0xffff
    sti

    ; MODIFIED: We are setting ES to point to video
    ; memory instead of DS. Your previous code reset DS
    ; to 0, and written the characters using the offset 0
    ; instead--Which written it to a random location.

    mov ax,vidmem
    mov es,ax

    mov ax,0003
    int 10h

    ; I am keeping your original code here--You set DS:SI to point
    ; to the string. Now, I set ES to point to initil base address
    ; of video memory

    mov si,msg1
    xor di,di ;0.0 screen
    xor ax,ax ;we are loaded at 0000:7c00,
    mov ds,ax ; so ds must be 0000 since.
    call write
    cli
    hlt

    write:
    lodsb ; Load DS:SI into AL
    or al,al
    jz writef
    mov ah,01h

    ; MODIFIED: Now, because ES points to base of
    ; video memory, refrence that instead of DS

    mov [es:di],ax ;write char
    jmp write

    writef:
    ret

    msg1: db "test",00

    times 510 - ($-$$) db 0
    dw 0xAA55
    [/code]
    This is not complete--it is a modified version of your original code, with additional comments to mark modified and additional code.

    Your original code was setting DS to the base of video memory, and resetting it to 0 prior to your function call. The above code works, and has been tested--It prints the first character of your string.

    You need to fix your print routine a little though. Insure to correctly test for the null terminator.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories