The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: smoalne on May 29, 2009, 11:37:26 AM

Title: having issues with accessing structs
Post by: smoalne on May 29, 2009, 11:37:26 AM
hello,
I am trying to follow the AoA text from webster.cs.ucr.edu and am having issues with trying to get a struct req. to work.
here is a sample piece of MY code.  what am i doing wrong?

here is the struct:
      mode              struct
      modbits           byte    ?
      reg                 byte    ?
      rm                  byte    ?
      mode              ends

      instr1adr         mode    {}
      instr2adr         mode    {}

      axbx              mode    {11b, 000b,000b}
      axdisp            mode    {00b,000b,110b}
      cxdispbxsi        mode    {01b,001b,000b}


      sptr1             dword    axdisp
      sptr2             dword    instr2adr

     mov al, axbx.modbits
     mov Instr1Adrs.modbits, al
     mov al, axbx.reg
     mov Instr1Adrs.reg, al
     mov al, axbx.rm
     mov Instr1Adrs.rm, al

i get an error stating that i cant use 16 bit registers w/ 32 bit arguments.  I tried changing the struct to words instead of bytes and the registers from al to eax but still get the same errors.  I am confused as to why i am still getting these errors.
could somebody help out with an interpretation of the errors and what i am doing incorrectly ?

thanks, Jeff
Title: Re: having issues with accessing structs
Post by: dedndave on May 29, 2009, 12:22:39 PM
sptr1 and sptr2 are 32-bit args - where is the code for those ?
Title: Re: having issues with accessing structs
Post by: PBrennick on May 29, 2009, 12:40:39 PM
Perhaps the problem is in the Instr1Adrs structure. Show us the code for that structure please.

Paul
Title: Re: having issues with accessing structs
Post by: ToutEnMasm on May 29, 2009, 01:34:58 PM

Perhaps i need to learn something,but masm don't use the }.Replace all this { by <  and } by > and all will be good.
Perhaps are you using a c++ compiler ?????
Title: Re: having issues with accessing structs
Post by: Jimg on May 29, 2009, 01:35:41 PM
The only problem I can see is you have to spell the variables the same.  This works-
mode              struct
      modbits           byte    ?
      reg                 byte    ?
      rm                  byte    ?
mode              ends
.data
      instr1adr         mode    {}
      instr2adr         mode    {}

      axbx              mode    {11b, 000b,000b}
      axdisp            mode    {00b,000b,110b}
      cxdispbxsi        mode    {01b,001b,000b}

      sptr1             dword    axdisp
      sptr2             dword    instr2adr
.code
     mov al, axbx.modbits
     mov instr1adr.modbits, al
     mov al, axbx.reg
     mov instr1adr.reg, al
     mov al, axbx.rm
     mov instr1adr.rm, al