hi folks,
just did my first test with MASM and FASM with the same code (almos) and I falled in trouble. The only difference is that to produce just the 104 bytes I need to write to MBR in FASM I put org 7c00h and in MASM 0h.
The problem is on the
mov si, offset msg
that in the first case transletes it to 44 7C (7c44h) and with masm translates to 44 00 (0044h)! but just when I change org 7c00h to org 0h in MASM. Otherwise it will produce the entire segment from 0 to 7dff.
how do I solve it?
or in short, how to make MASM produce a binary that begins at 7c00h as it first byte and subsequent jumps remain relative to 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