finished hello_files.asm
This commit is contained in:
@ -215,9 +215,9 @@ memory_copy:
|
|||||||
cld
|
cld
|
||||||
rep movsb ; REPEAT MoveStringByte
|
rep movsb ; REPEAT MoveStringByte
|
||||||
; 1. Copies the byte from [RSI] to [RDI].
|
; 1. Copies the byte from [RSI] to [RDI].
|
||||||
; 2. Increments RSI and RDI (because of CLD).
|
; 2. Increments RSI and RDI (because of CLD).
|
||||||
; 3. Decrements RCX.
|
; 3. Decrements RCX.
|
||||||
; 4. Repeats until RCX is 0.
|
; 4. Repeats until RCX is 0.
|
||||||
ret
|
ret
|
||||||
;endregion memory_copy
|
;endregion memory_copy
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ extern GetStdHandle
|
|||||||
extern WriteConsoleA
|
extern WriteConsoleA
|
||||||
|
|
||||||
struc wapi_ctbl
|
struc wapi_ctbl
|
||||||
.shadow: resb 32 ; 32 bytes for RCX, RDX, R8, R9
|
.shadow: resq 4 ; 32 bytes for RCX, RDX, R8, R9
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
; rcx: hObject
|
; rcx: hObject
|
||||||
@ -443,10 +443,11 @@ endstruc
|
|||||||
; NOTE: Even though the first two are DWORDs, on the stack they each
|
; NOTE: Even though the first two are DWORDs, on the stack they each
|
||||||
; occupy a full 8-byte slot in the x64 ABI.
|
; occupy a full 8-byte slot in the x64 ABI.
|
||||||
struc CreateFileA_ctbl
|
struc CreateFileA_ctbl
|
||||||
.shadow: resb 32
|
.shadow: resq 4
|
||||||
.dwCreationDisposition: resb 8
|
.dwCreationDisposition: resq 1
|
||||||
.dwFlagsAndAttributes: resb 8
|
.dwFlagsAndAttributes: resq 1
|
||||||
.hTemplateFile: resb 8
|
.hTemplateFile: resq 1
|
||||||
|
._pad resq 1
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
; rcx: hFile
|
; rcx: hFile
|
||||||
@ -463,7 +464,6 @@ endstruc
|
|||||||
struc ReadFile_ctbl
|
struc ReadFile_ctbl
|
||||||
.shadow: resq 4
|
.shadow: resq 4
|
||||||
.lpOverlapped: resq 1
|
.lpOverlapped: resq 1
|
||||||
._pad: resq 1 ; 8 bytes padding for 16-byte stack alignment
|
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
; rcx: hFile
|
; rcx: hFile
|
||||||
@ -474,7 +474,6 @@ endstruc
|
|||||||
struc WriteFileA_ctbl
|
struc WriteFileA_ctbl
|
||||||
.shadow: resq 4
|
.shadow: resq 4
|
||||||
.lpOverlapped: resq 1
|
.lpOverlapped: resq 1
|
||||||
._pad: resq 1 ; 8 bytes padding for 16-byte stack alignment
|
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
struc FileOpInfo
|
struc FileOpInfo
|
||||||
@ -483,7 +482,7 @@ endstruc
|
|||||||
|
|
||||||
; rcx: nStdHandle
|
; rcx: nStdHandle
|
||||||
struc GetStdHandle_ctbl
|
struc GetStdHandle_ctbl
|
||||||
.shadow: resb 32
|
.shadow: resq 4
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
; rcx: hConsoleOutput
|
; rcx: hConsoleOutput
|
||||||
@ -524,6 +523,7 @@ file_read_contents:
|
|||||||
push r12 ; result
|
push r12 ; result
|
||||||
push r13 ; backing
|
push r13 ; backing
|
||||||
push r14 ; file_size
|
push r14 ; file_size
|
||||||
|
sub rsp, 8
|
||||||
mov r12, result
|
mov r12, result
|
||||||
mov r13, backing
|
mov r13, backing
|
||||||
%define result r12
|
%define result r12
|
||||||
@ -617,6 +617,7 @@ file_read_contents:
|
|||||||
mov qword [result + FileOpInfo.content + Slice_Byte.len], 0
|
mov qword [result + FileOpInfo.content + Slice_Byte.len], 0
|
||||||
|
|
||||||
.cleanup:
|
.cleanup:
|
||||||
|
add rsp, 8
|
||||||
pop r14 ; file_size
|
pop r14 ; file_size
|
||||||
pop backing
|
pop backing
|
||||||
pop result
|
pop result
|
||||||
@ -643,7 +644,7 @@ global main
|
|||||||
%push proc_scope
|
%push proc_scope
|
||||||
main:
|
main:
|
||||||
stack_push GetStdHandle_ctbl_size ; call-frame GetStdHandle {
|
stack_push GetStdHandle_ctbl_size ; call-frame GetStdHandle {
|
||||||
mov rcounter_32, -MS_STD_OUTPUT_HANDLE ; rcounter.32 = -MS_STD_OUTPUT_HANDLE
|
mov rcounter_32, MS_STD_OUTPUT_HANDLE ; rcounter.32 = MS_STD_OUTPUT_HANDLE
|
||||||
call GetStdHandle ; GetStdHandle <- rcounter, stack
|
call GetStdHandle ; GetStdHandle <- rcounter, stack
|
||||||
mov [std_out_hndl], raccumulator ; std_out_hndl = raccumulator
|
mov [std_out_hndl], raccumulator ; std_out_hndl = raccumulator
|
||||||
stack_pop ; }
|
stack_pop ; }
|
||||||
@ -651,9 +652,9 @@ global main
|
|||||||
; dbg_wipe_gprs
|
; dbg_wipe_gprs
|
||||||
%push calling
|
%push calling
|
||||||
call_frame
|
call_frame
|
||||||
%define local_backing rsp + Slice_Byte_size
|
call_frame_alloc Slice_Byte_size ; stack local_backing : Slice_byte
|
||||||
call_frame_alloc Slice_Byte ; stack local_backing : Slice_byte
|
|
||||||
call_frame_commit ; call-frame file_read_contents {
|
call_frame_commit ; call-frame file_read_contents {
|
||||||
|
%define local_backing rsp + Slice_Byte_size
|
||||||
mov qword [local_backing + Slice_Byte.ptr], read_mem ; local_backing.ptr = read_mem.ptr
|
mov qword [local_backing + Slice_Byte.ptr], read_mem ; local_backing.ptr = read_mem.ptr
|
||||||
mov qword [local_backing + Slice_Byte.len], Mem_128k_size ; local_backing.len = Mem_128k_size
|
mov qword [local_backing + Slice_Byte.len], Mem_128k_size ; local_backing.len = Mem_128k_size
|
||||||
lea rcounter, file ; rcounter = file.ptr
|
lea rcounter, file ; rcounter = file.ptr
|
||||||
@ -666,7 +667,7 @@ global main
|
|||||||
|
|
||||||
stack_push WriteConsoleA_ctbl_size ; call-frame WriteConsoleA {
|
stack_push WriteConsoleA_ctbl_size ; call-frame WriteConsoleA {
|
||||||
mov rcounter, [std_out_hndl] ; rcounter = std_out_hndl
|
mov rcounter, [std_out_hndl] ; rcounter = std_out_hndl
|
||||||
lea rdata, [file + FileOpInfo.content + Slice_Byte.ptr] ; rdata = file.content.ptr
|
mov rdata, [file + FileOpInfo.content + Slice_Byte.ptr] ; rdata = file.content.ptr
|
||||||
mov r8_32, [file + FileOpInfo.content + Slice_Byte.len] ; r8 = file.content.len
|
mov r8_32, [file + FileOpInfo.content + Slice_Byte.len] ; r8 = file.content.len
|
||||||
lea r9, [rstack_ptr + WriteConsoleA_ctbl.lpNumberOfCharsWritten] ; r9 = & stack.ptr[WriteFileA.ctbl.lpNumberOfCharsWritten]
|
lea r9, [rstack_ptr + WriteConsoleA_ctbl.lpNumberOfCharsWritten] ; r9 = & stack.ptr[WriteFileA.ctbl.lpNumberOfCharsWritten]
|
||||||
mov qword [rstack_ptr + WriteConsoleA_ctbl.lpReserved], nullptr ; stack.ptr[.ctbl.lpRserved] = nullptr
|
mov qword [rstack_ptr + WriteConsoleA_ctbl.lpReserved], nullptr ; stack.ptr[.ctbl.lpRserved] = nullptr
|
||||||
|
@ -81,46 +81,16 @@ breakpoint:
|
|||||||
}
|
}
|
||||||
breakpoint:
|
breakpoint:
|
||||||
{
|
{
|
||||||
source_location: "hello_files.asm:469:1"
|
source_location: "hello_files.asm:674:1"
|
||||||
hit_count: 0
|
hit_count: 1
|
||||||
}
|
}
|
||||||
breakpoint:
|
breakpoint:
|
||||||
{
|
{
|
||||||
source_location: "hello_files.asm:474:1"
|
source_location: "hello_files.asm:584:1"
|
||||||
hit_count: 0
|
hit_count: 1
|
||||||
}
|
}
|
||||||
breakpoint:
|
breakpoint:
|
||||||
{
|
{
|
||||||
source_location: "hello_files.asm:494:1"
|
source_location: "hello_files.asm:605:1"
|
||||||
hit_count: 0
|
hit_count: 1
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:500:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:504:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:516:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:510:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:443:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
|
||||||
breakpoint:
|
|
||||||
{
|
|
||||||
source_location: "hello_files.asm:455:1"
|
|
||||||
hit_count: 0
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user