Author Topic: My First MASM 64-bit Hello World console  (Read 241 times)

Mikl__

  • Member
  • ***
  • Posts: 426
Re: My First MASM 64-bit Hello World console
« Reply #15 on: January 12, 2017, 06:58:13 PM »
Code: [Select]
include win64a.inc
includelib msvcrt.lib
include msvcrt.inc
.code
WinMain proc
        mov     ecx,offset hello
        call    printf

        xor     ecx,ecx
        call    exit

WinMain endp
hello db 'Hello 64-bit world!',0ah,0
end

jj2007

  • Member
  • *****
  • Posts: 6267
  • Assembler is fun ;-)
    • MasmBasic
Re: My First MASM 64-bit Hello World console
« Reply #16 on: January 12, 2017, 09:36:06 PM »
try MasmBasic:
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc
Init ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
  Inkey Chr$("Hello World: This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
EndOfCode

Hello World: This code was assembled with HJWasm32 in 64-bit format

Vortex

  • Member
  • *****
  • Posts: 1579
Re: My First MASM 64-bit Hello World console
« Reply #17 on: January 13, 2017, 06:00:21 AM »
Another example :

Code: [Select]
include HelloX64.inc

.data

msg db 'Hello world!',0

.code

start:

   sub      rsp,4*8+8
   invoke   StdOut,ADDR msg
   invoke   ExitProcess,0

StdOut PROC lpszText:QWORD

LOCAL hOutPut:QWORD
LOCAL bWritten:QWORD
LOCAL sl:QWORD
LOCAL _lpszText:QWORD

    mov     _lpszText,rcx
    invoke  GetStdHandle,STD_OUTPUT_HANDLE
    mov     hOutPut,rax

    invoke  lstrlen,_lpszText
    mov     sl,rax

    invoke  WriteFile,hOutPut,_lpszText,sl,ADDR bWritten,NULL
    mov     rax,bWritten
    ret

StdOut ENDP

END