-8

私はこのコードを持っていて、誰かが私がそれを機能させるのを手伝ってくれるかどうか疑問に思っていました.

TITLE MASM Template                     (main.asm)

; Description: this code is supposed to print out each letter followed by a space and then the capitalized version on seperate lines
; Revision date:

INCLUDE Irvine32.inc
.data

myArray byte 'l','s','d','t','h','c','f','u','c','k'    ;my array of 10 characters
.code
main PROC

    mov ecx,0                                        ;clears ecx
    mov ecx,LENGTHOF myArray                         ;should be 10
    mov edi,OFFSET myArray                   ;will point to the beginning of the array
    mov eax,0                                       ;clears eax
    mov esi,0                                       ;clears esi

LOne:

    mov eax,myArray[esi]          ;points the pointer at the beginning of myArray
    WriteChar eax                     ;prints the designated value in the array
    WriteChar 32                    ;prints a space (32 is the ascii value for ' ')
    sub eax,32                      ;subtracts 32 from the ascii value of the char
                         ;the capital version of each letter is -32 of its ascii value
    WriteChar eax           ;prints the capital version
    call CLRF               ;prints new line
    inc esi                 ;increments esi to the next array value
    dec ecx                 ;decrements ecx, moving it through the array

    loop LOne               ;loops back until ecx is equal to zero

    exit
main ENDP

END main

構文エラーが発生してコンパイルされません。

1>main.asm(22): エラー A2008: 構文エラー: eax
1>main.asm(23): エラー A2008: 構文エラー: WriteChar
1>main.asm(26): エラー A2008: 構文エラー: eax
1> main.asm(21): エラー A2022: 命令オペランドは同じサイズでなければなりません
1>main.asm(27): エラー A2006: 未定義のシンボル: CLRF

4

1 に答える 1

2

ああ、Kip Irvine の本です... 自分のライブラリを書きたかったのを覚えています。

これらのライブラリ関数が必要callです。これは、アセンブリ言語で行う方法ではありません。

彼のライブラリが第 4 版から変更されていないと仮定すると、WriteChar書き込みたい文字をレジスタに移動する必要がありますalCrlf引数を必要としないので、呼び出すだけでかまいませんが、スペルが重要です。;)

mov     al, BYTE PTR [edi + esi]
call    WriteChar                  ; print the character found at [edi + esi]

call    Crlf                       ; print a new line

構文を正しく理解したら、ロジックを再確認する必要があります。

于 2011-09-23T03:48:50.440 に答える