这款MASM X64出自教科书。我无法在Visual Studio中编译它。我用Visual Studio成功地编写和编译了MASM X32程序printf
/scanf
。我不知道我是否在X64中调用了printf
/scanf
错误,或者有MASM编译错误问题。它为printf
和scanf
提供了一个“未解析的外部符号”错误。任何洞察力都会有所帮助。
; Section 11.9 Complete Program
printf PROTO
scanf PROTO
.data
msg1fmt byte "%s",0
msg2fmt byte 0Ah,"%s",0Ah,0Ah,0
msg3fmt byte " %lld", 0Ah,0Ah,0
in1fmt byte "%lld",0
msg2 byte "Enter an integer: ",0
msg3 byte "Reversed",0
n sqword 5
arry sqword 5 dup(?)
.code
main proc
mov rcx,n ; initialize rcx to n
mov rbx,0 ; initialize rbx to 0
for01: nop
push rcx ; save rcx
lea rcx, msg1fmt
lea rdx, msg2
sub rsp, 40
CALL printf
add rsp, 40
lea rcx, in1fmt
lea rdx,arry[rbx]
sub rsp,40
call scanf
add rsp,40
pop rcx ; restore rcx
add rbx,8 ; increment rbx by 8
loop for01
endfor01: nop
lea rcx, msg2fmt
lea rdx, msg3
sub rsp, 40
CALL printf
add rsp, 40
mov rcx,n ; initialize rcx to n
sub rbx,8 ; subtract 8 from rbx
for02: nop
push rcx ; save rcx
lea rcx, msg3fmt
mov rdx, arry[rbx]
sub rsp, 40
CALL printf
add rsp, 40
pop rcx ; restore rcx
sub rbx,8 ; decrement rbx by 8
loop for02
endfor02: nop
ret
main endp
end
字符串
1条答案
按热度按时间wsxa1bj11#
printf
和scanf
是C运行时库libcmt.lib
的一部分,您需要关键字extern
将它们声明为外部过程。reverse.asm
字符串
上面的代码是使用这些命令编译和链接的:
型
运行程序输出
的数据