我有这个代码,我想知道是否有人愿意帮助我实现它。
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
答案 0 :(得分:2)
啊,Kip Irvine的书......我记得我想写自己的图书馆所以我不必使用他的......
你需要call
这些库函数,而不是你在汇编语言中的表现。
假设自第4版以来他的图书馆没有变更,WriteChar
要求您将要写入的字符移动到注册表al
中。 Crlf
不需要任何参数,因此您可以调用它,但拼写很重要。 ;)
mov al, BYTE PTR [edi + esi]
call WriteChar ; print the character found at [edi + esi]
call Crlf ; print a new line
在正确使用语法后,您需要仔细检查逻辑。