zondag 19 februari 2023

masm x64 console printf example. DO NOT USE!

;Let's make a simple "Hello World" in x86-64 assembly:

includelib ucrt.lib
includelib legacy_stdio_definitions.lib
includelib libcmt.lib

extrn printf: PROC

.data
msg db 'Hello World!', 0dh, 0ah, 0

.code
main proc
  push	rbp
  mov	rbp, rsp
  
  lea	rcx, msg
  call	printf 

  mov	rsp, rbp
  pop	rbp
  ret  
main endp

End

; compile with: ml64.exe hello_world.asm /link /subsystem:console
; It results in an exe of 123904 bytes. It's clear that using the Microsoft toolchain results in byte obesity.
; I guess this is the reason that assemblers like FASM were created.
; MASM also has no interaction with the PE-format; the .exe that is generated when assembling and linking.
; So, DO NOT USE this example or MASM for small size executables, but a "Hello World" created with FASM that will be posted later.

Geen opmerkingen:

Een reactie posten