1.11M Members

Structures arrays

 
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

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

    mov ecx,LENGTHOF workers
    mov esi,TYPE Employee

l1:
    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


    exit
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.

 
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.

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