-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
57 lines (48 loc) · 1.89 KB
/
Copy pathmain.asm
File metadata and controls
57 lines (48 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;==============================================================================
; File: main.asm
;
; Purpose: 0x0000-ASM-Hello-World Windows Console App written in Assembler.
;
; Platform: Windows x64
; Author: Kevin Thomas
; Date: 2025-06-29
; Updated: 2025-06-29
;==============================================================================
extrn GetStdHandle :PROC
extrn WriteConsoleA :PROC
extrn ExitProcess :PROC
.data
msgText db "Hello World", 0Ah, 0
writtenChars dq 0
.code
;------------------------------------------------------------------------------
; mainCRTStartup PROC main entry point
;------------------------------------------------------------------------------
mainCRTStartup PROC
SUB RSP, 28h ; reserve 32-byte shadow space, +8 16-b align
; HANDLE WINAPI GetStdHandle(
; _In_ DWORD nStdHandle
; );
MOV RCX, -11 ; 1st param = nStdHandle - STD_OUTPUT_HANDLE
CALL GetStdHandle ; call Win32 API
; BOOL WINAPI WriteConsole(
; _In_ HANDLE hConsoleOutput,
; _In_ const VOID *lpBuffer,
; _In_ DWORD nNumberOfCharsToWrite,
; _Out_opt_ LPDWORD lpNumberOfCharsWritten,
; _Reserved_ LPVOID lpReserved
; );
LEA R9, writtenChars ; 4th param = lpNumberOfCharsWritten
MOV R8, 12 ; 3rd param = nNumberOfCharsToWrite
LEA RDX, msgText ; 2nd param = *lpBuffer
MOV RCX, RAX ; 1st param = hConsoleOutput
CALL WriteConsoleA ; call Win32 API
; void ExitProcess(
; [in] UINT uExitCode
; );
MOV RCX, 0 ; 1st param = uExitCode
CALL ExitProcess ; call Win32 API
ADD RSP, 28h ; restore 32-byte shadow space, +8 16-b align
RET ; return to caller
mainCRTStartup ENDP
END