1 ; **************************************************************************** 2 ; pushtest.s (TRDOS 386, TRDOS v2.0 - sample binary file, 'pushtest.prg') 3 ; ---------------------------------------------------------------------------- 4 ; PUSHTEST.PRG ! TEST program ! 5 ; 6 ; 19/11/2017 7 ; 8 ; **************************************************************************** 9 10 ; 01/03/2017 11 ; 16/10/2016 12 ; 29/04/2016 13 ; TRDOS 386 system calls (temporary list!) 14 _ver equ 0 15 _exit equ 1 16 _fork equ 2 17 _read equ 3 18 _write equ 4 19 _open equ 5 20 _close equ 6 21 _wait equ 7 22 _creat equ 8 23 _link equ 9 24 _unlink equ 10 25 _exec equ 11 26 _chdir equ 12 27 _time equ 13 28 _mkdir equ 14 29 _chmod equ 15 30 _chown equ 16 31 _break equ 17 32 _stat equ 18 33 _seek equ 19 34 _tell equ 20 35 _mount equ 21 36 _umount equ 22 37 _setuid equ 23 38 _getuid equ 24 39 _stime equ 25 40 _quit equ 26 41 _intr equ 27 42 _fstat equ 28 43 _emt equ 29 44 _mdate equ 30 45 _video equ 31 46 _audio equ 32 47 _timer equ 33 48 _sleep equ 34 49 _msg equ 35 50 _geterr equ 36 51 _fpsave equ 37 52 _pri equ 38 53 _rele equ 39 54 _fff equ 40 55 _fnf equ 41 56 _alloc equ 42 57 _dalloc equ 43 58 _calbac equ 44 59 60 %macro sys 1-4 61 ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 62 ; 03/09/2015 63 ; 13/04/2015 64 ; Retro UNIX 386 v1 system call. 65 %if %0 >= 2 66 mov ebx, %2 67 %if %0 >= 3 68 mov ecx, %3 69 %if %0 = 4 70 mov edx, %4 71 %endif 72 %endif 73 %endif 74 mov eax, %1 75 ;int 30h 76 int 40h ; TRDOS 386 (TRDOS v2.0) 77 %endmacro 78 79 ; TRDOS 386 (and Retro UNIX 386 v1) system call format: 80 ; sys systemcall (eax) , , 81 82 [BITS 32] ; We need 32-bit intructions for protected mode 83 84 [ORG 0] 85 86 START_CODE: 87 00000000 89E5 mov ebp, esp 88 00000002 16 push ss 89 00000003 89E0 mov eax, esp 90 00000005 89EC mov esp, ebp 91 00000007 29C5 sub ebp, eax 92 00000009 89E8 mov eax, ebp 93 0000000B 0430 add al, 30h 94 0000000D A2[4F000000] mov [psize], al 95 sys _msg, msg_push_size, 255, 0Fh 95 <1> 95 <1> 95 <1> 95 <1> 95 <1> %if %0 >= 2 95 00000012 BB[31000000] <1> mov ebx, %2 95 <1> %if %0 >= 3 95 00000017 B9FF000000 <1> mov ecx, %3 95 <1> %if %0 = 4 95 0000001C BA0F000000 <1> mov edx, %4 95 <1> %endif 95 <1> %endif 95 <1> %endif 95 00000021 B823000000 <1> mov eax, %1 95 <1> 95 00000026 CD40 <1> int 40h 96 97 sys _exit ; INT 40h 97 <1> 97 <1> 97 <1> 97 <1> 97 <1> %if %0 >= 2 97 <1> mov ebx, %2 97 <1> %if %0 >= 3 97 <1> mov ecx, %3 97 <1> %if %0 = 4 97 <1> mov edx, %4 97 <1> %endif 97 <1> %endif 97 <1> %endif 97 00000028 B801000000 <1> mov eax, %1 97 <1> 97 0000002D CD40 <1> int 40h 98 here: 99 0000002F EBFE jmp short here 100 101 ;----------------------------------------------------------------- 102 ; DATA 103 ;----------------------------------------------------------------- 104 105 ;----------------------------------------------------------------- 106 ; messages 107 ;----------------------------------------------------------------- 108 109 msg_push_size: 110 00000031 0D0A db 0Dh, 0Ah 111 00000033 5365676D656E742072- db "Segment register push size: " 111 0000003C 656769737465722070- 111 00000045 7573682073697A653A- 111 0000004E 20 112 0000004F 58206279746573 psize: db "X bytes" 113 00000056 0D0A00 db 0Dh, 0Ah, 0