注册 登录
编程论坛 汇编论坛

求助啊.MASM关于结构体

nosaybye 发布于 2012-09-12 16:28, 738 次点击
DoubleWord      struc
lsw     dw      ?
msw     dw      ?
DoubleWord      ends

SectorBase      dd      ?         ; next sector to read

mov     SectorBase.lsw, 0       ; read sector zero.
mov     SectorBase.msw, 0

当我编译的时候会报错,我该怎么办?
6 回复
#2
zklhp2012-09-12 16:49
SectorBase      dd      ?         ; next sector to read

貌似应该是

SectorBase     DoubleWord     <?>

关于这个的语法好好去看书罢
#3
nosaybye2012-09-13 09:18
假如要是使用结构体的指针呢?
DoubleWord      struc
lsw     dw      ?
msw     dw      ?
DoubleWord      ends

SectorBase      DoubleWord     <?>         ;
pSectorBase     dd    ?

mov ebx,pSectorBase
mov eax,[ebx].DoubleWord ;//这样对么?
#4
nosaybye2012-09-13 10:14
//通过结构体的方式使用偏移
.386
PARM STRUC
BPREG DW ?
READR DW ?
PARM ENDS

CSEG SEGMENT
START:
      mov eax,[ebx].BPREG //我的目的是使用偏移
CSEG ENDS

end START

//直接使用结构体
.386
PARM STRUC
BPREG DW ?
READR DW ?
PARM ENDS

DSEG SEGMENT
APARM PARM <?>
DSEG ENDS
CSEG SEGMENT

START:
      mov ebx,APARM.BPREG


CSEG ENDS

end START

//间接使用结构体
.386
PARM STRUC
BPREG DW ?
READR DW ?
PARM ENDS

DSEG SEGMENT
APARM PARM <?>
DSEG ENDS
CSEG SEGMENT

START:
      mov ebx,offset APARM
      mov eax,[ebx].BPREG

CSEG ENDS

end START

怎么都不对啊,
#5
zklhp2012-09-13 10:17
以下是引用nosaybye在2012-9-13 09:18:50的发言:

假如要是使用结构体的指针呢?
DoubleWord      struc
lsw     dw      ?
msw     dw      ?
DoubleWord      ends

SectorBase      DoubleWord              ;
pSectorBase     dd    ?

mov ebx,pSectorBase
mov eax,[ebx].DoubleWord ;//这样对么?

用lea指令就可以了
#6
nosaybye2012-09-13 10:21
回复 5楼 zklhp
lea eax,SectorBase
mov pSectorBase,eax
mov ebx,pSectorBase
谢谢啊
#7
zklhp2012-09-13 10:23
以下是引用nosaybye在2012-9-13 10:21:12的发言:

lea eax,SectorBase
mov pSectorBase,eax
mov ebx,pSectorBase
谢谢啊

觉得好记得结题
1