Search code examples
memoryassemblyoutputmasm

MASM, output from some memory point


reader of this question.

I'm not new with assembly. But I'm new with MASM. (in fact, I was using that hardcore clean tasm stuff for about 8 years without even a single minute of using a single macros, he-he).

Now, I've got to make a simple program. I already did it's main logic. But there is some trouble with output. When I use

output <some-variable-name>

it makes the thing - it outputs characters. But now I want to begin output not from the very beginning of some variable but from a specific address in memory. Now I do:

lea eax, <some-variable-name>
mov esi, eax
... manipulations with address in esi, like 'add esi, ebx' and so on...
output esi

But that won't work. Compiler says 'error A2070: invalid instruction operands'. I use Microsoft Macro Assembler version 6.11.

Thanks in advance. Sorry for my broken English.

UPD: defenition of 'output' macros, taken from included 'io.h' file:

output      MACRO  string,xtra         ;; display string

            IFB    <string>
            .ERR <missing operand in OUTPUT>
            EXITM
            ENDIF

            IFNB   <xtra>
            .ERR <extra operand(s) in OUTPUT>
            EXITM
            ENDIF

            push   eax                 ;; save EAX
            lea    eax,string          ;; string address
            push   eax                 ;; string parameter on stack
            call   outproc             ;; call outproc(string)
            pop    eax                 ;; restore EAX
            ENDM

Solution

  • The soulution in this situation is use following:

    lea eax, <some-variable-name>
    mov esi, eax
    ... manipulations with pointer, like 'add esi, edx' and so on ...
    push esi
    call outproc