question about MBR of DOS

Programming, for all ages and all languages.
Post Reply
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

question about MBR of DOS

Post by david »

In the MBR of DOS, there is a few code that moving MBR from 0:7c00 to 0:600.

Code: Select all

    xor ax, ax
    ....
    mov sp, 7c00
    mov si, sp
    push ax
    pop es
    push ax
    pop ds
    ....
    mov di, 0600
    mov cx, 0100
    repnz
    movsw
i have a question , why use 'repnz' ? why not use 'rep' ?
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Post by mathematician »

According to AMD's manual, repnz can't be used with movsw. So either the programmer has made a mistake, or your disassembler has.
The continuous image of a connected set is connected.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

REPNZ will repeat the instruction while the Zero Flag is Not Zero (NZ). A Move instruction can not possibly set or clear the Zero Flag so that doesn't make sense. REP MOVSW is correct and I also use it in the BootStrap code that I have written for the MBR of the HDD:

Code: Select all

MOV     SI , ORIGINAL_MBR_SEGMENT_OFFSET                        
MOV     DI , RELOCATED_MBR_SEGMENT_OFFSET                       
CLD                                                             
MOV     CX , BYTESPERSECTOR / SIZEOF_CX                         
REP     MOVSW                                                   
JMP     LOADED_BOOT_SECTOR_STAGE1_SEGMENT_ADDRESS:\             
        RELOCATED_MBR_SEGMENT_OFFSET + LABEL_EIP(.RestofTheCode)
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

the reason maybe is that Microsoft don't want DOS run on AMD CPU, only run on Intel CPU.
Perhaps because Wintel...
i guess

My compter is Intel CPU .
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

david wrote:the reason maybe is that Microsoft don't want DOS run on AMD CPU, only run on Intel CPU.
Perhaps because Wintel...
i guess

My compter is Intel CPU .
no, AMD and Intel CPUs are almost 100% identical...

and MS definately (and quite specifically) does want it to run on AMD

your assembler must be mistaken... i cant seem to find my copy to check at the moment
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

method of get MBR in DOS(Virtual PC) :
1 debug
2 read MBR to memory buffer from Hard Disk use int 13h
3 use 'U' command disassemble the memory buffer(MBR)
then, the result is that i show you .
so, i don't think the method have problem .
i also think 'U' command is correct !

i don't know why the programmer who write MBR of DOS use 'repnz' .
because i always use 'rep' in this case .
so i want to know the reason!

maybe it doesn't make any sense.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

It doesn't. Here's the closet thing on the Web, already correctly disassembled and well documented.

http://mirror.href.com/thestarman/asm/mbr/STDMBR.htm

EDIT: There is a note at the bottom of the page that explains the reason it appears as REPNZ. So the page also includes your answer.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

Tyler wrote:It doesn't. Here's the closet thing on the Web, already correctly disassembled and well documented.

http://mirror.href.com/thestarman/asm/mbr/STDMBR.htm

EDIT: There is a note at the bottom of the page that explains the reason it appears as REPNZ. So the page also includes your answer.
thank you very much!
Just For Fun
1234
Posts: 24
Joined: Sat May 26, 2007 7:58 pm

Post by 1234 »

[post deleted]
Last edited by 1234 on Tue Jan 27, 2009 3:19 pm, edited 1 time in total.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Post by david »

XCHG wrote: REP MOVSW is correct and I also use it in the BootStrap code that I have written for the MBR of the HDD:
i know.

i am programming a routine , it is in NIC's option ROM, it will use PXE to downland a bootstrap from PXE server .

i think i must load the Onboard NIC driver , ready for UNDI. DHCP and PXE.

do you know how to load the Onboard NIC driver ?

thanks !
Just For Fun
Post Reply