-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsystem-calls-32bits.asm
667 lines (462 loc) · 17.3 KB
/
system-calls-32bits.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
System calls - M32
eax = function number
int 0x40 = execute system call
00 - Define and draw window
01 - Putpixel
02 - Get key
03 - Get system time
04 - Display text
05 - Delay
07 - Putimage
08 - Define button
09 - Process info
10 - Wait for event
11 - Check for event
12 - Window redraw status
13 - Draw filled rectangle
14 - Get screen size
15 - Background
16 - Save ramdisk to floppy
17 - Get button ID
18 - System
20 - Midi interface, MPU401
21 - Device setup
23 - Wait for event with timeout
24 - CD audio
25 - SB16 I
26 - Get setup for devices
27 - WSS
28 - SB16 II
29 - Get date
35 - Read screen pixel
37 - Read mouse data
38 - Display line
39 - Get background data
40 - Set bitfield for wanted events
41 - Get IRQ owner
42 - Get data read by IRQ
44 - Program IRQ
45 - Reserve/free IRQ
46 - Reserve/free port area
47 - Display number to window
48 - Define general window properties
50 - Free form window shape and scale
51 - Create thread
52 - Stack driver status
53 - Socket interface
55 - Sound interface
58 - File system
59 - Trace system calls
60 - Inter process communication
61 - Direct graphics access
62 - PCI access
63 - Debug board
64 - Application memory resize
65 - UTF
66 - Keyboard data mode
67 - Application window move / resize
113- Vertical/Horizontal Scroll
-1 - End application
--
00 - Define and draw window
In : ebx - [x start] shl 16 + [x size]
ecx - [y start] shl 16 + [y size]
edx - Body color 0xXYRRGGBB
X=8 - Color glide
Y=0 - Window type I
Y=1 - Reserve area, no draw
Y=2 - Window type II
Y=3 - Skinned window
Closebutton id=1 added
Y=4 - Skinned window with menu
Closebutton id=1 added
esi=zero or pointer to window label (asciiz)
edi=zero or pointer to menu struct
esi - Grab bar color 0xXYRRGGBB X=8-Color glide-
X=4-Color glide+
Y=1-No window move
edi - Frame color 0xRRGGBB
Out: -
01 - Putpixel
In : ebx - X
ecx - Y
edx - Pixel color 0x0XRRGGBB
X = 0 normal, 1 negative
Out: -
02 - Get key
Out: al = 0 - Successful - ah = key
al = 1 - No key in buffer
See function 66
03 - Get system time
Out: eax - 0x00SSMMHH seconds,minutes,hours
04 - Display text
In : ebx - [x start]*65536 + [y start]
ecx - Color - 0xF0RRGGBB - F=font(0/1)
edx - Pointer to text beginning
esi - Text length or -1 for asciiz string
Out: -
05 - Delay
In : ebx - Delay in 1/100 secs
Out: -
07 - Putimage
In : ebx - Pointer to image in memory - RRGGBBRRGGBB..
ecx - Image size [x]*65536+[y]
edx - Image position in window [x]*65536+[y]
Out: -
08 - Define button
In : ebx - [x start]*65536 + [x size]
ecx - [y start]*65536 + [y size]
edx - Button ID number (24 bits)
bit 31 - removes a button matching the id
function doesnt remove the button image
to avoid unnecessary flickering
bit 30 - button image is not drawn
bit 29 - rectangle is not drawn when pressed
esi - Button color 0xX0RRGGBB
X = 0 - use system color 1
X = 1 - use system color 2
edi = zero or pointer to button label (asciiz)
X = 2 - user defined color RRGGBB
Out: -
09 - Process info
In : ebx - Pointer to 1024 bytes table
ecx - Process number (-1 = whoami)
Out: eax - Number of processes
Table: +00 dword cpu usage
+04 word Processes position in window stack
+06 word Window stack value at ecx
+10 11 db Name of the process
+22 dword Start of processes memory
+26 dword Memory used by process
+30 dword PID of the process
+34 dword Window x start
+38 dword Window y start
+42 dword Window x size
+46 dword Window y size
+50 word Process slot state
10 - Wait for event
Out: eax - Event type
- 1 window redraw
- 2 key in buffer
- 3 button pressed
11 - Check for event
Out: eax - Event type
- 0 no event
- 1 window redraw
- 2 key in buffer
- 3 button pressed
12 - Window redraw status
In : ebx - 1 Start of redraw
- 2 End of redraw
Out: -
13 - Draw filled rectangle
In : ebx - [x start] shl 16 + [x size]
ecx - [y start] shl 16 + [y size]
edx - color 0xRRGGBB
Out: -
14 - Get screen size
Out: eax - [screen x max] shl 16 + [screen y max]
15 - Background
In : ebx 1 - Set background size
ecx - X size
edx - Y size
ebx 2 - Write to background memory - max (0x100000-16)
ecx - Position in memory in bytes
edx - Color 0xRRGGBB
ebx 3 - Draw background
ebx 4 - type of background draw
ecx 1 - Tiled
ecx 2 - Stretched
ebx 5 - Blockmove image to os bgr memory
ecx - Source
edx - Position in os background
esi - Count of bytes to move
16 - Save ramdisk to floppy
In : ebx 1 - Save all
17 - Get button ID
Out: al 0 - Successful and ah has ID
(shr eax,8 - eax=24 bit ID)
al 1 - No key in buffer
18 - System
In : ebx 1 - Boot
ebx 2 - Force terminate, ecx - Process slot
ebx 3 - Activate window, ecx - Process slot
ebx 4 - Idle cycles / second
ebx 5 - Time stamp / second
Out: rax
20 - Midi interface, MPU401
In : ebx 1 - reset device
ebx 2 - midi output, cl data
21 - Device setup
In : ebx 1 - Roland mpu midi base , base io address
ebx 2 - Keyboard 1 base keymap, 2 shift keymap (ecx pointer to keymap)
9 country 1eng 2fi 3ger 4rus
ebx 3 - Cd base 1 pri.master, 2 pri slave,
3 sec master, 4 sec slave
ebx 4 - Sb16 base, base io address
ebx 5 - System language, 1eng, 2fi, 3ger, 4rus
ebx 6 - Wss base, base io address
ebx 7 - Hd base, 1 pri.master, 2 pri slave
3 sec master, 4 sec slave
ebx 8 - Fat32 partition in hd
ebx 10- Sound dma channel in ecx
23 - Wait for event with timeout
In : ebx - Time to delay in HS
Out: eax - Event type
- 0 No event
- 1 Window redraw
- 2 Key in buffer
- 3 Button
24 - CD audio
In : ebx 1 - Play (ecx=00FRSSMM)
ebx 2 - Get playlist (size of ecx to [edx])
ebx 3 - Stop/pause play
Out: -
25 - SB16 I
In : ebx 1 - Set main volume cl [L]*16+[R]
ebx 2 - Set CD volume cl [L]*16+[R]
Out: -
26 - Get setup for devices
In : ebx 1 - Roland mpu midi base , base io address
ebx 2 - Keyboard 1 base keymap ,2 shift keymap
9 country 1eng, 2fi, 3ger, 4rus
ebx 3 - Cd base 1 pri.master, 2 pri slave,
3 sec master, 4 sec slave
ebx 4 - Sb16 base, base io address
ebx 5 - System language, 1eng, 2fi, 3ger, 4rus
ebx 6 - Wss base, base io address
ebx 7 - Hd base, 1 pri.master, 2 pri slave
3 sec master, 4 sec slave
ebx 8 - Fat32 partition in hd
ebx 9 - Uptime in 1/100 sec -> eax
Out: eax - Return value
27 - WSS
In : ebx 1 - Set main volume to cl 0-255
ebx 2 - Set cd volume to cl 0-255
Out: -
28 - SB16 II
In : ebx 1 - Set main volume to cl 0-255
ebx 2 - Set cd volume to cl 0-255
Out: -
29 - Get date
Out: eax - 0xYYDDMM year,date,month
35 - Read screen pixel
In : ebx - Pixel count from top left of the screen
Out: eax - 0x00RRGGBB Color
37 - Read mouse data
In : ebx - 0 Screen relative
ebx - 1 Window relative
ebx - 2 Buttons pressed
Out: eax - data
38 - Display line
In : ebx - [x start] shl 16 + [x end]
ecx - [y start] shl 16 + [y end]
edx - 0x00RRGGBB Color
Out: -
39 - Get background data
In : ebx 1 - Get background size
Out: eax=[x size] shl 16 + [y size]
ebx 2 - Get background pixel
ecx - Position at background memory map
Out: eax = value
ebx 4 - Get background type
Out: eax=1 tiled, eax=2 stretched
40 - Set bitfield for wanted events
In : ebx - bitfield of wanted events
default:
ebx = 00000000 00000000 00000000 00000111b Events:
I Window draw
I Key in buffer
I Button in buffer
I
I Desktop background draw
I Mouse
I IPC
I---------------I Get irqs data
Out: -
41 - Get IRQ owner
In : ebx - IRQ
Out: eax - PID of process
42 - Get data read by IRQ
In : ebx - IRQ number
Out: eax - Number of bytes in buffer
bl - Data
ecx - 0 - Successful data read
1 - No data in buffer
2 - Incorrect IRQ owner
44 - Program IRQ
In : ebx - Pointer to table
Out: ecx - IRQ number
45 - Reserve/free IRQ
In : ebx - 0 Reserve, 1 Free
ecx - IRQ number
Out: eax - 0 Successful, 1 Error
46 - Reserve/free port area
Direct IO access with IN and OUT commands
In : ebx - 0 Reserve, 1 Free
ecx - Port area start (min 256)
edx - Port area end (max 16383)
Out: eax - 0 Successful, 1 Error
47 - Display number
In : ebx - Print type, bl=0 - ecx=value
bl=1 - ecx=pointer
bh=0 - display decimal
bh=1 - display hexadecimal
bh=2 - display binary
bits 16-21 = number of digits to display (0-32)
bits 22-31 = reserved
ecx - Value or pointer
edx - x shl 16 + y
esi - Color
Out: -
48 - Define general window properties
In: ebx - 0 Apply/redraw
ecx - 0 Apply/redraw desktop
ebx - 1 Define button style
ecx - 0 Set flat buttons
ecx - 1 Set 3d buttons
ebx - 2 Define window colors
ecx Pointer to table
edx Number of bytes defined
ebx - 3 Get define window colors
ecx Pointer to table
edx Number of bytes to get
ebx - 4 Get window skin height
Out: -
50 - Free form window shape and scale
In : ebx - 0 Shape reference area
ecx - Pointer to reference area
byte per pixel (0=not used, 1=used, other=reserved)
ebx - 1 Scale of reference area (default 1:1)
ecx - Scale is set to 2^ecx
Out: -
51 - Create thread
In : ebx = 1 Create
ecx Thread entry point
edx Thread stack position
Out: eax = PID or 0xfffffff0+ for error
52 - Stack driver status
- See stack.txt
53 - Socket interface
- See stack.txt
55 - Sound interface
In : ebx - 0 Load sound block
ecx Pointer to (default size 65536 byte) soundblock
ebx - 1 Play (default 44 khz 8 bit mono) sound block
ebx - 2 Set format
ecx - 1 Set play block length
edx Block length
Out: -
58 - File system
In : ebx - Pointer to fileinfo block
Path examples:
'/RD/1/KERNEL.ASM',0
'/HD/1/KERNEL.ASM',0
Fileinfo:
dd 0 Read
dd 0x0 512 block to read 0+
dd 0x1 Blocks to read (/bytes to write/append)
dd 0x20000 Return data pointer
dd 0x10000 Work area for os - 16384 bytes
db PATH asciiz dir & filename
Out: eax - 0 Success or error code
ebx - Size of file
or
Fileinfo:
dd 1 Write
dd 0x0 Ignored
dd 10000 Bytes to write
dd 0x20000 Source data pointer
dd 0x10000 Work area for os - 16384 bytes
db PATH ASCIIZ dir & filename
Out: eax = 0 Success or error code
or
LBA
Fileinfo:
dd 0x8 LBA read
dd 0x0 512 block to read (write)
dd 0x1 Set to 1
dd 0x20000 Return data pointer
dd 0x10000 Work area for os (16384 bytes)
dd PATH Physical device ; asciiz
( or /rd/1/ )
LBA read must be enabled with setup
The asciiz in this context refers to the physical device and
not to logical one.
For hd: first=pri.master, second=pri.slave
third=sec.master, fourth=sec.slave
or
Fileinfo:
dd 16 Start application
dd 0x0 Ignored
dd param 0 or parameter area (asciiz)
Receiving application must
reserve a 256 byte area
dd 0x0 Ignored
dd 0x10000 Work area for os - 16384 bytes
db PATH asciiz dir & filename
Out: eax = pid or 0xfffffff0+ for error
59 - Trace system calls
In : ebx - 0 Get system events
ecx Pointer to table - 64 bytes/system call descriptor
+00 PID +32 EDI +36 ESI +40 EBP +44 ESP
+48 EBX +52 EDX +56 ECX +60 EAX
edx Number of bytes to return (max 1024)
Out: eax - Number of system calls from start
Latest call is saved to (eax mod 16)*64 in table
ebx - 0 Above format
60 - Inter process communication
In : ebx - 1 Define IPC memory
ebx - 2 Send message
Out: -
61 - Direct graphics access
In : ebx - 1 Get resolution -> eax [x] shl 16 + [y]
ebx - 2 Get bits per pixel -> eax
ebx - 3 Get bytes per scanline -> eax
Direct access with gs selector: mov [gs:0],dword 0xffffff
Out: eax - See above
62 - PCI access
- See pci.txt
63 - Debug board
In : ebx - 1 Write byte (cl=byte)
ebx - 2 Read byte
Out: ebx=1-byte in al
ebx=0-no data
Out: -
64 - Application memory resize
In : ebx - 1 Set amount of memory
ecx New amount of memory
Out: eax - 0 Successfull
eax - 1 Out of memory
65 - UTF
66 - Keyboard data mode
In : ebx - 1 Set mode
ecx - 0 Keymap
ecx - 1 Scancodes
ebx - 2 Get mode - return in eax
ebx - 3 Get ctrl alt shift state - return in eax
67 - Application window move / resize
In : ebx - New x start
ecx - New y start
edx - New x size
esi - New y size
Out: -
Specifying any parameter as -1 will leave the parameter unchanged.
113- Vertical/Horizontal Scroll
Vertical scroll
In : ebx - 1 shl 16 + X start
ecx - Y start shl 16+ Y size
edx - Scroll value start
esi - Scroll value size
edi - Current scroll value
Out: -
Horizontal scroll
In : ebx - 2 shl 16 + Y start
ecx - X start shl 16+ X size
edx - Scroll value start
esi - Scroll value size
edi - Current scroll value
Out: -
-1 - End application
In : -
Out: -