Hello!
I have an asm source code for changing memory timings at boot time on an AMD64 system. I need to build the *.bin from the *.asm which I include then as an optional rom file into the motherboard BIOS image (with cbrom). I don't know, how to make a *.bin file for use in the BIOS with the compiler/linker from the latest MASM32 version.
I tried to build the obj file and from that the exe but the linker throws an error everytime. So, how do I make a binary image file for use in the system BIOS with the MASM32 package?
here's the source code:
.486p
CSEG SEGMENT PARA PUBLIC USE16 'CODE'
ASSUME CS:CSEG
ORG 0
;---------------------------------------------------------------------
; Expansion PCI ROM Header
;---------------------------------------------------------------------
db 55h ; Rom signature byte 1
db 0AAh ; Rom signature byte 2
db 01h ; Rom Size (1bit = 512 bytes)
jmp INIT ;jump to initialization
;---------------------------------------------------------------------
; Address & Data Port
;---------------------------------------------------------------------
address equ 0CF8h ; Access to configuration address
data equ 0CFCh ; Access to configuration data
;---------------------------------------------------------------------
; PCI Bus, Device, Function, Register
;---------------------------------------------------------------------
; __________________________________________________ _______________
; | 28| 24| 20| 16| 12| 8| 4| 0| Bits Number
; |1 0 0 0|0 0 0 0|0 0 0 0 0 0 0 0|0 0 0 0|0 0 0 0|0 0 0 0|0 0 0 0| Bits
; |1 - - -|- - - -| Bus Number | Device |Func |Reg |- -| Definition
; |1 0 0 0|0 0 0 0|0 0 0 0 0 0 0 0|1 1 0 0 0|0 1 0|0 0 0 0 0 0|0 0| Bits
; | 8 | 0 | 0 0 | 24 | 2 | | 0 | Decimal
; | 8 | 0 | 0 0 | C | 2 | | | Hex
; |_________________________________________________ ______________|
dcl_add equ 08000C290h ; DRAM Configuration Low
;---------------------------------------------------------------------
; DRAM Configuration Low Address
;---------------------------------------------------------------------
; Bypass Max(dcl)
bpm_data equ 0F1FFFFFFh ; Bypass Max (3bit)
bpm_0x equ 000000000h ; 0x (Disabled)
bpm_1x equ 002000000h ; 1x
bpm_2x equ 004000000h ; 2x
bpm_3x equ 006000000h ; 3x
bpm_4x equ 008000000h ; 4x
bpm_5x equ 00A000000h ; 5x
bpm_6x equ 00C000000h ; 6x
bpm_7x equ 00E000000h ; 7x
;---------------------------------------------------------------------
; Sub Routine
;---------------------------------------------------------------------
ORG 100h
SAVE1 PROC NEAR ; Save all register that will be affected by our code
push eax
push ebx
push edx
pushfd
ret
SAVE1 ENDP
SENDER PROC NEAR ; Active communication with address
mov dx,address
out dx,eax
ret
SENDER ENDP
RECEIVER PROC NEAR ; Comunicate with the address & receive the data
mov dx,address
out dx,eax
mov dx,data
in eax,dx
ret
RECEIVER ENDP
TUNER1 PROC NEAR ; Sending new data from ebx stack
xchg eax,ebx
out dx,eax
xchg eax,ebx
ret
TUNER1 ENDP
TUNER2 PROC NEAR ; Increase data (OR)
or eax,ebx
out dx,eax
ret
TUNER2 ENDP
TUNER3 PROC NEAR ; Decrease data (AND)
and eax,ebx
out dx,eax
ret
TUNER3 ENDP
RETURN1 PROC NEAR ; Restore register contents and return far to system
popfd
pop edx
pop ebx
pop eax
retf
RETURN1 ENDP
RETURN2 PROC NEAR ; Restore register contents and return to SATA bios
popfd
pop edx
pop ebx
pop eax
retf
RETURN2 ENDP
;---------------------------------------------------------------------
; Main Routine
;---------------------------------------------------------------------
INIT PROC NEAR
; save all register that will be affected by our code
call SAVE1
; bypass max = 7x
mov eax,dcl_add
mov ebx,bpm_7x
call RECEIVER
and eax,bpm_data
call TUNER2
; END Patch back to system bios or SATA jump (RETURN1 = System ; RETURN2 = SATA jump)
call RETURN2
INIT ENDP
ORG 200h
CSEG ENDS
END
I wonder how to do this with MASM, with the NASM there is an option, which makes a binary file from source.asm: nasm -fbin source.asm -o output.bin
Any help would be appreciated
Hello VASkO,
Welcome to the forum.
To create the bin file you need one of the more recent 16-bit linkers, like the one available here:
http://spiff.tripnet.se/~iczelion/files/Lnk563.exe
Assuming the 16-bit linker has been renamed to link16.exe (as I do to avoid confusing it with the 32-bit linker), you can use these command lines:
ML /c filename.asm
LINK16 /tiny filename.obj, filename.bin;
I have doubts that the system BIOS will search it's own address space for option ROMs.
EDIT:
Investigating CBROM I found some dumps of recent BIOSs that would seem to indicate that, at least for some systems, option ROMs are included in the BIOS image. But it still seems like a risky undertaking.
thanks for the reply. I found a better patching code for the BIOS as the one posted here. I am allready modifying it to my needs. will report back later, if the PC boots up with the patch applied :bg
btw: the source for patching BIOS files can be found here. (http://www.geocities.com/mamanzip/Articles/Bios_Tricks.html#Bios_Chip_Hacking)
It worked. built the .com file, set file checksum to 00h, added as optional ISA rom, flashed... it works and sets the not existing bios memory controller timing.
i am very happy, it did work, so i don't have to wait for years for my mobo maker to release a better bios :U
VASk0,
great job! And thanks for posting the link, this sort of specialised information can be hard to find :U