MASM 및 FASM을 사용하여 동일한 코드 (almos)로 첫 테스트를했는데 문제가 발생했습니다. 유일한 차이점은 FASM에서 MBR에 쓸 필요가있는 104 바이트를 생성한다는 것입니다. org 7c00h와 MASM 0h를 넣었습니다.FASM vc MASM trasnlation 문제가 mov si, offset msg
문제는
mov si, offset msg
에 상기 제 1 케이스 (44) 7C (7c44h)에 transletes MASM과 함께 44 00 (0044h)로 변환 안에 하지만 내가 MASM에서 조직 7c00h를 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이 링커입니다. 그런 환경에 그런 새롭다면 그런 세그먼트를 정의하는 방법에 관해서 생각할 것이다 :) –
는 좋은 재료를 찾아 냈다 ... 모든 MASM docs는 http://web.sau.edu/LillisKevinM/csci240/masmdocs에 놓았다 / –