MASM 611 - How to access STRUCTURES

Started by Elite Commando, November 22, 2009, 01:50:31 PM

Previous topic - Next topic

Elite Commando

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

MichaelW

You cannot use the "." notation because you have been instructed not to use it, or because you believe that it will not work?
eschew obfuscation

Elite Commando

I believe I cannot use it in MASM 611, if it's possible, please tell me how. Thanks!

dedndave

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

Elite Commando

thanks!i will try to work out with it! :)

MichaelW

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.
eschew obfuscation