|
I use Visual Studio 2022 in Windows 11. The following code run OK on my machine. step1: Create a file hello.asm with contents: includelib ucrt.lib includelib legacy_stdio_definitions.lib includelib msvcrt.lib option casemap:none .data ; , 10 means line feed character (LF) ; , 0 means adding an terminating '\0' to the string fmtStr byte 'Hello', 10, 0 .code externdef printf:proc externdef _CRT_INIT:proc externdef exit:proc main proc call _CRT_INIT push rbp mov rbp, rsp sub rsp, 32 lea rcx, fmtStr ; lea: load the address of a variable into a register call printf xor ecx, ecx ; the first argument for exit() is setting to 0 call exit main endp endstep2: open "x64 Native Tools Command Prompt for VS 2022" windows, assemble and link the code This step use ml64.exe, the MASM assembler, together with link options, to generate hello.exe: ml64 hello.asm /link /subsystem:console /entry:mainstep3: Run the executable (责任编辑:) |
