Skip to content

Commit

Permalink
2.36.13
Browse files Browse the repository at this point in the history
  • Loading branch information
nidud committed Dec 23, 2024
1 parent 058c3bf commit eee78ef
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 183 deletions.
Binary file modified bin/asmc.exe
Binary file not shown.
Binary file modified bin/asmc64.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions source/asmc/inc/asmc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@ define PE_SUBSYSTEM_CUI 0x03
define PE_SUBSYSTEM_MASK 0x03
define PE_DLL 0x04

.enum static_link {
LINK_MT = 0x01, ; -MT used, -c not used --> use LIBC
LINK_MAIN = 0x02, ; [w]main proc defined
LINK_FLTUSED = 0x04, ; float used as :vararg param
LINK_ARGV = 0x08, ; [w]main has params
}

.template global_options
quiet db ? ; -q option
line_numbers db ? ; -Zd option
Expand Down Expand Up @@ -593,6 +600,7 @@ define PE_DLL 0x04
dotnamex db ? ; -dotnamex : option dotnamex:<on:off>
sysvregs db ? ; -sysvregs : skip RDI and RSI in USES
no_linking db ? ; -c ; assembles only
link_mt db ? ; -MT = 1, float used |= 2, argv used |= 4
.ends

.template module_vars
Expand Down
2 changes: 1 addition & 1 deletion source/asmc/inc/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ define ASMC_VERSION 236

define ASMC_MAJOR_VER 2
define ASMC_MINOR_VER 36
define ASMC_SUBMINOR_VER 12
define ASMC_SUBMINOR_VER 13

endif
33 changes: 27 additions & 6 deletions source/asmc/src/asmc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,24 @@ endif
ifdef __UNIX__
; gcc [-m32 -static] [-nostdlib] -s -o <name> *.o [-l:[x86/]libasmc.a]

.if ( Options.fctype != FCT_ELF64 )
.if ( Options.link_mt & LINK_MT || Options.pic == 0 || Options.fctype != FCT_ELF64 )
inc ebx
.endif
.if ( ebx )

CollectLinkOption("-m32")
CollectLinkOption("-static")
CollectLinkOption("-nostdlib")
CollectLinkObject("-l:x86/libasmc.a")
.elseif ( Options.pic == 0 )
CollectLinkOption("-nostdlib")
CollectLinkObject("-l:libasmc.a")
.if ( Options.link_mt & LINK_MT )
.if !( Options.link_mt & LINK_FLTUSED )
CollectLinkOption("-u _nofloat")
.endif
.endif
.if ( Options.fctype == FCT_ELF64 )
CollectLinkObject("-l:libasmc.a")
.else
CollectLinkOption("-m32")
CollectLinkObject("-l:x86/libasmc.a")
.endif
.else
CollectLinkOption("-Wl,-z,noexecstack")
.endif
Expand All @@ -605,6 +614,18 @@ ifdef __UNIX__
CollectLinkOption(&buffer[32])
else

.if ( Options.link_mt & LINK_MT )

.if !( Options.link_mt & LINK_FLTUSED )

CollectLinkOption("/INCLUDE:_nofloat")
.endif
.if ( Options.link_mt & LINK_MAIN && !( Options.link_mt & LINK_ARGV ) )

CollectLinkOption("/INCLUDE:_noargv")
.endif
.endif

; Masm use a (Unicode) response file here (mllink$.lnk)
; /OUT:name.exe *.obj
;
Expand Down
9 changes: 7 additions & 2 deletions source/asmc/src/cmdline.asm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ Options global_options {
0, ; .dotname
0, ; .dotnamex
0, ; .sysvregs
0 } ; .no_linking
0, ; .no_linking
0 } ; .link_mt

align size_t

Expand Down Expand Up @@ -571,6 +572,7 @@ endif
.return
.case 'c' ; -c
mov Options.no_linking,1
mov Options.link_mt,0
.return
.case 'ffoc' ; -coff
mov Options.output_format,OFORMAT_COFF
Expand Down Expand Up @@ -756,7 +758,10 @@ endif
define_name( "_DEBUG", "1" )
.case 'TM' ; -MT
define_name( "_MT", "1" )
.return
.if ( Options.no_linking == 0 )
or Options.link_mt,LINK_MT
.endif
.return
.case 'dDM' ; -MDd
define_name( "_DEBUG", "1" )
.case 'ilon' ; -nolib
Expand Down
59 changes: 47 additions & 12 deletions source/asmc/src/invoke.asm
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ fast_param proc __ccall private uses rsi rdi rbx pp:dsym_t, index:int_t, param:d

.if ( isfloat )

.if ( isvararg )
or Options.link_mt,LINK_FLTUSED
.endif

; 64 bit value <= USE32

.if ( eax <= 8 )
Expand Down Expand Up @@ -1235,10 +1239,14 @@ handle_address:

.if ( isfloat )

.if ( isvararg )
or Options.link_mt,LINK_FLTUSED
.endif

mov dl,memtype
mov ecx,dst_size

.if ( [rsi].sflags & S_ISVARARG && dl != MT_REAL4 && dl != MT_REAL8 )
.if ( isvararg && dl != MT_REAL4 && dl != MT_REAL8 )

mov dl,MT_REAL4
.if ( src_rsize == 16 || [rdi].kind == EXPR_FLOAT )
Expand Down Expand Up @@ -1296,7 +1304,7 @@ handle_address:

.if ( stack )

.if ( ecx == T_MOVSS && wordsize == 8 && [rsi].sflags & S_ISVARARG )
.if ( ecx == T_MOVSS && wordsize == 8 && isvararg )

mov ecx,T_CVTSS2SD
AddLineQueueX( " %r %r, %r", ecx, src_reg, src_reg )
Expand All @@ -1306,7 +1314,7 @@ handle_address:
.return
.endif

.if ( wordsize == 8 && [rsi].sflags & S_ISVARARG )
.if ( wordsize == 8 && isvararg )
.if ( ecx == T_MOVSS )
mov ecx,T_CVTSS2SD
.elseif ( ecx == T_MOVSD )
Expand Down Expand Up @@ -1334,7 +1342,7 @@ handle_address:

; v2.34.71 - the default size in 64-bit is double..

.if ( wordsize == 8 && [rsi].sflags & S_ISVARARG && dst_size == 4 )
.if ( wordsize == 8 && isvararg && dst_size == 4 )
mov dst_size,8
.endif
atofloat( rdi, rdx, dst_size, eax, 0 )
Expand Down Expand Up @@ -1390,7 +1398,7 @@ handle_address:
mov ecx,T_MOV
mov reg,T_EAX

.if ( [rsi].sflags & S_ISVARARG )
.if ( isvararg )

; v2.34.71 - convert float to double in 64-bit

Expand Down Expand Up @@ -1422,7 +1430,7 @@ handle_address:
.endif

mov ecx,T_MOVSS
.if ( [rsi].sflags & S_ISVARARG && wordsize == 8 )
.if ( isvararg && wordsize == 8 )
mov ecx,T_CVTSS2SD
.if ( [rdi].kind == EXPR_FLOAT )
mov ecx,T_MOVSD
Expand Down Expand Up @@ -1537,7 +1545,7 @@ endif
; - this fails for NULL pointers as the upper value is not cleared
; - the default size is 4
;
.if ( [rdi].value || !( [rsi].sflags & S_ISVARARG ) )
.if ( [rdi].value || !isvararg )

mov ecx,T_DWORD
.endif
Expand Down Expand Up @@ -2419,9 +2427,10 @@ endif

.if ( [rdi].asym.sflags & S_ISVARARG )

mov eax,pushsize

.if ( asize > eax )
.if ( opnd.mem_type & MT_FLOAT )
or Options.link_mt,LINK_FLTUSED
.endif
.if ( asize > pushsize )

mov eax,asize
.endif
Expand Down Expand Up @@ -2745,9 +2754,23 @@ endif
.new optype:dword = GetValueSp(eax)

; v2.11
.if ( [rdi].asym.sflags & S_ISVARARG && psize < pushsize )

mov psize,pushsize
.if ( [rdi].asym.sflags & S_ISVARARG )

.if ( psize < pushsize )

mov psize,eax
.endif
if 0
.if ( eax >= 4 )

; v2.36.13 - if float param used
;
; this "could" be a float, and then it "should" be converted to a double
;
or Options.link_mt,LINK_FLTUSED
.endif
endif
.endif

; v2.06: check if register is valid to be pushed.
Expand Down Expand Up @@ -3047,7 +3070,19 @@ endif
mov edx,opnd.hvalue

.if ( opnd.kind == EXPR_FLOAT )

mov ecx,4
.if ( [rdi].asym.sflags & S_ISVARARG && pushsize >= ecx )

or Options.link_mt,LINK_FLTUSED
.if ( psize == 16 )

__cvtq_sd(&opnd, &opnd)
mov ecx,8
mov psize,ecx
.endif
.endif

.elseif ( ( !edx && eax <= 255 ) || ( edx == -1 && sdword ptr eax >= -255 ) )
mov ecx,1
.elseif ( ( !edx && eax <= 65535 ) || ( edx == -1 && sdword ptr eax >= -65535 ) )
Expand Down
19 changes: 19 additions & 0 deletions source/asmc/src/proc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,25 @@ EndpDir proc __ccall uses rbx i:int_t, tokenarray:ptr asm_tok
.if ( rcx )

mov edx,[rcx].asym.name_size

; v2.36.13 -MT - static link option: "main defined" and "argv used"

.if ( Options.link_mt & LINK_MT && ( edx == 4 || edx == 5 ) )

mov rdx,[rcx].asym.name
mov eax,[rdx]
.if ( eax == 'niam' || ( eax == 'iamw' && byte ptr [rdx+4] == 'n' ) )

or Options.link_mt,LINK_MAIN
mov rax,[rcx].dsym.procinfo
mov rax,[rax].proc_info.paralist
.if ( rax )
or Options.link_mt,LINK_ARGV
.endif
.endif
mov edx,[rcx].asym.name_size
.endif

inc edx
.if ( SymCmpFunc( [rcx].asym.name, [rbx].string_ptr, edx ) == 0 )
ProcFini( CurrProc )
Expand Down
2 changes: 1 addition & 1 deletion source/libc/crt/_targvcrt.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; _NOARGV.ASM--
; _TARGVCRT.ASM--
;
; Copyright (c) The Asmc Contributors. All rights reserved.
; Consult your license regarding permissions and restrictions.
Expand Down
5 changes: 3 additions & 2 deletions source/libc/crt/_unoargv.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
include stdlib.inc
include tchar.inc

public _noargv
externdef c noargv:int_t

.data
_noargv label int_t
noargv label int_t
_argvusedA label int_t
_argvusedW int_t 0
end
Loading

0 comments on commit eee78ef

Please sign in to comment.