masm程序集如何访问结构变量

时间:2020-08-07 12:15:36

标签: assembly struct masm

DPT是这样定义的结构:

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.   

在MASM中组装时,我使用以下语法:

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

MASM显示以下错误:

syntax error : [

1 个答案:

答案 0 :(得分:2)

我不确定movb应该是什么,但是我认为这是一个错字,而您的意思是mov

您可以编写如下指令:

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

或者,如果您在PROC内,想要通过di进行多个结构访问,则可以告诉汇编器暂时假定di指向{{1} }:

DPT
相关问题