flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > How can make my program boot from floppy? |
Author |
|
Madis731 15 Nov 2004, 14:51
1) You will need a 512-byte header (for booting) that ends with 55AA
2) You need to write it in the boot sector 3) Then you'd have to write your program to other sectors. Search the forums - there are some tutorials about it. |
|||
15 Nov 2004, 14:51 |
|
Kristian_ 15 Nov 2004, 15:37
Thank you, but...
The only thing I found is this: http://board.flatassembler.net/topic.php?t=2120 After I compile this code, how can I write it on floppy so it will boot from it? And if my apps size is bigger than 512 bytes, I need to make two apps? 1. boot loader 2. my app? Thank you! |
|||
15 Nov 2004, 15:37 |
|
ASHLEY4 15 Nov 2004, 16:55
Try this code assemble as a bin file.
Code: ;************************************; \\|//; (@ @); ASHLEY4.; Put test.bin on boot sector; with rawrite.; Assemble with fasm; c:\fasm test.asm test.bin;;************************************org 0x7C00use16;****************************; Realmode startup code.;****************************start: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,0x7C00writesometext: mov ax,0xB800 mov es,ax lea si,[msg0] mov di,(80 * 1 + 2) * 2 mov cx,28 cld rep movsb jmp $ msg0 db " H E L L O W O R L D ! " ;*************************************; Make program 510 byte's + 0xaa55;************************************* times 510- ($-start) db 0dw 0xaa55 Also you can not use dos int for boot code ( dos is not loaded ), bios int are ok in realmode. Or you can do it the easy way and get bootprog.zip, get it and info on it from here: http://alexfru.chat.ru/epm.html Hope this helps. PS: In the above code you must have the same spacer between the letters of the string, as these are the color bytes. \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. Last edited by ASHLEY4 on 15 Nov 2004, 17:55; edited 2 times in total |
|||
15 Nov 2004, 16:55 |
|
Kristian_ 15 Nov 2004, 17:25
Thank you very much! But how can I write it on the floppy??? What tool can I use on DOS or Linux?
|
|||
15 Nov 2004, 17:25 |
|
ASHLEY4 15 Nov 2004, 17:44
rawrite for dos, run the program it will say name of image, you type test.bin and press enter, it will ask for drive you type A: and press enter, it then says put a floppy in the A: drive and press enter.
And when the floppy light is out you can reboot and try it. http://www.tux.org/pub/dos/rawrite/ Get rawrite.exe NOTES: Make show the bin file is in the same dir, as rawrite, or so once your write to the floppy in this way, it will need to format the floppy to use it in win/linux. So make shore you do not have any thing on the disk you want. PS: The OS forum may be a better place to ask OS/boot ? . \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
15 Nov 2004, 17:44 |
|
Kristian_ 15 Nov 2004, 19:18
OK, thank you very much!!! Can't wait to make it boot!!!
|
|||
15 Nov 2004, 19:18 |
|
Matrix 15 Nov 2004, 23:47
Kristian_ wrote: Hi! well, from the begining, you can't use dos function as you are not running any operating system during bootup. you should use bios function instead. (ah=0xe; int 10h) btw .: where do you wanna exit with int 20h? |
|||
15 Nov 2004, 23:47 |
|
Kristian_ 16 Nov 2004, 04:43
Thank you!
Quote: btw .: where do you wanna exit with int 20h? I never fought about it! As far as I understood I can't just exit! I need to reboot right? About thous BIOS calls, BIOS allready have pre-created fonts, and I can use them in real mode for displaying strings? If I want to create something bigger than just a small app (if I need to access more than 1MB of RAM, I will need to use Protected mode? And since I can't use BIOS calls in Protected mode, I will need to create my own fonts and characters with Pixels, and since I can't use BIOS I will need to write directly to Video memory to display pixels? Thank you! |
|||
16 Nov 2004, 04:43 |
|
ASHLEY4 16 Nov 2004, 06:02
This code will put you in pmode (not tested)
Code: ;************************************; \\|//; (@ @); ASHLEY4.; Put test.bin on boot sector; with rawrite.; Assemble with fasm; c:\fasm test.asm test.bin;************************************org 0x7C00use16;****************************; Realmode startup code.;****************************start: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,0x7C00;*****************************; Setting up, to enter pmode.;***************************** cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x10: protected;*****************************; Pmode. ;*****************************use32protected: mov ax,0x8 mov ds,ax mov es,ax mov ss,ax mov esp,0x7C00;*****************************; Turn floppy off (if space).;***************************** mov dx,3F2h mov al,0 out dx,al lea esi,[msg0] mov edi,0xB8000 + (80 * 3 + 4) * 2 mov ecx,28 cld rep movsb jmp $;*************************************; GDT. ;*************************************gdt: dw 0x0000, 0x0000, 0x0000, 0x0000sys_data: dw 0xFFFF, 0x0000, 0x9200, 0x00CFsys_code: dw 0xFFFF, 0x0000, 0x9800, 0x00CFgdt_end:gdtr: dw gdt_end - gdt - 1 dd gdt;*************************************; Data. ;*************************************msg0 db " H E L L O W O R L D ! " ;*************************************; Make program 510 byte's + 0xaa55;************************************* times 510- ($-start) db 0dw 0xaa55 You do not need to make you own fonts for pmode textmode, only if you use vesa. put it on the disk as before. NOTE: you can not use int's, with this code as it is. PS: In boot code to start with you can just do this: Code: LetsStayHere: jmp LetsStayHere You can then just switch off your pc, because you can not exit in any other way, from a basic boot/os. PPS: To get more ram, you will need to enable A20, in the above code. \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
16 Nov 2004, 06:02 |
|
Kristian_ 16 Nov 2004, 15:32
Thank you very much! But I have a problem! I try to write this bin on floppy, but when I rebooted my comp., my drive is starting to read the floppy and make some strange sounds for 3 seconds and just boots into lilo (boot manager). I try it on 4 floppy disks, but still the same sound. Can I burn it on CD? Then I try to install MenuetOS on floppy so I downloaded installer, but after the installation, the same result! My HDD is set into 4 partitions:
1. Linux ext3 2.Linux ext3 3.Linux Swap 4. fat32 Can I somehow put it on the first sector of fat32 partition? My BIOS is set to load first from floppy, but I can't seem to understand why can't it read! I can read/write data and everthing works, but doesn't work for booting! And thank you for the source!!! |
|||
16 Nov 2004, 15:32 |
|
ASHLEY4 16 Nov 2004, 16:57
NO! DO NOT TRY and put it on your hdd, it is not a good idea to touch your hdd, when testing code.
Is there not a floppy option in lilo menu ?. Have you got any thing to boot from A: drive ? Maybe doubler check bios floppy boot. PS: If you have vesa 2 on your pc, you can try down loading a small demo of a atapi driver, just burn it to cd and boot, this will test if you can burn it to cd, its a iso. it called "DemoVesa.zip" get here: http://www.falconrybells.co.uk/ PPS: I have try test.bin on all my pc and it works,so as now been tested. \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
16 Nov 2004, 16:57 |
|
Kristian_ 16 Nov 2004, 18:39
Thank you! I burned DemoVesa.zip, but after I restarted my computer, the CD booted, first it detected like Floppy drive, next it like changed resolution, but there was only blank screen and the cd led was blinking, but nothing happened, Does it has to be this way? Thanx!
P.S: Thank you for moving this post! |
|||
16 Nov 2004, 18:39 |
|
ASHLEY4 16 Nov 2004, 20:27
If it went to a black screen with no cursor, then you can boot cd's ok. so you can make a bootable cd from the floppy image.
Some cd do not read very well from cd-rw and others do not read very well cd-r at boot time, also try to boot more time and try pressing the A key when the cd light goes out, to retest "DemoVesa" also theres a menuetos iso,i think. ps: i did not move your post here. \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
16 Nov 2004, 20:27 |
|
Kristian_ 23 Nov 2004, 17:18
Thanx!
Well, your code is great and working, but too complicated for me to understand, but I got very simple boot code ready, but I have some questions: Code: org 0x7C00 use 16 ; does this mean 16 bit? start: mov ax, 0x0003 int 0x10 times 510-($-start) db 0 ; this makes program 512 bytes long, but why does it says times 510 not 512? ; and after this line executes, it goto start label ? and where can I read more about this times function and its syntax? dw 0xAA5 ; what does this mean? Thank you! |
|||
23 Nov 2004, 17:18 |
|
joachim_neu 23 Nov 2004, 18:44
use 16 ; does this mean 16 bit?
yes, it means. times 510-($-start) db 0 ; this makes program 512 bytes long, but why does it says times 510 not 512? because after that there is one other word=2 bytes: dw 0xAA5 ; what does this mean? it's for the PC to see, that this floppy is bootable. |
|||
23 Nov 2004, 18:44 |
|
ASHLEY4 23 Nov 2004, 20:47
510 + 0xAA55 = 512 bytes .
here a link to a simple hello boot programs, may help. http://osdev.neopages.net/tutorials/hello_btldr.php?the_id=85 NOTE: use this if you use fasm Code: org 0x7C00use 16 ; does this mean 16 bit?start: Code: times 510-($-start) db 0 dw 0xAA55 As the code in the link users nasm. ps: remember to put jmp $ at the end, and Y have you done, set text mode, ? you should not need to set this. \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
23 Nov 2004, 20:47 |
|
Kristian_ 23 Nov 2004, 22:18
Thank you very much!!!
|
|||
23 Nov 2004, 22:18 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.