The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Elite Commando on November 22, 2009, 01:50:31 PM

Title: MASM 611 - How to access STRUCTURES
Post by: Elite Commando on November 22, 2009, 01:50:31 PM
Hi, I am very new to assembly language, I am trying to access specific locations in a Structure I have defined myself, the problem is, I am bound to use MASM Version 611 and cannot use the DOT operator, say the structure is called "Employee", I cannot do it like this: "Employee.Salary" since I believ I cannot include the "Irvine16.inc" in MASM 611, if its possible, then please tell me how to do it! here's my code:

.stack 100h

.data
temp db "hello",'$'
msg1 db "enter some value: ", '$'

student struct
rollno db ?
name db 20 dup(?)
gpa db ?
student ends

array student 100 dup(<>)
.code

main proc

mov ax,@data
mov ds,ax

mov di,offset array
mov [di],9

mov ah,02
mov dx,[di+44]
int 21h


mov ax,4c00h
int 21h




main endp
end main


Any help will e greatly appreciated! Thanks

added code tags
Title: Re: MASM 611 - How to access STRUCTURES
Post by: MichaelW on November 22, 2009, 02:22:39 PM
You cannot use the "." notation because you have been instructed not to use it, or because you believe that it will not work?
Title: Re: MASM 611 - How to access STRUCTURES
Post by: Elite Commando on November 22, 2009, 02:55:33 PM
I believe I cannot use it in MASM 611, if it's possible, please tell me how. Thanks!
Title: Re: MASM 611 - How to access STRUCTURES
Post by: dedndave on November 22, 2009, 04:09:26 PM
first, your file should have a .MODEL directive

        .MODEL SMALL
        .STACK 512

second, this instruction has no size

        mov     [di],9

the assembler does not know if [di] is a byte or a word

        mov byte ptr [di],9

next, this code has a couple problems
int 21h function 2 displays a single character from DL - not DX - so mov dl,[di+44] is more appropriate
also, the value at [di+44] is uninitialized (probably a 0 byte - which will display as a space character)

        mov     ah,2
        mov     dl,[di+44]
        int     21h

finally, most of us use masm version 6.14 or better, as that is the version that comes with the MASM32 package
but, i don't know of any problem with using the dot operator with 6.11
if everything else is right, it should work for you
either way, you may be stuck using 6.11 so that your instructor can assemble the code
Title: Re: MASM 611 - How to access STRUCTURES
Post by: Elite Commando on November 22, 2009, 04:48:22 PM
thanks!i will try to work out with it! :)
Title: Re: MASM 611 - How to access STRUCTURES
Post by: MichaelW on November 22, 2009, 10:49:03 PM
The dot operator for structures and the irvine16 library (or at least the one I have from 2001) both work fine with MASM version 6.11.