The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Artoo on March 29, 2007, 12:54:20 AM

Title: MACRO Help - Insert JMP into struct.
Post by: Artoo on March 29, 2007, 12:54:20 AM
I am currently dealing with bootcode, specifically the Bios Paramter Block.  As you may know the first 3 bytes of the BPB is a jump to boot code. 

My question is how does one use a macro so that a "JMP short ToLabel" can be used instead of hardcoded values.

Heres what I got so far:


S_BPB STRUCT
     m_JumpToCode     DB 3 DUP(0)         ;Replace these 3 bytes with a "JMP short ToLabel, NOP'
     m_strOEM         DB "Mine",0,0,0,0
     <more fileds here>
S_BPB ENDS

S_BPB_DEF MACRO BPBName, ToLabel
     BPBName S_BPB <0EBh, ToLabel, 90>
ENDM

S_BPB_DEF MyBPB, MyCode

MyCode:
<boot code>



I hope this it is clear what I am asking.    Any ideas?

Thanks in advance.
Title: Re: MACRO Help - Insert JMP into struct.
Post by: Artoo on March 29, 2007, 02:06:09 AM
Fixed it with this:


S_BPB STRUCT
     m_JumpToCode   DB   0EBh                    ;JMP SHORT to
                    DB   ?                       ;Label
                    DB   090h                    ;NOP
     m_strOEM       DB   "Mine",0,0,0,0          ;sOEM
     <... lots of other fields ...>
S_BPB ENDS

S_BPB_DEF MACRO BPBName, JumpShortLabel
     BPBName S_BPB { , JumpShortLabel-BPBName.m_JumpToCode - 2 }
ENDM


BootSector:
; Define BIOS Parameter Block
S_BPB_DEF BPB, BootSectorStart

<might want to define extra data here>

BootSectorStart:

Title: Re: MACRO Help - Insert JMP into struct.
Post by: MichaelW on March 29, 2007, 08:47:59 AM
You can't just use jmp NEAR PTR BootSectorStart?