progress on hello_files

This commit is contained in:
2025-06-21 14:19:50 -04:00
parent c8f513f386
commit 39b4be9d7a
9 changed files with 297 additions and 117 deletions

View File

@ -11,6 +11,7 @@ DEFAULT REL ; Use RIP-relative addressing by default
%define rcounter_32 ecx %define rcounter_32 ecx
%define rdata_32 edx %define rdata_32 edx
%define r8_32 r8d %define r8_32 r8d
%define r9_32
%define raccumulator rax %define raccumulator rax
%define rbase rbx %define rbase rbx
@ -20,6 +21,10 @@ DEFAULT REL ; Use RIP-relative addressing by default
%define rsrc_id rsi %define rsrc_id rsi
%define rstack_ptr rsp %define rstack_ptr rsp
%define rstack_base_ptr rbp %define rstack_base_ptr rbp
%define false 0
%define true 1
%define true_overflow 2
;endregion DSL ;endregion DSL
;region Registers ;region Registers
@ -53,22 +58,22 @@ DEFAULT REL ; Use RIP-relative addressing by default
; Wipes the 128-bit XMM registers. Requires a CPU with at least SSE. ; Wipes the 128-bit XMM registers. Requires a CPU with at least SSE.
%macro wipe_xmms 0 %macro wipe_xmms 0
vxorps xmm0, xmm0, xmm0 vxorps xmm0, xmm0, xmm0
vxorps xmm1, xmm1, xmm1 vxorps xmm1, xmm1, xmm1
vxorps xmm2, xmm2, xmm2 vxorps xmm2, xmm2, xmm2
vxorps xmm3, xmm3, xmm3 vxorps xmm3, xmm3, xmm3
vxorps xmm4, xmm4, xmm4 vxorps xmm4, xmm4, xmm4
vxorps xmm5, xmm5, xmm5 vxorps xmm5, xmm5, xmm5
vxorps xmm6, xmm6, xmm6 vxorps xmm6, xmm6, xmm6
vxorps xmm7, xmm7, xmm7 vxorps xmm7, xmm7, xmm7
vxorps xmm8, xmm8, xmm8 vxorps xmm8, xmm8, xmm8
vxorps xmm9, xmm9, xmm9 vxorps xmm9, xmm9, xmm9
vxorps xmm10, xmm10, xmm10 vxorps xmm10, xmm10, xmm10
vxorps xmm11, xmm11, xmm11 vxorps xmm11, xmm11, xmm11
vxorps xmm12, xmm12, xmm12 vxorps xmm12, xmm12, xmm12
vxorps xmm13, xmm13, xmm13 vxorps xmm13, xmm13, xmm13
vxorps xmm14, xmm14, xmm14 vxorps xmm14, xmm14, xmm14
vxorps xmm15, xmm15, xmm15 vxorps xmm15, xmm15, xmm15
%endmacro %endmacro
; ============================================================================= ; =============================================================================
@ -78,23 +83,23 @@ DEFAULT REL ; Use RIP-relative addressing by default
; This also wipes the lower 128 bits (the XMM registers), so you don't ; This also wipes the lower 128 bits (the XMM registers), so you don't
; need to call WIPE_XMM_REGS if you call this one. ; need to call WIPE_XMM_REGS if you call this one.
%macro wipe_ymms 0 %macro wipe_ymms 0
vzeroupper ; Clears upper 128 bits of all YMM registers vzeroupper ; Clears upper 128 bits of all YMM registers
vxorps ymm0, ymm0, ymm0 ; Clears the full YMM0 (including lower XMM0) vxorps ymm0, ymm0, ymm0 ; Clears the full YMM0 (including lower XMM0)
vxorps ymm1, ymm1, ymm1 vxorps ymm1, ymm1, ymm1
vxorps ymm2, ymm2, ymm2 vxorps ymm2, ymm2, ymm2
vxorps ymm3, ymm3, ymm3 vxorps ymm3, ymm3, ymm3
vxorps ymm4, ymm4, ymm4 vxorps ymm4, ymm4, ymm4
vxorps ymm5, ymm5, ymm5 vxorps ymm5, ymm5, ymm5
vxorps ymm6, ymm6, ymm6 vxorps ymm6, ymm6, ymm6
vxorps ymm7, ymm7, ymm7 vxorps ymm7, ymm7, ymm7
vxorps ymm8, ymm8, ymm8 vxorps ymm8, ymm8, ymm8
vxorps ymm9, ymm9, ymm9 vxorps ymm9, ymm9, ymm9
vxorps ymm10, ymm10, ymm10 vxorps ymm10, ymm10, ymm10
vxorps ymm11, ymm11, ymm11 vxorps ymm11, ymm11, ymm11
vxorps ymm12, ymm12, ymm12 vxorps ymm12, ymm12, ymm12
vxorps ymm13, ymm13, ymm13 vxorps ymm13, ymm13, ymm13
vxorps ymm14, ymm14, ymm14 vxorps ymm14, ymm14, ymm14
vxorps ymm15, ymm15, ymm15 vxorps ymm15, ymm15, ymm15
%endmacro %endmacro
; ============================================================================= ; =============================================================================
@ -104,49 +109,49 @@ DEFAULT REL ; Use RIP-relative addressing by default
; Requires a CPU with AVX-512F support. This is the most comprehensive ; Requires a CPU with AVX-512F support. This is the most comprehensive
; vector register wipe and makes WIPE_XMM_REGS and WIPE_YMM_REGS redundant. ; vector register wipe and makes WIPE_XMM_REGS and WIPE_YMM_REGS redundant.
%macro wipe_avx512s 0 %macro wipe_avx512s 0
; Wipe Mask Registers (k0-k7) ; Wipe Mask Registers (k0-k7)
kxorb k0, k0, k0 kxorb k0, k0, k0
kxorb k1, k1, k1 kxorb k1, k1, k1
kxorb k2, k2, k2 kxorb k2, k2, k2
kxorb k3, k3, k3 kxorb k3, k3, k3
kxorb k4, k4, k4 kxorb k4, k4, k4
kxorb k5, k5, k5 kxorb k5, k5, k5
kxorb k6, k6, k6 kxorb k6, k6, k6
kxorb k7, k7, k7 kxorb k7, k7, k7
; Wipe ZMM registers (zmm0-zmm31) ; Wipe ZMM registers (zmm0-zmm31)
vpxord zmm0, zmm0, zmm0 vpxord zmm0, zmm0, zmm0
vpxord zmm1, zmm1, zmm1 vpxord zmm1, zmm1, zmm1
vpxord zmm2, zmm2, zmm2 vpxord zmm2, zmm2, zmm2
vpxord zmm3, zmm3, zmm3 vpxord zmm3, zmm3, zmm3
vpxord zmm4, zmm4, zmm4 vpxord zmm4, zmm4, zmm4
vpxord zmm5, zmm5, zmm5 vpxord zmm5, zmm5, zmm5
vpxord zmm6, zmm6, zmm6 vpxord zmm6, zmm6, zmm6
vpxord zmm7, zmm7, zmm7 vpxord zmm7, zmm7, zmm7
vpxord zmm8, zmm8, zmm8 vpxord zmm8, zmm8, zmm8
vpxord zmm9, zmm9, zmm9 vpxord zmm9, zmm9, zmm9
vpxord zmm10, zmm10, zmm10 vpxord zmm10, zmm10, zmm10
vpxord zmm11, zmm11, zmm11 vpxord zmm11, zmm11, zmm11
vpxord zmm12, zmm12, zmm12 vpxord zmm12, zmm12, zmm12
vpxord zmm13, zmm13, zmm13 vpxord zmm13, zmm13, zmm13
vpxord zmm14, zmm14, zmm14 vpxord zmm14, zmm14, zmm14
vpxord zmm15, zmm15, zmm15 vpxord zmm15, zmm15, zmm15
vpxord zmm16, zmm16, zmm16 vpxord zmm16, zmm16, zmm16
vpxord zmm17, zmm17, zmm17 vpxord zmm17, zmm17, zmm17
vpxord zmm18, zmm18, zmm18 vpxord zmm18, zmm18, zmm18
vpxord zmm19, zmm19, zmm19 vpxord zmm19, zmm19, zmm19
vpxord zmm20, zmm20, zmm20 vpxord zmm20, zmm20, zmm20
vpxord zmm21, zmm21, zmm21 vpxord zmm21, zmm21, zmm21
vpxord zmm22, zmm22, zmm22 vpxord zmm22, zmm22, zmm22
vpxord zmm23, zmm23, zmm23 vpxord zmm23, zmm23, zmm23
vpxord zmm24, zmm24, zmm24 vpxord zmm24, zmm24, zmm24
vpxord zmm25, zmm25, zmm25 vpxord zmm25, zmm25, zmm25
vpxord zmm26, zmm26, zmm26 vpxord zmm26, zmm26, zmm26
vpxord zmm27, zmm27, zmm27 vpxord zmm27, zmm27, zmm27
vpxord zmm28, zmm28, zmm28 vpxord zmm28, zmm28, zmm28
vpxord zmm29, zmm29, zmm29 vpxord zmm29, zmm29, zmm29
vpxord zmm30, zmm30, zmm30 vpxord zmm30, zmm30, zmm30
vpxord zmm31, zmm31, zmm31 vpxord zmm31, zmm31, zmm31
%endmacro %endmacro
;endregion Registers ;endregion Registers
@ -154,6 +159,12 @@ DEFAULT REL ; Use RIP-relative addressing by default
%define debug_trap 3 %define debug_trap 3
%ifidn BUILD_DEBUG, 1 %ifidn BUILD_DEBUG, 1
%macro assert_cmp 3
cmp %2, %3
%1 %%.passed
int debug_trap
%%.passed:
%endmacro
%macro assert_not_null 1 %macro assert_not_null 1
cmp %1, nullptr cmp %1, nullptr
jnz %%.passed jnz %%.passed
@ -166,6 +177,9 @@ DEFAULT REL ; Use RIP-relative addressing by default
%define dbg_wipe_ymms wipe_ymms %define dbg_wipe_ymms wipe_ymms
%define dbg_wipe_avx512s wipe_avx512s %define dbg_wipe_avx512s wipe_avx512s
%else %else
%macro assert_cmp 3
%cmp %2, %3
%endmacro
%macro assert_not_null 1 %macro assert_not_null 1
%endmacro %endmacro
%macro slice_assert 1 %macro slice_assert 1
@ -406,8 +420,8 @@ endstruc
; path: Slice_Str8 = { .ptr = rdata, .len = r8 } ; path: Slice_Str8 = { .ptr = rdata, .len = r8 }
; backing: r9 = [Slice_Byte] ; backing: r9 = [Slice_Byte]
%push proc_scope %push proc_scope
%define path_ptr rdata
%define result rcounter %define result rcounter
%define path_ptr rdata
%define path_len r8 %define path_len r8
%define backing r9 %define backing r9
@ -419,16 +433,20 @@ file_read_contents:
push rbx push rbx
push r12 push r12
push r13 push r13
push r14
mov r12, result mov r12, result
mov r13, backing mov r13, backing
%define result r12 %define result r12
%define backing r13 %define backing r13
; rcounter = str8_to_cstr_capped(path, slice_fmem(scratch)); ; rcounter = str8_to_cstr_capped(path, slice_fmem(scratch));
; We're using backing to store the cstr temporarily until ReadFile.
; TODO(Ed): This cannot be done with an allocator interface...
call str8_to_cstr_capped ; (rdata, r8, r9) call str8_to_cstr_capped ; (rdata, r8, r9)
; path_cstr = rcounter; path_len has will be discarded in the CreateFileA call ; path_cstr = rcounter; path_len has will be discarded in the CreateFileA call
%define path_cstr rcounter
wapi_shadow_space wapi_shadow_space
; rcounter = [path_cstr] ; rcounter = path_cstr
mov rdata_32, MS_GENERIC_READ ; dwDesiredAccess = MS_GENERIC_READ mov rdata_32, MS_GENERIC_READ ; dwDesiredAccess = MS_GENERIC_READ
mov r8_32, MS_FILE_SHARE_READ ; dwShareMode = MS_FILE_SHARE_READ mov r8_32, MS_FILE_SHARE_READ ; dwShareMode = MS_FILE_SHARE_READ
xor r9, r9 ; lpSecurityAttributes = nullptr xor r9, r9 ; lpSecurityAttributes = nullptr
@ -440,21 +458,50 @@ file_read_contents:
; B32 open_failed = raccumulator == MS_INVALID_HANDLE_VALUE ; B32 open_failed = raccumulator == MS_INVALID_HANDLE_VALUE
; if (open_failed) goto %%.error_exit ; if (open_failed) goto %%.error_exit
cmp raccumulator, MS_INVALID_HANDLE_VALUE assert_cmp jnz, raccumulator, MS_INVALID_HANDLE_VALUE
je .error_exit je .error_exit
mov rbase, raccumulator ; rbase = id_file mov rbase, raccumulator ; rbase = id_file
%define id_file rbase
wapi_shadow_space wapi_shadow_space
mov rcounter, rbase ; hfile: rcounter = rbase ; rcounter = path_str ; hfile
mov rdata, [backing + Slice_Byte.ptr ] ; lpBuffer: rdata = backing.ptr lea rdata, [result + FileOpInfo.content + Slice_Byte.len]; lpFileSize = result.content.len
mov r8_32, [backing + Slice_Byte.len ] ; nNumberOfBytesRead: r8_32 = backing.len call GetFileSizeEx
mov r9, [result + FileOpInfo.content + Slice_Byte.len] ; lpNumberOfBytesRead: result.content.len = backing.len
mov qword [rstack_ptr + wapi_ReadFile_lpOverlapped], 0 ; B32 not_enough_backing = backing.len < result.content.len
; if (not_enough_backing) goto .error_exit
mov r8, [backing + Slice_Byte.len]
mov r9, [result + FileOpInfo.content + Slice_Byte.len]
assert_cmp jg, r9, r8
jg .error_exit
; MS_BOOL get_size_failed = rax
; if (get_size_failed) goto .error_exit
assert_cmp jnz, raccumulator, false
je .error_exit
%define file_size r14d
mov r14d, r9d
wapi_shadow_space
mov rcounter, id_file ; hfile: rcounter = rbase
mov rdata, [backing + Slice_Byte.ptr ] ; lpBuffer: rdata = backing.ptr
mov r8_32, file_size ; nNumberOfBytesRead: r8_32 = file_size
mov r9, [result + FileOpInfo.content + Slice_Byte.len] ; lpNumberOfBytesToRead: r9 = & result.content.len
mov qword [rstack_ptr + wapi_ReadFile_lpOverlapped], 0 ; lpOverlapped: nullptr
call ReadFile call ReadFile
stack_pop stack_pop
; Close the handle. ; B32 read_failed = ! read_result
; read_failed |= amount_read != result.content.len
; if (read_failed) goto .error_exit
assert_cmp jnz, raccumulator, false
je .error_exit
assert_cmp je, amount_read, r9
je .error_exit
; CloseHandle(id_file)
wapi_shadow_space wapi_shadow_space
mov rcounter, rbase mov rcounter, rbase
call CloseHandle call CloseHandle
@ -464,13 +511,14 @@ file_read_contents:
mov raccumulator, [backing + Slice_Byte.ptr] mov raccumulator, [backing + Slice_Byte.ptr]
mov [result + FileOpInfo.content + Slice_Byte.ptr], raccumulator mov [result + FileOpInfo.content + Slice_Byte.ptr], raccumulator
jmp .cleanup jmp .cleanup
.error_exit: .error_exit:
; result = {} ; result = {}
mov qword [result + FileOpInfo.content + Slice_Byte.ptr], 0 mov qword [result + FileOpInfo.content + Slice_Byte.ptr], 0
mov qword [result + FileOpInfo.content + Slice_Byte.len], 0 mov qword [result + FileOpInfo.content + Slice_Byte.len], 0
.cleanup: .cleanup:
pop file_size
pop result pop result
pop backing pop backing
pop rbase pop rbase

89
code/asm/hello_files.proj Normal file
View File

@ -0,0 +1,89 @@
// raddbg 0.9.18 project file
recent_file: path: "hello_files.asm"
recent_file: path: "../../../code/asm/hello_files.asm"
recent_file: path: "../../../WATL_Exercise/c/watl.v0.msvc.c"
recent_file: path: "asm/hello_files.asm"
recent_file: path: "../hello_files.asm"
recent_file: path: "hello_slices.asm"
recent_file: path: "hello_nasm.asm"
recent_file: path: "../asm"
recent_file: path: "../../../../dev/raddbg/minkernel/crts/ucrt/src/appcrt/startup/abort.cpp"
recent_file: path: "../../../vefontcache-odin/backend/sokol/backend_sokol.odin"
recent_file: path: "../../../vefontcache-odin/examples/sokol_demo/sokol_demo.odin"
recent_file: path: "../../../vefontcache-odin/thirdparty/sokol/c/sokol_gfx.h"
recent_file: path: "../../../vefontcache-odin/thirdparty/sokol/c/sokol_log.h"
recent_file: path: "../../../vefontcache-odin/thirdparty/sokol/c/sokol_app.h"
recent_file: path: "D:/a/_work/1/s/src/vctools/crt/vcruntime/src/string/amd64/memcpy.asm"
recent_file: path: "D:/a/_work/1/s/src/vctools/crt/vcruntime/src/string/amd64/memset.asm"
breakpoint:
{
source_location: "../../../vefontcache-odin/backend/sokol/backend_sokol.odin:66:1"
hit_count: 0
}
target:
{
executable: "../../../WATL_Exercise/build/watl.v0.msvc.exe"
working_directory: "../../../WATL_Exercise/C"
}
type_view:
{
type: Slice_A2_Str8
expr: "$.slice()"
}
type_view:
{
type: Slice_UTF8
expr: "array($.ptr, $.len)"
}
type_view:
{
type: Slice_WATL_Node
expr: "array($.ptr, $.len)"
}
type_view:
{
type: Slice_WATL_Tok
expr: "slice($)"
}
type_view:
{
type: Slice_KT1CX_Cell_Str8
expr: "slice($)"
}
type_view:
{
type: Slice_KT1L_Slot_Str8
expr: "slice($)"
}
target:
{
executable: "../../build/hello_nasm.exe"
working_directory: "../../build"
}
target:
{
executable: "../../build/hello_slices.exe"
working_directory: "../../build"
}
target:
{
executable: "../../build/hello_files.exe"
working_directory: ../../
enabled: 1
}
breakpoint:
{
source_location: "hello_slices.asm:60:1"
hit_count: 0
}
breakpoint:
{
source_location: "hello_files.asm:429:1"
hit_count: 1
}
breakpoint:
{
source_location: "hello_files.asm:467:1"
hit_count: 0
}

View File

@ -5,19 +5,27 @@ $path_build = join-path $path_root 'build'
$path_code = join-path $path_root 'code' $path_code = join-path $path_root 'code'
$path_asm = join-path $path_code 'asm' $path_asm = join-path $path_code 'asm'
$path_toolchain = join-path $path_root 'toolchain' $path_toolchain = join-path $path_root 'toolchain'
$path_radlink = join-path $path_toolchain 'radlink' $path_rad = join-path $path_toolchain 'rad'
if ((test-path $path_build) -eq $false) { if ((test-path $path_build) -eq $false) {
new-item -itemtype directory -path $path_build new-item -itemtype directory -path $path_build
} }
$hello_nasm = join-path $path_asm 'hello_files.asm' $unit_name = 'hello_files'
$listing = join-path $path_build 'hello_files.list'
$link_obj = join-path $path_build 'hello_files.o' $unit = join-path $path_asm "$unit_name.asm"
$exe = join-path $path_build 'hello_files.exe' $listing = join-path $path_build "$unit_name.asm.list"
$link_obj = join-path $path_build "$unit_name.o"
$map = join-path $path_build "$unit_name.map"
$pdb = join-path $path_build "$unit_name.pdb"
$rdi = join-path $path_build "$unit_name.rdi"
$rdi_listing = join-path $path_build "$unit_name.rdi.list"
$exe = join-path $path_build "$unit_name.exe"
$nasm = 'nasm' $nasm = 'nasm'
$radlink = join-path $path_radlink 'radlink.exe' $link = 'link.exe'
$radbin = join-path $path_rad 'radbin.exe'
$radlink = join-path $path_rad 'radlink.exe'
push-location $path_root push-location $path_root
$f_assemble_only = '-a' $f_assemble_only = '-a'
@ -36,37 +44,42 @@ $f_optimize_multi_disp = '-Ov'
$f_outfile = '-o ' $f_outfile = '-o '
$f_warnings_as_errors = '-Werror' $f_warnings_as_errors = '-Werror'
$args = @( $args = @(
$hello_nasm, $unit,
$f_optimize_none, $f_optimize_none,
# $f_preprocess_only,
# ($f_dmacro + "BUILD_DEBUG 1"),
$f_bin_fmt_win64, $f_bin_fmt_win64,
$f_debug_fmt_win64, $f_debug_fmt_win64,
($f_listing + $listing), ($f_listing + $listing),
($f_outfile + $link_obj) ($f_outfile + $link_obj)
) )
write-host 'Assembling'
& $nasm $args & $nasm $args
$lib_kernel32 = 'kernel32.lib' $lib_kernel32 = 'kernel32.lib'
$lib_msvcrt = 'msvcrt.lib' $lib_msvcrt = 'msvcrt.lib'
$link = 'link.exe' $link_nologo = '/NOLOGO'
$link_debug = '/DEBUG:' $link_debug = '/DEBUG:'
$link_entrypoint = '/ENTRY:' $link_entrypoint = '/ENTRY:'
$link_library = '/' $link_mapfile = '/MAP:'
$link_no_incremental = '/INCREMENTAL:NO'
$link_large_address_aware = '/LARGEADDRESSAWARE:NO' $link_large_address_aware = '/LARGEADDRESSAWARE:NO'
$link_listing = '/LIST'
$link_outfile = '/OUT:' $link_outfile = '/OUT:'
$link_win_machine_64 = '/MACHINE:X64' $link_win_machine_64 = '/MACHINE:X64'
$link_win_pdb = '/PDB:'
$link_win_subsystem_console = '/SUBSYSTEM:CONSOLE' $link_win_subsystem_console = '/SUBSYSTEM:CONSOLE'
$link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS' $link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS'
$rad_debug = '/RAD_DEBUG' $rad_debug = '/RAD_DEBUG'
$rad_debug_name = '/RAD_DEBUG_NAME:' $rad_debug_name = '/RAD_DEBUG_NAME:'
$rad_large_pages = '/RAD_LARGE_PAGES:' $rad_large_pages = '/RAD_LARGE_PAGES:'
$args = @( $args = @(
$link_debug,
# $rad_debug, # $rad_debug,
# ($link_debug + 'FULL'), $link_nologo,
($link_debug + 'FULL'),
($link_mapfile + $map),
($link_win_pdb + $pdb),
# $link_listing,
$link_no_incremental,
$link_large_address_aware, $link_large_address_aware,
$link_win_machine_64, $link_win_machine_64,
$link_win_subsystem_console, $link_win_subsystem_console,
@ -76,5 +89,17 @@ $args = @(
($link_outfile + $exe), ($link_outfile + $exe),
$link_obj $link_obj
) )
& $radlink $args write-host 'Linking'
& $link $args
pop-location pop-location
$rbin_out = '--out:'
$rbin_dump = '--dump'
write-host 'Dumping RDI'
$args = @($pdb, ($rbin_out + $rdi))
& $radbin $args
$args = @($rbin_dump, $rdi)
$dump = & $radbin $args
$dump > $rdi_listing

View File

@ -5,19 +5,26 @@ $path_build = join-path $path_root 'build'
$path_code = join-path $path_root 'code' $path_code = join-path $path_root 'code'
$path_asm = join-path $path_code 'asm' $path_asm = join-path $path_code 'asm'
$path_toolchain = join-path $path_root 'toolchain' $path_toolchain = join-path $path_root 'toolchain'
$path_radlink = join-path $path_toolchain 'radlink' $path_rad = join-path $path_toolchain 'rad'
if ((test-path $path_build) -eq $false) { if ((test-path $path_build) -eq $false) {
new-item -itemtype directory -path $path_build new-item -itemtype directory -path $path_build
} }
$hello_nasm = join-path $path_asm 'hello_nasm.asm' $unit_name = 'hello_nasm'
$listing = join-path $path_build 'hello_nasm.list'
$link_obj = join-path $path_build 'hello_nasm.o' $unit = join-path $path_asm "$unit_name.asm"
$exe = join-path $path_build 'hello_nasm.exe' $listing = join-path $path_build "$unit_name.list"
$link_obj = join-path $path_build "$unit_name.o"
$map = join-path $path_build "$unit_name.map"
$pdb = join-path $path_build "$unit_name.pdb"
$rdi = join-path $path_build "$unit_name.rdi"
$exe = join-path $path_build "$unit_name.exe"
$nasm = 'nasm' $nasm = 'nasm'
$radlink = join-path $path_radlink 'radlink.exe' $link = 'link.exe'
$radbin = join-path $path_rad 'radbin.exe'
$radlink = join-path $path_rad 'radlink.exe'
push-location $path_root push-location $path_root
$f_assemble_only = '-a' $f_assemble_only = '-a'
@ -36,22 +43,23 @@ $f_optimize_multi_disp = '-Ov'
$f_outfile = '-o ' $f_outfile = '-o '
$f_warnings_as_errors = '-Werror' $f_warnings_as_errors = '-Werror'
$args = @( $args = @(
$hello_nasm, $unit,
$f_optimize_none, $f_optimize_none,
$f_bin_fmt_win64, $f_bin_fmt_win64,
$f_debug_fmt_win64, $f_debug_fmt_win64,
($f_listing + $listing), ($f_listing + $listing),
($f_outfile + $link_obj) ($f_outfile + $link_obj)
) )
write-host 'Assembling'
& $nasm $args & $nasm $args
$lib_kernel32 = 'kernel32.lib' $lib_kernel32 = 'kernel32.lib'
$lib_msvcrt = 'msvcrt.lib' $lib_msvcrt = 'msvcrt.lib'
$link = 'link.exe' $link_nologo = '/NOLOGO'
$link_debug = '/DEBUG:' $link_debug = '/DEBUG:'
$link_entrypoint = '/ENTRY:' $link_entrypoint = '/ENTRY:'
$link_mapfile = '/MAP:'
$link_library = '/' $link_library = '/'
$link_outfile = '/OUT:' $link_outfile = '/OUT:'
$link_win_machine_64 = '/MACHINE:X64' $link_win_machine_64 = '/MACHINE:X64'
@ -61,8 +69,10 @@ $rad_debug = '/RAD_DEBUG'
$rad_debug_name = '/RAD_DEBUG_NAME:' $rad_debug_name = '/RAD_DEBUG_NAME:'
$rad_large_pages = '/RAD_LARGE_PAGES:' $rad_large_pages = '/RAD_LARGE_PAGES:'
$args = @( $args = @(
$rad_debug, # $rad_debug,
# ($link_debug + 'FULL'), $link_nologo,
($link_debug + 'FULL'),
($link_mapfile + $map)
$link_win_machine_64, $link_win_machine_64,
$link_win_subsystem_console, $link_win_subsystem_console,
$lib_kernel32, $lib_kernel32,
@ -71,5 +81,11 @@ $args = @(
($link_outfile + $exe), ($link_outfile + $exe),
$link_obj $link_obj
) )
& $radlink $args write-host 'Linking'
& $link $args
pop-location pop-location
$rbin_out = '--out:'
$rbin_dump = '--dump '
# $radbin

View File

@ -1 +0,0 @@
$nams

View File

@ -7,9 +7,12 @@ $path_scripts = join-path $path_root 'scripts'
$path_source = join-path $path_root 'source' $path_source = join-path $path_root 'source'
$path_toolchain = join-path $path_root 'toolchain' $path_toolchain = join-path $path_root 'toolchain'
$url_yasm = 'https://github.com/yasm/yasm.git' # Note: No longer using nasm
if ($false) {
$url_yasm = 'https://github.com/yasm/yasm.git'
$path_yasm = join-path $path_toolchain 'yasm' $path_yasm = join-path $path_toolchain 'yasm'
$path_libyasm = join-path $path_yasm 'libyasm' $path_libyasm = join-path $path_yasm 'libyasm'
clone-gitrepo $path_yasm $url_yasm clone-gitrepo $path_yasm $url_yasm
}

BIN
toolchain/rad/radbin.exe Normal file

Binary file not shown.