View Single Post
Old Oct 20th, 2006, 3:14 PM   #9
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
DaWei
Here's what I understand about the boot process. After the power and motherboard perform the POST and the like. The computer searches the first sector (512 bytes at 0:0:1) of one of the I/O drives (be it a hard drive or floppy or CD or however else your BIOS specifies it). This segment of code which should terminate with the "magic number" 0x55AA. Is loaded into the RAM at location 0x7C00. From here execution begins based on whatever you had in that 512 bytes of code assuming of course it meets the "magic number" condition and it is in fact 512 bytes long. Both of these conditions are met in the code that I wrote as I understand it. These are the only two conditions I have to meet in as far as I know. The Bochs emulator is loading the boot sector of a floppy image. Which works based on the most recent code I posted. This code is just modified code from the MenuetOS bootstrapper 'cause I wanted to see if I could get something to work since obviously my code isn't working and I don't know why. Whatever that segment of code from MenuetOS is doing it makes the characters MenuetOS appear on the virtual monitor of the Bochs emulator, which means that if I took it onto an actual computer it would most likely work. However, my own code which should've just printed an 'a' character on the screen isn't working. Therefore, logically, the problem is my code and not the Bochs emulator. The copy and modify is only because I wanted to get something which would display so as not to grow discouraged. I'm actually hoping that I understand the boot process, at least after the POST test so that I can just code a simple bootstrapper which prints 'a' on the screen, and then I'll go further from there. One step at a time I hope.

niteice
The [org 0x7c00] directive only specifies where the programmer believes the actual program will be in memory. In this case I know (or I think I know rather) the program is being loaded into 7c00. In the MenuetOS code listed there that jmp instruction was actually followed by a series of data declarations. Hence, why the program jmps. However, those bytes weren't relevant to the printing of the characters 'MenuetOS'.

Polyphemus_
The idea of an OS is cool, but I doubt I could ever get something like that working. More than anything I just want to display some text lol. This isn't for school, just satisfaction of my own curiosity and to see if I can grasp at any sort of "mastery" over assembly language. I realize that I can use assembly to program via the win32 api and all that other stuff, but I mean just nitty gritty fundamental stuff where here's the processor now do stuff with it with some limited inputs and outputs. Kinda like if I were programming a PIC microcontroller. I realize the levels of difficulty are very different, but I can control a stepper motor with a PIC lol.
-----------------------------------
So let me see if I can redefine my question. Compare these two segements of code:
MY CODE
mov ah, 09h
mov al, 97
mov bx, 100b
mov cx, 01h
int 10h
times 0x1fe-$ db 00h ; pads with 0's
db 55h,0aah ; boot signature
MenuetOS CODE
boot_program       equ 07c00h ;position for boot code
   
                   jmp start_program
                   nop
   



start_program:

  xor ax,ax
  mov ss,ax
  mov sp,boot_program
  push ss
  pop ds

  mov  si,loading+boot_program
loop_loading:
  lodsb
  or al,al
  jz procura_arquivo_novamente
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_loading


procura_arquivo_novamente:

  push ss
  pop es

  mov  bp,16

newtry:

  dec bp

loop_envio_mensagem:

  lodsb
  or al,al
  jz espera_digitar_tecla
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_envio_mensagem

espera_digitar_tecla:

  jmp $

loading   db 13,10,'Starting MenuetOS ',00h


times 0x1fe-$ db 00h

  db 55h,0aah ;boot signature

MY CODE doesn't boot on a Bochs emulator. The MenuetOS code does boot on the Bochs emulator. What is the menuetOS code doing that I am not doing and therefore failing to create a primitive bootstrapper? Is there some procedure relevant to the boot process (once the boot sector has been loaded into memory) that I have failed to take into account/do in my own code?
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote