剛剛用MASM和FASM用相同的代碼(almos)進行了第一次測試,我陷入了麻煩。唯一的區別是我只需要在FASM中寫入MBR的104個字節,我把org 7c00h和MASM 0h寫入。FASM vc在mov si中的MASM trasnlation問題,偏移msg
的問題是在
mov si, offset msg
,在第一種情況下它transletes至44 7C(7c44h)中並用MASM轉換爲44 00(0044h)!但只是當我改變org 7c00h到MASM組織org 0h。否則它會產生從0到7dff的整個段。
我該如何解決?
或簡而言之,如何使MASM產生一個二進制開始於7c00h,因爲它的第一個字節和隨後的跳轉保持相對於7c00h?
.model TINY
.code
org 7c00h ; Boot entry point. Address 07c0:0000 on the computer memory
xor ax, ax ; Zero out ax
mov ds, ax ; Set data segment to base of RAM
jmp start ; Jump to the first byte after DOS boot record data
; ----------------------------------------------------------------------
; DOS boot record data
; ----------------------------------------------------------------------
brINT13Flag db 90h ; 0002h - 0EH for INT13 AH=42 READ
brOEM db 'MSDOS5.0' ; 0003h - OEM name & DOS version (8 chars)
brBPS dw 512 ; 000Bh - Bytes/sector
brSPC db 1 ; 000Dh - Sectors/cluster
brResCount dw 1 ; 000Eh - Reserved (boot) sectors
brFATs db 2 ; 0010h - FAT copies
brRootEntries dw 0E0h ; 0011h - Root directory entries
brSectorCount dw 2880 ; 0013h - Sectors in volume, < 32MB
brMedia db 240 ; 0015h - Media descriptor
brSPF dw 9 ; 0016h - Sectors per FAT
brSPH dw 18 ; 0018h - Sectors per track
brHPC dw 2 ; 001Ah - Number of Heads
brHidden dd 0 ; 001Ch - Hidden sectors
brSectors dd 0 ; 0020h - Total number of sectors
db 0 ; 0024h - Physical drive no.
db 0 ; 0025h - Reserved (FAT32)
db 29h ; 0026h - Extended boot record sig
brSerialNum dd 404418EAh ; 0027h - Volume serial number (random)
brLabel db 'OSAdventure' ; 002Bh - Volume label (11 chars)
brFSID db 'FAT12 ' ; 0036h - File System ID (8 chars)
;------------------------------------------------------------------------
; Boot code
; ----------------------------------------------------------------------
start:
mov si, offset msg
call showmsg
hang:
jmp hang
msg db 'Loading...',0
showmsg:
lodsb
cmp al, 0
jz showmsgd
push si
mov bx, 0007
mov ah, 0eh
int 10h
pop si
jmp showmsg
showmsgd:
retn
; ----------------------------------------------------------------------
; Boot record signature
; ----------------------------------------------------------------------
dw 0AA55h ; Boot record signature
END
我說過關於鏈接器創建的二進制文件。沒有檢查obj呢。這必須是一個MBR,所以它需要這樣。我使用masm32包,所以link16是鏈接器。將看看如何定義這樣的細分市場,一旦我是這樣的環境:) – 2010-06-05 18:58:40
發現一些好東西...所有MASM文檔設置在http://web.sau.edu/LillisKevinM/csci240/masmdocs / – 2010-06-06 13:47:13