Skip to content

Commit 8a6c8b8

Browse files
committed
v1.0.0.1 update
- removed reliance on include files - removed unused equates - added support for assembling UASM64 for Linux x64 (experimental) - added Array functions (untested) - added more CPU functions - added String functions (Ansi and Unicode) - added Text functions (Ansi and Unicode) - added File functions (Ansi and Unicode) - added Memory functions - updated mapping of older MASM32 library function names to UASM64 function names - added CPU constants for CPU_Features and other functions - updated api text files for RadASM and WinASM IDEs - updated source code documentation to allow for auto-gen of sphinx .rst files for readthedocs. - updated rst index files to include a table of functions for each category - added BuildForWindows.bat and BuildForLinux.bat
1 parent 1bb3b56 commit 8a6c8b8

331 files changed

Lines changed: 19591 additions & 1516 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* text eol=crlf
22
*.exe binary
3+
*.a binary
34
*.dll binary
45
*.zip binary
56
*.obj binary
@@ -16,8 +17,10 @@
1617
*.bat linguist-language=Text
1718
*.tpl linguist-language=Text
1819
*.rap linguist-language=Text
20+
*.bat linguist-language=Text
1921
*.asm linguist-language=Assembly
2022
*.inc linguist-language=Assembly
23+
*.rc linguist-language=Text
2124
*.hsl linguist-language=Text
2225
makefile linguist-language=Text
2326
conf.py linguist-language=Python

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
docs/build*/
22
*.chm
33
package_releases.bat
4+
gendocs.bat
45
*.old
56
*.obj
67
*.used

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ python:
1515
build:
1616
os: ubuntu-22.04
1717
tools:
18-
python: "3.12"
18+
python: "3.10"
1919

2020
sphinx:
2121
builder: html

Arg_GetArgument.asm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
.x64
1212

1313
option casemap : none
14+
IF @Platform EQ 1
1415
option win64 : 11
15-
option frame : auto
16-
option stackbase : rsp
16+
ENDIF
1717

18-
_WIN64 EQU 1
19-
WINVER equ 0501h
18+
option frame : auto
2019
2120
include UASM64.inc
2221

@@ -96,6 +95,10 @@ UASM64_ALIGN
9695
; the parser in this algorithm return an empty destination buffer that has an
9796
; ascii zero as it first character.
9897
;
98+
; See Also:
99+
;
100+
; Arg_GetCommandLine, Arg_GetCommandLineEx
101+
;
99102
;------------------------------------------------------------------------------
100103
Arg_GetArgument PROC FRAME USES RBX RCX RDX RDI RSI lpszArgumentList:QWORD,lpszDestination:QWORD,nArgument:QWORD,qwArgumentListReadOffset:QWORD
101104

Arg_GetCommandLine.asm

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
.x64
1212

1313
option casemap : none
14+
IF @Platform EQ 1
1415
option win64 : 11
16+
ENDIF
1517
option frame : auto
16-
option stackbase : rsp
1718

18-
_WIN64 EQU 1
19-
WINVER equ 0501h
20-
21-
include windows.inc
22-
includelib kernel32.lib
19+
IF @Platform EQ 1 ; Win x64
20+
GetCommandLineA PROTO
21+
includelib kernel32.lib
22+
ENDIF
23+
IF @Platform EQ 3 ; Linux x64
24+
; https://baturin.org/blog/hello-from-a-compiler-free-x86-64-world/
25+
; https://gist.github.com/Gydo194/730c1775f1e05fdca6e9b0c175636f5b
26+
ENDIF
2327

2428
include UASM64.inc
2529

@@ -58,9 +62,12 @@ UASM64_ALIGN
5862
; The buffer for the returned argument should be set at 128 bytes in length
5963
; which is the maximum allowable
6064
;
65+
; See Also:
66+
;
67+
; Arg_GetCommandLineEx, Arg_GetArgument
68+
;
6169
;------------------------------------------------------------------------------
6270
Arg_GetCommandLine PROC FRAME USES RCX RDI RSI nArgument:QWORD, lpszArgumentBuffer:QWORD
63-
6471
; -------------------------------------------------
6572
; arguments returned in "lpszArgumentBuffer"
6673
;
@@ -80,7 +87,15 @@ Arg_GetCommandLine PROC FRAME USES RCX RDI RSI nArgument:QWORD, lpszArgumentBuff
8087
LOCAL cmdBuffer[192] :BYTE
8188
LOCAL tmpBuffer[192] :BYTE
8289

83-
Invoke GetCommandLine
90+
IF @Platform EQ 3 ; Linux x64
91+
mov rax, 0 ; maybe we can get command line later with
92+
; ; https://baturin.org/blog/hello-from-a-compiler-free-x86-64-world/
93+
ret
94+
ENDIF
95+
96+
IF @Platform EQ 1 ; Win x64
97+
Invoke GetCommandLineA
98+
ENDIF
8499
mov lpCmdLine, rax ; address command line
85100

86101
; -------------------------------------------------

Arg_GetCommandLineEx.asm

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@
1111
.x64
1212

1313
option casemap : none
14+
IF @Platform EQ 1
1415
option win64 : 11
16+
ENDIF
1517
option frame : auto
16-
option stackbase : rsp
1718

18-
_WIN64 EQU 1
19-
WINVER equ 0501h
20-
21-
include windows.inc
22-
includelib kernel32.lib
23-
24-
;EXTERNDEF ArgByNumber :PROTO ,,,:QWORD
19+
IF @Platform EQ 1 ; Win x64
20+
GetCommandLineA PROTO
21+
includelib kernel32.lib
22+
ENDIF
23+
IF @Platform EQ 3 ; Linux x64
24+
; https://baturin.org/blog/hello-from-a-compiler-free-x86-64-world/
25+
; https://gist.github.com/Gydo194/730c1775f1e05fdca6e9b0c175636f5b
26+
ENDIF
2527

2628
include UASM64.inc
2729

2830
.CODE
2931

32+
IF @Platform EQ 1 ; Win x64
3033
UASM64_ALIGN
3134
;------------------------------------------------------------------------------
3235
; Arg_GetCommandLineEx
@@ -53,16 +56,23 @@ UASM64_ALIGN
5356
; 2 = no argument exists at specified arg number
5457
; 3 = non matching quotation marks
5558
;
59+
; See Also:
60+
;
61+
; Arg_GetCommandLine, Arg_GetArgument
62+
;
5663
;------------------------------------------------------------------------------
57-
Arg_GetCommandLineEx PROC FRAME nArgument:QWORD, lpszArgumentBuffer:QWORD
64+
Arg_GetCommandLineEx PROC FRAME USES RCX nArgument:QWORD, lpszArgumentBuffer:QWORD
65+
LOCAL lpszArgsList:QWORD
5866

5967
; 1 = successful operation
6068
; 2 = no argument exists at specified arg number
6169
; 3 = non matching quotation marks
6270

6371
add nArgument, 1
64-
Invoke GetCommandLine
65-
Invoke Arg_GetArgument, rax, lpszArgumentBuffer, nArgument, 0
72+
73+
Invoke GetCommandLineA
74+
mov lpszArgsList, rax
75+
Invoke Arg_GetArgument, lpszArgsList, lpszArgumentBuffer, nArgument, 0
6676

6777
.if rax >= 0
6878
mov rcx, lpszArgumentBuffer
@@ -78,7 +88,46 @@ Arg_GetCommandLineEx PROC FRAME nArgument:QWORD, lpszArgumentBuffer:QWORD
7888
ret
7989

8090
Arg_GetCommandLineEx ENDP
91+
ENDIF
8192

93+
IF @Platform EQ 3 ; Linux x64
94+
UASM64_ALIGN
95+
;------------------------------------------------------------------------------
96+
; Arg_GetCommandLineEx
97+
;
98+
; Extended version of Arg_GetCommandLine. This Arg_GetCommandLineEx function
99+
; uses the Arg_GetArgument function to obtain the selected argument from a
100+
; command line. It differs from the original version in that it will read a
101+
; command line of any length and the arguments can be delimited by spaces, tabs,
102+
; commas or any combination of the three.
103+
104+
; It is also faster but as the Arg_GetArgument function is table driven, it is
105+
; also larger.
106+
;
107+
; Parameters:
108+
;
109+
; * nArgument - The argument number to return from a command line.
110+
;
111+
; * lpszArgumentBuffer - The buffer to receive the selected argument.
112+
;
113+
; Returns:
114+
;
115+
; There are three (3) possible return values:
116+
; 1 = successful operation
117+
; 2 = no argument exists at specified arg number
118+
; 3 = non matching quotation marks
119+
;
120+
; See Also:
121+
;
122+
; Arg_GetCommandLine, Arg_GetArgument
123+
;
124+
;------------------------------------------------------------------------------
125+
Arg_GetCommandLineEx PROC FRAME nArgument:QWORD, lpszArgumentBuffer:QWORD
126+
mov rax, 0 ; maybe we can get command line later with
127+
; ; https://baturin.org/blog/hello-from-a-compiler-free-x86-64-world/
128+
ret
129+
Arg_GetCommandLineEx ENDP
130+
ENDIF
82131

83132
END
84133

Array_Create.asm

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
;==============================================================================
2+
;
3+
; UASM64 Library
4+
;
5+
; https://github.com/mrfearless/UASM64-Library
6+
;
7+
;==============================================================================
8+
.686
9+
.MMX
10+
.XMM
11+
.x64
12+
13+
option casemap : none
14+
IF @Platform EQ 1
15+
option win64 : 11
16+
ENDIF
17+
option frame : auto
18+
19+
;GlobalAlloc PROTO uFlags:DWORD, qwBytes:QWORD
20+
21+
;IFNDEF GMEM_FIXED
22+
;GMEM_FIXED EQU 0000h
23+
;ENDIF
24+
25+
;includelib kernel32.lib
26+
27+
include UASM64.inc
28+
29+
PUBLIC d_e_f_a_u_l_t__n_u_l_l_$
30+
31+
.DATA
32+
d_e_f_a_u_l_t__n_u_l_l_$ DQ 0 ; default null string as placeholder
33+
DQ 0,0,0
34+
35+
.CODE
36+
37+
UASM64_ALIGN
38+
;------------------------------------------------------------------------------
39+
; Array_Create
40+
;
41+
; Create a new array with a specified number of empty items.
42+
;
43+
; Parameters:
44+
;
45+
; * nItemCount - Number of items that the array created will hold.
46+
;
47+
; Returns:
48+
;
49+
; A pointer to the newly created array, which is used with the other array
50+
; functions, or 0 if an error occurred.
51+
;
52+
; Notes:
53+
;
54+
; This function as based on the MASM32 Library function: arralloc
55+
;
56+
; See Also:
57+
;
58+
; Array_CreateEx, Array_Destroy, Array_Resize
59+
;
60+
;------------------------------------------------------------------------------
61+
Array_Create PROC FRAME USES RCX RDX RSI nItemCount:QWORD
62+
63+
mov rax, nItemCount ; load the member count into EAX
64+
add rax, 1 ; correct for 1 based array
65+
lea rax, [0+rax*8] ; multiply it by 4 for memory size
66+
67+
Invoke Memory_Alloc, rax
68+
;Invoke GlobalAlloc, GMEM_FIXED, rax
69+
mov rsi, rax
70+
71+
test rax, rax ; if allocation failure return zero
72+
jz quit
73+
74+
mov rax, rsi
75+
mov rcx, nItemCount
76+
mov QWORD PTR [rax], rcx ; write count to 1st member
77+
78+
xor rdx, rdx
79+
@@:
80+
add rdx, 1 ; write adress of null string to all members
81+
lea rax, d_e_f_a_u_l_t__n_u_l_l_$
82+
mov [rax+rdx*8], rax ; OFFSET d_e_f_a_u_l_t__n_u_l_l_$
83+
cmp rdx, rcx
84+
jle @B
85+
86+
mov rax, rsi ; return pointer array handle
87+
88+
quit:
89+
90+
ret
91+
Array_Create ENDP
92+
93+
94+
END
95+

0 commit comments

Comments
 (0)