News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MACRO Help - Insert JMP into struct.

Started by Artoo, March 29, 2007, 12:54:20 AM

Previous topic - Next topic

Artoo

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.

Artoo

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:


MichaelW

You can't just use jmp NEAR PTR BootSectorStart?

eschew obfuscation