Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

my bootstrap, whats wrong

Status
Not open for further replies.

neos

Programmer
Oct 28, 2000
36
0
0
CA
I'm a newbie to assembly, bare with me. I'm using nasm. I wrote this small bootloader, but when it loaded up the string didn't print out, and I just got alot of colours on the screen.

bits 16
org 0

jmp start

start:
mov si, os_nam
call print

print:
mov ah, 0
int 10

os_nam db 'shauns OS', 0
times 489 db 0

shaun
 
Hi Neos.
Glad to see some proper assembly coding attempts ! I tried bootstrap writing a while ago, and rather than show you what might be wrong with yours, I will show you a sample that works. Take a look:
Code:
; Boot.asm - bootstrap assembly code.
code segment
  assume cs:code
  org 100h

program:
  jmp 07c0h:start

dataarea:
  msg1 db 'Operating System',0

start:
  ; Setup segment registers
  xor ax,ax
  mov ax,cs
  mov ds,ax
  mov es,ax
  ; Clear screen
  mov ax,0003h
  int 10h
  
  mov ah,13h
  mov al,01h
  mov bh,00h
  mov bl,07h
  mov cx,10h
  mov dh,09h
  mov dl,09h
  lea bp,msg1
  add bp,7b00h
  int 10h

hang:
  jmp hang
  
  org 510
  dw 0AA55h ; Boot signature
  ret

ends
end program
This is a fairly basic bootstrap, but gets across a few points you need to know about bootstrap writing.
1) The boot signature at the 511 and 512. The AA55h value is how a computer recognizes the disk as bootable.
2) The 'jmp 07c0:start' line: The bootcode is loaded from the disk at 07c0h.
3) The memory is now at 7c00h. This is why you have to add 7b00h to the org 100h base address after 'lea bp, msg1'.
(Incidentally, I only put 'org 100h' to compile this as a COM file with TASM, otherwise it complained about illegal entry point address :))

For my code, compile it as a COM file then write it to the first sector of a floppy. Pop the floppy in at startup and watch it work. (Don't try running COM file in DOS or Windows as it won't work properly due to memory marking up.)
Hope that has been helpful. Have Fun !

Adonai
 
The h indicates that the number is hexadecimal. It is not decorative. I don't know about nasm, but most assemblers allow you to enter numbers in decimal, hexadecimal, or binary, and if you don't say which you are using, sooner or later things will go wrong. I think decimal is mostly the default.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top