gpt4 book ai didi

assembly - 在 64 位 masm 中打印 hello

转载 作者:行者123 更新时间:2023-12-05 03:31:20 26 4
gpt4 key购买 nike

我是编程菜鸟。
我想写一个程序在 64 位 masm 中显示 hello。
我将 VS 代码与 ml64.exe 和 gcc 一起使用。
以下是我写的:

;; file name: hello.asm
printf proto

.data
messenge dq "hello", 0

.code
main proc
sub rsp, 40h
mov rcx, messenge
call printf
add rsp, 40h
ret
main endp

end

然后我编写了一个脚本来组装、链接和执行:

@:: file name: run.cmd
@ml64 /c hello.asm
@gcc -o hello.exe hello.obj
@del *.obj
@hello.exe

它是这样的:

C:\code\MASM>run.cmd
Microsoft (R) Macro Assembler (x64) Version 14.25.28614.0
Copyright (C) Microsoft Corporation. All rights reserved.

Assembling: hello.asm

没有输出hello字符串。
我该如何解决?

最佳答案

我只使用 ml64 hello.asm(没有 gcc)构建它。

;; file name: hello.asm
printf proto
includelib msvcrt.lib
includelib legacy_stdio_definitions.lib

.data
messenge db "hello", 13, 0

.code
main proc
sub rsp, 40h
mov rcx, offset messenge
call printf
add rsp, 40h
ret
main endp

end

基本上是迈克尔所说的。

关于assembly - 在 64 位 masm 中打印 hello,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70661294/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com