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!

Boot Problem

Status
Not open for further replies.

adholioshake

Programmer
Feb 9, 2003
136
0
0
I have been attempting to write a bootable floppy in assembly and have got this code so far. The problem is that I don't know where the data has got to ?! Can anyone point me in the right direction for finding it !
Thanks, Adonai.

PS: the code is here if you want to take a look :)
Code:
code segment
  assume cs:code
  org 100h

program:
  dw offset start,7C0h
  jmp start

dataarea:
  msg1 db 'Bootable disk'
  msg2 db 'Loading operating system'

start:
  push cs
  pop ds

; Clear Screen
  mov ax,0600h
  mov cx,0000h
  mov dx,184Fh
  mov bh,03h
  int 10h
; Display a nice message...
  mov si,offset msg1
  call message

message:        ; Dump ds:si to screen.
  lodsb         ; load byte at ds:si into al
  or al,al      ; test if character is 0 (end)
  jz done
  mov ah,0Eh    ; put character
  mov bx,0007h  ; attribute
  int 10h
  jmp message
done:
  ret

; OK, just hang for now...
hang:
  jmp hang

  org 510
  dw 0AA55h ; Boot signature
  ret

ends
end program
 
Don't worry, I've cracked it by trial and error.
The data I want is at 7C00h, so you have to add 7B00h to the offset of the data you want (because org 100h already gives extra 100h). This compiles as a com file and works when written to the first sector of a floppy and booted.
I've given the test code I used below if anyone else is interested... :) Adonai
Code:
code segment
  assume cs:code
  org 100h

program:
  jmp 07c0h:start

dataarea:
  msg1 db 'Bootable disk',0
  msg2 db 'Just a hanging 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
  ; Display a message
  mov si,offset msg1
  add si,7b00h
  call message
  ; Move cursor
  mov ah,02h
  mov bh,00h
  mov dx,0300h
  int 10h
  ; Display other message
  mov si,offset msg2
  add si,7b00h
  call message
  mov ah,02h
  mov bh,00h
  mov dx,0000h
  int 10h

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

message:        ; Dump ds:si to screen.
  lodsb         ; load byte at ds:si into al
  or al,al      ; test if character is 0 (end)
  jz done
  mov ah,0Eh    ; put character
  mov bx,0007h  ; attribute
  int 10h
  jmp message
done:
  ret

ends
end program
 
nice little routine you made :)

just a couple things of interest...

i notice you are using a far jump at the start. you could use a relative jump as the code segment on boot is set to 07C0h theres no need for far jumps here.

also...

personally i lost the org 0100h directive and wrote the com file code directly to the sector. this gives you an extra 256 bytes of code. the boot strap starts execution at 07C00:0000h and not 07C00:0100h. setting ds=cs as you have done should remove any further need for far pointers. i dont understand why you are setting si=07B00h unless you set a segment selector to zero?????? and taking into consideration the org 0100h

anyway, you have now got to write a little addition to load more sectors (your kernal) into memory and execute it.

keep up the good work :)
straiph




"There are 10 types of people in this world, those who know binary and those who don't!"
 
Thanks Straiph.

I only really included the 'org 100h' a t the start because my assembler complains about illegal entry point address when trying to compile. I think I should get another assembler that will just do straightforward binaries!

Just a thought: Have you found anymore info on network assembly code? I'm trying to find the ports for a standard ethernet card, but have had no such luck. I have also written a netbios program, but its not quite working yet.

Adonai :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top