Fresh IDE . Check-in [cd025fbff5]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:CreatePipe and WaitProcessExit for Linux implemented. Fixed a small issue in Exec2 for Linux.
Timelines: family | ancestors | descendants | both | FreshLibDev
Files: files | file ages | folders
SHA1:cd025fbff5a0db272e7c1a1b2529af915772a9f5
User & Date: johnfound 2018-10-19 13:53:30
Context
2018-11-08
09:48
Changes in bbcode.asm in order to make it compatible with the developed markdown compatible parser. check-in: 1c0a2da404 user: johnfound tags: FreshLibDev
2018-10-19
13:53
CreatePipe and WaitProcessExit for Linux implemented. Fixed a small issue in Exec2 for Linux. check-in: cd025fbff5 user: johnfound tags: FreshLibDev
2018-10-18
13:31
The Exec2 function is now the main. The old Exec is a wrapper of Exec2. Implemented for Win32 and Linux. check-in: 17ffd16cb7 user: johnfound tags: FreshLibDev
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/system/Linux/files.asm.

597
598
599
600
601
602
603




























604
605
606
607
608
609
610
        return

.exists:
        clc
        popad
        return
endp

































flushInput = 0
flushOutput = 1







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
        return

.exists:
        clc
        popad
        return
endp




body CreatePipe
.hRead  dd ?
.hWrite dd ?
begin
        push    ebx

        mov     eax, sys_pipe
        lea     ebx, [.hRead]
        int     $80
        neg     eax
        jnz     .err

        clc
        mov     eax, [.hRead]
        mov     edx, [.hWrite]
        pop     ebx
        return

.err:
        stc
        pop     ebx
        return
endp






flushInput = 0
flushOutput = 1

Changes to freshlib/system/Linux/process.asm.

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
        int     $80

        test    eax, eax
        jnz     .parent         ; this is the parent process

; here is the child.



        mov     eax, sys_dup2
        mov     ebx, [.hStdIn]
        mov     ecx, [STDIN]
        int     $80

        mov     eax, sys_dup2
        mov     ebx, [.hStdOut]
        mov     ecx, [STDOUT]
        int     $80

        mov     eax, sys_dup2
        mov     ebx, [.hStdErr]
        mov     ecx, [STDERR]
        int     $80

        mov     ecx, [.pArgs]
        mov     ebx, [ecx]                      ; the first argument is the executable name.

        mov     edx, [_ptrEnvironment]
        mov     eax, [edx]                      ; argument count
        lea     edx, [edx + 4*eax + 8]          ; +4 for argc and +4 for the termination 0; edx points to the env table here.

        mov     eax, sys_execve
        int     $80



        stc
        mov     [esp+4*regEAX], eax
        popad
        return

.parent:
        stdcall FreeMem, [.pArgs]
        bt      eax, 31
        mov     [esp+4*regEAX], eax















        popad
        return
endp



; Splits the string on spaces and forms one-memory-block area that contains, zero terminated







>
>


|




|




|












>
>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
        int     $80

        test    eax, eax
        jnz     .parent         ; this is the parent process

; here is the child.

        DebugMsg "Child process here!"

        mov     eax, sys_dup2
        mov     ebx, [.hStdIn]
        xor     ecx, ecx
        int     $80

        mov     eax, sys_dup2
        mov     ebx, [.hStdOut]
        inc     ecx
        int     $80

        mov     eax, sys_dup2
        mov     ebx, [.hStdErr]
        inc     ecx
        int     $80

        mov     ecx, [.pArgs]
        mov     ebx, [ecx]                      ; the first argument is the executable name.

        mov     edx, [_ptrEnvironment]
        mov     eax, [edx]                      ; argument count
        lea     edx, [edx + 4*eax + 8]          ; +4 for argc and +4 for the termination 0; edx points to the env table here.

        mov     eax, sys_execve
        int     $80

        OutputValue "Error Exec2: ", eax, 10, -1

        stc
        mov     [esp+4*regEAX], eax
        popad
        return

.parent:
        stdcall FreeMem, [.pArgs]
        bt      eax, 31
        mov     [esp+4*regEAX], eax
        popad
        return
endp



body WaitProcessExit
begin
        pushad
        mov     eax, sys_waitpid
        mov     ebx, [.ProcessID]
        xor     ecx, ecx
        xor     edx, edx
        int     $80
        clc
        popad
        return
endp



; Splits the string on spaces and forms one-memory-block area that contains, zero terminated

Changes to freshlib/system/files.asm.

79
80
81
82
83
84
85




86
87
88
89
90
91
92

interface GetFileInfo, .hFile, .ptrFileInfo

interface FileExists, .hFileName

interface CreateDirectory, .DirName







;--------------------------------------
; if CF = 0, eax is handle to the file.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileOpen, .filename







>
>
>
>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

interface GetFileInfo, .hFile, .ptrFileInfo

interface FileExists, .hFileName

interface CreateDirectory, .DirName


; returns the read handle in eax and write handle in edx

interface CreatePipe


;--------------------------------------
; if CF = 0, eax is handle to the file.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileOpen, .filename