移动一个字节一个字节 [英] Moving a BYTE to a BYTE
问题描述
我在计算机体系结构和汇编语言类,我应该创建一个用于创建Fibonacci序列到一个用户定义的数MASM程序,即(含)1和46之间。当我尝试传输字符串存储在字节
标记缓存
,这就是本书的作者 ReadString
程序存储一个字符串,另一个字节
标记用户
,我收到此生成输出:
1 GT; ------启动生成:项目:MASM2,配置:调试的Win32 ------
1>装配fibonacci.asm ...
1> fibonacci.asm(39):错误A2070:无效的指令操作数
1> C:\\ Program Files文件(x86)的\\的MSBuild \\ Microsoft.Cpp \\ V4.0 \\ V140 \\ BuildCustomizations \\ masm.targets(50,5):错误MSB3721:命令ML.EXE / C / NOLOGO / SG /紫/Fo\"Debug\\fibonacci.obj/Fl\"MASM2.lst/ IC:\\欧文/ W3 / errorReport:提示/Tafibonacci.asm退出,code 1。
==========生成:0成功,1失败,0了最新,0已跳过==========
我不知道为什么我不能移动到相同大小的物体相互转化。我评论出用户部件和印刷缓冲区,它被正确地存储输入为字符串。任何帮助是极大的AP preciated。
***注:我们使用这本书汇编语言的x86处理器,第7版。由硖欧文,他利用Irvine32库。
;计算斐波那契数到第n程度INCLUDE Irvine32.inc。数据
缓冲器字节21 DUP(0)
欢迎BYTE欢迎斐波纳契!我的名字是扎克,我将是你今天的程序员!,0
问题BYTE你叫什么名字?:0
BYTE打招呼你好,0用户BYTE?提示BYTE从1到46输入一个数字:0
听取汇报BYTE再见SDWORD输入?FIB DWORD?。code
主要PROC 调用Clrscr ;打印欢迎屏幕
MOV EDX,OFFSET欢迎
调用WriteString
调用CRLF
;获取用户名和问候
MOV EDX,OFFSET问题
调用WriteString
调用CRLF MOV EDX,漂移缓冲
MOV ECX,SIZEOF缓冲
调用ReadString
MOV用户,缓冲 MOV EDX,迎接OFFSET
调用WriteString
MOV EDX,漂移缓冲
调用WriteString
调用CRLF
;获得Input-- 1〜46 MOV EDX,OFFSET提示
调用WriteString 调用的readInt
MOV输入,EAX
;验证ñ ;计算-5每行而言W在/ 5位
MOV ECX,输入
MOV人,','
MOV EAX,1
调用WriteDec 开始:
调用WriteChar
调用WriteDec
MOV FIB,EAX
添加EAX,谎
循环开始 ;听取汇报
调用CRLF
MOV EDX,OFFSET汇报
调用WriteString
调用了ExitProcess,0
主要ENDP
最终主
有趣的新输出:
1 GT; ------启动生成:项目:MASM2,配置:调试的Win32 ------
1>装配fibonacci.asm ...
1 GT; fibonacci.asm(44):错误A2022:指令操作数必须是相同的大小
1 GT; fibonacci.asm(45):错误A2022:指令操作数必须是相同的大小
1> C:\\ Program Files文件(x86)的\\的MSBuild \\ Microsoft.Cpp \\ V4.0 \\ V140 \\ BuildCustomizations \\ masm.targets(50,5):错误MSB3721:命令ML.EXE / C / NOLOGO / SG /紫/Fo\"Debug\\fibonacci.obj/Fl\"MASM2.lst/ IC:\\欧文/ W3 / errorReport:提示/Tafibonacci.asm退出,code 1。
==========生成:0成功,1失败,0了最新,0已跳过==========
我改变了code所以ReadString径直到用户,输出是正确的。
;获取用户名和问候
MOV EDX,OFFSET问题
调用WriteString
调用CRLF MOV EDX,OFFSET用户
MOV ECX,SIZEOF用户
调用ReadString MOV EDX,迎接OFFSET
调用WriteString
MOV EDX,OFFSET用户
调用WriteString
调用CRLF
I am in a Machine Architecture and Assembly Language class, and I am supposed to create a MASM program that creates the Fibonacci sequence up to a user defined number, that is inclusively between 1 and 46. When I try to transfer the string stored in a BYTE
labeled buffer
, which is where the book authors ReadString
procedure stores a string, to another BYTE
labeled user
, I receive this build output:
1>------ Build started: Project: MASM2, Configuration: Debug Win32 ------
1> Assembling fibonacci.asm...
1>fibonacci.asm(39): error A2070: invalid instruction operands
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Sg /Zi /Fo"Debug\fibonacci.obj" /Fl"MASM2.lst" /I "c:\Irvine" /W3 /errorReport:prompt /Tafibonacci.asm" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am not sure why I can't move to same sized objects into each other. I commented out the user parts and printed the buffer, and it is storing the input as a string correctly. Any help is greatly appreciated.
***Note: We are using the book Assembly Language for the x86 Processor, 7th Ed. by Kip Irvine, and using his Irvine32 Library.
; Calculate Fibonacci to the nth degree
INCLUDE Irvine32.inc
.data
buffer BYTE 21 DUP(0)
welcome BYTE "Welcome to Fibonacci! My name is Zach, I will be your programmer today!", 0
question BYTE "What is your name?: ", 0
greet BYTE "Hello, ", 0
user BYTE ?
prompt BYTE "Enter a number from 1 to 46: ", 0
debrief BYTE "GoodBye"
input SDWORD ?
fib DWORD ?
.code
main proc
call Clrscr
;Print Welcome Screen
mov edx,OFFSET welcome
call WriteString
call Crlf
;Get Username and Greet
mov edx,OFFSET question
call WriteString
call Crlf
mov edx,OFFSET buffer
mov ecx,SIZEOF buffer
call ReadString
mov user, buffer
mov edx,OFFSET greet
call WriteString
mov edx,OFFSET buffer
call WriteString
call Crlf
;Get Input-- 1 to 46
mov edx,OFFSET prompt
call WriteString
call ReadInt
mov input,eax
;Validate n
;Calculate-5 terms per line w/5 spaces between
mov ecx,input
mov al, ','
mov eax,1
call WriteDec
start:
call WriteChar
call WriteDec
mov fib, eax
add eax,fib
LOOP start
;Debrief
call Crlf
mov edx,OFFSET debrief
call WriteString
invoke ExitProcess,0
main endp
end main
Fun New Output:
1>------ Build started: Project: MASM2, Configuration: Debug Win32 ------
1> Assembling fibonacci.asm...
1>fibonacci.asm(44): error A2022: instruction operands must be the same size
1>fibonacci.asm(45): error A2022: instruction operands must be the same size
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Sg /Zi /Fo"Debug\fibonacci.obj" /Fl"MASM2.lst" /I "c:\Irvine" /W3 /errorReport:prompt /Tafibonacci.asm" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I changed the code so ReadString goes straight to User, and the output is correct.
;Get Username and Greet
mov edx,OFFSET question
call WriteString
call Crlf
mov edx,OFFSET user
mov ecx,SIZEOF user
call ReadString
mov edx,OFFSET greet
call WriteString
mov edx,OFFSET user
call WriteString
call Crlf
这篇关于移动一个字节一个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!