NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on September 03, 2007, 06:56:34 PM
-
i want to know how did u put a booting program on an diskett.
I have this program:
Boot record is loaded at 0000:7C00,
ORG 7C00h
; load message address into SI register:
LEA SI,[msg]
; screen function:
MOV AH,0Eh
print: MOV AL,[SI]
CMP AL,0
JZ done ; zero byte at end of string
INT 10h ; write character to screen.
INC SI
JMP print
; wait for 'any key':
done: MOV AH,0
INT 16h ; waits for key press
; AL is ASCII code or zero
; AH is keyboard code
; store magic value at 0040h:0072h to reboot:
; 0000h - cold boot.
; 1234h - warm boot.
MOV AX,0040h
MOV DS,AX
MOV word[0072h],0000h ; cold boot.
JMP 0FFFFh:0000h ; reboot!
msg DB 'Welcome, I have control of the computer.',13,10
DB 'Press any key to reboot.',13,10
DB '(after removing the floppy)',13,10,0
i use nasm to assemble it but after that i dont know how to save it in a diskett ahy help would be nice
THX, Cesar
-
Hi Cesar,
I'd use dd. If your development OS doesn't have that, you could use "rawwrite", or John Fine's "partcopy", or DEBUG will do it (have to format the disk first - PITA!).
Or... since you claim to have control of the computer, you could write one. :)
Here's a start...
Best,
Frank
P.S. Your bootsector assumes that ds is zero. This may or may not be true - depends on the bios. If it doesn't work, that's probably why. If it does work on your machine, it may not work on another. As the Masm folks say, "Assume Nothing! :)
Having said that, *this* file assumes that your bootsector is named "boot.bin", and is going on a: :)
; nasm -f bin -o writeit.com writeit.asm
[BITS 16]
[ORG 0x100]
mov ax,3D00h
mov dx,filename
int 21h
; check for errors here!
mov bx,ax
mov ah,3Fh
mov dx,buffer
mov cx,512
int 21h
; check for errors here!
mov ah,3Eh
int 21h
push ds
pop es
mov bx, buffer
mov dl, 00h
mov dh, 0
mov cl, 1
mov ch, 0
mov ah, 03h
mov al, 1
int 13h
mov ax, 4C00h
int 21h
filename db 'BOOT.BIN',0
buffer times 512 db 0
-
Thanks i will try that now