vijay tiwari
vijay tiwari

Reputation: 39

masm assembly how to access structure variable

DPT is a structure defined like this:

DPT STRUC
rSrtHdUnld DB 1; Bits 0-3: SRT step rate time, bits 4-7: head unload time.
rDmaHdLd   DB 1; Bit  0: 1=use DMA, bits 2-7: head load time.
bMotorOff  DB 1; 55-ms increments before turning disk motor off.
bSectSize  DB 1; Sector size (0=128, 1=256, 2=512, 3=1024).
bLastTrack DB 1; EOT (last sector on a track).
bGapLen    DB 1; Gap length for read/write operations.
bDTL       DB 1; DTL (Data Transfer Length) max transfer when length not set.
bGapFmt    DB 1; Gap length for format operation.
bFillChar  DB 1; Fill character for format (normally 0f6H).
bHdSettle  DB 1; Head-settle time (in milliseconds).
bMotorOn   DB 1; Motor-startup time (in 1/8th-second intervals)
DPT ENDS ; Size=11.   

while assembling in MASM I used following syntax:

MOVB [DI-SIZEOF DPT]+[DPT.bHdSettle],15

MASM is showing following error:

syntax error : [

Upvotes: 1

Views: 433

Answers (1)

Michael
Michael

Reputation: 58427

I'm not sure what movb is supposed to be, but I assume it's a typo and you really meant mov.

You can either write the instruction like this:

mov (DPT PTR [DI-SIZEOF DPT]).bHdSettle,15

Or if you're inside a PROC where you want to do multiple structure accesses through di you can tell the assembler to temporarily assume that di points to a DPT:

ASSUME di:PTR DPT
mov [di-SIZEOF DPT].bHdSettle,15
.....
ASSUME di:NOTHING

Upvotes: 2

Related Questions