1,105,320 Community Members

Structures arrays

Member Avatar
Newbie Poster
18 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

Hi everyone
I wish a happy new year for all.

This is the code that i wrote so far.

TITLE MASM Template                     (main.asm)

; Description:
; Revision date:

INCLUDE Irvine32.inc
INCLUDE macros.inc
Employee STRUCT
    idnum BYTE "0000",0
    lastname BYTE 30 DUP(0)
    years WORD 0
Employee ENDS

workers Employee 3 DUP(<>)
count DWORD ?
main PROC

    mov ecx,LENGTHOF workers
    mov esi,TYPE Employee

    mov count,ecx
    mWrite "Enter employee id:> "

    mov edx,OFFSET workers[esi].idnum  ; Problem is here
    mov ecx,LENGTHOF workers.idnum
    call ReadString
    call crlf
    mov ecx,count
    add esi,TYPE employee
    loop l1

main ENDP

END main

I want to add ID for every worker in the structere.The problem is that i cant reach the workers' idnum variable.

Here's the errors:

Error 2 error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\main.obj" /I "c:\Irvine" /W3 /errorReport:prompt /Tamain.asm" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets 49 6 Project

Error 1 error A2098: invalid operand for OFFSET C:\Irvine\Examples\structure3\main.asm 28 1 Project

I need your hepls.

Member Avatar
Light Poster
38 posts since Jun 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
        ASSUME  esi : ptr workers

        mov     ebx, [esi:idnum]

          - or -

        mov     ebx, [esi: Employee:idnumb]

        ASSSUME esi : nothing

Been quite sometime since I've used MASM, so the move may not be exactly right, but should get you started in the right direction.

This article has been dead for over three months: Start a new discussion instead
Start New Discussion
Tags Related to this Article