0

アドレス計算で eax を使用できない理由がわかりません...次は無効なオペランド型エラーを返します...

1 つのパラメーターを取るマクロがあります。

    %macro  IdPrompt 1      ; 1% - the offset within Buff at which to write the ID that is read in                                                                                                                             

    mov eax, 3              ; Specify sys_read call                                                                                                                                                                            
    mov ebx, 0              ; Specify File Descriptor 0: Stdin                                                                                                                                                                 
    mov ecx, Buff+([%1]*2)  ; Pass offset of the buffer to read ID into, 2 is the scale                                                                                                                                                        
    mov edx, 3              ; Pass number of bytes to read at one pass                                                                                                                                                         
    int 80h                 ; call sys_read to fill the buffer                                                                                                                                                                 
    %endmacro

マクロは、別のマクロ内でこれによって呼び出されます。

    IdPrompt eax            ; call IdPrompt to get one ID

私はより小さなレジスタを使用してみました。また、バッファアドレスを次のように使用してみました: Buff+%1*2 運が悪い

4

1 に答える 1

1

@ user786653 のコメントによると:

正しい構文は次のとおりです。

%macro  IdPrompt 1      ; 1% - the offset within Buff at which to write the ID that is read in                                                                                                                             

mov eax, 3              ; Specify sys_read call                                                                                                                                                                            
mov ebx, 0              ; Specify File Descriptor 0: Stdin                                                                                                                                                                 
lea ecx, [Buff+%1*2]    ; Pass offset of the buffer to read ID into, 2 is the scale                                                                                                                                                        
mov edx, 3              ; Pass number of bytes to read at one pass                                                                                                                                                         
int 80h                 ; call sys_read to fill the buffer                                                                                                                                                                 
%endmacro

leaメモリにアクセスしないことに注意してください。アドレス計算のみを行います。
したがって、引数が[]角括弧で囲まれていても、リテラル レジスタ値を使用しています。

%1、レジスタ参照に置き換えられます。あなたの例では:lea ecx,[eax*2+Buff]

于 2013-10-16T01:24:26.607 に答える