NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: flyhigh427 on July 23, 2011, 08:10:19 PM
-
hey
im getting an error unable to open file.
and do i have to load into the buffer or just load straight into the file ?
thanks
TARGETDRIVE equ 0 ; hard drive (0, 1, ...)
org 100h
Start:
mov dx,80h + TARGETDRIVE ; read MBR of target drive
mov cx,1h ; it's always the first sector
mov bx, buffer ; point to our buffer
mov ax, 0201h ; read one sector
int 13h
mov cx,4h ; read up to four entries
mov si, buffer + 1BEh; scan our partition table
mov si,begin
mov ax, 4C00h ; Exit to DOS.
int 21h
buffer db 0 ;Dynamic buffer, 512 bytes.
Begin: INCBIN "holdsec.bin"
-
I'm not sure I understand the problem. "Begin" != "begin", but I don't think that's what you're talking about(?). You seem to be "incbin"ing a file, and then overwriting it. I don't "get" it.
Best,
Frank
-
hey frank
i had caps on and fixed that.
im tryng to make a copy of my mbr
-
Hmmm...
flyhigh427, are you trying to write data to file "holdsec.bin"?
If yes, you are mistaken. INCBIN just places the content of file to the code at compilation time, not at execution.
-
thanks
-
Right. Now I understand the question (Thanks, Serge!). Yeah, you'll have to read your MBR into a buffer (512 bytes +, please!), then open/create the file, and write the buffer to it. (or... you could write the buffer to stdout and redirect it - watch out for "helpful" dos routines that convert tabs to spaces, etc. - int 21h/40h should work)
Best,
Frank