@@ -16,128 +16,149 @@ Also:
1616
1717
1818
19- ## clr
20- Clears the specified register by setting it to zero.
19+ ## Auxiliary Macros
20+
21+ ### clr
22+ Clears the specified registers by setting them to zero.
2123
2224``` asm
23- clr reg
25+ clr reg1, reg2
2426```
2527
2628
2729** Arguments:** </br >
28- ` reg ` — the name of the register to be cleared (e.g., ` eax ` , ` rax ` , etc.)
30+ ` regN ` — actual registers to be cleared (set to zero), depending on the target architecture.
2931
3032
3133** Usage example:**
3234
3335``` asm
34- clr eax ; sets eax to 0
35- clr rax ; sets rax to 0
36- clr r0 ; sets r0 to 0
37- clr x0 ; sets x0 to 0
36+ clr eax, ebx ; sets eax and ebx to 0
37+ clr rax, rdi ; sets rax and rdi to 0
38+ clr r7, r0 ; sets r7 and r0 to 0
39+ clr x8, x0 ; sets x8 and x0 to 0
3840```
3941
4042
4143
42- ## exit
43- Terminates the program with a specified exit code.
44+ ### push / pop
45+ Pushes or pops multiple registers on/from the stack (equivalent to multiple ` push ` /` pop ` instructions).</br >
46+ Register order in ` pop ` must match the reverse of ` push ` .
4447
4548``` asm
46- exit code
49+ push reg1, reg2, reg3
50+ ...
51+ pop reg3, reg2, reg1
4752```
4853
4954
5055** Arguments:** </br >
51- ` code ` — the exit code to return to the operating system (e.g., ` 0 ` for success, ` 1 ` for error)
56+ ` regN ` — actual registers to push or pop depending on the target architecture.
5257
5358
5459** Usage example:**
5560
56- ``` asm
57- exit 0 ; exit with code 0
58- exit 1 ; exit with code 1
61+ For x86_64:
62+ ```
63+ push rax, rdi, rsi
64+ ...
65+ pop rsi, rdi, rax
5966```
6067
68+ For x86:
69+ ```
70+ push eax, edi, esi
71+ ...
72+ pop esi, edi, eax
73+ ```
6174
75+ For ARM:
76+ ```
77+ push r0, r1, r2
78+ ...
79+ pop r2, r1, r0
80+ ```
6281
63- ## time
64- Stores the current UNIX time (seconds since January 1, 1970) in the architecture-specific register.
65-
66- ``` asm
67- time
82+ For ARM64:
83+ ```
84+ push x0, x1, x2
85+ ...
86+ pop x2, x1, x0
6887```
6988
7089
7190
72- ## mkdir
73- Creates a directory with the given name and permissions (in octal format).</br >
74- Returns an error code in the architecture-specific register.
91+ ### exit
92+ Terminates the program with a specified exit code.
7593
7694``` asm
77- mkdir dir_name, permissions
95+ exit code
7896```
7997
8098
8199** Arguments:** </br >
82- ` dir_name ` — name of the directory to create, given as a string literal or a pointer to a string</br >
83- ` permissions ` — access mode in octal format, given as a number or a pointer to a variable containing the value
100+ ` code ` — the exit code to return to the operating system (e.g., ` 0 ` for success, ` 1 ` for error).
84101
85102
86103** Usage example:**
87104
88105``` asm
89- mkdir "dir", 700o
90- mkdir name, permissions
106+ exit 0 ; exit with code 0
107+ exit 1 ; exit with code 1
91108```
92109
93110
94111
95- ## rmdir
96- Removes the specified directory.</br >
112+ ## Directory Management Macros
113+
114+ ### mkdir
115+ Creates a directory with the given name and permissions (in octal format).</br >
97116Returns an error code in the architecture-specific register.
98117
99118``` asm
100- rmdir dir_name
119+ mkdir dir_name, permissions
101120```
102121
103122
104123** Arguments:** </br >
105- ` dir_name ` — name of the directory to remove, given as a string literal or a pointer to a string
124+ ` dir_name ` — name of the directory to create, given as a string literal or a pointer to a string.</br >
125+ ` permissions ` — access mode in octal format, given as a number or a pointer to a variable containing the value.
106126
107127
108128** Usage example:**
109129
110130``` asm
111- rmdir "dir"
112- rmdir name
131+ mkdir "dir", 700o
132+ mkdir name, permissions
113133```
114134
115135
116136
117- ## printnum
118- Prints the given number in decimal.</br >
119- Supports values according to the target architecture.</br >
120- Returns the number of bytes printed in the architecture-specific register.
137+ ### rmdir
138+ Removes the specified directory.</br >
139+ Returns an error code in the architecture-specific register.
121140
122141``` asm
123- printnum number
142+ rmdir dir_name
124143```
125144
126145
127146** Arguments:** </br >
128- ` number ` — the unsigned integer value to print
147+ ` dir_name ` — name of the directory to remove, given as a string literal or a pointer to a string.
129148
130149
131150** Usage example:**
132151
133152``` asm
134- printnum 18446744073709551615
135- printnum 4294967295
153+ rmdir "dir"
154+ rmdir name
136155```
137156
138157
139158
140- ## print
159+ ## Console Output Macros
160+
161+ ### print
141162Prints the string at the given address with the specified length.</br >
142163Returns the number of bytes printed in the architecture-specific register.
143164
@@ -147,8 +168,8 @@ print str, str_len
147168
148169
149170** Arguments:**
150- ` str ` — pointer to the string or string literal to print</br >
151- ` str_len ` — length of the string in bytes, given as a number or pointer
171+ ` str ` — pointer to the string or string literal to print. </br >
172+ ` str_len ` — length of the string in bytes, given as a number or pointer.
152173
153174
154175** Usage example:**
@@ -160,7 +181,7 @@ print "test", 4
160181
161182
162183
163- ## printtim
184+ ### printtim
164185Prints the given string a specified number of times.</br >
165186Returns the number of bytes printed in the architecture-specific register.
166187
@@ -170,9 +191,9 @@ printtim times, str, str_len
170191
171192
172193** Arguments:** </br >
173- ` times ` — number of times to print the string, given as a number or pointer
174- ` str ` — pointer to the string or string literal to print
175- ` str_len ` — length of the string in bytes, given as a number or pointer
194+ ` times ` — number of times to print the string, given as a number or pointer.</ br >
195+ ` str ` — pointer to the string or string literal to print.</ br >
196+ ` str_len ` — length of the string in bytes, given as a number or pointer.
176197
177198
178199** Usage example:**
@@ -184,69 +205,69 @@ printtim 3, "test", 4
184205
185206
186207
187- ## run
188- Executes the specified shell command.</br >
189- Returns an error code in the architecture-specific register.
208+ ### printnum
209+ Prints the given number in decimal.</br >
210+ Supports values according to the target architecture.</br >
211+ Returns the number of bytes printed in the architecture-specific register.
190212
191213``` asm
192- run command
214+ printnum number
193215```
194216
217+ ** Note:**
218+
219+ Not available in the library for arm and arm64.
220+
195221
196222** Arguments:** </br >
197- ` command ` — pointer to the command string or a string literal to execute
223+ ` number ` — the unsigned integer value to print.
198224
199225
200226** Usage example:**
201227
202- ```
203- run "echo test"
204- run cmd_str
228+ ``` asm
229+ printnum 18446744073709551615
230+ printnum 4294967295
205231```
206232
207233
208234
209- ## push / pop
210- Pushes or pops multiple registers on/from the stack (equivalent to multiple ` push ` /` pop ` instructions).
211- Register order in ` pop ` must match the reverse of ` push ` .
235+ ## Misc Macros
236+
237+ ### time
238+ Stores the current UNIX time (seconds since January 1, 1970) in the architecture-specific register.
212239
213240``` asm
214- push reg1, reg2, reg3
215- ...
216- pop reg3, reg2, reg1
241+ time
217242```
218243
244+ ** Note:**
219245
220- ** Arguments:** </br >
221- ` regN ` — actual registers to push or pop depending on the target architecture
246+ Not available in the library for arm and arm64.
222247
223248
224- ** Usage example:**
225249
226- For x86_64:
227- ```
228- push rax, rdi, rsi
229- ...
230- pop rsi, rdi, rax
231- ```
250+ ### run
251+ Executes the specified shell command.</br >
252+ Returns an error code in the architecture-specific register.
232253
233- For x86:
234- ```
235- push eax, edi, esi
236- ...
237- pop esi, edi, eax
254+ ``` asm
255+ run command
238256```
239257
240- For ARM:
241- ```
242- push r0, r1, r2
243- ...
244- pop r2, r1, r0
245- ```
246258
247- For ARM64:
259+ ** Note:**
260+
261+ Not available in the library for arm and arm64.
262+
263+
264+ ** Arguments:** </br >
265+ ` command ` — pointer to the command string or a string literal to execute.
266+
267+
268+ ** Usage example:**
269+
248270```
249- push x0, x1, x2
250- ...
251- pop x2, x1, x0
271+ run "echo test"
272+ run cmd_str
252273```
0 commit comments