     1                                  ; ****************************************************************************
     2                                  ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 11/08/2022 (Previous: 18/04/2021)
     5                                  ; ----------------------------------------------------------------------------
     6                                  ; Beginning: 04/01/2016
     7                                  ; ----------------------------------------------------------------------------
     8                                  ; Assembler: NASM version 2.15 (trdos386.s)
     9                                  ; ----------------------------------------------------------------------------
    10                                  ; Turkish Rational DOS
    11                                  ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                                  ;
    13                                  ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                                  ; unix386.s (03/01/2016)
    15                                  ;
    16                                  ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    17                                  ; TRDOS2.ASM (09/11/2011)
    18                                  ; 
    19                                  ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    20                                  ; ****************************************************************************
    21                                  ; nasm trdos386.s -l trdos386.txt -o TRDOS386.SYS
    22                                  
    23                                  KLOAD	equ 10000h ; Kernel loading address
    24                                  	; NOTE: Retro UNIX 8086 v1 boot code loads kernel at 1000h:0000h 
    25                                  KCODE	equ 08h	; Code segment descriptor (ring 0)
    26                                  KDATA	equ 10h	; Data segment descriptor (ring 0)
    27                                  ; 19/03/2015
    28                                  UCODE	equ 1Bh ; 18h + 3h  (ring 3)
    29                                  UDATA	equ 23h ; 20h + 3h  (ring 3)
    30                                  ; 24/03/2015
    31                                  TSS	equ 28h	; Task state segment descriptor (ring 0)
    32                                  ; 19/03/2015
    33                                  CORE	equ 400000h  ; Start of USER's virtual/linear address space 
    34                                  		     ; (at the end of the 1st 4MB)
    35                                  ECORE	equ 0FFC00000h ; End of USER's virtual address space (4GB - 4MB)
    36                                  		     ; ULIMIT = (ECORE/4096) - 1 = 0FFBFFh (in GDT)
    37                                  ;; 27/12/2013
    38                                  ;KEND	equ KLOAD + 65536 ; (28/12/2013) (end of kernel space)
    39                                  ; 04/07/2016
    40                                  KEND    equ KERNELFSIZE + KLOAD
    41                                  
    42                                  ; IBM PC/AT BIOS ----- 10/06/85 (postequ.inc)
    43                                  ;--------- CMOS TABLE LOCATION ADDRESS'S -------------------------------------
    44                                  CMOS_SECONDS	EQU	00H		; SECONDS (BCD)
    45                                  CMOS_SEC_ALARM	EQU	01H		; SECONDS ALARM (BCD)
    46                                  CMOS_MINUTES	EQU	02H		; MINUTES (BCD)
    47                                  CMOS_MIN_ALARM	EQU	03H		; MINUTES ALARM (BCD) 	
    48                                  CMOS_HOURS	EQU	04H		; HOURS (BCD
    49                                  CMOS_HR_ALARM	EQU	005H		; HOURS ALARM   (BCD)
    50                                  CMOS_DAY_WEEK	EQU	06H		; DAY OF THE WEEK  (BCD)
    51                                  CMOS_DAY_MONTH	EQU	07H		; DAY OF THE MONTH (BCD) 
    52                                  CMOS_MONTH	EQU	08H		; MONTH (BCD)
    53                                  CMOS_YEAR	EQU	09H		; YEAR (TWO DIGITS) (BCD)
    54                                  CMOS_CENTURY	EQU	32H		; DATE CENTURY BYTE (BCD)
    55                                  CMOS_REG_A	EQU	0AH		; STATUS REGISTER A
    56                                  CMOS_REG_B	EQU	00BH		; STATUS REGISTER B  ALARM
    57                                  CMOS_REG_C	EQU	00CH		; STATUS REGISTER C  FLAGS
    58                                  CMOS_REG_D	EQU	0DH		; STATUS REGISTER D  BATTERY
    59                                  CMOS_SHUT_DOWN	EQU	0FH		; SHUTDOWN STATUS COMMAND BYTE
    60                                  ;----------------------------------------
    61                                  ;	CMOS EQUATES FOR THIS SYSTEM	;
    62                                  ;-----------------------------------------------------------------------------
    63                                  CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
    64                                  CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
    65                                  NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
    66                                  					; HIGH BIT OF CMOS LOCATION ADDRESS
    67                                  
    68                                  ; Memory Allocation Table Address
    69                                  ; 05/11/2014
    70                                  ; 31/10/2014
    71                                  MEM_ALLOC_TBL	equ	100000h		; Memory Allocation Table at the end of
    72                                  					; the 1st 1 MB memory space.
    73                                  					; (This address must be aligned
    74                                  					;  on 128 KB boundary, if it will be
    75                                  					;  changed later.)
    76                                  					; ((lower 17 bits of 32 bit M.A.T.
    77                                  					;   address must be ZERO)).
    78                                  					; ((((Reason: 32 bit allocation 
    79                                  					;     instructions, dword steps)))
    80                                  					; (((byte >> 12 --> page >> 5)))  
    81                                  ;04/11/2014	
    82                                  PDE_A_PRESENT	equ	1		; Present flag for PDE
    83                                  PDE_A_WRITE	equ 	2		; Writable (write permission) flag
    84                                  PDE_A_USER	equ	4		; User (non-system/kernel) page flag
    85                                  ;
    86                                  PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
    87                                  PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
    88                                  PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
    89                                  PTE_A_ACCESS    equ	32		; Accessed flag (bit 5) ; 09/03/2015
    90                                  
    91                                  ; 17/02/2015 (unix386.s)
    92                                  ; 10/12/2014 - 30/12/2014 (0B000h -> 9000h) (dsectrm2.s)
    93                                  DPT_SEGM equ 09000h  ; FDPT segment (EDD v1.1, EDD v3)
    94                                  ;
    95                                  HD0_DPT	 equ 0	    ; Disk parameter table address for hd0
    96                                  HD1_DPT	 equ 32	    ; Disk parameter table address for hd1
    97                                  HD2_DPT	 equ 64	    ; Disk parameter table address for hd2
    98                                  HD3_DPT	 equ 96	    ; Disk parameter table address for hd3
    99                                  
   100                                  ; 15/11/2020
   101                                  VBE3INFOSEG equ 97E0h ; 512 bytes before Video_Pg_Backup
   102                                  ; 15/12/2020
   103                                  VBE3MODEINFOSEG equ 97C0h ; 512 bytes before VBE3INFOBLOCK 
   104                                  
   105                                  ; 29/11/2020
   106                                  VBE3INFOBLOCK equ 97E00h ; linear address (512 bytes)
   107                                  VBE3MODEINFOBLOCK equ 97C00h ; linear address (256 bytes)
   108                                  VBE3SAVERESTOREBLOCK equ 97600h ; linear address (2048 bytes)
   109                                  VBE3CRTCINFOBLOCK equ 97D80h ; linear address (64 bytes) ; 17/01/2021 
   110                                  VBE3BIOSDATABLOCK equ 97000h ; linear address (1536 bytes)
   111                                  VBE3STACKADDR equ 96000h ; linear address (1024 bytes)
   112                                  ; VBE3 32 bit Protected Mode Interface (16 bit) Selectors (in GDT)
   113                                  VBE3CS equ 30h ; _vbe3_CS:
   114                                  VBE3BDS equ 38h ; _vbe3_BDS:
   115                                  VBE3A000 equ 40h ; _A0000Sel:
   116                                  VBE3B000 equ 48h ; _B0000Sel:
   117                                  VBE3B800 equ 50h ; _B8000Sel:
   118                                  VBE3DS equ 58h ; _vbe3_DS:
   119                                  VBE3SS equ 60h ; _vbe3_SS:
   120                                  VBE3ES equ 68h ; _vbe3_ES:
   121                                  KCODE16 equ 70h ; _16bit_CS:
   122                                  ; 14/01/2021
   123                                  ; 06/12/2020
   124                                  VBE3VIDEOSTATE equ 95800h ; 2048 bytes
   125                                  ; 05/01/2021
   126                                  VGAFONT16USER equ 94000h ; 8x16 pixels user font (256 chars)	
   127                                  			 ; (reserved/allocated font space: 4096 bytes) 
   128                                  
   129                                  VGAFONT8USER equ 95000h	; 8x8 pixels user font (256 chars)	
   130                                  			; (reserved/allocated font space: 2048 bytes)
   131                                  ; 17/01/2021
   132                                  ; temporary (initial) location for EDID information
   133                                  VBE3EDIDINFOBLOCK equ 97D00h ; linear address (128 bytes)
   134                                   
   135                                  ; FDPT (Phoenix, Enhanced Disk Drive Specification v1.1, v3.0)
   136                                  ;      (HDPT: Programmer's Guide to the AMIBIOS, 1993)
   137                                  ;
   138                                  FDPT_CYLS	equ 0 ; 1 word, number of cylinders
   139                                  FDPT_HDS	equ 2 ; 1 byte, number of heads
   140                                  FDPT_TT		equ 3 ; 1 byte, A0h = translated FDPT with logical values
   141                                  		      ; otherwise it is standard FDPT with physical values 	
   142                                  FDPT_PCMP	equ 5 ; 1 word, starting write precompensation cylinder
   143                                  		      ; (obsolete for IDE/ATA drives)
   144                                  FDPT_CB		equ 8 ; 1 byte, drive control byte
   145                                  			; Bits 7-6 : Enable or disable retries (00h = enable)
   146                                  			; Bit 5	: 1 = Defect map is located at last cyl. + 1
   147                                  			; Bit 4 : Reserved. Always 0
   148                                  			; Bit 3 : Set to 1 if more than 8 heads
   149                                  			; Bit 2-0 : Reserved. Always 0
   150                                  FDPT_LZ		equ 12 ; 1 word, landing zone (obsolete for IDE/ATA drives)
   151                                  FDPT_SPT	equ 14 ; 1 byte, sectors per track
   152                                  
   153                                  ; Floppy Drive Parameters Table (Programmer's Guide to the AMIBIOS, 1993)
   154                                  ; (11 bytes long) will be used by diskette handler/bios
   155                                  ; which is derived from IBM PC-AT BIOS (DISKETTE.ASM, 21/04/1986).
   156                                  
   157                                  ; 01/02/2016
   158                                  Logical_DOSDisks equ 90000h + 100h ; 26*256 = 6656 bytes
   159                                  Directory_Buffer equ 80000h ; max = 64K Bytes
   160                                  FAT_Buffer	 equ 91C00h ; 1536 bytes (3 sectors)
   161                                  ; 15/02/2016
   162                                  Cluster_Buffer	 equ 70000h ; max = 64K Bytes ; buffer for file read & write
   163                                  ; 11/04/2016
   164                                  Env_Page:	 equ 93000h ; 512 bytes (4096 bytes)
   165                                  Env_Page_Size	 equ 512    ; (4096 bytes)
   166                                  ; 30/07/2016
   167                                  Video_Pg_Backup	 equ 98000h ; Mode 3h, video page backup (32K, 8 pages)
   168                                  
   169                                  ; 29/11/2020
   170                                  ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 96000h (available)
   171                                  ; 06/12/2020
   172                                  ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 95800h (available)
   173                                  
   174                                  ; 15/12/2020
   175                                  LFB_ADDR	equ LFB_Info+LFBINFO.LFB_addr
   176                                  LFB_SIZE	equ LFB_Info+LFBINFO.LFB_size
   177                                   
   178                                  [BITS 16]       ; We need 16-bit intructions for Real mode
   179                                  
   180                                  [ORG 0] 
   181                                  	; 12/11/2014
   182                                  	; Save boot drive number (that is default root drive)
   183 00000000 8816[F864]              	mov	[boot_drv], dl ; physical drv number
   184                                  
   185                                  	; Determine installed memory
   186                                  	; 31/10/2014
   187                                  	;
   188 00000004 B801E8                  	mov	ax, 0E801h ; Get memory size 
   189 00000007 CD15                    	int	15h	   ; for large configurations
   190 00000009 7308                    	jnc	short chk_ms
   191 0000000B B488                    	mov	ah, 88h    ; Get extended memory size 
   192 0000000D CD15                    	int	15h
   193                                  	;	   
   194                                  	;mov	al, 17h	; Extended memory (1K blocks) low byte
   195                                  	;out	70h, al ; select CMOS register
   196                                  	;in	al, 71h ; read data (1 byte)
   197                                  	;mov	cl, al
   198                                  	;mov	al, 18h ; Extended memory (1K blocks) high byte
   199                                  	;out	70h, al ; select CMOS register
   200                                  	;in	al, 71h ; read data (1 byte)
   201                                  	;mov	ch, al
   202                                   	;      
   203 0000000F 89C1                    	mov	cx, ax
   204 00000011 31D2                    	xor	dx, dx
   205                                  chk_ms:
   206 00000013 890E[F464]              	mov	[mem_1m_1k], cx
   207 00000017 8916[F664]              	mov	[mem_16m_64k], dx
   208                                  	; 05/11/2014
   209                                  	;and	dx, dx
   210                                  	;jz	short L2
   211 0000001B 81F90004                        cmp     cx, 1024
   212                                  	;jnb	short L0
   213 0000001F 7351                    	jnb	short V0 ; 14/11/2020
   214                                  		 ; insufficient memory_error	
   215                                  		 ; Minimum 2 MB memory is needed... 
   216                                  	; 05/11/2014
   217                                  	; (real mode error printing)
   218 00000021 FB                      	sti
   219 00000022 BE[3600]                	mov	si, msg_out_of_memory
   220 00000025 BB0700                  	mov	bx, 7
   221 00000028 B40E                    	mov	ah, 0Eh	; write tty
   222                                  oom_1:
   223 0000002A AC                      	lodsb
   224 0000002B 08C0                    	or	al, al
   225 0000002D 7404                    	jz	short oom_2
   226 0000002F CD10                    	int	10h
   227 00000031 EBF7                    	jmp	short oom_1
   228                                  oom_2:
   229 00000033 F4                              hlt
   230 00000034 EBFD                    	jmp	short oom_2
   231                                  
   232                                  ; 20/02/2017
   233                                  ; 05/11/2014
   234                                  msg_out_of_memory:
   235 00000036 070D0A                  	db 	07h, 0Dh, 0Ah
   236 00000039 496E73756666696369-             db      'Insufficient memory !'
   237 00000042 656E74206D656D6F72-
   238 0000004B 792021             
   239 0000004E 0D0A                    	db	0Dh, 0Ah
   240                                  _int13h_48h_buffer: ; 07/07/2016
   241 00000050 284D696E696D756D20-     	db	'(Minimum 2MB memory is needed.)'
   242 00000059 324D42206D656D6F72-
   243 00000062 79206973206E656564-
   244 0000006B 65642E29           
   245 0000006F 0D0A00                   	db	0Dh, 0Ah, 0
   246                                  V0:
   247                                  	; 15/12/2020
   248 00000072 8B36[F664]              	mov	si, [mem_16m_64k]
   249 00000076 8936[CA0E]              	mov	[real_mem_16m_64k], si
   250                                  	; 15/11/2020
   251                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   252                                  	; check VESA (VBE) VIDEO BIOS version
   253                                  
   254 0000007A B8034F                  	mov	ax, 4F03h  ; Return current VBE mode
   255 0000007D CD10                    	int	10h
   256 0000007F 83F84F                  	cmp	ax, 004Fh  ; successful (vbe) function call
   257 00000082 7567                    	jne	short L0   ; not a VESA VBE compatible bios	
   258                                  
   259                                  	;mov	ah, 3
   260                                  	;;jmp	short v1	
   261                                  	
   262                                  	; 15/11/2020
   263 00000084 BBE097                  	mov	bx, VBE3INFOSEG  ; 97E0h for current version 
   264 00000087 8EC3                    	mov	es, bx
   265 00000089 31FF                    	xor	di, di
   266 0000008B 2666C70556424532        	mov	dword [es:di], 'VBE2' ; request VESA VBE3 info
   267                                  		; es:di = buffer address (512 bytes)
   268                                  	;mov	ax, 4F00h ; Return VBE controller information
   269 00000093 86C4                    	xchg	al, ah
   270 00000095 CD10                    	int	10h
   271                                  	
   272                                  	; dx = cs
   273                                  	; es = VBE3INFOSEG (97E0h)
   274                                  	; di = 0
   275                                  	; ss = (endofkernelfile/16)+16
   276                                  	; sp = 0FFFEh
   277                                  
   278 00000097 83F84F                  	cmp	ax, 004Fh
   279 0000009A 754D                    	jne	short V1 ; old vga bios (not VESA compatible)
   280                                  
   281                                  	; 15/11/2020
   282 0000009C 2666813D56455341        	cmp	dword [es:di], 'VESA'
   283 000000A4 7543                    	jne	short V1
   284                                  	
   285                                  	;mov	ax, [es:di+4]
   286                                  	;	; ax = vbe version in BCD format (0200h or 0300h)
   287                                  	;mov	[vbe3], ah ; version number (major) 	
   288                                  
   289                                  	; 15/11/2020
   290 000000A6 268A4505                	mov	al, [es:di+5]
   291                                  		; al = high byte of VBE version number (02h or 03h)
   292                                  
   293 000000AA A2[3F09]                	mov	[vbe3], al ; version number (major) 	
   294                                  			   ; 02h or 03h is expected
   295                                  	; 17/01/2021
   296                                  	; Read EDID
   297 000000AD B301                    	mov	bl, 01h	; Read EDID
   298 000000AF 31C9                    	xor	cx, cx	; Controller unit number
   299                                  			; (00 = primary controller)
   300 000000B1 31D2                    	xor	dx, dx	; EDID block number = 0
   301 000000B3 B8C097                  	mov	ax, VBE3MODEINFOSEG  ; 97C0h for current version
   302 000000B6 8EC0                    	mov	es, ax
   303 000000B8 BF0001                  	mov	di, VBE3EDIDINFOBLOCK - VBE3MODEINFOBLOCK
   304                                  	; es:di = temporary address of 128 bytes EDID information 
   305 000000BB B8154F                  	mov	ax, 4F15h ; VBE/DDC Services 
   306 000000BE CD10                    	int	10h
   307                                  	;cmp	ax, 4Fh
   308                                  	;jne	short v2
   309 000000C0 A2[5741]                	mov	[edid], al ; 4Fh > 0	
   310                                  ;V2:
   311                                  	; 17/01/2021
   312 000000C3 31FF                    	xor	di, di
   313                                  	; 15/12/2020
   314                                  	; Get linear frame buffer info (for VESA VBE mode 118h)
   315                                  	;mov	si, VBE3MODEINFOSEG  ; 97C0h for current version
   316                                  	;mov	es, si
   317                                   	; di = 0
   318 000000C5 B91841                  	mov	cx, 04118h  ; 1024*768, 24 bpp, LFB
   319 000000C8 B8014F                  	mov	ax, 4F01h ; Return VBE mode information
   320 000000CB CD10                    	int	10h
   321                                  	;cmp	ax, 4Fh
   322                                  	;jne	short V1
   323                                  	; 19/12/2020
   324                                  	;mov	si, [es:di+MODEINFO.PhysBasePtr+2]
   325                                  			; hw of LFB base address
   326                                  	; MODEINFO structure starts from offset -2
   327 000000CD 268B752A                	mov	si, [es:di+MODEINFO.PhysBasePtr] ; hw of LFB addr
   328 000000D1 8936[CC0E]              	mov	[def_LFB_addr], si ; k_LFB_size = 3145728 bytes
   329 000000D5 81EE0001                	sub	si, 256
   330                                  	
   331                                  	; 15/12/2020
   332                                  	; check memory and decrease it to 3.5 GB if it is 4GB
   333                                  	; (reserve upper memory for LFB)
   334 000000D9 8B3E[F664]              	mov	di, [mem_16m_64k]
   335 000000DD 893E[CA0E]              	mov	[real_mem_16m_64k], di
   336                                  
   337 000000E1 39F7                    	cmp	di, si
   338 000000E3 7604                    	jna	short V1
   339                                  
   340 000000E5 8936[F664]              	mov	[mem_16m_64k], si
   341                                  
   342                                  	; VESA VBE3 video hardware 
   343                                  	; (example: NVIDIA GEFORCE FX550, 256 MB)
   344                                  	; uses upper memory from 0D0000000h to 0DFFFFFFFh
   345                                  	
   346                                  	;;cmp	di, 0CF00h ; 3328 MB - 16MB
   347                                  	;jna	short V1  ; <= 3328 MB memory, it is not required
   348                                  			  ; decrease
   349                                  	;cmp	al, 3 
   350                                  	;jb	short V2 
   351                                  	; VESA VBE 3
   352                                  	;mov	word [mem_16m_64k], 0CF00h ; 3328 MB - 16MB
   353                                  	;jmp	short V1 	
   354                                  ;V2:
   355                                  	; VESA VBE 2
   356                                  	; Check Bochs/Qemu/VirtualBox Emulator
   357                                  	; LFB base address: 0E0000000h
   358                                  	;sub	ax, ax ; 0
   359                                  	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
   360                                  	;out	dx, ax ; VBE_DISPI_INDEX_ID register
   361                                  	;inc	dx
   362                                  	;in	ax, dx
   363                                  	;and	al, 0F0h
   364                                  	;cmp	ax, 0B0C0h
   365                                  	;jne	short V1
   366                                  	;
   367                                  	; BOCHS/QEMU/VIRTUALBOX
   368                                  	;mov	word [mem_16m_64k], 0DF00h ; 3584 MB - 16MB	
   369                                  V1:
   370 000000E9 1E                      	push	ds
   371 000000EA 07                      	pop	es ; restore extra data segment	
   372                                  L0:
   373                                  
   374                                  %include 'diskinit.s' ; 07/03/2015
   375                              <1> ; ****************************************************************************
   376                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskinit.s
   377                              <1> ; ----------------------------------------------------------------------------
   378                              <1> ; Last Update: 09/08/2022 (Previous: 29/08/2020 - Kernel v2.0.4)
   379                              <1> ; ----------------------------------------------------------------------------
   380                              <1> ; Beginning: 24/01/2016
   381                              <1> ; ----------------------------------------------------------------------------
   382                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
   383                              <1> ; ----------------------------------------------------------------------------
   384                              <1> ; Turkish Rational DOS
   385                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
   386                              <1> ;
   387                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
   388                              <1> ; diskinit.inc (10/07/2015)
   389                              <1> ;
   390                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
   391                              <1> ; ****************************************************************************
   392                              <1> 
   393                              <1> ; Retro UNIX 386 v1 Kernel - DISKINIT.INC
   394                              <1> ; Last Modification: 12/07/2022 (Previous: 10/07/2015)
   395                              <1> 
   396                              <1> ; DISK I/O SYSTEM INITIALIZATION - Erdogan Tan (Retro UNIX 386 v1 project)
   397                              <1> 
   398                              <1> ; ///////// DISK I/O SYSTEM STRUCTURE INITIALIZATION ///////////////
   399                              <1> 
   400                              <1> 	; 09/08/2022
   401                              <1> 	; 08/08/2022
   402                              <1> 	; 14/07/2022 (TRDOS 386 v2.0.5)
   403                              <1> 	; 12/07/2022 (Retro UNIX 386 v1.2)
   404                              <1> 	; 29/08/2020
   405                              <1> 	; 17/07/2020
   406                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
   407                              <1> 	; 10/12/2014 - 02/02/2015 - dsectrm2.s
   408                              <1> ;L0:
   409                              <1> 	; 12/11/2014 (Retro UNIX 386 v1 - beginning)
   410                              <1> 	; Detecting disk drives... (by help of ROM-BIOS)
   411 000000EB BA7F00              <1> 	mov	dx, 7Fh
   412                              <1> L1:	
   413 000000EE FEC2                <1> 	inc	dl
   414 000000F0 B441                <1> 	mov	ah, 41h ; Check extensions present
   415                              <1> 			; Phoenix EDD v1.1 - EDD v3
   416 000000F2 BBAA55              <1> 	mov	bx, 55AAh
   417 000000F5 CD13                <1> 	int 	13h
   418 000000F7 721A                <1> 	jc	short L2
   419                              <1> 
   420 000000F9 81FB55AA            <1> 	cmp	bx, 0AA55h
   421 000000FD 7514                <1> 	jne	short L2
   422 000000FF FE06[FB64]          <1> 	inc	byte [hdc]	; count of hard disks (EDD present)
   423 00000103 8816[FA64]          <1>         mov     [last_drv], dl  ; last hard disk number
   424 00000107 BB[7E64]            <1> 	mov	bx, hd0_type - 80h
   425 0000010A 01D3                <1> 	add	bx, dx	 
   426 0000010C 880F                <1> 	mov	[bx], cl ; Interface support bit map in CX
   427                              <1> 			 ; Bit 0 - 1, Fixed disk access subset ready
   428                              <1> 			 ; Bit 1 - 1, Drv locking and ejecting ready
   429                              <1> 			 ; Bit 2 - 1, Enhanced Disk Drive Support
   430                              <1>                          ;            (EDD) ready (DPTE ready)
   431                              <1> 			 ; Bit 3 - 1, 64bit extensions are present
   432                              <1>                          ;            (EDD-3)
   433                              <1> 			 ; Bit 4 to 15 - 0, Reserved
   434 0000010E 80FA83              <1> 	cmp	dl, 83h	 ; drive number < 83h
   435 00000111 72DB                <1> 	jb	short L1
   436                              <1> L2:
   437                              <1> 	; 23/11/2014
   438                              <1> 	; 19/11/2014
   439 00000113 30D2                <1> 	xor	dl, dl  ; 0
   440                              <1> 	; 04/02/2016 (esi -> si)
   441 00000115 BE[FC64]            <1> 	mov	si, fd0_type
   442                              <1> L3:
   443                              <1> 	; 14/01/2015
   444 00000118 8816[F964]          <1> 	mov	[drv], dl
   445                              <1> 	;
   446 0000011C B408                <1> 	mov 	ah, 08h ; Return drive parameters
   447 0000011E CD13                <1> 	int	13h	
   448 00000120 7210                <1> 	jc	short L4
   449                              <1> 		; BL = drive type (for floppy drives)
   450                              <1> 		; DL = number of floppy drives
   451                              <1> 		;		
   452                              <1> 		; ES:DI = Address of DPT from BIOS
   453                              <1> 		;
   454 00000122 881C                <1> 	mov	[si], bl ;  Drive type
   455                              <1> 			; 4 = 1.44 MB, 80 track, 3 1/2"
   456                              <1> 	; 14/01/2015
   457 00000124 E8DD01              <1> 	call	set_disk_parms
   458                              <1> 	; 10/12/2014
   459 00000127 81FE[FC64]          <1> 	cmp	si, fd0_type
   460 0000012B 7705                <1> 	ja	short L4
   461 0000012D 46                  <1> 	inc	si ; fd1_type
   462 0000012E B201                <1> 	mov	dl, 1
   463 00000130 EBE6                <1> 	jmp	short L3
   464                              <1> L4:
   465 00000132 B27F                <1> 	mov	dl, 7Fh
   466                              <1> 	; 24/12/2014
   467 00000134 803E[FB64]00        <1> 	cmp	byte [hdc], 0 ; EDD present or not ?	
   468                              <1> 	;ja	L10	  ; yes, all fixed disk operations
   469                              <1> 			  ; will be performed according to
   470                              <1> 			  ; present EDD specification
   471                              <1> 	; 14/07/2022
   472 00000139 7603                <1> 	jna	short L5
   473 0000013B E98B00              <1> 	jmp	L10
   474                              <1> 
   475                              <1> L5:
   476                              <1> 	; 17/07/2020
   477                              <1> 	; Note: Virtual CPU will not come here while 
   478                              <1> 	; running in QEMU, Bochs, VirtualBox emulators !!!
   479                              <1> 	
   480                              <1> 	; 17/07/2020
   481                              <1> 	; Older BIOS (INT 13h, AH = 48h is not available)
   482                              <1> 
   483 0000013E FEC2                <1> 	inc 	dl
   484 00000140 8816[F964]          <1>         mov     [drv], dl
   485 00000144 8816[FA64]          <1>         mov     [last_drv], dl ; 14/01/2015
   486 00000148 B408                <1> 	mov 	ah, 08h ; Return drive parameters
   487 0000014A CD13                <1> 	int	13h	; (conventional function)
   488                              <1> 	;jc	L13	; fixed disk drive not ready
   489                              <1> 	; 14/07/2022
   490 0000014C 7303                <1> 	jnc	short L6
   491 0000014E E9A501              <1> 	jmp	L13
   492                              <1> L6:
   493 00000151 8816[FB64]          <1>         mov     [hdc], dl ; number of drives
   494                              <1> 	;; 14/01/2013
   495                              <1> 	;;push	cx
   496 00000155 E8AC01              <1> 	call	set_disk_parms
   497                              <1> 	;;pop	cx
   498                              <1> 	;
   499                              <1> 	;;and	cl, 3Fh	 ; sectors per track (bits 0-6)
   500 00000158 8A16[F964]          <1>         mov     dl, [drv]
   501 0000015C BB0401              <1> 	mov	bx, 65*4 ; hd0 parameters table (INT 41h)	
   502 0000015F 80FA80              <1> 	cmp	dl, 80h
   503 00000162 7603                <1> 	jna	short L7
   504 00000164 83C314              <1> 	add	bx, 5*4	 ; hd1 parameters table (INT 46h)
   505                              <1> L7:	
   506 00000167 31C0                <1> 	xor	ax, ax
   507 00000169 8ED8                <1> 	mov	ds, ax
   508 0000016B 8B37                <1>         mov     si, [bx]
   509 0000016D 8B4702              <1>         mov     ax, [bx+2] 
   510 00000170 8ED8                <1> 	mov	ds, ax
   511 00000172 3A4C0E              <1>         cmp     cl, [si+FDPT_SPT] ; sectors per track 
   512                              <1> 	;jne	L12 ; invalid FDPT
   513                              <1> 	; 14/07/2022
   514 00000175 7403                <1> 	je	short L7_8
   515 00000177 E97801              <1> 	jmp	L12
   516                              <1> L7_8:
   517 0000017A BF0000              <1> 	mov	di, HD0_DPT
   518 0000017D 80FA80              <1> 	cmp	dl, 80h
   519 00000180 7603                <1> 	jna	short L8
   520 00000182 BF2000              <1> 	mov	di, HD1_DPT 
   521                              <1> L8:
   522                              <1> 	; 30/12/2014
   523 00000185 B80090              <1> 	mov	ax, DPT_SEGM
   524 00000188 8EC0                <1> 	mov	es, ax
   525                              <1> 	; 24/12/2014
   526 0000018A B90800              <1> 	mov	cx, 8
   527 0000018D F3A5                <1> 	rep	movsw  ; copy 16 bytes to the kernel's DPT location
   528 0000018F 8CC8                <1> 	mov	ax, cs
   529 00000191 8ED8                <1> 	mov	ds, ax
   530                              <1> 
   531                              <1> 	; 02/02/2015
   532                              <1> 	;mov	cl, [drv]
   533                              <1> 	;mov	bl, cl
   534                              <1> 	;mov	ax, 1F0h
   535                              <1> 	;and	bl, 1
   536                              <1> 	;jz	short L9
   537                              <1> 	;shl	bl, 4
   538                              <1> 	;sub	ax, 1F0h-170h
   539                              <1> 
   540                              <1> 	; 17/07/2020 
   541                              <1> 	; (Only 1F0h port address must be valid for old ROM BIOSes)
   542 00000193 B8F001              <1> 	mov	ax, 1F0h
   543 00000196 B3A0                <1> 	mov	bl, 0A0h
   544 00000198 80FA80              <1> 	cmp	dl, 80h
   545 0000019B 7603                <1> 	jna	short L9
   546                              <1> 	; dl = 81h
   547 0000019D 80C310              <1> 	add	bl, 10h  ; slave disk
   548                              <1> 	;sub	ax, 1F0h-170h
   549                              <1> L9:
   550 000001A0 AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   551 000001A1 050602              <1> 	add	ax, 206h
   552 000001A4 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   553 000001A5 88D8                <1> 	mov	al, bl  ; bit 4, master/slave disk bit
   554                              <1> 	;add	al, 0A0h ; 17/07/2020
   555 000001A7 AA                  <1> 	stosb	; Device/Head Register upper nibble
   556                              <1> 	;
   557 000001A8 FE06[F964]          <1> 	inc	byte [drv]
   558                              <1> 	;mov	bx, hd0_type - 80h
   559                              <1> 	;add	bx, cx
   560                              <1> 	; 09/08/2022 - BugFix
   561 000001AC 30FF                <1> 	xor	bh, bh
   562 000001AE 88D3                <1> 	mov	bl, dl
   563 000001B0 81C3[7E64]          <1> 	add	bx, hd0_type - 80h
   564 000001B4 800F80              <1> 	or      byte [bx], 80h  ; present sign (when lower nibble is 0)
   565 000001B7 A0[FB64]            <1> 	mov	al, [hdc]
   566 000001BA FEC8                <1> 	dec	al
   567                              <1> 	;jz	L13
   568                              <1> 	; 14/07/2022
   569 000001BC 7408                <1> 	jz	short L9_10
   570 000001BE 80FA80              <1> 	cmp	dl, 80h
   571                              <1>         ;jna	L5 ; Max. 2 hard disks  ; 17/07/2020
   572                              <1> 	; 14/07/2022
   573 000001C1 7703                <1> 	ja	short L9_10
   574 000001C3 E978FF              <1> 	jmp	L5
   575                              <1> L9_10:
   576 000001C6 E92D01              <1>         jmp     L13
   577                              <1> L10:
   578 000001C9 FEC2                <1> 	inc 	dl
   579                              <1> 	; 25/12/2014
   580 000001CB 8816[F964]          <1> 	mov	[drv], dl
   581 000001CF B408                <1> 	mov 	ah, 08h ; Return drive parameters
   582 000001D1 CD13                <1> 	int	13h	; (conventional function)
   583                              <1> 	;jc	L13
   584                              <1> 	; 14/07/2022
   585 000001D3 72F1                <1> 	jc	short L9_10
   586                              <1> 	; 14/01/2015
   587                              <1> 	;mov	dl, [drv]
   588                              <1> 	; 09/08/2022
   589                              <1> 	;push	dx
   590 000001D5 51                  <1> 	push	cx
   591 000001D6 E82B01              <1> 	call	set_disk_parms
   592 000001D9 59                  <1> 	pop	cx
   593                              <1> 	;pop	dx
   594                              <1> 	; 09/08/2022
   595 000001DA 8A16[F964]          <1> 	mov	dl, [drv]	
   596                              <1> 	; 06/07/2016 (BugFix for >64K kernel files)
   597                              <1> 	; 04/02/2016 (esi -> si)
   598                              <1> 	;mov	si, _end ; 30 byte temporary buffer address 	
   599                              <1> 	;		 ; at the '_end' of kernel.
   600                              <1> 	;mov	word [si], 30
   601                              <1> 	; 06/07/2016
   602 000001DE BE[5000]            <1> 	mov	si, _int13h_48h_buffer
   603                              <1> 	; 09/07/2016
   604 000001E1 B81E00              <1> 	mov	ax, 001Eh
   605 000001E4 8824                <1> 	mov	[si], ah ; 0
   606 000001E6 46                  <1> 	inc	si
   607 000001E7 8904                <1> 	mov	[si], ax
   608                              <1>  	; word [si] = 30
   609                              <1> 	;
   610 000001E9 B448                <1> 	mov	ah, 48h	 ; Get drive parameters (EDD function)
   611 000001EB CD13                <1> 	int	13h
   612                              <1> 	;jc	L13
   613                              <1> 	; 14/07/2022
   614 000001ED 72D7                <1> 	jc	short L9_10
   615                              <1> 
   616                              <1> 	; 29/08/2020
   617                              <1> 	; 04/02/2016 (ebx -> bx)
   618                              <1> 	; 14/01/2015
   619 000001EF 28FF                <1> 	sub	bh, bh
   620 000001F1 88D3                <1> 	mov	bl, dl
   621                              <1> 	;sub	bl, 80h
   622                              <1> 	; 29/08/2020
   623 000001F3 81C3[7E64]          <1> 	add	bx, (hd0_type - 80h)
   624                              <1> 	;mov 	al, [bx]
   625 000001F7 8A07                <1> 	mov	al, [bx]
   626 000001F9 0C80                <1> 	or	al, 80h
   627 000001FB 8807                <1> 	mov 	[bx], al	
   628 000001FD 81EB[FC64]          <1> 	sub	bx, hd0_type - 2 ; 15/01/2015
   629                              <1> 	;add	bx, drv.status
   630                              <1> 	;mov	[bx], al
   631                              <1> 	; 29/08/2020
   632 00000201 8887[1E65]          <1> 	mov	[bx+drv.status], al
   633                              <1> 	; 04/02/2016 (eax -> ax)
   634                              <1> 	;mov	ax, [si+16]
   635                              <1> 	; 14/07/2020
   636                              <1> 	;mov	di, [si+18] 
   637                              <1> 	;;test	ax, [si+18]
   638                              <1> 	;test	ax, di ; 14/07/2020
   639                              <1> 	;jz	short L10_A0h ; (!) ; 17/07/2020
   640                              <1> 			; 'CHS only' disks on EDD system 
   641                              <1> 			;  are reported with ZERO disk size
   642                              <1> 			; (if so, we must not overwrite
   643                              <1> 			; calculated disk size in 'set_disk_parms')
   644                              <1> 	; 29/08/2020
   645 00000205 8B4410              <1> 	mov	ax, [si+16]
   646 00000208 8B7C12              <1> 	mov	di, [si+18]
   647 0000020B 09C0                <1> 	or	ax, ax
   648 0000020D 7504                <1> 	jnz	short L10_LBA
   649 0000020F 09FF                <1> 	or	di, di
   650 00000211 740B                <1> 	jz	short L10_A0h
   651                              <1> L10_LBA:
   652                              <1> 	;sub	bx, drv.status
   653 00000213 C1E302              <1> 	shl	bx, 2
   654                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   655                              <1> 	;mov	[bx], ax
   656                              <1> 	; 29/08/2020
   657 00000216 8987[0265]          <1> 	mov	[bx+drv.size], ax
   658                              <1> 	;mov	ax, [si+18]
   659                              <1> 	;;mov	[bx], ax
   660                              <1> 	;mov	[bx+2], ax ; BugFix ; 15/07/2020
   661                              <1> 	; 14/07/2020
   662                              <1> 	;mov	[bx+2], di ; 15/07/2020
   663                              <1> 	; 29/08/2020
   664 0000021A 89BF[0465]          <1> 	mov	[bx+drv.size+2], di
   665                              <1> L10_A0h: 
   666                              <1> 	; 17/07/2020
   667                              <1> 	; Note: Virtual CPU will jump here from above (!) test
   668                              <1> 	;	while running in QEMU
   669                              <1> 
   670                              <1> 	; Jump here to fix a ZERO (LBA) disk size problem 
   671                              <1> 	; for CHS disks (28/02/2015)
   672                              <1> 	
   673                              <1> 	; 30/12/2014
   674 0000021E BF0000              <1> 	mov	di, HD0_DPT
   675 00000221 88D0                <1> 	mov	al, dl
   676 00000223 83E003              <1> 	and 	ax, 3
   677 00000226 C0E005              <1> 	shl	al, 5 ; * 32
   678 00000229 01C7                <1> 	add 	di, ax
   679 0000022B B80090              <1> 	mov	ax, DPT_SEGM
   680 0000022E 8EC0                <1> 	mov	es, ax
   681                              <1> 	;
   682 00000230 88E8                <1> 	mov	al, ch	; max. cylinder number (bits 0-7)
   683 00000232 88CC                <1> 	mov	ah, cl	
   684 00000234 C0EC06              <1> 	shr	ah, 6	; max. cylinder number (bits 8-9)
   685 00000237 40                  <1>  	inc	ax	; logical cylinders (limit 1024)
   686 00000238 AB                  <1> 	stosw		
   687 00000239 88F0                <1> 	mov	al, dh	; max. head number
   688                              <1> 	;
   689 0000023B 30F6                <1> 	xor	dh, dh  ; 29/08/2020 (dh = 0 is needed here)
   690                              <1> 	;
   691 0000023D FEC0                <1> 	inc	al
   692 0000023F AA                  <1> 	stosb		; logical heads (limits 256)
   693 00000240 B0A0                <1> 	mov	al, 0A0h ; Indicates translated table
   694 00000242 AA                  <1> 	stosb
   695 00000243 8A440C              <1> 	mov	al, [si+12]
   696 00000246 AA                  <1> 	stosb		 ; physical sectors per track
   697 00000247 31C0                <1>  	xor	ax, ax
   698                              <1> 	;dec	ax	 ; 02/01/2015 
   699 00000249 AB                  <1> 	stosw		 ; precompensation (obsolete)
   700                              <1> 	;xor	al, al	 ; 02/01/2015	
   701 0000024A AA                  <1> 	stosb		 ; reserved
   702 0000024B B008                <1> 	mov	al, 8	 ; drive control byte
   703                              <1> 		         ; (do not disable retries, 
   704                              <1> 			 ; more than 8 heads)
   705 0000024D AA                  <1> 	stosb
   706 0000024E 8B4404              <1> 	mov	ax, [si+4]
   707 00000251 AB                  <1> 	stosw		 ; physical number of cylinders	
   708                              <1> 	;push	ax	 ; 02/01/2015
   709 00000252 8A4408              <1> 	mov	al, [si+8]
   710 00000255 AA                  <1> 	stosb		 ; physical num. of heads (limit 16)
   711 00000256 29C0                <1> 	sub 	ax, ax
   712                              <1> 	;pop	ax	 ; 02/01/2015	
   713 00000258 AB                  <1> 	stosw		 ; landing zone (obsolete)
   714 00000259 88C8                <1> 	mov	al, cl	 ; logical sectors per track (limit 63)
   715 0000025B 243F                <1> 	and 	al, 3Fh	
   716 0000025D AA                  <1> 	stosb
   717                              <1> 	;sub	al, al	 ; checksum
   718                              <1> 	;stosb
   719                              <1> 	;
   720 0000025E 83C61A              <1> 	add	si, 26   ; (BIOS) DPTE address pointer
   721 00000261 AD                  <1> 	lodsw
   722 00000262 50                  <1> 	push	ax ; *	 ; (BIOS) DPTE offset
   723 00000263 AD                  <1> 	lodsw
   724 00000264 50                  <1> 	push	ax ; **	 ; (BIOS) DPTE segment
   725                              <1> 	;
   726                              <1> 	; checksum calculation
   727 00000265 89FE                <1> 	mov	si, di
   728 00000267 06                  <1> 	push	es
   729 00000268 1F                  <1> 	pop	ds
   730                              <1> 	;mov	cx, 16
   731 00000269 B90F00              <1> 	mov 	cx, 15
   732 0000026C 29CE                <1> 	sub	si, cx
   733 0000026E 30E4                <1> 	xor	ah, ah
   734                              <1> 	;del	cl
   735                              <1> L11:		
   736 00000270 AC                  <1> 	lodsb
   737 00000271 00C4                <1> 	add	ah, al
   738 00000273 E2FB                <1> 	loop	L11
   739                              <1> 	;
   740 00000275 88E0                <1> 	mov	al, ah
   741 00000277 F6D8                <1> 	neg	al	; -x+x = 0
   742 00000279 AA                  <1> 	stosb		; put checksum in byte 15 of the tbl
   743                              <1> 	;
   744 0000027A 1F                  <1> 	pop	ds ; **	; (BIOS) DPTE segment
   745 0000027B 5E                  <1> 	pop	si ; *	; (BIOS) DPTE offset	
   746                              <1> 
   747                              <1> 	; 08/08/2022 (TRDOS 386 v2.0.5)
   748                              <1> 	; (Recent version of Retro UNIX 386 v1 'diskinit.s' file
   749                              <1> 	; -12/07/2022- does not contain following 2020 code) (*)
   750                              <1> 
   751                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
   752                              <1> 	; 0FFFFh:0FFFFh = invalid DPTE address
   753 0000027C 8B0C                <1> 	mov	cx, [si]
   754 0000027E 8B4402              <1> 	mov	ax, [si+2]
   755 00000281 21C1                <1> 	and	cx, ax
   756 00000283 41                  <1> 	inc	cx 
   757 00000284 7404                <1> 	jz	short L11c ; 0FFFFh:0FFFFh
   758 00000286 0B04                <1> 	or	ax, [si]
   759 00000288 752A                <1> 	jnz	short L11e ; <> 0
   760                              <1> L11c:
   761                              <1> 	; 17/07/2020
   762                              <1> 	; TRDOS 386 v2 DRVINIT assumptions:
   763                              <1> 	; (also by regarding QEMU, Bochs and VirtualBox settings)
   764                              <1> 	;	Hard disk 0 port address: 1F0h
   765                              <1> 	;	Hard disk 1 port address: 1F0h
   766                              <1> 	;	Hard disk 2 port address: 170h
   767                              <1> 	;	Hard disk 3 port address: 170h
   768                              <1> 
   769                              <1> 	; in QEMU, hda=hd0 (1F0h) and hdb=hd1 (1F0h) -IRQ14-
   770                              <1> 	;      and hdc=hd2 (170h) and hdd=hd3 (170h) -IRQ15-
   771                              <1> 
   772 0000028A B8F001              <1> 	mov	ax, 1F0h
   773                              <1> 
   774                              <1> 	; 15/07/2020
   775                              <1> 	; 14/07/2020
   776                              <1> 	; Invalid DPTE address...
   777                              <1> 	; Default DPTE parms must be set for DISK_IO_CONT
   778                              <1> 	; (diskio.s)
   779                              <1> 	; 17/07/2020
   780                              <1> 
   781                              <1> 	;mov	bl, dl
   782                              <1> 	;and	bl, 1
   783                              <1> 	;jz	short L11d
   784                              <1> 
   785 0000028D B3A0                <1> 	mov	bl, 0A0h
   786                              <1> 
   787 0000028F F6C201              <1> 	test	dl, 1
   788 00000292 7403                <1> 	jz	short L11g  ; Master (as default, for 80h & 82h))
   789                              <1> 	;shl	bl, 4 ; bl = 16 (bit 4 = 1 -> slave)
   790 00000294 80C310              <1> 	add	bl, 10h  ; Slave (as default, for 81h & 83h)
   791                              <1> L11g:
   792                              <1> 	; 17/07/2020
   793 00000297 80FA82              <1> 	cmp	dl, 82h	; Hard disk 3 or 4 ?
   794 0000029A 7203                <1> 	jb	short L11d ; Primary ATA channel (hd0, hd1)
   795                              <1> 			   ; (port address = 1F0h)
   796                              <1> 	
   797                              <1> 	; Secondary ATA channel (hd2, hd3)
   798                              <1> 	; (port address = 170h)
   799                              <1> 
   800 0000029C 2D8000              <1> 	sub	ax, 1F0h-170h
   801                              <1> L11d:
   802                              <1> 	; 14/07/2020
   803 0000029F AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   804 000002A0 050602              <1> 	add	ax, 206h
   805 000002A3 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   806 000002A4 88D8                <1> 	mov	al, bl  ; Master/Slave bit (0 = Master)
   807                              <1> 	; 17/07/2020
   808                              <1> 	;or	al, 0A0h ; CHS (LBA enable bit = 0)
   809                              <1> 			 ; (Bits 5&7, reserved bits  =  1)
   810 000002A6 30E4                <1> 	xor	ah, ah
   811                              <1> 	;stosb	; Device/Head Register upper nibble
   812 000002A8 AB                  <1> 	stosw
   813 000002A9 30C0                <1> 	xor	al, al
   814 000002AB B90500              <1> 	mov	cx, 5
   815 000002AE F3AB                <1> 	rep	stosw ; clear remain part of the (fake) DPTE
   816 000002B0 0E                  <1> 	push	cs
   817 000002B1 1F                  <1> 	pop	ds
   818 000002B2 EB2E                <1> 	jmp	short L11f
   819                              <1> 
   820                              <1> 	; 08/08/2022 (TRDOS 386 v2.0.5)
   821                              <1> 	; (Recent version of Retro UNIX 386 v1 'diskinit.s' file
   822                              <1> 	; -12/07/2022- does not contain above 2020 code) (*)
   823                              <1> L11e:
   824                              <1> 	; 23/02/2015
   825 000002B4 57                  <1> 	push	di
   826                              <1> 	; ES:DI points to DPTE (FDPTE) location
   827                              <1> 	;;mov	cx, 8
   828                              <1> 	;mov	cl, 8
   829 000002B5 B90800              <1> 	mov	cx, 8 ; 14/07/2020
   830 000002B8 F3A5                <1> 	rep	movsw	
   831                              <1> 	;
   832                              <1> 	; 23/02/2015
   833                              <1> 	; (P)ATA drive and LBA validation
   834                              <1> 	; (invalidating SATA drives and setting
   835                              <1> 	; CHS type I/O for old type fixed disks)
   836 000002BA 5B                  <1> 	pop	bx
   837 000002BB 8CC8                <1> 	mov	ax, cs
   838 000002BD 8ED8                <1> 	mov	ds, ax
   839 000002BF 268B07              <1> 	mov	ax, [es:bx]
   840 000002C2 3DF001              <1> 	cmp	ax, 1F0h
   841 000002C5 7413                <1> 	je	short L11a
   842 000002C7 3D7001              <1> 	cmp	ax, 170h
   843 000002CA 740E                <1> 	je	short L11a
   844                              <1> 	; invalidation 
   845                              <1> 	; (because base port address is not 1F0h or 170h)
   846                              <1> 	;xor	bh, bh
   847                              <1> 	;mov	bl, dl
   848                              <1> 	; 29/08/2020
   849                              <1> 	;xor	dh, dh ; 0
   850 000002CC 89D3                <1> 	mov	bx, dx
   851                              <1> 	;sub	bl, 80h
   852                              <1> 	;mov	byte [bx+hd0_type], 0 ; not a valid disk drive !		
   853                              <1>         ;or	byte [bx+drv.status+2], 0F0h ; (failure sign)
   854                              <1> 	; 29/08/2020
   855 000002CE C687[7E64]00        <1> 	mov	byte [bx+hd0_type-80h], 0
   856 000002D3 808F[A064]F0        <1> 	or	byte [bx+drv.status-7Eh], 0F0h
   857 000002D8 EB0F                <1> 	jmp	short L11b
   858                              <1> L11a:	
   859                              <1> 	; LBA validation
   860 000002DA 268A4704            <1> 	mov	al, [es:bx+4] ; Head register upper nibble
   861 000002DE A840                <1> 	test	al, 40h ; LBA bit (bit 6)
   862 000002E0 7507                <1> 	jnz	short L11b ; LBA type I/O is OK! (E0h or F0h)
   863                              <1> L11f:
   864                              <1> 	; force CHS type I/O for this drive (A0h or B0h)
   865                              <1> 	;sub	bh, bh
   866                              <1> 	;mov	bl, dl
   867                              <1> 	; 29/08/2020
   868                              <1> 	;xor	dh, dh ; 0
   869 000002E2 89D3                <1> 	mov	bx, dx
   870                              <1> 	;sub	bl, 80h ; 26/02/2015
   871                              <1>         ;and	byte [bx+drv.status+2], 0FEh ; clear bit 0
   872                              <1> 				; bit 0 = LBA ready bit
   873                              <1> 	; 29/08/2020
   874 000002E4 80A7[A064]FE        <1> 	and	byte [bx+drv.status-7Eh], 0FEh
   875                              <1> 	; 'diskio' procedure will check this bit !
   876                              <1> L11b:
   877 000002E9 3A16[FA64]          <1> 	cmp	dl, [last_drv] ; 25/12/2014
   878 000002ED 7307                <1>         jnb     short L13
   879 000002EF E9D7FE              <1>         jmp     L10
   880                              <1> 
   881                              <1> L12:
   882                              <1> 	; Restore data registers
   883 000002F2 8CC8                <1> 	mov	ax, cs
   884 000002F4 8ED8                <1> 	mov	ds, ax	
   885                              <1> L13:
   886                              <1> 	; 13/12/2014
   887 000002F6 0E                  <1> 	push	cs
   888 000002F7 07                  <1> 	pop	es
   889                              <1> L14:
   890                              <1> 	; clear keyboard buffer
   891 000002F8 B411                <1> 	mov 	ah, 11h
   892 000002FA CD16                <1> 	int 	16h
   893 000002FC 7440                <1> 	jz 	short L16 ; no keys in keyboard buffer
   894 000002FE B010                <1> 	mov	al, 10h
   895 00000300 CD16                <1> 	int 	16h
   896 00000302 EBF4                <1> 	jmp 	short L14
   897                              <1> 
   898                              <1> set_disk_parms:
   899                              <1> 	; 08/08/2022 - TRDOS 386 v2.0.5
   900                              <1> 	; 09/05/2022 - Retro UNIX 386 v1.2
   901                              <1> 	; 29/08/2020 - TRDOS 386 v2.0.2
   902                              <1> 	; 04/02/2016 (ebx -> bx)
   903                              <1> 	; 10/07/2015
   904                              <1> 	; 14/01/2015
   905                              <1> 	;push	bx
   906 00000304 28FF                <1> 	sub	bh, bh
   907 00000306 8A1E[F964]          <1> 	mov	bl, [drv]
   908 0000030A 80FB80              <1> 	cmp	bl, 80h
   909 0000030D 7203                <1> 	jb	short sdp0
   910 0000030F 80EB7E              <1> 	sub	bl, 7Eh
   911                              <1> sdp0:	
   912                              <1> 	;add	bx, drv.status
   913                              <1>   	;mov	byte [bx], 80h ; 'Present' flag
   914                              <1> 	; 29/08/2020
   915 00000312 C687[1E65]80        <1> 	mov	byte [bx+drv.status], 80h
   916                              <1> 	;
   917 00000317 88E8                <1> 	mov	al, ch ; last cylinder (bits 0-7)
   918 00000319 88CC                <1> 	mov	ah, cl ; 
   919 0000031B C0EC06              <1> 	shr	ah, 6  ; last cylinder (bits 8-9)
   920                              <1> 	;sub	bx, drv.status
   921 0000031E D0E3                <1> 	shl	bl, 1
   922                              <1> 	;add	bx, drv.cylinders
   923 00000320 40                  <1> 	inc	ax  ; convert max. cyl number to cyl count
   924                              <1> 	;mov	[bx], ax
   925                              <1> 	; 08/08/2022
   926                              <1> 	; 29/08/2020
   927                              <1> 	;mov	[bx+drv.cylinders], ax
   928                              <1> 	;
   929 00000321 50                  <1> 	push	ax ; ** cylinders
   930                              <1> 	;sub	bx, drv.cylinders
   931                              <1> 	;add	bx, drv.heads
   932 00000322 30E4                <1> 	xor	ah, ah
   933 00000324 88F0                <1> 	mov	al, dh ; heads
   934 00000326 40                  <1> 	inc	ax
   935                              <1> 	;mov	[bx], ax
   936                              <1> 	; 08/08/2022
   937                              <1> 	; 29/08/2020
   938                              <1> 	;mov	[bx+drv.heads], ax
   939                              <1> 	;sub	bx, drv.heads
   940                              <1>         ;add	bx, drv.spt
   941 00000327 30ED                <1> 	xor	ch, ch
   942 00000329 80E13F              <1> 	and	cl, 3Fh	; sectors (bits 0-6)
   943                              <1> 	;mov	[bx], cx
   944                              <1>         ; 08/08/2022
   945                              <1> 	; 29/08/2020
   946                              <1> 	;mov	[bx+drv.spt], cx
   947                              <1> 	;sub	bx, drv.spt
   948 0000032C D1E3                <1> 	shl	bx, 1
   949                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   950                              <1> 	; LBA size = cylinders * heads * secpertrack
   951 0000032E F7E1                <1> 	mul	cx 
   952 00000330 89C2                <1> 	mov	dx, ax	; heads*spt
   953 00000332 58                  <1> 	pop	ax ; ** cylinders
   954                              <1> 	; 09/05/2022 (fd0&fd1 drv.size = cyls*spt*heads)
   955                              <1> 	;dec	ax ; 1 cylinder reserved (!?) ; (*)
   956 00000333 F7E2                <1> 	mul	dx ; cylinders * (heads*spt)
   957                              <1> 	;mov	[bx], ax
   958                              <1> 	;mov	[bx+2], dx
   959                              <1> 	; 29/08/2020
   960 00000335 8987[0265]          <1> 	mov	[bx+drv.size], ax
   961 00000339 8997[0465]          <1> 	mov	[bx+drv.size+2], dx
   962                              <1> 	;
   963                              <1> 	;pop	bx
   964 0000033D C3                  <1> 	retn
   965                              <1> 
   966                              <1> L16:	; 28/05/2016
   967                                  
   968                                  	; 10/11/2014
   969 0000033E FA                           	cli	; Disable interrupts (clear interrupt flag)
   970                                  		; Reset Interrupt MASK Registers (Master&Slave)
   971                                  	;mov	al, 0FFh	; mask off all interrupts
   972                                  	;out	21h, al		; on master PIC (8259)
   973                                  	;jmp 	$+2  ; (delay)
   974                                  	;out	0A1h, al	; on slave PIC (8259)
   975                                  	;
   976                                  	; Disable NMI 
   977 0000033F B080                    	mov   	al, 80h 
   978 00000341 E670                    	out   	70h, al		; set bit 7 to 1 for disabling NMI
   979                                  	;23/02/2015
   980                                  	;nop			;
   981                                  	;in	al, 71h		; read in 71h just after writing out to 70h
   982                                  				; for preventing unknown state (!?)
   983                                  	;
   984                                   	; 20/08/2014
   985                                  	; Moving the kernel 64 KB back (to physical address 0)
   986                                  	; DS = CS = 1000h
   987                                  	; 05/11/2014
   988 00000343 31C0                    	xor	ax, ax
   989 00000345 8EC0                    	mov	es, ax ; ES = 0
   990                                  	;
   991                                  	; 04/07/2016 - TRDOS 386 (64K - 128K kernel)
   992 00000347 31F6                          	xor	si, si
   993 00000349 31FF                    	xor	di, di
   994 0000034B B90040                  	mov	cx, 16384
   995 0000034E F366A5                  	rep	movsd
   996                                  	;
   997 00000351 06                      	push	es ; 0
   998 00000352 68[5603]                	push	L17
   999 00000355 CB                      	retf
  1000                                  L17:
  1001 00000356 B90010                  	mov	cx, 1000h
  1002 00000359 8EC1                    	mov	es, cx  ; 1000h 
  1003 0000035B 01C9                    	add	cx, cx
  1004 0000035D 8ED9                    	mov	ds, cx  ; 2000h
  1005 0000035F 29F6                    	sub	si, si
  1006 00000361 29FF                    	sub	di, di
  1007 00000363 B90040                  	mov	cx, 16384
  1008 00000366 F366A5                  	rep	movsd
  1009                                  	
  1010                                  	; Turn off the floppy drive motor
  1011 00000369 BAF203                          mov     dx, 3F2h
  1012 0000036C EE                              out     dx, al ; 0 ; 31/12/2013
  1013                                  
  1014                                  	; Enable access to memory above one megabyte
  1015                                  L18:
  1016 0000036D E464                    	in	al, 64h
  1017 0000036F A802                    	test	al, 2
  1018 00000371 75FA                            jnz     short L18
  1019 00000373 B0D1                    	mov	al, 0D1h	; Write output port
  1020 00000375 E664                    	out	64h, al
  1021                                  L19:
  1022 00000377 E464                    	in	al, 64h
  1023 00000379 A802                    	test	al, 2
  1024 0000037B 75FA                            jnz     short L19
  1025 0000037D B0DF                    	mov	al, 0DFh	; Enable A20 line
  1026 0000037F E660                    	out	60h, al
  1027                                  ;L20:
  1028                                  	;
  1029                                  	; Load global descriptor table register
  1030                                  
  1031                                          ;mov     ax, cs
  1032                                          ;mov     ds, ax
  1033                                  
  1034 00000381 2E0F0116[6864]                  lgdt    [cs:gdtd]
  1035                                  
  1036 00000387 0F20C0                          mov     eax, cr0
  1037                                  	;or 	al, 1	; 24/07/2022
  1038 0000038A 40                      	inc	ax
  1039 0000038B 0F22C0                  	mov     cr0, eax
  1040                                  
  1041                                  	; Jump to 32 bit code
  1042                                  	
  1043 0000038E 66                      	db	66h 		; Prefix for 32-bit
  1044 0000038F EA                      	db	0EAh		; Opcode for far jump
  1045 00000390 [96030000]              	dd	StartPM		; Offset to start, 32-bit
  1046                                  				; (1000h:StartPM = StartPM + 10000h)
  1047 00000394 0800                    	dw	KCODE		; This is the selector for CODE32_DESCRIPTOR,
  1048                                  				; assuming that StartPM resides in code32
  1049                                  
  1050                                  ; 20/02/2017
  1051                                  
  1052                                  
  1053                                  [BITS 32] 
  1054                                  
  1055                                  StartPM:
  1056                                  	; Kernel Base Address = 0 ; 30/12/2013
  1057 00000396 66B81000                	mov	ax, KDATA 	; Save data segment identifier
  1058 0000039A 8ED8                            mov	ds, ax		; Move a valid data segment into DS register
  1059 0000039C 8EC0                           	mov	es, ax		; Move data segment into ES register
  1060 0000039E 8EE0                           	mov	fs, ax		; Move data segment into FS register
  1061 000003A0 8EE8                          	mov	gs, ax		; Move data segment into GS register
  1062 000003A2 8ED0                            mov	ss, ax		; Move data segment into SS register
  1063 000003A4 BC00000900                      mov	esp, 90000h	; Move the stack pointer to 090000h
  1064                                  
  1065                                  clear_bss: ; Clear uninitialized data area
  1066                                  	; 11/03/2015
  1067 000003A9 31C0                    	xor	eax, eax ; 0
  1068 000003AB B9F3660000              	mov	ecx, (bss_end - bss_start)/4
  1069                                  	;shr	ecx, 2 ; bss section is already aligned for double words
  1070 000003B0 BF[92740100]            	mov	edi, bss_start	
  1071 000003B5 F3AB                    	rep	stosd  		
  1072                                  
  1073                                  memory_init:
  1074                                  	; Initialize memory allocation table and page tables
  1075                                  	; 24/07/2022 (TRDOS 386 v2.0.5)
  1076                                  	; 18/04/2021 (TRDOS 386 v2.0.4)
  1077                                  	; 16/11/2014
  1078                                  	; 15/11/2014
  1079                                  	; 07/11/2014
  1080                                  	; 06/11/2014
  1081                                  	; 05/11/2014
  1082                                  	; 04/11/2014
  1083                                  	; 31/10/2014 (Retro UNIX 386 v1 - Beginning) 
  1084                                  	;
  1085                                  ;	xor	eax, eax
  1086                                  ;	xor 	ecx, ecx
  1087 000003B7 B108                    	mov	cl, 8
  1088 000003B9 BF00001000              	mov	edi, MEM_ALLOC_TBL	
  1089 000003BE F3AB                    	rep	stosd		   ; clear Memory Allocation Table
  1090                                  				   ; for the first 1 MB memory
  1091                                  	;
  1092 000003C0 668B0D[F4640000]        	mov	cx, [mem_1m_1k]	   ; Number of contiguous KB between
  1093                                  				   ; 1 and 16 MB, max. 3C00h = 15 MB.
  1094                                  	;shr	cx, 2		   ; convert 1 KB count to 4 KB count
  1095                                  	; 24/07/2022
  1096 000003C7 C1E902                  	shr	ecx, 2
  1097 000003CA 890D[88770100]          	mov	[free_pages], ecx
  1098 000003D0 668B15[F6640000]        	mov	dx, [mem_16m_64k]  ; Number of contiguous 64 KB blocks
  1099                                  				   ; between 16 MB and 4 GB.	
  1100 000003D7 6609D2                  	or	dx, dx
  1101 000003DA 7413                    	jz	short mi_0
  1102                                  	;
  1103 000003DC 6689D0                  	mov	ax, dx
  1104 000003DF C1E004                  	shl	eax, 4		   ; 64 KB -> 4 KB (page count)
  1105 000003E2 0105[88770100]          	add	[free_pages], eax
  1106 000003E8 0500100000              	add	eax, 4096	   ; 16 MB = 4096 pages
  1107 000003ED EB06                    	jmp	short mi_1
  1108                                  mi_0:
  1109                                  	;mov	ax, cx
  1110                                  	; 24/07/2022
  1111 000003EF 89C8                    	mov	eax, ecx
  1112 000003F1 66050001                	add	ax, 256		   ; add 256 pages for the first 1 MB		 
  1113                                  mi_1:
  1114 000003F5 A3[84770100]            	mov	[memory_size], eax ; Total available memory in pages
  1115                                  				   ; 1 alloc. tbl. bit = 1 memory page
  1116                                  				   ; 32 allocation bits = 32 mem. pages   
  1117                                  	;
  1118 000003FA 05FF7F0000              	add	eax, 32767	   ; 32768 memory pages per 1 M.A.T. page 	
  1119 000003FF C1E80F                  	shr	eax, 15		   ; ((32768 * x) + y) pages (y < 32768)
  1120                                  				   ;  --> x + 1 M.A.T. pages, if y > 0
  1121                                  				   ;  --> x M.A.T. pages, if y = 0
  1122 00000402 66A3[98770100]          	mov	[mat_size], ax	   ; Memory Alloc. Table Size in pages		
  1123 00000408 C1E00C                  	shl	eax, 12		   ; 1 M.A.T. page = 4096 bytes
  1124                                  	;			   ; Max. 32 M.A.T. pages (4 GB memory)
  1125 0000040B 89C3                    	mov	ebx, eax	   ; M.A.T. size in bytes
  1126                                  	; Set/Calculate Kernel's Page Directory Address
  1127 0000040D 81C300001000            	add	ebx, MEM_ALLOC_TBL
  1128 00000413 891D[80770100]          	mov	[k_page_dir], ebx  ; Kernel's Page Directory address
  1129                                  				   ; just after the last M.A.T. page
  1130                                  	;
  1131 00000419 83E804                  	sub	eax, 4		   ; convert M.A.T. size to offset value
  1132 0000041C A3[90770100]            	mov	[last_page], eax   ; last page ofset in the M.A.T.
  1133                                  	;			   ; (allocation status search must be 
  1134                                  				   ; stopped after here)	
  1135 00000421 31C0                    	xor	eax, eax
  1136 00000423 48                      	dec	eax		   ; FFFFFFFFh (set all bits to 1)	
  1137                                  	;push	cx
  1138                                  	; 18/04/2021
  1139 00000424 51                      	push	ecx
  1140 00000425 C1E905                  	shr	ecx, 5		   ; convert 1 - 16 MB page count to 
  1141                                  				   ; count of 32 allocation bits
  1142 00000428 F3AB                    	rep	stosd
  1143                                  	;pop	cx
  1144                                  	; 18/04/2021
  1145 0000042A 59                      	pop	ecx
  1146 0000042B 40                      	inc	eax		   ; 0	
  1147 0000042C 80E11F                  	and	cl, 31		   ; remain bits
  1148 0000042F 7412                    	jz	short mi_4
  1149 00000431 8907                    	mov	[edi], eax	   ; reset	
  1150                                  mi_2:
  1151 00000433 0FAB07                  	bts	[edi], eax	   ; 06/11/2014		
  1152 00000436 FEC9                    	dec	cl
  1153 00000438 7404                    	jz	short mi_3
  1154 0000043A FEC0                    	inc	al
  1155 0000043C EBF5                    	jmp	short mi_2
  1156                                  mi_3:
  1157 0000043E 28C0                    	sub	al, al	   	   ; 0
  1158 00000440 83C704                  	add	edi, 4		   ; 15/11/2014
  1159                                  mi_4:
  1160 00000443 6609D2                  	or	dx, dx		  ; check 16M to 4G memory space	
  1161 00000446 7421                    	jz	short mi_6	  ; max. 16 MB memory, no more...
  1162                                  	;	
  1163 00000448 B900021000              	mov	ecx, MEM_ALLOC_TBL + 512 ; End of first 16 MB memory
  1164                                  	;	
  1165 0000044D 29F9                    	sub	ecx, edi	  ; displacement (to end of 16 MB)
  1166 0000044F 7406                    	jz	short mi_5	  ; jump if EDI points to 
  1167                                  				  ;         end of first 16 MB	
  1168 00000451 D1E9                    	shr	ecx, 1		  ; convert to dword count
  1169 00000453 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
  1170 00000455 F3AB                    	rep 	stosd		  ; reset all bits for reserved pages
  1171                                  				  ; (memory hole under 16 MB)
  1172                                  mi_5:
  1173 00000457 6689D1                  	mov	cx, dx		  ; count of 64 KB memory blocks
  1174 0000045A D1E9                    	shr	ecx, 1		  ; 1 alloc. dword per 128 KB memory
  1175 0000045C 9C                      	pushf			  ; 16/11/2014		
  1176 0000045D 48                      	dec	eax		  ; FFFFFFFFh (set all bits to 1)
  1177 0000045E F3AB                    	rep	stosd
  1178 00000460 40                      	inc	eax		  ; 0
  1179 00000461 9D                      	popf			  ; 16/11/2014
  1180 00000462 7305                    	jnc	short mi_6
  1181 00000464 6648                    	dec	ax		  ; eax = 0000FFFFh
  1182 00000466 AB                      	stosd
  1183 00000467 6640                    	inc	ax		  ; 0		
  1184                                  mi_6:
  1185 00000469 39DF                    	cmp	edi, ebx	  ; check if EDI points to 	
  1186 0000046B 730A                    	jnb	short mi_7	  ; end of memory allocation table
  1187                                  	;			  ; (>= MEM_ALLOC_TBL + 4906) 
  1188 0000046D 89D9                    	mov	ecx, ebx	  ; end of memory allocation table
  1189 0000046F 29F9                    	sub	ecx, edi	  ; convert displacement/offset
  1190 00000471 D1E9                    	shr	ecx, 1		  ; to dword count 	 		
  1191 00000473 D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
  1192 00000475 F3AB                    	rep 	stosd		  ; reset all remain M.A.T. bits
  1193                                  mi_7:
  1194                                  	; Reset M.A.T. bits in M.A.T. (allocate M.A.T. pages)
  1195 00000477 BA00001000              	mov	edx, MEM_ALLOC_TBL
  1196                                  	;sub	ebx, edx	  ; Mem. Alloc. Tbl. size in bytes
  1197                                  	;shr	ebx, 12		  ; Mem. Alloc. Tbl. size in pages	
  1198 0000047C 668B0D[98770100]        	mov	cx, [mat_size]	  ; Mem. Alloc. Tbl. size in pages
  1199 00000483 89D7                    	mov	edi, edx
  1200 00000485 C1EF0F                  	shr	edi, 15		  ; convert M.A.T. address to
  1201                                  				  ; byte offset in M.A.T.
  1202                                  				  ; (1 M.A.T. byte points to 
  1203                                  				  ;	      32768 bytes)
  1204                                  				  ; Note: MEM_ALLOC_TBL address 
  1205                                  				  ; must be aligned on 128 KB 
  1206                                  				  ; boundary!
  1207 00000488 01D7                    	add	edi, edx	  ; points to M.A.T.'s itself	
  1208                                  	; eax = 0
  1209 0000048A 290D[88770100]          	sub	[free_pages], ecx ; 07/11/2014
  1210                                  mi_8:
  1211 00000490 0FB307                  	btr	[edi], eax	  ; clear bit 0 to bit x (1 to 31)
  1212                                  	;dec	bl
  1213 00000493 FEC9                    	dec	cl
  1214 00000495 7404                    	jz	short mi_9
  1215 00000497 FEC0                    	inc	al
  1216 00000499 EBF5                    	jmp	short mi_8
  1217                                  mi_9:
  1218                                  	;
  1219                                  	; Reset Kernel's Page Dir. and Page Table bits in M.A.T.
  1220                                  	;		(allocate pages for system page tables)
  1221                                  
  1222                                  	; edx = MEM_ALLOC_TBL
  1223 0000049B 8B0D[84770100]          	mov	ecx, [memory_size] ; memory size in pages (PTEs)
  1224 000004A1 81C1FF030000            	add	ecx, 1023	 ; round up (1024 PTEs per table)	 	
  1225 000004A7 C1E90A                  	shr	ecx, 10		 ; convert memory page count to 
  1226                                  				 ; page table count (PDE count)
  1227                                  	;
  1228 000004AA 51                      	push	ecx		 ; (**) PDE count (<= 1024)
  1229                                  	;
  1230 000004AB 41                      	inc	ecx		 ; +1 for kernel page directory	
  1231                                  	;
  1232 000004AC 290D[88770100]          	sub	[free_pages], ecx ; 07/11/2014
  1233                                  	;
  1234 000004B2 8B35[80770100]          	mov	esi, [k_page_dir] ; Kernel's Page Directory address
  1235 000004B8 C1EE0C                  	shr	esi, 12		 ; convert to page number
  1236                                  mi_10:
  1237 000004BB 89F0                    	mov	eax, esi	 ; allocation bit offset		 
  1238 000004BD 89C3                    	mov	ebx, eax
  1239 000004BF C1EB03                  	shr	ebx, 3		 ; convert to alloc. byte offset
  1240 000004C2 80E3FC                  	and	bl, 0FCh	 ; clear bit 0 and bit 1
  1241                                  				 ;   to align on dword boundary
  1242 000004C5 83E01F                  	and	eax, 31		 ; set allocation bit position 
  1243                                  				 ;  (bit 0 to bit 31)
  1244                                  	;
  1245 000004C8 01D3                    	add	ebx, edx	 ; offset in M.A.T. + M.A.T. address 
  1246                                  	;
  1247 000004CA 0FB303                  	btr 	[ebx], eax	 ; reset relevant bit (0 to 31)
  1248                                  	;
  1249 000004CD 46                      	inc	esi		 ; next page table
  1250 000004CE E2EB                    	loop	mi_10		 ; allocate next kernel page table 
  1251                                  				 ; (ecx = page table count + 1)		
  1252                                  	;
  1253 000004D0 59                      	pop	ecx		 ; (**) PDE count (= pg. tbl. count)
  1254                                  	;
  1255                                  	; Initialize Kernel Page Directory and Kernel Page Tables
  1256                                  	;
  1257                                  	; Initialize Kernel's Page Directory
  1258 000004D1 8B3D[80770100]          	mov	edi, [k_page_dir]
  1259 000004D7 89F8                    	mov	eax, edi
  1260 000004D9 0C03                    	or	al, PDE_A_PRESENT + PDE_A_WRITE
  1261                                  				; supervisor + read&write + present
  1262 000004DB 89CA                    	mov	edx, ecx 	; (**) PDE count (= pg. tbl. count)	
  1263                                  mi_11:
  1264 000004DD 0500100000              	add	eax, 4096	; Add page size (PGSZ)
  1265                                  			        ; EAX points to next page table
  1266 000004E2 AB                      	stosd
  1267 000004E3 E2F8                    	loop	mi_11
  1268 000004E5 29C0                    	sub	eax, eax	; Empty PDE
  1269 000004E7 66B90004                	mov	cx, 1024	; Entry count (PGSZ/4)
  1270 000004EB 29D1                    	sub	ecx, edx
  1271 000004ED 7402                    	jz	short mi_12
  1272 000004EF F3AB                    	rep	stosd 		; clear remain (empty) PDEs
  1273                                  	;
  1274                                  	; Initialization of Kernel's Page Directory is OK, here.
  1275                                  mi_12:
  1276                                  	; Initialize Kernel's Page Tables
  1277                                  	;
  1278                                  	; (EDI points to address of page table 0)
  1279                                  	; eax = 0
  1280 000004F1 8B0D[84770100]          	mov	ecx, [memory_size] ; memory size in pages
  1281 000004F7 89CA                    	mov	edx, ecx	; (***)
  1282 000004F9 B003                    	mov	al, PTE_A_PRESENT + PTE_A_WRITE
  1283                                  			     ; supervisor + read&write + present 	
  1284                                  mi_13:
  1285 000004FB AB                      	stosd
  1286 000004FC 0500100000              	add	eax, 4096	
  1287 00000501 E2F8                    	loop	mi_13	
  1288 00000503 6681E2FF03              	and	dx, 1023	; (***)
  1289 00000508 740A                    	jz	short mi_14
  1290 0000050A 66B90004                	mov	cx, 1024	
  1291                                  	;sub	cx, dx		; from dx (<= 1023) to 1024
  1292                                  	; 24/07/2022
  1293 0000050E 29D1                    	sub	ecx, edx
  1294 00000510 31C0                    	xor	eax, eax
  1295 00000512 F3AB                    	rep	stosd		; clear remain (empty) PTEs 
  1296                                  				; of the last page table
  1297                                  mi_14:
  1298                                  	;  Initialization of Kernel's Page Tables is OK, here.
  1299                                  	;
  1300 00000514 89F8                    	mov	eax, edi	; end of the last page table page
  1301                                  			        ; (beginging of user space pages)
  1302 00000516 C1E80F                  	shr	eax, 15		; convert to M.A.T. byte offset
  1303 00000519 24FC                    	and	al, 0FCh	; clear bit 0 and bit 1 for
  1304                                  				; aligning on dword boundary	
  1305                                  	 
  1306 0000051B A3[94770100]            	mov	[first_page], eax
  1307 00000520 A3[8C770100]            	mov	[next_page], eax ; The first free page pointer
  1308                                  				 ; for user programs
  1309                                  				 ; (Offset in Mem. Alloc. Tbl.)	
  1310                                  	;
  1311                                  	; Linear/FLAT (1 to 1) memory paging for the kernel is OK, here.
  1312                                  	;
  1313                                  	
  1314                                  	; Enable paging
  1315                                  	;
  1316 00000525 A1[80770100]                    mov     eax, [k_page_dir]
  1317 0000052A 0F22D8                  	mov	cr3, eax
  1318 0000052D 0F20C0                  	mov	eax, cr0
  1319 00000530 0D00000080              	or	eax, 80000000h	; set paging bit (bit 31)
  1320 00000535 0F22C0                  	mov	cr0, eax
  1321                                          ;jmp    KCODE:StartPMP
  1322                                  
  1323 00000538 EA                      	db	0EAh		; Opcode for far jump
  1324 00000539 [3F050000]                      dd	StartPMP	; 32 bit offset
  1325 0000053D 0800                    	dw	KCODE		; kernel code segment descriptor
  1326                                  
  1327                                  StartPMP:
  1328                                  	; 06/11//2014
  1329                                  	; Clear video page 0
  1330                                  	;
  1331                                  	; Temporary Code
  1332                                  	;
  1333 0000053F B9E8030000              	mov	ecx, 80*25/2
  1334 00000544 BF00800B00              	mov	edi, 0B8000h
  1335                                  	; 30/01/2016
  1336                                  	;xor	eax, eax	; black background, black fore color
  1337 00000549 B800070007              	mov	eax, 07000700h  ; black background, light gray fore color
  1338 0000054E F3AB                    	rep	stosd
  1339                                  	
  1340                                  	; 19/08/2014
  1341                                  	; Kernel Base Address = 0
  1342                                  	; It is mapped to (physically) 0 in the page table.
  1343                                  	; So, here is exactly 'StartPMP' address.
  1344                                  
  1345                                   	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
  1346 00000550 BE[523B0100]            	mov	esi, starting_msg
  1347                                  	;; 14/08/2015 (kernel version message will appear
  1348                                  	;;	       when protected mode and paging is enabled)
  1349 00000555 BF00800B00              	mov	edi, 0B8000h ; 27/08/2014
  1350                                  	
  1351                                  	; 30/11/2020
  1352                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
  1353                                  	;cmp	byte [vbe3], 3 ; 03h
  1354                                  	;jne	short pkv_1
  1355                                  	;;mov	ah, 0Bh ; Black background, light cyan forecolor
  1356                                  	;; Light red TRDOS 386 version text shows VBE3 is ready !
  1357                                  	;mov	ah, 0Ch ; Black background, light red forecolor
  1358                                  	;jmp	short pkv_2
  1359                                  ;pkv_1:
  1360 0000055A B40A                    	mov	ah, 0Ah ; Black background, light green forecolor
  1361                                  ;pkv_2:
  1362                                  	; 20/08/2014
  1363 0000055C E8D4030000              	call	printk
  1364                                  
  1365                                  	; 'UNIX v7/x86' source code by Robert Nordier (1999)
  1366                                  	; // Set IRQ offsets
  1367                                  	;
  1368                                  	;  Linux (v0.12) source code by Linus Torvalds (1991)
  1369                                  	;
  1370                                  					;; ICW1
  1371 00000561 B011                    	mov	al, 11h			; Initialization sequence
  1372 00000563 E620                    	out	20h, al			; 	8259A-1
  1373                                  	; jmp 	$+2
  1374 00000565 E6A0                    	out	0A0h, al		; 	8259A-2
  1375                                  					;; ICW2
  1376 00000567 B020                    	mov	al, 20h			; Start of hardware ints (20h)
  1377 00000569 E621                    	out	21h, al			;	for 8259A-1
  1378                                  	; jmp 	$+2
  1379 0000056B B028                    	mov	al, 28h			; Start of hardware ints (28h)
  1380 0000056D E6A1                    	out	0A1h, al		; 	for 8259A-2
  1381                                  					;
  1382 0000056F B004                    	mov	al, 04h			;; ICW3
  1383 00000571 E621                    	out	21h, al			; 	IRQ2 of 8259A-1 (master)
  1384                                  	; jmp 	$+2
  1385 00000573 B002                    	mov	al, 02h			; 	is 8259A-2 (slave)
  1386 00000575 E6A1                    	out	0A1h, al		;
  1387                                  					;; ICW4
  1388 00000577 B001                    	mov	al, 01h	 		;
  1389 00000579 E621                    	out	21h, al			; 	8086 mode, normal EOI	
  1390                                  	; jmp 	$+2
  1391 0000057B E6A1                    	out	0A1h, al		;	for both chips.
  1392                                  
  1393                                  	;mov	al, 0FFh	; mask off all interrupts for now
  1394                                  	;out	21h, al
  1395                                  	;; jmp 	$+2
  1396                                  	;out	0A1h, al
  1397                                  
  1398                                  	; 02/04/2015
  1399                                  	; 26/03/2015 System call (INT 30h) modification
  1400                                  	;  DPL = 3 (Interrupt service routine can be called from user mode)			
  1401                                  	;
  1402                                  	;; Linux (v0.12) source code by Linus Torvalds (1991)
  1403                                  	;  setup_idt:
  1404                                  	;
  1405                                          ;; 16/02/2015
  1406                                  	;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
  1407                                  	; 21/08/2014 (timer_int)
  1408 0000057D BE[D4370100]            	mov	esi, ilist
  1409 00000582 8D3D[98740100]          	lea	edi, [idt]
  1410                                  	; 26/03/2015
  1411 00000588 B930000000              	mov	ecx, 48		; 48 hardware interrupts (INT 0 to INT 2Fh)
  1412                                  	; 02/04/2015
  1413 0000058D BB00000800              	mov	ebx,  80000h
  1414                                  rp_sidt1:
  1415 00000592 AD                      	lodsd
  1416 00000593 89C2                    	mov	edx, eax
  1417 00000595 66BA008E                	mov	dx, 8E00h
  1418 00000599 6689C3                  	mov	bx, ax
  1419 0000059C 89D8                    	mov	eax, ebx	; /* selector = 0x0008 = cs */
  1420                                         			        ; /* interrupt gate - dpl=0, present */
  1421 0000059E AB                      	stosd	; selector & offset bits 0-15 	
  1422 0000059F 89D0                    	mov	eax, edx
  1423 000005A1 AB                      	stosd	; attributes & offset bits 16-23
  1424 000005A2 E2EE                    	loop	rp_sidt1
  1425                                  	; 15/04/2016
  1426                                  	; TRDOS 386 (TRDOS v2.0) /// 32 sofware interrupts ///
  1427                                  	;mov	cl, 16        ; 16 software interrupts (INT 30h to INT 3Fh)
  1428 000005A4 B120                    	mov	cl, 32	      ; 32 software interrupts (INT 30h to INT 4Fh)	
  1429                                  rp_sidt2:
  1430 000005A6 AD                      	lodsd
  1431 000005A7 21C0                    	and	eax, eax
  1432 000005A9 7413                    	jz	short rp_sidt3
  1433 000005AB 89C2                    	mov	edx, eax
  1434 000005AD 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
  1435 000005B1 6689C3                  	mov	bx, ax
  1436 000005B4 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
  1437 000005B6 AB                      	stosd
  1438 000005B7 89D0                    	mov	eax, edx
  1439 000005B9 AB                      	stosd
  1440 000005BA E2EA                    	loop	rp_sidt2
  1441 000005BC EB16                    	jmp	short sidt_OK
  1442                                  rp_sidt3:
  1443 000005BE B8[600D0000]            	mov	eax, ignore_int
  1444 000005C3 89C2                    	mov	edx, eax
  1445 000005C5 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
  1446 000005C9 6689C3                  	mov	bx, ax
  1447 000005CC 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
  1448                                  rp_sidt4:
  1449 000005CE AB                      	stosd
  1450 000005CF 92                      	xchg	eax, edx
  1451 000005D0 AB                      	stosd
  1452 000005D1 92                      	xchg	edx, eax
  1453 000005D2 E2FA                    	loop	rp_sidt4
  1454                                  sidt_OK: 
  1455 000005D4 0F011D[6E640000]        	lidt 	[idtd]
  1456                                  	;
  1457                                  	; TSS descriptor setup ; 24/03/2015
  1458 000005DB B8[18770100]            	mov	eax, task_state_segment
  1459 000005E0 66A3[1A640000]          	mov	[gdt_tss0], ax
  1460 000005E6 C1C010                  	rol	eax, 16
  1461 000005E9 A2[1C640000]            	mov	[gdt_tss1], al
  1462 000005EE 8825[1F640000]          	mov	[gdt_tss2], ah
  1463 000005F4 66C705[7E770100]68-     	mov	word [tss.IOPB], tss_end - task_state_segment
  1464 000005FC 00                 
  1465                                  		; 
  1466                                  		; IO Map Base address (When this address points
  1467                                  		; to end of the TSS, CPU does not use IO port 
  1468                                  		; permission bit map for RING 3 IO permissions, 
  1469                                  		; access to any IO ports in ring 3 will be forbidden.)
  1470                                   		;
  1471                                  	;mov	[tss.esp0], esp ; TSS offset 4
  1472                                  	;mov	word [tss.ss0], KDATA ; TSS offset 8 (SS)
  1473 000005FD 66B82800                   	mov	ax, TSS  ; It is needed when an interrupt 
  1474                                  			 ; occurs (or a system call -software INT- is requested)
  1475                                  			 ; while cpu running in ring 3 (in user mode).				
  1476                                  			 ; (Kernel stack pointer and segment will be loaded
  1477                                  			 ; from offset 4 and 8 of the TSS, by the CPU.)	 
  1478 00000601 0F00D8                  	ltr	ax  ; Load task register
  1479                                  	;
  1480                                  esp0_set0:
  1481                                  	; 30/07/2015
  1482 00000604 8B0D[84770100]          	mov 	ecx, [memory_size] ; memory size in pages
  1483 0000060A C1E10C                  	shl 	ecx, 12 ; convert page count to byte count
  1484 0000060D 81F900004000            	cmp	ecx, CORE ; beginning of user's memory space (400000h)
  1485                                  			  ; (kernel mode virtual address)
  1486 00000613 7605                    	jna	short esp0_set1
  1487                                  	;
  1488                                  	; If available memory > CORE (end of the 1st 4 MB)
  1489                                  	; set stack pointer to CORE
  1490                                  	;(Because, PDE 0 is reserved for kernel space in user's page directory)
  1491                                  	;(PDE 0 points to page table of the 1st 4 MB virtual address space)
  1492 00000615 B900004000              	mov	ecx, CORE
  1493                                  esp0_set1:
  1494 0000061A 89CC                    	mov	esp, ecx ; top of kernel stack (**tss.esp0**)
  1495                                  esp0_set_ok:
  1496                                  	; 30/07/2015 (**tss.esp0**) 
  1497 0000061C 8925[1C770100]          	mov	[tss.esp0], esp
  1498 00000622 66C705[20770100]10-             mov     word [tss.ss0], KDATA
  1499 0000062A 00                 
  1500                                  	; 14/08/2015
  1501                                  	; 10/11/2014 (Retro UNIX 386 v1 - Erdogan Tan)
  1502                                  	;
  1503                                  	;cli	; Disable interrupts (for CPU)
  1504                                  	;    (CPU will not handle hardware interrupts, except NMI!)
  1505                                  	;
  1506 0000062B 30C0                    	xor	al, al		; Enable all hardware interrupts!
  1507 0000062D E621                    	out	21h, al		; (IBM PC-AT compatibility)
  1508 0000062F EB00                    	jmp 	$+2		; (All conventional PC-AT hardware
  1509 00000631 E6A1                    	out	0A1h, al	;  interrupts will be in use.)	
  1510                                  				; (Even if related hardware component
  1511                                  				;  does not exist!)
  1512                                  	; Enable NMI 
  1513 00000633 B07F                    	mov	al, 7Fh		; Clear bit 7 to enable NMI (again)
  1514 00000635 E670                    	out  	70h, al
  1515                                  	; 23/02/2015
  1516 00000637 90                      	nop
  1517 00000638 E471                    	in	al, 71h		; read in 71h just after writing out to 70h
  1518                                  				; for preventing unknown state (!?)
  1519                                  	;
  1520                                  	; Only a NMI can occur here... (Before a 'STI' instruction)
  1521                                  	;
  1522                                  	; 02/09/2014
  1523                                  	;xor	bx, bx
  1524                                  	; 24/07/2022
  1525 0000063A 31DB                    	xor	ebx, ebx
  1526 0000063C 66BA0002                	mov	dx, 0200h	; Row 2, column 0  ; 07/03/2015
  1527 00000640 E8711C0000              	call	_set_cpos	; 24/01/2016
  1528                                  
  1529                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
  1530                                  	; Check VBE3 protected mode interface/feature(s)
  1531                                  
  1532                                  	;cmp	byte [vbe3], 3 ; 03h
  1533                                  	;jne	short display_mem_info
  1534                                  
  1535                                  	; 20/11/2020
  1536 00000645 803D[3F090000]02        	cmp	byte [vbe3], 2 ; 02h
  1537 0000064C 7707                    	ja	short vbe3_pmid_chk
  1538                                  	;;jb	short display_mem_info
  1539                                  	;jb	display_mem_info ; 02/12/2020
  1540 0000064E 7220                    	jb	short jmp_display_mem_info ; 24/07/2022
  1541 00000650 E9FD010000              	jmp	check_boch_plex86_vbe
  1542                                  
  1543                                  vbe3_pmid_chk:	
  1544 00000655 B9EA7F0000              	mov	ecx, 32768 - (20+2) ; 32766 - PMInfoBlockSize
  1545 0000065A BE02000C00              	mov	esi, 0C0002h ; 1st word of the video bios rom is 0AA55h
  1546                                  	
  1547                                  chk_pmi_sign:
  1548                                  	;mov	eax, [esi] 
  1549                                  	;cmp	eax, 'PMID'
  1550                                  	; 30/11/2020
  1551                                  	;cmp	al, 'P'
  1552                                  	;jne	short chk_pmi_sign_next
  1553 0000065F 813E504D4944            	cmp	dword [esi], 'PMID'
  1554                                  	;je	short display_vbios_product_name
  1555 00000665 740E                    	je	short verify_pmib_chksum ; 15/11/2020
  1556                                  ;chk_pmi_sign_next:
  1557 00000667 46                      	inc	esi  ; inc si
  1558 00000668 E2F5                    	loop	chk_pmi_sign
  1559                                  
  1560                                  not_valid_pmib:
  1561 0000066A FE0D[3F090000]          	dec	byte [vbe3] ; 2 = VBE2 compatible 
  1562                                  			    ; (vbe3 feature is defective in this vbios)
  1563                                  	;jmp	short display_mem_info
  1564                                  jmp_display_mem_info:	; 24/07/2022
  1565                                  	; 02/12/2020
  1566 00000670 E9A4010000              	jmp	display_mem_info
  1567                                  
  1568                                  verify_pmib_chksum:
  1569                                  	; 15/11/2020
  1570 00000675 31C0                    	xor	eax, eax
  1571                                  	;mov	ecx, eax 
  1572                                  	;mov	cl, 20
  1573 00000677 66B91400                	mov	cx, 20 ; 30/11/2020
  1574 0000067B 56                      	push	esi
  1575                                  pmib_sum_bytes:
  1576 0000067C AC                      	lodsb
  1577 0000067D 00C4                    	add	ah, al
  1578 0000067F E2FB                    	loop	pmib_sum_bytes
  1579 00000681 5E                      	pop	esi
  1580 00000682 08E4                    	or	ah, ah
  1581 00000684 75E4                    	jnz	short not_valid_pmib ; AH must be 0
  1582                                  
  1583                                  	; 28/02/2021
  1584                                  	; Set default (initial) truecolor bpp value to 32
  1585                                  	; (for VBE3 video bios.. because vbe3 video bioses
  1586                                  	;  use 32bpp -for truecolor modes- instead of 24bpp)
  1587                                  	; (This setting may be changed via 'sysvideo' bx=0908h)
  1588                                  	
  1589 00000686 C605[43740100]20        	mov	byte [truecolor], 32 ; (RGB: 00RRGGBBh)
  1590                                  
  1591                                  display_vbios_product_name: ; 14/11/2020
  1592                                  
  1593                                  	; ESI points to 'PMID' (0C0000h + 'PMID' offset)
  1594                                  
  1595                                  	; 15/11/2020
  1596                                  	;mov	[pmid_addr], si	; PMInfoBlock offset
  1597                                  	;		; (in VGA bios, 0C0000h + offset)
  1598                                  	; 02/12/2020
  1599                                  	;push	esi ; * pmid_addr
  1600 0000068D 89F7                    	mov	edi, esi
  1601                                  
  1602                                  	;mov	esi, [VBE3INFOBLOCK+22] ; 097E00h + 16h
  1603                                  	;		; OemVendorNamePtr (seg16:off16)
  1604 0000068F 8B35067E0900            	mov	esi, [VBE3INFOBLOCK+6] ; 097E00h + 06h
  1605                                  			; OemStringPtr (seg16:off16)
  1606 00000695 30C0                    	xor	al, al  ; eax = 0
  1607 00000697 6696                    	xchg	ax, si	; ax = offset, si = 0
  1608 00000699 C1EE0C                  	shr	esi, 12 ; (to convert segment to base addr)
  1609 0000069C 6601C6                  	add	si, ax  ; esi has an address < 1 MB limit
  1610                                  			; (OemVendorName is in VBE3INFOBLOCK)
  1611                                  			; Example: 
  1612                                  			; TRDOS 386 v2.0.3 VESA VBE3 protected mode
  1613                                  			; interface development reference is ...
  1614                                  			; NVIDIA GeForce FX5500 VGA BIOS -C000h:029Ch-
  1615                                  			; Version 4.34.20.54.00 -C000h:02EDh- 	  
  1616                                  			; ((OemString is 'NVIDIA'))
  1617                                  			; ((OemVendorName is 'NVIDIA Corporation'))
  1618                                  			; ((OemProductName is 'NV34 Board - p162-1nz))
  1619                                  
  1620                                  	;mov	ah, 0Eh ; Black background, yellow forecolor
  1621                                  	; 30/11/2020
  1622 0000069F B40C                    	mov	ah, 0Ch ; Black background, light red forecolor
  1623                                  
  1624 000006A1 E81E3A0000              	call	print_kmsg
  1625                                  
  1626                                  	;mov	ah, 07h
  1627                                  
  1628 000006A6 BE[25740100]            	mov	esi, vesa_vbe3_bios_msg
  1629                                  	;call	print_kmsg
  1630 000006AB E81A3A0000              	call	pkmsg_loop ; 30/11/2020
  1631                                  
  1632                                  	; 02/12/2020
  1633                                  	;pop	edi ; * pmid_addr
  1634                                  
  1635                                  	; 30/11/2020
  1636                                  	; 29/11/2020 - TRDOS 386 v2.0.3
  1637                                  
  1638                                  struc PMInfo  ;  VESA VBE3 PMInfoBlock ('PMID' block)
  1639                                  
  1640 00000000 <res 00000004>           .Signature:	resb 4  ; db 'PMID' ; PM Info Block Signature
  1641 00000004 <res 00000002>           .EntryPoint:	resw 1	; Offset of PM entry point within BIOS
  1642 00000006 <res 00000002>           .PMInitialize: resw 1	; Offset of PM initialization entry point
  1643 00000008 <res 00000002>           .BIOSDataSel:	resw 1 	; Selector to BIOS data area emulation block
  1644 0000000A <res 00000002>           .A0000Sel:	resw 1	; Selector to access A0000h physical mem
  1645 0000000C <res 00000002>           .B0000Sel:	resw 1  ; Selector to access B0000h physical mem
  1646 0000000E <res 00000002>           .B8000Sel:	resw 1	; Selector to access B8000h physical mem
  1647 00000010 <res 00000002>           .CodeSegSel:	resw 1	; Selector to access code segment as data
  1648 00000012 <res 00000001>           .InProtectMode: resb 1 ; Set to 1 when in protected mode
  1649 00000013 <res 00000001>           .Checksum:	resb 1	; Checksum byte for structure
  1650                                   .size:
  1651                                  
  1652                                  endstruc
  1653                                  
  1654                                  	; 24/07/2022
  1655                                  	; 29/11/2020
  1656                                  vbe3pminit:
  1657                                  	; 30/11/2020
  1658                                  	;cmp	byte [vbe3], 3 ; is VESA VBE3 PMI ready ?
  1659                                  	;jne	short di4
  1660                                  
  1661                                  	; Allocate 64KB contiguous (kernel) memory block
  1662 000006B0 31C0                    	xor	eax, eax
  1663 000006B2 B900000100              	mov	ecx, 65536
  1664 000006B7 E801550000              	call	allocate_memory_block
  1665                                  	;jc	short di4
  1666                                  	;jc	di0 ; 30/11/2020
  1667                                  	; 24/07/2022
  1668 000006BC 7305                    	jnc	short vbe3pminit0
  1669 000006BE E94F010000              	jmp	di0
  1670                                  
  1671                                  vbe3pminit0:
  1672                                  	; of course this block must be in the 1st 16MB
  1673                                  	; because vbe3 pmi segments will be 16 bit segments
  1674                                  	; (80286 type segment descriptors in GDT)
  1675                                  
  1676 000006C3 A3[D40F0300]            	mov	[vbe3bios_addr], eax
  1677                                  
  1678                                  	; set [pmid_addr] to the new location
  1679 000006C8 BE00000C00              	mov	esi, 0C0000h
  1680                                  
  1681                                  	; 30/11/2020
  1682 000006CD 29F7                    	sub	edi, esi ; izolate offset
  1683 000006CF 01C7                    	add	edi, eax ; new address
  1684 000006D1 893D[D80F0300]          	mov	[pmid_addr], edi ; new 'PMID' location	
  1685                                  
  1686                                  	; Move VIDEO BIOS from 0C0000h to EAX
  1687 000006D7 B900400000              	mov	ecx, 65536/4
  1688 000006DC 89C7                    	mov	edi, eax ; 30/11/2020
  1689 000006DE F3A5                    	rep	movsd
  1690                                  
  1691                                  	; 02/12/2020
  1692                                  	; 30/11/2020
  1693                                  	; set vbe3 segment selectors
  1694                                  
  1695                                  	; VBE3CS (VESA VBE3 video bios code segment)
  1696 000006E0 BF[22640000]            	mov	edi, _vbe3_CS+2 ; base address bits 0..15
  1697 000006E5 66AB                    	stosw	; edi = _vbe3_CS+4
  1698 000006E7 C1C810                  	ror	eax, 16
  1699 000006EA 8807                    	mov	[edi], al ; base address, bits 16..23
  1700                                  
  1701                                  	; VBE3DS ('CodeSegSel' in PMInfoBlock)
  1702 000006EC BF[4C640000]            	mov	edi, _vbe3_DS+4 ; base addr bits 16..23
  1703 000006F1 8807                    	mov	[edi], al 
  1704 000006F3 C1C010                  	rol	eax, 16
  1705 000006F6 668947FE                	mov	[edi-2], ax ; base address, bits 0..15
  1706                                  
  1707                                  	; VBE3BDS (BIOSDataSel in PMInfoBlock)
  1708 000006FA BF[2A640000]            	mov	edi, _vbe3_BDS+2 ; base addr bits 0..15
  1709 000006FF B800700900              	mov	eax, VBE3BIOSDATABLOCK ; 1536 bytes
  1710 00000704 66AB                    	stosw	; edi = _vbe3_BDS+4
  1711 00000706 C1E810                  	shr	eax, 16
  1712 00000709 8807                    	mov	[edi], al ; base address, bits 16..23
  1713                                  
  1714                                  	; VBE3SS (1024 bytes)
  1715 0000070B BF[52640000]            	mov	edi, _vbe3_SS+2 ; base addr bits 0..15
  1716 00000710 B800600900              	mov	eax, VBE3STACKADDR ; size = 1024 bytes
  1717 00000715 66AB                    	stosw	; edi = _vbe3_SS+4
  1718 00000717 C1E810                  	shr	eax, 16
  1719 0000071A 8807                    	mov	[edi], al ; base address, bits 16..23
  1720                                  
  1721                                  	; stack pointer (esp) will be set to 1020
  1722                                  	; (before VBE3 PMI call)
  1723                                  
  1724                                  	; VBE3ES (max: 2048 bytes)
  1725 0000071C BF[5A640000]            	mov	edi, _vbe3_ES+2 ; base addr bits 0..15
  1726 00000721 B800760900              	mov	eax, VBE3SAVERESTOREBLOCK
  1727 00000726 66AB                    	stosw	; edi = _vbe3_ES+4
  1728 00000728 C1E810                  	shr	eax, 16
  1729 0000072B 8807                    	mov	[edi], al ; base address, bits 16..23 	
  1730                                  
  1731                                  	;Note: low word of _VBE3_ES base address will be
  1732                                  	;      set -again- by VBE3 PMI caller routine 
  1733                                  
  1734                                  	; 09/12/2020
  1735                                  	;; set pmi32 (as VBE3 PMI is ready)
  1736                                  	;inc	byte [pmi32] ; = 1 
  1737                                  
  1738                                  	; KCODE16 (set PMI far return segment)
  1739 0000072D BF[62640000]            	mov	edi, _16bit_CS+2 ; base addr bits 0..15
  1740 00000732 B8[BA070000]            	mov	eax, pminit_return_addr16
  1741 00000737 66AB                    	stosw	; edi = _16bit_CS+4
  1742 00000739 C1E810                  	shr	eax, 16
  1743 0000073C 8807                    	mov	[edi], al ; base address, bits 16..23 
  1744                                  
  1745                                  	; 30/11/2020
  1746                                  	; clear mem from VBE3 BIOS data area emu block
  1747                                  	; to end of vbe3 buffers
  1748                                  
  1749                                  	; 01/12/2020
  1750 0000073E BF00700900              	mov	edi, VBE3BIOSDATABLOCK ; 97000h
  1751                                  	;mov	cx, (VBE3INFOBLOCK-VBE3BIOSDATABLOCK)/4
  1752                                  	;	; ecx = 3584/4 double words
  1753                                  	; 21/12/2020
  1754 00000743 66B90003                	mov	cx, (VBE3MODEINFOBLOCK-VBE3BIOSDATABLOCK)/4
  1755                                  		; ecx = 3072/4 double words
  1756                                  	;xor	eax, eax
  1757 00000747 30C0                    	xor	al, al
  1758 00000749 F3AB                    	rep	stosd
  1759                                  
  1760                                  	; Filling PMInfoBlock selector fields
  1761 0000074B 8B3D[D80F0300]          	mov	edi, [pmid_addr]
  1762 00000751 66C747083800            	mov	word [edi+PMInfo.BIOSDataSel], VBE3BDS
  1763 00000757 66C7470A4000            	mov	word [edi+PMInfo.A0000Sel], VBE3A000
  1764 0000075D 66C7470C4800            	mov	word [edi+PMInfo.B0000Sel], VBE3B000
  1765 00000763 66C7470E5000            	mov	word [edi+PMInfo.B8000Sel], VBE3B800	
  1766 00000769 66C747105800            	mov	word [edi+PMInfo.CodeSegSel], VBE3DS
  1767 0000076F C6471201                	mov	byte [edi+PMInfo.InProtectMode], 1
  1768                                  
  1769                                  	; Calculate and write checksum byte
  1770 00000773 89FE                    	mov	esi, edi
  1771 00000775 B113                    	mov	cl, PMInfo.size - 1
  1772                                  	;xor	ah, ah
  1773                                  pmid_chksum:
  1774 00000777 AC                      	lodsb	
  1775 00000778 00C4                    	add	ah, al
  1776 0000077A E2FB                    	loop	pmid_chksum
  1777 0000077C F6DC                    	neg	ah ; 1 -> 255, 255 -> 1
  1778 0000077E 8826                    	mov	byte [esi], ah  ; checksum
  1779                                  
  1780                                  	; far call PM initialization
  1781                                  	; (VBE3 video bios will return via 'retf')
  1782                                  
  1783 00000780 668B4706                	mov	ax, [edi+PMInfo.PMInitialize]
  1784                                  	; 30/11/2020
  1785 00000784 C1E010                  	shl	eax, 16 ; save entry address in hw
  1786                                  	; ax = 0 
  1787                                  
  1788                                  	; 02/12/2020
  1789 00000787 68[DE070000]            	push	pminit_ok ; normal, near return address
  1790                                  
  1791                                  	; 30/11/2020
  1792                                  _VBE3PMI_fcall:
  1793                                  	; ax = function, hw of eax = entry address
  1794 0000078C 9C                      	pushf	; save 32 bit flags
  1795 0000078D 56                      	push	esi ; *
  1796 0000078E 55                      	push	ebp ; **
  1797                                  
  1798 0000078F 89E5                    	mov	ebp, esp ; save 32 bit stack pointer
  1799                                  	
  1800 00000791 89C6                    	mov	esi, eax
  1801                                  
  1802 00000793 FA                      	cli
  1803                                  
  1804                                  	; Disable interrupts (clear interrupt flag)
  1805                                  	; Reset Interrupt MASK Registers (Master&Slave)
  1806 00000794 B0FF                    	mov	al, 0FFh	; mask off all interrupts
  1807 00000796 E621                    	out	21h, al		; on master PIC (8259)
  1808 00000798 EB00                    	jmp 	$+2  ; (delay)
  1809 0000079A E6A1                    	out	0A1h, al	; on slave PIC (8259)
  1810                                  
  1811                                  	; 02/12/2020
  1812 0000079C 66B86000                	mov	ax, VBE3SS
  1813 000007A0 8ED0                    	mov	ss, ax
  1814                                  	
  1815 000007A2 BCFC030000              	mov	esp, 1020 ; 30/11/2020
  1816                                  
  1817                                  	; 01/12/2020
  1818                                  	;lss	esp, [stack16]
  1819                                  
  1820 000007A7 C1E810                  	shr	eax, 16	; now, entry address is in lw
  1821                                  
  1822                                  	; 30/11/2020 - 16 bit pm selector test (OK)
  1823                                  	; (32 bit stack push/pop & retf with 32 bit code segment)
  1824                                  	; (16 bit stack push/pop with 16 bit code segment)
  1825                                  	
  1826                                  	; return
  1827                                  	;push	KCODE16
  1828                                  	;push	0 ; 30/11/2020 (pminit_return_addr16)
  1829                                  
  1830                                  	; 30/11/2020 (16 bit stack during retf from video bios)
  1831 000007AA C7042400007000          	mov	dword [esp], KCODE16 << 16
  1832                                  				; ip = 0, cs = KCODE16 
  1833                                  	; 01/12/2020
  1834                                  	;mov	dword [VBE3STACKADDR+1020], KCODE16*65536
  1835                                  
  1836                                  	;mov	[jumpfar16], eax
  1837                                  
  1838                                  	; 02/12/2020
  1839                                  	; 30/11/2020 (32 bit stack during retf from kernel)
  1840                                  	; far jump/call via retf
  1841 000007B1 6A30                    	push	VBE3CS ; VBE3 video bios's code segment
  1842 000007B3 50                      	push	eax ; PMInitialize or EntryPoint
  1843                                  
  1844                                  	;mov	ax, si ; restore function
  1845                                  	; 24/07/2022
  1846 000007B4 89F0                    	mov	eax, esi 
  1847                                  	
  1848                                  	; 02/12/2020
  1849 000007B6 31F6                    	xor	esi, esi ; (not necessary, it is not used)
  1850                                  	
  1851 000007B8 CB                      	retf 	; far return (to 16 bit code segment)
  1852                                  
  1853                                  	; 01/12/2020
  1854                                  	;db	0EAh  ; far jump to 16 bit code segment
  1855                                  ;jumpfar16:
  1856                                  	;dd	0		
  1857                                  	;dw	VBE3CS
  1858                                  
  1859                                  ;stack16:
  1860                                  	;dd	1020
  1861                                  	;dw	VBE3SS
  1862                                  
  1863 000007B9 90                      	align 2	
  1864                                  
  1865                                  pminit_return_addr16:
  1866                                  	; 02/12/2020
  1867                                  	; 30/11/2020
  1868                                  	;;db	66h 		     ; Prefix for 32-bit
  1869                                  	;db	0EAh 		     ; Opcode for far jump
  1870                                  	;dd	pminit_return_addr32 ; 32 bit Offset
  1871                                  	;dw	KCODE		     ; 32 bit code segment
  1872                                  	; 01/12/2020
  1873 000007BA EA[C1070000]0800        	jmp	KCODE:pminit_return_addr32
  1874                                  
  1875                                  pminit_return_addr32:
  1876                                  	; restore 32 bit kernel selectors and 32 bit stack addr
  1877 000007C1 BE10000000              	mov	esi, KDATA
  1878 000007C6 8EDE                    	mov	ds, si
  1879 000007C8 8EC6                    	mov	es, si
  1880 000007CA 8ED6                    	mov	ss, si
  1881 000007CC 89EC                    	mov	esp, ebp  ; top of stack = iretd return addr
  1882                                  
  1883 000007CE 5D                      	pop	ebp ; **
  1884 000007CF 5E                      	pop	esi ; *
  1885 000007D0 9D                      	popf	; restore 32 bit flags
  1886                                  
  1887                                  	; enable interrupts
  1888                                  
  1889 000007D1 FA                      	cli
  1890                                  
  1891                                  	; 21/12/2020
  1892 000007D2 50                      	push	eax
  1893                                  
  1894 000007D3 30C0                    	xor	al, al	   ; Enable all hardware interrupts!
  1895 000007D5 E621                    	out	21h, al	   ; (IBM PC-AT compatibility)
  1896 000007D7 EB00                    	jmp 	$+2	   ; (All conventional PC-AT hardware
  1897 000007D9 E6A1                    	out	0A1h, al   ;  interrupts will be in use.)	
  1898                                  			   ; (Even if related hardware component
  1899                                  			   ;  does not exist!)
  1900 000007DB 58                      	pop	eax
  1901                                  	
  1902 000007DC FB                      	sti
  1903                                  
  1904                                  	; top of stack = return address 
  1905                                  	; ('pminit_ok' for PMinit)
  1906                                  
  1907 000007DD C3                      	retn
  1908                                  
  1909                                  pminit_ok:
  1910                                  	; 03/12/2020
  1911                                  	; (set [pmid_addr] to PMI entry point for next calls)
  1912 000007DE 8305[D80F0300]04        	add	dword [pmid_addr], PMInfo.EntryPoint ; + 4
  1913                                  
  1914                                  	; 17/01/2021
  1915                                  	; copy EDID data from temporary location to final address
  1916 000007E5 803D[57410000]4F        	cmp	byte [edid], 4Fh
  1917 000007EC 7510                    	jne	short vbe3h_chcl
  1918                                  	;mov	ecx, 32 ; 128 bytes, 32 dwords
  1919                                  	; 24/07/2022
  1920 000007EE 31C9                    	xor	ecx, ecx
  1921 000007F0 B120                    	mov	cl, 32
  1922 000007F2 BE007D0900              	mov	esi, VBE3EDIDINFOBLOCK ; 97D00h
  1923 000007F7 BF[500F0300]            	mov	edi, edid_info
  1924 000007FC F3A5                    	rep	movsd
  1925                                  	; 17/01/2021
  1926                                  vbe3h_chcl:
  1927                                  	; 16/01/2021
  1928                                  	;; 06/12/2020
  1929                                  	;; Save video mode 03h regs/dac/bios state
  1930                                  	;
  1931                                  	;mov	ax, 4F04h ; VESA VBE Function 04h
  1932                                  	;		  ; Save/Restore State
  1933                                  	;sub	dl, dl	; 0 = return buffer size
  1934                                  	;mov	cx, 0Fh  ; ctrl/bios/dac/regs
  1935                                  	;
  1936                                  	;call	int10h_32bit_pmi
  1937                                   	;; bx = number of 64-byte blocks to hold the state buff
  1938                                  	;	
  1939                                  	;;mov	[vbe3stbufsize], bx
  1940                                  	;; 16/01/2021
  1941                                  	;or	word [vbe3stbsflags], 32768  ; set bit 15
  1942                                  	;mov	ax, bx
  1943                                  	;shl	ax, 6  ; * 64
  1944                                  	;mov	[vbestatebufsize+30], ax
  1945                                  	;
  1946                                  	;; 06/12/2020	
  1947                                  	;; check 'vbe3stbufsize' (it must be <= 32)
  1948                                  	;
  1949                                  	;cmp	bx, 32
  1950                                  	;ja	short display_mem_info ; light red forecolor
  1951                                  	;
  1952                                  	;; 16/01/2021
  1953                                  	;or	byte [vbe3stbsflags], 1 ; set bit 0
  1954                                  
  1955                                  	; 30/11/2020
  1956                                  	; Change VESA VBE3 BIOS text color in order to give
  1957                                  	; "VBE3 PMI initialization has been successed" meaning 	
  1958                                  
  1959 000007FE BE40810B00              	mov	esi, 0B8000h + 160*2 ; row 2
  1960 00000803 89F7                    	mov	edi, esi
  1961                                  vbe3h_chcl_next:
  1962 00000805 66AD                    	lodsw
  1963 00000807 80FC0C                  	cmp	ah, 0Ch	; light red forecolor
  1964 0000080A 750D                    	jne	short display_mem_info
  1965 0000080C B40E                    	mov	ah, 0Eh ; yellow forecolor
  1966 0000080E 66AB                    	stosw
  1967 00000810 EBF3                    	jmp	short vbe3h_chcl_next
  1968                                  
  1969                                  di0:
  1970                                  	; 30/11/2020
  1971                                  	; Memory allocation error !
  1972 00000812 C605[3F090000]00        	mov	byte [vbe3], 0 ; disable VBE3
  1973                                  
  1974                                  display_mem_info:
  1975                                  	; 19/12/2020
  1976                                  	; temporary
  1977 00000819 E8C2380000              	call	default_lfb_info
  1978                                  	;
  1979                                  	; 06/11/2014
  1980 0000081E E848380000              	call	memory_info
  1981                                  	; 14/08/2015
  1982                                  	;call	getch ; 28/02/2015
  1983                                  drv_init:
  1984 00000823 FB                      	sti	; Enable Interrupts
  1985                                  	; 06/02/2015
  1986 00000824 8B15[FE640000]          	mov	edx, [hd0_type] ; hd0, hd1, hd2, hd3
  1987 0000082A 668B1D[FC640000]        	mov	bx, [fd0_type] ; fd0, fd1
  1988                                  	; 22/02/2015
  1989 00000831 6621DB                  	and	bx, bx
  1990 00000834 756C                    	jnz	short di1
  1991                                  	;
  1992 00000836 09D2                    	or 	edx, edx
  1993 00000838 757A                    	jnz	short di2
  1994                                  	;
  1995                                  setup_error:
  1996 0000083A BE[F63A0100]            	mov 	esi, setup_error_msg
  1997                                  psem:	
  1998 0000083F AC                      	lodsb
  1999 00000840 08C0                    	or	al, al
  2000                                  	;jz	short haltx ; 22/02/2015
  2001 00000842 747C                    	jz	short di3
  2002 00000844 56                      	push	esi
  2003                                  	; 13/05/2016
  2004 00000845 BB07000000              	mov	ebx, 7	; Black background, 
  2005                                  			; light gray forecolor
  2006                                  			; Video page 0 (BH=0)
  2007 0000084A E8CF190000              	call	_write_tty
  2008 0000084F 5E                      	pop	esi
  2009 00000850 EBED                    	jmp	short psem
  2010                                  
  2011                                  check_boch_plex86_vbe:
  2012                                  	; 20/11/2020
  2013                                  	; check Bochs/Plex86 VGABios VBE extension
  2014                                  	; (check if TRDOS 386 v2 is running on emulators)
  2015                                  	; BOCHS/QEMU/VIRTUALBOX
  2016                                  	;
  2017                                  	; ref: vbe_display_api.txt
  2018                                  
  2019                                  	; bochs/plex86 VGAbios VBE source code
  2020                                  	;  by Jeroen Janssen (2002)
  2021                                  	;  and Volker Ruppert (2003-2020)
  2022                                  
  2023 00000852 29C0                    	sub	eax, eax ; 0
  2024 00000854 66BACE01                	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
  2025 00000858 66EF                    	out	dx, ax ; VBE_DISPI_INDEX_ID register
  2026                                  	;mov	ax, 0B0C0h ; VBE_DISPI_ID0
  2027                                  	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
  2028 0000085A 6642                    	inc	dx
  2029                                  	;out	dx, ax
  2030                                  	;nop
  2031 0000085C 66ED                    	in	ax, dx
  2032 0000085E 80FCB0                  	cmp	ah, 0B0h
  2033                                  	;jne	short not_boch_qemu_vbe
  2034 00000861 75B6                    	jne	short display_mem_info
  2035 00000863 3CC5                    	cmp	al, 0C5h ; it must be 0B0C4h or 0B0C5h ..
  2036                                  	;ja	short not_boch_qemu_vbe
  2037 00000865 77B2                    	ja	short display_mem_info
  2038 00000867 3CC0                    	cmp	al, 0C0h ; 0B0C0h to 0B0C5h .. ; Qemu
  2039                                  	;cmp	al, 0C4h ; 0BC04h or 0B0C5h is OK ; Bochs
  2040                                  	;jb	short not_boch_qemu_vbe
  2041 00000869 72AE                    	jb	short display_mem_info
  2042                                  
  2043                                  	; save VESA VBE2 bios (bochs/qemu) signature
  2044                                  	; for enabling VBE2 functions in TRDOS 386 v2 kernel
  2045 0000086B A2[40090000]            	mov	[vbe2bios], al ; 0C4h or 0C5h (for BOCHS) 
  2046                                  			       ; (0C0h-0C5h for QEMU)
  2047 00000870 C605[2E740100]32        	mov	byte [vbe_vnumber], "2"
  2048                                  	; 26/11/2020
  2049                                  	; "BOCHS/QEMU/VIRTUALBOX VBE2 Video BIOS ..".
  2050 00000877 BE[10740100]            	mov	esi, vbe2_bochs_vbios ; BOCH/QEMU vbios msg
  2051 0000087C B40E                    	mov	ah, 0Eh  ; Yellow font
  2052 0000087E E841380000              	call	print_kmsg
  2053                                  	
  2054                                  	; this is not necessary ! (20/11/2020)
  2055 00000883 803D[40090000]C4        	cmp	byte [vbe2bios], 0C4h 
  2056 0000088A 728D                    	jb	short display_mem_info	; (QEMU) 
  2057                                  
  2058                                  	; Display kernel version message if 0E9h hack port
  2059                                  	; is enabled (bochs emulator feature)
  2060 0000088C 66BAE900                	mov	dx, 0E9h ; hack port for BOCHS
  2061 00000890 BE[69740100]            	mov	esi, kernel_version_msg
  2062                                  kvmsg_next_char:
  2063 00000895 AC                      	lodsb	
  2064 00000896 08C0                    	or	al, al
  2065 00000898 7505                    	jnz	short put_kvmsg_in_hack_port
  2066                                  not_boch_qemu_vbe:
  2067 0000089A E97AFFFFFF               	jmp	display_mem_info
  2068                                  put_kvmsg_in_hack_port:	
  2069 0000089F EE                      	out	dx, al
  2070 000008A0 EBF3                    	jmp	short kvmsg_next_char
  2071                                  
  2072                                  di1:
  2073                                  	; supress 'jmp short T6'
  2074                                  	;  (activate fdc motor control code)
  2075 000008A2 66C705[A1090000]90-     	mov	word [T5], 9090h ; nop
  2076 000008AA 90                 
  2077                                  	;
  2078                                  	;mov	ax, int_0Eh	; IRQ 6 handler
  2079                                  	;mov	di, 0Eh*4	; IRQ 6 vector
  2080                                  	;stosw
  2081                                  	;mov 	ax, cs
  2082                                  	;stosw
  2083                                  	;; 16/02/2015
  2084                                          ;;mov	dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
  2085                                  	;
  2086                                  
  2087 000008AB E838450000              	CALL	DSKETTE_SETUP	; Initialize Floppy Disks
  2088                                  
  2089 000008B0 09D2                    	or	edx, edx
  2090 000008B2 740C                    	jz	short di3
  2091                                  di2:
  2092 000008B4 E865450000              	call   	DISK_SETUP	; Initialize Fixed Disks
  2093                                          ;jc	setup_error
  2094                                  	; 24/07/2022
  2095 000008B9 7305                    	jnc	short di3
  2096 000008BB E97AFFFFFF              	jmp	setup_error
  2097                                  di3:
  2098 000008C0 E87A370000              	call	setup_rtc_int	; 22/05/2015 (dsectrpm.s)
  2099                                  	;
  2100 000008C5 E8A6300100              	call	display_disks ; 07/03/2015  (Temporary)
  2101                                  ;haltx:
  2102                                  	; 14/08/2015
  2103                                  	;call	getch ; 22/02/2015
  2104                                  	;sti	; Enable interrupts (for CPU)
  2105                                  ;	; 29/01/2016
  2106                                  ;	sub	ah, ah ;  read time count
  2107                                  ;	call	int1Ah
  2108                                  ;	mov	edx, ecx ; 18.2 * seconds
  2109                                  ;md_info_msg_wait1:
  2110                                  ;	; 29/01/2016
  2111                                  ;	mov	ah, 1
  2112                                  ;	call	int16h
  2113                                  ;	jz	short md_info_msg_wait2
  2114                                  ;	xor	ah, ah ; 0
  2115                                  ;       call    int16h
  2116                                  ;	jmp 	short md_info_msg_ok
  2117                                  ;md_info_msg_wait2:
  2118                                  ;	sub	ah, ah  ; read time count
  2119                                  ;	call	int1Ah
  2120                                  ;	cmp	edx, ecx ; ; 18.2 * seconds
  2121                                  ;	jna	short md_info_msg_wait3
  2122                                  ;	xchg 	edx, ecx	
  2123                                  ;md_info_msg_wait3:
  2124                                  ;	sub	ecx, edx
  2125                                  ;	cmp	ecx, 127 ; 7 seconds (18.2 * 7)
  2126                                  ;	jb	short md_info_msg_wait1		
  2127                                  ;md_info_msg_ok:
  2128                                  
  2129                                  	; 15/12/2020
  2130                                  	; set initial values of LFB parameters
  2131                                  
  2132 000008CA 803D[3F090000]02        	cmp	byte [vbe3], 2
  2133 000008D1 7214                    	jb	short di4
  2134                                  
  2135                                  	;mov	ax, [def_LFB_addr]
  2136                                  	;shl	eax, 16
  2137                                  	;mov	[LFB_ADDR], eax
  2138                                  	;mov	eax, 1024*768*3
  2139                                  	;mov	[LFB_SIZE], eax
  2140                                  
  2141 000008D3 BEFE7B0900              	mov	esi, VBE3MODEINFOBLOCK - 2
  2142 000008D8 66C7061801              	mov	word [esi], 0118h ; default vbe mode
  2143                                  				  ; 1024*768, 24bpp
  2144 000008DD E808300000              	call	set_lfbinfo_table
  2145                                  
  2146 000008E2 E80F580000              	call	allocate_lfb_pages_for_kernel
  2147                                  di4:
  2148                                  	; 08/09/2016
  2149 000008E7 0F20C0                  	mov	eax, cr0
  2150 000008EA A810                    	test	al, 10h  ; Bit 4, ET (Extension Type)
  2151 000008EC 7408                    	jz	short sysinit
  2152                                  	; 27/02/2017
  2153 000008EE FE05[38840100]          	inc	byte [fpready]
  2154                                  	; 80387 (FPU) is ready
  2155 000008F4 DBE3                    	fninit	; Initialize Floating-Point Unit
  2156                                  sysinit:
  2157                                  	; 30/06/2015
  2158 000008F6 E80F620000              	call	sys_init
  2159                                  	;
  2160                                  	;jmp 	cpu_reset ; 22/02/2015
  2161                                  hang:  
  2162                                  	; 23/02/2015
  2163                                  	;sti			; Enable interrupts
  2164 000008FB F4                      	hlt
  2165                                  	;
  2166                                  	;nop
  2167                                  	;; 03/12/2014
  2168                                  	;; 28/08/2014
  2169                                  	;mov	ah, 11h
  2170                                  	;call	getc
  2171                                  	;jz      _c8
  2172                                  	;
  2173                                  	; 23/02/2015
  2174                                  	; 06/02/2015
  2175                                  	; 07/09/2014
  2176 000008FC 31DB                    	xor	ebx, ebx
  2177 000008FE 8A1D[AE770100]          	mov	bl, [ptty]	; active_page
  2178 00000904 89DE                    	mov	esi, ebx
  2179                                  	;shl 	si, 1
  2180                                  	; 24/07/2022
  2181 00000906 D1E6                    	shl	esi, 1
  2182 00000908 81C6[B0770100]          	add	esi, ttychr
  2183 0000090E 668B06                  	mov	ax, [esi]
  2184 00000911 6621C0                  	and	ax, ax
  2185                                  	;jz	short _c8
  2186 00000914 74E5                    	jz	short hang
  2187 00000916 66C7060000              	mov	word [esi], 0
  2188 0000091B 80FB03                  	cmp	bl, 3		; Video page 3
  2189                                  	;jb	short _c8
  2190 0000091E 72DB                    	jb	short hang
  2191                                  	;	
  2192                                  	; 13/05/2016
  2193                                  	; 07/09/2014
  2194                                  nxtl:
  2195                                  	;push	bx
  2196                                  	; 18/04/2021
  2197 00000920 53                      	push	ebx
  2198 00000921 66BB0E00                	mov	bx, 0Eh 	; Yellow character 
  2199                                  				; on black background
  2200                                  				; bh = 0 (video page 0)
  2201                                  				; Retro UNIX 386 v1 - Video Mode 0
  2202                                  				; (PC/AT Video Mode 3 - 80x25 Alpha.)
  2203                                  	;push	ax
  2204                                  	; 18/04/2021
  2205 00000925 50                      	push	eax
  2206 00000926 E8F3180000              	call 	_write_tty
  2207                                  	;pop	ax
  2208                                  	; 18/04/2021
  2209 0000092B 58                      	pop	eax
  2210                                  	;pop	bx
  2211 0000092C 5B                      	pop	ebx
  2212 0000092D 3C0D                    	cmp	al, 0Dh		; carriage return (enter)
  2213                                  	;jne	short _c8
  2214 0000092F 75CA                    	jne	short hang
  2215 00000931 B00A                    	mov	al, 0Ah		; next line
  2216 00000933 EBEB                    	jmp	short nxtl
  2217                                  	
  2218                                  ;_c8:
  2219                                  ;	; 25/08/2014
  2220                                  ;	cli				; Disable interrupts
  2221                                  ;	mov	al, [scounter + 1]
  2222                                  ;	and	al, al
  2223                                  ;	jnz	hang
  2224                                  ;	call	rtc_p
  2225                                  ;	jmp     hang
  2226                                  
  2227                                  	; 27/08/2014
  2228                                  	; 20/08/2014
  2229                                  printk:
  2230                                          ;mov    edi, [scr_row]
  2231                                  pkl:
  2232 00000935 AC                      	lodsb
  2233 00000936 08C0                    	or 	al, al
  2234 00000938 7404                    	jz	short pkr
  2235 0000093A 66AB                    	stosw
  2236 0000093C EBF7                    	jmp	short pkl
  2237                                  pkr:
  2238 0000093E C3                      	retn
  2239                                  
  2240                                  ; 14/11/2020 (TRDOS 386 v2.0.3)
  2241 0000093F 00                      vbe3:	db 0	; VESA VBE version (must be 03h)
  2242                                  		; for using video bios calls in protected mode
  2243                                  vbe2bios:
  2244 00000940 B0                      	db 0B0h ; 
  2245                                  ;pmid_addr: 		
  2246                                  	;dw 0   ; > 0 if 'PMID' sign is found 
  2247                                  	;       ;  ('pmid' offset addr in VGA bios seg, 0C000h)
  2248                                  	;; 02/12/2020
  2249                                  	;dw 0   ; 32 bit address in pmid_addr
  2250                                  		
  2251                                  ; 28/02/2017
  2252                                  ; 22/01/2017
  2253                                  ; 15/01/2017
  2254                                  ; 14/01/2017
  2255                                  ; 02/01/2017
  2256                                  ; 25/12/2016
  2257                                  ; 19/12/2016
  2258                                  ; 10/12/2016 (callback)
  2259                                  ; 06/06/2016
  2260                                  ; 23/05/2016
  2261                                  ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications
  2262                                  ; 25/07/2015
  2263                                  ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer)
  2264                                  ; 17/02/2015
  2265                                  ; 06/02/2015 (unix386.s)
  2266                                  ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 
  2267                                  ;
  2268                                  ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85)
  2269                                  ;
  2270                                  ;-- HARDWARE INT  08 H - ( IRQ LEVEL 0 ) ---------------------------------------
  2271                                  ;	THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF        :
  2272                                  ;	THE 8254 TIMER.  INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR        :
  2273                                  ;	IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND.     :
  2274                                  ;									       :
  2275                                  ;	THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE    :
  2276                                  ;	POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY.	       :
  2277                                  ;	THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40)  :
  2278                                  ;	OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE 	       :
  2279                                  ;	DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS.		       :
  2280                                  ;	THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH	       :
  2281                                  ;	INTERRUPT 1CH AT EVERY TIME TICK.  THE USER MUST CODE A 	       :
  2282                                  ;	ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE.	       :
  2283                                  ;-------------------------------------------------------------------------------
  2284                                  ;
  2285                                  
  2286                                  timer_int:	; IRQ 0
  2287                                  ;int_08h:	; Timer
  2288                                  	; 14/10/2015
  2289                                  	; Here, we are simulating system call entry (for task switch)
  2290                                  	; (If multitasking is enabled, 
  2291                                  	; 'clock' procedure may jump to 'sysrelease')
  2292                                  
  2293 00000941 1E                      	push	ds
  2294 00000942 06                      	push	es
  2295 00000943 0FA0                    	push	fs
  2296 00000945 0FA8                    	push	gs
  2297                                  
  2298 00000947 60                      	pushad	; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  2299 00000948 66B91000                	mov     cx, KDATA
  2300 0000094C 8ED9                            mov     ds, cx
  2301 0000094E 8EC1                            mov     es, cx
  2302 00000950 8EE1                            mov     fs, cx
  2303 00000952 8EE9                            mov     gs, cx
  2304                                  
  2305 00000954 0F20D9                  	mov	ecx, cr3
  2306 00000957 890D[28020300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  2307                                  
  2308                                  	; 14/01/2017
  2309 0000095D 3B0D[80770100]          	cmp 	ecx, [k_page_dir]
  2310 00000963 7409                    	je	short T3
  2311                                  
  2312 00000965 8B0D[80770100]          	mov	ecx, [k_page_dir]
  2313 0000096B 0F22D9                  	mov	cr3, ecx
  2314                                  T3:
  2315                                  	;sti				; INTERRUPTS BACK ON
  2316 0000096E 66FF05[00780100]        	inc	word [TIMER_LOW]	; INCREMENT TIME
  2317 00000975 7507                    	jnz	short T4		; GO TO TEST_DAY
  2318 00000977 66FF05[02780100]        	inc	word [TIMER_HIGH]	; INCREMENT HIGH WORD OF TIME
  2319                                  T4:					; TEST_DAY
  2320 0000097E 66833D[02780100]18      	cmp	word [TIMER_HIGH], 018h	; TEST FOR COUNT EQUALING 24 HOURS
  2321 00000986 7519                    	jnz	short T5		; GO TO DISKETTE_CTL
  2322 00000988 66813D[00780100]B0-     	cmp	word [TIMER_LOW], 0B0h
  2323 00000990 00                 
  2324 00000991 750E                    	jnz	short T5		; GO TO DISKETTE_CTL
  2325                                  
  2326                                  ;-----	TIMER HAS GONE 24 HOURS
  2327                                  	;;sub	ax, ax
  2328                                  	;mov	[TIMER_HIGH], ax
  2329                                  	;mov	[TIMER_LOW], ax
  2330 00000993 29C0                    	sub	eax, eax
  2331 00000995 A3[00780100]            	mov	[TIMER_LH], eax
  2332                                  	;	
  2333 0000099A C605[04780100]01        	mov	byte [TIMER_OFL], 1
  2334                                  
  2335                                  ;-----	TEST FOR DISKETTE TIME OUT
  2336                                  
  2337                                  T5:
  2338                                  	; 23/12/2014
  2339 000009A1 EB1D                    	jmp	short T6		; will be replaced with nop, nop
  2340                                  					; (9090h) if a floppy disk
  2341                                  					; is detected.
  2342                                  	;mov	al, [CS:MOTOR_COUNT]
  2343 000009A3 A0[07780100]            	mov	al, [MOTOR_COUNT]
  2344 000009A8 FEC8                    	dec	al
  2345                                  	;mov	[CS:MOTOR_COUNT], al	; DECREMENT DISKETTE MOTOR CONTROL
  2346 000009AA A2[07780100]            	mov	[MOTOR_COUNT], al
  2347                                  	;mov	[ORG_MOTOR_COUNT], al
  2348 000009AF 750F                    	jnz	short T6		; RETURN IF COUNT NOT OUT
  2349 000009B1 B0F0                    	mov 	al, 0F0h
  2350                                  	;and	[CS:MOTOR_STATUS],al 	; TURN OFF MOTOR RUNNING BITS
  2351 000009B3 2005[06780100]          	and	[MOTOR_STATUS], al
  2352                                  	;and	[ORG_MOTOR_STATUS], al
  2353 000009B9 B00C                    	mov	al, 0Ch			; bit 3 = enable IRQ & DMA, 
  2354                                  					; bit 2 = enable controller
  2355                                  					;	1 = normal operation
  2356                                  					;	0 = reset	
  2357                                  					; bit 0, 1 = drive select
  2358                                  					; bit 4-7 = motor running bits 
  2359 000009BB 66BAF203                	mov	dx, 03F2h		; FDC CTL PORT
  2360 000009BF EE                      	out	dx, al			; TURN OFF THE MOTOR
  2361                                  T6:	
  2362                                  	;inc	word [CS:wait_count]	; 22/12/2014 (byte -> word)
  2363                                  					; TIMER TICK INTERRUPT
  2364                                  	;;inc	word [wait_count] ;;27/02/2015
  2365                                  	;int	1Ch			; TRANSFER CONTROL TO A USER ROUTINE
  2366                                  	;cli
  2367 000009C0 E857040000              	call 	u_timer			; TRANSFER CONTROL TO A USER ROUTINE
  2368                                  	; 23/05/2016
  2369 000009C5 E8B4140100              	call	clock			; Multi Tasking control procedure
  2370                                  T7:
  2371                                  	; 14/10/2015
  2372 000009CA B020                    	mov	al, EOI			; GET END OF INTERRUPT MASK
  2373 000009CC FA                      	cli				; DISABLE INTERRUPTS TILL STACK CLEARED
  2374 000009CD E620                    	out	INTA00, al		; END OF INTERRUPT TO 8259 - 1	
  2375                                  	;
  2376                                  rtc_int_2:
  2377                                  	; 26/12/2016
  2378                                  	;mov	ecx, [cr3reg]
  2379                                  	; 13/01/2017
  2380 000009CF 803D[90010300]00        	cmp	byte [u.t_lock], 0  	; T_LOCK
  2381 000009D6 7730                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !
  2382                                  	; 28/02/2017
  2383                                  	; We need to exit if the user's IRQ callback service is in progress!
  2384                                  	; (To prevent a conflict!)
  2385 000009D8 803D[94010300]00        	cmp	byte [u.r_lock], 0	; R_LOCK, IRQ callback service lock !
  2386 000009DF 7727                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !	
  2387                                  	; 15/01/2017
  2388 000009E1 803D[0C840100]02        	cmp	byte [priority], 2
  2389 000009E8 733A                    	jnb	short T8  ; current process has a timer event (15/01/2017)
  2390                                  	; 22/05/2016
  2391 000009EA 803D[0D840100]00        	cmp	byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p'
  2392 000009F1 7615                    	jna	short timer_int_return ; 23/05/2016
  2393                                  
  2394                                  	; 15/01/2017
  2395                                  	
  2396                                  	; present process must be changed with high priority process	
  2397                                  	;xor	al, al
  2398 000009F3 31C0                    	xor	eax, eax ; 26/12/2016
  2399 000009F5 A2[0D840100]            	mov	[p_change], al ; 0
  2400                                  	;mov	byte [priority], 2 ; 15/01/2017 (there is a timer event)
  2401                                  
  2402 000009FA 803D[10010300]FF        	cmp     byte [sysflg], 0FFh ; user or system space ?
  2403 00000A01 7416                    	je	short rtc_int_3     ; user space ([sysflg]= 0FFh)
  2404                                  
  2405                                  	; system space, wait for 'sysret'
  2406                                  	; to change running process 	
  2407                                  	; with high priority (event) process
  2408                                  
  2409 00000A03 A2[64010300]            	mov	[u.quant], al ; 0
  2410                                  
  2411                                  timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2')
  2412 00000A08 8B0D[28020300]          	mov 	ecx, [cr3reg] 	; previous value/content of cr3 register
  2413 00000A0E 0F22D9                   	mov	cr3, ecx	; restore cr3 register content
  2414                                  	;
  2415 00000A11 61                      	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  2416                                  	;
  2417 00000A12 0FA9                    	pop	gs
  2418 00000A14 0FA1                    	pop	fs
  2419 00000A16 07                      	pop	es
  2420 00000A17 1F                      	pop	ds
  2421                                  	;
  2422 00000A18 CF                      	iretd	; return from interrupt
  2423                                  
  2424                                  rtc_int_3:
  2425 00000A19 FE05[10010300]          	inc	byte [sysflg] 	; now, we are in system space
  2426                                  	;
  2427 00000A1F E9EFC20000                      jmp     sysrelease ; change running process immediatelly 
  2428                                  
  2429                                  T8:
  2430                                  	; 13/01/2017 (eax -> ebx)
  2431                                  	; callback checking... (19/12/2016)
  2432 00000A24 31DB                    	xor	ebx, ebx
  2433 00000A26 871D[8C010300]          	xchg	ebx, [u.tcb] ; callback address (0 = normal return)
  2434 00000A2C 09DB                    	or	ebx, ebx
  2435 00000A2E 74D8                    	jz	short timer_int_return
  2436                                  
  2437                                  	; Set user's callback routine as return address from this interrupt
  2438                                  	; and set normal return address as return address from callback
  2439                                  	; routine!!! (19/12/2016)
  2440                                  	
  2441                                  	; 14/01/2017
  2442                                  	; 13/01/2017 - Timer Lock (T_LOCK)
  2443 00000A30 FE05[90010300]          	inc	byte [u.t_lock]
  2444 00000A36 8A0D[10010300]          	mov	cl, [sysflg]
  2445 00000A3C 880D[91010300]          	mov	[u.t_mode], cl 
  2446                                  
  2447 00000A42 8B2D[1C770100]          	mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  2448 00000A48 83ED14                  	sub	ebp, 20		; eip, cs, eflags, esp, ss
  2449 00000A4B 892D[14010300]           	mov	[u.sp], ebp
  2450 00000A51 8925[18010300]          	mov	[u.usp], esp
  2451                                  
  2452                                  	;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  2453                                  
  2454 00000A57 8B44241C                	mov	eax, [esp+28] ; pushed eax
  2455 00000A5B A3[1C010300]            	mov	[u.r0], eax
  2456                                  
  2457 00000A60 E884010100              	call	wswap ; save user's registers & status
  2458                                  
  2459                                  	; software int is in ring 0 but timer int must return to ring 3
  2460                                  	; so, ring 3 return address and stack registers
  2461                                  	; (eip, cs, eflags, esp, ss) 
  2462                                  	; must be copied to timer int return
  2463                                  	; eip will be replaced by callback service routine address
  2464                                  
  2465 00000A65 C605[10010300]FF        	mov	byte [sysflg], 0FFh ; user mode
  2466                                  
  2467                                  	; system mode (system call)
  2468                                  	;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  2469                                  			    ; ESP (u), SS (UDATA)
  2470                                  
  2471 00000A6C 8B4510                  	mov	eax, [ebp+16]	; SS (UDATA
  2472 00000A6F 89E6                    	mov	esi, esp
  2473 00000A71 50                      	push	eax
  2474 00000A72 50                      	push	eax
  2475 00000A73 89E7                    	mov	edi, esp
  2476 00000A75 893D[18010300]          	mov	[u.usp], edi
  2477 00000A7B B908000000              	mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  2478 00000A80 F3A5                    	rep	movsd
  2479 00000A82 B104                    	mov	cl, 4	
  2480 00000A84 F3AB                    	rep	stosd
  2481 00000A86 893D[14010300]          	mov	[u.sp], edi
  2482 00000A8C 89EE                    	mov	esi, ebp
  2483 00000A8E B105                    	mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  2484 00000A90 F3A5                    	rep	movsd
  2485                                  
  2486 00000A92 8B0D[74010300]          	mov	ecx, [u.pgdir]
  2487 00000A98 890D[28020300]          	mov	[cr3reg], ecx
  2488                                  
  2489                                  	; 13/01/207 (eax -> ebx)
  2490                                  	; EBX = callback routine address (virtual, not physical address!)
  2491                                  
  2492                                  	; 09/01/2017
  2493                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'sysrele'
  2494                                  	;     system call !!!	
  2495                                  	; 25/12/2016
  2496                                  	; Callback Note: (19/12/2016)
  2497                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'RETN' !!!
  2498                                  	;	pushf ; save flags	
  2499                                  	; 	<callback service code>
  2500                                  	; 	popf  ; restore flags
  2501                                  	; 	retn ; return to normal running address
  2502                                  	;
  2503                                  
  2504                                  	; 15/01/2017
  2505                                  	; 14/01/2017
  2506                                  	; 13/01/2017 (eax -> ebx)
  2507                                  	; 10/01/2017
  2508                                  set_callback_addr:
  2509                                  	; 09/01/2017 (**)
  2510                                  	; 02/01/2017 (*)
  2511                                  	; 25/12/2016 (*)
  2512                                  	; 19/12/2016 (TRDOS 386 feature only!)
  2513                                  	;
  2514                                  	; This routine sets return address
  2515                                  	; to start of user's interrupt
  2516                                  	; service (callback) address
  2517                                  	;; and sets callback 'retn' address to normal
  2518                                  	;; return address of user's running code! 
  2519                                  	;
  2520                                  	; INPUT:
  2521                                  	;	EBX = callback routine/service address
  2522                                  	;	      (virtual, not physical address!)	
  2523                                  	;	[u.sp] = kernel stack, points to
  2524                                  	;		 user's EIP,CS,EFLAGS,ESP,SS
  2525                                  	;		 registers.
  2526                                  	; OUTPUT:
  2527                                  	;	EIP (user) = callback (service) address
  2528                                  	;	CS (user) = UCODE
  2529                                  	;	EFLAGS (user) = flags before callback 	 
  2530                                  	;       ESP (user) = ESP-4 (user, before callback) 
  2531                                  	;	[ESP](user) = EIP (user) before callback
  2532                                  	;
  2533                                  	; Note: If CPU was in user mode while entering 
  2534                                  	;	the timer interrupt service routine,
  2535                                  	;	'IRET' will get return to callback routine
  2536                                  	;	immediately. If CPU was in system/kernel mode  
  2537                                  	;	'iret' will get return to system call and
  2538                                  	;	then, callback routine will be return address
  2539                                  	;	from system call. (User's callback/service code
  2540                                  	;	will be able to return to normal return address
  2541                                  	;	via an 'retn' at the end.) 
  2542                                  	;
  2543                                  	; Note(**): User's callback service code must be ended
  2544                                  	;	with a 'sysrele' sytstem call ! (09/01/2017)
  2545                                  	;
  2546                                  	;	For example:
  2547                                  	;
  2548                                  	;	timer_callback:
  2549                                  	;	    ...	 
  2550                                    	;	    inc	dword [time_counter]
  2551                                  	;	    ...
  2552                                  	;	    mov eax, 39 ; 'sysrele'
  2553                                  	;	    int 40h ; TRDOS 386 system call (interrupt)		
  2554                                  	;
  2555                                  	;
  2556                                  	;; Note(*): User's callback service code must preserve cpu 
  2557                                  	;;	flags if it has any instructions which changes
  2558                                  	;;	flags in the service code. (25/12/2016)
  2559                                  	;;
  2560                                  	;;	For example:
  2561                                  	;;
  2562                                  	;;	timer_callback:
  2563                                  	;;	    pushf ; save flags
  2564                                  	;;	    ; this instruction changes zero flag
  2565                                    	;;	    inc	dword [time_counter]
  2566                                  	;;	    popf ; restore flags
  2567                                  	;;	    retn ; return to normal user code
  2568                                  	;;		  (which is interrupted by the 
  2569                                  	;;		   timer interput) 	
  2570                                  	;;
  2571                                  
  2572                                  	; 15/01/2017
  2573 00000A9E 8B2D[14010300]          	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  2574 00000AA4 895D00                  	mov	[ebp], ebx
  2575 00000AA7 E95CFFFFFF              	jmp	timer_int_return
  2576                                  
  2577                                  	; 15/01/2017
  2578                                  	; 13/01/2017
  2579                                  	; 19/12/2016
  2580                                  	; 06/06/2016
  2581                                  	; 23/05/2016
  2582                                  	; 22/05/2016
  2583                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  2584                                  	; 26/02/2015
  2585                                  	; 07/09/2014
  2586                                  	; 25/08/2014
  2587                                  rtc_int:       ; Real Time Clock Interrupt (IRQ 8)
  2588                                  	; 22/05/2016
  2589 00000AAC 1E                      	push	ds ; ** ; 23/05/2016
  2590 00000AAD 50                      	push	eax ; *
  2591 00000AAE 66B81000                	mov	ax, KDATA
  2592 00000AB2 8ED8                    	mov	ds, ax
  2593                                  	;
  2594 00000AB4 8A25[FE770100]          	mov	ah, [RTC_2Hz] ;  2 Hz interrupt to 1 Hz function
  2595 00000ABA 80F401                  	xor	ah, 1
  2596 00000ABD 8825[FE770100]          	mov	[RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second
  2597 00000AC3 753B                    	jnz	short rtc_int_return ; half second
  2598                                  	; 1 second
  2599                                  rtc_int_0:
  2600                                  	; 22/05/2016
  2601 00000AC5 58                      	pop	eax ; *
  2602                                  	;
  2603                                  	; 14/10/2015 ('timer_int')
  2604                                  	; Here, we are simulating system call entry (for task switch)
  2605                                  	; (If multitasking is enabled, 
  2606                                  	; 'clock' procedure may jump to 'sysrelease')
  2607                                  	;push	ds ; ** ; 23/05/2016
  2608 00000AC6 06                      	push	es
  2609 00000AC7 0FA0                    	push	fs
  2610 00000AC9 0FA8                    	push	gs
  2611 00000ACB 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  2612 00000ACC 66B91000                	mov     cx, KDATA
  2613                                          ;mov    ds, cx ; 06/06/2016
  2614 00000AD0 8EC1                            mov     es, cx
  2615 00000AD2 8EE1                            mov     fs, cx
  2616 00000AD4 8EE9                            mov     gs, cx
  2617                                  	;
  2618 00000AD6 0F20D9                  	mov	ecx, cr3
  2619 00000AD9 890D[28020300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  2620                                  	;
  2621 00000ADF 803D[90010300]00        	cmp	byte [u.t_lock], 0 ; timer lock (callback) status ?
  2622 00000AE6 7711                    	ja	short rtc_int_1	   ; yes
  2623                                  
  2624                                  	; 15/01/2017
  2625 00000AE8 3B0D[80770100]          	cmp 	ecx, [k_page_dir]
  2626 00000AEE 7409                    	je	short rtc_int_1
  2627                                  
  2628 00000AF0 8B0D[80770100]          	mov	ecx, [k_page_dir]
  2629 00000AF6 0F22D9                  	mov	cr3, ecx
  2630                                  rtc_int_1:
  2631                                  	; Timer event (kernel) functions must be performed with
  2632                                  	; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! -
  2633                                   	;	
  2634                                  	; 25/08/2014
  2635 00000AF9 E81A030000              	call	rtc_p  ; 19/05/2016 - major modification 
  2636                                  	
  2637                                  	; 23/05/2016
  2638 00000AFE 28E4                    	sub	ah, ah ; 0
  2639                                  	; 22/05/2016 - TRDOS 386 timer event modifications
  2640                                  rtc_int_return: ; 19/05/2016
  2641                                  	; 22/02/2015 - dsectpm.s
  2642                                  	; [ source: http://wiki.osdev.org/RTC ]
  2643                                  	; read status register C to complete procedure
  2644                                  	;(it is needed to get a next IRQ 8) 
  2645 00000B00 B00C                    	mov	al, 0Ch ; 
  2646 00000B02 E670                    	out	70h, al ; select register C
  2647 00000B04 90                      	nop
  2648 00000B05 E471                    	in	al, 71h ; just throw away contents
  2649                                  	; 22/02/2015
  2650 00000B07 B020                    	mov	al, EOI		; END OF INTERRUPT
  2651                                  	;cli			; DISABLE INTERRUPTS TILL STACK CLEARED
  2652 00000B09 E6A0                    	out	INTB00, al	; FOR CONTROLLER #2
  2653                                  
  2654                                  	; 23/05/2016
  2655 00000B0B B020                    	mov	al, EOI		; GET END OF INTERRUPT MASK
  2656 00000B0D FA                      	cli			; DISABLE INTERRUPTS TILL STACK CLEARED
  2657 00000B0E E620                    	out	INTA00, al	; END OF INTERRUPT TO 8259 - 1	
  2658                                  	;
  2659                                  	; 23/05/2016
  2660 00000B10 20E4                    	and	ah, ah
  2661                                  	;jz	rtc_int_2
  2662                                  	; 24/07/2022
  2663 00000B12 7505                    	jnz	short rtc_int_4
  2664 00000B14 E9B6FEFFFF              	jmp	rtc_int_2
  2665                                  rtc_int_4:	
  2666                                  	; ah = 1 (half second)
  2667 00000B19 58                      	pop	eax ; *
  2668 00000B1A 1F                      	pop	ds  ; **
  2669 00000B1B CF                      	iretd
  2670                                  
  2671                                  ; ////////////////
  2672                                  
  2673                                  	; 28/08/2014
  2674                                  irq0:
  2675 00000B1C 6A00                            push 	dword 0
  2676 00000B1E EB48                    	jmp	short which_irq
  2677                                  irq1:
  2678 00000B20 6A01                            push 	dword 1
  2679 00000B22 EB44                    	jmp	short which_irq
  2680                                  irq2:
  2681 00000B24 6A02                            push 	dword 2
  2682 00000B26 EB40                    	jmp	short which_irq
  2683                                  irq3:
  2684                                  	; 20/11/2015
  2685                                  	; 24/10/2015
  2686 00000B28 2EFF15[39210100]        	call	dword [cs:com2_irq3]
  2687 00000B2F 6A03                    	push 	dword 3
  2688 00000B31 EB35                    	jmp	short which_irq
  2689                                  irq4:
  2690                                  	; 20/11/2015
  2691                                  	; 24/10/2015
  2692 00000B33 2EFF15[35210100]        	call	dword [cs:com1_irq4]
  2693 00000B3A 6A04                            push 	dword 4
  2694 00000B3C EB2A                    	jmp	short which_irq
  2695                                  irq5:
  2696 00000B3E 6A05                            push 	dword 5
  2697 00000B40 EB26                    	jmp	short which_irq
  2698                                  irq6:
  2699 00000B42 6A06                            push 	dword 6
  2700 00000B44 EB22                    	jmp	short which_irq
  2701                                  irq7:
  2702 00000B46 6A07                            push 	dword 7
  2703 00000B48 EB1E                    	jmp	short which_irq
  2704                                  irq8:
  2705 00000B4A 6A08                            push 	dword 8
  2706 00000B4C EB1A                    	jmp	short which_irq
  2707                                  irq9:
  2708 00000B4E 6A09                            push 	dword 9
  2709 00000B50 EB16                    	jmp	short which_irq
  2710                                  irq10:
  2711 00000B52 6A0A                            push 	dword 10
  2712 00000B54 EB12                    	jmp	short which_irq
  2713                                  irq11:
  2714 00000B56 6A0B                            push 	dword 11
  2715 00000B58 EB0E                    	jmp	short which_irq
  2716                                  irq12:
  2717 00000B5A 6A0C                            push 	dword 12
  2718 00000B5C EB0A                    	jmp	short which_irq
  2719                                  irq13:
  2720 00000B5E 6A0D                            push 	dword 13
  2721 00000B60 EB06                    	jmp	short which_irq
  2722                                  irq14:
  2723 00000B62 6A0E                            push 	dword 14
  2724 00000B64 EB02                    	jmp	short which_irq
  2725                                  irq15:
  2726 00000B66 6A0F                            push 	dword 15
  2727                                  	;jmp	short which_irq
  2728                                  
  2729                                  	; 22/01/2017
  2730                                  	; 19/10/2015
  2731                                  	; 29/08/2014
  2732                                  	; 21/08/2014
  2733                                  which_irq:
  2734 00000B68 870424                  	xchg	eax, [esp]  ; 28/08/2014
  2735 00000B6B 53                      	push	ebx
  2736 00000B6C 56                      	push	esi
  2737 00000B6D 57                      	push	edi
  2738 00000B6E 1E                      	push 	ds
  2739 00000B6F 06                      	push 	es
  2740                                  	;
  2741 00000B70 88C3                    	mov	bl, al
  2742                                  	;
  2743 00000B72 B810000000              	mov	eax, KDATA
  2744 00000B77 8ED8                    	mov	ds, ax
  2745 00000B79 8EC0                    	mov	es, ax
  2746                                  	; 19/10/2015
  2747 00000B7B FC                      	cld
  2748                                          ; 27/08/2014
  2749 00000B7C 8105[CA370100]A000-             add     dword [scr_row], 0A0h
  2750 00000B84 0000               
  2751                                  	;
  2752 00000B86 B417                    	mov	ah, 17h	; blue (1) background, 
  2753                                  			; light gray (7) forecolor
  2754 00000B88 8B3D[CA370100]                  mov     edi, [scr_row]
  2755 00000B8E B049                    	mov	al, 'I'
  2756 00000B90 66AB                    	stosw
  2757 00000B92 B052                    	mov	al, 'R'
  2758 00000B94 66AB                    	stosw
  2759 00000B96 B051                    	mov	al, 'Q'
  2760 00000B98 66AB                    	stosw
  2761 00000B9A B020                    	mov	al, ' '
  2762 00000B9C 66AB                    	stosw
  2763 00000B9E 88D8                    	mov	al, bl
  2764 00000BA0 3C0A                    	cmp	al, 10
  2765 00000BA2 7208                    	jb	short ii1
  2766 00000BA4 B031                    	mov	al, '1'
  2767 00000BA6 66AB                    	stosw
  2768 00000BA8 88D8                    	mov	al, bl
  2769 00000BAA 2C0A                    	sub	al, 10
  2770                                  ii1:
  2771 00000BAC 0430                    	add	al, '0'
  2772 00000BAE 66AB                    	stosw
  2773 00000BB0 B020                    	mov	al, ' '
  2774 00000BB2 66AB                    	stosw
  2775 00000BB4 B021                    	mov	al, '!'
  2776 00000BB6 66AB                    	stosw
  2777 00000BB8 B020                    	mov	al, ' '
  2778 00000BBA 66AB                    	stosw
  2779                                  	; 23/02/2015
  2780 00000BBC 80FB07                  	cmp	bl, 7 ; check for IRQ 8 to IRQ 15 
  2781 00000BBF 7604                    	jna	short ii2
  2782                                  	; 22/01/2017
  2783 00000BC1 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2784 00000BC3 E6A0                    	out	0A0h, al ; the 2nd 8259
  2785                                  ii2:
  2786 00000BC5 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2787 00000BC7 E620                    	out	20h, al ; the 2nd 8259
  2788 00000BC9 E9CC010000              	jmp     iiret
  2789                                  	;
  2790                                  	; 22/08/2014
  2791                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2792                                  	;out	20h, al	; 8259 PORT
  2793                                  	;
  2794                                  	;pop	es
  2795                                  	;pop	ds
  2796                                  	;pop	edi
  2797                                  	;pop	esi
  2798                                  	;pop	ebx
  2799                                  	;pop 	eax
  2800                                  	;iret
  2801                                  
  2802                                  	; 02/04/2015
  2803                                  	; 25/08/2014
  2804                                  exc0:
  2805 00000BCE 6A00                            push 	dword 0
  2806 00000BD0 E990000000                      jmp     cpu_except
  2807                                  exc1:
  2808 00000BD5 6A01                            push 	dword 1
  2809 00000BD7 E989000000                      jmp     cpu_except
  2810                                  exc2:
  2811 00000BDC 6A02                            push 	dword 2
  2812 00000BDE E982000000                      jmp     cpu_except
  2813                                  exc3:
  2814 00000BE3 6A03                            push 	dword 3
  2815 00000BE5 EB7E                            jmp     cpu_except
  2816                                  exc4:
  2817 00000BE7 6A04                            push 	dword 4
  2818 00000BE9 EB7A                            jmp     cpu_except
  2819                                  exc5:
  2820 00000BEB 6A05                            push 	dword 5
  2821 00000BED EB76                            jmp     cpu_except
  2822                                  exc6:
  2823 00000BEF 6A06                            push 	dword 6
  2824 00000BF1 EB72                            jmp     cpu_except
  2825                                  exc7:
  2826 00000BF3 6A07                            push 	dword 7
  2827 00000BF5 EB6E                            jmp     cpu_except
  2828                                  exc8:
  2829                                  	; [esp] = Error code
  2830 00000BF7 6A08                            push 	dword 8
  2831 00000BF9 EB5C                            jmp     cpu_except_en
  2832                                  exc9:
  2833 00000BFB 6A09                            push 	dword 9
  2834 00000BFD EB66                            jmp     cpu_except
  2835                                  exc10:
  2836                                  	; [esp] = Error code
  2837 00000BFF 6A0A                            push 	dword 10
  2838 00000C01 EB54                            jmp     cpu_except_en
  2839                                  exc11:
  2840                                  	; [esp] = Error code
  2841 00000C03 6A0B                            push 	dword 11
  2842 00000C05 EB50                            jmp     cpu_except_en
  2843                                  exc12:
  2844                                  	; [esp] = Error code
  2845 00000C07 6A0C                            push 	dword 12
  2846 00000C09 EB4C                            jmp     cpu_except_en
  2847                                  exc13:
  2848                                  	; [esp] = Error code
  2849 00000C0B 6A0D                            push 	dword 13
  2850 00000C0D EB48                            jmp     cpu_except_en
  2851                                  exc14:
  2852                                  	; [esp] = Error code
  2853 00000C0F 6A0E                            push 	dword 14
  2854 00000C11 EB44                    	jmp	short cpu_except_en
  2855                                  exc15:
  2856 00000C13 6A0F                            push 	dword 15
  2857 00000C15 EB4E                            jmp     cpu_except
  2858                                  exc16:
  2859 00000C17 6A10                            push 	dword 16
  2860 00000C19 EB4A                            jmp     cpu_except
  2861                                  exc17:
  2862                                  	; [esp] = Error code
  2863 00000C1B 6A11                            push 	dword 17
  2864 00000C1D EB38                    	jmp	short cpu_except_en
  2865                                  exc18:
  2866 00000C1F 6A12                            push 	dword 18
  2867 00000C21 EB42                    	jmp	short cpu_except
  2868                                  exc19:
  2869 00000C23 6A13                            push 	dword 19
  2870 00000C25 EB3E                    	jmp	short cpu_except
  2871                                  exc20:
  2872 00000C27 6A14                            push 	dword 20
  2873 00000C29 EB3A                    	jmp	short cpu_except
  2874                                  exc21:
  2875 00000C2B 6A15                            push 	dword 21
  2876 00000C2D EB36                    	jmp	short cpu_except
  2877                                  exc22:
  2878 00000C2F 6A16                            push 	dword 22
  2879 00000C31 EB32                    	jmp	short cpu_except
  2880                                  exc23:
  2881 00000C33 6A17                            push 	dword 23
  2882 00000C35 EB2E                    	jmp	short cpu_except
  2883                                  exc24:
  2884 00000C37 6A18                            push 	dword 24
  2885 00000C39 EB2A                    	jmp	short cpu_except
  2886                                  exc25:
  2887 00000C3B 6A19                            push 	dword 25
  2888 00000C3D EB26                    	jmp	short cpu_except
  2889                                  exc26:
  2890 00000C3F 6A1A                            push 	dword 26
  2891 00000C41 EB22                    	jmp	short cpu_except
  2892                                  exc27:
  2893 00000C43 6A1B                            push 	dword 27
  2894 00000C45 EB1E                    	jmp	short cpu_except
  2895                                  exc28:
  2896 00000C47 6A1C                            push 	dword 28
  2897 00000C49 EB1A                    	jmp	short cpu_except
  2898                                  exc29:
  2899 00000C4B 6A1D                            push 	dword 29
  2900 00000C4D EB16                    	jmp	short cpu_except
  2901                                  exc30:
  2902 00000C4F 6A1E                            push 	dword 30
  2903 00000C51 EB04                    	jmp	short cpu_except_en
  2904                                  exc31:
  2905 00000C53 6A1F                            push 	dword 31
  2906 00000C55 EB0E                            jmp     short cpu_except
  2907                                  
  2908                                  	; 19/10/2015
  2909                                  	; 19/09/2015
  2910                                  	; 01/09/2015
  2911                                  	; 28/08/2015
  2912                                  	; 28/08/2014
  2913                                  cpu_except_en:
  2914 00000C57 87442404                	xchg	eax, [esp+4] ; Error code
  2915 00000C5B 36A3[2C030300]          	mov	[ss:error_code], eax
  2916 00000C61 58                      	pop	eax  ; Exception number
  2917 00000C62 870424                  	xchg	eax, [esp]
  2918                                  		; eax = eax before exception
  2919                                  		; [esp] -> exception number
  2920                                  		; [esp+4] -> EIP to return
  2921                                  	; 22/01/2017
  2922                                  	; 19/10/2015
  2923                                  	; 19/09/2015
  2924                                  	; 01/09/2015
  2925                                  	; 28/08/2015
  2926                                  	; 29/08/2014
  2927                                  	; 28/08/2014
  2928                                  	; 25/08/2014
  2929                                  	; 21/08/2014
  2930                                  cpu_except:	; CPU Exceptions
  2931 00000C65 FC                      	cld
  2932 00000C66 870424                  	xchg	eax, [esp] 
  2933                                  		; eax = Exception number
  2934                                  		; [esp] = eax (before exception)	
  2935 00000C69 53                      	push	ebx
  2936 00000C6A 56                      	push	esi
  2937 00000C6B 57                      	push	edi
  2938 00000C6C 1E                      	push 	ds
  2939 00000C6D 06                      	push 	es
  2940                                  	; 28/08/2015
  2941 00000C6E 66BB1000                	mov	bx, KDATA
  2942 00000C72 8EDB                    	mov	ds, bx
  2943 00000C74 8EC3                    	mov	es, bx
  2944 00000C76 0F20DB                  	mov	ebx, cr3
  2945 00000C79 53                      	push	ebx ; (*) page directory
  2946                                  	; 19/10/2015
  2947 00000C7A FC                      	cld
  2948                                  	; 25/03/2015
  2949 00000C7B 8B1D[80770100]          	mov	ebx, [k_page_dir]
  2950 00000C81 0F22DB                  	mov	cr3, ebx
  2951                                  	; 28/08/2015
  2952 00000C84 83F80E                  	cmp	eax, 0Eh ; 14, PAGE FAULT	
  2953 00000C87 7510                    	jne	short cpu_except_nfp
  2954 00000C89 E8BD4C0000              	call	page_fault_handler
  2955 00000C8E 21C0                    	and 	eax, eax
  2956                                  	;jz	iiretp ; 01/09/2015
  2957                                  	; 24/07/2022
  2958 00000C90 7505                    	jnz	short cpu_except_pf
  2959 00000C92 E9FF000000              	jmp	iiretp
  2960                                  cpu_except_pf:	; 24/07/2022
  2961 00000C97 B00E                    	mov	al, 0Eh ; 14
  2962                                  cpu_except_nfp:
  2963                                  	; 23/08/2016
  2964 00000C99 803D[9E660000]03        	cmp	byte [CRT_MODE], 3
  2965 00000CA0 7409                    	je	short cpu_except_mode_3
  2966 00000CA2 50                      	push	eax
  2967 00000CA3 B003                    	mov	al, 3
  2968 00000CA5 E8220E0000              	call	_set_mode
  2969 00000CAA 58                      	pop	eax
  2970                                  cpu_except_mode_3:
  2971                                  	; 02/04/2015
  2972 00000CAB BB[FB080000]            	mov	ebx, hang
  2973 00000CB0 875C241C                	xchg	ebx, [esp+28]
  2974                                  		; EIP (points to instruction which faults)
  2975                                  	  	; New EIP (hang)
  2976 00000CB4 891D[30030300]          	mov	[FaultOffset], ebx
  2977 00000CBA C744242008000000        	mov	dword [esp+32], KCODE ; kernel's code segment
  2978 00000CC2 814C242400020000        	or	dword [esp+36], 200h ; enable interrupts (set IF)
  2979                                  	;
  2980 00000CCA 88C4                    	mov	ah, al
  2981 00000CCC 240F                    	and	al, 0Fh
  2982 00000CCE 3C09                    	cmp	al, 9
  2983 00000CD0 7602                    	jna	short h1ok
  2984 00000CD2 0407                    	add	al, 'A'-':'
  2985                                  h1ok:
  2986 00000CD4 C0EC04                  	shr	ah, 4
  2987 00000CD7 80FC09                  	cmp	ah, 9
  2988 00000CDA 7603                    	jna	short h2ok
  2989 00000CDC 80C407                  	add	ah, 'A'-':'
  2990                                  h2ok:	
  2991 00000CDF 86E0                    	xchg 	ah, al	
  2992 00000CE1 66053030                	add	ax, '00'
  2993 00000CE5 66A3[243A0100]          	mov	[excnstr], ax
  2994                                  	;
  2995                                  	; 29/08/2014
  2996 00000CEB A1[30030300]            	mov	eax, [FaultOffset]
  2997 00000CF0 51                      	push	ecx
  2998 00000CF1 52                      	push	edx
  2999 00000CF2 89E3                    	mov	ebx, esp
  3000                                  	; 28/08/2015
  3001 00000CF4 B910000000              	mov	ecx, 16	  ; divisor value to convert binary number
  3002                                  			  ; to hexadecimal string
  3003                                  	;mov	ecx, 10	    ; divisor to convert	
  3004                                  			    ; binary number to decimal string
  3005                                  b2d1:
  3006 00000CF9 31D2                    	xor	edx, edx
  3007 00000CFB F7F1                    	div	ecx
  3008                                  	;push	dx
  3009                                  	; 18/04/2021
  3010 00000CFD 52                      	push	edx
  3011 00000CFE 39C8                    	cmp	eax, ecx
  3012 00000D00 73F7                    	jnb	short b2d1
  3013 00000D02 BF[2F3A0100]            	mov	edi, EIPstr ; EIP value
  3014                                  			    ; points to instruction which faults	
  3015                                  	; 28/08/2015
  3016 00000D07 89C2                    	mov	edx, eax
  3017                                  b2d2:
  3018                                  	;add	al, '0'
  3019 00000D09 8A82[47410000]          	mov	al, [edx+hexchrs]
  3020 00000D0F AA                      	stosb		    ; write hexadecimal digit to its place	
  3021 00000D10 39E3                    	cmp	ebx, esp
  3022 00000D12 7605                    	jna	short b2d3
  3023                                  	;pop	ax
  3024                                  	; 18/04/2021
  3025 00000D14 58                      	pop	eax
  3026 00000D15 88C2                    	mov	dl, al
  3027 00000D17 EBF0                    	jmp	short b2d2
  3028                                  b2d3:
  3029 00000D19 B068                    	mov 	al, 'h' ; 28/08/2015
  3030 00000D1B AA                      	stosb
  3031 00000D1C B020                    	mov	al, 20h	    ; space
  3032 00000D1E AA                      	stosb
  3033 00000D1F 30C0                    	xor	al, al	    ; to do it an ASCIIZ string	
  3034 00000D21 AA                      	stosb
  3035                                  	;
  3036 00000D22 5A                      	pop	edx
  3037 00000D23 59                      	pop	ecx
  3038                                  	;
  3039 00000D24 B44F                    	mov	ah, 4Fh	; red (4) background, 
  3040                                  			; white (F) forecolor
  3041 00000D26 BE[143A0100]            	mov	esi, exc_msg ; message offset
  3042                                  	;
  3043                                  	; 20/01/2017 (!cpu exception!)
  3044                                  	;
  3045 00000D2B 8105[CA370100]A000-             add	dword [scr_row], 0A0h
  3046 00000D33 0000               
  3047 00000D35 8B3D[CA370100]                  mov	edi, [scr_row]
  3048                                  	;	
  3049 00000D3B C605[10010300]00        	mov	byte [sysflg], 0  ; system mode
  3050 00000D42 FB                              sti
  3051                                  	;
  3052 00000D43 E8EDFBFFFF              	call 	printk
  3053                                  	;
  3054 00000D48 B410                    	mov	ah, 10h
  3055 00000D4A E87F010000              	call	int16h ; getc
  3056                                  	;
  3057 00000D4F B003                    	mov	al, 3
  3058 00000D51 E8760D0000              	call	_set_mode
  3059                                  	;
  3060 00000D56 B801000000              	mov	eax, 1
  3061 00000D5B E9CFC00000              	jmp	sysexit ; terminate process !!!
  3062                                  	
  3063                                  	; 22/01/2017
  3064                                  	; 18/04/2016
  3065                                  	; 28/08/2015
  3066                                  	; 23/02/2015
  3067                                  	; 20/08/2014
  3068                                  ignore_int:
  3069 00000D60 50                      	push	eax
  3070 00000D61 53                      	push	ebx ; 23/02/2015
  3071 00000D62 56                      	push	esi
  3072 00000D63 57                      	push	edi
  3073 00000D64 1E                      	push 	ds
  3074 00000D65 06                      	push 	es
  3075                                  	; 18/04/2016
  3076 00000D66 66B81000                	mov	ax, KDATA
  3077 00000D6A 8ED8                    	mov	ds, ax
  3078 00000D6C 8EC0                    	mov	es, ax
  3079                                  	; 28/08/2015
  3080 00000D6E 0F20D8                  	mov	eax, cr3
  3081 00000D71 50                      	push	eax ; (*) page directory
  3082                                  	;
  3083 00000D72 B467                    	mov	ah, 67h	; brown (6) background, 
  3084                                  			; light gray (7) forecolor
  3085 00000D74 BE[DC380100]            	mov	esi, int_msg ; message offset
  3086                                  piemsg:
  3087                                          ; 27/08/2014
  3088 00000D79 8105[CA370100]A000-             add     dword [scr_row], 0A0h
  3089 00000D81 0000               
  3090 00000D83 8B3D[CA370100]                  mov     edi, [scr_row]
  3091                                          ;
  3092 00000D89 E8A7FBFFFF              	call 	printk
  3093                                  	;
  3094                                  	; 23/02/2015
  3095 00000D8E B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  3096 00000D90 E6A0                    	out	0A0h, al ; the 2nd 8259
  3097                                  	; 22/08/2014
  3098 00000D92 B020                    	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  3099 00000D94 E620                    	out	20h, al	; 8259 PORT
  3100                                  iiretp: 
  3101                                  	; 22/01/2017
  3102                                  	; 01/09/2015
  3103                                  	; 28/08/2015
  3104 00000D96 58                      	pop	eax ; (*) page directory
  3105 00000D97 0F22D8                  	mov	cr3, eax
  3106                                  iiret:
  3107 00000D9A 07                      	pop	es
  3108 00000D9B 1F                      	pop	ds
  3109 00000D9C 5F                      	pop	edi
  3110 00000D9D 5E                      	pop	esi
  3111 00000D9E 5B                      	pop	ebx ; 29/08/2014
  3112 00000D9F 58                      	pop 	eax
  3113 00000DA0 CF                      	iretd
  3114                                  
  3115                                  	; 23/05/2016
  3116                                  	; 22/08/2014
  3117                                  	; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm)
  3118                                  	; (INT 1Ah)
  3119                                  	;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991)
  3120                                  time_of_day:
  3121 00000DA1 E8F3550000              	call	UPD_IPR			; WAIT TILL UPDATE NOT IN PROGRESS
  3122 00000DA6 726F                            jc      short time_of_day_retn ; 23/05/2016
  3123 00000DA8 B000                    	mov	al, CMOS_SECONDS
  3124 00000DAA E820560000              	call	CMOS_READ
  3125 00000DAF A2[F0770100]            	mov	[time_seconds], al 
  3126 00000DB4 B002                    	mov	al, CMOS_MINUTES
  3127 00000DB6 E814560000              	call	CMOS_READ
  3128 00000DBB A2[F1770100]            	mov	[time_minutes], al 
  3129 00000DC0 B004                    	mov	al, CMOS_HOURS
  3130 00000DC2 E808560000              	call	CMOS_READ
  3131 00000DC7 A2[F2770100]                    mov     [time_hours], al
  3132 00000DCC B006                    	mov	al, CMOS_DAY_WEEK 
  3133 00000DCE E8FC550000              	call	CMOS_READ
  3134 00000DD3 A2[F3770100]            	mov	[date_wday], al
  3135 00000DD8 B007                     	mov	al, CMOS_DAY_MONTH
  3136 00000DDA E8F0550000              	call	CMOS_READ
  3137 00000DDF A2[F4770100]            	mov	[date_day], al
  3138 00000DE4 B008                    	mov	al, CMOS_MONTH
  3139 00000DE6 E8E4550000              	call	CMOS_READ
  3140 00000DEB A2[F5770100]            	mov	[date_month], al
  3141 00000DF0 B009                    	mov	al, CMOS_YEAR
  3142 00000DF2 E8D8550000              	call	CMOS_READ
  3143 00000DF7 A2[F6770100]            	mov	[date_year], al
  3144 00000DFC B032                    	mov	al, CMOS_CENTURY
  3145 00000DFE E8CC550000              	call	CMOS_READ
  3146 00000E03 A2[F7770100]            	mov	[date_century], al
  3147                                  	;
  3148 00000E08 B000                    	mov	al, CMOS_SECONDS
  3149 00000E0A E8C0550000              	call 	CMOS_READ
  3150 00000E0F 3A05[F0770100]          	cmp	al, [time_seconds]
  3151 00000E15 758A                    	jne	short time_of_day
  3152                                  
  3153                                  time_of_day_retn:
  3154 00000E17 C3                      	retn
  3155                                  
  3156                                  	; 15/01/2017
  3157                                  	; 10/06/2016
  3158                                  	; 07/06/2016
  3159                                  	; 06/06/2016
  3160                                  	; 23/05/2016
  3161                                  rtc_p:
  3162 00000E18 B101                    	mov	cl, 1 ; 15/01/2017
  3163 00000E1A EB02                    	jmp	short rtc_p0
  3164                                  u_timer: 
  3165                                  	; Timer Events with 18.2 Hz Timer Ticks
  3166                                  	; (and also timer events with RTC seconds)
  3167 00000E1C 28C9                    	sub	cl, cl ; mov cl, 0 ; 15/01/2017
  3168                                  rtc_p0:
  3169                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  3170                                  	; Major Modification:
  3171                                  	; Check and Perform Timer Events (for RTC)
  3172                                  	; 25/08/2014 - 07/09/2014
  3173                                  	; Retro UNIX 386 v1:
  3174                                   	; Print Real Time Clock content
  3175                                  	
  3176                                  	; 15/01/2017
  3177 00000E1E 880D[0C840100]          	mov	byte [priority], cl ; 0 or 1 (not 2)
  3178 00000E24 8A2D[0F840100]          	mov	ch, [timer_events]
  3179 00000E2A 20ED                    	and	ch, ch
  3180 00000E2C 7420                    	jz	short rtc_p3
  3181                                  
  3182 00000E2E BE[2C020300]            	mov	esi, timer_set  ; beginning address of
  3183                                  				; timer events space
  3184                                  rtc_p1:
  3185 00000E33 8B06                    	mov	eax, [esi]	
  3186 00000E35 20C0                    	and	al, al ; 0 = free, >0 = process no.
  3187 00000E37 7416                    	jz	short rtc_p4
  3188                                  	;
  3189 00000E39 C1C810                  	ror	eax, 16
  3190                                  	; ah = response value, al = interrupt type
  3191                                  	; 15/01/2017
  3192                                  	; cl = interrupt source
  3193                                  	;       1 = RTC, 0 = PIT  	 	
  3194 00000E3C 38C8                    	cmp	al, cl 
  3195 00000E3E 750A                    	jne	short rtc_p2 ; not as requested or undefined !
  3196 00000E40 3C01                    	cmp	al, 1 ; 1 ; RTC interrupt ?
  3197 00000E42 7410                    	je	short rtc_p5 ; yes, check for response
  3198                                  	; 06/06/2016 - 18.2 Hz Timer Ticks
  3199 00000E44 836E080A                	sub	dword [esi+8], 10 ; 1 tick = 10
  3200 00000E48 7613                    	jna	short rtc_p6  ; continue for responding
  3201                                  rtc_p2:
  3202                                  	; 15/01/2017 (cl -> ch)
  3203                                  	; 07/06/2016
  3204 00000E4A FECD                    	dec	ch    ; remain count of timer events	
  3205 00000E4C 7501                    	jnz	short rtc_p4
  3206                                  rtc_p3:	 
  3207 00000E4E C3                      	retn
  3208                                  rtc_p4:	
  3209                                  	;cmp	esi, timer_set + 240 ; 15*16 (last event)
  3210                                  	;jnb	short rtc_p3 ; end of timer event space
  3211 00000E4F 83C610                  	add	esi, 16 ; next timer event
  3212 00000E52 EBDF                    	jmp	short rtc_p1
  3213                                  rtc_p5:	 
  3214                                  	; current timer count ; 06/06/2016 (182)
  3215 00000E54 816E08B6000000          	sub	dword [esi+8], 182 ; 1 second (10*18.2)
  3216 00000E5B 77ED                    	ja	short rtc_p2  ; check for the next 
  3217                                  rtc_p6:	
  3218                                  	; it is the time of response! 
  3219 00000E5D 8B5E04                  	mov	ebx, [esi+4] ; set (count limit) value
  3220 00000E60 895E08                  	mov	[esi+8], ebx ; reset count down value
  3221                                  			     ; to count limit
  3222                                  	; 19/12/2016
  3223                                  	; 10/12/2016 - timer callback modification
  3224 00000E63 8B7E0C                  	mov	edi, [esi+12] ; response (or callback) address	
  3225 00000E66 807E0100                	cmp	byte [esi+1], 0 ; >0 = callback
  3226 00000E6A 762A                    	jna	short rtc_p8
  3227                                  
  3228                                  	; timer callback !
  3229 00000E6C 0FB61E                  	movzx	ebx, byte [esi] ; process number (>0)
  3230 00000E6F 89D8                    	mov	eax, ebx
  3231 00000E71 C0E302                  	shl	bl, 2 ; *4
  3232 00000E74 89BB[BC000300]          	mov	[ebx+p.tcb-4], edi ; user's callback service addr
  3233 00000E7A 3A05[6D010300]          	cmp	al, [u.uno]
  3234 00000E80 7521                    	jne	short rtc_p9
  3235 00000E82 893D[8C010300]          	mov	[u.tcb], edi
  3236                                  rtc_p7:
  3237                                  	; 15/01/2017
  3238 00000E88 B002                    	mov	al, 2
  3239 00000E8A A2[0C840100]            	mov	[priority], al ; 2
  3240                                  	; 10/01/2017
  3241                                  	;mov	byte [u.pri], 2
  3242 00000E8F A2[66010300]            	mov	[u.pri], al ; 2
  3243 00000E94 EBB4                    	jmp	short rtc_p2
  3244                                  rtc_p8:
  3245                                  	; response address is physical address of
  3246                                  	; the program's response (signal return) byte
  3247                                  	; 06/06/2016
  3248                                  	;mov	edi, [esi+12] ; response address
  3249 00000E96 8827                    	mov	[edi], ah     ; response value 
  3250                                  	;
  3251 00000E98 C1C010                  	rol	eax, 16
  3252                                  	; 15/01/2017
  3253 00000E9B 3A05[6D010300]          	cmp	al, [u.uno] ; running process ?
  3254 00000EA1 74E5                    	je	short rtc_p7
  3255                                  rtc_p9:
  3256                                  	; al = process number  ; 10/06/2016
  3257 00000EA3 B202                    	mov	dl, 2 ; priority, 2 = event (high)	
  3258 00000EA5 E8890F0100              	call	set_run_sequence ; 19/05/2016
  3259 00000EAA EB9E                    	jmp	short rtc_p2 ; 10/06/2016
  3260                                  
  3261                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  3262                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  3263                                  default_irq7:
  3264                                  	;push	ax
  3265                                  	; 18/04/2021
  3266 00000EAC 50                      	push	eax
  3267 00000EAD B00B                    	mov	al, 0Bh  ; In-Service register
  3268 00000EAF E620                    	out	20h, al
  3269 00000EB1 EB00                            jmp short $+2
  3270 00000EB3 EB00                    	jmp short $+2
  3271 00000EB5 E420                    	in	al, 20h
  3272 00000EB7 2480                    	and 	al, 80h ; bit 7 (is it real IRQ 7 or fake?)
  3273 00000EB9 7404                            jz      short irq7_iret ; Fake (spurious) IRQ, do not send EOI 
  3274 00000EBB B020                            mov     al, 20h ; EOI
  3275 00000EBD E620                    	out	20h, al 
  3276                                  irq7_iret:
  3277                                  	;pop	ax
  3278                                  	; 18/04/2021
  3279 00000EBF 58                      	pop	eax
  3280 00000EC0 CF                      	iretd
  3281                                  	
  3282                                  bcd_to_ascii:
  3283                                  	; 25/08/2014
  3284                                  	; INPUT ->
  3285                                  	;	al = Packed BCD number
  3286                                  	; OUTPUT ->
  3287                                  	;	ax  = ASCII word/number
  3288                                  	;
  3289                                  	; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011)
  3290                                  	;
  3291 00000EC1 D410                    	db	0D4h, 10h	; Undocumented inst. AAM
  3292                                  				; AH = AL / 10h
  3293                                  				; AL = AL MOD 10h
  3294 00000EC3 660D3030                	or	ax, '00'	; Make it ASCII based
  3295                                  
  3296 00000EC7 86E0                            xchg	ah, al 
  3297                                  	
  3298 00000EC9 C3                      	retn
  3299                                  
  3300                                  ; 15/12/2020
  3301                                  real_mem_16m_64k: 
  3302 00000ECA 0000                    	dw 0		; Real size of system memory (if > 16MB)
  3303                                  			; as number of 64K blocks - 256
  3304                                  			; (This is for saving real system memory
  3305                                  			; because if system memory is larger than
  3306                                  			; 3 GB and if a VESA VBE video bios
  3307                                  			; is detected, 'mem_16m_64K' may be
  3308                                  			; decreased to reserve LFB space 
  3309                                  			; at the end of system memory.)
  3310                                  			; Upper memory space from LFB base address
  3311                                  			; to 4GB will not be included by M.A.T.
  3312                                  def_LFB_addr:	
  3313 00000ECC 0000                    	dw 0		; HW of default LFB addr (for mode 118h)	
  3314                                  	
  3315                                  
  3316                                  %include 'keyboard.s' ; 07/03/2015
  3317                              <1> ; ****************************************************************************
  3318                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - keyboard.s
  3319                              <1> ; ----------------------------------------------------------------------------
  3320                              <1> ; Last Update: 07/08/2022 (Previous: 12/04/2021)
  3321                              <1> ; ----------------------------------------------------------------------------
  3322                              <1> ; Beginning: 17/01/2016
  3323                              <1> ; ----------------------------------------------------------------------------
  3324                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  3325                              <1> ; ----------------------------------------------------------------------------
  3326                              <1> ; Turkish Rational DOS
  3327                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  3328                              <1> ;
  3329                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  3330                              <1> ; keyboard.inc (17/10/2015)
  3331                              <1> ;
  3332                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
  3333                              <1> ; ****************************************************************************
  3334                              <1> 
  3335                              <1> ; Ref: Retro UNIX 386 v1.2 - keyboard.s - 11/06/2022
  3336                              <1> 
  3337                              <1> ; Retro UNIX 386 v1 Kernel - KEYBOARD.INC
  3338                              <1> ; Last Modification: 17/10/2015
  3339                              <1> ;		    (Keyboard Data is in 'KYBDATA.INC')	
  3340                              <1> ;
  3341                              <1> ; ///////// KEYBOARD FUNCTIONS (PROCEDURES) ///////////////
  3342                              <1> 
  3343                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
  3344                              <1> 
  3345                              <1> ; 03/12/2014
  3346                              <1> ; 26/08/2014
  3347                              <1> ; KEYBOARD I/O
  3348                              <1> ; (INT_16h - Retro UNIX 8086 v1 - U9.ASM, 30/06/2014)
  3349                              <1> 
  3350                              <1> ;NOTE: 'k0' to 'k7' are name of OPMASK registers.
  3351                              <1> ;	(The reason of using '_k' labels!!!) (27/08/2014)    
  3352                              <1> ;NOTE: 'NOT' keyword is '~' unary operator in NASM.
  3353                              <1> ;	('NOT LC_HC' --> '~LC_HC') (bit reversing operator)
  3354                              <1> 
  3355                              <1> int16h:	; 30/06/2015
  3356                              <1> ;getc:
  3357 00000ECE 9C                  <1> 	pushfd	; 28/08/2014
  3358 00000ECF 0E                  <1> 	push 	cs
  3359 00000ED0 E826000000          <1> 	call 	KEYBOARD_IO_1 ; getc_int
  3360 00000ED5 C3                  <1> 	retn	
  3361                              <1> 
  3362                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
  3363                              <1> 
  3364                              <1> 	;-----	SHIFT STATUS
  3365                              <1> _K3E:                                   ; GET THE EXTENDED SHIFT STATUS FLAGS
  3366 00000ED6 8A25[6A660000]      <1> 	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
  3367 00000EDC 80E404              <1> 	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
  3368                              <1> 	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
  3369                              <1> 	;shl	ah, cl			; BIT 7 POSITION
  3370 00000EDF C0E405              <1>         shl	ah, 5
  3371 00000EE2 A0[6A660000]        <1> 	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
  3372 00000EE7 2473                <1> 	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
  3373 00000EE9 08C4                <1> 	or	ah, al                  ; MERGE REMAINING BITS INTO AH
  3374 00000EEB A0[6C660000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
  3375 00000EF0 240C                <1> 	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
  3376 00000EF2 08C4                <1> 	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
  3377                              <1> _K3:
  3378 00000EF4 A0[69660000]        <1> 	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
  3379                              <1> 	; 24/07/2022
  3380 00000EF9 EB38                <1> 	jmp	short _KIO_EXIT		; RETURN TO CALLER
  3381                              <1> 
  3382                              <1> getc_int:
  3383                              <1> 	; 28/02/2015
  3384                              <1> 	; 03/12/2014 (derivation from pc-xt-286 bios source code -1986-, 
  3385                              <1> 	;	      instead of pc-at bios - 1985-)
  3386                              <1> 	; 28/08/2014 (_k1d)
  3387                              <1> 	; 30/06/2014
  3388                              <1> 	; 03/03/2014
  3389                              <1> 	; 28/02/2014
  3390                              <1> 	; Derived from "KEYBOARD_IO_1" procedure of IBM "pc-xt-286" 
  3391                              <1> 	; rombios source code (21/04/1986)
  3392                              <1> 	;	 'keybd.asm', INT 16H, KEYBOARD_IO
  3393                              <1> 	;
  3394                              <1> 	; KYBD --- 03/06/86  KEYBOARD BIOS
  3395                              <1> 	;
  3396                              <1> 	;--- INT 16 H -----------------------------------------------------------------
  3397                              <1> 	; KEYBOARD I/O								      :
  3398                              <1> 	;	THESE ROUTINES PROVIDE READ KEYBOARD SUPPORT			      :
  3399                              <1> 	; INPUT									      :
  3400                              <1> 	;	(AH)= 00H  READ THE NEXT ASCII CHARACTER ENTERED FROM THE KEYBOARD,   :
  3401                              <1> 	;		   RETURN THE RESULT IN (AL), SCAN CODE IN (AH).              :
  3402                              <1> 	;		   THIS IS THE COMPATIBLE READ INTERFACE, EQUIVALENT TO THE   :
  3403                              <1> 	;                  STANDARD PC OR PCAT KEYBOARD				      :	
  3404                              <1> 	;-----------------------------------------------------------------------------:
  3405                              <1> 	;	(AH)= 01H  SET THE ZERO FLAG TO INDICATE IF AN ASCII CHARACTER IS     :
  3406                              <1> 	;		   AVAILABLE TO BE READ FROM THE KEYBOARD BUFFER.	      :
  3407                              <1> 	;		   (ZF)= 1 -- NO CODE AVAILABLE			              :
  3408                              <1> 	;		   (ZF)= 0 -- CODE IS AVAILABLE  (AX)= CHARACTER              :
  3409                              <1> 	;		   IF (ZF)= 0, THE NEXT CHARACTER IN THE BUFFER TO BE READ IS :
  3410                              <1> 	;		   IN (AX), AND THE ENTRY REMAINS IN THE BUFFER.              :
  3411                              <1> 	;		   THIS WILL RETURN ONLY PC/PCAT KEYBOARD COMPATIBLE CODES    :
  3412                              <1> 	;-----------------------------------------------------------------------------:	
  3413                              <1> 	;	(AH)= 02H  RETURN THE CURRENT SHIFT STATUS IN AL REGISTER             :
  3414                              <1> 	;		   THE BIT SETTINGS FOR THIS CODE ARE INDICATED IN THE        :
  3415                              <1> 	;		   EQUATES FOR @KB_FLAG		                              :
  3416                              <1> 	;-----------------------------------------------------------------------------:	
  3417                              <1> 	;	(AH)= 03H  SET TYPAMATIC RATE AND DELAY                               :
  3418                              <1> 	;	      (AL) = 05H                                                      :
  3419                              <1> 	;	      (BL) = TYPAMATIC RATE (BITS 5 - 7 MUST BE RESET TO 0)           :
  3420                              <1> 	;		       							      :
  3421                              <1> 	;                     REGISTER     RATE      REGISTER     RATE                :
  3422                              <1> 	;                      VALUE     SELECTED     VALUE     SELECTED              :
  3423                              <1> 	;                     --------------------------------------------            :
  3424                              <1> 	;			00H        30.0        10H        7.5                 :
  3425                              <1> 	;			01H        26.7        11H        6.7                 :
  3426                              <1> 	;			02H        24.0        12H        6.0                 :
  3427                              <1> 	;			03H        21.8        13H        5.5                 :
  3428                              <1> 	;			04H        20.0        14H        5.0                 :
  3429                              <1> 	;			05H        18.5        15H        4.6                 :
  3430                              <1> 	;			06H        17.1        16H        4.3                 :
  3431                              <1> 	;			07H        16.0        17H        4.0                 :
  3432                              <1> 	;			08H        15.0        18H        3.7                 :
  3433                              <1> 	;			09H        13.3        19H        3.3                 :
  3434                              <1> 	;			0AH        12.0        1AH        3.0                 :
  3435                              <1> 	;			0BH        10.9        1BH        2.7                 :
  3436                              <1>         ;			0CH        10.0        1CH        2.5                 :
  3437                              <1> 	;			0DH         9.2        1DH        2.3                 :
  3438                              <1> 	;			0EH         8.6        1EH        2.1                 :
  3439                              <1> 	;			0FH         8.0        1FH        2.0                 :
  3440                              <1> 	;									      :
  3441                              <1> 	;	      (BH) = TYPAMATIC DELAY  (BITS 2 - 7 MUST BE RESET TO 0)         :
  3442                              <1> 	;		       							      :
  3443                              <1> 	;                     REGISTER     DELAY                                      :
  3444                              <1> 	;                      VALUE       VALUE                                      :
  3445                              <1> 	;                     ------------------                                      :
  3446                              <1> 	;			00H        250 ms                                     :
  3447                              <1> 	;			01H        500 ms                                     :
  3448                              <1> 	;			02H        750 ms                                     :
  3449                              <1> 	;			03H       1000 ms                                     :
  3450                              <1> 	;-----------------------------------------------------------------------------:
  3451                              <1> 	;	(AH)= 05H  PLACE ASCII CHARACTER/SCAN CODE COMBINATION IN KEYBOARD    :
  3452                              <1> 	;		   BUFFER AS IF STRUCK FROM KEYBOARD                          :
  3453                              <1> 	;		   ENTRY:  (CL) = ASCII CHARACTER		              :
  3454                              <1> 	;		           (CH) = SCAN CODE                                   :
  3455                              <1> 	;		   EXIT:   (AH) = 00H = SUCCESSFUL OPERATION                  :
  3456                              <1> 	;		           (AL) = 01H = UNSUCCESSFUL - BUFFER FULL            :
  3457                              <1> 	;		   FLAGS:  CARRY IF ERROR                                     :
  3458                              <1> 	;-----------------------------------------------------------------------------:		
  3459                              <1> 	;	(AH)= 10H  EXTENDED READ INTERFACE FOR THE ENHANCED KEYBOARD,         :
  3460                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=0                            :
  3461                              <1> 	;-----------------------------------------------------------------------------:
  3462                              <1> 	;	(AH)= 11H  EXTENDED ASCII STATUS FOR THE ENHANCED KEYBOARD,           :
  3463                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=1                            :
  3464                              <1> 	;-----------------------------------------------------------------------------:	
  3465                              <1> 	;	(AH)= 12H  RETURN THE EXTENDED SHIFT STATUS IN AX REGISTER            :
  3466                              <1> 	;		   AL = BITS FROM KB_FLAG, AH = BITS FOR LEFT AND RIGHT       :
  3467                              <1> 	;		   CTL AND ALT KEYS FROM KB_FLAG_1 AND KB_FLAG_3              :
  3468                              <1> 	; OUTPUT					                              :
  3469                              <1> 	;	AS NOTED ABOVE, ONLY (AX) AND FLAGS CHANGED	                      :
  3470                              <1> 	;	ALL REGISTERS RETAINED		                                      :
  3471                              <1> 	;------------------------------------------------------------------------------
  3472                              <1> 
  3473                              <1> ; 07/08/2022
  3474                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
  3475                              <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop)
  3476                              <1> ; 15/01/2017
  3477                              <1> ; 14/01/2017
  3478                              <1> ; 02/01/2017
  3479                              <1> ; 29/05/2016
  3480                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3481                              <1> int32h:  ; Keyboard BIOS
  3482                              <1> 
  3483                              <1> KEYBOARD_IO_1:	
  3484                              <1> 	;sti				; INTERRUPTS BACK ON
  3485                              <1> 	; 29/05/2016
  3486 00000EFB 80642408BE          <1>         and     byte [esp+8], 10111110b ; clear zero flag and cary flag
  3487                              <1> 	;
  3488 00000F00 1E                  <1> 	push	ds			; SAVE CURRENT DS
  3489 00000F01 53                  <1> 	push	ebx			; SAVE BX TEMPORARILY
  3490                              <1> 	;push	ecx			; SAVE CX TEMPORARILY
  3491 00000F02 66BB1000            <1>         mov     bx, KDATA
  3492 00000F06 8EDB                <1> 	mov	ds, bx			; PUT SEGMENT VALUE OF DATA AREA INTO DS
  3493                              <1> 	; 14/01/2017
  3494 00000F08 8B1C24              <1> 	mov	ebx, [esp]
  3495                              <1> 	;; 15/01/2017
  3496                              <1> 	; 02/01/2017
  3497                              <1> 	;;mov	byte [intflg], 32h	; keyboard interrupt 
  3498 00000F0B FB                  <1> 	sti
  3499                              <1> 	;
  3500 00000F0C 08E4                <1> 	or	ah, ah			; CHECK FOR (AH)= 00H
  3501 00000F0E 7433                <1> 	jz	short _K1		; ASCII_READ
  3502 00000F10 FECC                <1> 	dec	ah                      ; CHECK FOR (AH)= 01H
  3503 00000F12 744C                <1>         jz      short _K2               ; ASCII_STATUS
  3504 00000F14 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 02H
  3505 00000F16 74DC                <1>         jz	short _K3		; SHIFT STATUS
  3506 00000F18 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 03H	
  3507 00000F1A 746F                <1>         jz      short _K300		; SET TYPAMATIC RATE/DELAY
  3508 00000F1C 80EC02              <1> 	sub	ah, 2			; CHECK FOR (AH)= 05H	
  3509                              <1>         ;jz	short _K500		; KEYBOARD WRITE
  3510                              <1> 	; 07/08/2022
  3511 00000F1F 7505                <1> 	jnz	short _KIO1
  3512 00000F21 E988000000          <1> 	jmp	_K500         
  3513                              <1> _KIO1:	
  3514 00000F26 80EC0B              <1> 	sub	ah, 11			; AH =  10H
  3515 00000F29 740C                <1> 	jz	short _K1E		; EXTENDED ASCII READ
  3516 00000F2B FECC                <1> 	dec	ah			; CHECK FOR (AH)= 11H
  3517 00000F2D 7422                <1> 	jz	short _K2E		; EXTENDED_ASCII_STATUS
  3518 00000F2F FECC                <1> 	dec	ah			; CHECK FOR (AH)= 12H
  3519 00000F31 74A3                <1> 	jz	short _K3E		; EXTENDED_SHIFT_STATUS
  3520                              <1> _KIO_EXIT:
  3521                              <1> 	; 02/01/2017
  3522 00000F33 FA                  <1> 	cli
  3523                              <1> 	;;mov	byte [intflg], 0 ;; 15/01/2017
  3524                              <1> 	;
  3525                              <1> 	;pop	ecx			; RECOVER REGISTER
  3526 00000F34 5B                  <1> 	pop	ebx			; RECOVER REGISTER
  3527 00000F35 1F                  <1> 	pop	ds			; RECOVER SEGMENT
  3528 00000F36 CF                  <1> 	iretd				; INVALID COMMAND, EXIT
  3529                              <1> 
  3530                              <1> ; 24/07/2022
  3531                              <1> ;
  3532                              <1> ;	;-----	SHIFT STATUS
  3533                              <1> ;_K3E:					; GET THE EXTENDED SHIFT STATUS FLAGS
  3534                              <1> ;	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
  3535                              <1> ;	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
  3536                              <1> ;	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
  3537                              <1> ;	;shl	ah, cl			; BIT 7 POSITION
  3538                              <1> ;       shl	ah, 5
  3539                              <1> ;	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
  3540                              <1> ;	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
  3541                              <1> ;	or	ah, al                  ; MERGE REMAINING BITS INTO AH
  3542                              <1> ;	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
  3543                              <1> ;	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
  3544                              <1> ;	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
  3545                              <1> ;_K3:
  3546                              <1> ;	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
  3547                              <1> ;	; 24/07/2022
  3548                              <1> ;	jmp	short _KIO_EXIT		; RETURN TO CALLER
  3549                              <1> 
  3550                              <1> 	;-----	ASCII CHARACTER
  3551                              <1> _K1E:	
  3552 00000F37 E89F000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER (EXTENDED)
  3553 00000F3C E812010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
  3554 00000F41 EBF0                <1> 	jmp	short _KIO_EXIT         ; GIVE IT TO THE CALLER
  3555                              <1> _K1:	
  3556 00000F43 E893000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER
  3557 00000F48 E811010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
  3558 00000F4D 72F4                <1> 	jc	short _K1		; CARRY SET MEANS TROW CODE AWAY
  3559                              <1> _K1A:
  3560 00000F4F EBE2                <1> 	jmp	short _KIO_EXIT         ; RETURN TO CALLER
  3561                              <1> 
  3562                              <1> 	;-----	ASCII STATUS
  3563                              <1> _K2E:	
  3564 00000F51 E8D0000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER (EXTENDED)
  3565 00000F56 7420                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
  3566 00000F58 9C                  <1> 	pushf				; SAVE ZF FROM TEST
  3567 00000F59 E8F5000000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
  3568 00000F5E EB17                <1> 	jmp	short _K2A	        ; GIVE IT TO THE CALLER
  3569                              <1> _K2:	
  3570 00000F60 E8C1000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER
  3571 00000F65 7411                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
  3572 00000F67 9C                  <1> 	pushf				; SAVE ZF FROM TEST
  3573 00000F68 E8F1000000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
  3574 00000F6D 7308                <1> 	jnc	short _K2A	        ; CARRY CLEAR MEANS PASS VALID CODE
  3575 00000F6F 9D                  <1> 	popf				; INVALID CODE FOR THIS TYPE OF CALL
  3576 00000F70 E866000000          <1> 	call	_K1S			; THROW THE CHARACTER AWAY
  3577 00000F75 EBE9                <1> 	jmp	short _K2		; GO LOOK FOR NEXT CHAR, IF ANY
  3578                              <1> _K2A:
  3579 00000F77 9D                  <1> 	popf				; RESTORE ZF FROM TEST
  3580                              <1> _K2B:
  3581                              <1> 	; 02/01/2017
  3582 00000F78 FA                  <1> 	cli
  3583                              <1> 	;; mov	byte [intflg], 0 ;; 15/01/2017
  3584                              <1> 	;
  3585                              <1> 	;pop	ecx			; RECOVER REGISTER
  3586 00000F79 5B                  <1> 	pop	ebx			; RECOVER REGISTER
  3587 00000F7A 1F                  <1> 	pop	ds			; RECOVER SEGMENT
  3588                              <1> 	; (*) 29/05/2016
  3589                              <1> 	; (*) retf 4			; THROW AWAY (e)FLAGS
  3590 00000F7B 7208                <1> 	jc	short _k2d
  3591 00000F7D 7505                <1> 	jnz	short _k2c
  3592 00000F7F 804C240840          <1> 	or	byte [esp+8], 01000000b	; set zero flag bit of eflags register
  3593                              <1> _k2c:
  3594 00000F84 CF                  <1> 	iretd
  3595                              <1> _k2d:
  3596                              <1> 	; 29/05/2016 -set carry flag on stack-
  3597                              <1> 	; [esp] = EIP
  3598                              <1> 	; [esp+4] = CS
  3599                              <1> 	; [esp+8] = E-FLAGS
  3600 00000F85 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  3601                              <1> 	; [esp+12] = ESP (user)
  3602                              <1> 	; [esp+16] = SS (User)
  3603 00000F8A CF                  <1> 	iretd
  3604                              <1> 	
  3605                              <1> 	; (*) 29/05/2016 - 'retf 4' intruction causes to stack fault
  3606                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  3607                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  3608                              <1> 	; // RETF instruction:
  3609                              <1> 	;
  3610                              <1> 	; IF OperandMode=32 THEN
  3611                              <1>  	;    Load CS:EIP from stack;
  3612                              <1>  	;    Set CS RPL to CPL;
  3613                              <1>  	;    Increment ESP by 8 plus the immediate offset if it exists;
  3614                              <1>  	;    Load SS:ESP from stack;
  3615                              <1>  	; ELSE (* OperandMode=16 *)
  3616                              <1>  	;    Load CS:IP from stack;
  3617                              <1>  	;    Set CS RPL to CPL;
  3618                              <1>  	;    Increment SP by 4 plus the immediate offset if it exists;
  3619                              <1> 	;    Load SS:SP from stack;
  3620                              <1>  	; FI;
  3621                              <1> 	;
  3622                              <1> 	; //
  3623                              <1> 
  3624                              <1> 	; 24/07/2022
  3625                              <1> 	;-----	SET TYPAMATIC RATE AND DELAY
  3626                              <1> _K300:
  3627 00000F8B 3C05                <1> 	cmp	al, 5			; CORRECT FUNCTION CALL?
  3628 00000F8D 75A4                <1> 	jne	short _KIO_EXIT		; NO, RETURN
  3629 00000F8F F6C3E0              <1> 	test	bl, 0E0h		; TEST FOR OUT-OF-RANGE RATE
  3630 00000F92 759F                <1> 	jnz	short _KIO_EXIT		; RETURN IF SO
  3631 00000F94 F6C7FC              <1> 	test	bh, 0FCh		; TEST FOR OUT-OF-RANGE DELAY
  3632 00000F97 759A                <1> 	jnz	short _KIO_EXIT		; RETURN IF SO
  3633 00000F99 B0F3                <1> 	mov	al, KB_TYPA_RD		; COMMAND FOR TYPAMATIC RATE/DELAY		
  3634 00000F9B E875060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
  3635                              <1> 	;mov	cx, 5			; SHIFT COUNT
  3636                              <1> 	;shl	bh, cl			; SHIFT DELAY OVER
  3637 00000FA0 C0E705              <1> 	shl	bh, 5
  3638 00000FA3 88D8                <1> 	mov	al, bl			; PUT IN RATE
  3639 00000FA5 08F8                <1> 	or	al, bh			; AND DELAY
  3640 00000FA7 E869060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
  3641 00000FAC EB85                <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER
  3642                              <1> 
  3643                              <1> 	;-----	WRITE TO KEYBOARD BUFFER
  3644                              <1> _K500:
  3645 00000FAE 56                  <1> 	push	esi			; SAVE SI (esi)
  3646 00000FAF FA                  <1> 	cli				; 
  3647 00000FB0 8B1D[7A660000]      <1>      	mov	ebx, [BUFFER_TAIL]	; GET THE 'IN TO' POINTER TO THE BUFFER
  3648 00000FB6 89DE                <1> 	mov	esi, ebx		; SAVE A COPY IN CASE BUFFER NOT FULL
  3649 00000FB8 E8D1000000          <1> 	call	_K4			; BUMP THE POINTER TO SEE IF BUFFER IS FULL
  3650 00000FBD 3B1D[76660000]      <1> 	cmp	ebx, [BUFFER_HEAD]	; WILL THE BUFFER OVERRUN IF WE STORE THIS?
  3651 00000FC3 740D                <1> 	je	short _K502		; YES - INFORM CALLER OF ERROR		
  3652 00000FC5 66890E              <1> 	mov	[esi], cx		; NO - PUT ASCII/SCAN CODE INTO BUFFER	
  3653 00000FC8 891D[7A660000]      <1> 	mov	[BUFFER_TAIL], ebx	; ADJUST 'IN TO' POINTER TO REFLECT CHANGE
  3654 00000FCE 28C0                <1> 	sub	al, al			; TELL CALLER THAT OPERATION WAS SUCCESSFUL
  3655 00000FD0 EB02                <1> 	jmp	short _K504		; SUB INSTRUCTION ALSO RESETS CARRY FLAG
  3656                              <1> _K502:
  3657 00000FD2 B001                <1> 	mov	al, 01h			; BUFFER FULL INDICATION
  3658                              <1> _K504:
  3659 00000FD4 FB                  <1> 	sti				
  3660 00000FD5 5E                  <1> 	pop	esi			; RECOVER SI (esi)
  3661 00000FD6 E958FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER WITH STATUS IN AL
  3662                              <1> 
  3663                              <1> 	;-----	READ THE KEY TO FIGURE OUT WHAT TO DO -----
  3664                              <1> _K1S:
  3665 00000FDB FA                  <1> 	cli	; 03/12/2014
  3666 00000FDC 8B1D[76660000]      <1>         mov     ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
  3667 00000FE2 3B1D[7A660000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
  3668                              <1> 	;jne	short _K1U		; IF ANYTHING IN BUFFER SKIP INTERRUPT
  3669 00000FE8 750F                <1> 	jne	short _k1x ; 03/12/2014
  3670                              <1> 	;
  3671                              <1> 	; 03/12/2014
  3672                              <1> 	; 28/08/2014
  3673                              <1> 	; PERFORM OTHER FUNCTION ?? here !
  3674                              <1> 	;; MOV	AX, 9002h		; MOVE IN WAIT CODE & TYPE
  3675                              <1> 	;; INT 	15H			; PERFORM OTHER FUNCTION
  3676                              <1> _K1T:                                   ; ASCII READ
  3677 00000FEA FB                  <1> 	sti				; INTERRUPTS BACK ON DURING LOOP
  3678 00000FEB 90                  <1> 	nop				; ALLOW AN INTERRUPT TO OCCUR
  3679                              <1> _K1U:	
  3680 00000FEC FA                  <1> 	cli				; INTERRUPTS BACK OFF
  3681 00000FED 8B1D[76660000]      <1>         mov    	ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
  3682 00000FF3 3B1D[7A660000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
  3683                              <1> _k1x:
  3684 00000FF9 53                  <1> 	push	ebx			; SAVE ADDRESS		
  3685 00000FFA 9C                  <1> 	pushf				; SAVE FLAGS
  3686 00000FFB E8C9060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3687 00001000 8A1D[6B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3688 00001006 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3689 00001008 80E307              <1> 	and	bl, 07h	; KB_LEDS	; ISOLATE INDICATOR BITS
  3690 0000100B 7406                <1> 	jz	short _K1V		; IF NO CHANGE BYPASS UPDATE
  3691 0000100D E863060000          <1> 	call	SND_LED1
  3692 00001012 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3693                              <1> _K1V:
  3694 00001013 9D                  <1> 	popf				; RESTORE FLAGS
  3695 00001014 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
  3696 00001015 74D3                <1>         je      short _K1T              ; LOOP UNTIL SOMETHING IN BUFFER
  3697                              <1> 	;
  3698 00001017 668B03              <1> 	mov	ax, [ebx] 		; GET SCAN CODE AND ASCII CODE
  3699 0000101A E86F000000          <1>         call    _K4                     ; MOVE POINTER TO NEXT POSITION
  3700 0000101F 891D[76660000]      <1>         mov     [BUFFER_HEAD], ebx      ; STORE VALUE IN VARIABLE
  3701 00001025 C3                  <1> 	retn				; RETURN
  3702                              <1> 
  3703                              <1> 	;-----	READ THE KEY TO SEE IF ONE IS PRESENT -----
  3704                              <1> _K2S:
  3705 00001026 FA                  <1> 	cli				; INTERRUPTS OFF
  3706 00001027 8B1D[76660000]      <1>         mov     ebx, [BUFFER_HEAD]      ; GET HEAD POINTER
  3707 0000102D 3B1D[7A660000]      <1>         cmp     ebx, [BUFFER_TAIL]      ; IF EQUAL (Z=1) THEN NOTHING THERE
  3708 00001033 668B03              <1> 	mov	ax, [ebx]
  3709 00001036 9C                  <1> 	pushf				; SAVE FLAGS
  3710                              <1> 	;push	ax			; SAVE CODE
  3711                              <1> 	; 12/04/2021
  3712 00001037 50                  <1> 	push	eax
  3713 00001038 E88C060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3714 0000103D 8A1D[6B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3715 00001043 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3716 00001045 80E307              <1> 	and	bl, 07h ; KB_LEDS	; ISOLATE INDICATOR BITS
  3717 00001048 7405                <1> 	jz	short _K2T		; IF NO CHANGE BYPASS UPDATE
  3718 0000104A E80F060000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
  3719                              <1> _K2T:
  3720                              <1> 	;pop	ax			; RESTORE CODE
  3721                              <1> 	; 12/04/2021
  3722 0000104F 58                  <1> 	pop	eax
  3723 00001050 9D                  <1> 	popf				; RESTORE FLAGS
  3724 00001051 FB                  <1> 	sti				; INTERRUPTS BACK ON
  3725 00001052 C3                  <1> 	retn				; RETURN
  3726                              <1> 
  3727                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS -----
  3728                              <1> _KIO_E_XLAT:
  3729 00001053 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
  3730 00001055 7506                <1> 	jne	short _KIO_E_RET	; NO, PASS IT ON
  3731 00001057 08E4                <1>         or 	ah, ah			; AH = 0 IS SPECIAL CASE
  3732 00001059 7402                <1>         jz	short _KIO_E_RET        ; PASS THIS ON UNCHANGED
  3733 0000105B 30C0                <1> 	xor	al, al			; OTHERWISE SET AL = 0
  3734                              <1> _KIO_E_RET:				
  3735 0000105D C3                  <1> 	retn				; GO BACK
  3736                              <1> 
  3737                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS -----
  3738                              <1> _KIO_S_XLAT:
  3739 0000105E 80FCE0              <1> 	cmp	ah, 0E0h		; IS IT KEYPAD ENTER OR / ?
  3740 00001061 750F                <1> 	jne	short _KIO_S2		; NO, CONTINUE
  3741 00001063 3C0D                <1> 	cmp	al, 0Dh			; KEYPAD ENTER CODE?
  3742 00001065 7408                <1>         je	short _KIO_S1		; YES, MASSAGE A BIT
  3743 00001067 3C0A                <1> 	cmp	al, 0Ah			; CTRL KEYPAD ENTER CODE?
  3744 00001069 7404                <1>         je	short _KIO_S1		; YES, MASSAGE THE SAME
  3745 0000106B B435                <1> 	mov	ah, 35h			; NO, MUST BE KEYPAD /
  3746                              <1> _kio_ret: ; 03/12/2014
  3747 0000106D F8                  <1> 	clc
  3748 0000106E C3                  <1> 	retn
  3749                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
  3750                              <1> _KIO_S1:				
  3751 0000106F B41C                <1> 	mov	ah, 1Ch			; CONVERT TO COMPATIBLE OUTPUT
  3752                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
  3753 00001071 C3                  <1> 	retn
  3754                              <1> _KIO_S2:		
  3755 00001072 80FC84              <1> 	cmp	ah, 84h			; IS IT ONE OF EXTENDED ONES?
  3756 00001075 7715                <1> 	ja	short _KIO_DIS		; YES, THROW AWAY AND GET ANOTHER CHAR
  3757 00001077 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
  3758 00001079 7506                <1>         jne	short _KIO_S3		; NO, TRY LAST TEST
  3759 0000107B 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
  3760 0000107D 740C                <1>         jz	short _KIO_USE		; PASS THIS ON UNCHANGED
  3761 0000107F EB0B                <1> 	jmp	short _KIO_DIS		; THROW AWAY THE REST
  3762                              <1> _KIO_S3:
  3763 00001081 3CE0                <1> 	cmp	al, 0E0h		; IS IT AN EXTENSION OF A PREVIOUS ONE?
  3764                              <1> 	;jne	short _KIO_USE		; NO, MUST BE A STANDARD CODE
  3765 00001083 75E8                <1> 	jne	short _kio_ret
  3766 00001085 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
  3767 00001087 7402                <1>         jz	short _KIO_USE		; JUMP IF AH = 0
  3768 00001089 30C0                <1> 	xor	al, al			; CONVERT TO COMPATIBLE OUTPUT
  3769                              <1> 	;jmp	short _KIO_USE		; PASS IT ON TO CALLER
  3770                              <1> _KIO_USE:
  3771                              <1> 	;clc				; CLEAR CARRY TO INDICATE GOOD CODE
  3772 0000108B C3                  <1> 	retn				; RETURN	
  3773                              <1> _KIO_DIS:
  3774 0000108C F9                  <1> 	stc				; SET CARRY TO INDICATE DISCARD CODE
  3775 0000108D C3                  <1> 	retn				; RETURN
  3776                              <1> 
  3777                              <1> 	;-----	INCREMENT BUFFER POINTER ROUTINE -----
  3778                              <1> _K4:    
  3779 0000108E 43                  <1> 	inc     ebx
  3780 0000108F 43                  <1> 	inc	ebx			; MOVE TO NEXT WORD IN LIST
  3781 00001090 3B1D[72660000]      <1>         cmp     ebx, [BUFFER_END] 	; AT END OF BUFFER?
  3782                              <1>         ;jne    short _K5               ; NO, CONTINUE
  3783 00001096 7206                <1> 	jb	short _K5
  3784 00001098 8B1D[6E660000]      <1>         mov     ebx, [BUFFER_START]     ; YES, RESET TO BUFFER BEGINNING
  3785                              <1> _K5:
  3786 0000109E C3                  <1> 	retn
  3787                              <1> 
  3788                              <1> ; 20/02/2015
  3789                              <1> ; 05/12/2014
  3790                              <1> ; 26/08/2014
  3791                              <1> ; KEYBOARD (HARDWARE) INTERRUPT -  IRQ LEVEL 1
  3792                              <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014)
  3793                              <1> ;
  3794                              <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 
  3795                              <1> ; rombios source code (06/10/1985)
  3796                              <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1)
  3797                              <1> 
  3798                              <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC')
  3799                              <1> 
  3800                              <1> ;--------- 8042 COMMANDS -------------------------------------------------------
  3801                              <1> ENA_KBD		equ	0AEh		; ENABLE KEYBOARD COMMAND
  3802                              <1> DIS_KBD		equ	0ADh		; DISABLE KEYBOARD COMMAND
  3803                              <1> SHUT_CMD	equ	0FEh		; CAUSE A SHUTDOWN COMMAND
  3804                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
  3805                              <1> STATUS_PORT	equ	064h		; 8042 STATUS PORT
  3806                              <1> INPT_BUF_FULL	equ	00000010b 	; 1 = +INPUT BUFFER FULL
  3807                              <1> PORT_A		equ	060h		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
  3808                              <1> ;---------- 8042 KEYBOARD RESPONSE ---------------------------------------------
  3809                              <1> KB_ACK		equ	0FAh		; ACKNOWLEDGE PROM TRANSMISSION
  3810                              <1> KB_RESEND	equ	0FEh		; RESEND REQUEST
  3811                              <1> KB_OVER_RUN	equ	0FFh		; OVER RUN SCAN CODE
  3812                              <1> ;---------- KEYBOARD/LED COMMANDS ----------------------------------------------
  3813                              <1> KB_ENABLE	equ	0F4h		; KEYBOARD ENABLE
  3814                              <1> LED_CMD		equ	0EDh		; LED WRITE COMMAND
  3815                              <1> KB_TYPA_RD	equ	0F3h		; TYPAMATIC RATE/DELAY COMMAND
  3816                              <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------
  3817                              <1> NUM_KEY		equ	69		; SCAN CODE FOR	 NUMBER LOCK KEY
  3818                              <1> SCROLL_KEY	equ	70		; SCAN CODE FOR	 SCROLL LOCK KEY
  3819                              <1> ALT_KEY		equ	56		; SCAN CODE FOR	 ALTERNATE SHIFT KEY
  3820                              <1> CTL_KEY		equ	29		; SCAN CODE FOR	 CONTROL KEY
  3821                              <1> CAPS_KEY	equ	58		; SCAN CODE FOR	 SHIFT LOCK KEY
  3822                              <1> DEL_KEY		equ	83		; SCAN CODE FOR	 DELETE KEY
  3823                              <1> INS_KEY		equ	82		; SCAN CODE FOR	 INSERT KEY
  3824                              <1> LEFT_KEY	equ	42		; SCAN CODE FOR	 LEFT SHIFT
  3825                              <1> RIGHT_KEY	equ	54		; SCAN CODE FOR	 RIGHT SHIFT
  3826                              <1> SYS_KEY		equ	84		; SCAN CODE FOR	 SYSTEM KEY
  3827                              <1> ;---------- ENHANCED KEYBOARD SCAN CODES ---------------------------------------
  3828                              <1> ID_1		equ	0ABh		; 1ST ID CHARACTER FOR KBX
  3829                              <1> ID_2		equ	041h		; 2ND ID CHARACTER FOR KBX
  3830                              <1> ID_2A		equ	054h		; ALTERNATE 2ND ID CHARACTER FOR KBX
  3831                              <1> F11_M		equ	87		; F11 KEY MAKE
  3832                              <1> F12_M		equ	88		; F12 KEY MAKE
  3833                              <1> MC_E0		equ	224		; GENERAL MARKER CODE
  3834                              <1> MC_E1		equ	225		; PAUSE KEY MARKER CODE
  3835                              <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG----------------------------------------
  3836                              <1> RIGHT_SHIFT	equ	00000001b	; RIGHT SHIFT KEY DEPRESSED
  3837                              <1> LEFT_SHIFT	equ	00000010b	; LEFT SHIFT KEY DEPRESSED
  3838                              <1> CTL_SHIFT	equ	00000100b	; CONTROL SHIFT KEY DEPRESSED
  3839                              <1> ALT_SHIFT	equ	00001000b	; ALTERNATE SHIFT KEY DEPRESSED
  3840                              <1> SCROLL_STATE	equ	00010000b	; SCROLL LOCK STATE IS ACTIVE
  3841                              <1> NUM_STATE	equ	00100000b	; NUM LOCK STATE IS ACTIVE
  3842                              <1> CAPS_STATE	equ	01000000b	; CAPS LOCK STATE IS ACTIVE
  3843                              <1> INS_STATE	equ	10000000b	; INSERT STATE IS ACTIVE
  3844                              <1> ;---------- FLAG EQUATES WITHIN	@KB_FLAG_1 -------------------------------------
  3845                              <1> L_CTL_SHIFT	equ	00000001b	; LEFT CTL KEY DOWN
  3846                              <1> L_ALT_SHIFT	equ	00000010b	; LEFT ALT KEY DOWN
  3847                              <1> SYS_SHIFT	equ	00000100b	; SYSTEM KEY DEPRESSED AND HELD
  3848                              <1> HOLD_STATE	equ	00001000b	; SUSPEND KEY HAS BEEN TOGGLED
  3849                              <1> SCROLL_SHIFT	equ	00010000b	; SCROLL LOCK KEY IS DEPRESSED
  3850                              <1> NUM_SHIFT	equ	00100000b	; NUM LOCK KEY IS DEPRESSED
  3851                              <1> CAPS_SHIFT	equ	01000000b	; CAPS LOCK KEY IS DEPRE55ED
  3852                              <1> INS_SHIFT	equ	10000000b	; INSERT KEY IS DEPRESSED
  3853                              <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 -----------------------------------
  3854                              <1> KB_LEDS		equ	00000111b	; KEYBOARD LED STATE BITS
  3855                              <1> ;		equ	00000001b	; SCROLL LOCK INDICATOR
  3856                              <1> ;		equ	00000010b	; NUM LOCK INDICATOR
  3857                              <1> ;		equ	00000100b	; CAPS LOCK INDICATOR
  3858                              <1> ;		equ	00001000b	; RESERVED (MUST BE ZERO)
  3859                              <1> KB_FA		equ	00010000b	; ACKNOWLEDGMENT RECEIVED
  3860                              <1> KB_FE		equ	00100000b	; RESEND RECEIVED FLAG
  3861                              <1> KB_PR_LED	equ	01000000b	; MODE INDICATOR UPDATE
  3862                              <1> KB_ERR		equ	10000000b	; KEYBOARD TRANSMIT ERROR FLAG
  3863                              <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 -----------------------------------
  3864                              <1> LC_E1		equ	00000001b	; LAST CODE WAS THE E1 HIDDEN CODE
  3865                              <1> LC_E0		equ	00000010b	; LAST CODE WAS THE E0 HIDDEN CODE
  3866                              <1> R_CTL_SHIFT	equ	00000100b	; RIGHT CTL KEY DOWN
  3867                              <1> R_ALT_SHIFT	equ	00001000b	; RIGHT ALT KEY DOWN
  3868                              <1> GRAPH_ON	equ	00001000b	; ALT GRAPHICS KEY DOWN (WT ONLY)	
  3869                              <1> KBX		equ	00010000b	; ENHANCED KEYBOARD INSTALLED
  3870                              <1> SET_NUM_LK	equ	00100000b	; FORCE NUM LOCK IF READ ID AND KBX
  3871                              <1> LC_AB		equ	01000000b	; LAST CHARACTER WAS FIRST ID CHARACTER
  3872                              <1> RD_ID		equ	10000000b	; DOING A READ ID (MUST BE BIT0)
  3873                              <1> ;
  3874                              <1> ;----------- INTERRUPT EQUATES -------------------------------------------------
  3875                              <1> EOI		equ	020h		; END OF INTERRUPT COMMAND TO 8259
  3876                              <1> INTA00		equ	020h		; 8259 PORT
  3877                              <1> 
  3878                              <1> 
  3879                              <1> kb_int:
  3880                              <1> 
  3881                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
  3882                              <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop)
  3883                              <1> ; 17/10/2015 ('ctrlbrk') 
  3884                              <1> ; 05/12/2014
  3885                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-)
  3886                              <1> ; 26/08/2014
  3887                              <1> ;
  3888                              <1> ; 03/06/86  KEYBOARD BIOS
  3889                              <1> ;
  3890                              <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------
  3891                              <1> ;										;
  3892                              <1> ;	KEYBOARD INTERRUPT ROUTINE						;
  3893                              <1> ;										;
  3894                              <1> ;--------------------------------------------------------------------------------
  3895                              <1> 
  3896                              <1> KB_INT_1:
  3897 0000109F FB                  <1> 	sti				; ENABLE INTERRUPTS
  3898                              <1> 	;push	ebp
  3899 000010A0 50                  <1> 	push	eax
  3900 000010A1 53                  <1> 	push	ebx
  3901 000010A2 51                  <1> 	push	ecx
  3902 000010A3 52                  <1> 	push	edx
  3903 000010A4 56                  <1> 	push	esi
  3904 000010A5 57                  <1> 	push	edi
  3905 000010A6 1E                  <1> 	push	ds
  3906 000010A7 06                  <1> 	push	es
  3907 000010A8 FC                  <1> 	cld				; FORWARD DIRECTION
  3908 000010A9 66B81000            <1> 	mov	ax, KDATA
  3909 000010AD 8ED8                <1> 	mov	ds, ax
  3910 000010AF 8EC0                <1> 	mov	es, ax
  3911                              <1> 	;
  3912                              <1> 	;-----	WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED
  3913 000010B1 B0AD                <1> 	mov	al, DIS_KBD		; DISABLE THE KEYBOARD COMMAND
  3914 000010B3 E84B050000          <1> 	call	SHIP_IT			; EXECUTE DISABLE
  3915 000010B8 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3916 000010B9 B900000100          <1> 	mov	ecx, 10000h		; SET MAXIMUM TIMEOUT
  3917                              <1> KB_INT_01:
  3918 000010BE E464                <1> 	in	al, STATUS_PORT		; READ ADAPTER STATUS
  3919 000010C0 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK INPUT BUFFER FULL STATUS BIT
  3920 000010C2 E0FA                <1> 	loopnz	KB_INT_01		; WAIT FOR COMMAND TO BE ACCEPTED
  3921                              <1> 	;
  3922                              <1> 	;-----	READ CHARACTER FROM KEYBOARD INTERFACE
  3923 000010C4 E460                <1> 	in	al, PORT_A		; READ IN THE CHARACTER
  3924                              <1> 	;
  3925                              <1> 	;-----	SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 	
  3926                              <1> 	;mov	ah, 04Fh		; SYSTEM INTERCEPT - KEY CODE FUNCTION
  3927                              <1> 	;stc				; SET CY=1 (IN CASE OF IRET)
  3928                              <1> 	;int	15h			; CASETTE CALL (AL)=KEY SCAN CODE
  3929                              <1> 	;				; RETURNS CY=1 FOR INVALID FUNCTION
  3930                              <1> 	;jc	KB_INT_02		; CONTINUE IF CARRY FLAG SET ((AL)=CODE)
  3931                              <1> 	;jmp	K26			; EXIT IF SYSTEM HANDLES SCAN CODE
  3932                              <1> 	;				; EXT HANDLES HARDWARE EOI AND ENABLE		
  3933                              <1> 	;
  3934                              <1> 	;-----	CHECK FOR A RESEND COMMAND TO KEYBOARD
  3935                              <1> KB_INT_02:				; 	  (AL)= SCAN CODE
  3936 000010C6 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  3937 000010C7 3CFE                <1> 	cmp	al, KB_RESEND		; IS THE INPUT A RESEND
  3938 000010C9 740E                <1>         je      short KB_INT_4          ; GO IF RESEND
  3939                              <1> 	;
  3940                              <1> 	;-----	CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD
  3941 000010CB 3CFA                <1> 	cmp	al, KB_ACK		; IS THE INPUT AN ACKNOWLEDGE
  3942 000010CD 7514                <1>         jne     short KB_INT_2          ; GO IF NOT
  3943                              <1> 	;
  3944                              <1> 	;-----	A COMMAND TO THE KEYBOARD WAS ISSUED
  3945 000010CF FA                  <1> 	cli				; DISABLE INTERRUPTS
  3946 000010D0 800D[6B660000]10    <1> 	or	byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED
  3947                              <1>         ;jmp	K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
  3948                              <1> 	; 12/04/2021
  3949 000010D7 EB76                <1> 	jmp	short ID_EX  ; K26
  3950                              <1> 	;
  3951                              <1> 	;-----	RESEND THE LAST BYTE
  3952                              <1> KB_INT_4:
  3953 000010D9 FA                  <1> 	cli				; DISABLE INTERRUPTS
  3954 000010DA 800D[6B660000]20    <1> 	or	byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED
  3955                              <1>         ;jmp	K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
  3956                              <1> 	; 12/04/2021
  3957 000010E1 EB6C                <1> 	jmp	short ID_EX  ; K26
  3958                              <1> 	;
  3959                              <1> ;-----	UPDATE MODE INDICATORS IF CHANGE IN STATE
  3960                              <1> KB_INT_2:
  3961                              <1> 	;push 	ax			; SAVE DATA IN
  3962                              <1> 	; 12/04/2021
  3963 000010E3 50                  <1> 	push	eax
  3964 000010E4 E8E0050000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
  3965 000010E9 8A1D[6B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
  3966 000010EF 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
  3967 000010F1 80E307              <1> 	and	bl, KB_LEDS		; ISOLATE INDICATOR BITS
  3968 000010F4 7405                <1> 	jz	short UP0		; IF NO CHANGE BYPASS UPDATE
  3969 000010F6 E863050000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
  3970                              <1> UP0:
  3971                              <1> 	;pop	ax			; RESTORE DATA IN
  3972                              <1> 	; 12/04/2021
  3973 000010FB 58                  <1> 	pop	eax
  3974                              <1> ;------------------------------------------------------------------------
  3975                              <1> ;	START OF KEY PROCESSING						;
  3976                              <1> ;------------------------------------------------------------------------
  3977 000010FC 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE IN AH ALSO
  3978                              <1> 	;
  3979                              <1> 	;-----	TEST FOR OVERRUN SCAN CODE FROM KEYBOARD
  3980 000010FE 3CFF                <1> 	cmp	al, KB_OVER_RUN		; IS THIS AN OVERRUN CHAR
  3981                              <1>         ;je	K62			; BUFFER_FULL_BEEP
  3982                              <1> 	; 12/04/2021
  3983 00001100 7505                <1> 	jne	short K16
  3984 00001102 E9E8040000          <1> 	jmp	K62
  3985                              <1> K16:	
  3986 00001107 8A3D[6C660000]      <1> 	mov	bh, [KB_FLAG_3]		; LOAD FLAGS FOR TESTING
  3987                              <1> 	;
  3988                              <1> 	;-----	TEST TO SEE IF A READ_ID IS IN PROGRESS
  3989 0000110D F6C7C0              <1> 	test 	bh, RD_ID+LC_AB 	; ARE WE DOING A READ ID?
  3990 00001110 7442                <1> 	jz	short NOT_ID		; CONTINUE IF NOT
  3991 00001112 7914                <1> 	jns	short TST_ID_2		; IS THE RD_ID FLAG ON?
  3992 00001114 3CAB                <1> 	cmp	al, ID_1		; IS THIS THE 1ST ID CHARACTER?
  3993 00001116 7507                <1> 	jne	short RST_RD_ID
  3994 00001118 800D[6C660000]40    <1> 	or	byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK
  3995                              <1> RST_RD_ID:
  3996 0000111F 8025[6C660000]7F    <1> 	and	byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG
  3997 00001126 EB27                <1>         jmp	short ID_EX		; AND EXIT
  3998                              <1> 	; 12/04/2021
  3999                              <1> 	;jmp	K26
  4000                              <1> 	;
  4001                              <1> TST_ID_2:
  4002 00001128 8025[6C660000]BF    <1> 	and	byte [KB_FLAG_3], ~LC_AB ; RESET FLAG
  4003 0000112F 3C54                <1> 	cmp	al, ID_2A		; IS THIS THE 2ND ID CHARACTER?
  4004 00001131 7415                <1>         je	short KX_BIT		; JUMP IF SO
  4005 00001133 3C41                <1> 	cmp	al, ID_2		; IS THIS THE 2ND ID CHARACTER?
  4006 00001135 7518                <1>         jne	short ID_EX		; LEAVE IF NOT
  4007                              <1> 	; 12/04/2021
  4008                              <1> 	;jne	K26
  4009                              <1> 	;
  4010                              <1> 	;-----	A READ ID SAID THAT IT WAS ENHANCED KEYBOARD
  4011 00001137 F6C720              <1> 	test	bh, SET_NUM_LK 		; SHOULD WE SET NUM LOCK?
  4012 0000113A 740C                <1>         jz      short KX_BIT		; EXIT IF NOT
  4013 0000113C 800D[69660000]20    <1> 	or	byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON
  4014 00001143 E816050000          <1> 	call	SND_LED			; GO SET THE NUM LOCK INDICATOR
  4015                              <1> KX_BIT:
  4016 00001148 800D[6C660000]10    <1> 	or	byte [KB_FLAG_3], KBX	; INDICATE ENHANCED KEYBOARD WAS FOUND
  4017 0000114F E9CB010000          <1> ID_EX:	jmp     K26			; EXIT
  4018                              <1> 	;
  4019                              <1> NOT_ID:
  4020 00001154 3CE0                <1> 	cmp	al, MC_E0		; IS THIS THE GENERAL MARKER CODE?
  4021 00001156 7509                <1> 	jne	short TEST_E1
  4022 00001158 800D[6C660000]12    <1> 	or	byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND
  4023 0000115F EB0B                <1> 	jmp	short EXIT		; THROW AWAY THIS CODE
  4024                              <1> 	; 12/04/2021
  4025                              <1> 	;jmp	K26A	
  4026                              <1> TEST_E1:	
  4027 00001161 3CE1                <1> 	cmp	al, MC_E1		; IS THIS THE PAUSE KEY?
  4028 00001163 750C                <1> 	jne	short NOT_HC
  4029 00001165 800D[6C660000]11    <1> 	or	byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND
  4030 0000116C E9B5010000          <1> EXIT:	jmp	K26A			; THROW AWAY THIS CODE
  4031                              <1> 	;
  4032                              <1> NOT_HC:
  4033 00001171 247F                <1> 	and	al, 07Fh		; TURN OFF THE BREAK BIT
  4034 00001173 F6C702              <1> 	test	bh, LC_E0		; LAST CODE THE E0 MARKER CODE
  4035 00001176 7410                <1> 	jz	short NOT_LC_E0		; JUMP IF NOT
  4036                              <1> 	;
  4037 00001178 BF[56650000]        <1> 	mov	edi, _K6+6		; IS THIS A SHIFT KEY?
  4038 0000117D AE                  <1> 	scasb
  4039                              <1> 	;je	K26 ; K16B              ; YES, THROW AWAY & RESET FLAG
  4040                              <1> 	; 12/04/2021
  4041 0000117E 745B                <1> 	je	short K16B ; K26
  4042 00001180 AE                  <1> 	scasb
  4043 00001181 756D                <1> 	jne	short K16A		; NO, CONTINUE KEY PROCESSING
  4044                              <1> 	;jmp	short K16B		; YES, THROW AWAY & RESET FLAG
  4045 00001183 E997010000          <1> 	jmp	K26
  4046                              <1> 	;
  4047                              <1> NOT_LC_E0:
  4048 00001188 F6C701              <1> 	test	bh, LC_E1		; LAST CODE THE E1 MARKER CODE?
  4049 0000118B 7425                <1> 	jz	short T_SYS_KEY		; JUMP IF NOT
  4050 0000118D B904000000          <1> 	mov	ecx, 4			; LENGHT OF SEARCH
  4051 00001192 BF[54650000]        <1> 	mov	edi, _K6+4		; IS THIS AN ALT, CTL, OR SHIFT?
  4052 00001197 F2AE                <1> 	repne	scasb			; CHECK IT
  4053 00001199 74D1                <1> 	je	short EXIT		; THROW AWAY IF SO
  4054                              <1> 	; 12/04/2021
  4055                              <1> 	;je	K26A			
  4056                              <1> 	;
  4057 0000119B 3C45                <1> 	cmp	al, NUM_KEY		; IS IT THE PAUSE KEY?
  4058 0000119D 753C                <1> 	jne	short K16B		; NO, THROW AWAY & RESET FLAG
  4059                              <1> 	; 12/04/2021
  4060                              <1> 	;jne	K26
  4061 0000119F F6C480              <1> 	test	ah, 80h			; YES, IS IT THE BREAK OF THE KEY?
  4062 000011A2 7537                <1> 	jnz	short K16B		; YES, THROW THIS AWAY, TOO	
  4063                              <1> 	; 24/07/2022
  4064                              <1> 	;jnz	K26
  4065                              <1>         ; 20/02/2015 
  4066 000011A4 F605[6A660000]08    <1> 	test	byte [KB_FLAG_1],HOLD_STATE ; NO, ARE WE PAUSED ALREADY?
  4067 000011AB 752E                <1> 	jnz	short K16B		; YES, THROW AWAY
  4068                              <1> 	; 12/04/2021
  4069                              <1> 	;jnz	K26
  4070 000011AD E9B1020000          <1> 	jmp     K39P                    ; NO, THIS IS THE REAL PAUSE STATE
  4071                              <1> 	;
  4072                              <1> 	;-----	TEST FOR SYSTEM KEY
  4073                              <1> T_SYS_KEY:
  4074 000011B2 3C54                <1> 	cmp	al, SYS_KEY		; IS IT THE SYSTEM KEY?
  4075 000011B4 753A                <1> 	jnz	short K16A		; CONTINUE IF NOT
  4076                              <1> 	;
  4077 000011B6 F6C480              <1> 	test	ah, 80h			; CHECK IF THIS A BREAK CODE
  4078 000011B9 7525                <1> 	jnz	short K16C		; DO NOT TOUCH SYSTEM INDICATOR IF TRUE
  4079                              <1> 	;
  4080 000011BB F605[6A660000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 
  4081 000011C2 7517                <1> 	jnz	short K16B		; IF YES, DO NOT PROCESS SYSTEM INDICATOR	
  4082                              <1> 	; 12/04/2021
  4083                              <1> 	;jnz	K26		
  4084                              <1> 	;
  4085 000011C4 800D[6A660000]04    <1> 	or	byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED
  4086 000011CB B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  4087 000011CD E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  4088                              <1> 					; INTERRUPT-RETURN-NO-EOI
  4089 000011CF B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  4090 000011D1 E82D040000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  4091                              <1> 	; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!!
  4092                              <1> 	;MOV	AL, 8500H		; FUNCTION VALUE FOR MAKE OF SYSTEM KEY
  4093                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
  4094                              <1> 	;INT	15H			; USER INTERRUPT	
  4095 000011D6 E957010000          <1>         jmp     K27A                    ; END PROCESSING
  4096                              <1> 	;
  4097 000011DB E93F010000          <1> K16B:	jmp	K26			; IGNORE SYSTEM KEY
  4098                              <1> 	;
  4099                              <1> K16C:
  4100 000011E0 8025[6A660000]FB    <1> 	and	byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN
  4101 000011E7 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  4102 000011E9 E620                <1> 	out	20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT
  4103                              <1> 					; INTERRUPT-RETURN-NO-EOI
  4104                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  4105                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
  4106                              <1> 	;
  4107                              <1> 	;MOV	AX, 8501H		; FUNCTION VALUE FOR BREAK OF SYSTEM KEY
  4108                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
  4109                              <1> 	;INT	15H			; USER INTERRUPT
  4110                              <1> 	;JMP	K27A			; INGONRE SYSTEM KEY				
  4111                              <1> 	;
  4112 000011EB E93B010000          <1> 	jmp     K27			; IGNORE SYSTEM KEY
  4113                              <1> 	;
  4114                              <1> 	;-----	TEST FOR SHIFT KEYS
  4115                              <1> K16A:
  4116 000011F0 8A1D[69660000]      <1> 	mov	bl, [KB_FLAG]		; PUT STATE FLAGS IN BL
  4117 000011F6 BF[50650000]        <1> 	mov	edi, _K6		; SHIFT KEY TABLE offset
  4118 000011FB B908000000          <1> 	mov	ecx, _K6L		; LENGTH
  4119 00001200 F2AE                <1> 	repne	scasb			; LOOK THROUGH THE TABLE FOR A MATCH
  4120 00001202 88E0                <1> 	mov	al, ah			; RECOVER SCAN CODE
  4121                              <1>         ;jne	K25                     ; IF NO MATCH, THEN SHIFT NOT FOUND
  4122                              <1> 	; 12/04/2021
  4123 00001204 7405                <1> 	je	short K17
  4124 00001206 E9FC000000          <1> 	jmp	K25
  4125                              <1> 	;
  4126                              <1> 	;------	SHIFT KEY FOUND
  4127                              <1> K17:
  4128 0000120B 81EF[51650000]      <1>         sub     edi, _K6+1              ; ADJUST PTR TO SCAN CODE MATCH
  4129 00001211 8AA7[58650000]      <1>        	mov     ah, [edi+_K7]       	; GET MASK INTO AH
  4130 00001217 B102                <1> 	mov	cl, 2			; SETUP COUNT FOR FLAG SHIFTS
  4131 00001219 A880                <1> 	test	al, 80h			; TEST FOR BREAK KEY
  4132                              <1> 	;jnz	short K23		; JUMP OF BREAK
  4133                              <1> 	; 12/04/2021
  4134 0000121B 7405                <1> 	jz	short K17C
  4135 0000121D E981000000          <1> 	jmp	K23
  4136                              <1> 	;
  4137                              <1> 	;-----	SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE
  4138                              <1> K17C:
  4139 00001222 80FC10              <1> 	cmp	ah, SCROLL_SHIFT
  4140 00001225 7324                <1> 	jae	short K18		; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY
  4141                              <1> 	;
  4142                              <1> 	;-----	PLAIN SHIFT KEY, SET SHIFT ON
  4143 00001227 0825[69660000]      <1> 	or	[KB_FLAG], ah		; TURN ON SHIFT BIT
  4144 0000122D A80C                <1>         test	al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL?
  4145                              <1> 	;;jnz	short K17D		; YES, MORE FLAGS TO SET
  4146                              <1> 	;jz	K26			; NO, INTERRUPT RETURN
  4147                              <1> 	; 12/04/2021
  4148 0000122F 7415                <1> 	jz	short k17f
  4149                              <1> K17D:
  4150 00001231 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF NEW KEYS?
  4151 00001234 7408                <1> 	jz 	short K17E		; NO, JUMP
  4152 00001236 0825[6C660000]      <1> 	or	[KB_FLAG_3], ah		; SET BITS FOR RIGHT CTRL, ALT
  4153                              <1> 	;jmp	K26			; INTERRUPT RETURN
  4154                              <1> 	; 12/04/2021
  4155 0000123C EB08                <1> 	jmp	short k17f
  4156                              <1> K17E:
  4157 0000123E D2EC                <1> 	shr	ah, cl			; MOVE FLAG BITS TWO POSITIONS
  4158 00001240 0825[6A660000]      <1> 	or	[KB_FLAG_1], ah		; SET BITS FOR LEFT CTRL, ALT
  4159                              <1> k17f:	; 12/04/2021
  4160 00001246 E9D4000000          <1> 	jmp	K26
  4161                              <1> 	;
  4162                              <1> 	;-----	TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT
  4163                              <1> K18:					; SHIFT-TOGGLE
  4164 0000124B F6C304              <1> 	test	bl, CTL_SHIFT 		; CHECK CTL SHIFT STATE
  4165 0000124E 7402                <1> 	jz	short K18A              ; JUMP IF NOT CTL STATE
  4166                              <1>         ;jnz	K25                     ; JUMP IF CTL STATE
  4167                              <1> 	; 12/04/2021
  4168 00001250 EB1C                <1> 	jmp	short k20a ; K25
  4169                              <1> K18A:
  4170 00001252 3C52                <1> 	cmp	al, INS_KEY		; CHECK FOR INSERT KEY
  4171 00001254 7522                <1> 	jne	short K22		; JUMP IF NOT INSERT KEY
  4172 00001256 F6C308              <1> 	test	bl, ALT_SHIFT 		; CHECK FOR ALTERNATE SHIFT
  4173 00001259 7402                <1>       	jz	short K18B		; JUMP IF NOT ALTERNATE SHIFT	
  4174                              <1>         ;jnz	K25			; JUMP IF ALTERNATE SHIFT
  4175                              <1> 	; 12/04/2021
  4176 0000125B EB11                <1> 	jmp	short k20a ; K25
  4177                              <1> K18B:
  4178 0000125D F6C702              <1> 	test	bh, LC_E0 ;20/02/2015	; IS THIS NEW INSERT KEY?
  4179 00001260 7516                <1> 	jnz	short K22		; YES, THIS ONE'S NEVER A '0'
  4180                              <1> K19:	
  4181 00001262 F6C320              <1> 	test	bl, NUM_STATE 		; CHECK FOR BASE STATE
  4182 00001265 750C                <1> 	jnz	short K21		; JUMP IF NUM LOCK IS ON
  4183 00001267 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE
  4184 0000126A 740C                <1> 	jz	short K22		; JUMP IF BASE STATE
  4185                              <1> K20:					; NUMERIC ZERO, NOT INSERT KEY
  4186 0000126C 88C4                <1> 	mov	ah, al			; PUT SCAN CODE BACK IN AH
  4187                              <1> k20a:	; 12/04/2021
  4188 0000126E E994000000          <1>         jmp     K25                     ; NUMERAL '0', STNDRD. PROCESSING
  4189                              <1> K21:					; MIGHT BE NUMERIC
  4190 00001273 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT
  4191 00001276 74F4                <1> 	jz	short K20		; IS NUMERIC, STD. PROC.
  4192                              <1> 	;
  4193                              <1> K22:					; SHIFT TOGGLE KEY HIT; PROCESS IT
  4194 00001278 8425[6A660000]      <1> 	test	ah, [KB_FLAG_1] 	; IS KEY ALREADY DEPRESSED
  4195                              <1>         ;jnz	short K26		; JUMP IF KEY ALREADY DEPRESSED
  4196                              <1> 	; 12/04/2021
  4197 0000127E 75C6                <1> 	jnz	short k17f ; K26
  4198                              <1> K22A:
  4199 00001280 0825[6A660000]      <1>         or      [KB_FLAG_1], ah 	; INDICATE THAT THE KEY IS DEPRESSED
  4200 00001286 3025[69660000]      <1> 	xor	[KB_FLAG], ah		; TOGGLE THE SHIFT STATE
  4201                              <1> 	;
  4202                              <1> 	;-----	TOGGLE LED IF CAPS, NUM  OR SCROLL KEY DEPRESSED
  4203 0000128C F6C470              <1> 	test	ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE?
  4204 0000128F 7407                <1> 	jz	short K22B		; GO IF NOT
  4205                              <1> 	;
  4206                              <1> 	; 12/04/2021 (32 bit push/pop)
  4207 00001291 50                  <1> 	push	eax ; push ax		; SAVE SCAN CODE AND SHIFT MASK
  4208 00001292 E8C7030000          <1> 	call	SND_LED			; GO TURN MODE INDICATORS ON
  4209 00001297 58                  <1> 	pop	eax ; pop ax		; RESTORE SCAN CODE
  4210                              <1> K22B:
  4211 00001298 3C52                <1> 	cmp	al, INS_KEY		; TEST FOR 1ST MAKE OF INSERT KEY
  4212                              <1>         ;jne	short K26		; JUMP IF NOT INSERT KEY
  4213                              <1> 	; 12/04/2021
  4214 0000129A 75AA                <1> 	jne	short k17f ; K26
  4215 0000129C 88C4                <1> 	mov	ah, al		        ; SCAN CODE IN BOTH HALVES OF AX
  4216 0000129E E999000000          <1>         jmp	K28                     ; FLAGS UPDATED, PROC. FOR BUFFER
  4217                              <1> 	;
  4218                              <1> 	;-----	BREAK SHIFT FOUND
  4219                              <1> K23:					; BREAK-SHIFT-FOUND
  4220 000012A3 80FC10              <1> 	cmp	ah, SCROLL_SHIFT	; IS THIS A TOGGLE KEY
  4221 000012A6 F6D4                <1> 	not	ah			; INVERT MASK
  4222 000012A8 7355                <1> 	jae	short K24		; YES, HANDLE BREAK TOGGLE
  4223 000012AA 2025[69660000]      <1> 	and	[KB_FLAG], ah		; TURN OFF SHIFT BIT
  4224 000012B0 80FCFB              <1> 	cmp	ah, ~CTL_SHIFT		; IS THIS ALT OR CTL?
  4225 000012B3 7730                <1> 	ja	short K23D		; NO, ALL DONE
  4226                              <1> 	;
  4227 000012B5 F6C702              <1> 	test	bh, LC_E0		; 2ND ALT OR CTL?
  4228 000012B8 7408                <1> 	jz	short K23A		; NO, HANSLE NORMALLY
  4229 000012BA 2025[6C660000]      <1> 	and 	[KB_FLAG_3], ah		; RESET BIT FOR RIGHT ALT OR CTL
  4230 000012C0 EB08                <1> 	jmp	short K23B		; CONTINUE
  4231                              <1> K23A:
  4232 000012C2 D2FC                <1> 	sar	ah, cl			; MOVE THE MASK BIT TWO POSITIONS
  4233 000012C4 2025[6A660000]      <1> 	and	[KB_FLAG_1], ah		; RESET BIT FOR LEFT ALT AND CTL
  4234                              <1> K23B:
  4235 000012CA 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE
  4236 000012CC A0[6C660000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT ALT & CTRL FLAGS
  4237 000012D1 D2E8                <1> 	shr	al, cl			; MOVE TO BITS 1 & 0
  4238 000012D3 0A05[6A660000]      <1> 	or	al, [KB_FLAG_1]		; PUT IN LEFT ALT & CTL FLAGS
  4239 000012D9 D2E0                <1> 	shl	al, cl			; MOVE BACK TO BITS 3 & 2
  4240 000012DB 240C                <1> 	and	al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE
  4241 000012DD 0805[69660000]      <1> 	or	[KB_FLAG], al		; PUT RESULT IN THE REAL FLAGS	
  4242 000012E3 88E0                <1> 	mov	al, ah
  4243                              <1> K23D:
  4244 000012E5 3CB8                <1> 	cmp	al, ALT_KEY+80h		; IS THIS ALTERNATE SHIFT RELEASE
  4245 000012E7 7536                <1> 	jne	short K26		; INTERRUPT RETURN
  4246                              <1> 	;	
  4247                              <1> 	;-----	ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER
  4248 000012E9 A0[6D660000]        <1> 	mov	al, [ALT_INPUT]
  4249 000012EE B400                <1> 	mov	ah, 0			; SCAN CODE OF 0
  4250 000012F0 8825[6D660000]      <1> 	mov	[ALT_INPUT], ah 	; ZERO OUT THE FIELD
  4251 000012F6 3C00                <1> 	cmp	al, 0			; WAS THE INPUT = 0?
  4252 000012F8 7425                <1> 	je	short K26		; INTERRUPT_RETURN
  4253                              <1>         ; 29/01/2016
  4254                              <1> 	;jmp	K61			; IT WASN'T, SO PUT IN BUFFER
  4255 000012FA E9AB020000          <1> 	jmp	_K60
  4256                              <1> 	;
  4257                              <1> K24:					; BREAK-TOGGLE
  4258 000012FF 2025[6A660000]      <1> 	and	[KB_FLAG_1], ah 	; INDICATE NO LONGER DEPRESSED
  4259 00001305 EB18                <1> 	jmp	short K26		; INTERRUPT_RETURN
  4260                              <1> 	;
  4261                              <1> 	;-----	TEST FOR HOLD STATE
  4262                              <1> 					; AL, AH = SCAN CODE
  4263                              <1> K25:					; NO-SHIFT-FOUND
  4264 00001307 3C80                <1> 	cmp	al, 80h			; TEST FOR BREAK KEY
  4265 00001309 7314                <1> 	jae	short K26		; NOTHING FOR BREAK CHARS FROM HERE ON
  4266 0000130B F605[6A660000]08    <1> 	test	byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE
  4267 00001312 7428                <1> 	jz	short K28		; BRANCH AROUND TEST IF NOT
  4268 00001314 3C45                <1> 	cmp	al, NUM_KEY
  4269 00001316 7407                <1> 	je	short K26		; CAN'T END HOLD ON NUM_LOCK
  4270 00001318 8025[6A660000]F7    <1> 	and	byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT
  4271                              <1> K26:
  4272 0000131F 8025[6C660000]FC    <1> 	and	byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  4273                              <1> K26A:					; INTERRUPT-RETURN
  4274 00001326 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4275 00001327 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  4276 00001329 E620                <1> 	out	20h, al	;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  4277                              <1> K27:					; INTERRUPT-RETURN-NO-EOI
  4278 0000132B B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  4279 0000132D E8D1020000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  4280                              <1> K27A:
  4281 00001332 FA                  <1> 	cli				; DISABLE INTERRUPTS
  4282                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017 ;; 15/01/2017
  4283 00001333 07                  <1> 	pop	es			; RESTORE REGISTERS
  4284 00001334 1F                  <1> 	pop	ds
  4285 00001335 5F                  <1> 	pop	edi
  4286 00001336 5E                  <1> 	pop	esi
  4287 00001337 5A                  <1> 	pop	edx
  4288 00001338 59                  <1> 	pop	ecx
  4289 00001339 5B                  <1> 	pop	ebx
  4290 0000133A 58                  <1> 	pop	eax
  4291                              <1> 	;pop	ebp
  4292 0000133B CF                  <1> 	iretd				; RETURN
  4293                              <1> 
  4294                              <1> 	;-----	NOT IN	HOLD STATE
  4295                              <1> K28:					; NO-HOLD-STATE
  4296 0000133C 3C58                <1> 	cmp	al, 88			; TEST FOR OUT-OF-RANGE SCAN CODES
  4297 0000133E 77DF                <1> 	ja	short K26		; IGNORE IF OUT-OF-RANGE	
  4298                              <1> 	;
  4299 00001340 F6C308              <1> 	test	bl, ALT_SHIFT 		; ARE WE IN ALTERNATE SHIFT
  4300 00001343 740E                <1>         jz	short K28A		; IF NOT ALTERNATE
  4301                              <1>         ; 12/04/2021
  4302                              <1> 	;jz	K38
  4303                              <1> 	;
  4304 00001345 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENCHANCED KEYBOARD?
  4305 00001348 740E                <1> 	jz	short K29		; NO, ALT STATE IS REAL
  4306                              <1> 	 ;28/02/2015
  4307 0000134A F605[6A660000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN?
  4308 00001351 7405                <1> 	jz	short K29		;  NO, ALT STATE IS REAL
  4309                              <1> 	; 12/04/2021
  4310                              <1> 	;jnz	K38			; YES, THIS IS PHONY ALT STATE 
  4311                              <1>         ;				; DUE TO PRESSING SYSREQ	
  4312 00001353 E9C4000000          <1> K28A:	jmp	K38
  4313                              <1> 	;
  4314                              <1> 	;-----	TEST FOR RESET KEY SEQUENCE (CTL ALT DEL)
  4315                              <1> K29:					; TEST-RESET
  4316 00001358 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT ALSO?
  4317 0000135B 740B                <1> 	jz	short K31		; NO_RESET
  4318 0000135D 3C53                <1> 	cmp	al, DEL_KEY		; CTL-ALT STATE, TEST FOR DELETE KEY
  4319 0000135F 7507                <1> 	jne	short K31		; NO_RESET, IGNORE
  4320                              <1> 	;
  4321                              <1> 	;-----	CTL-ALT-DEL HAS BEEN FOUND
  4322                              <1>  	; 26/08/2014
  4323                              <1> cpu_reset:
  4324                              <1> 	; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN)
  4325                              <1> 	; Send FEh (system reset command) to the keyboard controller.
  4326 00001361 B0FE                <1> 	mov	al, SHUT_CMD		; SHUTDOWN COMMAND
  4327 00001363 E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROL PORT
  4328                              <1> khere:
  4329 00001365 F4                  <1> 	hlt				; WAIT FOR 80286 RESET
  4330 00001366 EBFD                <1> 	jmp 	short khere		; INSURE HALT
  4331                              <1> 	;
  4332                              <1> 	;-----	IN ALTERNATE SHIFT, RESET NOT FOUND
  4333                              <1> K31:					; NO-RESET
  4334 00001368 3C39                <1> 	cmp	al, 57			; TEST FOR SPACE KEY
  4335 0000136A 7507                <1> 	jne	short K311		; NOT THERE
  4336 0000136C B020                <1> 	mov	al, ' '			; SET SPACE CHAR
  4337                              <1> k31a:	; 12/04/2021
  4338 0000136E E929020000          <1>         jmp     K57                     ; BUFFER_FILL
  4339                              <1> K311:
  4340 00001373 3C0F                <1> 	cmp	al, 15			; TEST FOR TAB KEY
  4341 00001375 7506                <1> 	jne	short K312		; NOT THERE
  4342 00001377 66B800A5            <1> 	mov	ax, 0A500h		; SET SPECIAL CODE FOR ALT-TAB
  4343                              <1>         ;jmp	K57			; BUFFER_FILL
  4344                              <1> 	; 12/04/2021
  4345 0000137B EBF1                <1> 	jmp	short k31a
  4346                              <1> K312:
  4347 0000137D 3C4A                <1> 	cmp	al, 74			; TEST FOR KEY PAD -
  4348                              <1>         ;je	short K37B		; GO PROCESS
  4349                              <1> 	; 12/04/2021
  4350 0000137F 7404                <1> 	je	short k312a
  4351 00001381 3C4E                <1> 	cmp	al, 78			; TEST FOR KEY PAD +
  4352                              <1>         ;je	short K37B		; GO PROCESS
  4353                              <1> 	; 12/04/2021
  4354 00001383 7505                <1> 	jne	short K32
  4355                              <1> k312a:
  4356 00001385 E988000000          <1> 	jmp	K37B	
  4357                              <1> 	;
  4358                              <1> 	;-----	LOOK FOR KEY PAD ENTRY
  4359                              <1> K32:					; ALT-KEY-PAD
  4360 0000138A BF[2C650000]        <1> 	mov	edi, K30		; ALT-INPUT-TABLE offset
  4361 0000138F B90A000000          <1> 	mov	ecx, 10			; LOOK FOR ENTRY USING KEYPAD
  4362 00001394 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH
  4363 00001396 7521                <1> 	jne	short K33		; NO_ALT_KEYPAD
  4364 00001398 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF THE NEW KEYS?
  4365 0000139B 7579                <1>         jnz	short K37C		; YES, JUMP, NOT NUMPAD KEY
  4366 0000139D 81EF[2D650000]      <1> 	sub	edi, K30+1		; DI NOW HAS ENTRY VALUE
  4367 000013A3 A0[6D660000]        <1> 	mov	al, [ALT_INPUT] 	; GET THE CURRENT BYTE
  4368 000013A8 B40A                <1> 	mov	ah, 10			; MULTIPLY BY 10
  4369 000013AA F6E4                <1> 	mul	ah
  4370 000013AC 6601F8              <1> 	add	ax, di			; ADD IN THE LATEST ENTRY
  4371 000013AF A2[6D660000]        <1> 	mov	[ALT_INPUT], al 	; STORE IT AWAY
  4372                              <1> K32A:
  4373 000013B4 E966FFFFFF          <1>         jmp     K26                     ; THROW AWAY THAT KEYSTROKE
  4374                              <1> 	;
  4375                              <1> 	;-----	LOOK FOR SUPERSHIFT ENTRY
  4376                              <1> K33:					; NO-ALT-KEYPAD
  4377 000013B9 C605[6D660000]00    <1>         mov     byte [ALT_INPUT], 0     ; ZERO ANY PREVIOUS ENTRY INTO INPUT
  4378 000013C0 B91A000000          <1> 	mov	ecx, 26			; (DI),(ES) ALREADY POINTING
  4379 000013C5 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH IN ALPHABET
  4380 000013C7 7445                <1> 	je	short K37A		; MATCH FOUND, GO FILLL THE BUFFER
  4381                              <1> 	;
  4382                              <1> 	;-----	LOOK FOR TOP ROW OF ALTERNATE SHIFT
  4383                              <1> K34:					; ALT-TOP-ROW
  4384 000013C9 3C02                <1> 	cmp	al, 2			; KEY WITH '1' ON IT
  4385 000013CB 7245                <1> 	jb	short K37B		; MUST BE ESCAPE
  4386 000013CD 3C0D                <1> 	cmp	al, 13			; IS IT IN THE REGION
  4387 000013CF 7705                <1> 	ja	short K35		; NO, ALT SOMETHING ELSE
  4388 000013D1 80C476              <1> 	add	ah, 118			; CONVERT PSEUDO SCAN CODE TO RANGE
  4389 000013D4 EB38                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  4390                              <1> 	;
  4391                              <1> 	;-----	TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES
  4392                              <1> K35:					; ALT-FUNCTION
  4393 000013D6 3C57                <1> 	cmp	al, F11_M		; IS IT F11?	
  4394 000013D8 7209                <1> 	jb	short K35A ; 20/02/2015	; NO, BRANCH
  4395 000013DA 3C58                <1> 	cmp	al, F12_M		; IS IT F12?
  4396 000013DC 7705                <1> 	ja	short K35A ; 20/02/2015	; NO, BRANCH
  4397 000013DE 80C434              <1> 	add	ah, 52			; CONVERT TO PSEUDO SCAN CODE
  4398 000013E1 EB2B                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  4399                              <1> K35A:
  4400 000013E3 F6C702              <1> 	test	bh, LC_E0		; DO WE HAVE ONE OF THE NEW KEYS?
  4401 000013E6 741B                <1> 	jz	short K37		; NO, JUMP
  4402 000013E8 3C1C                <1> 	cmp	al, 28			; TEST FOR KEYPAD ENTER
  4403 000013EA 7506                <1>         jne     short K35B              ; NOT THERE
  4404 000013EC 66B800A6            <1> 	mov	ax, 0A600h		; SPECIAL CODE
  4405                              <1> 	;jmp	K57			; BUFFER FILL
  4406                              <1> 	; 12/04/2021
  4407 000013F0 EB0C                <1> 	jmp	short k35c
  4408                              <1> K35B:
  4409 000013F2 3C53                <1> 	cmp	al, 83			; TEST FOR DELETE KEY
  4410 000013F4 7420                <1> 	je	short K37C		; HANDLE WITH OTHER EDIT KEYS
  4411 000013F6 3C35                <1> 	cmp	al, 53			; TEST FOR KEYPAD /
  4412 000013F8 75BA                <1> 	jne	short K32A		; NOT THERE, NO OTHER E0 SPECIALS
  4413                              <1>         ; 12/04/2021
  4414                              <1> 	;jne	K26
  4415 000013FA 66B800A4            <1> 	mov	ax, 0A400h		; SPECIAL CODE1
  4416                              <1> k35c:	; 12/04/2021
  4417 000013FE E999010000          <1> 	jmp	K57			; BUFFER FILL
  4418                              <1> K37:
  4419 00001403 3C3B                <1> 	cmp	al, 59			; TEST FOR FUNCTION KEYS (F1)
  4420 00001405 720B                <1>         jb      short K37B		; NO FN, HANDLE W/OTHER EXTENDED
  4421 00001407 3C44                <1> 	cmp	al, 68			; IN KEYPAD REGION?
  4422 00001409 77A9                <1> 	ja	short K32A		; IF SO, IGNORE
  4423                              <1> 	; 12/04/2021
  4424                              <1> 	;ja	K26
  4425 0000140B 80C42D              <1> 	add	ah, 45			; CONVERT TO PSEUDO SCAN CODE
  4426                              <1> K37A:
  4427 0000140E B000                <1> 	mov	al, 0			; ASCII CODE OF ZERO
  4428                              <1> 	;jmp	K57			; PUT IT IN THE BUFFER
  4429                              <1> 	; 12/04/2021
  4430 00001410 EBEC                <1> 	jmp	short k35c
  4431                              <1> K37B:
  4432 00001412 B0F0                <1> 	mov	al, 0F0h		; USE SPECIAL ASCII CODE
  4433                              <1> 	;jmp	K57			; PUT IT IN THE BUFFER
  4434                              <1> 	; 12/04/2021
  4435 00001414 EBE8                <1> 	jmp	short k35c
  4436                              <1> K37C:
  4437 00001416 0450                <1> 	add	al, 80			; CONVERT SCAN CODE (EDIT KEYS)
  4438 00001418 88C4                <1> 	mov	ah, al			; (SCAN CODE NOT IN AH FOR INSERT)
  4439 0000141A EBF2                <1> 	jmp     short K37A              ; PUT IT IN THE BUFFER
  4440                              <1> 	;
  4441                              <1> 	;-----	NOT IN ALTERNATE SHIFT
  4442                              <1> K38:					; NOT-ALT-SHIFT
  4443                              <1> 					; BL STILL HAS SHIFT FLAGS
  4444 0000141C F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT?
  4445                              <1> 	;;jnz	short K38A		; YES, START PROCESSING	
  4446                              <1>         ;jz	K44			; NOT-CTL-SHIFT
  4447                              <1> 	; 12/04/2021
  4448 0000141F 7505                <1> 	jnz	short K38A		; YES, START PROCESSING	
  4449 00001421 E9AB000000          <1> 	jmp	K44			; NOT-CTL-SHIFT
  4450                              <1> 	;
  4451                              <1> 	;-----	CONTROL SHIFT, TEST SPECIAL CHARACTERS
  4452                              <1> 	;-----	TEST FOR BREAK
  4453                              <1> K38A:
  4454 00001426 3C46                <1> 	cmp	al, SCROLL_KEY		; TEST FOR BREAK
  4455 00001428 7530                <1> 	jne	short K39		; JUMP, NO-BREAK
  4456 0000142A F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  4457 0000142D 7405                <1> 	jz	short K38B		; NO, BREAK IS VALID	
  4458 0000142F F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  4459 00001432 7426                <1> 	jz	short K39		; NO-BREAK, TEST FOR PAUSE	
  4460                              <1> K38B:
  4461 00001434 8B1D[76660000]      <1> 	mov	ebx, [BUFFER_HEAD] 	; RESET BUFFER TO EMPTY
  4462 0000143A 891D[7A660000]      <1> 	mov	[BUFFER_TAIL], ebx
  4463 00001440 C605[68660000]80    <1> 	mov	byte [BIOS_BREAK], 80h  ; TURN ON BIOS_BREAK BIT
  4464                              <1> 	;
  4465                              <1> 	;-----	ENABLE KEYBOARD
  4466 00001447 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  4467 00001449 E8B5010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  4468                              <1> 	;
  4469                              <1> 	; CTRL+BREAK code here !!!
  4470                              <1> 	;INT	1BH			; BREAK INTERRUPT VECTOR
  4471                              <1> 	; 17/10/2015	
  4472 0000144E E85B580000          <1> 	call	ctrlbrk ; control+break subroutine
  4473                              <1> 	;
  4474                              <1> 	;sub	ax, ax			; PUT OUT DUMMY CHARACTER
  4475                              <1>         ; 12/04/2021
  4476 00001453 29C0                <1> 	sub	eax, eax
  4477 00001455 E942010000          <1>         jmp     K57                     ; BUFFER_FILL
  4478                              <1> 	;
  4479                              <1> 	;-----	TEST FOR PAUSE
  4480                              <1> K39:					; NO_BREAK
  4481 0000145A F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  4482 0000145D 7537                <1> 	jnz	short K41		; YES, THEN THIS CAN'T BE PAUSE	
  4483 0000145F 3C45                <1> 	cmp	al, NUM_KEY		; LOOK FOR PAUSE KEY
  4484 00001461 7533                <1> 	jne	short K41		; NO-PAUSE
  4485                              <1> K39P:
  4486 00001463 800D[6A660000]08    <1> 	or	byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG
  4487                              <1> 	;
  4488                              <1> 	;-----	ENABLE KEYBOARD
  4489 0000146A B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  4490 0000146C E892010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  4491                              <1> K39A:
  4492 00001471 B020                <1> 	mov	al, EOI			; END OF INTERRUPT TO CONTROL PORT
  4493 00001473 E620                <1> 	out	20h, al ;out INTA00, al	; ALLOW FURTHER KEYSTROKE INTERRUPTS
  4494                              <1> 	;
  4495                              <1> 	;-----	DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON
  4496 00001475 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7      ; IS THIS BLACK AND WHITE CARD
  4497 0000147C 740A                <1>         je      short K40              	; YES, NOTHING TO DO
  4498 0000147E 66BAD803            <1> 	mov	dx, 03D8h		; PORT FOR COLOR CARD
  4499 00001482 A0[9F660000]        <1>         mov     al, [CRT_MODE_SET] 	; GET THE VALUE OF THE CURRENT MODE
  4500 00001487 EE                  <1> 	out	dx, al			; SET THE CRT MODE, SO THAT CRT IS ON
  4501                              <1> 	;
  4502                              <1> K40:					; PAUSE-LOOP
  4503 00001488 F605[6A660000]08    <1>         test    byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG
  4504 0000148F 75F7                <1> 	jnz	short K40		; LOOP UNTIL FLAG TURNED OFF
  4505                              <1> 	;
  4506 00001491 E995FEFFFF          <1>         jmp     K27                     ; INTERRUPT_RETURN_NO_EOI
  4507                              <1>         ;
  4508                              <1> 	;-----	TEST SPECIAL CASE KEY 55
  4509                              <1> K41:					; NO-PAUSE
  4510 00001496 3C37                <1> 	cmp	al, 55			; TEST FOR */PRTSC KEY
  4511 00001498 7513                <1> 	jne	short K42		; NOT-KEY-55
  4512 0000149A F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  4513 0000149D 7405                <1> 	jz	short K41A		; NO, CTL-PRTSC IS VALID	
  4514 0000149F F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  4515 000014A2 7421                <1> 	jz	short K42B		; NO, TRANSLATE TO A FUNCTION
  4516                              <1> K41A:	
  4517 000014A4 66B80072            <1> 	mov	ax, 114*256		; START/STOP PRINTING SWITCH
  4518 000014A8 E9EF000000          <1>         jmp     K57                     ; BUFFER_FILL
  4519                              <1> 	;
  4520                              <1> 	;-----	SET UP TO TRANSLATE CONTROL SHIFT
  4521                              <1> K42:					; NOT-KEY-55
  4522 000014AD 3C0F                <1> 	cmp	al, 15			; IS IT THE TAB KEY?
  4523 000014AF 7414                <1> 	je	short K42B		; YES, XLATE TO FUNCTION CODE
  4524 000014B1 3C35                <1> 	cmp	al, 53			; IS IT THE / KEY?
  4525 000014B3 750E                <1> 	jne	short K42A		; NO, NO MORE SPECIAL CASES	
  4526 000014B5 F6C702              <1> 	test	bh, LC_E0		; YES, IS IT FROM THE KEY PAD?
  4527 000014B8 7409                <1> 	jz	short K42A		; NO, JUST TRANSLATE
  4528 000014BA 66B80095            <1> 	mov	ax, 9500h		; YES, SPECIAL CODE FOR THIS ONE
  4529 000014BE E9D9000000          <1> 	jmp	K57			; BUFFER FILL	
  4530                              <1> K42A: 
  4531                              <1> 	;;mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  4532 000014C3 3C3B                <1> 	cmp	al, 59			; IS IT IN CHARACTER TABLE?
  4533                              <1>         ;jb	short K45F              ; YES, GO TRANSLATE CHAR
  4534                              <1> 	;;jb	K56 ; 20/02/2015
  4535                              <1> 	;;jmp	K64 ; 20/02/2015
  4536                              <1> K42B:
  4537 000014C5 BB[60650000]        <1> 	mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  4538                              <1> 	;jb	K56 ;; 20/02/2015
  4539                              <1> 	; 12/04/2021
  4540 000014CA 7267                <1> 	jb	short K45F	
  4541 000014CC E9B9000000          <1> 	jmp	K64	
  4542                              <1>         ;
  4543                              <1> 	;-----	NOT IN CONTROL SHIFT
  4544                              <1> K44:					; NOT-CTL-SHIFT
  4545 000014D1 3C37                <1> 	cmp	al, 55			; PRINT SCREEN KEY?
  4546 000014D3 7528                <1> 	jne	short K45		; NOT PRINT SCREEN
  4547 000014D5 F6C710              <1> 	test	bh, KBX			; IS THIS ENHANCED KEYBOARD?
  4548 000014D8 7407                <1> 	jz	short K44A		; NO, TEST FOR SHIFT STATE	
  4549 000014DA F6C702              <1> 	test	bh, LC_E0		; YES, LAST CODE A MARKER?
  4550 000014DD 7507                <1> 	jnz	short K44B		; YES, IS PRINT SCREEN
  4551 000014DF EB41                <1> 	jmp	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  4552                              <1> K44A:
  4553 000014E1 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN?
  4554 000014E4 743C                <1> 	jz	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  4555                              <1> 	;
  4556                              <1> 	;-----	ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION
  4557                              <1> K44B:
  4558 000014E6 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  4559 000014E8 E816010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  4560 000014ED B020                <1> 	mov	al, EOI			; END OF CURRENT INTERRUPT
  4561 000014EF E620                <1> 	out	20h, al ;out INTA00, al	; SO FURTHER THINGS CAN HAPPEN
  4562                              <1> 	; Print Screen !!!		; ISSUE PRINT SCREEN INTERRUPT (INT 05h)
  4563                              <1> 	;PUSH 	BP			; SAVE POINTER
  4564                              <1> 	;INT 	5H			; ISSUE PRINT SCREEN INTERRUPT
  4565                              <1> 	;POP	BP			; RESTORE POINTER
  4566 000014F1 8025[6C660000]FC    <1>         and     byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS
  4567 000014F8 E92EFEFFFF          <1>         jmp     K27                     ; GO BACK WITHOUT EOI OCCURRING
  4568                              <1> 	;
  4569                              <1> 	;-----	HANDLE IN-CORE KEYS
  4570                              <1> K45:					; NOT-PRINT-SCREEN
  4571 000014FD 3C3A                <1> 	cmp	al, 58			; TEST FOR IN-CORE AREA
  4572 000014FF 7734                <1> 	ja	short K46		; JUMP IF NOT
  4573 00001501 3C35                <1> 	cmp	al, 53			; IS THIS THE '/' KEY?
  4574 00001503 7505                <1> 	jne	short K45A		; NO, JUMP
  4575 00001505 F6C702              <1> 	test	bh, LC_E0		; WAS THE LAST CODE THE MARKER?
  4576 00001508 7518                <1> 	jnz	short K45C		; YES, TRANSLATE TO CHARACTER
  4577                              <1> K45A:
  4578 0000150A B91A000000          <1> 	mov	ecx, 26			; LENGHT OF SEARCH
  4579 0000150F BF[36650000]        <1> 	mov	edi, K30+10		; POINT TO TABLE OF A-Z CHARS
  4580 00001514 F2AE                <1> 	repne	scasb			; IS THIS A LETTER KEY?
  4581                              <1> 		; 20/02/2015
  4582 00001516 7505                <1> 	jne	short K45B              ; NO, SYMBOL KEY
  4583                              <1> 	;
  4584 00001518 F6C340              <1> 	test	bl, CAPS_STATE		; ARE WE IN CAPS_LOCK?
  4585 0000151B 750C                <1> 	jnz	short K45D		; TEST FOR SURE
  4586                              <1> K45B:
  4587 0000151D F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  4588 00001520 750C                <1> 	jnz	short K45E		; YES, UPPERCASE
  4589                              <1> 					; NO, LOWERCASE
  4590                              <1> K45C:
  4591 00001522 BB[B8650000]        <1> 	mov	ebx, K10		; TRANSLATE TO LOWERCASE LETTERS
  4592 00001527 EB51                <1> 	jmp	short K56	
  4593                              <1> K45D:					; ALMOST-CAPS-STATE
  4594 00001529 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO?
  4595 0000152C 75F4                <1> 	jnz	short K45C		; SHIFTED TEMP OUT OF CAPS STATE
  4596                              <1> K45E:
  4597 0000152E BB[10660000]        <1> 	mov	ebx, K11		; TRANSLATE TO UPPER CASE LETTERS
  4598 00001533 EB45                <1> K45F:	jmp	short K56
  4599                              <1> 	;
  4600                              <1> 	;-----	TEST FOR KEYS F1 - F10
  4601                              <1> K46:					; NOT IN-CORE AREA
  4602 00001535 3C44                <1> 	cmp	al, 68			; TEST FOR F1 - F10
  4603                              <1> 	;ja	short K47		; JUMP IF NOT
  4604                              <1> 	;jmp	short K53		; YES, GO DO FN KEY PROCESS			
  4605 00001537 7635                <1> 	jna	short K53		
  4606                              <1> 	;
  4607                              <1> 	;-----	HANDLE THE NUMERIC PAD KEYS
  4608                              <1> K47:					; NOT F1 - F10
  4609 00001539 3C53                <1> 	cmp	al, 83			; TEST NUMPAD KEYS
  4610 0000153B 772D                <1> 	ja	short K52		; JUMP IF NOT
  4611                              <1> 	;
  4612                              <1> 	;-----	KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION
  4613                              <1> K48:
  4614 0000153D 3C4A                <1> 	cmp	al, 74			; SPECIAL CASE FOR MINUS
  4615 0000153F 74ED                <1> 	je	short K45E		; GO TRANSLATE
  4616 00001541 3C4E                <1> 	cmp	al, 78			; SPECIAL CASE FOR PLUS
  4617 00001543 74E9                <1> 	je	short K45E		; GO TRANSLATE
  4618 00001545 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OFTHE NEW KEYS?
  4619 00001548 750A                <1> 	jnz	short K49		; YES, TRANSLATE TO BASE STATE
  4620                              <1> 	;		
  4621 0000154A F6C320              <1> 	test 	bl, NUM_STATE		; ARE WE IN NUM LOCK
  4622 0000154D 7514                <1> 	jnz	short K50		; TEST FOR SURE
  4623 0000154F F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  4624                              <1> 	;jnz	short K51		; IF SHIFTED, REALLY NUM STATE
  4625 00001552 75DA                <1> 	jnz	short K45E
  4626                              <1> 	;
  4627                              <1> 	;-----	BASE CASE FOR KEYPAD
  4628                              <1> K49:					
  4629 00001554 3C4C                <1> 	cmp	al, 76			; SPECIAL CASE FOR BASE STATE 5
  4630 00001556 7504                <1> 	jne	short K49A		; CONTINUE IF NOT KEYPAD 5
  4631 00001558 B0F0                <1> 	mov	al, 0F0h		; SPECIAL ASCII CODE	
  4632 0000155A EB40                <1> 	jmp	short K57		; BUFFER FILL
  4633                              <1> K49A:
  4634 0000155C BB[B8650000]        <1> 	mov	ebx, K10		; BASE CASE TABLE	
  4635 00001561 EB27                <1> 	jmp	short K64		; CONVERT TO PSEUDO SCAN
  4636                              <1> 	;
  4637                              <1> 	;-----	MIGHT BE NUM LOCK, TEST SHIFT STATUS
  4638                              <1> K50:					; ALMOST-NUM-STATE
  4639 00001563 F6C303              <1>         test    bl, LEFT_SHIFT+RIGHT_SHIFT
  4640 00001566 75EC                <1> 	jnz 	short K49		; SHIFTED TEMP OUT OF NUM STATE
  4641 00001568 EBC4                <1> K51:	jmp	short K45E		; REALLY NUM STATE
  4642                              <1> 	;
  4643                              <1> 	;-----	TEST FOR THE NEW KEYS ON WT KEYBOARDS 
  4644                              <1> K52:					; NOT A NUMPAD KEY
  4645 0000156A 3C56                <1> 	cmp	al, 86			; IS IT THE NEW WT KEY?
  4646                              <1> 	;jne	short K53		; JUMP IF NOT
  4647                              <1> 	;jmp	short K45B		; HANDLE WITH REST OF LETTER KEYS
  4648 0000156C 74AF                <1> 	je	short K45B		
  4649                              <1> 	;
  4650                              <1> 	;-----	MUST BE F11 OR F12 
  4651                              <1> K53:					; F1 - F10 COME HERE, TOO
  4652 0000156E F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE
  4653 00001571 74E1                <1> 	jz	short K49		; JUMP, LOWER CASE PSEUDO SC'S
  4654                              <1> 		; 20/02/2015 
  4655 00001573 BB[10660000]        <1> 	mov	ebx, K11		; UPPER CASE PSEUDO SCAN CODES
  4656 00001578 EB10                <1> 	jmp	short K64		; TRANSLATE SCAN
  4657                              <1> 	;
  4658                              <1> 	;-----	TRANSLATE THE CHARACTER
  4659                              <1> K56:					; TRANSLATE-CHAR
  4660 0000157A FEC8                <1> 	dec	al			; CONVERT ORIGIN
  4661 0000157C D7                  <1> 	xlat    			; CONVERT THE SCAN CODE TO ASCII
  4662 0000157D F605[6C660000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  4663 00001584 7416                <1> 	jz	short K57		; NO, GO FILL BUFFER
  4664 00001586 B4E0                <1> 	mov	ah, MC_E0		; YES, PUT SPECIAL MARKER IN AH
  4665 00001588 EB12                <1> 	jmp	short K57		; PUT IT INTO THE BUFFER	
  4666                              <1> 	;
  4667                              <1> 	;-----	TRANSLATE SCAN FOR PSEUDO SCAN CODES
  4668                              <1> K64:					; TRANSLATE-SCAN-ORGD
  4669 0000158A FEC8                <1> 	dec	al			; CONVERT ORIGIN
  4670 0000158C D7                  <1>        	xlat    	                ; CTL TABLE SCAN
  4671 0000158D 88C4                <1> 	mov	ah, al			; PUT VALUE INTO AH
  4672 0000158F B000                <1> 	mov	al, 0			; ZERO ASCII CODE
  4673 00001591 F605[6C660000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  4674 00001598 7402                <1> 	jz	short K57		; NO, GO FILL BUFFER
  4675 0000159A B0E0                <1> 	mov	al, MC_E0		; YES, PUT SPECIAL MARKER IN AL
  4676                              <1> 	;
  4677                              <1> 	;-----	PUT CHARACTER INTO BUFFER
  4678                              <1> K57:					; BUFFER_FILL
  4679 0000159C 3CFF                <1> 	cmp	al, -1			; IS THIS AN IGNORE CHAR
  4680 0000159E 7405                <1> 	je	short K59		; YES, DO NOTHING WITH IT
  4681                              <1> 	;je	K26			; YES, DO NOTHING WITH IT
  4682 000015A0 80FCFF              <1> 	cmp	ah, -1			; LOOK FOR -1 PSEUDO SCAN
  4683                              <1>         ;;jne	short K61		; NEAR_INTERRUPT_RETURN
  4684                              <1> 	;je	K26			; INTERRUPT_RETURN
  4685                              <1> 	; 12/04/2021
  4686 000015A3 7505                <1>         jne	short _K60		; NEAR_INTERRUPT_RETURN
  4687                              <1> K59:					; NEAR_INTERRUPT_RETURN
  4688 000015A5 E975FDFFFF          <1> 	jmp	K26			; INTERRUPT_RETURN
  4689                              <1> 
  4690                              <1> _K60: ; 29/01/2016
  4691 000015AA 80FC68              <1> 	cmp	ah, 68h	; ALT + F1 key
  4692 000015AD 721D                <1> 	jb	short K61
  4693 000015AF 80FC6F              <1> 	cmp	ah, 6Fh ; ALT + F8 key	
  4694 000015B2 7718                <1> 	ja	short K61
  4695                              <1> 	;
  4696 000015B4 8A1D[AE770100]      <1> 	mov	bl, [ACTIVE_PAGE]
  4697 000015BA 80C368              <1> 	add	bl, 68h
  4698 000015BD 38E3                <1> 	cmp	bl, ah
  4699 000015BF 740B                <1> 	je	short K61
  4700                              <1> 	; 24/07/2022
  4701                              <1> 	;push	ax
  4702 000015C1 50                  <1> 	push	eax
  4703 000015C2 88E0                <1> 	mov	al, ah
  4704 000015C4 2C68                <1> 	sub	al, 68h
  4705 000015C6 E827090000          <1> 	call	set_active_page
  4706 000015CB 58                  <1> 	pop	eax
  4707                              <1> 	;pop	ax
  4708                              <1> K61:					; NOT-CAPS-STATE
  4709 000015CC 8B1D[7A660000]      <1> 	mov	ebx, [BUFFER_TAIL] 	; GET THE END POINTER TO THE BUFFER
  4710 000015D2 89DE                <1> 	mov	esi, ebx		; SAVE THE VALUE
  4711 000015D4 E8B5FAFFFF          <1> 	call	_K4			; ADVANCE THE TAIL
  4712 000015D9 3B1D[76660000]      <1> 	cmp	ebx, [BUFFER_HEAD] 	; HAS THE BUFFER WRAPPED AROUND
  4713 000015DF 740E                <1> 	je	short K62		; BUFFER_FULL_BEEP
  4714 000015E1 668906              <1> 	mov	[esi], ax		; STORE THE VALUE
  4715 000015E4 891D[7A660000]      <1> 	mov	[BUFFER_TAIL], ebx 	; MOVE THE POINTER UP
  4716 000015EA E930FDFFFF          <1> 	jmp	K26
  4717                              <1> 	;;cli				; TURN OFF INTERRUPTS
  4718                              <1> 	;;mov	al, EOI			; END OF INTERRUPT COMMAND
  4719                              <1> 	;;out	INTA00, al		; SEND COMMAND TO INTERRUPT CONTROL PORT
  4720                              <1> 	;mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  4721                              <1> 	;call	SHIP_IT			; EXECUTE ENABLE
  4722                              <1> 	;mov	ax, 9102h		; MOVE IN POST CODE & TYPE
  4723                              <1> 	;int	15h			; PERFORM OTHER FUNCTION
  4724                              <1> 	;;and	byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  4725                              <1> 	;jmp	K27A			; INTERRUPT_RETURN
  4726                              <1> 	;;jmp   K27                    
  4727                              <1> 	;
  4728                              <1> 	;-----	BUFFER IS FULL SOUND THE BEEPER
  4729                              <1> K62:
  4730 000015EF B020                <1> 	mov	al, EOI			; ENABLE INTERRUPT CONTROLLER CHIP
  4731 000015F1 E620                <1> 	out	INTA00, al
  4732 000015F3 66B9A602            <1> 	mov	cx, 678			; DIVISOR FOR 1760 HZ
  4733 000015F7 B304                <1> 	mov	bl, 4			; SHORT BEEP COUNT (1/16 + 1/64 DELAY)
  4734 000015F9 E8190D0000          <1> 	call	beep			; GO TO COMMON BEEP HANDLER
  4735 000015FE E928FDFFFF          <1> 	jmp     K27			; EXIT   
  4736                              <1> 
  4737                              <1> SHIP_IT:
  4738                              <1> 	;---------------------------------------------------------------------------------
  4739                              <1> 	; SHIP_IT
  4740                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  4741                              <1> 	;	TO THE KEYBOARD CONTROLLER.
  4742                              <1> 	;---------------------------------------------------------------------------------
  4743                              <1> 	;
  4744                              <1> 	
  4745                              <1> 	;push	ax			; SAVE DATA TO SEND
  4746                              <1> 	; 12/04/2021
  4747 00001603 50                  <1> 	push	eax
  4748                              <1> 
  4749                              <1> 	;-----	WAIT FOR COMMAND TO ACCEPTED
  4750 00001604 FA                  <1> 	cli				; DISABLE INTERRUPTS TILL DATA SENT
  4751                              <1> 	; xor	ecx, ecx		; CLEAR TIMEOUT COUNTER
  4752 00001605 B900000100          <1> 	mov	ecx, 10000h			
  4753                              <1> S10:
  4754 0000160A E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD CONTROLLER STATUS
  4755 0000160C A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ITS INPUT BUFFER BUSY
  4756 0000160E E0FA                <1> 	loopnz	S10			; WAIT FOR COMMAND TO BE ACCEPTED
  4757                              <1> 
  4758                              <1> 	;pop	ax			; GET DATA TO SEND
  4759                              <1> 	; 12/04/2021
  4760 00001610 58                  <1> 	pop	eax
  4761                              <1> 
  4762 00001611 E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROLLER
  4763 00001613 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  4764 00001614 C3                  <1> 	retn				; RETURN TO CALLER
  4765                              <1> 
  4766                              <1> 	; 12/04/2021 (32 bit push/pop)
  4767                              <1> SND_DATA:
  4768                              <1> 	; ---------------------------------------------------------------------------------
  4769                              <1> 	; SND_DATA
  4770                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  4771                              <1> 	;	TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  4772                              <1> 	;	HANDLES ANY RETRIES IF REQUIRED
  4773                              <1> 	; ---------------------------------------------------------------------------------
  4774                              <1> 	;
  4775 00001615 50                  <1> 	push	eax ; push ax		; SAVE REGISTERS
  4776 00001616 53                  <1> 	push	ebx ; push bx
  4777 00001617 51                  <1> 	push	ecx
  4778 00001618 88C7                <1> 	mov	bh, al			; SAVE TRANSMITTED BYTE FOR RETRIES
  4779 0000161A B303                <1> 	mov	bl, 3			; LOAD RETRY COUNT
  4780                              <1> SD0:
  4781 0000161C FA                  <1> 	cli				; DISABLE INTERRUPTS
  4782 0000161D 8025[6B660000]CF    <1> 	and	byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS
  4783                              <1> 	;
  4784                              <1> 	;-----	WAIT FOR COMMAND TO BE ACCEPTED
  4785 00001624 B900000100          <1> 	mov	ecx, 10000h		; MAXIMUM WAIT COUNT
  4786                              <1> SD5:
  4787 00001629 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD PROCESSOR STATUS PORT
  4788 0000162B A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ANY PENDING COMMAND
  4789 0000162D E0FA                <1> 	loopnz	SD5			; WAIT FOR COMMAND TO BE ACCEPTED
  4790                              <1> 	;
  4791 0000162F 88F8                <1> 	mov	al, bh			; REESTABLISH BYTE TO TRANSMIT
  4792 00001631 E660                <1> 	out	PORT_A, al		; SEND BYTE
  4793 00001633 FB                  <1> 	sti				; ENABLE INTERRUPTS
  4794                              <1> 	;mov	cx, 01A00h		; LOAD COUNT FOR 10 ms+
  4795 00001634 B9FFFF0000          <1> 	mov	ecx, 0FFFFh
  4796                              <1> SD1:
  4797 00001639 F605[6B660000]30    <1> 	test	byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET
  4798 00001640 750F                <1> 	jnz	short SD3		; IF SET, SOMETHING RECEIVED GO PROCESS
  4799 00001642 E2F5                <1> 	loop	SD1			; OTHERWISE WAIT
  4800                              <1> SD2:
  4801 00001644 FECB                <1> 	dec	bl			; DECREMENT RETRY COUNT
  4802 00001646 75D4                <1> 	jnz	short SD0		; RETRY TRANSMISSION
  4803 00001648 800D[6B660000]80    <1> 	or	byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  4804 0000164F EB09                <1> 	jmp	short SD4		; RETRIES EXHAUSTED FORGET TRANSMISSION
  4805                              <1> SD3:
  4806 00001651 F605[6B660000]10    <1> 	test	byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  4807 00001658 74EA                <1> 	jz	short SD2		; IF NOT, GO RESEND
  4808                              <1> SD4:	
  4809 0000165A 59                  <1> 	pop	ecx			; RESTORE REGISTERS
  4810 0000165B 5B                  <1> 	pop	ebx ; pop bx
  4811 0000165C 58                  <1> 	pop	eax ; pop ax
  4812 0000165D C3                  <1> 	retn				; RETURN, GOOD TRANSMISSION
  4813                              <1> 
  4814                              <1> SND_LED:
  4815                              <1> 	; ---------------------------------------------------------------------------------
  4816                              <1> 	; SND_LED
  4817                              <1> 	;	THIS ROUTINES TURNS ON THE MODE INDICATORS.
  4818                              <1> 	;
  4819                              <1> 	;----------------------------------------------------------------------------------
  4820                              <1> 	;
  4821 0000165E FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4822 0000165F F605[6B660000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  4823 00001666 755F                <1> 	jnz 	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  4824                              <1> 	;
  4825 00001668 800D[6B660000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  4826 0000166F B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  4827 00001671 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  4828 00001673 EB11                <1> 	jmp	short SL0		; GO SEND MODE INDICATOR COMMAND
  4829                              <1> SND_LED1:
  4830 00001675 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4831 00001676 F605[6B660000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  4832 0000167D 7548                <1> 	jnz	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  4833                              <1> 	;
  4834 0000167F 800D[6B660000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  4835                              <1> SL0:
  4836 00001686 B0ED                <1> 	mov	al, LED_CMD		; LED CMD BYTE
  4837 00001688 E888FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4838 0000168D FA                  <1> 	cli
  4839 0000168E E836000000          <1> 	call	MAKE_LED		; GO FORM INDICATOR DATA BYTE
  4840 00001693 8025[6B660000]F8    <1> 	and	byte [KB_FLAG_2], 0F8h	; ~KB_LEDS ; CLEAR MODE INDICATOR BITS
  4841 0000169A 0805[6B660000]      <1> 	or	[KB_FLAG_2], al 	; SAVE PRESENT INDICATORS FOR NEXT TIME
  4842 000016A0 F605[6B660000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  4843 000016A7 750F                <1> 	jnz	short SL2		; IF SO, BYPASS SECOND BYTE TRANSMISSION
  4844                              <1> 	;
  4845 000016A9 E867FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4846 000016AE FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4847 000016AF F605[6B660000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  4848 000016B6 7408                <1> 	jz	short SL3		; IF NOT, DON'T SEND AN ENABLE COMMAND
  4849                              <1> SL2:
  4850 000016B8 B0F4                <1> 	mov	al, KB_ENABLE		; GET KEYBOARD CSA ENABLE COMMAND
  4851 000016BA E856FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  4852 000016BF FA                  <1> 	cli				; TURN OFF INTERRUPTS
  4853                              <1> SL3:
  4854 000016C0 8025[6B660000]3F    <1> 	and	byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR
  4855                              <1> SL1:					; UPDATE AND TRANSMIT ERROR FLAG
  4856 000016C7 FB                  <1> 	sti				; ENABLE INTERRUPTS
  4857 000016C8 C3                  <1> 	retn				; RETURN TO CALLER
  4858                              <1> 
  4859                              <1> MAKE_LED:
  4860                              <1> 	;---------------------------------------------------------------------------------
  4861                              <1> 	; MAKE_LED
  4862                              <1> 	;	THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF
  4863                              <1> 	;	THE MODE INDICATORS.
  4864                              <1> 	;---------------------------------------------------------------------------------
  4865                              <1> 	;
  4866                              <1> 	;push 	cx			; SAVE CX
  4867 000016C9 A0[69660000]        <1> 	mov	al, [KB_FLAG]		; GET CAPS & NUM LOCK INDICATORS
  4868 000016CE 2470                <1> 	and	al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS
  4869                              <1> 	;mov	cl, 4			; SHIFT COUNT
  4870                              <1> 	;rol	al, cl			; SHIFT BITS OVER TO TURN ON INDICATORS
  4871 000016D0 C0C004              <1> 	rol	al, 4 ; 20/02/2015
  4872 000016D3 2407                <1> 	and	al, 07h			; MAKE SURE ONLY MODE BITS ON
  4873                              <1> 	;pop	cx
  4874 000016D5 C3                  <1> 	retn				; RETURN TO CALLER
  4875                              <1> 
  4876                              <1> ; % include 'kybdata.s'   ; KEYBOARD DATA
  4877                              <1> 
  4878                              <1> 
  4879                              <1> ; /// End Of KEYBOARD FUNCTIONS ///
  4880                                  
  4881                                  %include 'video.s' ; 07/03/2015
  4882                              <1> ; ****************************************************************************
  4883                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - video.s
  4884                              <1> ; ----------------------------------------------------------------------------
  4885                              <1> ; Last Update: 07/08/2022 (Previous: 17/04/2021 - Kernel v2.0.4)
  4886                              <1> ; ----------------------------------------------------------------------------
  4887                              <1> ; Beginning: 16/01/2016
  4888                              <1> ; ----------------------------------------------------------------------------
  4889                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
  4890                              <1> ; ----------------------------------------------------------------------------
  4891                              <1> ; Turkish Rational DOS
  4892                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
  4893                              <1> ;
  4894                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
  4895                              <1> ; video.inc (13/08/2015)
  4896                              <1> ;
  4897                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
  4898                              <1> ; ****************************************************************************
  4899                              <1> 
  4900                              <1> ; Retro UNIX 386 v1 Kernel - VIDEO.INC
  4901                              <1> ; Last Modification: 13/08/2015
  4902                              <1> ;		  (Video Data is in 'VIDATA.INC')
  4903                              <1> ;
  4904                              <1> ; ///////// VIDEO (CGA) FUNCTIONS ///////////////
  4905                              <1> 
  4906                              <1> ; 16/01/2016 (32 bit modifications, TRDOS386 - TRDOS v2.0, video.s)
  4907                              <1> ; INT 31H (TRDOS 386) = INT 10H (IBM PC/AT REAL MODE)
  4908                              <1> 
  4909                              <1> ; IBM PC-AT BIOS Source Code
  4910                              <1> ; TITLE VIDEO1 --- 06/10/85 VIDEO DISPLAY BIOS
  4911                              <1> 
  4912                              <1> _int10h:
  4913                              <1> 	; 23/03/2016
  4914                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  4915 000016D6 9C                  <1> 	pushfd
  4916 000016D7 0E                  <1> 	push	cs
  4917 000016D8 E851000000          <1> 	call	VIDEO_IO_1
  4918 000016DD C3                  <1> 	retn
  4919                              <1> 
  4920                              <1> ;--- INT 10 H -------------------------------------------------------------------
  4921                              <1> ; VIDEO_IO									:
  4922                              <1> ;	THESE ROUTINES PROVIDE THE CRT DISPLAY INTERFACE			:
  4923                              <1> ;	THE FOLLOWING FUNCTIONS ARE PROVIDED:					:
  4924                              <1> ;										:
  4925                              <1> ;    (AH)= 00H	SET MODE (AL) CONTAINS MODE VALUE				:
  4926                              <1> ;		(AL) = 00H  40X25 BW MODE (POWER ON DEFAULT)			:
  4927                              <1> ;		(AL) = 01H  40X25 COLOR						:
  4928                              <1> ;		(AL) = 02H  80X25 BW						:
  4929                              <1> ;		(AL) = 03H  80X25 COLOR						:
  4930                              <1> ;		              GRAPHICS MODES					:
  4931                              <1> ;		(AL) = 04H  320X200 COLOR					:
  4932                              <1> ;		(AL) = 05H  320X200 BW MODE					:
  4933                              <1> ;		(AL) = 06H  640X200 BW MODE					:
  4934                              <1> ;		(AL) = 07H   80X25 MONOCHROME (USED INTERNAL TO VIDEO ONLY)	:
  4935                              <1> ;		*** NOTES -BW MODES OPERATE SAME AS COLOR MODES, BUT COLOR	:
  4936                              <1> ;		           BURST IS NOT ENABLED					:
  4937                              <1> ;		          -CURSOR IS NOT DISPLAYED IN GRAPHICS MODE		:
  4938                              <1> ;    (AH)= 01H	SET CURSOR TYPE							:
  4939                              <1> ;		(CH) = BITS 4-0 = START LINE FOR CURSOR				:
  4940                              <1> ;		       ** HARDWARE WILL ALWAYS CAUSE BLINK			:
  4941                              <1> ;		       ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING	:
  4942                              <1> ;		          OR NO CURSOR AT ALL					:
  4943                              <1> ;		(CL) = BITS 4-0 = END LINE FOR CURSOR				:
  4944                              <1> ;    (AH)= 02H	SET CURSOR POSITION						:
  4945                              <1> ;		(DH,DL) = ROW,COLUMN  (00H,00H) IS UPPER LEFT			:
  4946                              <1> ;		(BH) = A PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
  4947                              <1> ;    (AH)= 03H	READ CURSOR POSITION						:
  4948                              <1> ;		(BH) = PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
  4949                              <1> ;		ON EXIT (DH,DL) = ROW,COLUMN OF CURRENT CURSOR			:
  4950                              <1> ;		        (CH,CL) = CURSOR MODE CURRENTLY SET			:
  4951                              <1> ;    (AH)= 04H	READ LIGHT PEN POSITION						:
  4952                              <1> ;		ON EXIT:							:
  4953                              <1> ;		(AH) = 00H -- LIGHT PEN SWITCH NOT DOWN/NOT TRIGGERED		:
  4954                              <1> ;		(AH) = 01H -- VALID LIGHT PEN VALUE IN REGISTERS		:
  4955                              <1> ;		        (DH,DL) = ROW,COLUMN OF CHARACTER LP POSITION		:
  4956                              <1> ;		        (CH) = RASTER LINE (0-199)				:
  4957                              <1> ;		        (BX) = PIXEL COLUMN (0-319,639)				:
  4958                              <1> ;    (AH)= 05H	SELECT ACTIVE DISPLAY PAGE (VALID ONLY FOR ALPHA MODES)		:
  4959                              <1> ;		(AL) = NEW PAGE VALUE (0-7 FOR MODES 0&1, 0-3 FOR MODES 2&3)	:
  4960                              <1> ;    (AH)= 06H	SCROLL ACTIVE PAGE UP						:
  4961                              <1> ;		(AL) = NUMBER OF LINES. ( LINES BLANKED AT BOTTOM OF WINDOW )	:
  4962                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
  4963                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
  4964                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
  4965                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
  4966                              <1> ;    (AH)= 07H	SCROLL ACTIVE PAGE DOWN						:
  4967                              <1> ;		(AL) = NUMBER OF LINES, INPUT LINES BLANKED AT TOP OF WINDOW	:
  4968                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
  4969                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
  4970                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
  4971                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
  4972                              <1> ;										:
  4973                              <1> ;   CHARACTER HANDLING ROUTINES							:
  4974                              <1> ;										:
  4975                              <1> ;    (AH)= 08H	READ ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
  4976                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  4977                              <1> ;		ON EXIT:							:
  4978                              <1> ;		(AL) = CHAR READ						:
  4979                              <1> ;		(AH) = ATTRIBUTE OF CHARACTER READ (ALPHA MODES ONLY)		:
  4980                              <1> ;    (AH)= 09H	WRITE ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
  4981                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  4982                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
  4983                              <1> ;		(AL) = CHAR TO WRITE						:
  4984                              <1> ;		(BL) = ATTRIBUTE OF CHARACTER (ALPHA)/COLOR OF CHAR (GRAPHICS)	:
  4985                              <1> ;		         SEE NOTE ON WRITE DOT FOR BIT 7 OF BL = 1.		:
  4986                              <1> ;    (AH) = 0AH	WRITE CHARACTER ONLY AT CURRENT CURSOR POSITION			:
  4987                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
  4988                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
  4989                              <1> ;		(AL) = CHAR TO WRITE						:
  4990                              <1> ;		       NOTE: USE FUNCTION (AH)= 09H IN GRAPHICS MODES		:
  4991                              <1> ;	FOR READ/WRITE CHARACTER INTERFACE WHILE IN GRAPHICS MODE, THE		:
  4992                              <1> ;		CHARACTERS ARE FORMED FROM A CHARACTER GENERATOR IMAGE		:
  4993                              <1> ;		MAINTAINED IN THE SYSTEM ROM. ONLY THE 1ST 128 CHARS		:
  4994                              <1> ;		ARE CONTAINED THERE. TO READ/WRITE THE SECOND 128 CHARS,	:
  4995                              <1> ;		THE USER MUST INITIALIZE THE POINTER AT INTERRUPT 1FH		:
  4996                              <1> ;		(LOCATION 0007CH) TO POINT TO THE 1K BYTE TABLE CONTAINING	:
  4997                              <1> ;		THE CODE POINTS FOR THE SECOND 128 CHARS (128-255).		:
  4998                              <1> ;	FOR WRITE CHARACTER INTERFACE IN GRAPHICS MODE, THE REPLICATION FACTOR	:
  4999                              <1> ;		CONTAINED IN (CX) ON ENTRY WILL PRODUCE VALID RESULTS ONLY	:
  5000                              <1> ;		FOR CHARACTERS CONTAINED ON THE SAME ROW. CONTINUATION TO	:
  5001                              <1> ;		SUCCEEDING LINES WILL NOT PRODUCE CORRECTLY.			:
  5002                              <1> ;										:
  5003                              <1> ;    GRAPHICS INTERFACE								:
  5004                              <1> ;    (AH)= 0BH	SET COLOR PALETTE						:
  5005                              <1> ;		(BH) = PALETTE COLOR ID BEING SET (0-127)			:
  5006                              <1> ;		(BL) = COLOR VALUE TO BE USED WITH THAT COLOR ID		:
  5007                              <1> ;		       NOTE: FOR THE CURRENT COLOR CARD, THIS ENTRY POINT HAS	:
  5008                              <1> ;		               MEANING ONLY FOR 320X200 GRAPHICS.		:
  5009                              <1> ;		       COLOR ID = 0 SELECTS THE BACKGROUND COLOR (0-15)		:
  5010                              <1> ;		       COLOR ID = 1 SELECTS THE PALETTE TO BE USED:		:
  5011                              <1> ;		               0 = GREEN(1)/RED(2)/YELLOW(3)			:
  5012                              <1> ;		               1 = CYAN(1)/MAGENTA(2)/WHITE(3)			:
  5013                              <1> ;		       IN 40X25 OR 80X25 ALPHA MODES, THE VALUE SET FOR 	:
  5014                              <1> ;		               PALETTE COLOR 0 INDICATES THE BORDER COLOR	:
  5015                              <1> ;		               TO BE USED (VALUES 0-31, WHERE 16-31 SELECT	:
  5016                              <1> ;		               THE HIGH INTENSITY BACKGROUND SET.		:
  5017                              <1> ;    (AH)= 0CH	WRITE DOT							:
  5018                              <1> ;		(DX) = ROW NUMBER						:
  5019                              <1> ;		(CX) = COLUMN NUMBER						:
  5020                              <1> ;		(AL) = COLOR VALUE						:
  5021                              <1> ;		        IF BIT 7 OF AL = 1, THEN THE COLOR VALUE IS EXCLUSIVE	:
  5022                              <1> ;		        ORed WITH THE CURRENT CONTENTS OF THE DOT		:
  5023                              <1> ;    (AH)= ODH	READ DOT							:
  5024                              <1> ;		(DX) = ROW NUMBER						:
  5025                              <1> ;		(CX) = COLUMN NUMBER						:
  5026                              <1> ;		(AL) = RETURNS THE DOT READ					:
  5027                              <1> ;										:
  5028                              <1> ;    ASCII TELETYPE ROUTINE FOR OUTPUT						:
  5029                              <1> ;										:
  5030                              <1> ;    (AH)= 0EH	WRITE TELETYPE TO ACTIVE PAGE					:
  5031                              <1> ;		(AL) = CHAR TO WRITE						:
  5032                              <1> ;		(BL) = FOREGROUND COLOR IN GRAPHICS MODE			:
  5033                              <1> ;		NOTE -- SCREEN WIDTH IS CONTROLLED BY PREVIOUS MODE SET		:
  5034                              <1> ;    (AH)= 0FH	CURRENT VIDEO STATE						:
  5035                              <1> ;		RETURNS THE CURRENT VIDEO STATE					:
  5036                              <1> ;		(AL) = MODE CURRENTLY SET ( SEE (AH)=00H FOR EXPLANATION)	:
  5037                              <1> ;		(AH) = NUMBER OR CHARACTER COLUMNS ON SCREEN			:
  5038                              <1> ;		(BH) = CURRENT ACTIVE DISPLAY PAGE				:
  5039                              <1> ;    (AH)= 10H	RESERVED							:
  5040                              <1> ;    (AH)= 11H	RESERVED							:
  5041                              <1> ;    (AH)= 12H	RESERVED							:
  5042                              <1> ;    (AH)= 13H	WRITE STRING							:
  5043                              <1> ;			ES:BP  -  POINTER T0 STRING TO BE WRITTEN		:
  5044                              <1> ;			CX     -  LENGTH OF CHARACTER STRING TO WRITTEN		:
  5045                              <1> ;			DX     -  CURSOR POSITION FOR STRING TO BE WRITTEN	:
  5046                              <1> ;			BH     -  PAGE NUMBER					:
  5047                              <1> ;		(AL)= 00H	WRITE CHARACTER STRING				:
  5048                              <1> ;			BL     -  ATTRIBUTE					:
  5049                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
  5050                              <1> ;			CURSOR NOT MOVED					:
  5051                              <1> ;		(AL)= 01H	WRITE CHARACTER STRING AND MOVE CURSOR		:
  5052                              <1> ;			BL     -  ATTRIBUTE					:
  5053                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
  5054                              <1> ;			CURSOR MOVED						:
  5055                              <1> ;		(AL)= 02H	WRITE CHARACTER AND ATTRIBUTE STRING		:
  5056                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
  5057                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
  5058                              <1> ;			CURSOR IS NOT MOVED					:
  5059                              <1> ;		(AL)= 03H WRITE CHARACTER AND ATTRIBUTE STRING AND MOVE CURSOR	:
  5060                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
  5061                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
  5062                              <1> ;			CURSOR IS MOVED						:
  5063                              <1> ;		 NOTE:  CARRIAGE RETURN, LINE FEED, BACKSPACE, AND BELL ARE	:
  5064                              <1> ;		        TREATED AS COMMANDS RATHER THAN PRINTABLE CHARACTERS.	:
  5065                              <1> ;										:
  5066                              <1> ;	BX,CX,DX,SI,DI,BP,SP,DS,ES,SS PRESERVED DURING CALLS EXCEPT FOR		:
  5067                              <1> ;	BX,CX,DX RETURN VALUES ON FUNCTIONS 03H,04H,0DH AND 0FH. ON ALL CALLS	:
  5068                              <1> ;	AX IS MODIFIED.								:
  5069                              <1> ;--------------------------------------------------------------------------------
  5070                              <1> 
  5071 000016DE [861A0000]          <1> M1:	dd	SET_MODE	; TABLE OF ROUTINES WITHIN VIDEO I/O
  5072 000016E2 [3C1E0000]          <1> 	dd	SET_CTYPE
  5073 000016E6 [6A1E0000]          <1> 	dd	SET_CPOS
  5074 000016EA [8E1E0000]          <1> 	dd	READ_CURSOR
  5075                              <1> 	;dd	VIDEO_RETURN	; READ_LPEN
  5076 000016EE [841A0000]          <1> 	dd	set_mode_ncm	; Set mode without clearing video memory
  5077 000016F2 [D41E0000]          <1> 	dd	ACT_DISP_PAGE
  5078 000016F6 [5E1F0000]          <1> 	dd	SCROLL_UP
  5079 000016FA [75200000]          <1> 	dd	SCROLL_DOWN
  5080 000016FE [F4200000]          <1> 	dd	READ_AC_CURRENT
  5081 00001702 [51210000]          <1> 	dd	WRITE_AC_CURRENT
  5082 00001706 [77210000]          <1> 	dd	WRITE_C_CURRENT
  5083 0000170A [7F2A0000]          <1> 	dd	SET_COLOR
  5084 0000170E [E72A0000]          <1> 	dd	WRITE_DOT
  5085 00001712 [B62A0000]          <1> 	dd	READ_DOT
  5086 00001716 [01220000]          <1> 	dd	WRITE_TTY
  5087 0000171A [6C1A0000]          <1> 	dd	VIDEO_STATE
  5088 0000171E [B4350000]          <1> 	dd	vga_pal_funcs	; 10/08/2016 (TRDOS 386)
  5089 00001722 [CC2F0000]          <1> 	dd	font_setup	; 10/07/2016 (TRDOS 386)
  5090 00001726 [BB1A0000]          <1> 	dd	VIDEO_RETURN	; RESERVED
  5091 0000172A [77230000]          <1> 	dd	WRITE_STRING	; 23/06/2016 (TRDOS 386)
  5092                              <1> M1L	EQU	$ - M1
  5093                              <1> 
  5094                              <1> ; 02/08/2022 - TRDOS 386 v2.0.5
  5095                              <1> ; 06/12/2020
  5096                              <1> ; 05/12/2020
  5097                              <1> ; 03/12/2020
  5098                              <1> ; 27/11/2020 - TRDOS 386 v2.0.3
  5099                              <1> ; 14/01/2017
  5100                              <1> ; 02/01/2017
  5101                              <1> ; 04/07/2016
  5102                              <1> ; 12/05/2016
  5103                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  5104                              <1> int31h:  ; Video BIOS
  5105                              <1> 
  5106                              <1> ; BH = Video page number
  5107                              <1> ; BL = Color/Attribute
  5108                              <1> ; AH = Function number
  5109                              <1> ; AL = Character
  5110                              <1> 
  5111                              <1> VIDEO_IO_1:
  5112                              <1> 	;sti				; INTERRUPTS BACK ON
  5113 0000172E FC                  <1> 	cld				; SET DIRECTION FORWARD
  5114                              <1> 	
  5115                              <1> 	;cmp	ah, M1L/4		; TEST FOR WITHIN TABLE RANGE
  5116                              <1> 	;jnb	short M4		; BRANCH TO EXIT IF NOT A VALID COMMAND
  5117                              <1> 
  5118                              <1> 	; 26/11/2020
  5119 0000172F 80FC14              <1> 	cmp	ah, M1L/4
  5120 00001732 7205                <1> 	jb	short VGA_func
  5121                              <1> 
  5122 00001734 80FC4F              <1> 	cmp	ah, 4Fh
  5123 00001737 7532                <1> 	jne	short M4 ; invalid !
  5124                              <1> 
  5125                              <1> VGA_func: ; 26/11/2020
  5126 00001739 06                  <1> 	push	es ; *
  5127 0000173A 1E                  <1> 	push	ds ; **			; SAVE WORK AND PARAMETER REGISTERS
  5128                              <1> 
  5129                              <1> 	; 26/11/2020
  5130 0000173B 50                  <1> 	push	eax ; -
  5131                              <1> 	
  5132 0000173C 66B81000            <1> 	mov	ax, KDATA 		; POINT DS: TO DATA SEGMENT
  5133 00001740 8ED8                <1> 	mov	ds, ax
  5134 00001742 8EC0                <1> 	mov	es, ax
  5135                              <1> 
  5136                              <1> 	; 26/11/2020
  5137 00001744 58                  <1> 	pop	eax ; +
  5138                              <1> 	;
  5139 00001745 FB                  <1> 	sti
  5140 00001746 80FC4F              <1> 	cmp	ah, 4Fh
  5141 00001749 747A                <1> 	je	short VBE_func
  5142                              <1> 
  5143                              <1> 	; 04/12/2020
  5144 0000174B A3[04840100]        <1> 	mov	[video_eax], eax
  5145                              <1> 
  5146                              <1> 	; 21/12/2020
  5147 00001750 803D[9E660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh	; Current mode is a VESA VBE mode ?
  5148 00001757 7213                <1> 	jb	short VGA_func_std
  5149                              <1> 
  5150 00001759 08E4                <1> 	or	ah, ah			; set mode ?
  5151 0000175B 750F                <1> 	jnz	short VGA_func_std	; no
  5152                              <1> 
  5153 0000175D 803D[3F090000]03    <1> 	cmp	byte [vbe3], 3		; (real) VESA VBE 3 video bios ?
  5154 00001764 7506                <1> 	jne	short VGA_func_std	; no
  5155                              <1> 
  5156 00001766 E984010000          <1> 	jmp	vesa_vbe3_pmi
  5157                              <1> 
  5158                              <1> 	; 21/12/2020
  5159                              <1> M4:					; COMMAND NOT VALID
  5160 0000176B CF                  <1> 	iretd				; DO NOTHING IF NOT IN VALID RANGE
  5161                              <1> 
  5162                              <1> VGA_func_std:
  5163                              <1> 	; 06/12/2020
  5164                              <1> 	; 03/12/2020
  5165 0000176C 80FC0F              <1> 	cmp	ah, 0Fh
  5166 0000176F 773D                <1> 	ja	short VGA_funcs_0	; only CGA funcs will be handled by	
  5167                              <1> 	; 06/12/2020			; vga bios firmware
  5168                              <1> 	; 03/12/2020			
  5169                              <1> 	;test	ah, 7Fh ; set mode ?
  5170                              <1> 	;;or	ah, ah			; only 'set mode' will be handled by
  5171                              <1> 	;jnz	short VGA_funcs_0	; vga bios firmware	
  5172                              <1> 	;jz	short vbe_pmi32_0
  5173                              <1> 
  5174                              <1> 	; 28/11/2020
  5175 00001771 803D[D00F0300]00    <1> 	cmp	byte [pmi32], 0		; 32 bit protected mode interface for
  5176 00001778 7634                <1> 	jna	short VGA_funcs_0	; video hardware's vga bios firmware
  5177                              <1> 					; ([pmi32] > 0 if it is activated)
  5178                              <1> 					; note:
  5179                              <1> 					; [vbe3] = 3 is required to activate
  5180                              <1> 	; 07/12/2020
  5181 0000177A 20E4                <1> 	and	ah, ah ; is this set mode ?
  5182 0000177C 7413                <1> 	jz	short vbe_pmi32_2 ; yes
  5183                              <1> 
  5184 0000177E 80FC04              <1> 	cmp	ah, 04h	 ; set mode ('no clear memory' option)
  5185 00001781 742B                <1> 	je	short VGA_funcs_0
  5186                              <1> 
  5187                              <1> 	; 07/12/2020
  5188 00001783 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
  5189 0000178A 7622                <1> 	jna	short VGA_funcs_0  ; no	
  5190                              <1> 
  5191                              <1> 	; when mode 3 is active, 
  5192                              <1> 	; video bios functions are not redirected
  5193                              <1> 	; to VESA VBE3 PMI except 'set mode' function
  5194                              <1> 
  5195                              <1> vbe_pmi32_0:
  5196                              <1> 	; 06/12/2020
  5197                              <1> 	;or	ah, ah
  5198                              <1> 	;jnz	short vbe_pmi32_2
  5199                              <1> 	; ah = 0 ; 'set mode'
  5200                              <1> 	;cmp	al, 3 ; 80x25 text mode, 16 colors, default mode for MainProg
  5201                              <1> 	;jne	short vbe_pmi32_1
  5202                              <1> 	;cmp	byte [CRT_MODE], 3 ; If current video mode <> 3 and requested
  5203                              <1> 	;			; video mode is 3, use internal 'set mode';
  5204                              <1> 	;			; otherwise, use vesa vbe 3 bios's 'set mode'.
  5205                              <1> 	;jne	short VGA_funcs_0
  5206                              <1> vbe_pmi32_1:
  5207 0000178C E95E010000          <1> 	jmp	vesa_vbe3_pmi
  5208                              <1> ;vbe_pmi32_2:
  5209                              <1> 	;cmp	ah, 04h ; set mode (no clear mem option)
  5210                              <1> 	;jne	short vbe_pmi32_1
  5211                              <1> 
  5212                              <1> vbe_pmi32_2:
  5213                              <1> 	; 07/12/2020
  5214 00001791 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
  5215 00001798 77F2                <1> 	ja	short vbe_pmi32_1  ; yes
  5216                              <1> 
  5217 0000179A 3C07                <1> 	cmp	al, 7	; requested mode > 7 ?
  5218 0000179C 7610                <1> 	jna	short VGA_funcs_0  ; no (CGA)
  5219                              <1> 
  5220 0000179E 3C13                <1> 	cmp	al, 13h
  5221 000017A0 76EA                <1> 	jna	short vbe_pmi32_1
  5222                              <1> 
  5223 000017A2 A880                <1> 	test	al, 80h
  5224 000017A4 7408                <1> 	jz	short VGA_funcs_0  ; unknown or special
  5225                              <1> 
  5226 000017A6 3C87                <1> 	cmp	al, 87h	; requested mode > 7 ? 
  5227                              <1> 			; (with no clear mem ops)
  5228 000017A8 7604                <1> 	jna	short VGA_funcs_0  ; no (CGA)
  5229                              <1> 
  5230 000017AA 3C93                <1> 	cmp	al, 93h
  5231 000017AC 76DE                <1> 	jna	short vbe_pmi32_1
  5232                              <1> 
  5233                              <1> 	; > 13h video modes are unknown or special
  5234                              <1>  	; they must be handled by kernel	
  5235                              <1> 
  5236                              <1> 	; CGA video modes will be handled by kernel
  5237                              <1> 
  5238                              <1> VGA_funcs_0:
  5239 000017AE 52                  <1> 	push	edx ; ***
  5240 000017AF 51                  <1> 	push	ecx ; ****
  5241 000017B0 53                  <1> 	push	ebx ; *****
  5242 000017B1 56                  <1> 	push	esi ; ******
  5243 000017B2 57                  <1> 	push	edi ; *******
  5244 000017B3 55                  <1> 	push	ebp ; ********
  5245                              <1> 
  5246                              <1> 	;mov	[video_eax], eax ; 12/05/2016 
  5247 000017B4 BF00800B00          <1> 	mov	edi, 0B8000h		; GET offset FOR COLOR CARD
  5248                              <1> 
  5249                              <1> 	; 23/03/2016
  5250 000017B9 C0E402              <1> 	shl	ah, 2  ; dword		; TIMES 2 FOR WORD TABLE LOOKUP
  5251 000017BC 0FB6F4              <1> 	movzx	esi, ah			; MOVE OFFSET INTO LOOK UP REGISTER (SI)
  5252                              <1> 	;mov	ah, [CRT_MODE]		; MOVE CURRENT MODE INTO (AH) REGISTER
  5253                              <1> 
  5254                              <1> 	;;15/01/2017
  5255                              <1> 	; 14/01/2017
  5256                              <1> 	; 02/01/2017
  5257                              <1> 	;;mov	byte [intflg], 31h  ; video interrupt
  5258                              <1> 	;sti ; 26/11/2020
  5259                              <1> 	;
  5260                              <1> 
  5261 000017BF FFA6[DE160000]      <1> 	jmp	dword [esi+M1]		; GO TO SELECTED FUNCTION
  5262                              <1> 
  5263                              <1> VBE_func:
  5264                              <1> 	; 26/11/2020
  5265                              <1> 	;sti
  5266 000017C5 55                  <1> 	push	ebp ; *** ; 27/11/2020	
  5267 000017C6 56                  <1> 	push	esi ; **** 
  5268                              <1> 	
  5269                              <1> 	; Note:
  5270                              <1> 	; ebx, ecx, edx, edi, ebp registers
  5271                              <1> 	; must be saved by VBE functions and
  5272                              <1> 	; eax register must be set
  5273                              <1> 	; (according to VBE 3 standard)
  5274                              <1> 	; before return from this interrupt
  5275                              <1> 	; (every function must restore and set
  5276                              <1> 	; registers except esp, esi, es, ds)
  5277                              <1> 
  5278 000017C7 803D[3F090000]02    <1> 	cmp	byte [vbe3], 2
  5279 000017CE 7740                <1> 	ja	short VESA_VBE3_PMI_CALL ; VBE3 video bios ('PMID')
  5280                              <1> 	;je	short VBE_func_0  ; Bochs/Qemu/VirtualBox emulator
  5281 000017D0 7268                <1> 	jb	short VBE_unknown ; invalid ([vbe3] = 0)
  5282                              <1> 
  5283                              <1> 	;jmp	VESA_VBE3_PMI_CALL
  5284                              <1> 
  5285                              <1> VBE_func_0:	
  5286                              <1> 	; Bochs/Plex86 VGAbios VBE extension
  5287                              <1> 	; (TRDOS 386 v2.0.3 can use VBE graphics modes on emulators)
  5288                              <1> 	; BOCHS/QEMU/VIRTUALBOX
  5289                              <1>  
  5290 000017D2 8A25[40090000]      <1> 	mov	ah, [vbe2bios]
  5291 000017D8 80FCC0              <1> 	cmp	ah, 0C0h		
  5292 000017DB 725D                <1> 	jb	short VBE_unknown 	
  5293 000017DD 80FCC5              <1> 	cmp	ah, 0C5h
  5294 000017E0 7758                <1> 	ja	short VBE_unknown
  5295                              <1> 
  5296                              <1> 	; TRDOS 386 is running on BOCHS or QEMU
  5297 000017E2 B44F                <1> 	mov	ah, 4Fh
  5298                              <1> VBE_func_1:
  5299 000017E4 0FB6F0              <1> 	movzx	esi, al ; VESA VBE function number
  5300                              <1> 	;shl	si, 2 ; dword
  5301                              <1> 	; 02/08/2022
  5302 000017E7 C1E602              <1> 	shl	esi, 2
  5303 000017EA 6683FE14            <1> 	cmp	si, N1L
  5304 000017EE 734A                <1> 	jnb	short VBE_unknown
  5305                              <1> 	;sti
  5306                              <1> 	
  5307 000017F0 FF96[FC170000]      <1> 	call	dword [esi+N1] ; call VBE function
  5308                              <1> 		
  5309                              <1> 	;jmp	short VBE_bios_return
  5310                              <1> 
  5311                              <1> VBE_bios_return:
  5312 000017F6 FA                  <1> 	cli
  5313 000017F7 5E                  <1> 	pop	esi ; ****
  5314 000017F8 5D                  <1> 	pop	ebp ; *** ; 27/11/2020
  5315 000017F9 07                  <1> 	pop	es  ; **
  5316 000017FA 1F                  <1> 	pop	ds  ; *
  5317 000017FB CF                  <1> 	iretd
  5318                              <1> 
  5319                              <1> 	; 26/11/2020
  5320                              <1> N1:
  5321 000017FC [5D180000]          <1> 	dd	vbe_biosfn_return_ctrl_info
  5322 00001800 [6C380000]          <1> 	dd	vbe_biosfn_return_mode_info
  5323 00001804 [26390000]          <1> 	dd	vbe_biosfn_set_mode
  5324 00001808 [F6390000]          <1> 	dd	vbe_biosfn_return_current_mode
  5325 0000180C [153A0000]          <1> 	dd	vbe_biosfn_save_restore_state
  5326                              <1> 	;dd	vbe_biosfn_display_window_ctrl
  5327                              <1> 	;dd	vbe_biosfn_set_get_log_scanline
  5328                              <1> 	;dd	vbe_biosfn_set_get_disp_start
  5329                              <1> 	;dd	vbe_biosfn_set_get_dac_pal_frm
  5330                              <1> 	;dd	vbe_biosfn_set_get_palette_data
  5331                              <1> 	
  5332                              <1> N1L	EQU	$ - N1
  5333                              <1> 
  5334                              <1> 
  5335                              <1> VESA_VBE3_PMI_CALL: ; VESA VBE video bios (firmware) functions
  5336                              <1> 		    ; by using VESA VBE3 Protected Mode Interface
  5337                              <1> 	
  5338                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
  5339                              <1> 	; 29/11/2020
  5340                              <1> 	; 26/11/2020 - TRDOS 386 v2.0.3 video.s
  5341                              <1> 
  5342                              <1> 	; We are here because..
  5343                              <1> 	; 'PMID' has been verified by TRDOS 386 v2.0.3 kernel.
  5344                              <1> 	; (Otherwise bochs/plex86 compatible VBE functions and
  5345                              <1> 	;  modes would be used on BOCHS/QEMU/VIRTUALBOX emulators
  5346                              <1> 	;  or only standard/old VGA graphics modes would be used.)
  5347                              <1> 
  5348                              <1> 	; (TRDOS 386 v2.0.3 can use VESA VBE graphics modes if
  5349                              <1> 	;  the video bios is full compatible with VBE3 standard) 
  5350                              <1> 
  5351                              <1> 	; 29/11/2020
  5352                              <1> 
  5353 00001810 0FB6F0              <1> 	movzx	esi, al ; VESA VBE 3 function number
  5354                              <1> 	;shl	si, 2 ; dword
  5355                              <1> 	; 02/08/2022
  5356 00001813 C1E602              <1> 	shl	esi, 2
  5357 00001816 6683FE14            <1> 	cmp	si, P1L
  5358 0000181A 731E                <1> 	jnb	short VBE_unknown
  5359                              <1> 	;sti
  5360                              <1> 
  5361 0000181C 57                  <1> 	push	edi ; *****
  5362                              <1> 		
  5363 0000181D FF96[26180000]      <1> 	call	dword [esi+P1] ; call VBE 3 function
  5364                              <1> 
  5365 00001823 5F                  <1> 	pop	edi ; *****
  5366                              <1> 		
  5367 00001824 EBD0                <1> 	jmp	short VBE_bios_return
  5368                              <1> 
  5369                              <1> P1:
  5370 00001826 [40180000]          <1> 	dd	vbe3_pmfn_return_ctrl_info
  5371 0000182A [63180000]          <1> 	dd	vbe3_pmfn_return_mode_info
  5372 0000182E [9F180000]          <1> 	dd	vbe3_pmfn_set_mode
  5373 00001832 [9A180000]          <1> 	dd	vbe3_pmfn_return_current_mode
  5374 00001836 [90190000]          <1> 	dd	vbe3_pmfn_save_restore_state
  5375                              <1> 	;dd	vbe3_pmfn_display_window_ctrl
  5376                              <1> 	;dd	vbe3_pmfn_set_get_log_scanline
  5377                              <1> 	;dd	vbe3_pmfn_set_get_disp_start
  5378                              <1> 	;dd	vbe3_pmfn_set_get_dac_pal_frm
  5379                              <1> 	;dd	vbe3_pmfn_set_get_palette_data
  5380                              <1> 	;dd	vbe3_pmfn_return_pmi ; invalid for TRDOS 386 v2
  5381                              <1> 	;dd	vbe3_pmfn_set_get_pixel_clock
  5382                              <1> 	
  5383                              <1> P1L	EQU	$ - P1
  5384                              <1> 
  5385                              <1> ;	; 29/11/2020
  5386                              <1> ;	mov	edi, VBE3MODEINFOBLOCK >> 4 ; / 16
  5387                              <1> ;	
  5388                              <1> ;	cmp	al, 04h
  5389                              <1> ;	jb	short vbe3_pm_f ; function: 4F00h to 4F03h
  5390                              <1> ;	ja	short vbe3_pmi_f5B ; function: 4F05h to 4F0Bh
  5391                              <1> ;
  5392                              <1> ;	; check buffer length (must be <= 2048 bytes)
  5393                              <1> ;
  5394                              <1> ;	and	dl, dl ; 0
  5395                              <1> ;	jz	short vbe3_pm_f 
  5396                              <1> ;		       ; Return Save/Restore State buffer size
  5397                              <1> ;
  5398                              <1> ;	push	ebx  ; buffer address
  5399                              <1> ;	push	edx  ; function: save (01h) or restore (02h)
  5400                              <1> ;	call	
  5401                              <1> ;
  5402                              <1> ;vbe3_pm_f03:
  5403                              <1> ;	cmp	al, 2
  5404                              <1> ;	ja	short vbe3_pm_f ; function 4F03h
  5405                              <1> ;	jb	short vbe3_pm_f1
  5406                              <1> ;
  5407                              <1> ;
  5408                              <1> ;vbe3_pm_f1:
  5409                              <1> ;	
  5410                              <1> ;
  5411                              <1> ;vbe3_pmi_f5B:
  5412                              <1> ;	cmp	al, 09h
  5413                              <1> ;	jna	short vbe3_pm_f ; funcs 05h to 09h are usable 
  5414                              <1> ;	
  5415                              <1> ;	cmp	al, 0Bh ; Get/Set pixel clock, last function
  5416                              <1> ;	jne	short VBE_unknown 
  5417                              <1> ;			; (do not use 'uncertain' functions
  5418                              <1> ;			; because of system-user buff transfers)
  5419                              <1> ;vbe3_pm_f:
  5420                              <1> ;	mov	byte [vbe3_pm_fn], al	; set
  5421                              <1> ;	; prepare 16 bit pm segments & registers for pmi call 
  5422                              <1> ;	call	VESA_VBE3_PM_FUNCTION
  5423                              <1> ;
  5424                              <1> ;
  5425                              <1> 
  5426                              <1> 	; 26/11/2020
  5427                              <1> VBE_unknown:
  5428 0000183A 66B80001            <1> 	mov	ax, 0100h  ; ah = 1 : Function call failed	
  5429                              <1> 			   ; al = 0 : Function is not supported	
  5430                              <1> 	
  5431 0000183E EBB6                <1> 	jmp	short VBE_bios_return
  5432                              <1> 
  5433                              <1> vbe3_pmfn_return_ctrl_info:
  5434                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  5435                              <1> 	; 12/12/2020
  5436                              <1> 	;
  5437                              <1> 	; VBE function 4F00h - Return VBE Controller Information
  5438                              <1> 	;
  5439                              <1> 	; Input:
  5440                              <1> 	;      EDI = Pointer to buffer in which to place
  5441                              <1> 	;	     VbeInfoBlock structure
  5442                              <1> 	;
  5443                              <1> 	;	AX = 4F00h
  5444                              <1> 	; Output:
  5445                              <1> 	;	AX = VBE return status
  5446                              <1> 	;	     AX = 004Fh -> succeeded
  5447                              <1> 	;	     AX <> 004Fh -> failed
  5448                              <1> 	; 
  5449                              <1> 	; Modified registers: eax (+ edi for kernel's own call)
  5450                              <1> 
  5451                              <1> 	; NOTE: TRDOS 386 v2 (v2.0.3) kernel calls this function
  5452                              <1> 	; during startup while cpu is in real mode
  5453                              <1> 	; (by using int 10h, 4F02h) and saves VbeInfoBlock at
  5454                              <1> 	; VBE3INFOBLOCK address (97E00h for TRDOS 386 v2.0.3).
  5455                              <1> 	;	
  5456                              <1> 	; So...
  5457                              <1> 	; This VBE function is adjusted to return/move same info
  5458                              <1> 	; from VBE3INFOBLOCK to user's buffer in EDI.
  5459                              <1> 
  5460                              <1> 	; int 31h (int 10h) entrance
  5461                              <1> 
  5462 00001840 21FF                <1> 	and	edi, edi
  5463 00001842 7423                <1> 	jz	short vbe3_func_fail ; invalid buffer address !
  5464                              <1> 
  5465                              <1> ;_vbe3_pmfn_return_ctrl_info:		
  5466                              <1> 	;or	edi, edi
  5467                              <1> 	;jnz	short _vbe_biosfn_return_ctrl_info
  5468                              <1> 	;
  5469                              <1> 	;; this option may not be necessary - 12/12/2020
  5470                              <1> 	;
  5471                              <1> 	;; edi = 0, kernel forces to get ctrl info again
  5472                              <1> 	;;	   by using VESA VBE3 video bios's pmi
  5473                              <1> 	;
  5474                              <1> 	;;push	edi
  5475                              <1> 	;; far call to VESA VBE3 PMI 
  5476                              <1> 	;;mov	ax, 4F00h ; Return VBE Controller Info
  5477                              <1> 	;mov	edi, VBE3INFOBLOCK-VBE3SAVERESTOREBLOCK
  5478                              <1> 	;; ES selector base address = VBE3SAVERESTOREBLOCK 
  5479                              <1> 	;call	int10h_32bit_pmi
  5480                              <1> 	;;pop	edi
  5481                              <1> 	;mov	edi, VBE3INFOBLOCK ; retn to the kernel sub
  5482                              <1> 	;cmp	ax, 004Fh
  5483                              <1> 	;je	short vbe_ctrl_info_retn
  5484                              <1> 	;stc	
  5485                              <1> 	;retn
  5486                              <1> 
  5487                              <1> _vbe_biosfn_return_ctrl_info:
  5488 00001844 57                  <1> 	push	edi
  5489 00001845 51                  <1> 	push	ecx
  5490 00001846 BE007E0900          <1> 	mov	esi, VBE3INFOBLOCK
  5491                              <1> 	;mov	ecx, 512
  5492                              <1> 	; 02/08/2022
  5493 0000184B 29C9                <1> 	sub	ecx, ecx
  5494 0000184D B502                <1> 	mov	ch, 2
  5495                              <1> 	; ecx = 512
  5496 0000184F E8D9F40000          <1> 	call	transfer_to_user_buffer
  5497 00001854 59                  <1> 	pop	ecx
  5498 00001855 5F                  <1> 	pop	edi
  5499 00001856 720F                <1> 	jc	short vbe3_func_fail
  5500                              <1> 
  5501 00001858 31C0                <1> 	xor	eax, eax
  5502 0000185A B04F                <1> 	mov	al, 4Fh ; successful
  5503                              <1> ;vbe_ctrl_info_retn:
  5504 0000185C C3                  <1> 	retn
  5505                              <1> 
  5506                              <1> vbe_biosfn_return_ctrl_info:
  5507                              <1> 	; 12/12/2020
  5508                              <1> 	;
  5509                              <1> 	; VBE function 4F00h - Return VBE Controller Information
  5510                              <1> 	;
  5511                              <1> 	; Input:
  5512                              <1> 	;      EDI = Pointer to buffer in which to place
  5513                              <1> 	;	     VbeInfoBlock structure
  5514                              <1> 	;
  5515                              <1> 	;	AX = 4F00h
  5516                              <1> 	; Output:
  5517                              <1> 	;	AX = VBE return status
  5518                              <1> 	;	     AX = 004Fh -> succeeded
  5519                              <1> 	;	     AX <> 004Fh -> failed   
  5520                              <1> 	; 
  5521                              <1> 	; Modified registers: eax
  5522                              <1> 
  5523 0000185D 21FF                <1> 	and	edi, edi
  5524 0000185F 7406                <1> 	jz	short vbe3_func_fail ; invalid buffer addr !
  5525 00001861 EBE1                <1> 	jmp	short _vbe_biosfn_return_ctrl_info 
  5526                              <1> 
  5527                              <1> vbe3_pmfn_return_mode_info:
  5528                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)	
  5529                              <1> 	; 21/12/2020
  5530                              <1> 	; 12/12/2020
  5531                              <1> 	;
  5532                              <1> 	; VBE function 4F01h - Return VBE Mode Information
  5533                              <1> 	;
  5534                              <1> 	; Input:
  5535                              <1> 	;	CX = Mode number (VESA VBE mode number)
  5536                              <1> 	;      EDI = Pointer to ModeInfoBlock structure
  5537                              <1> 	;	     (256 bytes) -User's buffer address-
  5538                              <1> 	;      EDI = 0 -> kernel call
  5539                              <1> 	;		  (do not transfer ModeInfoBlock
  5540                              <1> 	;		  to user's buffer address)
  5541                              <1> 	;	AX = 4F01h	
  5542                              <1> 	; Output:
  5543                              <1> 	;	AX = VBE return status
  5544                              <1> 	;	     AX = 004Fh -> succeeded
  5545                              <1> 	;	     AX <> 004Fh -> failed   
  5546                              <1> 	; 
  5547                              <1> 	; Modified registers: eax, esi, edi
  5548                              <1> 
  5549                              <1> 	; int 31h (int 10h) entrance
  5550                              <1> 	
  5551 00001863 09FF                <1> 	or	edi, edi
  5552 00001865 7506                <1> 	jnz	short _vbe3_pmfn_return_mode_info
  5553                              <1> 
  5554                              <1> vbe3_func_fail:
  5555 00001867 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
  5556                              <1> 			   ; al = 4Fh : Function is supported
  5557 0000186C C3                  <1> 	retn
  5558                              <1> 	
  5559                              <1> 	; jump from '_vbe_biosfn_return_mode_info' 
  5560                              <1> _vbe3_pmfn_return_mode_info:
  5561 0000186D 57                  <1> 	push	edi
  5562                              <1> 
  5563                              <1> 	;; clear vbe3 'mode info block' buffer
  5564                              <1> 	;push	ecx
  5565                              <1> 	;xor	eax, eax
  5566                              <1> 	;mov	ecx, 256/4
  5567                              <1> 	;mov	edi, VBE3MODEINFOBLOCK
  5568                              <1> 	;rep	stosd
  5569                              <1> 	;pop	ecx
  5570                              <1> 
  5571                              <1> 	; far call to VESA VBE3 PMI 
  5572                              <1> 	;mov	ax, 4F01h ; Return VBE Mode Information
  5573 0000186E BF00060000          <1> 	mov	edi, VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK
  5574                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
  5575 00001873 E8FA000000          <1> 	call	int10h_32bit_pmi
  5576                              <1> 
  5577 00001878 5F                  <1> 	pop	edi
  5578                              <1> 
  5579                              <1> 	;cmp	ax, 004Fh
  5580                              <1> 	;jne	short vbe3_func_retn  ; failed !
  5581                              <1> 
  5582 00001879 21FF                <1> 	and	edi, edi
  5583                              <1> 	;jz	short vbe3_func_success
  5584                              <1> 	; 21/12/2020
  5585 0000187B 741C                <1> 	jz	short vbe3_func_retn
  5586                              <1> 
  5587 0000187D 6683F84F            <1> 	cmp	ax, 004Fh
  5588 00001881 7516                <1> 	jne	short vbe3_func_retn  ; failed !
  5589                              <1> 
  5590 00001883 51                  <1> 	push	ecx
  5591 00001884 BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK		
  5592                              <1> 	;mov	ecx, 256
  5593                              <1> 	; 02/08/2022
  5594 00001889 29C9                <1> 	sub	ecx, ecx
  5595 0000188B FEC5                <1> 	inc	ch
  5596                              <1> 	; ecx = 256
  5597 0000188D E89BF40000          <1> 	call	transfer_to_user_buffer
  5598 00001892 59                  <1> 	pop	ecx
  5599 00001893 72D2                <1> 	jc	short vbe3_func_fail
  5600                              <1> 
  5601 00001895 31C0                <1> 	xor	eax, eax
  5602 00001897 B04F                <1> 	mov	al, 4Fh ; successful
  5603                              <1> vbe3_func_success:
  5604                              <1> vbe3_func_retn:	
  5605 00001899 C3                  <1> 	retn
  5606                              <1> 
  5607                              <1> vbe3_pmfn_return_current_mode:
  5608                              <1> 	; 12/12/2020
  5609                              <1> 	;
  5610                              <1> 	; VBE function 4F03h - Return Current VBE Mode
  5611                              <1> 	;
  5612                              <1> 	; Input:
  5613                              <1> 	;	none (AX = 4F03h)
  5614                              <1> 	; Output:
  5615                              <1> 	;	AX = VBE return status
  5616                              <1> 	;	     AX = 004Fh -> succeeded
  5617                              <1> 	;	     AX <> 004Fh -> failed
  5618                              <1> 	;	BX = Current VBE mode
  5619                              <1> 	;	  bit 0-13 = Mode number
  5620                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
  5621                              <1> 	;	         = 1 Linear frame buffer model
  5622                              <1> 	;	  bit 15 
  5623                              <1> 	;	      = 0 Memory cleared at last mode set
  5624                              <1> 	;	      = 1 Memory not cleared at last mode set
  5625                              <1> 	; 
  5626                              <1> 	; Modified registers: eax, ebx
  5627                              <1> 
  5628                              <1> 	; int 31h (int 10h) entrance
  5629                              <1> 	
  5630                              <1> 	; far call to VESA VBE3 PMI 
  5631                              <1> 
  5632                              <1> 	;mov	eax, 4F03h ; Return Current VBE Mode
  5633                              <1> vbe3_pmfn_far_call:
  5634                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
  5635                              <1> 	;call	int10h_32bit_pmi
  5636                              <1> 	;retn
  5637 0000189A E9D3000000          <1> 	jmp	int10h_32bit_pmi
  5638                              <1> 
  5639                              <1> vbe3_pmfn_set_mode:
  5640                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  5641                              <1> 	; 22/12/2020
  5642                              <1> 	; 21/12/2020
  5643                              <1> 	; 12/12/2020
  5644                              <1> 	;
  5645                              <1> 	; VBE function 4F02h - Set VBE Mode
  5646                              <1> 	;
  5647                              <1> 	; Input:
  5648                              <1> 	;	BX = Desired Mode to set
  5649                              <1> 	;	  bit 0-13 = Mode number
  5650                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
  5651                              <1> 	;	         = 1 Linear frame buffer model
  5652                              <1> 	;	  bit 15 
  5653                              <1> 	;	      = 0 Memory cleared at last mode set
  5654                              <1> 	;	      = 1 Memory not cleared at last mode set
  5655                              <1> 	; Output:
  5656                              <1> 	;	AX = VBE return status
  5657                              <1> 	;	     AX = 004Fh -> succeeded
  5658                              <1> 	;	     AX <> 004Fh -> failed
  5659                              <1> 	; 
  5660                              <1> 	; Modified registers: eax, ebx, esi (21/12/2020)
  5661                              <1> 
  5662                              <1> 	; int 31h (int 10h) entrance
  5663                              <1> 
  5664                              <1> 	; 22/12/2020 (VESA VBE3 feature)
  5665                              <1> 	; BX bit 11 is flag for
  5666                              <1> 	;	user specified CRTC values for refresh rate
  5667                              <1> 	; 'test bh, 8'
  5668                              <1> 	; if bit 11 is set, EDI points to 'CRTCInfoBlock'
  5669                              <1> 
  5670                              <1> 	; 22/12/2020
  5671                              <1> 	;; test bx for VBE video mode
  5672                              <1> 	;test	bh, 1
  5673                              <1> 	;jnz	short vbe3_sm_0
  5674                              <1> 
  5675                              <1> 	;; use internal VBE mode set procedure
  5676                              <1> 	;; for non-vbe (std VGA/CGA) modes
  5677                              <1> 	;
  5678                              <1> 	;; (it is useful -as 4F02h function- 
  5679                              <1> 	;;  to jump 'vbe_biosfn_set_mode'
  5680                              <1> 	;;  instead of direct jump to '_set_mode')
  5681                              <1> 	;; ((eliminates additional push-pops and settings))
  5682                              <1>  
  5683                              <1> 	;jmp	vbe_biosfn_set_mode	
  5684                              <1> 
  5685                              <1> vbe3_sm_0: 
  5686                              <1> 	;;push	ds  ; *
  5687                              <1> 	;;push	es  ; **
  5688                              <1> 	;;push	ebp ; ***
  5689                              <1> 	;;push	esi ; **** 
  5690                              <1> 	
  5691                              <1> 	; Fit bx to VESA VBE2 type mode setting
  5692                              <1> 	; (bx bit 11 is used for custom CRTC values in VBE3)
  5693                              <1> 	; clear bit 9 to 11 (clear bh bit 1 to bit 3)
  5694                              <1> 
  5695                              <1> 	; 22/12/2020
  5696 0000189F 57                  <1> 	push	edi ; *****
  5697 000018A0 F6C708              <1> 	test	bh, 8	; Use user specified CRTC values
  5698 000018A3 7530                <1> 	jnz	short vbe3_sm_3  ; for refresh rate
  5699                              <1> vbe3_sm_4:
  5700 000018A5 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  5701                              <1> 	;mov	[vbe_mode_x], bh
  5702                              <1> 
  5703 000018A8 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h ?
  5704 000018AF 7509                <1> 	jne	short vbe3_sm_1    ; no
  5705                              <1> 
  5706                              <1> 	; save mode 03h video pages and cursor positions
  5707 000018B1 57                  <1> 	push	edi ; **!***	
  5708 000018B2 51                  <1> 	push	ecx ; ******
  5709                              <1> 	;push	esi
  5710                              <1> 	
  5711 000018B3 E8B6040000          <1> 	call	save_mode3_multiscreen
  5712                              <1> 	
  5713                              <1> 	;pop	esi
  5714 000018B8 59                  <1> 	pop	ecx ; ******
  5715 000018B9 5F                  <1> 	pop	edi ; **!***
  5716                              <1> vbe3_sm_1:
  5717                              <1> 	; ax = 4F02h
  5718                              <1> 	; bx = video mode number (vbe2 type)
  5719 000018BA E8B3000000          <1> 	call	int10h_32bit_pmi 
  5720                              <1> 			; call to far call to VBE3 PMI
  5721                              <1> 
  5722 000018BF 6683F84F            <1> 	cmp	ax, 004Fh ; succeeded ?
  5723 000018C3 750E                <1> 	jne	short vbe3_sm_2
  5724                              <1> 	; set current mode byte/sign to extended (SVGA) mode
  5725 000018C5 C605[9E660000]FF    <1> 	mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
  5726                              <1> 	; set current VBE mode word to bx input
  5727 000018CC 66891D[D20F0300]    <1> 	mov	[video_mode], bx
  5728                              <1> vbe3_sm_2:
  5729                              <1> 	; 22/12/2020
  5730 000018D3 5F                  <1> 	pop	edi ; ***** 
  5731 000018D4 C3                  <1> 	retn
  5732                              <1> 
  5733                              <1> vbe3_sm_3:
  5734                              <1> 	; 22/12/2020
  5735                              <1> 	; copy user's CRTCInfoBlock to the buffer
  5736 000018D5 51                  <1> 	push	ecx
  5737 000018D6 89FE                <1> 	mov	esi, edi
  5738 000018D8 BF807D0900          <1> 	mov	edi, VBE3CRTCINFOBLOCK
  5739                              <1> 	;mov	ecx, 64
  5740                              <1> 	; 02/08/2022
  5741 000018DD 29C9                <1> 	sub	ecx, ecx
  5742 000018DF B140                <1> 	mov	cl, 64
  5743 000018E1 E891F40000          <1> 	call	transfer_from_user_buffer
  5744 000018E6 59                  <1> 	pop	ecx
  5745                              <1> 	; set offset (es base addr is VBE3SAVERESTOREBLOCK) 
  5746 000018E7 81EF00760900        <1> 	sub	edi, VBE3SAVERESTOREBLOCK
  5747 000018ED EBB6                <1> 	jmp	short vbe3_sm_4
  5748                              <1> 	
  5749                              <1> vesa_vbe3_pmi:
  5750                              <1> 	; 12/12/2020
  5751                              <1> 	; 08/12/2020
  5752                              <1> 	; 07/12/2020
  5753                              <1> 	; 05/12/2020, 06/12/2020
  5754                              <1> 	; 03/12/2020, 04/12/2020
  5755                              <1> 	; 28/11/2020 (TRDOS 386 v2.0.3)
  5756                              <1> 	; VGA BIOS functions via
  5757                              <1> 	; VESA VBE3 Protected Mode Inface
  5758                              <1> 	; [vbe3] = 3 and [pmi32] > 0
  5759                              <1> 
  5760                              <1> 	; 04/12/2020
  5761                              <1> 	; Only 'set mode' will be redirected to vbe3 video bios
  5762                              <1> 	; (by setting mode 3 multiscreen paraters before and after) 
  5763                              <1> 
  5764                              <1> 	; 06/12/2020
  5765 000018EF 20E4                <1> 	and	ah, ah	; 0 = set mode function
  5766 000018F1 7402                <1> 	jz	short vbe3_pmi_0
  5767 000018F3 EB76                <1> 	jmp	vbe3_pmi_9 
  5768                              <1> 
  5769                              <1> vbe3_pmi_0:
  5770                              <1> 	; 07/12/2020
  5771 000018F5 88C4                <1> 	mov	ah, al
  5772 000018F7 80E480              <1> 	and	ah, 80h ; 0 or 80h
  5773 000018FA 30E0                <1> 	xor	al, ah ; 8?h -> 0?h
  5774                              <1> 
  5775                              <1> 	;cmp	al, 13h ; mode number above 13h is returned
  5776                              <1> 	;jna	short vbe3_pmi_1
  5777                              <1> 	;		; back to default code due to uncertainty
  5778                              <1> 	; 		; (>13h is not std for all svga bioses)
  5779                              <1> 	;jmp	VGA_funcs_0
  5780                              <1> vbe3_pmi_1:
  5781                              <1> 	; 07/12/2020
  5782                              <1> 	; Possible cases for VBE3 (PMI, ah=0) set mode:
  5783                              <1> 	; current mode > 07h and requested mode: any 
  5784                              <1> 	; current mode <= 07h and requested mode > 07h
  5785                              <1> 
  5786                              <1> 	; 06/12/2020
  5787 000018FC 8825[13840100]      <1> 	mov	byte [noclearmem], ah ; 0 or 80h
  5788                              <1> 	; check current video mode if it is 03h
  5789 00001902 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; current mode
  5790 00001909 750B                <1> 	jne	short vbe3_pmi_3
  5791                              <1> 	; 07/12/2020
  5792                              <1> 	; check new video mode if it is 03h also
  5793                              <1> 	;cmp	al, 3
  5794                              <1> 	;jne	short vbe3_pmi_2
  5795                              <1> 	;mov	byte [p_crt_mode], 80h 	; clear video memory
  5796                              <1> 	;jmp	short vbe3_pmi_5
  5797                              <1> vbe3_pmi_2:
  5798                              <1> 	; case 1:
  5799                              <1> 	; Current mode is 03h and new mode is not 03h
  5800                              <1> 
  5801                              <1> 	; save video pages and cursor positions
  5802 0000190B 56                  <1> 	push	esi
  5803 0000190C 57                  <1> 	push	edi
  5804 0000190D 51                  <1> 	push	ecx
  5805                              <1> 
  5806                              <1> 	; 12/12/2020
  5807                              <1> 	;mov	esi, 0B8000h ; mode 3 video memory
  5808                              <1> 	;mov	edi, 98000h  ; backup location
  5809                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  5810                              <1> 	;rep	movsd
  5811                              <1> 	;
  5812                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  5813                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  5814                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
  5815                              <1> 	;
  5816                              <1> 	;; save cursor positions
  5817                              <1> 	;mov	esi, CURSOR_POSN
  5818                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  5819                              <1> 	;mov	cl, 4
  5820                              <1> 	;rep	movsd
  5821                              <1> 
  5822                              <1> 	; 12/12/2020
  5823 0000190E E85B040000          <1> 	call	save_mode3_multiscreen
  5824                              <1> 
  5825 00001913 59                  <1> 	pop	ecx
  5826 00001914 5F                  <1> 	pop	edi
  5827 00001915 5E                  <1> 	pop	esi
  5828                              <1> vbe3_pmi_3:
  5829                              <1> 	; 08/12/2020
  5830                              <1> 	; 07/12/2020
  5831                              <1> 	; case 3 or case 4
  5832 00001916 A2[9E660000]        <1> 	mov	[CRT_MODE], al
  5833 0000191B 3C03                <1> 	cmp	al, 3
  5834 0000191D 7407                <1> 	je	short vbe3_pmi_4
  5835                              <1> 	; case 4:
  5836                              <1> 	; Current mode is not 03h and also new mode is not 03h
  5837 0000191F 800D[11840100]80    <1> 	or	byte [p_crt_mode], 80h  ; 83h (case 1 -> case 4)
  5838                              <1> 	;jmp	short vbe3_pmi_5
  5839                              <1> vbe3_pmi_4:
  5840                              <1> 	; case 3:
  5841                              <1> 	;
  5842                              <1> 	; Current mode is not 03h and new mode is 03h
  5843                              <1> 
  5844                              <1> ;vbe3_pmi_5:
  5845                              <1> 	;mov	[CRT_MODE], al
  5846                              <1> 
  5847 00001926 E847000000          <1> 	call	int10h_32bit_pmi	
  5848                              <1> 
  5849 0000192B 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  5850                              <1> 	;jne	vbe3_pmi_8	; video mode <> 03h
  5851 00001932 7532                <1> 	jne	short vbe3_pmi_8	
  5852                              <1> 
  5853                              <1> 	;push	eax ; 04/12/2020
  5854 00001934 53                  <1> 	push	ebx
  5855 00001935 51                  <1> 	push	ecx
  5856 00001936 52                  <1> 	push	edx
  5857 00001937 57                  <1> 	push	edi ; 03/12/2020
  5858                              <1> 
  5859                              <1> 	; 12/12/2020
  5860 00001938 56                  <1> 	push	esi
  5861 00001939 E862040000          <1> 	call	restore_mode3_multiscreen
  5862 0000193E 5E                  <1> 	pop	esi
  5863                              <1> 	; AL = active video page
  5864                              <1> 
  5865                              <1> 	; 12/12/2020
  5866                              <1> 	;mov	al, [p_crt_page] ; previous mode 3 active page
  5867                              <1> 	;
  5868                              <1> 	;;test	byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  5869                              <1> 	;;jz	short vbe3_pmi_6 ; do not restore video pages
  5870                              <1> 	;			 ; clear current video page
  5871                              <1> 	;; case 3
  5872                              <1> 	;
  5873                              <1> 	;; ([p_crt_mode] = 03h)
  5874                              <1> 	;
  5875                              <1> 	;; New video mode is 3 while current video mode is not 3
  5876                              <1> 	;; (multi screen) video pages will be restored from 098000h
  5877                              <1> 	;
  5878                              <1> 	;; restore video pages and cursor positions
  5879                              <1> 	;
  5880                              <1> 	;mov	[ACTIVE_PAGE], al ; current mode 3 active page
  5881                              <1> 	;
  5882                              <1> 	;push	esi
  5883                              <1> 	;
  5884                              <1> 	;; restore video pages
  5885                              <1> 	;mov	esi, 98000h
  5886                              <1> 	;mov	edi, 0B8000h
  5887                              <1> 	;;mov	ecx, 2000h
  5888                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  5889                              <1> 	;rep	movsd
  5890                              <1> 	;
  5891                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  5892                              <1> 	;
  5893                              <1> 	;; restore cursor positions
  5894                              <1> 	;mov	esi, cursor_pposn
  5895                              <1> 	;mov	edi, CURSOR_POSN
  5896                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  5897                              <1> 	;mov	cl, 4
  5898                              <1> 	;rep 	movsd
  5899                              <1> 	;
  5900                              <1> 	;pop	esi
  5901                              <1> 	;
  5902                              <1> 	;; 07/12/2020
  5903                              <1> 	;; restore CRT_START according to ACTIVE_PAGE
  5904                              <1> 	;mov	[CRT_START], cx ; 0
  5905                              <1> 	;
  5906                              <1> 	;; check active page and set it again if it is not 0
  5907                              <1> 	;or	al, al
  5908                              <1> 	;jz	short vbe3_pmi_7
  5909                              <1> 	;
  5910                              <1> 	;mov	cl, al
  5911                              <1> ;vbe3_pmi_5:
  5912                              <1> 	;add	word [CRT_START], 4096
  5913                              <1> 	;dec	cl
  5914                              <1> 	;jnz	short vbe3_pmi_5
  5915                              <1> 
  5916 0000193F B405                <1> 	mov	ah, 05h ; set current video page
  5917                              <1> 	;al = video page
  5918 00001941 E82C000000          <1> 	call	int10h_32bit_pmi
  5919                              <1> 	
  5920                              <1> 	; check current cursor position & set it again if not 0,0
  5921                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  5922 00001946 0FB6D8              <1> 	movzx	ebx, al
  5923 00001949 D0E3                <1> 	shl	bl, 1
  5924 0000194B 81C3[9E770100]      <1> 	add	ebx, CURSOR_POSN
  5925 00001951 668B13              <1> 	mov	dx, [ebx]
  5926 00001954 6621D2              <1> 	and	dx, dx		
  5927 00001957 7409                <1> 	jz	short vbe3_pmi_7
  5928                              <1> 	
  5929                              <1> 	;dx = cursor position (dl = column, dh = row)
  5930                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 06/12/2020
  5931 00001959 88C7                <1> 	mov	bh, al
  5932 0000195B B402                <1> 	mov	ah, 02h ; set cursor position
  5933 0000195D E810000000          <1> 	call	int10h_32bit_pmi
  5934                              <1> 	
  5935                              <1> 	;jmp	short vbe3_pmi_7
  5936                              <1> 
  5937                              <1> ;vbe3_pmi_6:
  5938                              <1> ;	; 07/12/2020
  5939                              <1> ;	; case 1, previous mode is 03h, current mode is 03h
  5940                              <1> ;	; 03/12/2020
  5941                              <1> ;	cmp	byte [noclearmem], 0
  5942                              <1> ;	jna	short vbe3_pmi_7 ; do not clear memory
  5943                              <1> ;	; clear video page
  5944                              <1> ;	mov	ecx, 1024 ; 4096/4
  5945                              <1> ;	mov	eax, 07200720h
  5946                              <1> ;	mov	edi, 0B8000h ; [crt_base]
  5947                              <1> ;	add	di, [CRT_START]
  5948                              <1> ;	rep	stosd	; FILL THE REGEN BUFFER WITH BLANKS
  5949                              <1> 
  5950                              <1> vbe3_pmi_7:
  5951 00001962 5F                  <1> 	pop	edi
  5952 00001963 5A                  <1> 	pop	edx
  5953 00001964 59                  <1> 	pop	ecx
  5954 00001965 5B                  <1> 	pop	ebx
  5955                              <1> 	;pop	eax ; 04/12/2020
  5956                              <1> vbe3_pmi_8:
  5957                              <1> 	; 04/12/2020
  5958                              <1> 	;(TRDOS 386 v2.0.3, INT 31h, ah=0 return)
  5959 00001966 31C0                <1> 	xor	eax, eax  ; eax = 0 -> succesful
  5960                              <1> vesa_vbe3_pmi_retn:
  5961 00001968 07                  <1> 	pop	es  ; **
  5962 00001969 1F                  <1> 	pop	ds  ; *
  5963 0000196A CF                  <1> 	iretd
  5964                              <1> 
  5965                              <1> vbe3_pmi_9:
  5966                              <1> 	; 06/12/2020 
  5967                              <1> 	;cmp	ah, 10h ; Set/Get Palette Registers
  5968                              <1> 	;jnb	short vbe3_pmi_10
  5969                              <1> 	; 05/12/2020
  5970 0000196B E802000000          <1> 	call	int10h_32bit_pmi
  5971 00001970 EBF6                <1> 	jmp	short vesa_vbe3_pmi_retn
  5972                              <1> 
  5973                              <1> ;vbe3_pmi_10:
  5974                              <1> 	; 06/12/2020
  5975                              <1> 	;jmp	VGA_funcs_0
  5976                              <1> 
  5977                              <1> int10h_32bit_pmi:
  5978                              <1> 	; 03/12/2020
  5979                              <1> 	; 28/11/2020
  5980                              <1> 	; calling standard VGA Bios (INT 10h) functions
  5981                              <1> 	; by using 32 bit protected mode interface of
  5982                              <1> 	; VESA VBE3 Video Bios (with 'PMID' signature)
  5983                              <1> 
  5984                              <1> 	; 03/12/2020
  5985                              <1> 	; eax, ebx, ecx, edx, edi will be used by vbios pmi
  5986                              <1> 	; (esi and ebp will not be used) 
  5987                              <1> 
  5988                              <1> 	; 03/12/2020
  5989 00001972 56                  <1> 	push	esi
  5990 00001973 C1E010              <1> 	shl	eax, 16  ; move function number (ax) to hw
  5991 00001976 8B35[D80F0300]      <1> 	mov	esi, [pmid_addr] ; linear address of
  5992                              <1> 				 ; PMInfo.Entrypoint pointer
  5993                              <1> 	;mov	ax, [esi+PMInfo.EntryPoint]	
  5994 0000197C 668B06              <1> 	mov	ax, [esi]	 
  5995 0000197F C1C010              <1> 	rol	eax, 16 ; move PM entry address to hw
  5996                              <1> 			; and move function number to lw (ax)
  5997 00001982 5E                  <1> 	pop	esi
  5998                              <1> 
  5999                              <1> 	; top of stack: ; (*)
  6000                              <1> 	; return (the caller) address of "int10h_32bit_pmi"
  6001                              <1> 
  6002 00001983 E904EEFFFF          <1> 	jmp	_VBE3PMI_fcall ; will return to the caller (*)
  6003                              <1> 
  6004                              <1> _vbe3_pmfn_srs_8:
  6005                              <1> 	; 17/01/2021
  6006 00001988 31DB                <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  6007                              <1> _vbe3_pmfn_srs_9: ; 24/01/2021
  6008 0000198A 66B8044F            <1> 	mov	ax, 4F04h
  6009 0000198E EBE2                <1> 	jmp	short int10h_32bit_pmi
  6010                              <1> 
  6011                              <1> vbe3_pmfn_save_restore_state:
  6012                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  6013                              <1> 	; 24/01/2021
  6014                              <1> 	; 23/01/2021
  6015                              <1> 	; 16/01/2021 - 17/01/2021
  6016                              <1> 	; 14/01/2021
  6017                              <1> 	;
  6018                              <1> 	; VBE function 4F04h - Save/Restore Video State
  6019                              <1> 	;
  6020                              <1> 	; Input:
  6021                              <1> 	;	DL = sub function
  6022                              <1> 	;	CL = requested state
  6023                              <1> 	;      EBX = pointer to buffer (if DL<>00h)
  6024                              <1> 	;	AX = 4F04h 
  6025                              <1> 	; Output:
  6026                              <1> 	;	AX = 004Fh (successful)
  6027                              <1> 	;	AH > 0 -> error
  6028                              <1> 	;	BX = Number of 64-byte blocks 
  6029                              <1> 	;	     to hold the state buffer (if DL=00h)
  6030                              <1> 
  6031                              <1> 	; Modified registers: eax, ebx, esi, edi
  6032                              <1> 	
  6033 00001990 21DB                <1> 	and	ebx, ebx ; user's buffer address
  6034 00001992 750A                <1> 	jnz	short _vbe3_pmfn_save_restore_state
  6035                              <1> 
  6036 00001994 08D2                <1> 	or	dl, dl
  6037 00001996 740C                <1> 	jz	short _vbe3_pmfn_srs_0
  6038                              <1> 
  6039                              <1> 	; function failed
  6040                              <1> 	;;mov	eax, 0100h
  6041                              <1> 	;sub	eax, eax
  6042                              <1> 	;inc	ah  ; eax = 0100h
  6043                              <1> 	;retn
  6044                              <1> 	; 16/01/2021
  6045                              <1> _vbe3_pmfn_srs_fail:
  6046 00001998 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
  6047                              <1> 			   ; al = 4Fh : Function is supported
  6048                              <1> _vbe3_srs_retn:
  6049 0000199D C3                  <1> 	retn
  6050                              <1> 
  6051                              <1> _vbe3_pmfn_save_restore_state:
  6052 0000199E 20D2                <1> 	and	dl, dl
  6053 000019A0 7555                <1> 	jnz	short _vbe3_pmfn_srs_2
  6054                              <1> _vbe3_pmfn_srs:
  6055 000019A2 31DB                <1> 	xor	ebx, ebx
  6056                              <1> _vbe3_pmfn_srs_0:
  6057                              <1> 	; 24/01/2021
  6058 000019A4 83F90F              <1> 	cmp	ecx, 0Fh
  6059                              <1> 	;ja	short _vbe3_pmfn_srs_1
  6060 000019A7 77EF                <1> 	ja	short _vbe3_pmfn_srs_fail 
  6061                              <1> 
  6062                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  6063                              <1> 	; (when bit 2 is set, function causes cpu exception)
  6064                              <1> 	; BIOS data will not be saved and restored
  6065                              <1> 	; (to prevent protected mode page fault error)
  6066 000019A9 80E1FD              <1> 	and	cl, ~2 ; and cl, not 2
  6067                              <1> 	
  6068                              <1> 	; 24/01/2021
  6069                              <1> 	;mov	bl, 1
  6070 000019AC FEC3                <1> 	inc	bl ; = 1
  6071                              <1> 	;shl	bx, cl 
  6072                              <1> 	; 02/08/2022
  6073 000019AE D3E3                <1> 	shl	ebx, cl
  6074 000019B0 66231D[DC0F0300]    <1> 	and	bx, [vbe3stbsflags]
  6075 000019B7 7415                <1> 	jz	short _vbe3_pmfn_srs_1
  6076                              <1> 	;mov	bx, cx
  6077 000019B9 89CB                <1> 	mov	ebx, ecx ; <= 15
  6078 000019BB D0E3                <1> 	shl	bl, 1 ; 0, 2, 8 .. 30
  6079 000019BD 668B9B[C63A0000]    <1> 	mov	bx, [vbestatebufsize+ebx]
  6080 000019C4 89DF                <1> 	mov	edi, ebx
  6081                              <1> 	; edi = state buffer size in bytes
  6082                              <1> 	;shr	bx, 6 ; / 64
  6083                              <1> 	; 02/08/2022
  6084 000019C6 C1EB06              <1> 	shr	ebx, 6
  6085                              <1> 	;mov	ax, 4Fh
  6086 000019C9 28E4                <1> 	sub	ah, ah
  6087 000019CB B04F                <1> 	mov	al, 4Fh
  6088 000019CD C3                  <1> 	retn
  6089                              <1> _vbe3_pmfn_srs_1:
  6090                              <1> 	; ax = 4F04h
  6091                              <1> 	;call	int10h_32bit_pmi
  6092                              <1> 	; 24/01/2021
  6093                              <1> 	;call	_vbe3_pmfn_srs_8
  6094                              <1> 	; ebx = 0
  6095 000019CE E8B7FFFFFF          <1> 	call	_vbe3_pmfn_srs_9	
  6096 000019D3 6683F84F            <1> 	cmp	ax, 004Fh
  6097 000019D7 75C4                <1> 	jne	short _vbe3_srs_retn
  6098                              <1> 	; 24/01/2021
  6099                              <1> 	;cmp	ecx, 0Fh
  6100                              <1> 	;ja	short _vbe3_srs_retn
  6101                              <1> 	; 24/01/2021
  6102                              <1> 	;mov	ax, 1
  6103 000019D9 B001                <1> 	mov	al, 1
  6104                              <1> 	;shl	ax, cl		
  6105                              <1> 	; 02/08/2022
  6106 000019DB D3E0                <1> 	shl	eax, cl
  6107 000019DD 660905[DC0F0300]    <1> 	or	[vbe3stbsflags], ax ; set flag for state option
  6108                              <1> 	; 23/01/2021
  6109 000019E4 89DF                <1> 	mov	edi, ebx
  6110 000019E6 89C8                <1> 	mov	eax, ecx
  6111 000019E8 D0E0                <1> 	shl	al, 1
  6112                              <1> 	;shl	di, 6 ; * 64
  6113                              <1> 	; 02/08/2022
  6114 000019EA C1E706              <1> 	shl	edi, 6
  6115 000019ED 6689B8[C63A0000]    <1> 	mov	[vbestatebufsize+eax], di
  6116                              <1> 				; save buf size for option 
  6117                              <1> 	;xchg	edi, ebx
  6118                              <1> 	; edi = state buffer size in bytes
  6119 000019F4 B04F                <1> 	mov	al, 4Fh
  6120 000019F6 C3                  <1> 	retn
  6121                              <1> 
  6122                              <1> _vbe3_pmfn_srs_2:
  6123                              <1> 	; 24/01/2021
  6124                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  6125                              <1> 	; (when bit 2 is set, function causes cpu exception)
  6126                              <1> 	; BIOS data will not be saved and restored
  6127                              <1> 	; (to prevent protected mode page fault error)
  6128                              <1> 
  6129 000019F7 F6C1FD              <1> 	test	cl, ~2 ; test cl, not 2
  6130 000019FA 749C                <1> 	jz	short _vbe3_pmfn_srs_fail
  6131                              <1> 
  6132 000019FC 80FA02              <1> 	cmp	dl, 2
  6133 000019FF 7748                <1> 	ja	short _vbe3_pmfn_srs_5
  6134                              <1> 
  6135                              <1> 	;and	cl, ~2 ; and cl, not 2
  6136                              <1> 
  6137 00001A01 53                  <1> 	push	ebx ; * ; buffer address
  6138                              <1> 	; save or restore state
  6139                              <1> 	; (get required buffer size at first)
  6140 00001A02 52                  <1> 	push	edx ; **
  6141 00001A03 28D2                <1> 	sub	dl, dl ; 0
  6142 00001A05 E898FFFFFF          <1> 	call	_vbe3_pmfn_srs
  6143 00001A0A 5A                  <1> 	pop	edx ; **
  6144                              <1> 	; 24/01/2021
  6145 00001A0B 5B                  <1> 	pop	ebx ; *
  6146 00001A0C 08E4                <1> 	or	ah, ah
  6147 00001A0E 7538                <1> 	jnz	short _vbe3_pmfn_srs_4 ; error
  6148                              <1> 
  6149                              <1> 	; edi = buffer size in bytes
  6150 00001A10 81FF00080000        <1> 	cmp	edi, 2048
  6151 00001A16 772B                <1> 	ja	short _vbe3_pmfn_srs_3
  6152                              <1> 
  6153 00001A18 80FA01              <1> 	cmp	dl, 1
  6154 00001A1B 7531                <1> 	jne	short _vbe3_pmfn_srs_6 ; restore state
  6155                              <1> 	
  6156                              <1> 	; save video state
  6157                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  6158                              <1> 	;mov	ax, 4F04h
  6159                              <1> 	;call	int10h_32bit_pmi
  6160                              <1> 
  6161                              <1> 	; 24/01/2021
  6162 00001A1D E842000000          <1> 	call	_vbe3_pmfn_srs_7
  6163                              <1> 	
  6164 00001A22 6683F84F            <1> 	cmp	ax, 004Fh
  6165 00001A26 7520                <1> 	jne	short _vbe3_pmfn_srs_4
  6166                              <1> 
  6167 00001A28 09DB                <1> 	or	ebx, ebx  ; kernel ('sysvideo') ?
  6168 00001A2A 741C                <1> 	jz	short _vbe3_pmfn_srs_4 ; yes
  6169                              <1> 
  6170                              <1> 	; the caller is user
  6171 00001A2C 51                  <1> 	push	ecx ; *
  6172 00001A2D 89F9                <1> 	mov	ecx, edi ; state buffer size
  6173 00001A2F BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; source
  6174                              <1> 					; (vbe3 pmi buff)
  6175 00001A34 89DF                <1> 	mov	edi, ebx	; destination (user buff)
  6176 00001A36 E8F2F20000          <1> 	call	transfer_to_user_buffer
  6177 00001A3B 59                  <1> 	pop	ecx ; *
  6178 00001A3C 7205                <1> 	jc	short _vbe3_pmfn_srs_3
  6179                              <1> 
  6180 00001A3E 29C0                <1> 	sub	eax, eax
  6181 00001A40 B04F                <1> 	mov	al, 4Fh
  6182 00001A42 C3                  <1> 	retn
  6183                              <1> 
  6184                              <1> 	; 24/01/2021
  6185                              <1> _vbe3_pmfn_srs_3:
  6186 00001A43 B84F010000          <1> 	mov	eax, 014Fh
  6187                              <1> _vbe3_pmfn_srs_4:
  6188 00001A48 C3                  <1> 	retn
  6189                              <1> _vbe3_pmfn_srs_5:
  6190 00001A49 31C0                <1> 	xor	eax, eax
  6191 00001A4B FEC4                <1> 	inc	ah
  6192                              <1> 	; eax = 0100h, function is not supported
  6193 00001A4D C3                  <1> 	retn
  6194                              <1> 
  6195                              <1> _vbe3_pmfn_srs_6:
  6196                              <1> 	; restore video state
  6197                              <1> 	; 24/01/2021
  6198                              <1> 	;pop	ebx ; *
  6199                              <1> 	; 23/01/2021
  6200 00001A4E 09DB                <1> 	or	ebx, ebx ; 0 ?	
  6201 00001A50 7412                <1> 	jz	short _vbe3_pmfn_srs_7 ; 'sysvideo' call
  6202                              <1> 	; 24/01/2021
  6203                              <1> 	;jz	_vbe3_pmfn_srs_8
  6204 00001A52 89DE                <1> 	mov	esi, ebx
  6205                              <1> 	; esi = user's video state buffer
  6206 00001A54 51                  <1> 	push	ecx ; *
  6207 00001A55 89F9                <1> 	mov	ecx, edi ; state buffer size
  6208 00001A57 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
  6209                              <1> 					; (vbe3 pmi buff)
  6210                              <1> 	;mov	esi, ebx	; source (user buff)
  6211 00001A5C E816F30000          <1> 	call	transfer_from_user_buffer
  6212 00001A61 59                  <1> 	pop	ecx ; *
  6213 00001A62 72DF                <1> 	jc	short _vbe3_pmfn_srs_3
  6214                              <1> _vbe3_pmfn_srs_7:
  6215 00001A64 53                  <1> 	push	ebx ; *
  6216                              <1> 	; restore video state
  6217                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  6218                              <1> 	;mov	ax, 4F04h
  6219                              <1> 	;call	int10h_32bit_pmi
  6220                              <1> 	; 17/01/2021
  6221 00001A65 E81EFFFFFF          <1> 	call	_vbe3_pmfn_srs_8
  6222 00001A6A 5B                  <1> 	pop	ebx ; *
  6223 00001A6B C3                  <1> 	retn
  6224                              <1> 
  6225                              <1> VIDEO_STATE:
  6226                              <1> 	; 26/06/2016
  6227                              <1> 	; 12/05/2016
  6228                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  6229                              <1> 
  6230                              <1> ;---------------------------------------------------
  6231                              <1> ; VIDEO STATE
  6232                              <1> ;  RETURNS THE CURRENT VIDEO STATE IN AX
  6233                              <1> ;  AH = NUMBER OF COLUMNS ON THE SCREEN
  6234                              <1> ;  AL = CURRENT VIDEO MODE
  6235                              <1> ;  BH = CURRENT ACTIVE PAGE
  6236                              <1> ;---------------------------------------------------
  6237                              <1> 
  6238 00001A6C 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS]	; GET NUMBER OF COLUMNS
  6239 00001A72 A0[9E660000]        <1> 	mov	al, [CRT_MODE]	; CURRENT MODE
  6240                              <1> 	;movzx	esi, al
  6241                              <1> 	;mov	ah, [esi+M6] 
  6242                              <1> 	; BH = active page
  6243 00001A77 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE
  6244 00001A7D FA                  <1> 	cli	; 02/01/2017
  6245 00001A7E 5D                  <1> 	pop	ebp		; RECOVER REGISTERS
  6246 00001A7F 5F                  <1> 	pop	edi
  6247 00001A80 5E                  <1> 	pop	esi
  6248 00001A81 59                  <1> 	pop	ecx		; DISCARD SAVED BX
  6249 00001A82 EB41                <1> 	jmp	short M15	; RETURN TO CALLER
  6250                              <1> 
  6251                              <1> set_mode_ncm:
  6252                              <1> 	; 17/11/2020 (TRDOS 386 v2.0.3)
  6253                              <1> 	; 04/07/2016 - TRDOS 386 (TRDOS v2.0)
  6254                              <1> 	; set mode without clearing the video memory
  6255                              <1> 	; (ony for graphics modes)
  6256                              <1> 
  6257                              <1> 	;cmp	al, 7 ; IBM PC CGA modes
  6258                              <1> 	;jna	short SET_MODE ; normal function (clear)
  6259                              <1> 	;; do not clear memory
  6260                              <1> 	;;mov	[noclearmem], al ; > 0
  6261                              <1> 	;mov	byte [noclearmem], 80h ; 17/11/2020
  6262                              <1> 	;call	_set_mode
  6263                              <1> 	;mov	byte [noclearmem], 0
  6264                              <1>         ;jmp     short VIDEO_RETURN
  6265                              <1> 
  6266                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  6267 00001A84 0C80                <1> 	or	al, 80h ; not clear memory option
  6268                              <1> 
  6269                              <1> 	; 05/12/2020
  6270                              <1> 	; 27/11/2020
  6271                              <1> 	; 17/11/2020
  6272                              <1> 	; 08/08/2016, 10/08/2016
  6273                              <1> 	; 29/07/2016, 30/07/2016
  6274                              <1> 	; 25/07/2016, 26/07/2016, 27/07/2016
  6275                              <1> 	; 02/07/2016, 18/07/2016, 23/07/2016
  6276                              <1> 	; 24/06/2016, 26/06/2016
  6277                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  6278                              <1> SET_MODE:
  6279                              <1> 	; For 32 bit TRDOS and Retro UNIX 386:
  6280                              <1> 	;	valid video mode: 03h only!
  6281                              <1> 	;	(VGA modes will be selected with another routine)
  6282                              <1> 	;
  6283                              <1> 	; set_txt_mode ; 80*25 (16 fore colors, 8 back colors)
  6284                              <1> 
  6285                              <1> 	; 27/11/2020
  6286                              <1> 	
  6287                              <1> 	; Check if current mode is 
  6288                              <1> 	; Bochs/Plex86 VBE graphics mode
  6289 00001A86 803D[9E660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; VESA VBE graphics mode
  6290 00001A8D 7220                <1> 	jb	short _set_mode_      ; signature  	
  6291                              <1> 				      ; VBE mode number is in	 
  6292                              <1> 				      ; [video_mode] bit 0to8
  6293 00001A8F 88C3                <1> 	mov	bl, al ; save video mode
  6294 00001A91 E87C230000          <1> 	call	dispi_get_enable
  6295 00001A96 50                  <1> 	push	eax ; save current VBE dispi status 
  6296                              <1> 	; Disable Bochs/Plex86 VBE dispi
  6297                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  6298 00001A97 31C0                <1> 	xor	eax, eax ; 0 
  6299 00001A99 E849230000          <1> 	call	dispi_set_enable
  6300 00001A9E 88D8                <1> 	mov	al, bl ; restore video mode
  6301 00001AA0 E827000000          <1> 	call	_set_mode
  6302 00001AA5 58                  <1> 	pop	eax ; restore current VBE dispi status 
  6303 00001AA6 7313                <1> 	jnc	short VIDEO_RETURN
  6304                              <1> 	; ! unimplemented or invalid video mode number !
  6305                              <1> 	; VBE dispi must be enabled again
  6306                              <1> 	; (return to run on current VBE graphics mode)
  6307                              <1> 	;;mov	al, [video_mode+1] ; bit 8 to 15
  6308                              <1> 	;;and	al, 0C0h ; isolate bit 14 and bit 15 
  6309                              <1> 	;;or	al, 1 ; VBE_DISPI_ENABLED
  6310 00001AA8 E83A230000          <1> 	call	dispi_set_enable
  6311 00001AAD EB07                <1> 	jmp	short _video_func_err
  6312                              <1> 
  6313                              <1> _set_mode_:
  6314                              <1> 	; VGA bios (non-VBE) 'setmode' procedure
  6315                              <1> 
  6316                              <1> 	; 26/11/2020 (TRDOS v2.0.3)
  6317                              <1> 	
  6318                              <1> ;------------------------------------------------------
  6319                              <1> ; SET MODE					      :
  6320                              <1> ;	THIS ROUTINE INITIALIZES THE ATTACHMENT TO    :
  6321                              <1> ;	THE SELECTED MODE, THE SCREEN IS BLANKED.     :
  6322                              <1> ; INPUT						      :
  6323                              <1> ;	(AL) - MODE SELECTED (RANGE 0-7)	      :
  6324                              <1> ; OUTPUT					      :
  6325                              <1> ;	NONE					      :
  6326                              <1> ;------------------------------------------------------
  6327                              <1> 
  6328 00001AAF E818000000          <1> 	call	_set_mode ; 24/06/2016 (set_txt_mode)
  6329                              <1> 	; 26/11/2020
  6330 00001AB4 7305                <1> 	jnc	short VIDEO_RETURN
  6331                              <1> 
  6332                              <1> 	; 26/11/2020
  6333                              <1> _video_func_err:
  6334 00001AB6 31C0                <1> 	xor	eax, eax ; function call failed
  6335 00001AB8 48                  <1> 	dec	eax  ; 0FFFFFFFFh ; - 1	
  6336 00001AB9 EB05                <1> 	jmp	short _video_return	
  6337                              <1> 
  6338                              <1> ; 12/05/2016
  6339                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  6340                              <1> 
  6341                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  6342                              <1> 
  6343                              <1> VIDEO_RETURN:
  6344 00001ABB A1[04840100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  6345                              <1> _video_return:
  6346 00001AC0 FA                  <1> 	cli ; 02/01/2017
  6347 00001AC1 5D                  <1> 	pop	ebp ; ******** ; 26/11/2020
  6348 00001AC2 5F                  <1> 	pop	edi ; *******
  6349 00001AC3 5E                  <1> 	pop	esi ; ******
  6350 00001AC4 5B                  <1> 	pop	ebx ; *****
  6351                              <1> M15:	; VIDEO_RETURN_C
  6352                              <1> 	;;15/01/2017
  6353                              <1> 	; 02/01/2017
  6354                              <1> 	;;mov	byte [intflg], 0
  6355                              <1> 	;
  6356 00001AC5 59                  <1> 	pop	ecx ; **** ; 26/11/2020
  6357 00001AC6 5A                  <1> 	pop	edx ; ***
  6358 00001AC7 1F                  <1> 	pop	ds  ; **
  6359 00001AC8 07                  <1> 	pop	es  ; *	; RECOVER SEGMENTS
  6360 00001AC9 CF                  <1> 	iretd		; ALL DONE
  6361                              <1> 
  6362                              <1> set_txt_mode:
  6363                              <1> 	
  6364                              <1> 	; 29/07/2016
  6365                              <1> 	; 27/06/2016
  6366 00001ACA B003                <1> 	mov	al, 3 ; 26/11/2020 (bit 7 = 0)
  6367                              <1> 
  6368                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  6369                              <1> 	;mov	byte [noclearmem], 0
  6370                              <1> 
  6371                              <1> ; 04/08/2022
  6372                              <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  6373                              <1> ; 12/04/2021
  6374                              <1> ; 10/08/2016
  6375                              <1> ; 08/08/2016
  6376                              <1> ; 30/07/2016
  6377                              <1> ; 29/07/2016
  6378                              <1> ; 25/07/2016 - 26/07/2016 - 27/07/2016
  6379                              <1> ; 07/07/2016 - 18/07/2016 - 23/07/2016
  6380                              <1> ; 02/07/2016 - 03/07/2016 - 04/07/2016
  6381                              <1> ; 26/06/2016
  6382                              <1> ; 24/06/2016 (set_txt_mode -> _set_mode)
  6383                              <1> ; 17/06/2016
  6384                              <1> ; 29/05/2016
  6385                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  6386                              <1> 
  6387                              <1> _set_mode:
  6388                              <1> 	; 12/12/2020
  6389                              <1> 	; 26/11/2020
  6390                              <1> 	; call from 'biosfn_set_video_mode'
  6391                              <1> 	;	(bochs/plex86 video bios code)
  6392                              <1> 	; call from 'SET_MODE'
  6393                              <1> 	;	(TRDOS 386 v2 default, IBM PC/AT rom bios code)
  6394                              <1> 	; continue from 'set_txt_mode'	
  6395                              <1> 
  6396                              <1> 	; INPUT:
  6397                              <1> 	;	al = VGA video mode
  6398                              <1> 	; RETURN:
  6399                              <1> 	;	cf = 1 -> video mode not implemented
  6400                              <1> 	;	cf = 0 -> OK
  6401                              <1> 	;
  6402                              <1> 	; Modified registers: eax, bx, ecx, esi, edi, (ebp)
  6403                              <1> 
  6404                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  6405                              <1> 	; no clear memory option 
  6406                              <1> 	; (from mode number byte bit 7)
  6407 00001ACC 88C4                <1> 	mov	ah, al
  6408 00001ACE 80E480              <1> 	and	ah, 80h
  6409                              <1> 	;mov	[noclearmem], al
  6410 00001AD1 8825[13840100]      <1> 	mov	[noclearmem], ah
  6411                              <1> 	;and	al, 7Fh ; clear bit 7
  6412                              <1> 	;;xor	[noclearmem], al ; clear bit 0 to 6
  6413                              <1> 	; 26/11/2020
  6414 00001AD7 30E0                <1> 	xor	al, ah ; and al, 7Fh
  6415                              <1> 
  6416                              <1> 	; 19/11/2020
  6417                              <1> 
  6418                              <1> 	; Video mode 03h action principle:
  6419                              <1> 	;
  6420                              <1> 	; for case 1:
  6421                              <1> 	; Current mode is 03h and next/requested mode is not 03h
  6422                              <1> 	;	- save mode (set mode 03h flag)
  6423                              <1> 	;	- save 8 video pages (which are will be restored)	
  6424                              <1> 	;	- save active page number (which will be reactivated)
  6425                              <1> 	;	- set active page to 0 always (no multi screen)
  6426                              <1> 	;	- save 8 cursor positions (which will be restored)
  6427                              <1> 	; 	- use 'noclearmem' option
  6428                              <1> 	;	[p_crt_mode] = 0 -> 03h 
  6429                              <1> 	;
  6430                              <1> 	; for case 2:
  6431                              <1> 	; Current mode is 03h and next/requested mode is also 03h
  6432                              <1> 	;	- clear active video page if 'noclearmem' is not set
  6433                              <1> 	;	[p_crt_mode] = 0 -> 80h -> 0
  6434                              <1> 	;
  6435                              <1> 	; for case 3:
  6436                              <1> 	; Current mode is not 03h and next/requested mode is 03h
  6437                              <1> 	;	- restore video pages (8 video pages were saved)	
  6438                              <1> 	;	- restore active page number (which were saved)
  6439                              <1> 	;	- restore 8 cursor positions (which were saved)
  6440                              <1> 	;	- reset/clear mode 03h flag
  6441                              <1> 	;	[p_crt_mode] = 03h -> 0
  6442                              <1> 	;
  6443                              <1> 	; for case 4:
  6444                              <1> 	; Current mode is not 03h and next/requested mode is not 03h
  6445                              <1> 	; 	- use 'noclearmem' option
  6446                              <1> 	;	- set active page to 0 always
  6447                              <1> 	;	[p_crt_mode] = 03h -> 83h -> 03h
  6448                              <1> 	;
  6449                              <1> 	; initial (boot time) values:
  6450                              <1> 	;	[p_crt_mode] = 0 ("there isn't a page backup, yet")
  6451                              <1> 	;	  [CRT_MODE] = 3 (kernel's starting mode)
  6452                              <1> 
  6453                              <1> 	; 26/11/2020
  6454 00001AD9 3C03                <1> 	cmp	al, 03h	    ; mode 3, 80x25 text, 16 colors
  6455 00001ADB 7515                <1> 	jne	short _sm_0 ; (default mode for TRDOS 386 mainprog)
  6456                              <1> 
  6457                              <1> 	; case 2 or case 3
  6458                              <1> 
  6459                              <1> 	; check current video mode if it is 03h
  6460 00001ADD 08E4                <1> 	or	ah, ah ; 80h or 0 ('noclearmem' option)
  6461 00001ADF 7521                <1> 	jnz	short _sm_1 ; do not clear display page
  6462                              <1>  	
  6463                              <1> 	; 26/11/2020
  6464                              <1> 	; Note:
  6465                              <1> 	; [CRT_MODE] = 0FFh for VESA VBE video modes
  6466                              <1> 	; [video_mode] = standard VGA and VESA VBE video modes
  6467                              <1> 	
  6468 00001AE1 3805[9E660000]      <1> 	cmp	[CRT_MODE], al	; 03h
  6469 00001AE7 7520                <1> 	jne	short _sm_2	; case 3 ([p_crt_mode] = 03h)
  6470                              <1> 
  6471                              <1> 	; case 2
  6472                              <1> 
  6473                              <1> 	; [p_crt_mode] = 0
  6474                              <1> 
  6475                              <1> 	; 19/11/2020
  6476                              <1> 	; If '_set_mode' procedure is called for video mode 3
  6477                              <1> 	;     while video mode is 3, video page will be cleared
  6478                              <1> 	;     and cursor position of video page will be reset.	 
  6479                              <1> 
  6480                              <1> 	; clear display page
  6481 00001AE9 C605[11840100]80    <1> 	mov	byte [p_crt_mode], 80h ; clear page sign
  6482 00001AF0 EB1C                <1> 	jmp	short _sm_3	; bypass save video page routine
  6483                              <1> _sm_0:
  6484                              <1> 	; case 1 or case 4
  6485                              <1> 
  6486                              <1> 	; 05/12/2020
  6487 00001AF2 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h?
  6488 00001AF9 7507                <1> 	jne	short _sm_1	; case 4 ; [p_crt_mode] = 03h
  6489                              <1> 	
  6490                              <1> 	; case 1
  6491                              <1> 	; [p_crt_mode] = 0
  6492                              <1> 
  6493                              <1> 	; 19/11/2020
  6494                              <1> 	; If '_set_mode' procedure is called for a video mode
  6495                              <1> 	;     except video mode 3 while current video mode
  6496                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  6497                              <1> 	;     to 98000h address as backup, before mode change.
  6498                              <1> 	
  6499                              <1> _sm_save_pm:
  6500                              <1> 	; 12/12/2020
  6501                              <1> 	;; 03/07/2016
  6502                              <1> 	;; save video pages
  6503                              <1> 	;mov	esi, 0B8000h
  6504                              <1> 	;mov	edi, 98000h ; 30/07/2016
  6505                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  6506                              <1> 	;rep	movsd
  6507                              <1> 
  6508                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  6509                              <1> 	;; 26/11/2020
  6510                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  6511                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
  6512                              <1> 	;
  6513                              <1> 	;; save cursor positions
  6514                              <1> 	;mov	esi, CURSOR_POSN
  6515                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  6516                              <1> 	;mov	cl, 4
  6517                              <1> 	;rep	movsd
  6518                              <1> 
  6519                              <1> 	; 12/12/2020
  6520 00001AFB E86E020000          <1> 	call	save_mode3_multiscreen
  6521                              <1> 
  6522                              <1> 	; 29/07/2016
  6523                              <1> 	;;mov	[ACTIVE_PAGE], cl ; 0
  6524                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  6525                              <1> 	;mov	[p_crt_page], cl  ; previous page (for mode 3)
  6526                              <1> 	
  6527                              <1> 	; [ACTIVE_PAGE] = 0 
  6528                              <1> 	
  6529 00001B00 EB07                <1> 	jmp	short _sm_2	; case 1 - 19/11/2020
  6530                              <1> _sm_1:
  6531                              <1> 	; 26/11/2020
  6532                              <1> 	; 19/11/2020
  6533                              <1> 	
  6534                              <1> 	; case 4
  6535 00001B02 800D[11840100]80    <1> 	or	byte [p_crt_mode], 80h 
  6536                              <1> 				; here [p_crt_mode] must be 83h
  6537                              <1> 				;	  (for case 4)
  6538                              <1> 				; (because video mode 03h
  6539                              <1> 				; was changed before as in case 1)
  6540                              <1> 
  6541                              <1> _sm_2:	; case 4 (jump to _sm_2) - 19/11/2020 
  6542                              <1> 
  6543                              <1> 	; 19/11/2020
  6544                              <1> 	; case 3
  6545                              <1> 	; If '_set_mode' procedure is called for video mode 3
  6546                              <1> 	;     while video mode is not 3 and if there is video
  6547                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  6548                              <1> 	;     video pages will be restored from 98000h.
  6549                              <1> 
  6550 00001B09 A2[9E660000]        <1> 	mov	[CRT_MODE], al  ; save mode in global variable
  6551                              <1> _sm_3:
  6552                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  6553                              <1> 	; 30/07/2016
  6554                              <1> 	; 26/07/2016
  6555                              <1> 	; 25/07/2016
  6556                              <1> 	; set_mode_vga:
  6557                              <1> 	; 18/07/2016
  6558                              <1> 	; 14/07/2016
  6559                              <1> 	; 09/07/2016
  6560                              <1> 	; 04/07/2016
  6561                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  6562                              <1> 	; /// video mode 13h ///
  6563                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6564                              <1> 	; vgabios-0.7a (2011)
  6565                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6566                              <1> 	; 'vgabios.c', 'vgatables.h'
  6567                              <1> 	;
  6568                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  6569                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  6570                              <1> 	;
  6571 00001B0E 88C4                <1> 	mov	ah, al
  6572 00001B10 B910000000          <1> 	mov	ecx, vga_mode_count
  6573 00001B15 BE[BA660000]        <1> 	mov	esi, vga_modes
  6574 00001B1A 31DB                <1> 	xor	ebx, ebx
  6575                              <1> _sm_4:
  6576 00001B1C AC                  <1> 	lodsb
  6577 00001B1D 38C4                <1> 	cmp	ah, al
  6578 00001B1F 7406                <1> 	je	short _sm_5
  6579 00001B21 FEC3                <1> 	inc	bl
  6580 00001B23 E2F7                <1> 	loop	_sm_4
  6581                              <1> 
  6582                              <1> 	; UNIMPLEMENTED VIDEO MODE !
  6583                              <1> 	;xor	eax, eax
  6584                              <1>         ;mov	[video_eax], eax ; 0
  6585                              <1> 
  6586                              <1> 	; 26/11/2020
  6587 00001B25 F9                  <1> 	stc	; unimplemented video mode ! (cf=1)
  6588                              <1> 
  6589 00001B26 C3                  <1> 	retn
  6590                              <1> 
  6591                              <1> ;-----	EBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE
  6592                              <1> 
  6593                              <1> _sm_5: 	; 25/07/2016
  6594                              <1> 	;mov	esi, ebx
  6595                              <1> 	;add	esi, vga_memmodel
  6596                              <1> 	;mov	al, [esi]
  6597                              <1> 	; 19/11/2020
  6598 00001B27 8A83[0A670000]      <1> 	mov	al, [ebx+vga_memmodel]
  6599 00001B2D A2[2A840100]        <1> 	mov	[VGA_MTYPE], al
  6600                              <1> 
  6601 00001B32 89DF                <1> 	mov	edi, ebx
  6602 00001B34 81C7[1A670000]      <1> 	add	edi, vga_dac_s 	
  6603 00001B3A C0E302              <1> 	shl	bl, 2 ; byte -> dword
  6604 00001B3D 81C3[CA660000]      <1> 	add	ebx, vga_mode_tbl_ptr
  6605                              <1> 
  6606                              <1> 	;mov	dword [VGA_BASE], 0B8000h
  6607                              <1> 	;cmp	ah, 0Dh ; [CRT_MODE]
  6608                              <1> 	;jb	short M9 
  6609                              <1> 	;mov	dword [VGA_BASE], 0A0000h
  6610                              <1> ;M9:
  6611 00001B43 8B33                <1> 	mov	esi, [ebx]
  6612 00001B45 89F3                <1> 	mov	ebx, esi
  6613 00001B47 83C614              <1> 	add	esi, vga_p_cm_pos ; ebx + 20
  6614 00001B4A 668B06              <1> 	mov	ax, [esi]       ; get the cursor mode from the table
  6615 00001B4D 66A3[B7660000]      <1> 	mov	[CURSOR_MODE], ax ; save cursor mode (initial value)
  6616                              <1> 	; al = 6, ah = 7
  6617                              <1> 	; al = 0Dh, ah = 0Eh ; 25/07/2016
  6618 00001B53 E893020000          <1> 	call	cursor_shape_fix
  6619                              <1> 	; al = 14, ah = 15 (If [CHAR_HEIGHT] = 16)
  6620 00001B58 668906              <1> 	mov	[esi], ax
  6621                              <1> 
  6622 00001B5B 56                  <1> 	push	esi ; *	
  6623                              <1> 
  6624                              <1> 	; 17/04/2021
  6625 00001B5C B603                <1> 	mov	dh, 03h
  6626                              <1> 	;
  6627 00001B5E 8A25[A5660000]      <1> 	mov	ah, [VGA_MODESET_CTL]
  6628 00001B64 80E408              <1> 	and	ah, 8 ; default palette loading ?
  6629 00001B67 7520                <1> 	jnz	short _sm_6
  6630                              <1> 	;mov	dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register)
  6631                              <1> 	; 17/04/2021
  6632 00001B69 B2C6                <1> 	mov	dl, 0C6h
  6633 00001B6B B0FF                <1> 	mov	al, 0FFh ; PEL mask
  6634 00001B6D EE                  <1> 	out	dx, al
  6635 00001B6E 8A27                <1> 	mov	ah, [edi] ; DAC model (selection number)
  6636 00001B70 E8F80F0000          <1> 	call	load_dac_palette
  6637                              <1> 	; ecx = 0
  6638 00001B75 F605[A5660000]02    <1> 	test	byte [VGA_MODESET_CTL], 2 ; gray scale summing
  6639 00001B7C 740B                <1> 	jz	short _sm_6
  6640 00001B7E 53                  <1> 	push	ebx
  6641 00001B7F 29DB                <1> 	sub	ebx, ebx ; sub bl, bl
  6642                              <1> 	;mov	cx, 256
  6643                              <1> 	; 02/08/2022
  6644                              <1> 	;sub	ecx, ecx
  6645                              <1> 	; ecx = 0
  6646 00001B81 FEC5                <1> 	inc	ch
  6647                              <1> 	; ecx = 256
  6648 00001B83 E837100000          <1> 	call	gray_scale_summing
  6649 00001B88 5B                  <1> 	pop	ebx	
  6650                              <1> _sm_6:
  6651                              <1> 	; Reset Attribute Ctl flip-flop
  6652                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  6653                              <1>  	; 17/03/2021
  6654 00001B89 B2DA                <1> 	mov	dl, 0DAh ; dx = 3DAh
  6655 00001B8B EC                  <1> 	in	al, dx
  6656                              <1> 	; Set Attribute Ctl
  6657 00001B8C 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  6658 00001B8E 83C623              <1> 	add	esi, 35  ; actl regs
  6659 00001B91 30E4                <1> 	xor	ah, ah ; 0
  6660                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  6661                              <1> 	; 17/04/2021
  6662 00001B93 B2C0                <1> 	mov	dl, 0C0h
  6663                              <1> _sm_7:
  6664 00001B95 88E0                <1> 	mov	al, ah
  6665 00001B97 EE                  <1> 	out	dx, al ; index
  6666 00001B98 AC                  <1> 	lodsb
  6667                              <1> 	; DX = 3C0h = VGAREG_ACTL_WRITE_DATA
  6668 00001B99 EE                  <1> 	out	dx, al ; value
  6669 00001B9A FEC4                <1> 	inc	ah
  6670 00001B9C 80FC14              <1> 	cmp	ah, 20 ; number of actl registers
  6671 00001B9F 72F4                <1> 	jb	short _sm_7
  6672                              <1> 	;
  6673 00001BA1 88E0                <1> 	mov	al, ah ; 20
  6674 00001BA3 EE                  <1> 	out	dx, al ; index
  6675 00001BA4 28C0                <1> 	sub	al, al ; 0
  6676 00001BA6 EE                  <1> 	out	dx, al ; value
  6677                              <1> 	;
  6678                              <1> 	; Set Sequencer Ctl
  6679 00001BA7 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  6680 00001BA9 83C605              <1> 	add	esi, 5 ; sequ regs
  6681                              <1> 	;
  6682                              <1> 	;mov	dx, 3C4h  ; VGAREG_SEQU_ADDRESS
  6683                              <1> 	; 17/04/2021
  6684 00001BAC B2C4                <1> 	mov	dl, 0C4h
  6685 00001BAE EE                  <1> 	out	dx, al ; 0
  6686                              <1> 	;inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  6687                              <1> 	; 17/04/2021
  6688 00001BAF FEC2                <1> 	inc	dl ; dx = 3C5h	
  6689 00001BB1 B003                <1> 	mov	al, 3
  6690 00001BB3 EE                  <1> 	out	dx, al
  6691 00001BB4 B401                <1> 	mov	ah, 1	
  6692                              <1> _sm_8:
  6693 00001BB6 88E0                <1> 	mov	al, ah
  6694                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6695                              <1> 	;dec	dx
  6696                              <1> 	; 17/04/2021
  6697 00001BB8 FECA                <1> 	dec	dl ; dx = 3C4h
  6698 00001BBA EE                  <1> 	out	dx, al ; index
  6699 00001BBB AC                  <1> 	lodsb
  6700                              <1> 	;inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  6701                              <1> 	; 17/04/2021
  6702 00001BBC FEC2                <1> 	inc	dl
  6703 00001BBE EE                  <1> 	out	dx, al
  6704 00001BBF 80FC04              <1> 	cmp	ah, 4 ; number of sequ regs
  6705 00001BC2 7304                <1> 	jnb	short _sm_9		
  6706 00001BC4 FEC4                <1> 	inc	ah 
  6707 00001BC6 EBEE                <1> 	jmp	short _sm_8
  6708                              <1> _sm_9:
  6709                              <1> 	; Set Grafx Ctl
  6710 00001BC8 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  6711 00001BCA 83C637              <1> 	add	esi, 55 ; grdc regs
  6712 00001BCD 30E4                <1> 	xor	ah, ah ; 0
  6713                              <1> _sm_10:
  6714 00001BCF 88E0                <1> 	mov	al, ah
  6715                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6716                              <1> 	; 17/04/2021
  6717 00001BD1 B2CE                <1> 	mov	dl, 0CEh
  6718 00001BD3 EE                  <1> 	out	dx, al	
  6719 00001BD4 AC                  <1> 	lodsb
  6720                              <1> 	;inc	dx ; 3CFh ; VGAREG_GRDC_DATA
  6721                              <1> 	; 17/04/2021
  6722 00001BD5 FEC2                <1> 	inc	dl ; 3CFh
  6723 00001BD7 EE                  <1> 	out	dx, al
  6724 00001BD8 FEC4                <1> 	inc	ah
  6725 00001BDA 80FC09              <1> 	cmp	ah, 9 ; number of grdc regs
  6726 00001BDD 72F0                <1> 	jb	short _sm_10
  6727                              <1> 	;
  6728                              <1> 	; Disable CRTC write protection
  6729                              <1> 	;mov	dx, 3D4h  ; VGAREG_VGA_CRTC_ADDRESS
  6730                              <1> 	; 17/04/2021
  6731 00001BDF B2D4                <1> 	mov	dl, 0D4h
  6732                              <1> 	;mov	al, 11h
  6733                              <1> 	;out	dx, al
  6734                              <1> 	;inc	dx
  6735                              <1> 	;sub	al, al
  6736                              <1> 	;out	dx, al
  6737 00001BE1 66B81100            <1> 	mov	ax, 11h
  6738 00001BE5 66EF                <1> 	out	dx, ax
  6739 00001BE7 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  6740 00001BE9 83C60A              <1> 	add	esi, 10 ; crtc regs
  6741                              <1> 	; ah = 0
  6742                              <1> _sm_11:
  6743 00001BEC 88E0                <1> 	mov	al, ah
  6744                              <1> 	; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS
  6745 00001BEE EE                  <1> 	out	dx, al ; index
  6746 00001BEF AC                  <1> 	lodsb
  6747                              <1> 	;inc	dx  ; VGAREG_VGA_CRTC_ADDRESS + 1
  6748                              <1> 	; 17/04/2021
  6749 00001BF0 FEC2                <1> 	inc	dl
  6750 00001BF2 EE                  <1> 	out	dx, al ; value
  6751 00001BF3 80FC18              <1> 	cmp	ah, 24 ; number of crtc registers - 1
  6752 00001BF6 7306                <1> 	jnb	short _sm_12
  6753 00001BF8 FEC4                <1> 	inc	ah
  6754                              <1> 	;dec	dx ; 3D4h
  6755                              <1> 	; 17/04/2021
  6756 00001BFA FECA                <1> 	dec	dl
  6757 00001BFC EBEE                <1> 	jmp	short _sm_11
  6758                              <1> _sm_12:
  6759                              <1> 	; Set the misc register
  6760                              <1> 	;mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  6761                              <1> 	; 17/04/2021
  6762 00001BFE B2CC                <1> 	mov	dl, 0CCh
  6763 00001C00 8A4309              <1> 	mov	al, [ebx+9] ; misc reg
  6764 00001C03 EE                  <1> 	out	dx, al
  6765                              <1> 	;
  6766                              <1> 	; Enable video
  6767                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  6768                              <1> 	; 17/04/2021
  6769 00001C04 B2C0                <1> 	mov	dl, 0C0h
  6770 00001C06 B020                <1> 	mov	al, 20h  
  6771 00001C08 EE                  <1>         out     dx, al   ; set bit 5 to 1
  6772                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  6773                              <1> 	; 17/04/2021
  6774 00001C09 B2DA                <1> 	mov	dl, 0DAh
  6775 00001C0B EC                  <1> 	in	al, dx
  6776                              <1> 	;
  6777                              <1> 	; 17/11/2020
  6778                              <1> 	;cmp	byte [noclearmem], 0
  6779                              <1>         ;ja	short _sm_15
  6780                              <1> 
  6781 00001C0C F605[13840100]80    <1> 	test	byte [noclearmem], 80h
  6782 00001C13 753B                <1> 	jnz	short _sm_15	
  6783                              <1> 
  6784                              <1> 	; 29/07/2016
  6785 00001C15 31C0                <1> 	xor	eax, eax
  6786                              <1> 	;mov	ecx, 4000h ; 16K words (32K)
  6787                              <1> 	; 02/08/2022
  6788 00001C17 29C9                <1> 	sub	ecx, ecx
  6789 00001C19 B540                <1> 	mov	ch, 40h
  6790                              <1> 	; ecx = 4000h 
  6791 00001C1B 803D[2A840100]02    <1> 	cmp     byte [VGA_MTYPE], 2  ; CTEXT, MTEXT, CGA
  6792 00001C22 7715                <1> 	ja	short _sm_14    ; no ? (0A0000h)
  6793 00001C24 BF00800B00          <1> 	mov	edi, 0B8000h
  6794 00001C29 7409                <1> 	je	short _sm_13	; CGA graphics mode
  6795                              <1> 	; 08/08/2016
  6796 00001C2B A3[26840100]        <1> 	mov	[VGA_INT43H], eax ; 0 ; default font 
  6797 00001C30 66B82007            <1> 	mov	ax, 0720h	; CGA text mode
  6798                              <1> _sm_13:
  6799 00001C34 F366AB              <1> 	rep	stosw
  6800 00001C37 EB17                <1> 	jmp	short _sm_15
  6801                              <1> 
  6802                              <1> _sm_14:
  6803 00001C39 BF00000A00          <1> 	mov	edi, 0A0000h
  6804                              <1> 	; ecx = 16384 dwords (64K)
  6805                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6806                              <1> 	; 17/04/2021
  6807 00001C3E B2C4                <1> 	mov	dl, 0C4h
  6808 00001C40 B002                <1> 	mov	al, 2
  6809 00001C42 EE                  <1> 	out	dx, al
  6810                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
  6811                              <1> 	;inc	dx
  6812                              <1> 	; 17/04/2021
  6813 00001C43 FEC2                <1> 	inc	dl ; 3C5h
  6814 00001C45 EC                  <1> 	in	al, dx ; mmask
  6815                              <1> 	;push	ax
  6816                              <1> 	; 12/04/2021
  6817 00001C46 50                  <1> 	push	eax
  6818 00001C47 B00F                <1> 	mov	al, 0Fh ; all planes
  6819 00001C49 EE                  <1> 	out	dx, al
  6820 00001C4A 30C0                <1> 	xor	al, al ; 0
  6821 00001C4C F3AB                <1> 	rep	stosd	; ecx = 163684 (64K)
  6822                              <1> 	;pop	ax
  6823                              <1> 	; 12/04/2021
  6824 00001C4E 58                  <1> 	pop	eax
  6825 00001C4F EE                  <1> 	out	dx, al  ; mmask
  6826                              <1> _sm_15:
  6827                              <1> 	; ebx = addr of params tbl for selected mode
  6828                              <1> 	; 10/08/2016
  6829 00001C50 668B03              <1> 	mov	ax, [ebx] ; num of columns, 'twidth'
  6830 00001C53 A2[A0660000]        <1> 	mov	[CRT_COLS], al
  6831                              <1> 	;; 26/07/2016
  6832                              <1> 	;; CRTC_ADDRESS = 3D4h (always)
  6833                              <1> 	;mov	ah, [ebx+1] ; num of rows, 'theightm1'
  6834 00001C58 FEC4                <1> 	inc	ah ; 09/07/2016
  6835 00001C5A 8825[A6660000]      <1> 	mov	[VGA_ROWS], ah
  6836                              <1> 	; 10/08/2016
  6837 00001C60 8A4302              <1> 	mov	al, [ebx+2]
  6838 00001C63 A2[A2660000]        <1> 	mov	[CHAR_HEIGHT], al 
  6839                              <1> 	; 29/07/2016
  6840                              <1> 	; length of regen buffer in bytes
  6841 00001C68 668B4B03            <1> 	mov	cx, [ebx+3] ; 'slength_l'
  6842 00001C6C 66890D[14840100]    <1> 	mov	[CRT_LEN], cx
  6843                              <1> 	;
  6844                              <1> 	; 27/07/2016
  6845 00001C73 30E4                <1> 	xor	ah, ah
  6846 00001C75 A0[AE770100]        <1> 	mov	al, [ACTIVE_PAGE] ; may be > 0 for mode 3
  6847                              <1> 	;mul	word [CRT_LEN] ; 4096 for mode 3
  6848 00001C7A 66F7E1              <1> 	mul	cx ; 29/07/2016
  6849 00001C7D 66A3[9C770100]      <1> 	mov	[CRT_START], ax
  6850                              <1> 	;
  6851 00001C83 B060                <1> 	mov	al, 60h
  6852                              <1> 	;cmp	byte [noclearmem], 0
  6853                              <1> 	;jna	short _sm_16
  6854                              <1> 	;add	al, 80h
  6855 00001C85 0A05[13840100]      <1> 	or	al, [noclearmem] ; 17/11/2020
  6856                              <1> _sm_16:
  6857 00001C8B A2[A3660000]        <1> 	mov	[VGA_VIDEO_CTL], al
  6858 00001C90 C605[A4660000]F9    <1> 	mov	byte [VGA_SWITCHES], 0F9h
  6859 00001C97 8025[A5660000]7F    <1> 	and	byte [VGA_MODESET_CTL], 7Fh
  6860                              <1> 
  6861 00001C9E 5E                  <1> 	pop	esi ; *
  6862                              <1> 
  6863                              <1> 	; 26/07/2016
  6864                              <1> 	; 07/07/2016
  6865 00001C9F 668B0D[B7660000]    <1> 	mov	cx, [CURSOR_MODE] ; restore cursor mode (initial value)
  6866 00001CA6 66870E              <1> 	xchg	cx, [esi] ; cl = start line, ch = end line
  6867                              <1> 			  ; reset to initial value
  6868 00001CA9 86E9                <1> 	xchg 	ch, cl  ; ch = start line, cl = end line  
  6869 00001CAB 66890D[B7660000]    <1> 	mov	[CURSOR_MODE], cx ; save (fixed) cursor mode
  6870                              <1> 
  6871                              <1> 	; 27/07/2016
  6872 00001CB2 803D[2A840100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  6873 00001CB9 7317                <1> 	jnb	short _sm_17
  6874                              <1> 
  6875                              <1> 	; Set cursor shape
  6876                              <1> 	;mov	cx, 0607h
  6877                              <1> 	;call	_set_ctype
  6878                              <1> 
  6879                              <1> 	; 29/07/2016
  6880 00001CBB B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  6881 00001CBD E81F060000          <1> 	call	m16	; output cx register
  6882                              <1> 	
  6883                              <1> 	; 25/07/2016
  6884 00001CC2 803D[9E660000]03    <1>         cmp     byte [CRT_MODE], 03h
  6885 00001CC9 7507                <1> 	jne	short _sm_17
  6886                              <1> 	; 26/07/2016
  6887                              <1> 
  6888 00001CCB A0[AE770100]        <1> 	mov	al, [ACTIVE_PAGE]
  6889 00001CD0 EB0B                <1> 	jmp	short _sm_18
  6890                              <1> _sm_17:
  6891                              <1> 	; Set cursor pos for page 0..7
  6892                              <1> 	;sub	ax, ax ; eax = 0
  6893 00001CD2 29C0                <1> 	sub	eax, eax ; 17/11/2020
  6894 00001CD4 BF[9E770100]        <1> 	mov	edi, CURSOR_POSN
  6895 00001CD9 AB                  <1> 	stosd	
  6896 00001CDA AB                  <1> 	stosd
  6897 00001CDB AB                  <1> 	stosd
  6898 00001CDC AB                  <1> 	stosd
  6899                              <1> 	;; Set active page 0
  6900                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  6901                              <1> _sm_18:
  6902                              <1> 	; 29/07/2016
  6903 00001CDD 803D[2A840100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  6904                              <1> 	;jnb	_sm_23
  6905                              <1> 	; 04/08/2022
  6906 00001CE4 7205                <1> 	jb	short _sm_24
  6907 00001CE6 E90C020000          <1> 	jmp	_set_active_page
  6908                              <1> _sm_24:
  6909                              <1> 	;cmp	byte [CHAR_HEIGHT], 16
  6910                              <1> 	;je	short _sm_19
  6911                              <1> 
  6912                              <1>  	;; copy and activate 8x16 font
  6913                              <1> 	
  6914                              <1> 	; 26/07/2016
  6915 00001CEB B004                <1> 	mov	al, 04h
  6916                              <1> 	;sub	bl, bl
  6917                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set
  6918                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6919 00001CED E844160000          <1> 	call	load_text_8_16_pat
  6920                              <1> 
  6921                              <1> 	; video_func_1103h:
  6922                              <1> 	; biosfn_set_text_block_specifier:
  6923                              <1> 	; BL = font block selector code	
  6924                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  6925                              <1> 	; (It is as BL = 0 for TRDOS 386)
  6926 00001CF2 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6927                              <1> 	;;mov	ah, bl
  6928                              <1> 	;sub	ah, ah ; 0
  6929                              <1> 	;mov	al, 03h
  6930                              <1> 	; 19/11/2020
  6931 00001CF6 66B80300            <1> 	mov	ax, 03h
  6932 00001CFA 66EF                <1> 	out	dx, ax
  6933                              <1> _sm_19:
  6934                              <1> 	; 29/07/2016
  6935                              <1> 	; 26/07/2016
  6936                              <1> 	; 24/06/2016
  6937                              <1> 	;mov	edi, 0B8000h
  6938                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  6939                              <1> 	;
  6940 00001CFC 30C0                <1> 	xor	al, al
  6941 00001CFE 3805[11840100]      <1>         cmp     [p_crt_mode], al ; 0 
  6942 00001D04 7705                <1>         ja      short _sm_20 ; 03h, 80h or 83h
  6943                              <1> 
  6944                              <1> 	; case 1 - 19/11/2020
  6945                              <1> 	;
  6946                              <1> 	; If [pc_crt_mode] = 0, that means, previous mode is 03h
  6947                              <1> 	; and current mode is not 03h (case 1)
  6948                              <1> 
  6949                              <1> 	; 30/07/2016
  6950                              <1> 	; 24/06/2016
  6951                              <1> 	; TRDOS 386 (TRDOS v2) 'set mode' modification
  6952                              <1> 	; (for multiscreen feature):
  6953                              <1> 	; If '_set_mode' procedure is called for video mode 3
  6954                              <1> 	;     while video mode is 3, video page will be cleared
  6955                              <1> 	;     and cursor position of video page will be reset.
  6956                              <1> 	; If '_set_mode' procedure is called for a video mode
  6957                              <1> 	;     except video mode 3, while current video mode
  6958                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  6959                              <1> 	;     to 98000h address as backup, before mode change.
  6960                              <1> 	; If '_set_mode' procedure is called for video mode 3
  6961                              <1> 	;     while video mode is not 3 and if there is video
  6962                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  6963                              <1> 	;     video pages will be restored from 98000h.
  6964                              <1> 
  6965                              <1> 	; 19/11/2020
  6966                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  6967                              <1> 
  6968                              <1> 	; Here,
  6969                              <1> 	; video memory already cleared if [noclearmem] <> 80h
  6970                              <1> 	
  6971                              <1> 	;mov	ax, 0720h
  6972                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  6973                              <1> 	;mov	edi, 0B8000h
  6974                              <1> 	;rep	stosw
  6975                              <1> 	;sub	al, al
  6976                              <1> 	
  6977                              <1> 	;jmp	short _sm_23
  6978                              <1> 
  6979                              <1> 	; Set hardware side for the new active video page
  6980                              <1>  
  6981 00001D06 E9EC010000          <1> 	jmp	_set_active_page ; 19/11/2020	
  6982                              <1> 
  6983                              <1> _sm_20:
  6984                              <1> 	; 19/11/2020
  6985                              <1> 	; case 2 or case 3 or case 4 - 19/11/2020
  6986                              <1> 	
  6987                              <1> 	; 19/11/2020
  6988 00001D0B 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  6989 00001D12 754E                <1> 	jne	short _sm_22 ; al = 0 (& video mode <> 03h)
  6990                              <1> 			     ; case 4 - 19/11/2020
  6991                              <1> 			     ; ([p_crt_mode] = 83h)
  6992                              <1> 
  6993                              <1> 	; case 2 or case 3 - 19/11/2020	
  6994                              <1> 
  6995                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  6996                              <1> 	; 19/11/2020
  6997 00001D14 A0[12840100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  6998                              <1> 	;movzx	ebx, al
  6999                              <1> 	;shl	bl, 1 ; * 2
  7000                              <1> 	;add	ebx, CURSOR_POSN
  7001                              <1> 
  7002                              <1> 	; 29/07/2016
  7003 00001D19 F605[11840100]7F    <1> 	test    byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  7004 00001D20 740F                <1> 	jz	short _sm_21	; do not restore video pages
  7005                              <1> 				; case 2 - 19/11/2020 
  7006                              <1> 	; case 3 - 19/11/2020
  7007                              <1> 
  7008                              <1> 	; ([p_crt_mode] = 03h)
  7009                              <1> 
  7010                              <1> 	; New video mode is 3 while current video mode is not 3
  7011                              <1> 	; (multi screen) video pages will be restored from 098000h
  7012                              <1> 
  7013                              <1> 	; 19/11/2020
  7014 00001D22 A2[AE770100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  7015                              <1> 
  7016                              <1> 	; 12/12/2020
  7017                              <1> 	;; restore video pages
  7018                              <1> 	;mov	esi, 98000h ; 30/07/2016 
  7019                              <1> 	;mov	edi, 0B8000h
  7020                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  7021                              <1> 	;rep	movsd
  7022                              <1> 	;
  7023                              <1> 	;; 19/11/2020
  7024                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  7025                              <1> 	;
  7026                              <1> 	;; restore cursor positions
  7027                              <1> 	;mov	esi, cursor_pposn
  7028                              <1> 	;mov	edi, CURSOR_POSN
  7029                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  7030                              <1> 	;mov	cl, 4
  7031                              <1> 	;rep 	movsd
  7032                              <1> 	
  7033                              <1> 	; 12/12/2020
  7034 00001D27 E89A000000          <1> 	call	_restore_mode3_multiscreen
  7035                              <1> 
  7036                              <1> 	;jmp	short _sm_23 ; do not clear current video pages
  7037                              <1> 
  7038                              <1> 	; 19/11/2020
  7039 00001D2C E9C6010000          <1> 	jmp	_set_active_page
  7040                              <1> 
  7041                              <1> _sm_21:
  7042                              <1> 	; 19/11/2020
  7043                              <1> 	; case 2 
  7044                              <1> 	;
  7045                              <1> 	; ([p_crt_mode] = 80h)
  7046                              <1> 	;
  7047                              <1> 	; User has requested to set video mode 3 again while
  7048                              <1> 	; current video mode is 3.. that means, set mode 03h
  7049                              <1> 	; parameters again and clear video page.
  7050                              <1> 	; ('noclearmem' option effects the result) 
  7051                              <1> 	
  7052                              <1> 	; 19/11/2020
  7053 00001D31 F605[13840100]80    <1> 	test	byte [noclearmem], 80h
  7054 00001D38 7528                <1> 	jnz	short _sm_22	; 'do not clear video memory'
  7055                              <1> 				; continue with current text
  7056                              <1> 				; (user's option/choice) 
  7057                              <1> 	; clear video page
  7058                              <1> 	;mov	cx, [CRT_LEN] ; 4096
  7059                              <1> 	;shr	cx, 1 ; 2048 ; 16/11/2020
  7060 00001D3A 66B82007            <1> 	mov	ax, 0720h
  7061                              <1> 	; 26/11/2020
  7062                              <1> 	;mov	ecx, 2048 ; 4096/2
  7063                              <1> 	; 02/08/2022
  7064 00001D3E 29C9                <1> 	sub	ecx, ecx
  7065 00001D40 B508                <1> 	mov	ch, 08h
  7066                              <1> 	; ecx = 0800h
  7067 00001D42 BF00800B00          <1> 	mov	edi, 0B8000h ; [crt_base]
  7068 00001D47 66033D[9C770100]    <1> 	add	di, [CRT_START]
  7069 00001D4E F366AB              <1> 	rep	stosw	; FILL THE REGEN BUFFER WITH BLANKS
  7070                              <1> 	;
  7071                              <1> 	; 19/11/2020
  7072 00001D51 A0[AE770100]        <1> 	mov	al, [ACTIVE_PAGE] ; 0 to 7 (for video mode 3)
  7073 00001D56 0FB6D8              <1> 	movzx	ebx, al
  7074 00001D59 D0E3                <1> 	shl	bl, 1
  7075 00001D5B 66898B[9E770100]    <1> 	mov	[ebx+CURSOR_POSN], cx ; reset cursor position
  7076                              <1> _sm_22:
  7077                              <1> 	;mov	[p_crt_mode], al ; 0 ; reset
  7078                              <1> 	; 19/11/2020
  7079                              <1> 	;and	byte [p_crt_mode], 3 ; 83h -> 3, 80h -> 0  
  7080 00001D62 8025[11840100]7F    <1> 	and	byte [p_crt_mode], 7Fh ; 83h -> 3, 80h -> 0
  7081                              <1> _sm_23:
  7082                              <1> 	; al = video page number
  7083                              <1> 	; [CRT_LEN] = length of regen buffer in bytes
  7084                              <1> 	;call	_set_active_page
  7085                              <1> 	; 16/11/2020
  7086 00001D69 E989010000          <1> 	jmp	_set_active_page
  7087                              <1> 
  7088                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  7089                              <1> 	;retn
  7090                              <1> 
  7091                              <1> save_mode3_multiscreen:
  7092                              <1> 	; 02/08/2022 (TRDOS v2.0.5)
  7093                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  7094                              <1> 	; save mode 03h video pages and cursor positions
  7095                              <1> 	;
  7096                              <1> 	; Modified registers: ecx (=0), esi, edi
  7097                              <1> 	
  7098                              <1> 	; 12/12/2020
  7099                              <1> 	; moved here from '_set_mode'	
  7100                              <1> 	; 03/07/2016
  7101                              <1> 	; save video pages
  7102 00001D6E BE00800B00          <1> 	mov	esi, 0B8000h
  7103 00001D73 BF00800900          <1> 	mov	edi, 98000h ; 30/07/2016
  7104                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  7105                              <1> 	; 02/08/2022
  7106 00001D78 29C9                <1> 	sub	ecx, ecx
  7107 00001D7A B520                <1> 	mov	ch, 20h
  7108                              <1> 	; ecx = 2000h 
  7109 00001D7C F3A5                <1> 	rep	movsd
  7110                              <1> 	
  7111 00001D7E C605[11840100]03    <1> 	mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  7112                              <1> 	; 26/11/2020
  7113 00001D85 860D[AE770100]      <1> 	xchg	cl, [ACTIVE_PAGE]
  7114 00001D8B 880D[12840100]      <1> 	mov	[p_crt_page], cl  ; save as previous active page
  7115                              <1> 	
  7116                              <1> 	; save cursor positions
  7117 00001D91 BE[9E770100]        <1> 	mov	esi, CURSOR_POSN
  7118 00001D96 BF[16840100]        <1> 	mov	edi, cursor_pposn ; cursor positions backup
  7119 00001D9B B104                <1> 	mov	cl, 4
  7120 00001D9D F3A5                <1> 	rep	movsd
  7121 00001D9F C3                  <1> 	retn
  7122                              <1> 
  7123                              <1> restore_mode3_multiscreen:
  7124                              <1> 	; 02/08/2022 (TRDOS v2.0.5)
  7125                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  7126                              <1> 	; restore mode 03h video pages and cursor positions
  7127                              <1> 	;
  7128                              <1> 	; Input:
  7129                              <1> 	;    settings from the last 'save_mode3_multiscreen'
  7130                              <1> 	;
  7131                              <1> 	; Output: 
  7132                              <1> 	;    AL = active video page = [ACTIVE_PAGE]
  7133                              <1> 	;
  7134                              <1> 	; Modified registers: al, ecx (=0), esi, edi
  7135                              <1> 
  7136 00001DA0 A0[12840100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  7137 00001DA5 A2[AE770100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  7138                              <1> 
  7139                              <1> 	; 12/12/2020
  7140                              <1> 	; moved here from 'vesa_vbe3_pmi'	
  7141                              <1> 
  7142                              <1> 	; 07/12/2020
  7143                              <1> 	; restore CRT_START according to ACTIVE_PAGE
  7144                              <1> 	;mov	[CRT_START], cx ; 0
  7145                              <1> 	; 12/12/2020
  7146 00001DAA 66C705[9C770100]00- <1> 	mov	word [CRT_START], 0
  7147 00001DB2 00                  <1>
  7148                              <1> 
  7149                              <1> 	; check active page and set it again if it is not 0
  7150 00001DB3 08C0                <1> 	or	al, al
  7151                              <1> 	;;jz	short vbe3_pmi_7
  7152                              <1> 	;jz	short _restore_mode3_multiscreen
  7153 00001DB5 740F                <1> 	jz	short r_m3_ms_1
  7154 00001DB7 88C1                <1> 	mov	cl, al
  7155                              <1> ;vbe3_pmi_5:
  7156                              <1> r_m3_ms_0:
  7157 00001DB9 668105[9C770100]00- <1> 	add	word [CRT_START], 4096
  7158 00001DC1 10                  <1>
  7159 00001DC2 FEC9                <1> 	dec	cl
  7160                              <1> 	;jnz	short vbe3_pmi_5
  7161 00001DC4 75F3                <1> 	jnz	short r_m3_ms_0
  7162                              <1> r_m3_ms_1:
  7163                              <1> 	; 12/12/2020
  7164                              <1> 	; moved here from '_set_mode'	
  7165                              <1> _restore_mode3_multiscreen:
  7166                              <1> 	; Modified registers: ecx, esi, edi
  7167                              <1> 
  7168                              <1> 	; restore video pages
  7169 00001DC6 BE00800900          <1> 	mov	esi, 98000h ; 30/07/2016 
  7170 00001DCB BF00800B00          <1> 	mov	edi, 0B8000h
  7171                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  7172                              <1> 	;mov	ecx, 2000h
  7173                              <1> 	; 02/08/2022
  7174 00001DD0 29C9                <1> 	sub	ecx, ecx
  7175 00001DD2 B520                <1> 	mov	ch, 20h
  7176                              <1> 	; ecx = 2000h 
  7177 00001DD4 F3A5                <1> 	rep	movsd
  7178                              <1> 
  7179                              <1> 	; 19/11/2020
  7180 00001DD6 880D[11840100]      <1> 	mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  7181                              <1> 
  7182                              <1> 	; restore cursor positions
  7183 00001DDC BE[16840100]        <1> 	mov	esi, cursor_pposn
  7184 00001DE1 BF[9E770100]        <1> 	mov	edi, CURSOR_POSN
  7185                              <1> 	;mov	ecx, 4	; restore all cursor positions (16 bytes)
  7186 00001DE6 B104                <1> 	mov	cl, 4
  7187 00001DE8 F3A5                <1> 	rep 	movsd
  7188 00001DEA C3                  <1> 	retn
  7189                              <1> 
  7190                              <1> cursor_shape_fix:
  7191                              <1> 	; 12/04/2021
  7192                              <1> 	; 07/07/2016
  7193                              <1> 	; (Cursor start and cursor end line values -6,7-
  7194                              <1> 	; will be fixed depending on character height)
  7195                              <1> 	;
  7196                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7197                              <1> 	; vgabios-0.7a (2011)
  7198                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7199                              <1> 	; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)'
  7200                              <1> 	;
  7201                              <1> 	; INPUT ->
  7202                              <1> 	;	AL = cursor start line (=6)
  7203                              <1> 	;	AH = cursor end line (=7)
  7204                              <1> 	; OUTPUT ->
  7205                              <1> 	;	AL = cursor start line (=14)
  7206                              <1> 	;	AH = cursor end line (=15)
  7207                              <1> 	;
  7208                              <1> 	;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20))
  7209                              <1> 
  7210                              <1> 	;test	byte [VGA_MODESET_CTL], 1 ; VGA active
  7211                              <1> 	;jz	short csf_3
  7212 00001DEB 803D[A2660000]08    <1> 	cmp	byte [CHAR_HEIGHT], 8
  7213 00001DF2 7647                <1> 	jna	short csf_3
  7214 00001DF4 80FC08              <1> 	cmp	ah, 8
  7215 00001DF7 7342                <1> 	jnb	short csf_3
  7216 00001DF9 3C20                <1> 	cmp	al, 20h
  7217 00001DFB 733E                <1> 	jnb	short csf_3
  7218                              <1> 	;
  7219                              <1> 	;push	ax
  7220                              <1> 	; 12/04/2021
  7221 00001DFD 50                  <1> 	push	eax
  7222                              <1> 	; {
  7223                              <1>    	; if(CL!=(CH+1))	
  7224 00001DFE FEC0                <1> 	inc	al
  7225 00001E00 38C4                <1> 	cmp	ah, al   ; ah != al + 1
  7226 00001E02 740F                <1>         je      short csf_1
  7227                              <1> 	; CH = ((CH+1) * cheight / 8) -1;
  7228 00001E04 8A25[A2660000]      <1> 	mov	ah, [CHAR_HEIGHT]
  7229 00001E0A F6E4                <1> 	mul	ah
  7230 00001E0C C0E803              <1> 	shr	al, 3 ; / 8
  7231 00001E0F FEC8                <1> 	dec	al ; - 1
  7232 00001E11 EB0E                <1> 	jmp	short csf_2 
  7233                              <1> csf_1: 	
  7234                              <1>  	; }
  7235                              <1>    	; else		; ah = al + 1
  7236                              <1>     	; {
  7237 00001E13 FEC4                <1> 	inc	ah	; ah = ah + 1   
  7238                              <1> 	; CH = ((CL+1) * cheight / 8) - 2;
  7239 00001E15 A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  7240 00001E1A F6E4                <1> 	mul	ah
  7241 00001E1C C0E803              <1> 	shr	al, 3 ; / 8
  7242 00001E1F 2C02                <1> 	sub	al, 2 ; - 2
  7243                              <1> 	; al = 14 (if [CHAR_HEIGHT] = 16)
  7244                              <1> csf_2:
  7245 00001E21 880424              <1> 	mov	[esp], al
  7246 00001E24 8A642401            <1> 	mov	ah, [esp+1]
  7247                              <1> 	; CL = ((CL+1) * cheight / 8) - 1;
  7248 00001E28 FEC4                <1> 	inc	ah 
  7249 00001E2A A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  7250 00001E2F F6E4                <1> 	mul	ah
  7251 00001E31 C0E803              <1> 	shr	al, 3 ; / 8
  7252 00001E34 FEC8                <1> 	dec	al ; - 1
  7253 00001E36 88442401            <1> 	mov	[esp+1], al
  7254                              <1> 	; ah = 15 (if [CHAR_HEIGHT] = 16)
  7255                              <1> 	;
  7256                              <1> 	;pop	ax
  7257                              <1> 	; 12/04/2021
  7258 00001E3A 58                  <1> 	pop	eax
  7259                              <1> csf_3:
  7260 00001E3B C3                  <1> 	retn
  7261                              <1> 
  7262                              <1> SET_CTYPE:
  7263                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  7264                              <1> 	; 12/09/2016
  7265                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7266 00001E3C 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7
  7267                              <1> 	;ja	VIDEO_RETURN ; 12/09/2016
  7268                              <1> 	; 04/08/2022
  7269 00001E43 7738                <1> 	ja	short set_cpos_inv_vp
  7270 00001E45 E805000000          <1> 	call	_set_ctype
  7271 00001E4A E96CFCFFFF          <1>         jmp     VIDEO_RETURN
  7272                              <1> 
  7273                              <1> _set_ctype:
  7274                              <1> 	; 02/09/2014 (Retro UNIX 386 v1)
  7275                              <1> 	;
  7276                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7277                              <1> 
  7278                              <1> 	; (CH) = BITS 4-0 = START LINE FOR CURSOR
  7279                              <1> 	;  ** HARDWARE WILL ALWAYS CAUSE BLINK
  7280                              <1> 	;  ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING
  7281                              <1> 	;     OR NO CURSOR AT ALL
  7282                              <1> 	; (CL) = BITS 4-0 = END LINE FOR CURSOR
  7283                              <1> 
  7284                              <1> ;------------------------------------------------
  7285                              <1> ; SET_CTYPE
  7286                              <1> ;	THIS ROUTINE SETS THE CURSOR VALUE
  7287                              <1> ; INPUT
  7288                              <1> ;	(CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE
  7289                              <1> ; OUTPUT	
  7290                              <1> ;	NONE
  7291                              <1> ;------------------------------------------------
  7292                              <1> 	
  7293                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  7294                              <1> 	;
  7295                              <1> 	; 07/07/2016
  7296                              <1> 	; Fixing cursor start and stop line depending on
  7297                              <1> 	; current character height (=16)
  7298                              <1> 	; (Note: Default/initial values are 6 and 7.
  7299                              <1> 	; If set values are 6 (start) & 7 (stop) and 
  7300                              <1> 	; [CHAR_HEIGHT] = 16 :
  7301                              <1> 	; After fixing, start line will be 14, stop line
  7302                              <1> 	; will be 15.)
  7303                              <1> 
  7304                              <1> 	;mov	ax, cx
  7305                              <1> 	; 02/08/2022
  7306 00001E4F 89C8                <1> 	mov	eax, ecx
  7307                              <1> 
  7308 00001E51 86C4                <1> 	xchg	al, ah
  7309                              <1> 	; AL = start line, AH = stop line
  7310 00001E53 E893FFFFFF          <1> 	call	cursor_shape_fix
  7311                              <1> 	; AL = start line (fixed), AH = stop line (fixed)
  7312                              <1> 	;mov	cx, ax
  7313                              <1> 	; 02/08/2022
  7314 00001E58 89C1                <1> 	mov	ecx, eax
  7315 00001E5A 86E9                <1> 	xchg	ch, cl
  7316                              <1> 	; CH = start line (fixed), CL = stop line (fixed)
  7317                              <1> 	;
  7318 00001E5C B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  7319 00001E5E 66890D[B7660000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  7320                              <1> 	;call	m16	; output cx register
  7321                              <1> 	;retn
  7322 00001E65 E977040000          <1>         jmp     m16
  7323                              <1> 
  7324                              <1> SET_CPOS:
  7325                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  7326                              <1> 	; 12/09/2016
  7327                              <1> 	; 07/07/2016
  7328                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7329 00001E6A 80FF07              <1> 	cmp	bh, 7 ; video page > 7 ; 07/07/2016
  7330                              <1> 	;ja	VIDEO_RETURN
  7331                              <1> 	; 02/08/2022
  7332 00001E6D 770E                <1> 	ja	short set_cpos_inv_vp
  7333                              <1> 	;
  7334 00001E6F 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7
  7335 00001E76 770A                <1> 	ja	short vga_set_cpos ; 12/09/2016	
  7336 00001E78 E839040000          <1> 	call	_set_cpos
  7337                              <1> set_cpos_inv_vp:   ; 02/08/2022
  7338 00001E7D E939FCFFFF          <1>         jmp     VIDEO_RETURN
  7339                              <1> 
  7340                              <1> vga_set_cpos:
  7341                              <1> 	; 12/09/2016
  7342                              <1> 	; 09/07/2016
  7343                              <1> 	; set cursor position
  7344                              <1> 	; NOTE: Hardware cursor position will not be set
  7345                              <1> 	;   in any VGA modes (>7)
  7346                              <1> 	;   But, cursor position will be saved into
  7347                              <1> 	;   [CURSOR_POSN].
  7348                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  7349                              <1> 	;   (page 0) for all graphics modes.
  7350                              <1> 
  7351 00001E82 668915[9E770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  7352                              <1> 	; 04/08/2016
  7353                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  7354                              <1> 	;call	_set_cpos
  7355 00001E89 E92DFCFFFF          <1> 	jmp     VIDEO_RETURN
  7356                              <1> 
  7357                              <1> READ_CURSOR:
  7358                              <1> 	; 12/09/2016
  7359                              <1> 	; 07/07/2016
  7360                              <1> 	; 12/05/2016
  7361                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7362                              <1> 	;
  7363                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7364                              <1> 
  7365                              <1> ;------------------------------------------------------
  7366                              <1> ; READ_CURSOR
  7367                              <1> ;	THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE
  7368                              <1> ;	845, FORMATS IT, AND SENDS IT BACK TO THE CALLER
  7369                              <1> ; INPUT
  7370                              <1> ;	BH - PAGE OF CURSOR
  7371                              <1> ; OUTPUT
  7372                              <1> ;	DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION
  7373                              <1> ;	CX - CURRENT CURSOR MODE
  7374                              <1> ;------------------------------------------------------
  7375                              <1> 
  7376                              <1> 	; BH = Video page number (0 to 7)
  7377                              <1> 
  7378                              <1> 	; 07/07/2016
  7379 00001E8E 80FF07              <1> 	cmp	bh, 7 ; video page > 7 (invalid)
  7380 00001E91 7606                <1> 	jna	short read_cursor_1
  7381                              <1> 	; invalid video page (input) 
  7382 00001E93 31C9                <1> 	xor	ecx, ecx ; 0
  7383 00001E95 31D2                <1> 	xor	edx, edx ; 0
  7384 00001E97 EB15                <1> 	jmp	short read_cursor_2
  7385                              <1> read_cursor_1:
  7386                              <1> 	; 12/09/2016
  7387 00001E99 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; vga mode
  7388 00001EA0 7727                <1> 	ja	short vga_get_cpos
  7389                              <1> 	;
  7390 00001EA2 E815000000          <1> 	call	get_cpos
  7391 00001EA7 0FB70D[B7660000]    <1> 	movzx	ecx, word [CURSOR_MODE]
  7392                              <1> read_cursor_2:
  7393 00001EAE 5D                  <1> 	pop	ebp
  7394 00001EAF 5F                  <1> 	pop	edi
  7395 00001EB0 5E                  <1> 	pop	esi
  7396 00001EB1 5B                  <1> 	pop	ebx
  7397 00001EB2 58                  <1> 	pop	eax  ; DISCARD SAVED CX AND DX
  7398 00001EB3 58                  <1> 	pop	eax
  7399 00001EB4 A1[04840100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  7400                              <1> 	;;15/01/2017
  7401                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017
  7402 00001EB9 1F                  <1> 	pop	ds
  7403 00001EBA 07                  <1> 	pop	es
  7404 00001EBB CF                  <1> 	iretd
  7405                              <1> 
  7406                              <1> get_cpos:
  7407                              <1> 	; 12/05/2016
  7408                              <1> 	; 16/01/2016
  7409                              <1> 	; BH = Video page number (0 to 7)
  7410                              <1> 	;
  7411 00001EBC D0E7                <1> 	shl	bh, 1 ; WORD OFFSET
  7412 00001EBE 0FB6F7              <1> 	movzx	esi, bh 
  7413 00001EC1 0FB796[9E770100]    <1> 	movzx	edx, word [esi+CURSOR_POSN]
  7414 00001EC8 C3                  <1> 	retn
  7415                              <1> 
  7416                              <1> vga_get_cpos:
  7417                              <1> 	; 12/09/2016
  7418                              <1> 	; get cursor position (vga)
  7419 00001EC9 0FB715[9E770100]    <1> 	movzx	edx, word [CURSOR_POSN] ; cursor pos for pg 0
  7420 00001ED0 31C9                <1> 	xor	ecx, ecx ; Cursor Mode = 0 (invalid)
  7421 00001ED2 EBDA                <1> 	jmp     short read_cursor_2
  7422                              <1> 
  7423                              <1> ACT_DISP_PAGE:
  7424                              <1> 	; 07/07/2016
  7425                              <1> 	; 26/06/2016
  7426                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7427                              <1> 	;
  7428                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7429                              <1> 	;
  7430                              <1> ;-----------------------------------------------------
  7431                              <1> ; ACT_DISP_PAGE
  7432                              <1> ;	THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING
  7433                              <1> ;	THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT
  7434                              <1> ; INPUT
  7435                              <1> ;	AL HAS THE NEW ACTIVE DISPLAY PAGE
  7436                              <1> ; OUTPUT
  7437                              <1> ;	THE 6845 IS RESET TO DISPLAY THAT PAGE
  7438                              <1> ;-----------------------------------------------------
  7439                              <1> 	; 07/07/2016
  7440 00001ED4 3C07                <1> 	cmp	al, 7	; > 7 = invalid video page number
  7441                              <1> 	;ja	VIDEO_RETURN
  7442 00001ED6 7715                <1>         ja	short adp_2 ; 18/11/2020
  7443                              <1> 	;cmp	byte [CRT_MODE], 3
  7444                              <1> 	;je	short adp_1
  7445                              <1> 	; 18/11/2020
  7446 00001ED8 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE]
  7447 00001EDE 80FC03              <1> 	cmp	ah, 3
  7448 00001EE1 7605                <1> 	jna	short adp_1 ; mode 01h, 00h (01h), 02h (03h), 03h
  7449 00001EE3 80FC07              <1> 	cmp	ah, 7	    ; mode 07h (03h)
  7450 00001EE6 7505                <1> 	jne	short adp_2
  7451                              <1> 	;and 	al, al
  7452                              <1>         ;jnz	VIDEO_RETURN
  7453                              <1> 	;;sub	al, al ; 0 ; force to page 0
  7454                              <1> adp_1:	
  7455 00001EE8 E805000000          <1> 	call	set_active_page
  7456                              <1> adp_2:
  7457 00001EED E9C9FBFFFF          <1>         jmp     VIDEO_RETURN
  7458                              <1> 
  7459                              <1> set_active_page:   ; tty_sw
  7460                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  7461                              <1> 	; 09/12/2017
  7462                              <1> 	; 26/07/2016
  7463                              <1> 	; 26/06/2016
  7464                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7465                              <1> 	; 30/06/2015
  7466                              <1> 	; 04/03/2014  (act_disp_page --> tty_sw)
  7467                              <1> 	; 10/12/2013
  7468                              <1> 	; 04/12/2013
  7469                              <1> 	;
  7470 00001EF2 A2[AE770100]        <1> 	mov	[ACTIVE_PAGE], al ; save active page value ; [ptty]
  7471                              <1> _set_active_page:
  7472                              <1> 	; 27/06/2015
  7473                              <1> 	;movzx	ebx, al
  7474                              <1> 	; 02/08/2022
  7475 00001EF7 0FB6C0              <1> 	movzx	eax, al
  7476 00001EFA 89C3                <1> 	mov	ebx, eax
  7477                              <1> 	;
  7478                              <1> 	;cbw	; 07/09/2014 (ah=0)
  7479                              <1> 	; 02/08/2022
  7480                              <1> 	;sub	ah, ah ; 09/12/2017
  7481 00001EFC 66F725[14840100]    <1> 	mul	word [CRT_LEN]  ; get saved length of regen buffer
  7482                              <1> 				; display page times regen length
  7483                              <1> 	; 10/12/2013
  7484 00001F03 66A3[9C770100]      <1> 	mov	[CRT_START], ax ; save start address for later
  7485                              <1> 	;mov	cx, ax ; start address to cx
  7486                              <1> 	; 02/08/2022
  7487 00001F09 89C1                <1> 	mov	ecx, eax
  7488                              <1> _M16:
  7489                              <1> 	;;sar	cx, 1
  7490                              <1> 	;shr	cx, 1	; divide by 2 for 6845 handling
  7491                              <1> 	; 02/08/2022
  7492 00001F0B D1E9                <1> 	shr	ecx, 1
  7493 00001F0D B40C                <1> 	mov	ah, 12	; 6845 register for start address
  7494 00001F0F E8CD030000          <1> 	call	m16
  7495                              <1> 	;sal	bx, 1
  7496                              <1> 	; 01/09/2014
  7497 00001F14 D0E3                <1> 	shl	bl, 1	; *2 for word offset
  7498 00001F16 81C3[9E770100]      <1> 	add	ebx, CURSOR_POSN
  7499 00001F1C 668B13              <1> 	mov	dx, [ebx] ; get cursor for this page
  7500                              <1> 	; 16/01/2016
  7501                              <1> 	;call	m18
  7502                              <1> 	;retn
  7503 00001F1F E9A9030000          <1> 	jmp	m18
  7504                              <1> 
  7505                              <1> position:
  7506                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
  7507                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  7508                              <1> 	; 24/06/2016
  7509                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  7510                              <1> 	; 27/06/2015
  7511                              <1> 	; 02/09/2014
  7512                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  7513                              <1> 	; 04/12/2013 (Retro UNIX 8086 v1)
  7514                              <1> 	;
  7515                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7516                              <1> 	;
  7517                              <1> ;-----------------------------------------
  7518                              <1> ; POSITION
  7519                              <1> ;	THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS
  7520                              <1> ;	OF A CHARACTER IN THE ALPHA MODE
  7521                              <1> ; INPUT
  7522                              <1> ;	AX = ROW, COLUMN POSITION
  7523                              <1> ; OUTPUT
  7524                              <1> ;	AX = OFFSET OF CHAR POSITION IN REGEN BUFFER
  7525                              <1> ;-----------------------------------------
  7526                              <1> 
  7527                              <1> 	; DX = ROW, COLUMN POSITION
  7528                              <1> 	;movzx	eax, byte [CRT_COLS] ; 27/06/2015
  7529 00001F24 31C0                <1> 	xor	eax, eax ; 02/09/2014
  7530 00001F26 B050                <1> 	mov	al, 80   ; determine bytes to row	
  7531 00001F28 F6E6                <1> 	mul	dh	 ; row value
  7532                              <1> 	;xor	dh, dh   ; 0	
  7533                              <1> 	;add	ax, dx	 ; add column value to the result
  7534                              <1> 	; 16/04/2021
  7535 00001F2A 00D0                <1> 	add	al, dl
  7536 00001F2C 80D400              <1> 	adc	ah, 0
  7537                              <1> 	; 02/08/2022
  7538 00001F2F D1E0                <1> 	shl	eax, 1
  7539                              <1> 	;shl	ax, 1	; * 2 for attribute bytes
  7540                              <1> 		; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 
  7541 00001F31 C3                  <1> 	retn
  7542                              <1> 
  7543                              <1> find_position:
  7544                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  7545                              <1> 	; 24/06/2016
  7546                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  7547                              <1> 	; 27/06/2015
  7548                              <1> 	; 07/09/2014
  7549                              <1> 	; 02/09/2014
  7550                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  7551                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7552                              <1> 
  7553 00001F32 0FB6CF              <1> 	movzx	ecx, bh ; video page number
  7554                              <1> 	; 17/04/2021
  7555                              <1> 	;mov	esi, ecx
  7556                              <1> 	;shl	si, 1
  7557                              <1> 	;mov	dx, [esi+CURSOR_POSN]
  7558                              <1> 	;jz	short p21
  7559                              <1> 	;xor	si, si
  7560                              <1> 	; 17/04/2021
  7561 00001F35 31F6                <1> 	xor	esi, esi
  7562 00001F37 D0E1                <1> 	shl	cl, 1
  7563 00001F39 668B91[9E770100]    <1> 	mov	dx, [ecx+CURSOR_POSN]
  7564 00001F40 740B                <1> 	jz	short p21
  7565 00001F42 D0E9                <1> 	shr	cl, 1
  7566                              <1> p20:
  7567 00001F44 660335[14840100]    <1> 	add	si, [CRT_LEN] ; 24/06/2016
  7568                              <1> 	;add	si, 80*25*2 ; add length of buffer for one page
  7569 00001F4B E2F7                <1> 	loop	p20
  7570                              <1> p21:
  7571 00001F4D 6621D2              <1> 	and	dx, dx
  7572 00001F50 7407                <1> 	jz	short p22
  7573 00001F52 E8CDFFFFFF          <1> 	call 	position ; determine location in regen in page
  7574 00001F57 01C6                <1> 	add	esi, eax ; add location to start of regen page
  7575                              <1> p22:	
  7576                              <1> 	;mov	dx, [addr_6845] ; get base address of active display
  7577                              <1> 	;mov	dx, 03D4h ; I/O address of color card
  7578                              <1> 	;add	dx, 6	; point at status port
  7579 00001F59 66BADA03            <1> 	mov	dx, 03DAh ; status port
  7580                              <1> 	; cx = 0
  7581 00001F5D C3                  <1> 	retn
  7582                              <1> 
  7583                              <1> SCROLL_UP:
  7584                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  7585                              <1> 	; 07/07/2016
  7586                              <1> 	; 26/06/2016
  7587                              <1> 	; 12/05/2016
  7588                              <1> 	; 30/01/2016
  7589                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7590                              <1> 	; 07/09/2014
  7591                              <1> 	; 02/09/2014
  7592                              <1> 	; 01/09/2014 (Retro UNIX 386 v1 - beginning)
  7593                              <1> 	; 04/04/2014
  7594                              <1> 	; 04/12/2013
  7595                              <1> 	;
  7596                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7597                              <1> 	;
  7598                              <1> ;----------------------------------------------
  7599                              <1> ; SCROLL UP
  7600                              <1> ;	THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP
  7601                              <1> ;	ON THE SCREEN
  7602                              <1> ; INPUT
  7603                              <1> ;	(AH) = CURRENT CRT MODE
  7604                              <1> ;	(AL) = NUMBER OF ROWS TO SCROLL
  7605                              <1> ;	(CX) = ROW/COLUMN OF UPPER LEFT CORNER
  7606                              <1> ;	(DX) = ROW/COLUMN OF LOWER RIGHT CORNER
  7607                              <1> ;	(BH) = ATTRIBUTE TO BE USED ON BLANKED LINE
  7608                              <1> ;	(DS) = DATA SEGMENT
  7609                              <1> ;	(ES) = REGEN BUFFER SEGMENT
  7610                              <1> ; OUTPUT
  7611                              <1> ;	NONE -- THE REGEN BUFFER IS MODIFIED
  7612                              <1> ;--------------------------------------------
  7613                              <1> 
  7614                              <1> 	; 07/07/2016
  7615 00001F5E 38F5                <1> 	cmp	ch, dh
  7616                              <1> 	;ja	VIDEO_RETURN
  7617                              <1> 	; 04/08/2022
  7618 00001F60 7709                <1> 	ja	short _s_u_retn
  7619                              <1> 
  7620 00001F62 38D1                <1> 	cmp	cl, dl
  7621                              <1> 	;ja	VIDEO_RETURN
  7622                              <1> 	; 04/08/2022
  7623 00001F64 7705                <1> 	ja	short _s_u_retn
  7624                              <1> 	;
  7625 00001F66 E805000000          <1> 	call	_scroll_up
  7626                              <1> _s_u_retn:
  7627 00001F6B E94BFBFFFF          <1>         jmp     VIDEO_RETURN
  7628                              <1> 
  7629                              <1> _scroll_up:  ; from 'write_tty'
  7630                              <1> 	;
  7631                              <1> 	; cl = left upper column
  7632                              <1> 	; ch = left upper row
  7633                              <1> 	; dl = right lower column
  7634                              <1> 	; dh = right lower row
  7635                              <1> 	;
  7636                              <1> 	; al = line count 
  7637                              <1> 	; bl = attribute to be used on blanked line
  7638                              <1> 	; bh = video page number (0 to 7)
  7639                              <1> 
  7640 00001F70 E89B000000          <1> 	call	test_line_count ; 16/01/2016
  7641                              <1> 
  7642 00001F75 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  7643                              <1> 	;;cmp	byte [CRT_MODE], 4
  7644                              <1> 	;cmp	ah, 4 ; 07/07/2016
  7645                              <1> 	;jnb	GRAPHICS_UP ; 26/06/2016
  7646                              <1> 	; 18/11/2020
  7647 00001F7B 80FC04              <1> 	cmp	ah, 4
  7648 00001F7E 720A                <1>  	jb	short n0	
  7649 00001F80 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  7650                              <1> 		      ;	(80x25 text, mono)
  7651 00001F83 7405                <1> 	je	short n0 ; same with mode 3 for TRDOS 386
  7652 00001F85 E91B050000          <1> 	jmp	GRAPHICS_UP
  7653                              <1> n0:
  7654                              <1> 	; 07/07/2016
  7655 00001F8A 80FF07              <1> 	cmp	bh, 7 ; video page number
  7656 00001F8D 7606                <1> 	jna	short n1
  7657 00001F8F 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE]
  7658                              <1> n1:
  7659 00001F95 88DC                <1> 	mov	ah, bl ; attribute
  7660                              <1> 	;push	ax ; *
  7661                              <1> 	; 12/04/2021
  7662 00001F97 50                  <1> 	push	eax ; *
  7663                              <1> 	;mov 	esi, [CRT_BASE]
  7664 00001F98 BE00800B00          <1>         mov     esi, 0B8000h  
  7665 00001F9D 3A3D[AE770100]      <1>         cmp     bh, [ACTIVE_PAGE]
  7666 00001FA3 750B                <1> 	jne	short n2
  7667                              <1> 	;
  7668 00001FA5 66A1[9C770100]      <1>         mov     ax, [CRT_START]
  7669 00001FAB 6601C6              <1>         add     si, ax
  7670 00001FAE EB11                <1>         jmp     short n4
  7671                              <1> n2:
  7672 00001FB0 20FF                <1>         and     bh, bh
  7673 00001FB2 740D                <1> 	jz	short n4
  7674 00001FB4 88F8                <1> 	mov	al, bh
  7675                              <1> n3:
  7676 00001FB6 660335[14840100]    <1>         add	si, [CRT_LEN]
  7677 00001FBD FEC8                <1>         dec	al
  7678 00001FBF 75F5                <1> 	jnz	short n3
  7679                              <1> n4:	
  7680 00001FC1 E85B000000          <1> 	call	scroll_position ; 16/01/2016
  7681 00001FC6 7420                <1>         jz      short n6 
  7682                              <1> 
  7683 00001FC8 01CE                <1>         add     esi, ecx ; from address for scroll
  7684 00001FCA 88F5                <1> 	mov	ch, dh  ; #rows in block
  7685 00001FCC 28C5                <1> 	sub	ch, al	; #rows to be moved
  7686                              <1> n5:
  7687 00001FCE E88A000000          <1> 	call	n10 ; 16/01/2016
  7688                              <1> 	
  7689 00001FD3 51                  <1>         push	ecx
  7690 00001FD4 0FB60D[A0660000]    <1> 	movzx	ecx, byte [CRT_COLS] 
  7691 00001FDB 00C9                <1> 	add	cl, cl
  7692 00001FDD 01CE                <1>         add	esi, ecx  ; next line
  7693 00001FDF 01CF                <1>         add	edi, ecx
  7694 00001FE1 59                  <1> 	pop	ecx
  7695                              <1> 
  7696 00001FE2 FECD                <1> 	dec	ch	 ; count of lines to move
  7697 00001FE4 75E8                <1> 	jnz	short n5 ; row loop
  7698                              <1> 	; ch = 0
  7699 00001FE6 88C6                <1> 	mov	dh, al	 ; #rows
  7700                              <1> n6:
  7701                              <1> 	; attribute in ah
  7702 00001FE8 B020                <1> 	mov	al, ' '	 ; fill with blanks
  7703                              <1> n7:
  7704 00001FEA E87B000000          <1> 	call	n11 ; 16/01/2016
  7705                              <1> 
  7706 00001FEF 8A0D[A0660000]      <1> 	mov	cl, [CRT_COLS]
  7707 00001FF5 00C9                <1> 	add	cl, cl
  7708 00001FF7 01CF                <1>         add	edi, ecx
  7709                              <1> 
  7710 00001FF9 FECE                <1> 	dec	dh
  7711 00001FFB 75ED                <1> 	jnz	short n7
  7712                              <1> n16:
  7713 00001FFD 3A3D[AE770100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  7714 00002003 750A                <1> 	jne	short n8
  7715                              <1> 	
  7716                              <1> 	;cmp	byte [CRT_MODE], 7 ; is this the black and white card
  7717                              <1> 	;je	short n8	   ; if so, skip the mode reset
  7718                              <1> 
  7719 00002005 A0[9F660000]        <1> 	mov	al, [CRT_MODE_SET] ; get the value of mode set
  7720 0000200A 66BAD803            <1> 	mov	dx, 03D8h ; always set color card port
  7721 0000200E EE                  <1> 	out	dx, al
  7722                              <1> n8:
  7723 0000200F C3                  <1> 	retn
  7724                              <1> 
  7725                              <1> test_line_count:
  7726                              <1> 	; 12/04/2021
  7727                              <1> 	; 12/05/2016
  7728                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7729                              <1> 	; 07/09/2014 (scroll_up)
  7730 00002010 08C0                <1> 	or	al, al
  7731 00002012 740C                <1> 	jz	short al_set2
  7732                              <1> 	;push	dx
  7733                              <1> 	; 12/04/2021
  7734 00002014 52                  <1> 	push	edx
  7735 00002015 28EE                <1> 	sub	dh, ch  ; subtract upper row from lower row number
  7736 00002017 FEC6                <1> 	inc	dh	; adjust difference by 1
  7737 00002019 38C6                <1> 	cmp	dh, al 	; line count = amount of rows in window?
  7738 0000201B 7502                <1> 	jne	short al_set1 ; if not the we're all set
  7739 0000201D 30C0                <1> 	xor	al, al	; otherwise set al to zero
  7740                              <1> al_set1:
  7741                              <1> 	;pop	dx
  7742                              <1> 	; 12/04/2021
  7743 0000201F 5A                  <1> 	pop	edx
  7744                              <1> al_set2:
  7745 00002020 C3                  <1> 	retn
  7746                              <1> 
  7747                              <1> scroll_position:
  7748                              <1> 	; 12/04/2021
  7749                              <1> 	; 26/06/2016
  7750                              <1> 	; 30/01/2016
  7751                              <1>         ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7752                              <1> 	; 07/09/2014 (scroll_up)
  7753                              <1> 
  7754                              <1> 	; (*) [esp+4] = ax (al = line count, ah = attribute)
  7755                              <1> 
  7756                              <1> 	;push	dx
  7757                              <1> 	; 12/04/2021
  7758 00002021 52                  <1> 	push	edx
  7759 00002022 6689CA              <1> 	mov	dx, cx	; now, upper left position in DX
  7760 00002025 E8FAFEFFFF          <1> 	call	position
  7761 0000202A 01C6                <1> 	add	esi, eax
  7762 0000202C 89F7                <1> 	mov	edi, esi
  7763                              <1> 	;pop	dx	; lower right position in DX
  7764                              <1> 	; 12/04/2021
  7765 0000202E 5A                  <1> 	pop	edx
  7766 0000202F 6629CA              <1> 	sub	dx, cx
  7767 00002032 FEC6                <1> 	inc	dh	; dh = #rows 
  7768 00002034 FEC2                <1> 	inc	dl	; dl = #cols in block
  7769 00002036 59                  <1> 	pop	ecx 	; return address
  7770                              <1> 	;pop	ax	; * ; al = line count, ah = attribute
  7771                              <1> 	; 12/04/2021
  7772 00002037 58                  <1> 	pop	eax ; (*)
  7773 00002038 51                  <1> 	push	ecx	; return address
  7774 00002039 0FB7C8              <1> 	movzx	ecx, ax
  7775 0000203C 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS]
  7776 00002042 F6E4                <1> 	mul	ah	; determine offset to from address
  7777                              <1> 	;add	ax, ax  ; *2 for attribute byte
  7778                              <1> 	; 02/08/2022
  7779                              <1> 	;shl	eax, 1
  7780 00002044 01C0                <1> 	add	eax, eax
  7781                              <1> 	;
  7782                              <1> 	;push	ax	; offset 
  7783                              <1> 	;push	dx
  7784                              <1> 	; 12/04/2021
  7785 00002046 50                  <1> 	push	eax	; offset 
  7786 00002047 52                  <1> 	push	edx
  7787                              <1> 	;
  7788                              <1> 	; 04/04/2014
  7789 00002048 66BADA03            <1> 	mov	dx, 3DAh ; guaranteed to be color card here	
  7790                              <1> n9:                      ; wait_display_enable
  7791 0000204C EC                  <1>         in      al, dx   ; get port
  7792 0000204D A808                <1> 	test	al, RVRT ; wait for vertical retrace	
  7793 0000204F 74FB                <1> 	jz	short n9 ; wait_display_enable
  7794 00002051 B025                <1> 	mov	al, 25h
  7795 00002053 B2D8                <1> 	mov	dl, 0D8h ; address control port
  7796 00002055 EE                  <1> 	out	dx, al	; turn off video during vertical retrace
  7797                              <1> 	;pop	dx	; #rows, #cols
  7798                              <1>        	;pop	ax	; offset
  7799                              <1> 	; 12/04/2021
  7800 00002056 5A                  <1> 	pop	edx	; #rows, #cols
  7801 00002057 58                  <1>        	pop	eax	; offset
  7802 00002058 6691                <1> 	xchg	ax, cx	; 
  7803                              <1> 	; ecx = offset, al = line count, ah = attribute
  7804                              <1> 	;
  7805 0000205A 08C0                <1> 	or	al, al
  7806 0000205C C3                  <1> 	retn
  7807                              <1> n10:
  7808                              <1> 	; Move rows
  7809 0000205D 88D1                <1> 	mov	cl, dl	; get # of cols to move
  7810 0000205F 56                  <1> 	push	esi
  7811 00002060 57                  <1> 	push	edi	; save start address
  7812                              <1> n10r:
  7813 00002061 66A5                <1> 	movsw		; move that line on screen
  7814 00002063 FEC9                <1> 	dec	cl
  7815 00002065 75FA                <1>         jnz     short n10r
  7816 00002067 5F                  <1> 	pop	edi
  7817 00002068 5E                  <1> 	pop	esi	; recover addresses
  7818 00002069 C3                  <1> 	retn
  7819                              <1> n11:
  7820                              <1> 	; Clear rows
  7821                              <1>                 	; dh =  #rows
  7822 0000206A 88D1                <1>         mov	cl, dl	; get # of cols to clear
  7823 0000206C 57                  <1>         push    edi     ; save address
  7824                              <1> n11r:
  7825 0000206D 66AB                <1>         stosw           ; store fill character
  7826 0000206F FEC9                <1> 	dec	cl
  7827 00002071 75FA                <1>         jnz     short n11r
  7828 00002073 5F                  <1>         pop     edi     ; recover address
  7829 00002074 C3                  <1> 	retn
  7830                              <1> 
  7831                              <1> SCROLL_DOWN:
  7832                              <1> 	; 12/04/2021
  7833                              <1> 	; 07/07/2016
  7834                              <1> 	; 27/06/2016
  7835                              <1> 	; 26/06/2016
  7836                              <1> 	; 12/05/2016
  7837                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7838                              <1> 	;
  7839                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7840                              <1> 
  7841                              <1> ;------------------------------------------
  7842                              <1> ; SCROLL DOWN
  7843                              <1> ;	THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED
  7844                              <1> ;	BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES
  7845                              <1> ;	WITH A DEFINED CHARACTER
  7846                              <1> ; INPUT
  7847                              <1> ;	(AH) = CURRENT CRT MODE
  7848                              <1> ;	(AL) = NUMBER OF LINES TO SCROLL
  7849                              <1> ;	(CX) = UPPER LEFT CORNER OF RECION
  7850                              <1> ;	(DX) = LOWER RIGHT CORNER OF REGION
  7851                              <1> ;	(BH) = FILL CHARACTER
  7852                              <1> ;	(DS) = DATA SEGMENT
  7853                              <1> ;	(ES) = REGEN SEGMENT
  7854                              <1> ; OUTPUT
  7855                              <1> ;	NONE -- SCREEN IS SCROLLED
  7856                              <1> ;------------------------------------------
  7857                              <1> 
  7858                              <1> 	; 07/07/2016
  7859 00002075 38F5                <1> 	cmp	ch, dh
  7860                              <1> 	;ja	VIDEO_RETURN
  7861 00002077 7709                <1> 	ja	short _s_d_retn ; 18/11/2020
  7862 00002079 38D1                <1> 	cmp	cl, dl
  7863                              <1> 	;ja	VIDEO_RETURN
  7864 0000207B 7705                <1> 	ja	short _s_d_retn ; 18/11/2020
  7865                              <1> 	;
  7866 0000207D E805000000          <1> 	call	_scroll_down
  7867                              <1> _s_d_retn:
  7868 00002082 E934FAFFFF          <1>         jmp     VIDEO_RETURN
  7869                              <1> 
  7870                              <1> _scroll_down: ; 27/06/2016
  7871                              <1> 
  7872                              <1> 	; cl = left upper column
  7873                              <1> 	; ch = left upper row
  7874                              <1> 	; dl = right lower column
  7875                              <1> 	; dh = right lower row
  7876                              <1> 	;
  7877                              <1> 	; al = line count 
  7878                              <1> 	; bl = attribute to be used on blanked line
  7879                              <1> 	; bh = video page number (0 to 7)
  7880                              <1> 
  7881                              <1> 	; !!!!
  7882 00002087 FD                  <1> 	std		; DIRECTION FOR SCROLL DOWN
  7883                              <1> 	; !!!!
  7884 00002088 E883FFFFFF          <1> 	call	test_line_count ; 16/01/2016
  7885                              <1> 	
  7886 0000208D 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  7887                              <1> 	;;cmp	byte [CRT_MODE], 4
  7888                              <1> 	;cmp	ah, 4 ; 07/07/2016
  7889                              <1> 	;jnb	GRAPHICS_DOWN ; 26/06/2016
  7890                              <1> 	; 18/11/2020
  7891 00002093 80FC04              <1> 	cmp	ah, 4
  7892 00002096 720A                <1>  	jb	short _n0	
  7893 00002098 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  7894                              <1> 		      ;	(80x25 text, mono)
  7895 0000209B 7405                <1> 	je	short _n0 ; same with mode 3 for TRDOS 386
  7896 0000209D E9D5060000          <1> 	jmp	GRAPHICS_DOWN
  7897                              <1> _n0:
  7898                              <1> 	; 07/07/2016
  7899 000020A2 80FF07              <1> 	cmp	bh, 7 ; video page number
  7900 000020A5 7606                <1> 	jna	short n12
  7901 000020A7 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE]
  7902                              <1> 	;
  7903                              <1> n12:			; CONTINUE_DOWN
  7904 000020AD 88DC                <1> 	mov	ah, bl
  7905                              <1> 	;push	ax	; * ; save attribute in ah
  7906                              <1> 	; 12/04/2021
  7907 000020AF 50                  <1> 	push	eax
  7908 000020B0 6689D0              <1> 	mov	ax, dx	; LOWER RIGHT CORNER
  7909 000020B3 E869FFFFFF          <1> 	call	scroll_position	; GET REGEN LOCATION
  7910 000020B8 741F                <1> 	jz	short n14
  7911 000020BA 29CE                <1> 	sub	esi, ecx  ; SI IS FROM ADDRESS
  7912 000020BC 88F5                <1> 	mov	ch, dh  ; #rows in block
  7913 000020BE 28C5                <1> 	sub	ch, al	; #rows to be moved
  7914                              <1> n13:
  7915 000020C0 E898FFFFFF          <1> 	call	n10	; MOVE ONE ROW
  7916                              <1> 
  7917 000020C5 51                  <1> 	push	ecx
  7918 000020C6 8A0D[A0660000]      <1> 	mov	cl, [CRT_COLS] 
  7919 000020CC 00C9                <1> 	add	cl, cl
  7920 000020CE 29CE                <1>         sub	esi, ecx  ; next line
  7921 000020D0 29CF                <1>         sub	edi, ecx
  7922 000020D2 59                  <1>         pop	ecx
  7923                              <1> 	
  7924 000020D3 FECD                <1> 	dec	ch	 ; count of lines to move
  7925 000020D5 75E9                <1> 	jnz	short n13 ; row loop
  7926                              <1> 	; ch = 0
  7927 000020D7 88C6                <1> 	mov	dh, al	 ; #rows
  7928                              <1> n14:
  7929                              <1> 	; attribute in ah
  7930 000020D9 B020                <1> 	mov	al, ' '	 ; fill with blanks
  7931                              <1> n15:
  7932 000020DB E88AFFFFFF          <1> 	call	n11 ; 16/01/2016
  7933                              <1> 
  7934 000020E0 8A0D[A0660000]      <1> 	mov	cl, [CRT_COLS]
  7935 000020E6 00C9                <1> 	add	cl, cl
  7936 000020E8 29CF                <1>         sub	edi, ecx
  7937                              <1>         
  7938 000020EA FECE                <1> 	dec	dh
  7939 000020EC 75ED                <1> 	jnz	short n15
  7940                              <1> 	;
  7941                              <1> 	; 18/11/2020
  7942 000020EE FC                  <1> 	cld	; clear direction flag	
  7943                              <1> 	;
  7944 000020EF E909FFFFFF          <1> 	jmp	n16 ; 27/06/2016
  7945                              <1> 
  7946                              <1> ;	cmp	bh, [ACTIVE_PAGE]
  7947                              <1> ;	jne	short n16
  7948                              <1> ;
  7949                              <1> ;	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  7950                              <1> ;	;je	short n16		; if so, skip the mode reset
  7951                              <1> ;
  7952                              <1> ;	mov	al, [CRT_MODE_SET] ; get the value of mode set
  7953                              <1> ;	mov	dx, 03D8h ; always set color card port
  7954                              <1> ;	out	dx, al
  7955                              <1> ;n16:
  7956                              <1> ;	; !!!!
  7957                              <1> ;	cld		; Clear direction flag !
  7958                              <1> ;	; !!!!
  7959                              <1> ;	retn
  7960                              <1> 
  7961                              <1> READ_AC_CURRENT:
  7962                              <1> 	; 08/07/2016
  7963                              <1> 	; 26/06/2016
  7964                              <1> 	; 12/05/2016
  7965                              <1> 	; 18/01/2016
  7966                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  7967                              <1> 	;
  7968                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  7969                              <1> 	;
  7970                              <1> 	; 08/07/2016
  7971 000020F4 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7 ; 6!?
  7972 000020FB 7607                <1> 	jna	short read_ac_c
  7973 000020FD 31C0                <1> 	xor	eax, eax
  7974 000020FF E9BCF9FFFF          <1>         jmp     _video_return 
  7975                              <1> read_ac_c:
  7976 00002104 E805000000          <1> 	call	_read_ac_current
  7977                              <1> 	; 12/05/2016
  7978                              <1>         ;jmp     VIDEO_RETURN
  7979 00002109 E9B2F9FFFF          <1> 	jmp	_video_return
  7980                              <1> 
  7981                              <1> ;------------------------------------------------------------------------
  7982                              <1> ; READ_AC_CURRENT							:
  7983                              <1> ;	THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT	:
  7984                              <1> ;	CURSOR POSITION AND RETURNS THEM TO THE CALLER			:
  7985                              <1> ; INPUT									:
  7986                              <1> ;	(AH) = CURRENT CRT MODE						:
  7987                              <1> ;	(BH) = DISPLAY PAGE ( ALPHA MODES ONLY )			:
  7988                              <1> ;	(DS) = DATA SEGMENT						:
  7989                              <1> ;	(ES) = REGEN SEGMENT						:
  7990                              <1> ; OUTPUT								:
  7991                              <1> ;	(AL) = CHARACTER READ						:
  7992                              <1> ;	(AH) = ATTRIBUTE READ						:
  7993                              <1> ;------------------------------------------------------------------------
  7994                              <1> 
  7995                              <1> _read_ac_current:
  7996                              <1> 	; 26/06/2016
  7997                              <1> 	; 12/05/2016 
  7998                              <1> 	; 18/01/2016
  7999                              <1> 
  8000 0000210E 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  8001 00002114 80FC04              <1> 	cmp	ah, 4
  8002 00002117 720A                <1>  	jb	short p10
  8003                              <1> 	; 18/11/2020
  8004                              <1> 	;cmp	byte [CRT_MODE], 4
  8005                              <1> 	;jnb	GRAPHICS_READ ; 26/06/2016
  8006                              <1> 
  8007 00002119 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD (80x25 monochrome text)
  8008 0000211C 7405                <1> 	je	short p10	 ; same with mode 3 in TRDOS 386
  8009 0000211E E9A0080000          <1> 	jmp	GRAPHICS_READ
  8010                              <1> p10:
  8011 00002123 E80AFEFFFF          <1> 	call	find_position	; GET REGEN LOCATION AND PORT ADDRESS
  8012                              <1> 	;
  8013                              <1> 	; esi = regen location
  8014                              <1> 	; dx = status port
  8015                              <1> 	;
  8016                              <1> 
  8017                              <1> 	; 18/11/2020
  8018                              <1> 	; convert display mode to a zero value 
  8019                              <1> 	; for 80 column color mode
  8020                              <1> 	;mov	ah, [CRT_MODE]	
  8021                              <1> 	;sub	ah, 2
  8022                              <1> 	;shr	ah, 1
  8023                              <1> 	;jnz	short p13
  8024                              <1> 
  8025                              <1> 	; 05/12/2020
  8026                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  8027                              <1> 	;xor	bl, bl	; 0
  8028 00002128 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  8029                              <1> 	;je	short p11    ; Note: Only mode 03h and mode 01h are
  8030                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  8031                              <1> 	;jmp	short p14    ;       (07h, 00h and 02h are redirected)		
  8032 0000212F 7516                <1> 	jne	short p13
  8033                              <1> 
  8034                              <1> 	; 05/12/2020
  8035 00002131 3A3D[AE770100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  8036 00002137 750E                <1> 	jne	short p13 
  8037                              <1> 
  8038                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  8039                              <1> p11:
  8040 00002139 FB                  <1> 	sti		; enable interrupts first
  8041                              <1> 	; 05/12/2020
  8042 0000213A 90                  <1> 	nop
  8043                              <1> 	; 18/11/2020
  8044                              <1> 	;or	bl, bl
  8045                              <1> 	;jnz	short p13 ; mode 01h (and mode 00h) - 40x25 color text
  8046 0000213B FA                  <1> 	cli 		; block interrupts for single loop
  8047 0000213C EC                  <1> 	in	al, dx	; get status from the adapter
  8048 0000213D A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  8049 0000213F 75F8                <1> 	jnz	short p11 ; wait until it is
  8050                              <1> p12:			;  wait for either retrace high
  8051 00002141 EC                  <1> 	in	al, dx ; get status again
  8052 00002142 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  8053 00002144 74FB                <1> 	jz	short p12 ; wait until either retrace active
  8054                              <1> ;p14:
  8055 00002146 FB                  <1> 	sti
  8056                              <1> p13:
  8057 00002147 81C600800B00        <1> 	add	esi, 0B8000h 
  8058 0000214D 668B06              <1> 	mov	ax, [esi]
  8059                              <1> 
  8060 00002150 C3                  <1> 	retn	; 18/01/2016
  8061                              <1> 
  8062                              <1> WRITE_AC_CURRENT:
  8063                              <1> 	; 08/07/2016
  8064                              <1> 	; 26/06/2016
  8065                              <1> 	; 24/06/2016
  8066                              <1> 	; 12/05/2016
  8067                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  8068                              <1> 	;
  8069                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  8070                              <1> 	;
  8071                              <1> ;----------------------------------------------------------------
  8072                              <1> ; WRITE_AC_CURRENT						:
  8073                              <1> ;	THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER		:
  8074                              <1> ;	AT THE CURRENT CURSOR POSITION				:
  8075                              <1> ; INPUT								:
  8076                              <1> ;	(AH) = CURRENT CRT MODE					:
  8077                              <1> ;	(BH) = DISPLAY PAGE					:
  8078                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  8079                              <1> ;	(AL) = CHAR TO WRITE					:
  8080                              <1> ;	(BL) = ATTRIBUTE OF CHAR TO WRITE			:
  8081                              <1> ;	(DS) = DATA SEGMENT					:
  8082                              <1> ;	(ES) = REGEN SEGMENT					:
  8083                              <1> ; OUTPUT							:
  8084                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  8085                              <1> ;----------------------------------------------------------------
  8086                              <1> 
  8087                              <1> 	; 08/07/2016
  8088 00002151 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  8089 00002158 760A                <1> 	jna	short write_ac_c
  8090                              <1> 
  8091 0000215A E8B60A0000          <1> 	call	vga_write_char_attr
  8092 0000215F E957F9FFFF          <1> 	jmp     VIDEO_RETURN	
  8093                              <1> 
  8094                              <1> write_ac_c:
  8095 00002164 E834000000          <1> 	call	_write_c_current
  8096                              <1> 
  8097 00002169 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  8098 0000216C 889E[A7660000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  8099                              <1> 
  8100 00002172 E944F9FFFF          <1>         jmp     VIDEO_RETURN
  8101                              <1> 
  8102                              <1> WRITE_C_CURRENT:
  8103                              <1> 	; 08/07/2016
  8104                              <1> 	; 26/06/2016
  8105                              <1> 	; 12/05/2016
  8106                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  8107                              <1> 	;
  8108                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  8109                              <1> 	;
  8110                              <1> ;----------------------------------------------------------------
  8111                              <1> ; WRITE_C_CURRENT						:
  8112                              <1> ;	THIS ROUTINE WRITES THE CHARACTER AT			:
  8113                              <1> ;	THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED	:
  8114                              <1> ; INPUT								:
  8115                              <1> ;	(AH) = CURRENT CRT MODE					:
  8116                              <1> ;	(BH) = DISPLAY PAGE					:
  8117                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  8118                              <1> ;	(AL) = CHAR TO WRITE					:
  8119                              <1> ;	(DS) = DATA SEGMENT					:
  8120                              <1> ;	(ES) = REGEN SEGMENT					:
  8121                              <1> ; OUTPUT							:
  8122                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  8123                              <1> ;----------------------------------------------------------------
  8124                              <1> 
  8125                              <1> 	; 08/07/2016
  8126 00002177 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  8127 0000217E 760A                <1> 	jna	short write_c_c
  8128                              <1> 
  8129 00002180 E8900A0000          <1> 	call	vga_write_char_only
  8130 00002185 E931F9FFFF          <1> 	jmp     VIDEO_RETURN	
  8131                              <1> 
  8132                              <1> write_c_c:
  8133                              <1> 	;and	bh, 7 ; video page number (<= 7)
  8134 0000218A 0FB6F7              <1> 	movzx	esi, bh	
  8135 0000218D 8A9E[A7660000]      <1> 	mov	bl, [esi+chr_attrib]
  8136                              <1> 
  8137 00002193 E805000000          <1> 	call	_write_c_current
  8138 00002198 E91EF9FFFF          <1>         jmp     VIDEO_RETURN
  8139                              <1> 
  8140                              <1> _write_c_current:  ; from 'write_tty'
  8141                              <1> 	; 12/04/2021
  8142                              <1> 	; 18/11/2020
  8143                              <1> 	; 26/06/2016
  8144                              <1> 	; 24/06/2016
  8145                              <1> 	; 12/05/2016
  8146                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  8147                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  8148                              <1> 	; 18/01/2014
  8149                              <1> 	; 04/12/2013
  8150                              <1> 	;
  8151                              <1> 	; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS
  8152                              <1> 
  8153                              <1> 	; 18/11/2020
  8154 0000219D 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  8155 000021A3 80FC04              <1> 	cmp	ah, 4
  8156 000021A6 720A                <1>  	jb	short p40
  8157                              <1> 	
  8158                              <1> 	;cmp	byte [CRT_MODE], 4
  8159                              <1>         ;jnb	GRAPHICS_WRITE ; 26/06/2016
  8160                              <1> 
  8161 000021A8 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD
  8162 000021AB 7405                <1> 	je	short p40
  8163 000021AD E963070000          <1> 	jmp	GRAPHICS_WRITE
  8164                              <1> p40:
  8165                              <1> 	; al = character
  8166                              <1> 	; bl = color/attribute
  8167                              <1> 	; bh = video page
  8168                              <1> 	; cx = count of characters to write
  8169                              <1> 	;push	dx
  8170                              <1> 	; 12/04/2021
  8171 000021B2 52                  <1> 	push	edx ; *
  8172 000021B3 88DC                <1> 	mov	ah, bl  ; color/attribute (12/05/2016)
  8173                              <1> 	;push	ax	; save character & attribute/color
  8174                              <1> 	;push	cx
  8175                              <1> 	; 12/04/2021
  8176 000021B5 50                  <1> 	push	eax ; ** ; save character & attribute/color
  8177 000021B6 51                  <1> 	push	ecx ; ***
  8178 000021B7 E876FDFFFF          <1> 	call 	find_position  ; get regen location and port address
  8179                              <1> 	;pop	cx
  8180                              <1> 	; 12/04/2021
  8181 000021BC 59                  <1> 	pop	ecx ; ***
  8182                              <1> 	; esi = regen location
  8183                              <1> 	; dx = status port
  8184                              <1> 	;
  8185 000021BD 81C600800B00        <1> 	add	esi, 0B8000h ; 30/08/2014 (crt_base) 
  8186                              <1> 	;
  8187                              <1> 	; 18/11/2020
  8188                              <1> 	; convert display mode to a zero value 
  8189                              <1> 	; for 80 column color mode
  8190                              <1> 	;mov	ah, [CRT_MODE]	
  8191                              <1> 	;sub	ah, 2
  8192                              <1> 	;shr	ah, 1
  8193                              <1> 	;jnz	short p44    ; 26/06/2016
  8194                              <1> 
  8195                              <1> 	; 05/12/2020
  8196                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  8197                              <1> 	;xor	bl, bl	; 0
  8198 000021C3 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  8199                              <1> 	;je	short p41    ; Note: Only mode 03h and mode 01h are
  8200                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  8201                              <1> 	;jmp	short p43    ;       (07h, 00h and 02h are redirected)			
  8202                              <1> 	; 05/12/2020
  8203 000021CA 751A                <1> 	jne	short p44
  8204                              <1> p46:
  8205                              <1> 	; 05/12/2020
  8206 000021CC 3A3D[AE770100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  8207 000021D2 7512                <1> 	jne	short p44
  8208                              <1> 
  8209                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  8210                              <1> p41:
  8211                              <1> 	; 05/12/2020
  8212 000021D4 FB                  <1> 	sti		; enable interrupts first
  8213 000021D5 90                  <1> 	nop
  8214                              <1> 	; 18/11/2020
  8215                              <1> 	;or	bl, bl
  8216                              <1> 	;jnz	short p44 ; mode 01h (and mode 00h) - 40x25 color text
  8217 000021D6 FA                  <1> 	cli 		; block interrupts for single loop
  8218 000021D7 EC                  <1> 	in	al, dx	; get status from the adapter
  8219 000021D8 A808                <1> 	test	al, RVRT ; check for vertical retrace first
  8220 000021DA 7509                <1> 	jnz	short p43 ; Do fast write now if vertical retrace
  8221 000021DC A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  8222 000021DE 75F4                <1> 	jnz	short p41 ; wait until it is
  8223                              <1> p42:			;  wait for either retrace high
  8224 000021E0 EC                  <1> 	in	al, dx ; get status again
  8225 000021E1 A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  8226 000021E3 74FB                <1> 	jz	short p42 ; wait until either retrace active
  8227                              <1> p43:	
  8228 000021E5 FB                  <1> 	sti
  8229                              <1> p44:
  8230 000021E6 668B0424            <1> 	mov	ax, [esp] ; restore the character (al) & attribute (ah)
  8231 000021EA 668906              <1> 	mov	[esi], ax
  8232                              <1> 
  8233 000021ED 6649                <1> 	dec	cx
  8234 000021EF 740D                <1> 	jz	short p45
  8235                              <1> 
  8236 000021F1 46                  <1> 	inc	esi
  8237 000021F2 46                  <1> 	inc	esi
  8238                              <1> 
  8239                              <1> 	; 05/12/2020
  8240 000021F3 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 03h
  8241 000021FA 75EA                <1> 	jne	short p44
  8242                              <1> 	;jmp	short p41
  8243 000021FC EBCE                <1> 	jmp	short p46
  8244                              <1> p45:	
  8245                              <1> 	;pop	ax
  8246                              <1> 	;pop	dx
  8247                              <1> 	; 12/04/2021
  8248 000021FE 58                  <1> 	pop	eax ; **
  8249 000021FF 5A                  <1> 	pop	edx ; *
  8250 00002200 C3                  <1> 	retn
  8251                              <1> 
  8252                              <1> ; 09/07/2016
  8253                              <1> ; 26/06/2016
  8254                              <1> ; 24/06/2016
  8255                              <1> ; 12/05/2016
  8256                              <1> ; 18/01/2016
  8257                              <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0)
  8258                              <1> ; 30/06/2015
  8259                              <1> ; 27/06/2015
  8260                              <1> ; 11/03/2015
  8261                              <1> ; 02/09/2014
  8262                              <1> ; 30/08/2014
  8263                              <1> ; VIDEO FUNCTIONS
  8264                              <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014)
  8265                              <1> 
  8266                              <1> WRITE_TTY:
  8267                              <1> 	; 09/12/2017
  8268                              <1> 	; 09/07/2016
  8269                              <1> 	; 01/07/2016
  8270                              <1> 	; 26/06/2016
  8271                              <1> 	; 24/06/2016
  8272                              <1> 	; 13/05/2016
  8273                              <1> 	; 12/05/2016
  8274                              <1> 	; 30/01/2016
  8275                              <1> 	; 18/01/2016
  8276                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  8277                              <1> 	; 13/08/2015
  8278                              <1> 	; 02/09/2014
  8279                              <1> 	; 30/08/2014 (Retro UNIX 386 v1 - beginning)
  8280                              <1> 	; 01/02/2014 (Retro UNIX 8086 v1 - last update)
  8281                              <1> 	; 03/12/2013 (Retro UNIX 8086 v1 - beginning)	
  8282                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  8283                              <1> 	;
  8284                              <1> 	; INPUT -> AL = Character to be written
  8285                              <1> 	;	   BL = Color (Forecolor, Backcolor)
  8286                              <1> 	;	   BH = Video Page (0 to 7)
  8287                              <1> 
  8288                              <1> 	; 09/07/2016
  8289 00002201 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7
  8290 00002208 760A                <1> 	jna 	short write_tty_cga
  8291                              <1> 
  8292 0000220A E8EB0C0000          <1> 	call	vga_write_teletype
  8293 0000220F E9A7F8FFFF          <1> 	jmp	VIDEO_RETURN
  8294                              <1> 
  8295                              <1> write_tty_cga:
  8296                              <1> 	; 13/05/2016
  8297                              <1> 	;call	_write_tty
  8298                              <1> 	; 01/07/2016
  8299 00002214 E818000000          <1> 	call	_write_tty_m3
  8300 00002219 E99DF8FFFF          <1> 	jmp	VIDEO_RETURN
  8301                              <1> 
  8302                              <1> RVRT	equ	00001000b	; VIDEO VERTICAL RETRACE BIT
  8303                              <1> RHRZ	equ	00000001b	; VIDEO HORIZONTAL RETRACE BIT
  8304                              <1> 
  8305                              <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code
  8306                              <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO
  8307                              <1> ;
  8308                              <1> ; 06/10/85  VIDEO DISPLAY BIOS
  8309                              <1> ;
  8310                              <1> ;--- WRITE_TTY ------------------------------------------------------------------
  8311                              <1> ;										:
  8312                              <1> ;   THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE			:
  8313                              <1> ;   VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT			:
  8314                              <1> ;   CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION.		:
  8315                              <1> ;   IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN		:
  8316                              <1> ;   IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW		:
  8317                              <1> ;   ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW,		:
  8318                              <1> ;   FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE.		:
  8319                              <1> ;   WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE		:
  8320                              <1> ;   NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS		:
  8321                              <1> ;   LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE,		:
  8322                              <1> ;   THE 0 COLOR IS USED.							:
  8323                              <1> ;   ENTRY --									:
  8324                              <1> ;     (AH) = CURRENT CRT MODE							:
  8325                              <1> ;     (AL) = CHARACTER TO BE WRITTEN						:
  8326                              <1> ;	    NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE	:
  8327                              <1> ;	    HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS	:
  8328                              <1> ;     (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE	:
  8329                              <1> ;   EXIT -- 									:
  8330                              <1> ;     ALL REGISTERS SAVED							:
  8331                              <1> ;--------------------------------------------------------------------------------
  8332                              <1> 
  8333                              <1> ; 02/08/2022 (TRDOS 386 v2.0.5)
  8334                              <1> ; 18/11/2020 (TRDOS 386 v2.0.3)
  8335                              <1> ; 09/12/2017
  8336                              <1> ; 08/07/2016
  8337                              <1> ; 26/06/2016
  8338                              <1> ; 24/06/2016
  8339                              <1> _write_tty:
  8340                              <1> 	; 13/05/2016
  8341                              <1> 	; --- 18/11/2020 ---
  8342                              <1> 	; NOTE:
  8343                              <1> 	; Only kernel calls "_write_tty" procedure...
  8344                              <1> 	; TRDOS 386 v2 kernel uses video mode 3 for displaying
  8345                              <1> 	; (some error) messages and also mainprog command interpreter
  8346                              <1> 	; (in kernel) uses "_write_tty".
  8347                              <1> 	; So, here video mode must be set to 3 if it is not 3.
  8348                              <1>  
  8349 0000221E FA                  <1> 	cli	; disable interrupts
  8350                              <1> 	;
  8351                              <1> 	; 01/09/2014
  8352 0000221F 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3
  8353 00002226 7409                <1> 	je	short _write_tty_m3
  8354                              <1> 	;
  8355                              <1> set_mode_3:
  8356 00002228 53                  <1> 	push	ebx
  8357 00002229 50                  <1> 	push	eax
  8358                              <1> 	;call	_set_mode
  8359                              <1> 	; 18/11/2020 
  8360 0000222A E89BF8FFFF          <1> 	call	set_txt_mode  ; set video mode to 03h 
  8361 0000222F 58                  <1> 	pop	eax
  8362 00002230 5B                  <1> 	pop	ebx
  8363                              <1> 	;
  8364                              <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3)
  8365 00002231 0FB6F7              <1> 	movzx 	esi, bh ; 12/05/2016
  8366                              <1> 	;shl	si, 1
  8367                              <1> 	; 02/08/2022
  8368 00002234 D1E6                <1> 	shl	esi, 1
  8369 00002236 81C6[9E770100]      <1> 	add	esi, CURSOR_POSN
  8370 0000223C 668B16              <1> 	mov	dx, [esi]
  8371                              <1> 	;
  8372                              <1> 	; dx now has the current cursor position
  8373                              <1> 	;
  8374 0000223F 3C0D                <1> 	cmp	al, 0Dh	; CR	; is it carriage return or control character
  8375                              <1> 	;jbe	short u8
  8376                              <1> 	; 17/04/2021
  8377 00002241 7241                <1> 	jb	short u8
  8378 00002243 746F                <1> 	je	short u9
  8379                              <1> 	;
  8380                              <1> 	; write the char to the screen
  8381                              <1> u0:	
  8382                              <1> 	; al = character
  8383                              <1> 	; bl = attribute/color
  8384                              <1> 	; bh = video page number (0 to 7)
  8385                              <1> 	;
  8386                              <1> 	;mov	cx, 1  ; 24/06/2016
  8387                              <1> 	; 02/08/2022
  8388 00002245 29C9                <1> 	sub	ecx, ecx
  8389 00002247 FEC1                <1> 	inc	cl ; ecx = 1
  8390                              <1> 	; cx = count of characters to write
  8391                              <1> 	;
  8392 00002249 E84FFFFFFF          <1> 	call	_write_c_current ; 16/01/2015
  8393                              <1> 	;
  8394                              <1> 	; position the cursor for next char
  8395 0000224E FEC2                <1> 	inc	dl		; next column
  8396 00002250 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]  ; test for column overflow 
  8397                              <1> 	;jne	_set_cpos
  8398                              <1> 	; 02/08/2022
  8399 00002256 7402                <1> 	je	short u13
  8400 00002258 EB5C                <1> 	jmp	_set_cpos
  8401                              <1> u13:
  8402 0000225A B200                <1> 	mov	dl, 0		; column = 0
  8403                              <1> u10:				; (line feed found)
  8404 0000225C 80FE18              <1> 	cmp	dh, 25-1 	; check for last row
  8405 0000225F 721F                <1> 	jb 	short u6
  8406                              <1> 	;
  8407                              <1> 	; scroll required
  8408                              <1> u1:	
  8409                              <1> 	; SET CURSOR POSITION (04/12/2013)
  8410 00002261 E850000000          <1> 	call	_set_cpos
  8411                              <1> 	;
  8412                              <1> 	; determine value to fill with during scroll
  8413                              <1> u2:
  8414                              <1> 	; bh = video page number
  8415                              <1> 	;
  8416 00002266 E8A3FEFFFF          <1> 	call	_read_ac_current ; 18/01/2016
  8417                              <1> 	;
  8418                              <1> 	; al = character, ah = attribute
  8419                              <1> 	; bh = video page number
  8420                              <1> 	; 18/11/2020
  8421 0000226B 88E3                <1> 	mov	bl, ah ; color/attribute 	
  8422                              <1> u3:
  8423                              <1> 	;;mov	ax, 0601h 	; scroll one line
  8424                              <1> 	;;sub	cx, cx		; upper left corner
  8425                              <1> 	;;mov	dh, 25-1 	; lower right row
  8426                              <1> 	;;;mov	dl, [CRT_COLS]
  8427                              <1> 	;mov	dl, 80		; lower right column	
  8428                              <1> 	;;dec	dl
  8429                              <1> 	;;mov	dl, 79
  8430                              <1> 
  8431                              <1> 	;;call	scroll_up	; 04/12/2013
  8432                              <1> 	;;; 11/03/2015
  8433                              <1> 	; 02/09/2014
  8434                              <1> 	;;;mov	cx, [crt_ulc] ; Upper left corner  (0000h)
  8435                              <1> 	;;;mov	dx, [crt_lrc] ; Lower right corner (184Fh)
  8436                              <1> 	; 11/03/2015
  8437                              <1> 	;sub	cx, cx
  8438                              <1> 	; 17/04/2021
  8439 0000226D 29C9                <1> 	sub	ecx, ecx
  8440                              <1> 	;mov	dx, 184Fh ; dl = 79 (column), dh = 24 (row)
  8441                              <1> 	; 18/11/2020
  8442 0000226F B618                <1> 	mov	dh, 25-1
  8443 00002271 8A15[A0660000]      <1> 	mov	dl, [CRT_COLS]
  8444 00002277 FECA                <1> 	dec	dl
  8445                              <1> 	;
  8446 00002279 B001                <1> 	mov	al, 1		; scroll 1 line up
  8447                              <1> 		; ah = attribute
  8448                              <1> 	;mov	bl, al ; 12/05/2016
  8449 0000227B E9F0FCFFFF          <1> 	jmp	_scroll_up	; 16/01/2016
  8450                              <1> ;u4:
  8451                              <1> 	;;int	10h		; video-call return
  8452                              <1> 				; scroll up the screen
  8453                              <1> 				; tty return
  8454                              <1> ;u5:
  8455                              <1> 	;retn			; return to the caller
  8456                              <1> 
  8457                              <1> u6:				; set-cursor-inc
  8458 00002280 FEC6                <1> 	inc	dh		; next row
  8459                              <1> 				; set cursor
  8460                              <1> ;u7:					
  8461                              <1> 	;;mov	ah, 02h
  8462                              <1> 	;;jmp	short u4 	; establish the new cursor
  8463                              <1> 	;call	_set_cpos
  8464                              <1> 	;jmp 	short u5
  8465 00002282 EB32                <1> 	jmp     _set_cpos
  8466                              <1> 
  8467                              <1> 	; check for control characters
  8468                              <1> u8:
  8469                              <1> 	;je	short u9 ; 17/04/2021
  8470 00002284 3C0A                <1> 	cmp	al, 0Ah		; is it a line feed (0Ah)
  8471 00002286 74D4                <1> 	je	short u10
  8472 00002288 3C07                <1> 	cmp	al, 07h 	; is it a bell
  8473 0000228A 747C                <1> 	je	short u11
  8474 0000228C 3C08                <1> 	cmp	al, 08h		; is it a backspace
  8475                              <1> 	;jne	short u0
  8476 0000228E 741C                <1> 	je	short bs	; 12/12/2013
  8477                              <1> 	; 12/12/2013 (tab stop)
  8478 00002290 3C09                <1> 	cmp	al, 09h		; is it a tab stop
  8479 00002292 75B1                <1> 	jne	short u0
  8480 00002294 88D0                <1> 	mov	al, dl
  8481                              <1> 	;cbw
  8482 00002296 30E4                <1> 	xor	ah, ah ; 09/12/2017
  8483 00002298 B108                <1> 	mov	cl, 8
  8484 0000229A F6F1                <1> 	div	cl
  8485 0000229C 28E1                <1> 	sub	cl, ah
  8486                              <1> ts:
  8487                              <1> 	; 02/09/2014
  8488                              <1> 	; 01/09/2014
  8489                              <1> 	;mov	al, 20h
  8490                              <1> tsloop:
  8491                              <1> 	;push	cx
  8492                              <1> 	; 12/04/2021
  8493 0000229E 51                  <1> 	push	ecx ; *
  8494                              <1> 	; 18/11/2020
  8495                              <1> 	;push	ax
  8496                              <1> 	;;mov	bh, [ACTIVE_PAGE]
  8497                              <1> 	; 05/12/2020
  8498                              <1> 	;push	bx
  8499 0000229F B020                <1> 	mov	al, 20h ; al = space (blank) 
  8500                              <1> 			; bl = color/attribute
  8501 000022A1 E88BFFFFFF          <1> 	call	_write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3)
  8502                              <1> 	; 05/12/2020
  8503                              <1> 	; bx is preserved in '_write_tty_m3'
  8504                              <1> 	; 18/11/2020
  8505                              <1> 	;pop	bx  ; BL = color/attribute, Bh = video page 
  8506                              <1> 	;pop	ax  ; AL = character
  8507                              <1> 	; 12/04/2021
  8508                              <1> 	;pop	cx
  8509 000022A6 59                  <1> 	pop	ecx ; *
  8510 000022A7 FEC9                <1> 	dec	cl
  8511 000022A9 75F3                <1> 	jnz	short tsloop
  8512 000022AB C3                  <1> 	retn
  8513                              <1> bs:	
  8514                              <1> 	; back space found
  8515                              <1> 
  8516 000022AC 08D2                <1> 	or	dl, dl 		; is it already at start of line
  8517                              <1> 	;je	short u7 	; set_cursor
  8518 000022AE 7406                <1> 	jz	short _set_cpos
  8519                              <1> 	;dec	dx     		; no -- just move it back
  8520                              <1> 	; 17/04/2021
  8521 000022B0 FECA                <1> 	dec	dl		; move to 1 column back
  8522                              <1> 	;jmp	short u7
  8523 000022B2 EB02                <1> 	jmp	short _set_cpos
  8524                              <1> 
  8525                              <1> 	; carriage return found
  8526                              <1> u9:
  8527 000022B4 B200                <1> 	mov	dl, 0 		; move to first column
  8528                              <1> 	;jmp	short u7
  8529                              <1> 	;jmp	short _set_cpos ; 30/01/2016
  8530                              <1> 
  8531                              <1> 	; line feed found
  8532                              <1> ;u10:
  8533                              <1> ;	cmp	dh, 25-1 	; bottom of screen
  8534                              <1> ;	jne	short u6 	; no, just set the cursor
  8535                              <1> ;       jmp     u1              ; yes, scroll the screen
  8536                              <1> 
  8537                              <1> _set_cpos:
  8538                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
  8539                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  8540                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  8541                              <1> 	; 27/06/2015
  8542                              <1> 	; 01/09/2014
  8543                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  8544                              <1> 	;
  8545                              <1> 	; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 
  8546                              <1> 	;
  8547                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  8548                              <1> 	;
  8549                              <1> ;----------------------------------------------
  8550                              <1> ; SET_CPOS
  8551                              <1> ;	THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE
  8552                              <1> ;	NEW X-Y VALUES PASSED
  8553                              <1> ; INPUT
  8554                              <1> ;	DX - ROW,COLUMN OF NEW CURSOR
  8555                              <1> ;	BH - DISPLAY PAGE OF CURSOR
  8556                              <1> ; OUTPUT
  8557                              <1> ;	CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY
  8558                              <1> ;----------------------------------------------
  8559                              <1> 	;
  8560 000022B6 BE[9E770100]        <1> 	mov	esi, CURSOR_POSN
  8561 000022BB 0FB6C7              <1>         movzx   eax, bh	; BH = video page number
  8562                              <1> ;	or	al, al
  8563                              <1> ;	jz	short _set_cpos_0
  8564 000022BE D0E0                <1>         shl     al, 1   ; word offset
  8565 000022C0 01C6                <1>         add     esi, eax
  8566                              <1> ;_set_cpos_0:
  8567 000022C2 668916              <1> 	mov	[esi], dx ; save the pointer
  8568 000022C5 383D[AE770100]      <1> 	cmp	[ACTIVE_PAGE], bh
  8569 000022CB 7532                <1> 	jne	short m17
  8570                              <1> 	;call	m18	; CURSOR SET
  8571                              <1> ;m17:			; SET_CPOS_RETURN
  8572                              <1> 	; 01/09/2014
  8573                              <1> ;	retn
  8574                              <1> 		; DX = row/column
  8575                              <1> m18:
  8576 000022CD E852FCFFFF          <1> 	call	position ; determine location in regen buffer	
  8577 000022D2 668B0D[9C770100]    <1> 	mov	cx, [CRT_START]
  8578 000022D9 6601C1              <1> 	add	cx, ax  ; add char position in regen buffer
  8579                              <1> 			; to the start address (offset) for this page
  8580 000022DC 66D1E9              <1> 	shr	cx, 1	; divide by 2 for char only count
  8581 000022DF B40E                <1> 	mov	ah, 14	; register number for cursor
  8582                              <1> 	;call	m16	; output value to the 6845	
  8583                              <1> 	;retn
  8584                              <1> 
  8585                              <1> 	;-----	THIS ROUTINE OUTPUTS THE CX REGISTER
  8586                              <1> 	;	TO THE 6845 REGISTERS NAMED IN (AH)
  8587                              <1> m16:
  8588 000022E1 FA                  <1> 	cli
  8589                              <1> 	;mov	dx, [addr_6845] ; address register
  8590 000022E2 66BAD403            <1> 	mov 	dx, 03D4h ; I/O address of color card
  8591 000022E6 88E0                <1> 	mov	al, ah	; get value
  8592 000022E8 EE                  <1> 	out	dx, al	; register set
  8593                              <1> 	;inc	dx	; data register
  8594                              <1> 	; 17/04/2021
  8595 000022E9 FEC2                <1> 	inc	dl
  8596 000022EB EB00                <1> 	jmp	$+2	; i/o delay
  8597 000022ED 88E8                <1> 	mov	al, ch	; data
  8598 000022EF EE                  <1> 	out	dx, al	
  8599                              <1> 	;dec	dx	
  8600                              <1> 	; 17/04/2021
  8601 000022F0 FECA                <1> 	dec	dl
  8602 000022F2 88E0                <1> 	mov	al, ah
  8603 000022F4 FEC0                <1> 	inc	al	; point to other data register
  8604 000022F6 EE                  <1> 	out	dx, al	; set for second register
  8605                              <1> 	;inc	dx
  8606                              <1> 	; 17/04/2021
  8607 000022F7 FEC2                <1> 	inc	dl
  8608 000022F9 EB00                <1> 	jmp	$+2	; i/o delay
  8609 000022FB 88C8                <1> 	mov	al, cl	; second data value
  8610 000022FD EE                  <1> 	out	dx, al
  8611 000022FE FB                  <1> 	sti
  8612                              <1> m17:
  8613 000022FF C3                  <1> 	retn
  8614                              <1> 
  8615                              <1> _beep:
  8616                              <1> 	; 12/02/2021 (TRDOS v2.0.3)
  8617 00002300 FA                  <1> 	cli
  8618 00002301 E811000000          <1> 	call	beep
  8619 00002306 FB                  <1> 	sti
  8620 00002307 C3                  <1> 	retn
  8621                              <1> 
  8622                              <1> beeper: 
  8623                              <1> 	; 04/08/2016
  8624                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  8625                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  8626                              <1> 	; 18/01/2014
  8627                              <1> 	; 03/12/2013
  8628                              <1> 	; bell found
  8629                              <1> u11:
  8630 00002308 FB                  <1> 	sti
  8631 00002309 3A3D[AE770100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  8632 0000230F 7552                <1> 	jne	short u12	; Do not sound the beep 
  8633                              <1> 				; if it is not written on the active page
  8634                              <1> beeper_gfx: ; 04/08/2016
  8635 00002311 66B93305            <1> 	mov	cx, 1331 	; divisor for 896 hz tone
  8636 00002315 B31F                <1> 	mov	bl, 31		; set count for 31/64 second for beep
  8637                              <1> 	;call	beep		; sound the pod bell
  8638                              <1> 	;jmp	short u5 	; tty_return
  8639                              <1> 	;retn
  8640                              <1> 	
  8641                              <1> TIMER	equ 	040h   		; 8254 TIMER - BASE ADDRESS
  8642                              <1> PORT_B	equ	061h		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  8643                              <1> GATE2	equ	00000001b	; TIMER 2 INPUT CATE CLOCK BIT
  8644                              <1> SPK2	equ	00000010b	; SPEAKER OUTPUT DATA ENABLE BIT
  8645                              <1> 
  8646                              <1> beep:
  8647                              <1> 	; 12/02/2021
  8648                              <1> 	; 07/02/2015
  8649                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  8650                              <1> 	; 18/01/2014
  8651                              <1> 	; 03/12/2013
  8652                              <1> 	;
  8653                              <1> 	; TEST4.ASM - 06/10/85  POST AND BIOS UTILITY ROUTINES
  8654                              <1> 	;
  8655                              <1> 	; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE
  8656                              <1> 	;
  8657                              <1> 	; ENTRY:
  8658                              <1> 	;    (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND )
  8659                              <1> 	;    (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ)
  8660                              <1> 	; EXIT:				:
  8661                              <1> 	;    (AX),(BL),(CX) MODIFIED.
  8662                              <1> 
  8663 00002317 9C                  <1> 	pushfd  ; 18/01/2014	; save interrupt status
  8664 00002318 FA                  <1> 	cli			; block interrupts during update
  8665 00002319 B0B6                <1> 	mov	al, 10110110b	; select timer 2, lsb, msb binary
  8666 0000231B E643                <1> 	out	TIMER+3, al 	; write timer mode register
  8667 0000231D EB00                <1> 	jmp	$+2		; I/O delay
  8668 0000231F 88C8                <1> 	mov	al, cl		; divisor for hz (low)
  8669 00002321 E642                <1> 	out	TIMER+2,AL	; write timer 2 count - lsb
  8670 00002323 EB00                <1> 	jmp	$+2		; I/O delay
  8671 00002325 88E8                <1> 	mov	al, ch		; divisor for hz (high)
  8672 00002327 E642                <1> 	out	TIMER+2, al	; write timer 2 count - msb
  8673 00002329 E461                <1> 	in	al, PORT_B	; get current setting of port
  8674 0000232B 88C4                <1> 	mov	ah, al		; save that setting
  8675 0000232D 0C03                <1> 	or	al, GATE2+SPK2	; gate timer 2 and turn speaker on
  8676 0000232F E661                <1> 	out	PORT_B, al	; and restore interrupt status
  8677                              <1> 	; 12/02/2021
  8678 00002331 9D                  <1> 	popfd	; 18/01/2014
  8679                              <1> 	;sti
  8680                              <1> g7:				; 1/64 second per count (bl)
  8681 00002332 B90B040000          <1> 	mov	ecx, 1035	; delay count for 1/64 of a second
  8682 00002337 E828000000          <1> 	call	waitf		; go to beep delay 1/64 count
  8683 0000233C FECB                <1> 	dec	bl		; (bl) length count expired?
  8684 0000233E 75F2                <1> 	jnz	short g7	; no - continue beeping speaker
  8685                              <1> 	;
  8686 00002340 9C                  <1> 	pushfd	; 12/02/2021	; save interrupt status
  8687 00002341 FA                  <1> 	cli  	; 18/01/2014	; block interrupts during update
  8688 00002342 E461                <1> 	in	al, PORT_B	; get current port value
  8689                              <1>         ;or	al, not (GATE2+SPK2) ; isolate current speaker bits in case
  8690 00002344 0CFC                <1>         or      al, ~(GATE2+SPK2)
  8691 00002346 20C4                <1>         and	ah, al		; someone turned them off during beep
  8692 00002348 88E0                <1> 	mov	al, ah		; recover value of port
  8693                              <1>         ;or	al, not (GATE2+SPK2) ; force speaker data off
  8694 0000234A 0CFC                <1> 	or 	al, ~(GATE2+SPK2) ; isolate current speaker bits in case
  8695 0000234C E661                <1> 	out	PORT_B, al	; and stop speaker timer
  8696 0000234E 9D                  <1> 	popfd	; 12/02/2021		; restore interrupt flag state
  8697                              <1> 	;sti
  8698                              <1> 	;mov	ecx, 1035	; force 1/64 second delay (short)
  8699                              <1> 	; 17/04/2021
  8700 0000234F 66B90B04            <1> 	mov	cx, 1035
  8701 00002353 E80C000000          <1> 	call	waitf		; minimum delay between all beeps
  8702 00002358 9C                  <1> 	pushfd			; save interrupt status
  8703 00002359 FA                  <1> 	cli			; block interrupts during update
  8704 0000235A E461                <1> 	in	al, PORT_B	; get current port value in case
  8705 0000235C 2403                <1> 	and	al, GATE2+SPK2	; someone turned them on
  8706 0000235E 08E0                <1> 	or	al, ah		; recover value of port_b
  8707 00002360 E661                <1> 	out	PORT_B, al	; restore speaker status
  8708 00002362 9D                  <1> 	popfd			; restore interrupt flag state
  8709                              <1> u12:	
  8710 00002363 C3                  <1> 	retn
  8711                              <1> 
  8712                              <1> REFRESH_BIT equ	00010000b 	; REFRESH TEST BIT
  8713                              <1> 
  8714                              <1> WAITF:
  8715                              <1> waitf:
  8716                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  8717                              <1> 	; 03/12/2013
  8718                              <1> 	;
  8719                              <1> ;	push	ax		; save work register (ah)
  8720                              <1> ;waitf1:
  8721                              <1> 				; use timer 1 output bits
  8722                              <1> ;	in	al, PORT_B	; read current counter output status
  8723                              <1> ;	and	al, REFRESH_BIT	; mask for refresh determine bit
  8724                              <1> ;	cmp	al, ah		; did it just change
  8725                              <1> ;	je	short waitf1	; wait for a change in output line
  8726                              <1> ;	;
  8727                              <1> ;	mov	ah, al		; save new lflag state
  8728                              <1> ;	loop	waitf1		; decrement half cycles till count end
  8729                              <1> ;	;
  8730                              <1> ;	pop	ax		; restore (ah)
  8731                              <1> ;	retn			; return (cx)=0
  8732                              <1> 
  8733                              <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s)
  8734                              <1> ; 17/12/2014 (dsectrm2.s)
  8735                              <1> ; WAITF
  8736                              <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 ///
  8737                              <1> ;
  8738                              <1> ;---WAITF-----------------------------------------------------------------------
  8739                              <1> ;	FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR)
  8740                              <1> ; ENTRY:
  8741                              <1> ;	(CX) =	COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT
  8742                              <1> ;	      	MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE
  8743                              <1> ; EXIT:
  8744                              <1> ;	       	AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS)
  8745                              <1> ;	(CX) = 0	
  8746                              <1> ;-------------------------------------------------------------------------------
  8747                              <1> 
  8748                              <1> ; Refresh period: 30 micro seconds (15-80 us)
  8749                              <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH)
  8750                              <1> 
  8751                              <1> ;WAITF:					; DELAY FOR (CX)*15.085737 US
  8752                              <1> 	;push	AX			; SAVE WORK REGISTER (AH)
  8753                              <1> 	; 11/04/2021
  8754 00002364 50                  <1> 	push	eax
  8755                              <1> 	; 16/12/2014
  8756                              <1> 	;shr	cx, 1			; convert to count of 30 micro seconds
  8757 00002365 D1E9                <1> 	shr	ecx, 1	; 21/02/2015
  8758                              <1> ;17/12/2014	
  8759                              <1> ;WAITF1:
  8760                              <1> ;	in	al, PORT_B   ;061h	; READ CURRENT COUNTER OUTPUT STATUS
  8761                              <1> ;	and	al, REFRESH_BIT	;00010000b ; MASK FOR REFRESH DETERMINE BIT
  8762                              <1> ;	cmp	al, ah			; DID IT JUST CHANGE
  8763                              <1> ;	je	short WAITF1		; WAIT FOR A CHANGE IN OUTPUT LINE
  8764                              <1> ;	mov	ah, al			; SAVE NEW FLAG STATE
  8765                              <1> ;	loop	WAITF1			; DECREMENT HALF CYCLES TILL COUNT END		
  8766                              <1> 	;
  8767                              <1> 	; 17/12/2014
  8768                              <1> 	;
  8769                              <1> 	; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999
  8770                              <1> 	;
  8771                              <1> ;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
  8772                              <1> ;   	INPUT:  CX = number of refresh periods to wait
  8773                              <1> ;     	       (refresh periods = 1 per 30 microseconds on most machines)
  8774                              <1> WR_STATE_0:
  8775 00002367 E461                <1> 	in	al, PORT_B		; IN AL,SYS1
  8776 00002369 A810                <1> 	test	al, 010h
  8777 0000236B 74FA                <1> 	JZ	short WR_STATE_0
  8778                              <1> WR_STATE_1:
  8779 0000236D E461                <1> 	in	al, PORT_B		; IN AL,SYS1
  8780 0000236F A810                <1> 	test	al, 010h
  8781 00002371 75FA                <1> 	jnz	short WR_STATE_1
  8782 00002373 E2F2                <1>         loop    WR_STATE_0
  8783                              <1> 	;
  8784                              <1> 	;pop	ax			; RESTORE (AH)
  8785                              <1> 	; 11/04/2021
  8786 00002375 58                  <1> 	pop	eax
  8787 00002376 C3                  <1> 	retn				; (CX) = 0
  8788                              <1> 
  8789                              <1> ; 03/08/2022
  8790                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  8791                              <1> ; 09/07/2016
  8792                              <1> ; 01/07/2016
  8793                              <1> ; 24/06/2016
  8794                              <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0)
  8795                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  8796                              <1> ;-------------------------------------------------------------------------------
  8797                              <1> ; WRITE_STRING								       :
  8798                              <1> ;	THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT.		       :
  8799                              <1> ; INPUT 								       :
  8800                              <1> ;	(AL) = WRITE STRING COMMAND  0 - 3				       :
  8801                              <1> ;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				       :
  8802                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	       :
  8803                              <1> ;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		       :
  8804                              <1> ;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1       :
  8805                              <1> ;	(EBP) = SOURCE STRING OFFSET					       :
  8806                              <1> ; OUTPUT								       :
  8807                              <1> ;	NONE								       :
  8808                              <1> ;-------------------------------------------------------------------------------
  8809                              <1> 
  8810                              <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  8811                              <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor
  8812                              <1> ; AL = 02h: Use attributes in string; do not update cursor
  8813                              <1> ; AL = 03h: Use attributes in string; update cursor
  8814                              <1> 
  8815                              <1> WRITE_STRING:
  8816                              <1> 	; 03/08/2022
  8817                              <1> 	; 02/08/2022
  8818                              <1> 	; 12/09/2016
  8819                              <1> 	; 09/07/2016
  8820                              <1> 	;cmp	byte [CRT_MODE], 7 ; 6?!
  8821                              <1> 	;ja	VIDEO_RETURN		; not a valid function for VGA modes
  8822                              <1> 	;
  8823 00002377 A2[10840100]        <1> 	mov	[w_str_cmd], al		; save (AL) command
  8824 0000237C 3C04                <1> 	cmp	al, 4			; TEST FOR INVALID WRITE STRING OPTION
  8825                              <1> 	;jnb	VIDEO_RETURN		; IF OPTION INVALID THEN RETURN
  8826                              <1> 	; 02/08/2022
  8827 0000237E 7361                <1> 	jnb	short P55
  8828                              <1> 
  8829                              <1>         ;jcxz	VIDEO_RETURN		; IF ZERO LENGTH STRING THEN RETURN
  8830                              <1> 
  8831 00002380 67E35E              <1>         jcxz    P55			; 01/07/2016
  8832                              <1> 
  8833                              <1> 	; 01/07/2016
  8834                              <1> 	;and	ecx, 0FFFFh
  8835                              <1> 	; ecx = byte count
  8836                              <1> 	;push	ecx
  8837 00002383 89EE                <1> 	mov	esi, ebp ; user buffer
  8838 00002385 BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  8839 0000238A E8E8E90000          <1> 	call	transfer_from_user_buffer
  8840                              <1> 	;pop	ecx
  8841                              <1> 	;jc	VIDEO_RETURN
  8842                              <1> 	; 02/08/2022
  8843 0000238F 7250                <1> 	jc	short P55
  8844                              <1> 	; ecx = transfer (byte) count = character count
  8845 00002391 BD00000700          <1> 	mov	ebp, Cluster_Buffer
  8846                              <1> 	; 12/09/2016
  8847 00002396 803D[9E660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6?!
  8848                              <1> 	;ja	vga_write_string
  8849                              <1> 	; 02/08/2022
  8850 0000239D 7605                <1> 	jna	short P57
  8851 0000239F E99C000000          <1> 	jmp	vga_write_string
  8852                              <1> P57:
  8853 000023A4 0FB6F7              <1> 	movzx	esi, bh			; GET CURRENT CURSOR PAGE
  8854                              <1> 	;sal	si, 1			; CONVERT TO PAGE OFFSET (SI = PAGE)
  8855                              <1> 	; 02/08/2022
  8856 000023A7 D1E6                <1> 	sal	esi, 1
  8857                              <1> 	; *****
  8858 000023A9 66FFB6[9E770100]    <1> 	push	word [esi+CURSOR_POSN]	; SAVE CURRENT CURSOR POSITION IN STACK
  8859                              <1> 
  8860                              <1> 	;mov	ax, 0200h		; SET NEW CURSOR POSITION
  8861                              <1> 	;int	10h
  8862                              <1> P50next:	
  8863 000023B0 51                  <1> 	push	ecx ; ****
  8864 000023B1 53                  <1> 	push	ebx ; *** ; 18/11/2020
  8865 000023B2 56                  <1> 	push	esi ; **
  8866 000023B3 52                  <1> 	push	edx ; *
  8867 000023B4 E8FDFEFFFF          <1> 	call	_set_cpos
  8868                              <1> P50:
  8869 000023B9 8A4500              <1> 	mov	al, [ebp]		; GET CHARACTER FROM INPUT STRING
  8870 000023BC 45                  <1> 	inc	ebp			; BUMP POINTER TO CHARACTER
  8871                              <1> 
  8872                              <1> ;-----	TEST FOR SPECIAL CHARACTER'S
  8873                              <1> 
  8874 000023BD 3C08                <1> 	cmp	al, 08h			; IS IT A BACKSPACE
  8875 000023BF 7410                <1> 	je	short P51		; BACK_SPACE
  8876 000023C1 3C0D                <1> 	cmp	al, 0Dh ; CR		; IS IT CARRIAGE RETURN
  8877 000023C3 740C                <1> 	je	short P51		; CAR_RET
  8878 000023C5 3C0A                <1> 	cmp	al, 0Ah ; LF		; IS IT A LINE FEED
  8879 000023C7 7408                <1> 	je	short P51		; LINE_FEED
  8880                              <1> 	; 18/11/2020
  8881 000023C9 3C09                <1> 	cmp	al, 09h			; is it a tab stop
  8882 000023CB 7404                <1> 	je	short P51
  8883                              <1> 	;
  8884 000023CD 3C07                <1> 	cmp	al, 07h			; IS IT A BELL
  8885 000023CF 7515                <1> 	jne	short P52		; IF NOT THEN DO WRITE CHARACTER
  8886                              <1> P51:
  8887                              <1> 	;mov	ah, 0Eh			; TTY_CHARACTER_WRITE
  8888                              <1> 	;int	10h			; WRITE TTY CHARACTER TO THE CRT
  8889                              <1> 	
  8890 000023D1 E85BFEFFFF          <1> 	call	_write_tty_m3
  8891                              <1> 
  8892 000023D6 5A                  <1> 	pop	edx ; *
  8893 000023D7 5E                  <1> 	pop	esi ; **
  8894                              <1> 
  8895 000023D8 668B96[9E770100]    <1> 	mov	dx, [esi+CURSOR_POSN]	; GET CURRENT CURSOR POSITION
  8896 000023DF EB44                <1> 	jmp	short P54		; SET CURSOR POSITION AND CONTINUE
  8897                              <1> P55:
  8898 000023E1 E9D5F6FFFF          <1> 	jmp	VIDEO_RETURN
  8899                              <1> P52:
  8900                              <1> 	;mov	cx, 1			; SET CHARACTER WRITE AMOUNT TO ONE
  8901                              <1> 	; 02/08/2022
  8902 000023E6 29C9                <1> 	sub	ecx, ecx
  8903 000023E8 FEC1                <1> 	inc	cl
  8904                              <1> 	; ecx = 1
  8905 000023EA 803D[10840100]02    <1> 	cmp	byte [w_str_cmd], 2	; IS THE ATTRIBUTE IN THE STRING
  8906 000023F1 7204                <1> 	jb	short P53		; IF NOT THEN SKIP
  8907 000023F3 8A5D00              <1> 	mov	bl, [ebp]		; ELSE GET NEW ATTRIBUTE
  8908 000023F6 45                  <1> 	inc	ebp			; BUMP STRING POINTER
  8909                              <1> P53:
  8910                              <1> 	;mov	ah, 09h			; GOT_CHARACTER
  8911                              <1> 	;int	10h			; WRITE CHARACTER TO THE CRT
  8912                              <1> 
  8913 000023F7 E8A1FDFFFF          <1> 	call	_write_c_current
  8914                              <1> 	
  8915 000023FC 5A                  <1> 	pop	edx ; *	
  8916                              <1> 
  8917                              <1> 	; 05/12/2020
  8918                              <1> 	; bx is preserved in '_write_c_current'
  8919                              <1> 	; 18/11/2020
  8920                              <1> 	;mov	ebx, [esp+4]	; ***
  8921                              <1> 
  8922 000023FD 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  8923 00002400 889E[A7660000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  8924                              <1> 
  8925 00002406 FEC2                <1> 	inc	dl			; INCREMENT COLUMN COUNTER
  8926 00002408 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]		; IF COLS ARE WITHIN RANGE FOR THIS MODE
  8927                              <1> 	;jb	short P54		;    THEN GO TO COLUMNS SET
  8928 0000240E 7214                <1> 	jb	short P56 ; 05/12/2020
  8929 00002410 FEC6                <1> 	inc	dh			; BUMP ROW COUNTER BY ONE
  8930 00002412 28D2                <1> 	sub	dl, dl			; SET COLUMN COUNTER TO ZERO
  8931 00002414 80FE19              <1> 	cmp	dh, 25			; IF ROWS ARE LESS THAN 25 THEN
  8932                              <1> 	;jb	short P54		; GO TO ROWS_COLUMNS_SET
  8933 00002417 720B                <1> 	jb	short P56 ; 05/12/2020
  8934                              <1> 
  8935                              <1> 	; 18/11/2020
  8936                              <1> 	;mov	ax, 0E0Ah		; ELSE SCROLL SCREEN
  8937                              <1> 	;int	10h			; RESET ROW COUNTER TO 24
  8938                              <1> 
  8939                              <1> 	; 18/11/2020
  8940 00002419 B00A                <1> 	mov	al, 0Ah	; line feed
  8941                              <1> 
  8942 0000241B E811FEFFFF          <1> 	call	_write_tty_m3
  8943                              <1> 	
  8944 00002420 66BA0018            <1> 	mov	dx, 1800h		; Column = 0, Row = 24
  8945                              <1> P56:	
  8946                              <1> 	; 05/12/2020
  8947                              <1> 	; 18/11/2020
  8948 00002424 5E                  <1> 	pop	esi ; **
  8949                              <1> P54:					; ROW_COLUMNS_SET
  8950                              <1> 	;mov	ax, 0200h		; SET NEW CURSOR POSITION COMMAND
  8951                              <1> 	;int	10h			; ESTABLISH NEW CURSOR POSITION
  8952                              <1> 
  8953                              <1> 	; 18/11/2020
  8954 00002425 5B                  <1> 	pop	ebx ; ***
  8955 00002426 59                  <1> 	pop	ecx ; ****
  8956                              <1> 
  8957                              <1> 	;loop	P50			; DO IT ONCE MORE UNTIL (CX) = ZERO
  8958 00002427 6649                <1> 	dec	cx
  8959 00002429 7585                <1> 	jnz	short P50next
  8960                              <1> 
  8961 0000242B 665A                <1> 	pop	dx  ; *****		; RESTORE OLD CURSOR COORDINATES
  8962                              <1> 	
  8963 0000242D F605[10840100]01    <1> 	test	byte [w_str_cmd], 1	; IF CURSOR WAS NOT TO BE MOVED
  8964                              <1> 	;jnz	VIDEO_RETURN		; THEN EXIT WITHOUT RESETTING OLD VALUE
  8965                              <1> 	; 03/08/2022
  8966 00002434 7505                <1> 	jnz	short P58
  8967                              <1> 	
  8968                              <1> 	;mov	ax, 0200h		; ELSE RESTORE OLD CURSOR POSITION
  8969                              <1> 	;int	10h
  8970                              <1> 					; DONE - EXIT WRITE STRING
  8971 00002436 E87BFEFFFF          <1> 	call	_set_cpos
  8972                              <1> P58:
  8973 0000243B E97BF6FFFF          <1> 	jmp	VIDEO_RETURN		; RETURN TO CALLER
  8974                              <1> 
  8975                              <1> vga_write_string:
  8976                              <1> 	; 04/08/2022 - TRDOS 386 Kernel v2.0.5
  8977                              <1> 	; 12/09/2016 - TRDOS 386 (TRDOS v2.0)
  8978                              <1> 	;
  8979                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8980                              <1> 	; vgabios-0.7a (2011)
  8981                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8982                              <1> 	; 'vgabios.c', ' biosfn_write_string'
  8983                              <1> 
  8984                              <1> 	; INPUT 								  :
  8985                              <1> 	;	(AL) = WRITE STRING COMMAND  0 - 3				  :
  8986                              <1> 	;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				  :
  8987                              <1> 	;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	  :
  8988                              <1> 	;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		  :
  8989                              <1> 	;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1  :
  8990                              <1> 	;	(EBP) = SOURCE STRING OFFSET					  :
  8991                              <1> 	; OUTPUT								  :
  8992                              <1> 	;	NONE								  :
  8993                              <1> 	;-------------------------------------------------------------------------;
  8994                              <1> 
  8995                              <1> 	; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  8996                              <1> 	; AL = 01h: Assign all characters the attribute in BL; update cursor
  8997                              <1> 	; AL = 02h: Use attributes in string; do not update cursor
  8998                              <1> 	; AL = 03h: Use attributes in string; update cursor
  8999                              <1> 	
  9000                              <1> 	; biosfn_write_string(GET_AL(),GET_BH(),GET_BL(),CX,GET_DH(),GET_DL(),ES,BP);
  9001                              <1> 	; static void biosfn_write_string (flag,page,attr,count,row,col,seg,offset) 
  9002                              <1> 
  9003                              <1> 	; // Read curs info for the page
  9004                              <1>  	; biosfn_get_cursor_pos(page,&dummy,&oldcurs);
  9005                              <1> 	; bh = video page = 0
  9006                              <1> 	;movzx	esi, word [CURSOR_POSN] ; current cursor position for video page 0
  9007                              <1> 	
  9008                              <1> 	; // if row=0xff special case : use current cursor position
  9009                              <1> 	; if(row==0xff)
  9010                              <1> 	;  {col=oldcurs&0x00ff;
  9011                              <1> 	;   row=(oldcurs&0xff00)>>8;
  9012                              <1> 	;  }
  9013                              <1> 
  9014                              <1> 	;mov	al, [w_str_cmd]
  9015                              <1> 
  9016 00002440 80FEFF              <1> 	cmp	dh, 0FFh
  9017 00002443 7407                <1> 	je	short vga_wstr_1 ; user current cursor position
  9018                              <1> vga_wstr_0:
  9019                              <1> 	; set cursor position
  9020 00002445 668915[9E770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  9021                              <1> vga_wstr_1:
  9022 0000244C 66FF35[9E770100]    <1> 	push	word [CURSOR_POSN] ; *
  9023                              <1> 
  9024                              <1> 	; ebp = string offset in system buffer (user buffer was copied to)
  9025                              <1> 	
  9026                              <1> 	; while(count--!=0)
  9027                              <1> 	;  {
  9028                              <1> 	;   car=read_byte(seg,offset++);
  9029                              <1> 	;   if((flag&0x02)!=0)
  9030                              <1> 	;    attr=read_byte(seg,offset++);
  9031                              <1> 	;    biosfn_write_teletype(car,page,attr,WITH_ATTR);
  9032                              <1> 	;  }
  9033                              <1> 
  9034                              <1> 	;push	eax ; **
  9035                              <1> 	;test	al, 2
  9036 00002453 F605[10840100]02    <1> 	test	byte [w_str_cmd], 2
  9037 0000245A 751D                <1> 	jnz	short vga_wstr_3
  9038 0000245C 881D[AF770100]      <1> 	mov	[ccolor], bl
  9039                              <1> vga_wstr_2:
  9040 00002462 51                  <1> 	push	ecx
  9041 00002463 8A4500              <1> 	mov	al, [ebp]
  9042 00002466 E88F0A0000          <1> 	call	vga_write_teletype
  9043 0000246B 59                  <1> 	pop	ecx
  9044 0000246C 6649                <1> 	dec	cx
  9045 0000246E 741E                <1> 	jz	short vga_wstr_4
  9046 00002470 45                  <1> 	inc	ebp
  9047 00002471 8A1D[AF770100]      <1> 	mov	bl, [ccolor]
  9048 00002477 EBE9                <1> 	jmp	short vga_wstr_2
  9049                              <1> vga_wstr_3:
  9050 00002479 51                  <1> 	push	ecx
  9051 0000247A 8A4500              <1> 	mov	al, [ebp]
  9052 0000247D 45                  <1> 	inc	ebp
  9053 0000247E 8A5D00              <1> 	mov	bl, [ebp]
  9054 00002481 E8740A0000          <1> 	call	vga_write_teletype
  9055 00002486 59                  <1> 	pop	ecx
  9056 00002487 6649                <1> 	dec	cx
  9057 00002489 7403                <1> 	jz	short vga_wstr_4
  9058 0000248B 45                  <1> 	inc	ebp
  9059 0000248C EBEB                <1> 	jmp	short vga_wstr_3
  9060                              <1> vga_wstr_4:
  9061                              <1> 	; // Set back curs pos 
  9062                              <1> 	; if((flag&0x01)==0)
  9063                              <1> 	;  biosfn_set_cursor_pos(page,oldcurs);
  9064                              <1> 	; }
  9065                              <1> 	;pop	eax ; **
  9066 0000248E 665A                <1> 	pop	dx ; word [CURSOR_POSN] ; *
  9067                              <1> 	;test	al, 1
  9068 00002490 F605[10840100]01    <1> 	test	byte [w_str_cmd], 1
  9069                              <1> 	;jnz	VIDEO_RETURN
  9070                              <1> 	; 04/08/2022
  9071 00002497 7507                <1> 	jnz	short vga_wstr_5
  9072 00002499 668915[9E770100]    <1> 	mov 	[CURSOR_POSN], dx
  9073                              <1> vga_wstr_5:
  9074 000024A0 E916F6FFFF          <1> 	jmp	VIDEO_RETURN
  9075                              <1> 
  9076                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  9077                              <1> ; 07/07/2016
  9078                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  9079                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  9080                              <1> ;------------------------------------------------------
  9081                              <1> ;  SCROLL UP
  9082                              <1> ;   THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT
  9083                              <1> ; ENTRY ---
  9084                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  9085                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  9086                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  9087                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  9088                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  9089                              <1> ;  DS = DATA SEGMENT
  9090                              <1> ;  ES = REGEN SEGMENT
  9091                              <1> ; EXIT --
  9092                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  9093                              <1> ;--------------------------------------------------------
  9094                              <1> 
  9095                              <1> 	; cl = upper left column
  9096                              <1> 	; ch = upper left row
  9097                              <1> 	; dl = lower rigth column
  9098                              <1> 	; dh = lower right row
  9099                              <1> 	;
  9100                              <1> 	; al = line count (AL=0 means blank entire fields)
  9101                              <1> 	; bl = fill value for blanked lines	
  9102                              <1> 	; bh = unused
  9103                              <1> 
  9104                              <1> GRAPHICS_UP:
  9105                              <1> 	; 07/07/2016
  9106                              <1> 	; AH = Current video mode, [CRT_MODE]
  9107 000024A5 80FC07              <1> 	cmp	ah, 7
  9108 000024A8 7762                <1> 	ja	short vga_graphics_up
  9109                              <1> 	;je	n0
  9110                              <1> 
  9111 000024AA 88C7                <1> 	mov	bh, al			; save line count in BH
  9112                              <1> 	;mov	ax, cx			; GET UPPER LEFT POSITION INTO AX REG
  9113                              <1> 	; 03/08/2022
  9114 000024AC 89C8                <1> 	mov	eax, ecx
  9115                              <1> 
  9116                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  9117                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  9118                              <1> 
  9119 000024AE E8BA050000          <1> 	call	GRAPH_POSN
  9120                              <1> 	;movzx	edi, ax			; SAVE RESULT AS DESTINATION ADDRESS
  9121                              <1> 	; 03/08/2022
  9122 000024B3 89C7                <1> 	mov	edi, eax
  9123                              <1> 
  9124                              <1> ;-----	DETERMINE SIZE OF WINDOW
  9125                              <1> 
  9126 000024B5 6629CA              <1> 	sub	dx, cx
  9127 000024B8 6681C20101          <1>         add     dx, 101h                ; ADJUST VALUES
  9128 000024BD C0E602              <1> 	sal	dh, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  9129                              <1> 					; AND EVEN/ODD ROWS
  9130                              <1> ;-----	DETERMINE CRT MODE
  9131                              <1> 
  9132 000024C0 803D[9E660000]06    <1> 	cmp	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  9133 000024C7 7304                <1>         jnc	short _R7_              ; FIND_SOURCE
  9134                              <1> 
  9135                              <1> ;-----	MEDIUM RES UP
  9136 000024C9 D0E2                <1> 	sal	dl, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  9137                              <1> 	;sal	di, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  9138                              <1> 	; 03/08/2022
  9139 000024CB D1E7                <1> 	sal	edi, 1
  9140                              <1> 
  9141                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  9142                              <1> _R7_:                                   ; FIND_SOURCE
  9143 000024CD 81C700800B00        <1> 	add	edi, 0B8000h
  9144 000024D3 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  9145 000024D6 7430                <1>         jz	short _R11              ; IF ZERO, THEN BLANK ENTIRE FIELD
  9146 000024D8 B050                <1> 	mov	al, 80			; 80 BYTES/ROW
  9147 000024DA F6E7                <1> 	mul	bh			; determine offset to source
  9148                              <1> 	;movzx	esi, ax			; offset to source
  9149                              <1> 	; 03/08/2022
  9150 000024DC 89C6                <1> 	mov	esi, eax
  9151 000024DE 01FE                <1> 	add	esi, edi		; SET UP SOURCE
  9152 000024E0 88F4                <1> 	mov	ah, dh			; NUMBER OF ROWS IN FIELD
  9153 000024E2 28FC                <1> 	sub	ah, bh			; determine number to move
  9154                              <1> 
  9155                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  9156                              <1> _R8:                                    ; ROW_LOOP
  9157 000024E4 E8FD030000          <1>         call    _R17                    ; MOVE ONE ROW
  9158 000024E9 6681EEB01F          <1> 	sub	si, 2000h-80		; MOVE TO NEXT ROW
  9159 000024EE 6681EFB01F          <1> 	sub	di, 2000h-80
  9160 000024F3 FECC                <1> 	dec	ah			; NUMBER OF ROWS TO MOVE
  9161 000024F5 75ED                <1>         jnz     short _R8               ; CONTINUE TILL ALL MOVED
  9162                              <1> 
  9163                              <1> ;-----	FILL IN THE VACATED LINE(S)
  9164                              <1> _R9:                                    ; CLEAR ENTRY
  9165 000024F7 88D8                <1> 	mov	al, bl			; attribute to fill with
  9166                              <1> _R10_:
  9167 000024F9 E804040000          <1>         call    _R18                    ; CLEAR THAT ROW
  9168 000024FE 6681EFB01F          <1> 	sub	di, 2000h-80		; POINT TO NEXT LINE
  9169 00002503 FECF                <1> 	dec	bh			; number of lines to fill
  9170 00002505 75F2                <1> 	jnz	short _R10_             ; CLEAR LOOP
  9171 00002507 C3                  <1> 	retn				; EVERYYHING DONE
  9172                              <1> 
  9173                              <1> _R11:                                   ; BLANK_FIELD
  9174 00002508 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  9175 0000250A EBEB                <1>         jmp     short _R9               ; CLEAR THE FIELD
  9176                              <1> 
  9177                              <1> vga_graphics_up:
  9178                              <1> 	; 03/08/2022 - TRDOS 386 Kertnel v2.0.5
  9179                              <1> 	; 12/04/2021
  9180                              <1> 	; 08/08/2016
  9181                              <1> 	; 07/08/2016
  9182                              <1> 	; 04/08/2016
  9183                              <1> 	; 01/08/2016
  9184                              <1> 	; 31/07/2016
  9185                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9186                              <1> 	;
  9187                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9188                              <1> 	; vgabios-0.7a (2011)
  9189                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9190                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  9191                              <1> 	;
  9192                              <1> 
  9193                              <1> 	; cl = upper left column
  9194                              <1> 	; ch = upper left row
  9195                              <1> 	; dl = lower rigth column
  9196                              <1> 	; dh = lower right row
  9197                              <1> 	;
  9198                              <1> 	; al = line count (AL=0 means blank entire fields)
  9199                              <1> 	; bl = fill value for blanked lines	
  9200                              <1> 	; bh = unused
  9201                              <1> 	;
  9202                              <1> 	; ah = [CRT_MODE], current video mode	
  9203                              <1> 
  9204 0000250C 88C7                <1> 	mov	bh, al ; 31/07/2016
  9205 0000250E BE[C2660000]        <1> 	mov	esi, vga_g_modes
  9206 00002513 89F7                <1> 	mov	edi, esi
  9207 00002515 83C708              <1> 	add	edi, vga_g_mode_count
  9208                              <1> vga_g_up_0:
  9209 00002518 AC                  <1> 	lodsb
  9210 00002519 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  9211 0000251B 7405                <1> 	je	short vga_g_up_1
  9212 0000251D 39FE                <1> 	cmp	esi, edi
  9213 0000251F 72F7                <1> 	jb	short vga_g_up_0
  9214                              <1> 	;xor	bh, bh ; 31/07/2016)
  9215 00002521 C3                  <1> 	retn	; nothing to do
  9216                              <1> vga_g_up_1:
  9217 00002522 88F8                <1> 	mov	al, bh ; 31/07/2016
  9218 00002524 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  9219                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  9220                              <1> 	
  9221                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  9222                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  9223                              <1>  	; if(nblines>nbrows)nblines=0;
  9224                              <1>  	; cols=clr-cul+1;
  9225                              <1> 
  9226 00002527 3A35[A6660000]      <1> 	cmp	dh, [VGA_ROWS]
  9227 0000252D 7208                <1> 	jb	short vga_g_up_2
  9228 0000252F 8A35[A6660000]      <1> 	mov	dh, [VGA_ROWS]
  9229 00002535 FECE                <1> 	dec	dh
  9230                              <1> vga_g_up_2:
  9231 00002537 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  9232 0000253D 7208                <1> 	jb	short vga_g_up_3
  9233 0000253F 8A15[A0660000]      <1> 	mov	dl, [CRT_COLS]
  9234 00002545 FECA                <1> 	dec	dl
  9235                              <1> vga_g_up_3:	
  9236 00002547 3A05[A6660000]      <1> 	cmp	al, [VGA_ROWS]
  9237 0000254D 7602                <1> 	jna	short vga_g_up_4
  9238 0000254F 28C0                <1> 	sub	al, al ; 0
  9239                              <1> vga_g_up_4:
  9240 00002551 88D7                <1> 	mov	bh, dl ; clr
  9241 00002553 28CF                <1> 	sub	bh, cl ; cul
  9242 00002555 FEC7                <1> 	inc	bh ; cols = clr-cul+1
  9243                              <1> 
  9244 00002557 20C0                <1> 	and	al, al ; nblines = 0
  9245 00002559 7559                <1> 	jnz	short vga_g_up_6
  9246 0000255B 20ED                <1> 	and	ch, ch ; rul = 0
  9247 0000255D 7555                <1> 	jnz	short vga_g_up_6
  9248 0000255F 20C9                <1> 	and	cl, cl ; cul = 0
  9249 00002561 7551                <1> 	jnz	short vga_g_up_6
  9250                              <1> 
  9251                              <1> 	;push	ax
  9252                              <1> 	; 12/04/2021
  9253 00002563 50                  <1> 	push	eax
  9254 00002564 A0[A6660000]        <1> 	mov	al, [VGA_ROWS]
  9255 00002569 FEC8                <1> 	dec	al  
  9256 0000256B 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  9257 0000256D 7545                <1> 	jne	short vga_g_up_5
  9258 0000256F A0[A0660000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  9259 00002574 FEC8                <1> 	dec	al 
  9260 00002576 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  9261                              <1> 	;jne	short vga_g_up_5
  9262                              <1> 	;;pop	ax
  9263                              <1> 	; 12/04/2021
  9264 00002578 58                  <1> 	pop	eax
  9265 00002579 7539                <1> 	jne	short vga_g_up_5
  9266                              <1> 
  9267 0000257B 66B80502            <1> 	mov	ax, 0205h
  9268 0000257F 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9269 00002583 66EF                <1> 	out	dx, ax
  9270 00002585 A0[A6660000]        <1> 	mov	al, [VGA_ROWS]
  9271 0000258A 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  9272 00002590 F6E4                <1> 	mul	ah
  9273 00002592 0FB7D0              <1> 	movzx	edx, ax
  9274                              <1> 	; 08/08/2016
  9275 00002595 0FB605[A2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  9276 0000259C F7E2                <1> 	mul	edx
  9277                              <1> 	; eax = byte count	
  9278 0000259E 89C1                <1> 	mov	ecx, eax
  9279                              <1> 	;; 07/08/2016
  9280                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  9281                              <1> 	;mov	ecx, edx
  9282 000025A0 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  9283 000025A2 BF00000A00          <1> 	mov	edi, 0A0000h
  9284 000025A7 F3AA                <1> 	rep	stosb		
  9285                              <1> 	
  9286                              <1> 	;mov	ax, 5
  9287                              <1> 	; 03/08/2022
  9288 000025A9 30E4                <1> 	xor	ah, ah
  9289 000025AB B005                <1> 	mov	al, 5
  9290                              <1> 
  9291 000025AD 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9292 000025B1 66EF                <1> 	out	dx, ax ; 0005h	
  9293                              <1> 
  9294 000025B3 C3                  <1> 	retn
  9295                              <1> 
  9296                              <1> vga_g_up_5:
  9297                              <1> 	;;pop	ax
  9298                              <1> 	; 12/04/2021
  9299                              <1> 	;pop	eax
  9300                              <1> 
  9301                              <1> vga_g_up_6:
  9302                              <1> 	; [ESI] = VGA memory model number for current video mode
  9303                              <1>         ;
  9304                              <1>         ; LINEAR8 equ 5
  9305                              <1>         ; PLANAR4 equ 4
  9306                              <1>         ; PLANAR1 equ 3
  9307                              <1> 
  9308 000025B4 803E04              <1> 	cmp	byte [esi], PLANAR4
  9309 000025B7 7424                <1> 	je	short vga_g_up_planar
  9310 000025B9 803E03              <1> 	cmp	byte [esi], PLANAR1
  9311 000025BC 741F                <1> 	je	short vga_g_up_planar
  9312                              <1> vga_g_up_linear8:
  9313                              <1> 	; 07/07/2016 (TEMPORARY)
  9314                              <1> 	;
  9315                              <1> 	; cl = upper left column ; cul
  9316                              <1> 	; ch = upper left row ; rul
  9317                              <1> 	; dl = lower rigth column ; clr
  9318                              <1> 	; dh = lower right row ; rlr
  9319                              <1> 
  9320                              <1> vga_g_up_l0:
  9321                              <1>  	;{for(i=rul;i<=rlr;i++)
  9322                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  9323 000025BE 08C0                <1> 	or	al, al
  9324 000025C0 7414                <1> 	jz	short vga_g_up_l2
  9325 000025C2 88C4                <1> 	mov	ah, al
  9326 000025C4 00EC                <1> 	add	ah, ch ; i+nblines
  9327                              <1> 	;jc	short vga_g_up_l2	
  9328 000025C6 38F4                <1> 	cmp	ah, dh
  9329 000025C8 770C                <1> 	ja	short vga_g_up_l2
  9330                              <1> 	; else
  9331                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  9332 000025CA E8F2000000          <1> 	call	vgamem_copy_l8
  9333                              <1> vga_g_up_l1:
  9334 000025CF FEC5                <1> 	inc	ch
  9335 000025D1 38F5                <1> 	cmp	ch, dh
  9336 000025D3 76E9                <1> 	jna	short vga_g_up_l0
  9337 000025D5 C3                  <1> 	retn
  9338                              <1> vga_g_up_l2:
  9339                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  9340 000025D6 E84C010000          <1> 	call	vgamem_fill_l8
  9341 000025DB EBF2                <1> 	jmp	short vga_g_up_l1
  9342                              <1> 
  9343                              <1> vga_g_up_planar:
  9344                              <1> 	; cl = upper left column ; cul
  9345                              <1> 	; ch = upper left row ; rul
  9346                              <1> 	; dl = lower rigth column ; clr
  9347                              <1> 	; dh = lower right row ; rlr
  9348                              <1> vga_g_up_pl0:
  9349                              <1>  	;{for(i=rul;i<=rlr;i++)
  9350                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  9351 000025DD 20C0                <1> 	and	al, al
  9352 000025DF 7414                <1> 	jz	short vga_g_up_pl2	
  9353 000025E1 88C4                <1> 	mov	ah, al
  9354 000025E3 00EC                <1> 	add	ah, ch ; i+nblines
  9355                              <1> 	;jc	short vga_g_up_pl2
  9356 000025E5 38F4                <1> 	cmp	ah, dh
  9357 000025E7 770C                <1> 	ja	short vga_g_up_pl2
  9358                              <1> 	; else
  9359                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  9360 000025E9 E80E000000          <1> 	call	vgamem_copy_pl4
  9361                              <1> vga_g_up_pl1:
  9362 000025EE FEC5                <1> 	inc	ch 
  9363 000025F0 38F5                <1> 	cmp	ch, dh
  9364 000025F2 76E9                <1> 	jna	short vga_g_up_pl0
  9365 000025F4 C3                  <1> 	retn
  9366                              <1> vga_g_up_pl2:
  9367                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  9368 000025F5 E870000000          <1> 	call	vgamem_fill_pl4
  9369 000025FA EBF2                <1> 	jmp	short vga_g_up_pl1
  9370                              <1> 
  9371                              <1> vgamem_copy_pl4:
  9372                              <1> 	; 08/08/2016
  9373                              <1> 	; 07/08/2016
  9374                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9375                              <1> 	;
  9376                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9377                              <1> 	; vgabios-0.7a (2011)
  9378                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9379                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  9380                              <1> 	;
  9381                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  9382                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  9383                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  9384                              <1> 
  9385                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  9386                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  9387                              <1> 
  9388 000025FC 52                  <1> 	push	edx
  9389 000025FD 50                  <1> 	push	eax
  9390                              <1> 
  9391                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  9392 000025FE 66B80501            <1> 	mov	ax, 0105h
  9393 00002602 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9394 00002606 66EF                <1> 	out	dx, ax
  9395                              <1> 
  9396                              <1> 	; 07/08/2016
  9397                              <1>  	;mov     ah, [esp+1]
  9398                              <1> 	;movzx	edx, ah ; ysrc
  9399 00002608 0FB6542401          <1> 	movzx	edx, byte [esp+1]
  9400                              <1> 	; 08/08/2016
  9401 0000260D 0FB605[A2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  9402 00002614 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  9403 0000261A F6E4                <1> 	mul	ah 
  9404                              <1> 	;; 07/08/2016
  9405                              <1> 	;movzx	eax, byte [CRT_COLS]
  9406                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  9407 0000261C 50                  <1> 	push	eax ; cheight * nbcols
  9408 0000261D F7E2                <1> 	mul	edx ; * ysrc
  9409                              <1> 	; eax = ysrc * cheight * nbcols
  9410                              <1> 	; edx = 0
  9411 0000261F 88CA                <1> 	mov	dl, cl ; edx = xstart	
  9412 00002621 01D0                <1>  	add	eax, edx
  9413 00002623 89C6                <1> 	mov	esi, eax ; src
  9414 00002625 88EA                <1> 	mov	dl, ch ; ydest
  9415 00002627 58                  <1> 	pop	eax ; cheight * nbcols
  9416 00002628 F7E2                <1> 	mul	edx
  9417                              <1> 	; eax = ydest * cheight * nbcols
  9418 0000262A 88CA                <1> 	mov	dl, cl ; edx = xstart	
  9419 0000262C 01D0                <1>  	add	eax, edx
  9420 0000262E 89C7                <1> 	mov	edi, eax ; dest
  9421                              <1> 	; esi = src
  9422                              <1> 	; edi = dest
  9423                              <1> 	; for(i=0;i<cheight;i++)
  9424                              <1>   	; {
  9425                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  9426                              <1>   	; }
  9427 00002630 51                  <1> 	push	ecx
  9428 00002631 B900000A00          <1> 	mov	ecx, 0A0000h
  9429 00002636 01CE                <1> 	add	esi, ecx
  9430 00002638 01CF                <1> 	add	edi, ecx
  9431                              <1> 	; 08/08/2016
  9432 0000263A 8A35[A2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  9433                              <1> 	;; 07/08/2016
  9434                              <1> 	;mov	dh, 8 ; 07/08/2016
  9435 00002640 28D2                <1> 	sub	dl, dl ; i
  9436                              <1> vgamem_copy_pl4_0:
  9437 00002642 56                  <1> 	push	esi
  9438 00002643 57                  <1> 	push	edi
  9439 00002644 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  9440 0000264B F6E2                <1> 	mul	dl
  9441                              <1> 	; eax = i * nbcols
  9442 0000264D 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  9443 0000264F 01C6                <1> 	add	esi, eax
  9444 00002651 0FB6CF              <1> 	movzx	ecx, bh ; cols
  9445 00002654 F3A4                <1> 	rep	movsb
  9446 00002656 5F                  <1> 	pop	edi
  9447 00002657 5E                  <1> 	pop	esi
  9448 00002658 FECE                <1> 	dec	dh
  9449 0000265A 75E6                <1> 	jnz	short vgamem_copy_pl4_0
  9450                              <1> vgamem_copy_pl4_1:
  9451 0000265C 59                  <1> 	pop	ecx
  9452                              <1> 
  9453                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  9454 0000265D 66B80500            <1> 	mov	ax, 0005h
  9455 00002661 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9456 00002665 66EF                <1> 	out	dx, ax
  9457                              <1> 
  9458 00002667 58                  <1> 	pop	eax
  9459 00002668 5A                  <1> 	pop	edx
  9460                              <1> 
  9461 00002669 C3                  <1> 	retn	
  9462                              <1> 
  9463                              <1> vgamem_fill_pl4:
  9464                              <1> 	; 08/08/2016
  9465                              <1> 	; 07/08/2016
  9466                              <1> 	; 04/08/2016
  9467                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9468                              <1> 	;
  9469                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9470                              <1> 	; vgabios-0.7a (2011)
  9471                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9472                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  9473                              <1> 	;
  9474                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  9475                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  9476                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  9477                              <1> 
  9478                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  9479 0000266A 52                  <1> 	push	edx
  9480 0000266B 50                  <1> 	push	eax
  9481                              <1> 
  9482                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  9483 0000266C 66B80502            <1> 	mov	ax, 0205h
  9484 00002670 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9485 00002674 66EF                <1> 	out	dx, ax
  9486                              <1> 
  9487                              <1>       	; 08/08/2016
  9488 00002676 0FB605[A2660000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  9489 0000267D F6E5                <1> 	mul	ch
  9490                              <1> 	;; 07/08/2016
  9491                              <1> 	;movzx	eax, ch
  9492                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  9493 0000267F 0FB615[A0660000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  9494 00002686 F7E2                <1> 	mul	edx
  9495                              <1> 	; edx  = 0
  9496 00002688 88CA                <1> 	mov	dl, cl 
  9497 0000268A 01D0                <1> 	add	eax, edx
  9498 0000268C 89C7                <1> 	mov	edi, eax
  9499                              <1> 	; edi = dest
  9500                              <1> 	; for(i=0;i<cheight;i++)
  9501                              <1>   	; {
  9502                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  9503                              <1>   	; }
  9504 0000268E 81C700000A00        <1> 	add	edi, 0A0000h
  9505 00002694 51                  <1> 	push	ecx
  9506                              <1> 	; 08/08/2016
  9507 00002695 8A35[A2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  9508                              <1> 	;; 07/08/2016
  9509                              <1> 	;mov	dh, 8 ; 07/08/2016
  9510 0000269B 28D2                <1> 	sub	dl, dl ; i
  9511                              <1> vgamem_fill_pl4_0:
  9512 0000269D 57                  <1> 	push	edi
  9513 0000269E 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  9514 000026A5 F6E2                <1> 	mul	dl
  9515                              <1> 	; eax = i * nbcols
  9516 000026A7 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  9517 000026A9 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  9518 000026AB 0FB6CF              <1> 	movzx	ecx, bh ; cols
  9519 000026AE F3AA                <1>  	rep	stosb
  9520 000026B0 5F                  <1> 	pop	edi
  9521 000026B1 75EA                <1> 	jnz	short vgamem_fill_pl4_0
  9522                              <1> vgamem_fill_pl4_1:
  9523 000026B3 59                  <1> 	pop	ecx
  9524                              <1> 
  9525                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  9526 000026B4 66B80500            <1> 	mov	ax, 0005h
  9527 000026B8 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9528 000026BC 66EF                <1> 	out	dx, ax
  9529                              <1> 
  9530 000026BE 58                  <1> 	pop	eax
  9531 000026BF 5A                  <1> 	pop	edx 
  9532                              <1> 	
  9533 000026C0 C3                  <1> 	retn
  9534                              <1> 
  9535                              <1> vgamem_copy_l8:
  9536                              <1> 	; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  9537                              <1> 	; 08/08/2016
  9538                              <1> 	; 07/08/2016
  9539                              <1> 	; 06/08/2016
  9540                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9541                              <1> 	;
  9542                              <1> 	; TEMPORARY
  9543                              <1> 	;
  9544                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9545                              <1> 	; vgabios-0.7a (2011)
  9546                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9547                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  9548                              <1> 	;
  9549                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  9550                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  9551                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  9552                              <1> 
  9553                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  9554                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  9555                              <1> 
  9556 000026C1 52                  <1> 	push	edx
  9557 000026C2 50                  <1> 	push	eax
  9558                              <1> 
  9559                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  9560                              <1> 	;mov	ax, 0105h
  9561                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9562                              <1> 	;out	dx, ax
  9563                              <1> 
  9564                              <1> 	;mov	ah, [esp+1]
  9565                              <1> 
  9566 000026C3 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  9567                              <1> 	; 08/08/2016
  9568 000026C6 0FB605[A2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  9569 000026CD 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  9570 000026D3 F6E4                <1> 	mul	ah 
  9571                              <1> 	;; 07/08/2016
  9572                              <1> 	;movzx	eax, byte [CRT_COLS]
  9573                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  9574 000026D5 50                  <1> 	push	eax ; cheight * nbcols
  9575 000026D6 F7E2                <1> 	mul	edx ; * ysrc
  9576                              <1> 	; eax = ysrc * cheight * nbcols
  9577                              <1> 	; edx = 0
  9578 000026D8 88CA                <1> 	mov	dl, cl ; edx = xstart
  9579 000026DA 01D0                <1>  	add	eax, edx
  9580 000026DC 89C6                <1> 	mov	esi, eax ; src
  9581                              <1> 	;shl	si, 3 ; * 8 ; 06/08/2016
  9582                              <1> 	; 02/08/2022
  9583 000026DE C1E603              <1> 	shl	esi, 3
  9584 000026E1 88EA                <1> 	mov	dl, ch ; ydest
  9585 000026E3 58                  <1> 	pop	eax ; cheight * nbcols
  9586 000026E4 F7E2                <1> 	mul	edx
  9587                              <1> 	; eax = ydest * cheight * nbcols
  9588 000026E6 88CA                <1> 	mov	dl, cl ; edx = xstart	
  9589 000026E8 01D0                <1>  	add	eax, edx
  9590 000026EA 89C7                <1> 	mov	edi, eax ; dest
  9591                              <1> 	;shl	di, 3 ; * 8 ; 06/08/2016
  9592                              <1> 	; 02/08/2022
  9593 000026EC C1E703              <1> 	shl	edi, 3
  9594                              <1> 	; esi = src
  9595                              <1> 	; edi = dest
  9596                              <1> 	; for(i=0;i<cheight;i++)
  9597                              <1>   	; {
  9598                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  9599                              <1>   	; }
  9600 000026EF 51                  <1> 	push	ecx
  9601 000026F0 B900000A00          <1> 	mov	ecx, 0A0000h
  9602 000026F5 01CE                <1> 	add	esi, ecx
  9603 000026F7 01CF                <1> 	add	edi, ecx
  9604                              <1> 	; 08/08/2016
  9605 000026F9 8A35[A2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  9606                              <1> 	;; 07/08/2016
  9607                              <1> 	;mov	dh, 8 ; 07/08/2016
  9608 000026FF 28D2                <1> 	sub	dl, dl ; i
  9609                              <1> vgamem_copy_l8_0:
  9610 00002701 56                  <1> 	push	esi
  9611 00002702 57                  <1> 	push	edi
  9612 00002703 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  9613 0000270A F6E2                <1> 	mul	dl
  9614                              <1> 	; eax = i * nbcols
  9615                              <1> 	;shl	ax, 3 ; * 8 ; 06/08/2016
  9616                              <1> 	; 02/08/2022
  9617 0000270C C1E003              <1> 	shl	eax, 3
  9618 0000270F 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  9619 00002711 01C6                <1> 	add	esi, eax
  9620 00002713 0FB6CF              <1> 	movzx	ecx, bh ; cols
  9621                              <1> 	;shl	cx, 3 ; * 8 ; 06/08/2016
  9622                              <1> 	; 02/08/2022
  9623 00002716 C1E103              <1> 	shl	ecx, 3
  9624 00002719 F3A4                <1> 	rep	movsb
  9625 0000271B 5F                  <1> 	pop	edi
  9626 0000271C 5E                  <1> 	pop	esi
  9627 0000271D FEC2                <1> 	inc	dl ; 06/08/2016
  9628 0000271F FECE                <1> 	dec	dh
  9629 00002721 75DE                <1> 	jnz	short vgamem_copy_l8_0
  9630                              <1> vgamem_copy_l8_1:
  9631 00002723 59                  <1> 	pop	ecx
  9632                              <1> 
  9633                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  9634                              <1> 	;mov	ax, 0005h
  9635                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9636                              <1> 	;out	dx, ax
  9637                              <1> 
  9638 00002724 58                  <1> 	pop	eax
  9639 00002725 5A                  <1> 	pop	edx
  9640                              <1> 
  9641 00002726 C3                  <1> 	retn
  9642                              <1> 
  9643                              <1> vgamem_fill_l8:
  9644                              <1> 	; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  9645                              <1> 	; 08/08/2016
  9646                              <1> 	; 07/08/2016
  9647                              <1> 	; 06/08/2016
  9648                              <1> 	; 04/08/2016
  9649                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9650                              <1> 	;
  9651                              <1> 	; TEMPORARY
  9652                              <1> 	;
  9653                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9654                              <1> 	; vgabios-0.7a (2011)
  9655                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9656                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  9657                              <1> 	;
  9658                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  9659                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  9660                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  9661                              <1> 
  9662                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  9663 00002727 52                  <1> 	push	edx
  9664 00002728 50                  <1> 	push	eax
  9665                              <1> 
  9666                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  9667                              <1> 	;mov	ax, 0205h
  9668                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9669                              <1> 	;out	dx, ax
  9670                              <1> 
  9671                              <1>         ; 08/08/2016
  9672 00002729 0FB605[A2660000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  9673 00002730 F6E5                <1> 	mul	ch
  9674                              <1> 	;; 07/08/2016
  9675                              <1> 	;movzx	eax, ch
  9676                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  9677 00002732 0FB615[A0660000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  9678 00002739 F7E2                <1> 	mul	edx
  9679                              <1> 	; edx  = 0
  9680 0000273B 88CA                <1> 	mov	dl, cl 
  9681 0000273D 01D0                <1> 	add	eax, edx
  9682 0000273F 89C7                <1> 	mov	edi, eax
  9683                              <1> 	;shl	di, 3 ; * 8 ; 06/08/2016
  9684                              <1> 	; 02/08/2022
  9685 00002741 C1E703              <1> 	shl	edi, 3
  9686                              <1> 	; edi = dest
  9687                              <1> 	; for(i=0;i<cheight;i++)
  9688                              <1>   	; {
  9689                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  9690                              <1>   	; }
  9691 00002744 81C700000A00        <1> 	add	edi, 0A0000h
  9692 0000274A 51                  <1> 	push	ecx
  9693                              <1> 	; 08/08/2016
  9694 0000274B 8A35[A2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  9695                              <1> 	;; 07/08/2016
  9696                              <1> 	;mov	dh, 8 ; 07/08/2016
  9697 00002751 28D2                <1> 	sub	dl, dl ; i
  9698                              <1> vgamem_fill_l8_0:
  9699 00002753 57                  <1> 	push	edi
  9700 00002754 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  9701 0000275B F6E2                <1> 	mul	dl
  9702                              <1> 	; eax = i * nbcols
  9703                              <1> 	;shl	ax, 3 ; * 8 ; 06/08/2016
  9704                              <1> 	; 02/08/2022
  9705 0000275D C1E003              <1> 	shl	eax, 3
  9706 00002760 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  9707 00002762 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  9708 00002764 0FB6CF              <1> 	movzx	ecx, bh ; cols
  9709                              <1> 	;shl	cx, 3 ; * 8 ; 06/08/2016
  9710                              <1>  	; 02/08/2022
  9711 00002767 C1E103              <1> 	shl	ecx, 3
  9712 0000276A F3AA                <1> 	rep	stosb
  9713 0000276C 5F                  <1> 	pop	edi
  9714 0000276D FEC2                <1> 	inc	dl ; 06/08/2016
  9715 0000276F FECE                <1> 	dec	dh
  9716 00002771 75E0                <1> 	jnz	short vgamem_fill_l8_0
  9717                              <1> vgamem_fill_l8_1:
  9718 00002773 59                  <1> 	pop	ecx
  9719                              <1> 
  9720                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  9721                              <1> 	;mov	ax, 0005h
  9722                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9723                              <1> 	;out	dx, ax
  9724                              <1> 
  9725 00002774 58                  <1> 	pop	eax
  9726 00002775 5A                  <1> 	pop	edx 
  9727                              <1> 
  9728 00002776 C3                  <1> 	retn
  9729                              <1> 
  9730                              <1> ; 03/08/2022 - TRDOS 386 Kernel V2.0.5
  9731                              <1> ; 07/07/2016
  9732                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  9733                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  9734                              <1> ;------------------------------------------------------
  9735                              <1> ; SCROLL DOWN
  9736                              <1> ;  THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT
  9737                              <1> ; ENTRY --
  9738                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  9739                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  9740                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  9741                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  9742                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  9743                              <1> ;  DS = DATA SEGMENT
  9744                              <1> ;  ES = REGEN SEGMENT
  9745                              <1> ; EXIT --
  9746                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  9747                              <1> ;--------------------------------------------------------
  9748                              <1> 
  9749                              <1> 	; cl = upper left column
  9750                              <1> 	; ch = upper left row
  9751                              <1> 	; dl = lower rigth column
  9752                              <1> 	; dh = lower right row
  9753                              <1> 	;
  9754                              <1> 	; al = line count (AL=0 means blank entire fields)
  9755                              <1> 	; bl = fill value for blanked lines	
  9756                              <1> 	; bh = unused
  9757                              <1> 
  9758                              <1> GRAPHICS_DOWN:
  9759                              <1> 	; 07/07/2016
  9760                              <1> 	; ah = Current video mode, [CRT_MODE]
  9761                              <1> 	; std				; SET DIRECTION
  9762 00002777 80FC07              <1> 	cmp	ah, 7
  9763 0000277A 7769                <1>         ja	short vga_graphics_down ; 03/08/2022
  9764                              <1> 	;je	_n0
  9765                              <1> 
  9766 0000277C 88C7                <1> 	mov	bh, al			; save line count in BH
  9767                              <1> 	;mov	ax, dx			; GET LOWER RIGHT POSITION INTO AX REG
  9768                              <1> 	; 03/08/2022
  9769 0000277E 89D0                <1> 	mov	eax, edx
  9770                              <1> 
  9771                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  9772                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  9773                              <1> 
  9774 00002780 E8E8020000          <1> 	call	GRAPH_POSN
  9775                              <1> 	;movzx	edi, ax			; SAVE RESULT AS DESTINATION ADDRESS
  9776                              <1> 	; 03/08/2022
  9777 00002785 89C7                <1> 	mov	edi, eax
  9778                              <1> 
  9779                              <1> ;-----	DETERMINE SIZE OF WINDOW
  9780                              <1> 
  9781 00002787 6629CA              <1> 	sub	dx, cx
  9782 0000278A 6681C20101          <1>         add     dx, 101h                ; ADJUST VALUES
  9783 0000278F C0E602              <1> 	sal	dh, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  9784                              <1> 					; AND EVEN/ODD ROWS
  9785                              <1> ;-----	DETERMINE CRT MODE
  9786                              <1> 
  9787 00002792 803D[9E660000]06    <1> 	cmp	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  9788 00002799 7305                <1> 	jnc	short _R12              ; FIND_SOURCE_DOWN
  9789                              <1> 
  9790                              <1> ;-----	MEDIUM RES DOWN
  9791 0000279B D0E2                <1> 	sal	dl, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  9792                              <1> 	;sal	di, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  9793                              <1> 	; 03/08/2022
  9794 0000279D D1E7                <1> 	sal	edi, 1
  9795                              <1> 	;inc	di			; POINT TO LAST BYTE
  9796                              <1> 	; 03/08/2022
  9797 0000279F 47                  <1> 	inc	edi
  9798                              <1> 
  9799                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  9800                              <1> 
  9801                              <1> _R12:                                   ; FIND_SOURCE_DOWN
  9802 000027A0 81C700800B00        <1> 	add	edi, 0B8000h		
  9803 000027A6 6681C7F000          <1> 	add	di, 240			; POINT TO LAST ROW OF PIXELS
  9804 000027AB C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  9805 000027AE 74(06)              <1> 	jz	short 6			; IF ZERO, THEN BLANK ENTIRE FIELD
  9806 000027B0 B050                <1> 	mov	al, 80			; 80 BYTES/ROW
  9807 000027B2 F6E7                <1> 	mul	bh			; determine offset to source
  9808 000027B4 89FE                <1> 	mov	esi, edi		; SET UP SOURCE
  9809                              <1> 	;sub	si, ax			; SUBTRACT THE OFFSET
  9810                              <1> 	; 03/08/2022
  9811 000027B6 29C6                <1> 	sub	esi, eax
  9812 000027B8 88F4                <1> 	mov	ah, dh			; NUMBER OF ROWS IN FIELD
  9813 000027BA 28FC                <1> 	sub	ah, bh			; determine number to move
  9814                              <1> 
  9815                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  9816                              <1> 
  9817                              <1> _R13:                                   ; ROW_LOOP_DOWN
  9818 000027BC E825010000          <1>         call    _R17                    ; MOVE ONE ROW
  9819 000027C1 6681EE5020          <1> 	sub	si, 2000h+80		; MOVE TO NEXT ROW
  9820 000027C6 6681EF5020          <1> 	sub	di, 2000h+80
  9821 000027CB FECC                <1> 	dec	ah			; NUMBER OF ROWS TO MOVE
  9822 000027CD 75ED                <1> 	jnz	short _R13              ; CONTINUE TILL ALL MOVED
  9823                              <1> 
  9824                              <1> ;-----	FILL IN THE VACATED LINE(S)
  9825                              <1> _R14:                                   ; CLEAR_ENTRY_DOWN
  9826 000027CF 88D8                <1> 	mov	al, bl			; attribute to fill with
  9827                              <1> _R15_:                                  ; CLEAR_LOOP_DOWN
  9828 000027D1 E82C010000          <1> 	call	_R18			; CLEAR A ROW
  9829 000027D6 6681EF5020          <1> 	sub	di, 2000h+80		; POINT TO NEXT LINE
  9830 000027DB FECF                <1> 	dec	bh			; number of lines to fill
  9831 000027DD 75F2                <1>         jnz	short _R15_             ; CLEAR_LOOP_DOWN
  9832                              <1> 	; 18/11/2020
  9833 000027DF FC                  <1> 	cld				; RESET THE DIRECTION FLAG
  9834                              <1> 	
  9835 000027E0 C3                  <1> 	retn				; EVERYTHING DONE
  9836                              <1> 
  9837                              <1> _R16:                                   ; BLANK_FIELD_DOWN
  9838 000027E1 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  9839 000027E3 EBEA                <1>         jmp     short _R14              ; CLEAR THE FIELD
  9840                              <1> 
  9841                              <1> vga_graphics_down:
  9842                              <1> 	; 03/08/2022 - TRDOS 386 Kertnel v2.0.5
  9843                              <1> 	; 12/04/2021
  9844                              <1> 	; 08/08/2016
  9845                              <1> 	; 07/08/2016
  9846                              <1> 	; 31/07/2016
  9847                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  9848                              <1> 	;
  9849                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  9850                              <1> 	; vgabios-0.7a (2011)
  9851                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  9852                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  9853                              <1> 	;
  9854                              <1> 
  9855                              <1> 	; cl = upper left column
  9856                              <1> 	; ch = upper left row
  9857                              <1> 	; dl = lower rigth column
  9858                              <1> 	; dh = lower right row
  9859                              <1> 	;
  9860                              <1> 	; al = line count (AL=0 means blank entire fields)
  9861                              <1> 	; bl = fill value for blanked lines	
  9862                              <1> 	; bh = unused
  9863                              <1> 	;
  9864                              <1> 	; ah = [CRT_MODE], current video mode	
  9865                              <1> 
  9866 000027E5 FC                  <1>         cld     ; !!! Clear direction flag !!! 
  9867                              <1> 
  9868 000027E6 88C7                <1> 	mov	bh, al ; 31/07/2016
  9869                              <1> 
  9870 000027E8 BE[BA660000]        <1> 	mov	esi, vga_modes
  9871 000027ED 89F7                <1> 	mov	edi, esi
  9872 000027EF 83C710              <1> 	add	edi, vga_mode_count
  9873                              <1> vga_g_down_0:
  9874 000027F2 AC                  <1> 	lodsb
  9875 000027F3 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  9876 000027F5 7405                <1> 	je	short vga_g_down_1
  9877 000027F7 39FE                <1> 	cmp	esi, edi
  9878 000027F9 72F7                <1> 	jb	short vga_g_down_0
  9879                              <1> 	; xor 	bh, bh	; 31/07/2016
  9880 000027FB C3                  <1> 	retn	; nothing to do
  9881                              <1> vga_g_down_1:
  9882 000027FC 88F8                <1> 	mov	al, bh ; 31/07/2016
  9883 000027FE 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  9884                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  9885                              <1> 	
  9886                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  9887                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  9888                              <1>  	; if(nblines>nbrows)nblines=0;
  9889                              <1>  	; cols=clr-cul+1;
  9890                              <1> 
  9891 00002801 3A35[A6660000]      <1> 	cmp	dh, [VGA_ROWS]
  9892 00002807 7208                <1> 	jb	short vga_g_down_2
  9893 00002809 8A35[A6660000]      <1> 	mov	dh, [VGA_ROWS]
  9894 0000280F FECE                <1> 	dec	dh
  9895                              <1> vga_g_down_2:
  9896 00002811 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  9897 00002817 7208                <1> 	jb	short vga_g_down_3
  9898 00002819 8A15[A0660000]      <1> 	mov	dl, [CRT_COLS]
  9899 0000281F FECA                <1> 	dec	dl
  9900                              <1> vga_g_down_3:	
  9901 00002821 3A05[A6660000]      <1> 	cmp	al, [VGA_ROWS]
  9902 00002827 7602                <1> 	jna	short vga_g_down_4
  9903 00002829 28C0                <1> 	sub	al, al ; 0
  9904                              <1> vga_g_down_4:
  9905 0000282B 88F7                <1> 	mov	bh, dh ; clr
  9906 0000282D 28CF                <1> 	sub	bh, cl ; cul
  9907 0000282F FEC7                <1> 	inc	bh ; cols = clr-cul+1
  9908                              <1> 
  9909 00002831 20C0                <1> 	and	al, al ; nblines = 0
  9910 00002833 7559                <1> 	jnz	short vga_g_down_6
  9911 00002835 20ED                <1> 	and	ch, ch ; rul = 0
  9912 00002837 7555                <1> 	jnz	short vga_g_down_6
  9913 00002839 20C9                <1> 	and	cl, cl ; cul = 0
  9914 0000283B 7551                <1> 	jnz	short vga_g_down_6
  9915                              <1> 
  9916 0000283D 50                  <1> 	push	eax ; push ax ; 12/04/2021
  9917 0000283E A0[A6660000]        <1> 	mov	al, [VGA_ROWS]
  9918 00002843 FEC8                <1> 	dec	al  
  9919 00002845 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  9920 00002847 7545                <1> 	jne	short vga_g_down_5
  9921 00002849 A0[A0660000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  9922 0000284E FEC8                <1> 	dec	al 
  9923 00002850 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  9924                              <1> 	;jne	short vga_g_down_5
  9925                              <1>  	; 12/04/2021
  9926 00002852 58                  <1> 	pop	eax ; pop ax
  9927 00002853 7539                <1> 	jne	short vga_g_down_5
  9928                              <1> 
  9929 00002855 66B80502            <1> 	mov	ax, 0205h
  9930 00002859 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9931 0000285D 66EF                <1> 	out	dx, ax
  9932 0000285F A0[A6660000]        <1> 	mov	al, [VGA_ROWS]
  9933 00002864 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  9934 0000286A F6E4                <1> 	mul	ah
  9935 0000286C 0FB7D0              <1> 	movzx	edx, ax
  9936                              <1> 	; 08/08/2016
  9937 0000286F 0FB605[A2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  9938 00002876 F7E2                <1> 	mul	edx
  9939                              <1> 	; eax = byte count	
  9940 00002878 89C1                <1> 	mov	ecx, eax
  9941                              <1> 	;; 07/08/2016
  9942                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  9943                              <1> 	;mov	ecx, edx
  9944 0000287A 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  9945 0000287C BF00000A00          <1> 	mov	edi, 0A0000h
  9946 00002881 F3AA                <1> 	rep	stosb			
  9947                              <1> 	
  9948                              <1> 	; 03/08/2022
  9949 00002883 30E4                <1> 	xor	ah, ah ; 0 
  9950                              <1> 	
  9951 00002885 B005                <1> 	mov	al, 5
  9952 00002887 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  9953 0000288B 66EF                <1> 	out	dx, ax ; 0005h	
  9954                              <1> 
  9955 0000288D C3                  <1> 	retn
  9956                              <1> 
  9957                              <1> vga_g_down_5:
  9958                              <1> 	; 12/04/2021
  9959                              <1> 	;pop	eax  ; pop ax
  9960                              <1> 
  9961                              <1> vga_g_down_6:
  9962                              <1> 	; [ESI] = VGA memory model number for current video mode
  9963                              <1>         ;
  9964                              <1>         ; LINEAR8 equ 5
  9965                              <1>         ; PLANAR4 equ 4
  9966                              <1>         ; PLANAR1 equ 3
  9967                              <1> 
  9968 0000288E 803E04              <1> 	cmp	byte [esi], PLANAR4
  9969 00002891 742C                <1> 	je	short vga_g_down_planar
  9970 00002893 803E03              <1> 	cmp	byte [esi], PLANAR1
  9971 00002896 7427                <1> 	je	short vga_g_down_planar
  9972                              <1> vga_g_down_linear8:
  9973                              <1> 	; 07/07/2016 (TEMPORARY)
  9974                              <1> 	;
  9975                              <1> 	; cl = upper left column ; cul
  9976                              <1> 	; ch = upper left row ; rul
  9977                              <1> 	; dl = lower rigth column ; clr
  9978                              <1> 	; dh = lower right row ; rlr
  9979                              <1> 
  9980                              <1> vga_g_down_l0:
  9981                              <1> 	;{for(i=rlr;i>=rul;i--)
  9982                              <1>         ; if((i<rul+nblines)||(nblines==0))
  9983 00002898 08C0                <1> 	or	al, al
  9984 0000289A 741C                <1> 	jz	short vga_g_down_l2
  9985 0000289C 88C4                <1> 	mov	ah, al
  9986 0000289E 00EC                <1> 	add	ah, ch
  9987                              <1> 	;jc	short vga_g_down_l2	
  9988 000028A0 86EE                <1> 	xchg	ch, dh
  9989 000028A2 38E5                <1> 	cmp	ch, ah
  9990 000028A4 7212                <1> 	jb	short vga_g_down_l2
  9991 000028A6 88EC                <1> 	mov	ah, ch
  9992 000028A8 28C4                <1> 	sub	ah, al ; ah = i - nblines
  9993                              <1> 	; else
  9994                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  9995 000028AA E812FEFFFF          <1> 	call	vgamem_copy_l8
  9996                              <1> vga_g_down_l1:
  9997 000028AF 86F5                <1> 	xchg	dh, ch
  9998 000028B1 FECE                <1> 	dec	dh 
  9999 000028B3 38EE                <1> 	cmp	dh, ch
 10000 000028B5 73E1                <1> 	jnb	short vga_g_down_l0
 10001 000028B7 C3                  <1> 	retn
 10002                              <1> 
 10003                              <1> vga_g_down_l2:
 10004                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
 10005 000028B8 E86AFEFFFF          <1> 	call	vgamem_fill_l8
 10006 000028BD EBF0                <1> 	jmp	short vga_g_down_l1
 10007                              <1> 		 
 10008                              <1> vga_g_down_planar:
 10009                              <1> 	; cl = upper left column ; cul
 10010                              <1> 	; ch = upper left row ; rul
 10011                              <1> 	; dl = lower rigth column ; clr
 10012                              <1> 	; dh = lower right row ; rlr
 10013                              <1> vga_g_down_pl0:
 10014                              <1>  	;{for(i=rlr;i>=rul;i--)
 10015                              <1>         ; if((i<rul+nblines)||(nblines==0))
 10016 000028BF 08C0                <1> 	or	al, al
 10017 000028C1 741C                <1> 	jz	short vga_g_down_pl2
 10018 000028C3 88C4                <1> 	mov	ah, al
 10019 000028C5 00EC                <1> 	add	ah, ch
 10020                              <1> 	;jc	short vga_g_down_pl2	
 10021 000028C7 86EE                <1> 	xchg	ch, dh
 10022 000028C9 38E5                <1> 	cmp	ch, ah
 10023 000028CB 7212                <1> 	jb	short vga_g_down_pl2
 10024 000028CD 88EC                <1> 	mov	ah, ch
 10025 000028CF 28C4                <1> 	sub	ah, al ; ah = i - nblines
 10026                              <1> 	; else
 10027                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
 10028 000028D1 E826FDFFFF          <1> 	call	vgamem_copy_pl4
 10029                              <1> vga_g_down_pl1:
 10030 000028D6 86F5                <1> 	xchg	dh, ch
 10031 000028D8 FECE                <1> 	dec	dh 
 10032 000028DA 38EE                <1> 	cmp	dh, ch
 10033 000028DC 73E1                <1> 	jnb	short vga_g_down_pl0
 10034 000028DE C3                  <1> 	retn
 10035                              <1> 
 10036                              <1> vga_g_down_pl2:
 10037                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
 10038 000028DF E886FDFFFF          <1> 	call	vgamem_fill_pl4
 10039 000028E4 EBF0                <1> 	jmp	short vga_g_down_pl1
 10040                              <1> 
 10041                              <1> 
 10042                              <1> 
 10043                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
 10044                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10045                              <1> 
 10046                              <1> ;-----	ROUTINE TO MOVE ONE ROW OF INFORMATION
 10047                              <1> 
 10048                              <1> _R17:
 10049 000028E6 0FB6CA              <1> 	movzx	ecx, dl			; NUMBER OF BYTES IN THE ROW
 10050 000028E9 56                  <1> 	push	esi
 10051 000028EA 57                  <1> 	push	edi			; SAVE POINTERS
 10052 000028EB F3A4                <1> 	rep	movsb			; MOVE THE EVEN FIELD
 10053 000028ED 5F                  <1> 	pop	edi
 10054 000028EE 5E                  <1> 	pop	esi
 10055 000028EF 6681C60020          <1> 	add	si, 2000h
 10056 000028F4 6681C70020          <1> 	add	di, 2000h		; POINT TO THE ODD FIELD
 10057 000028F9 56                  <1> 	push	esi
 10058 000028FA 57                  <1> 	push	edi			; SAVE THE POINTERS
 10059 000028FB 88D1                <1> 	mov	cl, dl			; COUNT BACK
 10060 000028FD F3A4                <1> 	rep	movsb			; MOVE THE ODD FIELD
 10061 000028FF 5F                  <1> 	pop	edi
 10062 00002900 5E                  <1> 	pop	esi			; POINTERS BACK
 10063 00002901 C3                  <1> 	retn				; RETURN TO CALLER
 10064                              <1> 
 10065                              <1> ;-----	CLEAR A SINGLE ROW
 10066                              <1> 
 10067                              <1> _R18:
 10068 00002902 0FB6CA              <1> 	movzx	ecx, dl			; NUMBER OF BYTES IN FIELD
 10069 00002905 57                  <1> 	push	edi			; SAVE POINTER
 10070 00002906 F3AA                <1> 	rep	stosb			; STORE THE NEW VALUE
 10071 00002908 5F                  <1> 	pop	edi			; POINTER BACK
 10072 00002909 6681C70020          <1> 	add	di, 2000h		; POINT TO ODD FIELD
 10073 0000290E 57                  <1> 	push	edi
 10074 0000290F 88D1                <1> 	mov	cl, dl
 10075 00002911 F3AA                <1> 	rep	stosb			; FILL THE ODD FIELD
 10076 00002913 5F                  <1> 	pop	edi
 10077 00002914 C3                  <1> 	retn				; RETURN TO CALLER
 10078                              <1> 
 10079                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
 10080                              <1> ; 04/07/2016
 10081                              <1> ; 01/07/2016
 10082                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
 10083                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10084                              <1> ;--------------------------------------------------
 10085                              <1> ; GRAPHICS WRITE
 10086                              <1> ;  THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT
 10087                              <1> ;  POSITION ON THE SCREEN.
 10088                              <1> ; ENTRY --
 10089                              <1> ;  AL = CHARACTER TO WRITE
 10090                              <1> ;  BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR
 10091                              <1> ;	IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER
 10092                              <1> ;	(0 IS USED FOR THE BACKGROUND COLOR)
 10093                              <1> ;  CX = NUMBER OF CHARS TO WRITE
 10094                              <1> ;  DS = DATA SEGMENT
 10095                              <1> ;  ES = REGEN SEGMENT
 10096                              <1> ; EXIT --
 10097                              <1> ;  NOTHING IS RETURNED
 10098                              <1> ;
 10099                              <1> ; GRAPHICS READ
 10100                              <1> ;  THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR
 10101                              <1> ;  POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE
 10102                              <1> ;  CHARACTER GENERATOR CODE POINTS
 10103                              <1> ; ENTRY --
 10104                              <1> ;  NONE (0 IS ASSUMED AS THE BACKGROUND COLOR)
 10105                              <1> ; EXIT --
 10106                              <1> ;  AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND)
 10107                              <1> ;
 10108                              <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM
 10109                              <1> ;  FOR THE 1ST 128 CHARS.  TO ACCESS CHARS IN THE SECOND HALF, THE USER
 10110                              <1> ;  MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO
 10111                              <1> ;  POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES).
 10112                              <1> ;  FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS
 10113                              <1> ;-----------------------------------------------------
 10114                              <1> 
 10115                              <1> GRAPHICS_WRITE:
 10116 00002915 25FF000000          <1> 	and 	eax, 0FFh		; ZERO TO HIGH OF CODE POINT
 10117 0000291A 50                  <1> 	push	eax			; SAVE CODE POINT VALUE
 10118                              <1> 
 10119                              <1> ;-----	DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS
 10120                              <1> 
 10121 0000291B E846010000          <1> 	call	S26			; FIND LOCATION IN REGEN BUFFER
 10122 00002920 89C7                <1> 	mov	edi, eax		; REGEN POINTER IN DI
 10123                              <1> 
 10124                              <1> ;-----	DETERMINE REGION TO GET CODE POINTS FROM
 10125                              <1> 
 10126 00002922 58                  <1> 	pop	eax			; RECOVER CODE POINT
 10127                              <1> 
 10128 00002923 BE[104E0100]        <1> 	mov	esi, CRT_CHAR_GEN	; OFFSET OF IMAGES
 10129                              <1> 
 10130                              <1> ;-----	DETERMINE GRAPHICS MODE IN OPERATION
 10131                              <1> 					; DETERMINE_MODE
 10132                              <1> 	;sal	ax, 3			; MULTIPLY CODE POINT VALUE BY 8
 10133                              <1> 	; 03/08/2022
 10134 00002928 C1E003              <1> 	sal	eax, 3
 10135 0000292B 01C6                <1> 	add	esi, eax		; SI HAS OFFSET OF DESIRED CODES
 10136                              <1> 	
 10137 0000292D 803D[9E660000]06    <1> 	cmp	byte [CRT_MODE], 6
 10138 00002934 7231                <1> 	jc	short S6		; TEST FOR MEDIUM RESOLUTION MODE
 10139                              <1> 
 10140                              <1> ;-----	HIGH RESOLUTION MODE
 10141                              <1> 
 10142 00002936 81C700800B00        <1> 	add	edi, 0B8000h
 10143                              <1> S1:					; HIGH_CHAR
 10144 0000293C 57                  <1> 	push	edi			; SAVE REGEN POINTER
 10145 0000293D 56                  <1> 	push	esi			; SAVE CODE POINTER
 10146 0000293E B604                <1> 	mov	dh, 4			; NUMBER OF TIMES THROUGH LOOP
 10147                              <1> S2:
 10148 00002940 AC                  <1> 	lodsb				; GET BYTE FROM CODE POINTS
 10149 00002941 F6C380              <1> 	test	bl, 80h			; SHOULD WE USE THE FUNCTION
 10150 00002944 7515                <1> 	jnz	short S5		; TO PUT CHAR IN
 10151 00002946 AA                  <1> 	stosb				; STORE IN REGEN BUFFER
 10152 00002947 AC                  <1> 	lodsb
 10153                              <1> S4:
 10154 00002948 8887FF1F0000        <1> 	mov	[edi+2000h-1], al	; STORE IN SECOND HALF
 10155 0000294E 83C74F              <1> 	add	edi, 79			; MOVE TO NEXT ROW IN REGEN
 10156 00002951 FECE                <1> 	dec	dh			; DONE WITH LOOP
 10157 00002953 75EB                <1> 	jnz	short S2
 10158 00002955 5E                  <1> 	pop	esi
 10159 00002956 5F                  <1> 	pop	edi			; RECOVER REGEN POINTER
 10160 00002957 47                  <1> 	inc	edi			; POINT TO NEXT CHAR POSITION
 10161 00002958 E2E2                <1> 	loop	S1			; MORE CHARS TO WRITE
 10162 0000295A C3                  <1> 	retn
 10163                              <1> 
 10164                              <1> S5:
 10165 0000295B 3207                <1> 	xor	al, [edi]		; EXCLUSIVE OR WITH CURRENT
 10166 0000295D AA                  <1> 	stosb				; STORE THE CODE POINT
 10167 0000295E AC                  <1> 	lodsb				; AGAIN FOR ODD FIELD
 10168 0000295F 3287FF1F0000        <1> 	xor	al, [edi+2000h-1]
 10169 00002965 EBE1                <1> 	jmp	short S4		; BACK TO MAINSTREAM
 10170                              <1> 
 10171                              <1> ;-----	MEDIUM RESOLUTION WRITE
 10172                              <1> S6:					; MED_RES_WRITE
 10173 00002967 88DA                <1> 	mov	dl, bl			; SAVE HIGH COLOR BIT
 10174                              <1> 	; 03/08/2022
 10175 00002969 D1E7                <1> 	sal	edi, 1
 10176                              <1> 	;sal	di, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
 10177                              <1> 					; EXPAND BL TO FULL WORD OF COLOR
 10178 0000296B 80E303              <1> 	and	bl, 3			; ISOLATE THE COLOR BITS ( LOW 2 BITS )
 10179 0000296E B055                <1> 	mov	al, 055h		; GET BIT CONVERSION MULTIPLIER
 10180 00002970 F6E3                <1> 	mul	bl			; EXPAND 2 COLOR BITS TO 4 REPLICATIONS
 10181 00002972 88C3                <1> 	mov	bl, al			; PLACE BACK IN WORK REGISTER
 10182 00002974 88C7                <1> 	mov	bh, al			; EXPAND TO 8 REPLICATIONS OF COLOR BITS
 10183 00002976 81C700800B00        <1> 	add	edi, 0B8000h
 10184                              <1> S7:                                     ; MED_CHAR
 10185 0000297C 57                  <1> 	push	edi			; SAVE REGEN POINTER
 10186 0000297D 56                  <1> 	push	esi			; SAVE THE CODE POINTER
 10187 0000297E B604                <1> 	mov	dh, 4			; NUMBER OF LOOPS
 10188                              <1> S8:
 10189 00002980 AC                  <1> 	lodsb				; GET CODE POINT
 10190 00002981 E8B1000000          <1> 	call	S21			; DOUBLE UP ALL THE BITS
 10191 00002986 6621D8              <1> 	and	ax, bx			; CONVERT TO FOREGROUND COLOR ( 0 BACK )
 10192 00002989 86E0                <1> 	xchg	ah, al			; SWAP HIGH/LOW BYTES FOR WORD MOVE
 10193 0000298B F6C280              <1> 	test	dl, 80h			; IS THIS XOR FUNCTION
 10194 0000298E 7403                <1> 	jz	short S9		; NO, STORE IT IN AS IS
 10195 00002990 663307              <1> 	xor	ax, [edi]		; DO FUNCTION WITH LOW/HIGH
 10196                              <1> S9:
 10197 00002993 668907              <1> 	mov	[edi], ax		; STORE FIRST BYTE HIGH, SECOND LOW
 10198 00002996 AC                  <1> 	lodsb				; GET CODE POINT
 10199 00002997 E89B000000          <1> 	call	S21
 10200 0000299C 6621D8              <1> 	and	ax, bx			; CONVERT TO COLOR
 10201 0000299F 86E0                <1> 	xchg	ah, al			; SWAP HIGH/LOW BYTES FOR WORD MOVE
 10202 000029A1 F6C280              <1> 	test	dl, 80h			; AGAIN, IS THIS XOR FUNCTION
 10203 000029A4 7407                <1> 	jz	short _S10		; NO, JUST STORE THE VALUES
 10204 000029A6 66338700200000      <1> 	xor	ax, [edi+2000h]		; FUNCTION WITH FIRST HALF LOW
 10205                              <1> _S10:
 10206 000029AD 66898700200000      <1> 	mov	[edi+2000h], ax		; STORE SECOND PORTION HIGH
 10207 000029B4 6683C750            <1> 	add	di, 80			; POINT TO NEXT LOCATION
 10208 000029B8 FECE                <1> 	dec	dh
 10209 000029BA 75C4                <1> 	jnz	short S8		; KEEP GOING
 10210 000029BC 5E                  <1> 	pop	esi			; RECOVER CODE POINTER
 10211 000029BD 5F                  <1> 	pop	edi			; RECOVER REGEN POINTER
 10212 000029BE 47                  <1> 	inc	edi			; POINT TO NEXT CHAR POSITION
 10213 000029BF 47                  <1> 	inc	edi
 10214 000029C0 E2BA                <1> 	loop	S7			; MORE TO WRITE
 10215 000029C2 C3                  <1> 	retn
 10216                              <1> 
 10217                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
 10218                              <1> ; 04/07/2016
 10219                              <1> ; 01/07/2016
 10220                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
 10221                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10222                              <1> ;----------------------------------------
 10223                              <1> ; GRAPHICS READ
 10224                              <1> ;----------------------------------------
 10225                              <1> GRAPHICS_READ:
 10226 000029C3 E89E000000          <1> 	call	S26			; CONVERTED TO OFFSET IN REGEN
 10227 000029C8 89C6                <1> 	mov	esi, eax		; SAVE IN SI
 10228 000029CA 81C600800B00        <1> 	add	esi, 0B8000h		; 01/07/2016
 10229 000029D0 83EC08              <1> 	sub	esp, 8			; ALLOCATE SPACE FOR THE READ CODE POINT
 10230 000029D3 89E5                <1> 	mov	ebp, esp		; POINTER TO SAVE AREA
 10231                              <1> 
 10232                              <1> ;-----	DETERMINE GRAPHICS MODES
 10233 000029D5 B604                <1> 	mov	dh, 4			; number of passes ; 01/07/2016
 10234 000029D7 803D[9E660000]06    <1> 	cmp	byte [CRT_MODE], 6
 10235 000029DE 7219                <1> 	jc	short S12		; MEDIUM RESOLUTION
 10236                              <1> 
 10237                              <1> ;-----	HIGH RESOLUTION READ
 10238                              <1> ;-----	GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT
 10239                              <1> 	;mov	dh,4			; NUMBER OF PASSES
 10240                              <1> S11:
 10241 000029E0 8A06                <1> 	mov	al, [esi] 		; GET FIRST BYTE
 10242 000029E2 884500              <1> 	mov	[ebp], al 		; SAVE IN STORAGE AREA
 10243 000029E5 45                  <1> 	inc	ebp			; NEXT LOCATION
 10244 000029E6 8A8600200000        <1> 	mov	al, [esi+2000h]		; GET LOWER REGION BYTE
 10245 000029EC 884500              <1> 	mov	[ebp], al 		; ADJUST AND STORE
 10246 000029EF 45                  <1> 	inc	ebp
 10247 000029F0 83C650              <1> 	add	esi, 80			; POINTER INTO REGEN
 10248 000029F3 FECE                <1> 	dec	dh			; LOOP CONTROL
 10249 000029F5 75E9                <1> 	jnz	short S11		; DO IT SOME MORE
 10250 000029F7 EB1C                <1> 	jmp	short S14		; GO MATCH THE SAVED CODE POINTS
 10251                              <1> 
 10252                              <1> ;-----	MEDIUM RESOLUTION READ
 10253                              <1> S12:	
 10254                              <1> 	;sal	si, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
 10255                              <1> 	; 03/08/2022
 10256 000029F9 D1E6                <1> 	sal	esi, 1
 10257                              <1> 	;mov	dh, 4			; NUMBER OF PASSES
 10258                              <1> S13:
 10259 000029FB E84B000000          <1> 	call	S23			; GET BYTES FROM REGEN INTO SINGLE SAVE
 10260 00002A00 81C6FE1F0000        <1> 	add	esi, 2000h-2		; GO TO LOWER REGION
 10261 00002A06 E840000000          <1> 	call	S23			; GET THIS PAIR INTO SAVE
 10262 00002A0B 81EEB21F0000        <1> 	sub	esi, 2000h-80+2		; ADJUST POINTER BACK INTO UPPER
 10263 00002A11 FECE                <1> 	dec	dh
 10264 00002A13 75E6                <1> 	jnz	short S13		; KEEP GOING UNTIL ALL 8 DONE
 10265                              <1> 
 10266                              <1> ;-----	SAVE AREA HAS CHARACTER IN IT, MATCH IT
 10267                              <1> S14:					; FIND_CHAR
 10268 00002A15 BF[104E0100]        <1> 	mov	edi, CRT_CHAR_GEN	; ESTABLISH ADDRESSING
 10269 00002A1A 83ED08              <1> 	sub	ebp, 8			; ADJUST POINTER TO START OF SAVE AREA
 10270 00002A1D 89EE                <1> 	mov	esi, ebp
 10271                              <1> S15:
 10272                              <1> 	;mov	ax, 256			; NUMBER TO TEST AGAINST
 10273                              <1> 	; 03/08/2022
 10274 00002A1F 29C0                <1> 	sub	eax, eax
 10275 00002A21 FEC4                <1> 	inc	ah
 10276                              <1> 	; eax = 256
 10277                              <1> S16:
 10278 00002A23 56                  <1> 	push	esi			; SAVE SAVE AREA POINTER
 10279 00002A24 57                  <1> 	push	edi			; SAVE CODE POINTER
 10280                              <1> 	;mov	ecx, 4			; NUMBER OF WORDS TO MATCH
 10281                              <1> 	;repe	cmpsw			; COMPARE THE 8 BYTES AS WORDS
 10282 00002A25 A7                  <1> 	cmpsd				; compare first 4 bytes 
 10283 00002A26 7501                <1> 	jne	short S17		; 
 10284 00002A28 A7                  <1> 	cmpsd				; compare last 4 bytes
 10285                              <1> S17:
 10286 00002A29 5F                  <1> 	pop	edi			; RECOVER THE POINTERS
 10287 00002A2A 5E                  <1> 	pop	esi
 10288                              <1> 	;jz	short S18		; IF ZERO FLAG SET, THEN MATCH OCCURRED
 10289 00002A2B 7406                <1> 	je	short S18
 10290                              <1> 	;				; NO MATCH, MOVE ON TO NEXT
 10291 00002A2D 83C708              <1> 	add	edi, 8			; NEXT CODE POINT
 10292                              <1> 	;dec	ax			; LOOP CONTROL
 10293                              <1> 	; 03/08/2022
 10294 00002A30 48                  <1> 	dec	eax
 10295 00002A31 75F0                <1> 	jnz	short S16		; DO ALL OF THEM
 10296                              <1> 
 10297                              <1> ;-----	CHARACTER IS FOUND ( AL=0 IF NOT FOUND )
 10298                              <1> S18:	
 10299 00002A33 83C408              <1> 	add	esp, 8			; READJUST THE STACK, THROW AWAY SAVE
 10300 00002A36 C3                  <1> 	retn				; ALL DONE
 10301                              <1> 
 10302                              <1> ; 12/04/2021
 10303                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
 10304                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10305                              <1> ;--------------------------------------------
 10306                              <1> ; EXPAND BYTE
 10307                              <1> ;  THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL
 10308                              <1> ;  OF THE BITS, TURNING THE 8 BITS INTO 16 BITS.
 10309                              <1> ;  THE RESULT IS LEFT IN AX
 10310                              <1> ;--------------------------------------------
 10311                              <1> S21:
 10312                              <1> 	; 03/08/2022
 10313                              <1> 	;push	cx			; SAVE REGISTER
 10314                              <1> 	; 12/04/2021
 10315 00002A37 51                  <1> 	push	ecx
 10316                              <1> 	;;mov	cx, 8			; SHIFT COUNT REGISTER FOR ONE BYTE
 10317                              <1> 	;mov	cl, 8
 10318 00002A38 B408                <1> 	mov	ah, 8
 10319                              <1> S22:
 10320 00002A3A D0C8                <1> 	ror	al, 1			; SHIFT BITS, LOW BIT INTO CARRY FLAG
 10321                              <1> 	;rcr	bp, 1			; MOVE CARRY FLAG (LOW BIT INTO RESULTS
 10322                              <1> 	;sar	bp, 1			; SIGN EXTEND HIGH BIT (DOUBLE IT)
 10323                              <1> 	; 03/08/2022
 10324 00002A3C 66D1D9              <1> 	rcr	cx, 1
 10325 00002A3F 66D1F9              <1> 	sar	cx, 1
 10326                              <1> 
 10327                              <1> 	;;loop	S22			; REPEAT FOR ALL 8 BITS
 10328                              <1> 	;dec	cl
 10329                              <1> 	;jnz	short S22
 10330                              <1> 	;xchg	ax, bp			; MOVE RESULTS TO PARAMETER REGISTER
 10331                              <1> 	; 03/08/5022
 10332 00002A42 FECC                <1> 	dec	ah
 10333 00002A44 75F4                <1> 	jnz	short S22
 10334 00002A46 6689C8              <1> 	mov	ax, cx
 10335                              <1> 	;pop	cx			; RECOVER REGISTER
 10336                              <1> 	; 12/04/2021
 10337 00002A49 59                  <1> 	pop	ecx
 10338 00002A4A C3                  <1> 	retn				; ALL DONE
 10339                              <1> 
 10340                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
 10341                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10342                              <1> ;--------------------------------------------------
 10343                              <1> ; MED_READ_BYTE
 10344                              <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER,
 10345                              <1> ;  COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE
 10346                              <1> ;  THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT
 10347                              <1> ;  POSITION IN THE SAVE AREA
 10348                              <1> ; ENTRY --
 10349                              <1> ;  SI,DS = POINTER TO REGEN AREA OF INTEREST
 10350                              <1> ;  BX = EXPANDED FOREGROUND COLOR
 10351                              <1> ;  BP = POINTER TO SAVE AREA
 10352                              <1> ; EXIT --
 10353                              <1> ;  SI AND BP ARE INCREMENTED
 10354                              <1> ;----------------------------------------------------
 10355                              <1> S23:
 10356 00002A4B 66AD                <1> 	lodsw				; GET FIRST BYTE AND SECOND BYTES
 10357 00002A4D 86C4                <1> 	xchg	al, ah			; SWAP FOR COMPARE
 10358                              <1> 	;mov	cx, 0C000h		; 2 BIT MASK TO TEST THE ENTRIES
 10359                              <1> 	; 02/08/2022
 10360 00002A4F 29C9                <1> 	sub	ecx, ecx
 10361 00002A51 B5C0                <1> 	mov	ch, 0C0h
 10362                              <1> 	; ecx = 0C000h
 10363                              <1> 	;mov	dl, 0			; RESULT REGISTER
 10364                              <1> 	; 03/08/2022
 10365 00002A53 28D2                <1> 	sub	dl, dl
 10366                              <1> S24:
 10367                              <1> 	;test	ax, cx			; IS THIS SECTION BACKCROUND?
 10368                              <1>         ; 03/08/2022
 10369 00002A55 85C8                <1> 	test	eax, ecx
 10370 00002A57 7401                <1> 	jz	short S25               ; IF ZERO, IT IS BACKGROUND (CARRY=0)
 10371 00002A59 F9                  <1> 	stc				; WASN'T, SO SET CARRY
 10372                              <1> S25:
 10373 00002A5A D0D2                <1> 	rcl	dl, 1			; MOVE THAT BIT INTO THE RESULT
 10374                              <1> 	;shr	cx, 2			; MOVE THE MASK TO THE RIGHT BY 2 BITS
 10375                              <1> 	; 02/08/2022
 10376 00002A5C C1E902              <1> 	shr	ecx, 2
 10377 00002A5F 73F4                <1> 	jnc	short S24		; DO IT AGAIN IF MASK DIDN'T FALL OUT
 10378 00002A61 885500              <1> 	mov	[ebp], dl 		; STORE RESULT IN SAVE AREA
 10379 00002A64 45                  <1> 	inc	ebp			; ADJUST POINTER
 10380 00002A65 C3                  <1> 	retn				; ALL DONE
 10381                              <1> 
 10382                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
 10383                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
 10384                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10385                              <1> ;-----------------------------------------
 10386                              <1> ; V4_POSITION
 10387                              <1> ;  THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN
 10388                              <1> ;  THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET
 10389                              <1> ;  INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR.
 10390                              <1> ;  FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST
 10391                              <1> ;  BE DOUBLED.
 10392                              <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED
 10393                              <1> ; EXIT--
 10394                              <1> ;  AX CONTAINS OFFSET INTO REGEN BUFFER
 10395                              <1> ;-----------------------------------------
 10396                              <1> S26:
 10397 00002A66 0FB705[9E770100]    <1> 	movzx	eax, word [CURSOR_POSN]	; GET CURRENT CURSOR
 10398                              <1> GRAPH_POSN:
 10399 00002A6D 53                  <1> 	push	ebx			; SAVE REGISTER
 10400 00002A6E 0FB6D8              <1> 	movzx	ebx, al			; SAVE A COPY OF CURRENT CURSOR
 10401 00002A71 A0[A0660000]        <1> 	mov	al, [CRT_COLS]		; GET BYTES PER COLUMN
 10402 00002A76 F6E4                <1> 	mul	ah			; MULTIPLY BY ROWS
 10403                              <1> 	;shl	ax, 2			; MULTIPLY * 4 SINCE 4 ROWS/BYTE
 10404                              <1> 	; 02/08/2022
 10405 00002A78 C1E002              <1> 	shl	eax, 2
 10406 00002A7B 01D8                <1> 	add	eax, ebx		; DETERMINE OFFSET
 10407 00002A7D 5B                  <1> 	pop	ebx			; RECOVER POINTER
 10408 00002A7E C3                  <1> 	retn				; ALL DONE
 10409                              <1> 
 10410                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
 10411                              <1> ; 09/07/2016
 10412                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
 10413                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10414                              <1> ;---------------------------------------------
 10415                              <1> ; SET_COLOR
 10416                              <1> ;	THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR,
 10417                              <1> ;	AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS
 10418                              <1> ; INPUT
 10419                              <1> ;	(BH) HAS COLOR ID
 10420                              <1> ;		IF BH=0, THE BACKGROUND COLOR VALUE IS SET
 10421                              <1> ;			FROM THE LOW BITS OF BL (0-31)
 10422                              <1> ;		IF BH=1, THE PALETTE SELECTION IS MADE
 10423                              <1> ;			BASED ON THE LOW BIT OF BL:
 10424                              <1> ;				0 = GREEN, RED, YELLOW FOR COLORS 1,2,3
 10425                              <1> ;				1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3
 10426                              <1> ;	(BL) HAS THE COLOR VALUE TO BE USED
 10427                              <1> ; OUTPUT
 10428                              <1> ;	THE COLOR SELECTION IS UPDATED
 10429                              <1> ;----------------------------------------------
 10430                              <1> SET_COLOR:
 10431 00002A7F 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7      ; 09/07/2016
 10432                              <1> 	;ja	VIDEO_RETURN		; nothing to do for VGA modes
 10433                              <1> 	; 03/08/2022
 10434 00002A86 7605                <1> 	jna	short M21
 10435 00002A88 E92EF0FFFF          <1> 	jmp	VIDEO_RETURN
 10436                              <1> M21:
 10437                              <1> 	;mov	dx, [ADDR_6845]		; I/O PORT FOR PALETTE
 10438                              <1> 	;mov	dx, 3D4h
 10439                              <1> 	;add	dx, 5			; OVERSCAN PORT
 10440 00002A8D 66BAD903            <1> 	mov	dx, 3D9h
 10441 00002A91 A0[A1660000]        <1> 	mov	al, [CRT_PALETTE] 	; GET THE CURRENT PALETTE VALUE
 10442 00002A96 08FF                <1> 	or	bh, bh			; IS THIS COLOR 0?
 10443 00002A98 7512                <1> 	jnz	short M20		; OUTPUT COLOR 1
 10444                              <1> 
 10445                              <1> ;-----	HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR
 10446                              <1> 
 10447 00002A9A 24E0                <1> 	and	al, 0E0h 		; TURN OFF LOW 5 BITS OF CURRENT
 10448 00002A9C 80E31F              <1> 	and	bl, 01Fh 		; TURN OFF HIGH 3 BITS OF INPUT VALUE
 10449 00002A9F 08D8                <1> 	or	al, bl			; PUT VALUE INTO REGISTER
 10450                              <1> M19:					; OUTPUT THE PALETTE
 10451 00002AA1 EE                  <1> 	out	dx, al			; OUTPUT COLOR SELECTION TO 3D9 PORT
 10452 00002AA2 A2[A1660000]        <1> 	mov	[CRT_PALETTE], al 	; SAVE THE COLOR VALUE
 10453 00002AA7 E90FF0FFFF          <1> 	jmp	VIDEO_RETURN
 10454                              <1> 
 10455                              <1> ;-----	HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED
 10456                              <1> 
 10457                              <1> M20:
 10458 00002AAC 24DF                <1> 	and	al, 0DFH 		; TURN OFF PALETTE SELECT BIT
 10459 00002AAE D0EB                <1> 	shr	bl, 1			; TEST THE LOW ORDER BIT OF BL
 10460 00002AB0 73EF                <1> 	jnc	short M19		; ALREADY DONE
 10461 00002AB2 0C20                <1> 	or	al, 20H			; TURN ON PALETTE SELECT BIT
 10462 00002AB4 EBEB                <1> 	jmp	short M19		; GO DO IT
 10463                              <1> 
 10464                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
 10465                              <1> ; 09/07/2016
 10466                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
 10467                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10468                              <1> ;--------------------------------------------
 10469                              <1> ; READ DOT -- WRITE DOT
 10470                              <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE
 10471                              <1> ;  DOT AT THE INDICATED LOCATION
 10472                              <1> ; ENTRY --
 10473                              <1> ;   DX = ROW (0-199)	(THE ACTUAL VALUE DEPENDS ON THE MODE)
 10474                              <1> ;   CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED )
 10475                              <1> ;   AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE,
 10476                              <1> ;	REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED)
 10477                              <1> ;	BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION
 10478                              <1> ;   DS = DATA SEGMENT
 10479                              <1> ;   ES = REGEN SEGMENT
 10480                              <1> ;
 10481                              <1> ; EXIT
 10482                              <1> ;	AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY
 10483                              <1> ;----------------------------------------------
 10484                              <1> 
 10485                              <1> READ_DOT:
 10486                              <1> 	; 09/07/2016
 10487 00002AB6 8A25[9E660000]      <1> 	mov	ah,  [CRT_MODE]
 10488 00002ABC 80FC07              <1> 	cmp	ah, 7 ; 6!?
 10489 00002ABF 760A                <1> 	jna	short read_dot_cga
 10490                              <1> 
 10491 00002AC1 E8B3030000          <1> 	call	vga_read_pixel
 10492                              <1> 	; al = pixel value
 10493                              <1> read_dot_retn:	; 03/08/2022
 10494 00002AC6 E9F5EFFFFF          <1> 	jmp	_video_return
 10495                              <1> 
 10496                              <1> read_dot_cga:
 10497                              <1> 	;je	VIDEO_RETURN ; 7	
 10498 00002ACB 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
 10499                              <1> 	;jb	VIDEO_RETURN ; no, text mode, nothing to do
 10500                              <1> 	; 03/08/2022
 10501 00002ACE 72F6                <1> 	jb	short read_dot_retn
 10502                              <1> 
 10503 00002AD0 E84F000000          <1> 	call	R3			; DETERMINE BYTE POSITION OF DOT
 10504 00002AD5 8A06                <1> 	mov	al, [esi]		; GET THE BYTE
 10505 00002AD7 20E0                <1> 	and	al, ah			; MASK OFF THE OTHER BITS IN THE BYTE
 10506 00002AD9 D2E0                <1> 	shl	al, cl			; LEFT JUSTIFY THE VALUE
 10507 00002ADB 88F1                <1> 	mov	cl, dh			; GET NUMBER OF BITS IN RESULT
 10508 00002ADD D2C0                <1> 	rol	al, cl			; RIGHT JUSTIFY THE RESULT
 10509                              <1> 	;jmp	VIDEO_RETURN		; RETURN FROM VIDEO I/O
 10510 00002ADF 0FB6C0              <1> 	movzx	eax, al
 10511 00002AE2 E9D9EFFFFF          <1> 	jmp	_video_return
 10512                              <1> 
 10513                              <1> ; 03/08/2022
 10514                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
 10515                              <1> ; 12/04/2021
 10516                              <1> ; 09/07/2016
 10517                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
 10518                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10519                              <1> 
 10520                              <1> WRITE_DOT:
 10521                              <1> 	; 09/07/2016
 10522 00002AE7 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE]
 10523 00002AED 80FC07              <1> 	cmp	ah, 7 ; 6!?
 10524 00002AF0 760A                <1> 	jna	short write_dot_cga
 10525                              <1> 	
 10526 00002AF2 E8F2020000          <1> 	call	vga_write_pixel
 10527                              <1> write_dot_retn:	; 03/08/2022
 10528 00002AF7 E9BFEFFFFF          <1> 	jmp	VIDEO_RETURN
 10529                              <1> 
 10530                              <1> write_dot_cga:
 10531                              <1> 	;je	VIDEO_RETURN ; 7	
 10532 00002AFC 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
 10533                              <1> 	;jb	VIDEO_RETURN ; no, text mode, nothing to do
 10534                              <1> 	; 03/08/2022
 10535 00002AFF 72F6                <1> 	jb	short write_dot_retn
 10536                              <1> 
 10537                              <1> 	;;push	ax			; SAVE DOT VALUE
 10538                              <1> 	;push	ax			; TWICE
 10539                              <1> 	; 12/04/2021
 10540 00002B01 50                  <1> 	push	eax
 10541 00002B02 E81D000000          <1> 	call	R3			; DETERMINE BYTE POSITION OF THE DOT
 10542 00002B07 D2E8                <1> 	shr	al, cl			; SHIFT TO SET UP THE BITS FOR OUTPUT
 10543 00002B09 20E0                <1> 	and	al, ah			; STRIP OFF THE OTHER BITS
 10544 00002B0B 8A0E                <1> 	mov	cl, [esi]		; GET THE CURRENT BYTE
 10545                              <1> 	;pop	bx			; RECOVER XOR FLAG
 10546                              <1> 	; 12/04/2021
 10547 00002B0D 5B                  <1> 	pop	ebx
 10548 00002B0E F6C380              <1> 	test	bl, 80h			; IS IT ON
 10549 00002B11 750D                <1> 	jnz	short R2		; YES, XOR THE DOT
 10550 00002B13 F6D4                <1> 	not	ah			; SET MASK TO REMOVE THE INDICATED BITS
 10551 00002B15 20E1                <1> 	and	cl, ah
 10552 00002B17 08C8                <1> 	or	al, cl			; OR IN THE NEW VALUE OF THOSE BITS
 10553                              <1> R1:					; FINISH_DOT
 10554 00002B19 8806                <1> 	mov	[esi], al		; RESTORE THE BYTE IN MEMORY
 10555                              <1> 	;;pop	AX
 10556 00002B1B E99BEFFFFF          <1> 	jmp	VIDEO_RETURN		; RETURN FROM VIDEO I/O
 10557                              <1> R2:					; XOR_DOT
 10558 00002B20 30C8                <1> 	xor	al, cl			; EXCLUSIVE OR THE DOTS
 10559 00002B22 EBF5                <1> 	jmp	short R1		; FINISH UP THE WRITING
 10560                              <1> 
 10561                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
 10562                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
 10563                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
 10564                              <1> 
 10565                              <1> ;----------------------------------------------
 10566                              <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE
 10567                              <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE.
 10568                              <1> ; ENTRY --
 10569                              <1> ;  DX = ROW VALUE (0-199)
 10570                              <1> ;  CX = COLUMN VALUE (0-639)
 10571                              <1> ; EXIT --
 10572                              <1> ;  SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST
 10573                              <1> ;  AH = MASK TO STRIP OFF THE BITS OF INTEREST
 10574                              <1> ;  CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH
 10575                              <1> ;  DH = # BITS IN RESULT
 10576                              <1> ;  BX = MODIFIED
 10577                              <1> ;-----------------------------------------------
 10578                              <1> R3:
 10579                              <1> 
 10580                              <1> ;-----	DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40
 10581                              <1> ;-----	 ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW )
 10582                              <1> 
 10583 00002B24 0FB7F0              <1> 	movzx	esi, ax			; WILL SAVE AL AND AH DURING OPERATION
 10584 00002B27 B028                <1> 	mov	al, 40
 10585 00002B29 F6E2                <1> 	mul	dl			; AX= ADDRESS OF START OF INDICATED ROW
 10586 00002B2B A808                <1> 	test	al, 08H 		; TEST FOR EVEN/ODD ROW CALCULATED
 10587 00002B2D 7404                <1> 	JZ	short R4		; JUMP IF EVEN ROW
 10588 00002B2F 6605D81F            <1> 	add	ax, 2000h-40		; OFFSET TO LOCATION OF ODD ROWS ADJUST
 10589                              <1> R4:					; EVEN_ROW
 10590                              <1> 	;xchg	si, ax			; MOVE POINTER TO (SI) AND RECOVER (AX)
 10591                              <1> 	; 02/08/2022
 10592 00002B33 96                  <1> 	xchg	esi, eax
 10593 00002B34 81C600800B00        <1> 	add	esi, 0B8000h
 10594                              <1> 	;mov	dx, cx			; COLUMN VALUE TO DX
 10595 00002B3A 0FB7D1              <1> 	movzx	edx, cx
 10596                              <1> 
 10597                              <1> ;-----	DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT
 10598                              <1> 
 10599                              <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE
 10600                              <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES )
 10601                              <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M )
 10602                              <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M )
 10603                              <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M )
 10604                              <1> 
 10605 00002B3D 66BBC002            <1> 	mov	bx, 2C0h
 10606 00002B41 66B90203            <1> 	mov	cx, 302h 		; SET PARMS FOR MED RES
 10607 00002B45 803D[9E660000]06    <1> 	cmp	byte [CRT_MODE], 6
 10608 00002B4C 7208                <1> 	jc	short R5		; HANDLE IF MED RES
 10609 00002B4E 66BB8001            <1> 	mov	bx, 180h
 10610 00002B52 66B90307            <1> 	mov	cx, 703h 		; SET PARMS FOR HIGH RES
 10611                              <1> 
 10612                              <1> ;-----	DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK
 10613                              <1> R5:
 10614 00002B56 20D5                <1> 	and	ch, dl			; ADDRESS OF PEL WITHIN BYTE TO CH
 10615                              <1> 
 10616                              <1> ;-----	DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN
 10617                              <1> 
 10618                              <1> 	;shr	dx, cl			; SHIFT BY CORRECT AMOUNT
 10619                              <1> 	;add	si, dx			; INCREMENT THE POINTER
 10620                              <1> 	; 02/08/2022
 10621 00002B58 D3EA                <1> 	shr	edx, cl
 10622 00002B5A 01D6                <1> 	add	esi, edx
 10623 00002B5C 88FE                <1> 	mov	dh, bh			; GET THE # OF BITS IN RESULT TO DH
 10624                              <1> 
 10625                              <1> ;-----	MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET)
 10626                              <1> 
 10627 00002B5E 28C9                <1> 	sub	cl, cl			; ZERO INTO STORAGE LOCATION
 10628                              <1> R6:
 10629 00002B60 D0C8                <1> 	ror	al, 1			; LEFT JUSTIFY VALUE IN AL (FOR WRITE)
 10630 00002B62 00E9                <1> 	add	cl, ch			; ADD IN THE BIT OFFSET VALUE
 10631 00002B64 FECF                <1> 	dec	bh			; LOOP CONTROL
 10632 00002B66 75F8                <1> 	jnz	short R6		; ON EXIT, CL HAS COUNT TO RESTORE BITS
 10633 00002B68 88DC                <1> 	mov	ah, bl			;  GET MASK TO AH
 10634 00002B6A D2EC                <1> 	shr	ah, cl			;  MOVE THE MASK TO CORRECT LOCATION
 10635 00002B6C C3                  <1> 	retn				;  RETURN WITH EVERYTHING SET UP
 10636                              <1> 
 10637                              <1> load_dac_palette:
 10638                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
 10639                              <1> 	; 29/07/2016
 10640                              <1> 	; 23/07/2016
 10641                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
 10642                              <1> 	; (set_mode_vga)
 10643                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 10644                              <1> 	; vgabios-0.7a (2011)
 10645                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 10646                              <1> 	; 'vgabios.c', 'load_dac_palette'
 10647                              <1> 	;
 10648                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
 10649                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
 10650                              <1> 	;
 10651                              <1> 	; INPUT -> AH = DAC selection number (3, 2 or 1)
 10652                              <1> 	; OUTPUT -> ECX = 0, AX = 0
 10653                              <1> 	; (Modifed registers: EAX, ECX, EDX, ESI)
 10654                              <1> 	;
 10655 00002B6D 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
 10656 00002B71 28C0                <1> 	sub	al, al ; 0
 10657 00002B73 EE                  <1> 	out	dx, al ; 0 ; color index, always 0 at the beginning
 10658                              <1> 	;inc	dx   ; 3C9h ; VGAREG_DAC_DATA
 10659                              <1> 	; 02/08/2022
 10660 00002B74 FEC2                <1> 	inc	dl ; dx = 3C9h
 10661                              <1> 	;mov	ecx, 256   ; always 256*3 values
 10662                              <1> 	; 02/08/2022
 10663 00002B76 31C9                <1> 	xor	ecx, ecx
 10664 00002B78 FEC5                <1> 	inc	ch	
 10665                              <1> 	; ecx = 256
 10666                              <1> 
 10667                              <1> 	;push	esi
 10668 00002B7A 88E0                <1> 	mov	al, ah
 10669 00002B7C B43F                <1> 	mov	ah, 3Fh	; 3Fh except DAC selection number 3
 10670 00002B7E 3C02                <1> 	cmp 	al, 2
 10671 00002B80 7414                <1> 	je	short l_dac_p_2
 10672 00002B82 7719                <1> 	ja	short l_dac_p_3
 10673 00002B84 20C0                <1> 	and	al, al
 10674 00002B86 7507                <1> 	jnz	short l_dac_p_1
 10675                              <1> l_dac_p_0:
 10676 00002B88 BE[D0480100]        <1> 	mov	esi, palette0
 10677 00002B8D EB15                <1> 	jmp	short l_dac_p_4	
 10678                              <1> l_dac_p_1:
 10679 00002B8F BE[90490100]        <1> 	mov	esi, palette1
 10680 00002B94 EB0E                <1> 	jmp	short l_dac_p_4
 10681                              <1> l_dac_p_2:
 10682 00002B96 BE[504A0100]        <1> 	mov	esi, palette2
 10683 00002B9B EB07                <1> 	jmp	short l_dac_p_4
 10684                              <1> l_dac_p_3:
 10685 00002B9D B4FF                <1> 	mov	ah, 0FFh ; dac registers
 10686 00002B9F BE[104B0100]        <1> 	mov	esi, palette3
 10687                              <1> l_dac_p_4:
 10688 00002BA4 AC                  <1> 	lodsb
 10689 00002BA5 EE                  <1> 	out	dx, al  ; Red
 10690 00002BA6 AC                  <1> 	lodsb
 10691 00002BA7 EE                  <1> 	out	dx, al	; Green
 10692 00002BA8 AC                  <1> 	lodsb
 10693 00002BA9 EE                  <1> 	out	dx, al	; Blue
 10694 00002BAA 20E4                <1> 	and	ah, ah
 10695 00002BAC 7405                <1> 	jz	short l_dac_p_5	
 10696 00002BAE FECC                <1> 	dec	ah
 10697 00002BB0 E2F2                <1> 	loop	l_dac_p_4
 10698                              <1> 	;pop	esi
 10699 00002BB2 C3                  <1> 	retn
 10700                              <1> l_dac_p_5:
 10701                              <1> 	; 29/07/2016
 10702 00002BB3 FEC9                <1> 	dec	cl
 10703 00002BB5 7407                <1> 	jz	short l_dac_p_7
 10704                              <1> 	;
 10705 00002BB7 28C0                <1> 	sub	al, al ; 0
 10706                              <1> l_dac_p_6:
 10707 00002BB9 EE                  <1> 	out	dx, al ; outb(VGAREG_DAC_DATA,0);
 10708 00002BBA EE                  <1> 	out	dx, al
 10709 00002BBB EE                  <1> 	out	dx, al
 10710 00002BBC E2FB                <1> 	loop	l_dac_p_6
 10711                              <1> l_dac_p_7:
 10712                              <1> 	;pop	esi
 10713 00002BBE C3                  <1> 	retn
 10714                              <1> 
 10715                              <1> gray_scale_summing:
 10716                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 10717                              <1> 	; 12/04/2021
 10718                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
 10719                              <1> 	; (set_mode_vga)
 10720                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 10721                              <1> 	; vgabios-0.7a (2011)
 10722                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 10723                              <1> 	; 'vgabios.c', 'biosfn_perform_gray_scale_summing'
 10724                              <1> 	;
 10725                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
 10726                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
 10727                              <1> 	;
 10728                              <1> 
 10729                              <1> 	; INPUT -> EBX = Start address (color index <= 255)
 10730                              <1> 	;	   ECX = Count (<= 256)
 10731                              <1> 	; OUTPUT -> (E)CX = 0
 10732                              <1> 	; (Modifed registers: EAX, ECX, EDX, EBX)
 10733                              <1> 
 10734 00002BBF 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10735 00002BC3 EC                  <1> 	in	al, dx
 10736 00002BC4 30C0                <1> 	xor	al, al ; 0
 10737                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10738                              <1> 	; 03/08/2022
 10739 00002BC6 B2C0                <1> 	mov	dl, 0C0h
 10740 00002BC8 EE                  <1> 	out	dx, al	; clear bit 5
 10741                              <1> 			; (while loading palette registers)
 10742                              <1> 	; set read address and switch to read mode
 10743                              <1> g_s_s_1:
 10744                              <1> 	;mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10745                              <1> 	; 03/08/2022
 10746 00002BC9 B2C7                <1> 	mov	dl, 0C7h
 10747 00002BCB 88D8                <1> 	mov	al, bl
 10748 00002BCD EE                  <1> 	out	dx, al
 10749                              <1> 	; get 6-bit wide RGB data values
 10750                              <1>  	; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue)
 10751                              <1> 	; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8;
 10752                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10753                              <1> 	; 03/08/2022
 10754 00002BCE B2C9                <1> 	mov	dl, 0C9h
 10755 00002BD0 EC                  <1> 	in	al, dx ; red
 10756 00002BD1 B44D                <1> 	mov	ah, 77 ; 0.3* Red
 10757 00002BD3 F6E4                <1> 	mul	ah
 10758                              <1> 	;push	ax
 10759                              <1> 	; 12/04/2021
 10760 00002BD5 50                  <1> 	push	eax
 10761 00002BD6 EC                  <1> 	in	al, dx ; green
 10762 00002BD7 B497                <1> 	mov	ah, 151  ; 0.59 * Green
 10763 00002BD9 F6E4                <1> 	mul	ah
 10764                              <1> 	;push	ax
 10765                              <1> 	; 12/04/2021
 10766 00002BDB 50                  <1> 	push	eax
 10767 00002BDC EC                  <1> 	in	al, dx ; blue
 10768 00002BDD B41C                <1> 	mov	ah, 28 ; 0.11 * Blue
 10769 00002BDF F6E4                <1> 	mul	ah
 10770                              <1> 	;pop	dx
 10771                              <1> 	; 12/04/2021
 10772 00002BE1 5A                  <1> 	pop	edx
 10773 00002BE2 6601D0              <1> 	add	ax, dx
 10774                              <1> 	;pop	dx
 10775                              <1> 	; 12/04/2021
 10776 00002BE5 5A                  <1> 	pop	edx
 10777 00002BE6 6601D0              <1> 	add	ax, dx
 10778 00002BE9 66058000            <1> 	add	ax, 80h  
 10779 00002BED B03F                <1> 	mov	al, 3Fh
 10780 00002BEF 38C4                <1> 	cmp	ah, al	; if(i>0x3f)i=0x3f
 10781 00002BF1 7602                <1> 	jna	short g_s_s_2
 10782 00002BF3 88C4                <1> 	mov	ah, al
 10783                              <1> g_s_s_2:
 10784                              <1> 	;mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
 10785                              <1> 	; 03/08/2022
 10786 00002BF5 B2C8                <1> 	mov	dl, 0C8h
 10787 00002BF7 88D8                <1> 	mov	al, bl ; color index
 10788 00002BF9 EE                  <1> 	out	dx, al
 10789 00002BFA 88E0                <1> 	mov	al, ah ; intensity
 10790                              <1> 	;inc	dx ; 3C9h ; VGAREG_DAC_DATA
 10791                              <1> 	; 03/08/2022
 10792 00002BFC FEC2                <1> 	inc	dl
 10793 00002BFE EE                  <1> 	out	dx, al ; R (R=G=B)
 10794 00002BFF 88E0                <1> 	mov	al, ah ; intensity
 10795 00002C01 EE                  <1> 	out	dx, al ; G (R=G=B)
 10796 00002C02 88E0                <1>  	mov	al, ah ; intensity
 10797 00002C04 EE                  <1> 	out	dx, al ; B (R=G=B)
 10798                              <1> 	;dec	cx
 10799                              <1> 	; 03/08/2022
 10800 00002C05 49                  <1> 	dec	ecx
 10801 00002C06 7404                <1> 	jz	short g_s_s_3
 10802 00002C08 FEC3                <1> 	inc	bl    ; next color index value
 10803 00002C0A EBBD                <1> 	jmp	short g_s_s_1
 10804                              <1> g_s_s_3:
 10805                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10806                              <1> 	; 03/08/2022
 10807 00002C0C B2DA                <1> 	mov	dl, 0DAh
 10808 00002C0E EC                  <1> 	in	al, dx
 10809 00002C0F B020                <1> 	mov	al, 20h
 10810                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10811                              <1> 	; 03/08/2022
 10812 00002C11 B2C0                <1> 	mov	dl, 0C0h 
 10813 00002C13 EE                  <1> 	out	dx, al ; 20h -> set bit 5
 10814                              <1> 		        ; (after loading palette regs)
 10815 00002C14 C3                  <1> 	retn
 10816                              <1> 
 10817                              <1> vga_write_char_attr:
 10818                              <1> vga_write_char_only: 
 10819                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
 10820                              <1> 	;
 10821                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 10822                              <1> 	; vgabios-0.7a (2011)
 10823                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 10824                              <1> 	; 'vgabios.c', 'biosfn_write_char_attr'
 10825                              <1> 	; 'biosfn_write_char_only'
 10826                              <1> 
 10827                              <1> 	; INPUT ->
 10828                              <1> 	; [CRT_MODE] = current video mode (>7)
 10829                              <1> 	; CX = Count of characters to write
 10830                              <1> 	; AL = Character to write
 10831                              <1> 	; BL = Color of character
 10832                              <1> 	; OUTPUT ->
 10833                              <1> 	; Regen buffer updated
 10834                              <1>  
 10835 00002C15 8A25[9E660000]      <1> 	mov 	ah, [CRT_MODE]
 10836 00002C1B 668B15[9E770100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
 10837                              <1> 
 10838 00002C22 BE[BA660000]        <1> 	mov	esi, vga_modes
 10839 00002C27 89F7                <1> 	mov	edi, esi
 10840 00002C29 83C710              <1> 	add	edi, vga_mode_count
 10841                              <1> vga_wca_0:
 10842 00002C2C AC                  <1> 	lodsb
 10843 00002C2D 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
 10844 00002C2F 7405                <1> 	je	short vga_wca_2
 10845 00002C31 39FE                <1> 	cmp	esi, edi
 10846 00002C33 72F7                <1> 	jb	short vga_wca_0
 10847                              <1> vga_wca_1:
 10848 00002C35 C3                  <1> 	retn	; nothing to do
 10849                              <1> vga_wca_2:
 10850 00002C36 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
 10851                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
 10852                              <1> 
 10853                              <1> 	; biosfn_write_char_attr (car,page,attr,count) 
 10854                              <1> 	; AL = car, page = 0, BL = attr, CX = count
 10855 00002C39 803E04              <1> 	cmp	byte [esi], PLANAR4
 10856 00002C3C 741D                <1> 	je	short vga_wca_planar
 10857 00002C3E 803E03              <1> 	cmp	byte [esi], PLANAR1
 10858 00002C41 7418                <1> 	je	short vga_wca_planar
 10859                              <1> vga_wca_linear8:
 10860                              <1> 	; while((count-->0) && (xcurs<nbcols))
 10861                              <1> 	; CX = count
 10862 00002C43 6621C9              <1> 	and	cx, cx
 10863 00002C46 74ED                <1> 	jz	short vga_wca_1
 10864 00002C48 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]
 10865 00002C4E 73E5                <1> 	jnb	short vga_wca_1
 10866                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
 10867                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
 10868                              <1> 	; [CRT_COLS] = nbcols
 10869 00002C50 E81E000000          <1> 	call	write_gfx_char_lin	 
 10870 00002C55 6649                <1> 	dec	cx ; count
 10871 00002C57 FEC2                <1> 	inc	dl ; xcurs
 10872 00002C59 EBE8                <1> 	jmp	short vga_wca_linear8
 10873                              <1> vga_wca_planar:
 10874                              <1> 	; while((count-->0) && (xcurs<nbcols))
 10875                              <1> 	; CX = count
 10876 00002C5B 6621C9              <1> 	and	cx, cx
 10877 00002C5E 74D5                <1> 	jz	short vga_wca_1
 10878 00002C60 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS]
 10879 00002C66 73CD                <1> 	jnb	short vga_wca_1
 10880                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
 10881                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
 10882                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
 10883 00002C68 E8A7000000          <1> 	call	write_gfx_char_pl4
 10884 00002C6D 6649                <1> 	dec	cx ; count
 10885 00002C6F FEC2                <1> 	inc	dl ; xcurs
 10886 00002C71 EBE8                <1> 	jmp	short vga_wca_planar
 10887                              <1> 
 10888                              <1> write_gfx_char_lin:
 10889                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
 10890                              <1> 	; 08/01/2021
 10891                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
 10892                              <1> 	; 08/08/2016
 10893                              <1> 	; 31/07/2016
 10894                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
 10895                              <1> 	;
 10896                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 10897                              <1> 	; vgabios-0.7a (2011)
 10898                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 10899                              <1> 	; 'vgabios.c', 'write_gfx_char_lin'
 10900                              <1> 
 10901                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols)
 10902                              <1> 	; INPUT ->
 10903                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
 10904                              <1> 	; [CRT_COLS] = nbcols
 10905                              <1> 	; OUTPUT ->
 10906                              <1> 	; Regen buffer updated
 10907                              <1> 
 10908 00002C73 51                  <1> 	push	ecx
 10909 00002C74 53                  <1> 	push	ebx
 10910 00002C75 52                  <1> 	push	edx
 10911 00002C76 50                  <1> 	push	eax
 10912                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
 10913                              <1> 	; 08/08/2016
 10914 00002C77 0FB6F0              <1> 	movzx	esi, al ; car
 10915                              <1> 	; 08/01/2021
 10916                              <1> 	;movzx	eax, dh ; ycurs
 10917                              <1> 	;mov	ah, [CRT_COLS] ; nbcols
 10918                              <1> 	;mul	ah
 10919 00002C7A A0[A0660000]        <1> 	mov	al, [CRT_COLS]
 10920 00002C7F F6E6                <1> 	mul	dh
 10921                              <1> 	;shl	ax, 6 ; * 64
 10922                              <1> 	;shl	ax, 3 ; 8 * ycurs * [CRT_COLS]
 10923                              <1> 	; 02/08/2022
 10924 00002C81 C1E003              <1> 	shl	eax, 3
 10925                              <1> 	;sub	dh, dh
 10926                              <1> 	;shl	dx, 3 ; xcurs * 8
 10927                              <1> 	;movzx	edi, dx
 10928 00002C84 BF00000A00          <1> 	mov	edi, 0A0000h
 10929 00002C89 30F6                <1> 	xor	dh, dh
 10930 00002C8B 6689D7              <1> 	mov	di, dx
 10931                              <1> 	;movzx	edi, dl
 10932 00002C8E 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
 10933                              <1> 	;xor	dh, dh
 10934 00002C92 8A15[A2660000]      <1> 	mov	dl, [CHAR_HEIGHT]
 10935 00002C98 66F7E2              <1> 	mul	dx
 10936                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
 10937                              <1> 	;add	edi, eax ; addr
 10938                              <1> 	;add	edi, 0A0000h
 10939 00002C9B 6601C7              <1> 	add	di, ax
 10940                              <1> 	;shl	si, 3 ; car * 8
 10941 00002C9E 30E4                <1> 	xor	ah, ah
 10942 00002CA0 A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT]
 10943 00002CA5 66F7E6              <1> 	mul	si
 10944 00002CA8 6689C6              <1> 	mov	si, ax
 10945                              <1> 	;; esi = src = car * 8
 10946                              <1> 	; esi = src = car * [CHAR_HEIGHT]
 10947                              <1> 	; i = 0
 10948                              <1> 	;add	esi, vgafont8 ; fdata [src+i]
 10949                              <1> 	; 08/08/2016
 10950 00002CAB A1[26840100]        <1> 	mov	eax, [VGA_INT43H]
 10951 00002CB0 09C0                <1> 	or	eax, eax ; 0 ?
 10952 00002CB2 743E                <1> 	jz	short wfxl_7 ; yes, default font
 10953                              <1> 	;cmp	eax, vgafont16
 10954                              <1>         ;je	short wgfxl_0
 10955                              <1> 	;cmp	eax, vgafont14
 10956                              <1> 	;je	short wgfxl_0
 10957                              <1> 	;cmp	eax, vgafont8
 10958                              <1> 	;je	short wgfxl_0
 10959                              <1> 	;; 05/01/2021 (TRDOS 386 v2.0.3)
 10960                              <1> 	;; user font  
 10961                              <1> 	;mov	eax, VGAFONTUSR ; 8x16 or 8x8 or 8x14 font
 10962                              <1> 	;			; (256 characters)
 10963                              <1> wgfxl_0:
 10964 00002CB4 01C6                <1> 	add	esi, eax
 10965                              <1> wgfxl_1:
 10966 00002CB6 28FF                <1> 	sub	bh, bh ; i = 0
 10967                              <1> wgfxl_2:
 10968                              <1> 	; for(i=0;i<8;i++)
 10969 00002CB8 57                  <1> 	push	edi ; addr
 10970 00002CB9 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
 10971 00002CC0 F6E7                <1> 	mul	bh ; nbcols*i
 10972                              <1> 	;shl	ax, 3 ; i*nbcols*8
 10973                              <1>  	; 02/08/2022
 10974 00002CC2 C1E003              <1> 	shl	eax, 3
 10975                              <1> 	; dest=addr+i*nbcols*8;
 10976 00002CC5 01C7                <1> 	add	edi, eax ; dest + j ; j = 0
 10977 00002CC7 B180                <1> 	mov	cl, 80h ; mask = 0x80;
 10978                              <1> 	; esi = fdata + src + i
 10979                              <1> 	; for(j=0;j<8;j++)
 10980 00002CC9 29D2                <1> 	sub	edx, edx ; j = 0
 10981                              <1> wgfxl_3:
 10982 00002CCB 8A06                <1> 	mov	al, [esi] ; al = fdata[src+i]
 10983 00002CCD 20C8                <1> 	and	al, cl ; if (fdata[src+i] & mask)
 10984 00002CCF 7402                <1> 	jz	short wgfxl_4  ; data = 0, zf = 1
 10985 00002CD1 88D8                <1> 	mov	al, bl ; data = attr;
 10986                              <1> wgfxl_4:
 10987                              <1> 	; write_byte(0xa000,dest+j,data);		
 10988 00002CD3 AA                  <1> 	stosb  ; dest + j (+ 0A0000h)
 10989                              <1> 	;inc	dl ; j++
 10990                              <1> 	;cmp	dl, 8
 10991 00002CD4 80FA07              <1> 	cmp	dl, 7
 10992 00002CD7 720E                <1> 	jb	short wgfxl_5
 10993 00002CD9 5F                  <1> 	pop	edi
 10994                              <1> 	; 08/08/2016
 10995                              <1> 	;cmp	bh, 7
 10996                              <1> 	;jnb	short wgfxl_6
 10997 00002CDA FEC7                <1> 	inc	bh ; i++
 10998 00002CDC 3A3D[A2660000]      <1> 	cmp	bh, [CHAR_HEIGHT]
 10999 00002CE2 7309                <1> 	jnb	short wgfxl_6
 11000 00002CE4 46                  <1> 	inc	esi
 11001 00002CE5 EBD1                <1> 	jmp	short wgfxl_2
 11002                              <1> wgfxl_5:
 11003 00002CE7 D0E9                <1> 	shr	cl, 1 ; mask >>= 1;
 11004 00002CE9 FEC2                <1> 	inc	dl ; j++
 11005 00002CEB EBDE                <1>         jmp     short wgfxl_3
 11006                              <1> wgfxl_6:
 11007 00002CED 58                  <1> 	pop	eax
 11008 00002CEE 5A                  <1> 	pop	edx
 11009 00002CEF 5B                  <1> 	pop	ebx
 11010 00002CF0 59                  <1> 	pop	ecx
 11011 00002CF1 C3                  <1> 	retn
 11012                              <1> wfxl_7:
 11013                              <1> 	; 08/01/2021
 11014                              <1> 	; 05/01/2021
 11015                              <1> 	; Default font (8x8 or 8x14 or 8x16)
 11016 00002CF2 A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT]
 11017 00002CF7 3C08                <1> 	cmp	al, 8
 11018 00002CF9 7507                <1> 	jne	short wfxl_8
 11019 00002CFB B8[104E0100]        <1> 	mov	eax, vgafont8
 11020 00002D00 EBB2                <1> 	jmp	short wgfxl_0
 11021                              <1> wfxl_8:
 11022 00002D02 3C0E                <1> 	cmp	al, 14
 11023 00002D04 7507                <1> 	jne	short wfxl_9
 11024 00002D06 B8[10560100]        <1> 	mov	eax, vgafont14
 11025 00002D0B EBA7                <1> 	jmp	short wgfxl_0
 11026                              <1> wfxl_9:
 11027 00002D0D B8[10640100]        <1> 	mov	eax, vgafont16
 11028 00002D12 EBA0                <1> 	jmp	short wgfxl_0
 11029                              <1> 
 11030                              <1> write_gfx_char_pl4:
 11031                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
 11032                              <1> 	; 08/08/2016
 11033                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
 11034                              <1> 	;
 11035                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11036                              <1> 	; vgabios-0.7a (2011)
 11037                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11038                              <1> 	; 'vgabios.c', 'write_gfx_char_pl4'
 11039                              <1> 
 11040                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight)
 11041                              <1> 	; INPUT ->
 11042                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
 11043                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
 11044                              <1> 	; OUTPUT ->
 11045                              <1> 	; Regen buffer updated
 11046                              <1> 
 11047 00002D14 51                  <1> 	push	ecx
 11048 00002D15 53                  <1> 	push	ebx
 11049 00002D16 52                  <1> 	push	edx
 11050 00002D17 50                  <1> 	push	eax
 11051                              <1> wgfxpl_f0:
 11052                              <1> 	; switch(cheight)
 11053 00002D18 8A25[A2660000]      <1> 	mov	ah, [CHAR_HEIGHT]
 11054 00002D1E 80FC10              <1> 	cmp	ah, 16 ; case 16:
 11055 00002D21 7507                <1> 	jne	short wgfxpl_f1
 11056                              <1> 	; fdata = &vgafont16;
 11057 00002D23 BE[10640100]        <1> 	mov	esi, vgafont16
 11058 00002D28 EB13                <1> 	jmp	short wgfxpl_f3
 11059                              <1> wgfxpl_f1:
 11060 00002D2A 80FC0E              <1> 	cmp	ah, 14 ; case 14:
 11061 00002D2D 7507                <1> 	jne	short wgfxpl_f2
 11062 00002D2F BE[10560100]        <1> 	mov	esi, vgafont14
 11063 00002D34 EB07                <1> 	jmp	short wgfxpl_f3
 11064                              <1> wgfxpl_f2:
 11065                              <1> 	; default:
 11066                              <1> 	;  fdata = &vgafont8;
 11067 00002D36 BE[104E0100]        <1> 	mov	esi, vgafont8
 11068 00002D3B B408                <1> 	mov	ah, 8	
 11069                              <1> wgfxpl_f3:
 11070                              <1> 	; al = car
 11071 00002D3D F6E4                <1> 	mul	ah ; ah = cheight
 11072 00002D3F 25FFFF0000          <1> 	and	eax, 0FFFFh ; car * cheight
 11073                              <1> 	; src = car * cheight;
 11074 00002D44 01C6                <1> 	add	esi, eax ; esi = fdata[src+i]
 11075                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
 11076 00002D46 88F0                <1> 	mov	al, dh ; ycurs
 11077 00002D48 8A25[A0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
 11078 00002D4E F6E4                <1> 	mul	ah
 11079                              <1> 	; 08/08/2016
 11080                              <1> 	;shl	ax, 6 ; * 64
 11081                              <1> 	;shl	ax, 3 ; * 8
 11082                              <1> 	; 02/08/2022
 11083 00002D50 C1E003              <1> 	shl	eax, 3
 11084                              <1> 	;sub	dh, dh ; 0
 11085                              <1> 	;shl	dx, 3 ; xcurs * 8
 11086                              <1> 	;movzx	edi, dx
 11087 00002D53 0FB6FA              <1> 	movzx	edi, dl
 11088                              <1> 	;shl	di, 3 ; xcurs * 8
 11089                              <1> 	; 02/08/2022
 11090 00002D56 C1E703              <1> 	shl	edi, 3
 11091 00002D59 30F6                <1> 	xor	dh, dh
 11092 00002D5B 8A15[A2660000]      <1> 	mov	dl, [CHAR_HEIGHT]
 11093 00002D61 66F7E2              <1> 	mul	dx
 11094                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
 11095 00002D64 01C7                <1> 	add	edi, eax ; addr
 11096 00002D66 81C700000A00        <1> 	add	edi, 0A0000h
 11097                              <1> 	;
 11098                              <1> 	; outw(VGAREG_SEQU_ADDRESS, 0x0f02);
 11099                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
 11100 00002D6C 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 11101 00002D70 66B8020F            <1> 	mov	ax, 0F02h
 11102 00002D74 66EF                <1> 	out	dx, ax
 11103 00002D76 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11104 00002D7A 66B80502            <1> 	mov	ax, 0205h
 11105 00002D7E 66EF                <1> 	out	dx, ax
 11106                              <1> 	;
 11107 00002D80 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11108 00002D84 F6C380              <1> 	test	bl, 80h ; if(attr&0x80)
 11109 00002D87 7406                <1> 	jz	short wgfxpl_f4 ; else
 11110                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x1803);
 11111 00002D89 66B80318            <1> 	mov	ax, 1803h
 11112 00002D8D EB04                <1> 	jmp	short wgfxpl_f5
 11113                              <1> wgfxpl_f4:
 11114                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0003);
 11115 00002D8F 66B80300            <1> 	mov	ax, 0003h	
 11116                              <1> wgfxpl_f5:
 11117 00002D93 66EF                <1> 	out	dx, ax
 11118                              <1> 	;	
 11119 00002D95 28FF                <1> 	sub	bh, bh ; i = 0
 11120                              <1> wgfxpl_0:
 11121                              <1> 	; for(i=0;i<cheight;i++)
 11122 00002D97 57                  <1> 	push	edi ; addr
 11123 00002D98 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
 11124 00002D9F F6E7                <1> 	mul	bh ; nbcols*i
 11125                              <1> 	; dest=addr+i*nbcols
 11126 00002DA1 01C7                <1> 	add	edi, eax ; dest
 11127 00002DA3 B580                <1> 	mov	ch, 80h ; mask = 0x80;
 11128                              <1> 	; for(j=0;j<8;j++)
 11129 00002DA5 28C9                <1> 	sub	cl, cl ; j = 0
 11130                              <1> wgfxpl_1:
 11131 00002DA7 D2ED                <1> 	shr	ch, cl ; mask=0x80>>j;
 11132                              <1> 	;
 11133                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
 11134                              <1>      	; read_byte(0xa000,dest);
 11135                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11136 00002DA9 88EC                <1> 	mov	ah, ch
 11137 00002DAB B008                <1> 	mov	al, 8
 11138 00002DAD 66EF                <1> 	out	dx, ax
 11139 00002DAF 8A07                <1> 	mov	al, [edi] ; ? (io delay?)
 11140                              <1> 	;
 11141 00002DB1 28C0                <1> 	sub	al, al ; attr = 0
 11142                              <1> 	; if (fdata[src+i] & mask)
 11143 00002DB3 842E                <1> 	test	byte [esi], ch
 11144 00002DB5 7404                <1> 	jz	short wgfxpl_2  ; zf = 1
 11145                              <1> 	; write_byte(0xa000,dest,attr&0x0f);
 11146 00002DB7 88D8                <1> 	mov	al, bl ; attr;
 11147 00002DB9 240F                <1> 	and	al, 0Fh	; attr&0x0f
 11148                              <1> wgfxpl_2:
 11149                              <1> 	; write_byte(0xa000,dest,0x00);		
 11150 00002DBB 8807                <1> 	mov	[edi], al ; dest (+ 0A0000h)
 11151 00002DBD FEC1                <1> 	inc	cl ; j++
 11152 00002DBF 80F908              <1> 	cmp	cl, 8
 11153 00002DC2 72E3                <1> 	jb	short wgfxpl_1
 11154 00002DC4 5F                  <1> 	pop	edi
 11155                              <1> 	; 08/08/2016
 11156                              <1> 	;cmp	bh, 7
 11157                              <1> 	;jnb	short wgfxpl_3
 11158 00002DC5 FEC7                <1> 	inc	bh ; i++
 11159 00002DC7 3A3D[A2660000]      <1> 	cmp	bh, [CHAR_HEIGHT]
 11160 00002DCD 7303                <1> 	jnb	short wgfxpl_3
 11161 00002DCF 46                  <1> 	inc	esi
 11162 00002DD0 EBC5                <1> 	jmp	short wgfxpl_0
 11163                              <1> wgfxpl_3:
 11164                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11165 00002DD2 66B808FF            <1>   	mov	ax, 0FF08h
 11166 00002DD6 66EF                <1> 	out	dx, ax
 11167 00002DD8 66B80500            <1> 	mov	ax, 0005h
 11168 00002DDC 66EF                <1> 	out	dx, ax
 11169 00002DDE 66B80300            <1> 	mov	ax, 0003h
 11170 00002DE2 66EF                <1> 	out	dx, ax
 11171                              <1> 	;
 11172 00002DE4 58                  <1> 	pop	eax
 11173 00002DE5 5A                  <1> 	pop	edx
 11174 00002DE6 5B                  <1> 	pop	ebx
 11175 00002DE7 59                  <1> 	pop	ecx
 11176 00002DE8 C3                  <1> 	retn
 11177                              <1> 
 11178                              <1> vga_write_pixel:
 11179                              <1> 	; 02/08/2022 (TRDOS 386 Kerbel v2.0.5)
 11180                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
 11181                              <1> 	;
 11182                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11183                              <1> 	; vgabios-0.7a (2011)
 11184                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11185                              <1> 	; 'vgabios.c', 'biosfn_write_pixel'
 11186                              <1> 
 11187                              <1> 	; INPUT ->
 11188                              <1> 	; 	DX = row (0-239)
 11189                              <1> 	; 	CX = column (0-799)
 11190                              <1> 	; 	AL = pixel value
 11191                              <1> 	;	(AH = [CRT_MODE])
 11192                              <1> 	; OUTPUT ->
 11193                              <1> 	; 	none
 11194                              <1>  
 11195 00002DE9 88C3                <1> 	mov	bl, al ; pixel value
 11196                              <1> 	;mov 	ah, [CRT_MODE]
 11197 00002DEB BE[BA660000]        <1> 	mov	esi, vga_modes
 11198 00002DF0 89F7                <1> 	mov	edi, esi
 11199 00002DF2 83C710              <1> 	add	edi, vga_mode_count
 11200                              <1> vga_wp_0:
 11201 00002DF5 AC                  <1> 	lodsb
 11202 00002DF6 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
 11203 00002DF8 7405                <1> 	je	short vga_wp_1
 11204 00002DFA 39FE                <1> 	cmp	esi, edi
 11205 00002DFC 72F7                <1> 	jb	short vga_wp_0
 11206 00002DFE C3                  <1> 	retn	; nothing to do
 11207                              <1> vga_wp_1:
 11208 00002DFF 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
 11209                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
 11210 00002E02 BF00000A00          <1> 	mov	edi, 0A0000h
 11211                              <1> 	;
 11212 00002E07 803E04              <1> 	cmp	byte [esi], PLANAR4
 11213 00002E0A 741C                <1> 	je	short vga_wp_planar
 11214 00002E0C 803E03              <1> 	cmp	byte [esi], PLANAR1
 11215 00002E0F 7417                <1> 	je	short vga_wp_planar
 11216                              <1> vga_wp_linear8:
 11217                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
 11218 00002E11 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
 11219                              <1>      	;shl	ax, 3 ; * 8
 11220                              <1> 	; 02/08/2022
 11221 00002E18 C1E003              <1> 	shl	eax, 3
 11222 00002E1B 66F7E2              <1> 	mul	dx
 11223 00002E1E 50                  <1> 	push	eax
 11224                              <1> 	;mov	edi, 0A0000h
 11225 00002E1F 6601CF              <1> 	add	di, cx
 11226 00002E22 58                  <1> 	pop	eax
 11227 00002E23 01C7                <1> 	add	edi, eax ; addr
 11228                              <1> 	; write_byte(0xa000,addr,AL);
 11229 00002E25 881F                <1> 	mov	[edi], bl
 11230 00002E27 C3                  <1> 	retn    
 11231                              <1> vga_wp_planar:
 11232                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
 11233 00002E28 0FB7C1              <1> 	movzx	eax, cx
 11234 00002E2B 66C1E803            <1> 	shr	ax, 3 ; CX/8
 11235 00002E2F 50                  <1> 	push	eax
 11236 00002E30 28E4                <1> 	sub	ah, ah ; 0
 11237 00002E32 A0[A0660000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
 11238 00002E37 66F7E2              <1> 	mul	dx
 11239                              <1> 	;mov	edi, 0A0000h
 11240 00002E3A 6601C7              <1>         add     di, ax
 11241 00002E3D 58                  <1> 	pop	eax
 11242 00002E3E 01C7                <1> 	add	edi, eax ; addr
 11243 00002E40 80E107              <1> 	and	cl, 7
 11244 00002E43 B580                <1> 	mov	ch, 80h ; mask
 11245 00002E45 D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
 11246                              <1> 	
 11247                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
 11248 00002E47 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11249 00002E4B 88EC                <1> 	mov	ah, ch
 11250 00002E4D B008                <1> 	mov	al, 8
 11251 00002E4F 66EF                <1> 	out	dx, ax
 11252                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
 11253 00002E51 66B80502            <1> 	mov	ax, 0205h
 11254 00002E55 66EF                <1> 	out	dx, ax
 11255                              <1> 	; data = read_byte(0xa000,addr);
 11256 00002E57 8A07                <1> 	mov	al, [edi] ; (delay?)	
 11257                              <1> 	; if (AL & 0x80)
 11258                              <1> 	; {
 11259                              <1> 	;  outw(VGAREG_GRDC_ADDRESS, 0x1803);
 11260                              <1> 	; }
 11261 00002E59 F6C380              <1> 	test	bl, 80h
 11262 00002E5C 7406                <1> 	jz	short vga_wp_2
 11263 00002E5E 66B80318            <1> 	mov	ax, 1803h
 11264 00002E62 66EF                <1> 	out	dx, ax
 11265                              <1> vga_wp_2:	
 11266                              <1> 	; write_byte(0xa000,addr,AL);
 11267 00002E64 881F                <1> 	mov	[edi], bl
 11268                              <1> 	;
 11269                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11270 00002E66 66B808FF            <1>   	mov	ax, 0FF08h
 11271 00002E6A 66EF                <1> 	out	dx, ax
 11272 00002E6C 66B80500            <1> 	mov	ax, 0005h
 11273 00002E70 66EF                <1> 	out	dx, ax
 11274 00002E72 66B80300            <1> 	mov	ax, 0003h
 11275 00002E76 66EF                <1> 	out	dx, ax
 11276                              <1> 	;
 11277 00002E78 C3                  <1> 	retn
 11278                              <1> 
 11279                              <1> vga_read_pixel: 
 11280                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
 11281                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
 11282                              <1> 	;
 11283                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11284                              <1> 	; vgabios-0.7a (2011)
 11285                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11286                              <1> 	; 'vgabios.c', 'biosfn_read_pixel'
 11287                              <1> 
 11288                              <1> 	; INPUT ->
 11289                              <1> 	; 	DX = row (0-239)
 11290                              <1> 	; 	CX = column (0-799)
 11291                              <1> 	;	(AH = [CRT_MODE])
 11292                              <1> 	; OUTPUT ->
 11293                              <1> 	; 	AL = pixel value
 11294                              <1> 	 
 11295                              <1> 	;mov 	ah, [CRT_MODE]
 11296 00002E79 BE[BA660000]        <1> 	mov	esi, vga_modes
 11297 00002E7E 89F7                <1> 	mov	edi, esi
 11298 00002E80 83C710              <1> 	add	edi, vga_mode_count
 11299                              <1> vga_rp_0:
 11300 00002E83 AC                  <1> 	lodsb
 11301 00002E84 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
 11302 00002E86 7405                <1> 	je	short vga_rp_1
 11303 00002E88 39FE                <1> 	cmp	esi, edi
 11304 00002E8A 72F7                <1> 	jb	short vga_rp_0
 11305 00002E8C C3                  <1> 	retn	; nothing to do
 11306                              <1> vga_rp_1:
 11307 00002E8D 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
 11308                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
 11309 00002E90 BF00000A00          <1> 	mov	edi, 0A0000h
 11310                              <1> 	;
 11311 00002E95 803E04              <1> 	cmp	byte [esi], PLANAR4
 11312 00002E98 741C                <1> 	je	short vga_rp_planar
 11313 00002E9A 803E03              <1> 	cmp	byte [esi], PLANAR1
 11314 00002E9D 7417                <1> 	je	short vga_rp_planar
 11315                              <1> vga_rp_linear8:
 11316                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
 11317 00002E9F 0FB605[A0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
 11318                              <1>      	;shl	ax, 3 ; * 8
 11319                              <1> 	; 02/08/2022
 11320 00002EA6 C1E003              <1> 	shl	eax, 3
 11321 00002EA9 66F7E2              <1> 	mul	dx
 11322 00002EAC 50                  <1> 	push	eax
 11323                              <1> 	;mov	edi, 0A0000h
 11324 00002EAD 6601CF              <1> 	add	di, cx
 11325 00002EB0 58                  <1> 	pop	eax
 11326 00002EB1 01C7                <1> 	add	edi, eax ; addr
 11327                              <1> 	; attr=read_byte(0xa000,addr);
 11328 00002EB3 8A07                <1> 	mov	al, [edi] ; pixel value
 11329 00002EB5 C3                  <1> 	retn    
 11330                              <1> vga_rp_planar:
 11331                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
 11332 00002EB6 0FB7C1              <1> 	movzx	eax, cx
 11333 00002EB9 66C1E803            <1> 	shr	ax, 3 ; CX/8
 11334 00002EBD 50                  <1> 	push	eax
 11335 00002EBE 28E4                <1> 	sub	ah, ah ; 0
 11336 00002EC0 A0[A0660000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
 11337 00002EC5 66F7E2              <1> 	mul	dx
 11338                              <1> 	;mov	edi, 0A0000h
 11339 00002EC8 6601C7              <1>         add     di, ax
 11340 00002ECB 58                  <1> 	pop	eax
 11341 00002ECC 01C7                <1> 	add	edi, eax ; addr
 11342 00002ECE 80E107              <1> 	and	cl, 7
 11343 00002ED1 B580                <1> 	mov	ch, 80h ; mask
 11344 00002ED3 D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
 11345                              <1> 	; attr = 0x00;
 11346 00002ED5 30DB                <1> 	xor	bl, bl ; attr = bl = 0, 
 11347 00002ED7 30C9                <1> 	xor	cl, cl ; i = cl = 0
 11348                              <1> 	; for(i=0;i<4;i++)
 11349                              <1>       	; {
 11350                              <1>        	;  outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04);
 11351                              <1>        	;  data = read_byte(0xa000,addr) & mask;
 11352                              <1>        	;  if (data > 0) attr |= (0x01 << i);
 11353                              <1>       	; }
 11354                              <1> vga_rp_2:
 11355 00002ED9 88CC                <1> 	mov	ah, cl ; i << 8
 11356 00002EDB B004                <1> 	mov	al, 4  ; | 0x04
 11357 00002EDD 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11358 00002EE1 66EF                <1> 	out	dx, ax
 11359                              <1> 	; data = read_byte(0xa000,addr) & mask;
 11360 00002EE3 8A07                <1> 	mov	al, [edi]
 11361 00002EE5 20E8                <1> 	and	al, ch ; & mask
 11362                              <1> 	; if (data > 0) attr |= (0x01 << i);
 11363 00002EE7 08C0                <1> 	or	al, al
 11364 00002EE9 7408                <1> 	jz	short vga_rp_3 ; al = 0 
 11365 00002EEB B701                <1> 	mov	bh, 1
 11366 00002EED D2E7                <1> 	shl	bh, cl ; (0x01 << i)
 11367 00002EEF 08FB                <1> 	or	bl, bh ; attr |= (0x01 << i)
 11368 00002EF1 88D8                <1> 	mov	al, bl ; pixel value	
 11369                              <1> vga_rp_3:	
 11370 00002EF3 C3                  <1> 	retn
 11371                              <1> 
 11372                              <1> vga_beeper:
 11373                              <1> 	; 04/08/2016  (TRDOS 386 = TRDOS v2.0)
 11374 00002EF4 FB                  <1> 	sti
 11375                              <1> 	;mov	bh, [ACTIVE_PAGE]
 11376 00002EF5 E917F4FFFF          <1>         jmp     beeper_gfx
 11377                              <1> 
 11378                              <1> vga_write_teletype:
 11379                              <1> 	; 03/08/2022 (TRDOS 386 Kernel v2.0.5)
 11380                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
 11381                              <1> 	; 09/12/2017
 11382                              <1> 	; 06/08/2016
 11383                              <1> 	; 04/08/2016
 11384                              <1> 	; 01/08/2016
 11385                              <1> 	; 31/07/2016
 11386                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
 11387                              <1> 	;
 11388                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11389                              <1> 	; vgabios-0.7a (2011)
 11390                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11391                              <1> 	; 'vgabios.c', 'biosfn_write_teletype'
 11392                              <1> 	; 'biosfn_write_char_only'
 11393                              <1> 
 11394                              <1> 	; INPUT ->
 11395                              <1> 	; [CRT_MODE] = current video mode (>7)
 11396                              <1> 	; AL = Character to write
 11397                              <1> 	; BL = Color of character
 11398                              <1> 	; OUTPUT ->
 11399                              <1> 	; Regen buffer updated
 11400                              <1> 
 11401                              <1> 	; biosfn_write_teletype (car, page, attr, flag) 
 11402                              <1> 	; car = character (AL)
 11403                              <1> 	; page = 0
 11404                              <1> 	; attr = color (BL)
 11405                              <1> 	; 'flag' not used
 11406                              <1> 
 11407 00002EFA 8A25[9E660000]      <1> 	mov 	ah, [CRT_MODE]
 11408 00002F00 88C7                <1> 	mov	bh, al ; character
 11409 00002F02 668B15[9E770100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
 11410                              <1> 
 11411 00002F09 BE[C2660000]        <1> 	mov	esi, vga_g_modes
 11412 00002F0E 89F7                <1> 	mov	edi, esi
 11413 00002F10 83C708              <1> 	add	edi, vga_g_mode_count
 11414                              <1> vga_wtty_0:
 11415 00002F13 AC                  <1> 	lodsb
 11416 00002F14 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
 11417 00002F16 7405                <1> 	je	short vga_wtty_2
 11418 00002F18 39FE                <1> 	cmp	esi, edi
 11419 00002F1A 72F7                <1> 	jb	short vga_wtty_0
 11420                              <1> vga_wtty_1:
 11421 00002F1C C3                  <1> 	retn	; nothing to do
 11422                              <1> vga_wtty_2:
 11423 00002F1D 80FF07              <1> 	cmp	bh, 07h ; bell (beep)
 11424 00002F20 74D2                <1> 	je	short vga_beeper  ; u11
 11425 00002F22 80FF08              <1> 	cmp	bh, 08h ; backspace
 11426 00002F25 7508                <1> 	jne	short vga_wtty_3
 11427                              <1> 	; if(xcurs>0)xcurs--;
 11428 00002F27 08D2                <1> 	or	dl, dl ; xcurs (column)
 11429 00002F29 74F1                <1> 	jz	short vga_wtty_1
 11430 00002F2B FECA                <1> 	dec	dl ; xcurs--;
 11431 00002F2D EB55                <1>         jmp     short vga_wtty_12 
 11432                              <1> vga_wtty_3:			
 11433 00002F2F 80FF0D              <1> 	cmp	bh, 0Dh ; carriage return (\r)
 11434 00002F32 7504                <1> 	jne	short vga_wtty_4
 11435                              <1> 	; xcurs=0;
 11436 00002F34 28D2                <1> 	sub	dl, dl ; 0
 11437 00002F36 EB4C                <1>         jmp     short vga_wtty_12 
 11438                              <1> vga_wtty_4:	
 11439 00002F38 80FF0A              <1> 	cmp	bh, 0Ah ; new line (\n)
 11440 00002F3B 7504                <1> 	jne	short vga_wtty_5
 11441                              <1> 	; ycurs++;
 11442 00002F3D FEC6                <1> 	inc	dh ; next row
 11443 00002F3F EB5E                <1>         jmp     short vga_wtty_11
 11444                              <1> vga_wtty_5:
 11445 00002F41 80FF09              <1> 	cmp 	bh, 09h ; tab stop
 11446 00002F44 7523                <1> 	jne	short vga_wtty_8
 11447 00002F46 88D0                <1> 	mov	al, dl
 11448                              <1> 	;cbw
 11449 00002F48 30E4                <1> 	xor	ah, ah ; 09/12/2017
 11450 00002F4A B108                <1> 	mov	cl, 8
 11451 00002F4C F6F1                <1> 	div	cl
 11452 00002F4E 28E1                <1> 	sub	cl, ah
 11453                              <1> 	;
 11454 00002F50 B720                <1> 	mov	bh, 20h ; space
 11455                              <1> vga_wtty_6: ; tab stop loop
 11456                              <1> 	;push	cx
 11457                              <1> 	;push	bx
 11458                              <1> 	; 12/04/2021
 11459 00002F52 51                  <1> 	push	ecx
 11460 00002F53 53                  <1> 	push	ebx
 11461 00002F54 E810000000          <1> 	call	vga_wtty_8
 11462                              <1> 	;pop	bx  ; bh = character, bl = color
 11463                              <1> 	;pop	cx
 11464                              <1> 	; 12/04/2021
 11465 00002F59 5B                  <1> 	pop	ebx  ; bh = character, bl = color
 11466 00002F5A 59                  <1> 	pop	ecx
 11467 00002F5B FEC9                <1> 	dec	cl
 11468 00002F5D 7409                <1> 	jz	short vga_wtty_7
 11469 00002F5F 668B15[9E770100]    <1> 	mov	dx, [CURSOR_POSN] ; new cursor position (pg 0)
 11470 00002F66 EBEA                <1> 	jmp	short vga_wtty_6
 11471                              <1> vga_wtty_7:
 11472 00002F68 C3                  <1> 	retn
 11473                              <1> 	;
 11474                              <1> vga_wtty_8:
 11475 00002F69 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
 11476                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
 11477 00002F6C BF00000A00          <1> 	mov	edi, 0A0000h
 11478                              <1> 	;
 11479 00002F71 88F8                <1> 	mov	al, bh ; character
 11480                              <1> 	;
 11481 00002F73 803E04              <1> 	cmp	byte [esi], PLANAR4
 11482 00002F76 7414                <1> 	je	short vga_wtty_planar
 11483 00002F78 803E03              <1> 	cmp	byte [esi], PLANAR1
 11484 00002F7B 740F                <1> 	je	short vga_wtty_planar
 11485                              <1> vga_wtty_linear8:
 11486                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
 11487                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
 11488                              <1> 	; [CRT_COLS] = nbcols
 11489 00002F7D E8F1FCFFFF          <1> 	call	write_gfx_char_lin
 11490 00002F82 EB0D                <1> 	jmp	short vga_wtty_9
 11491                              <1> 
 11492                              <1> vga_wtty_12:
 11493                              <1> 	; 09/07/2016
 11494                              <1> 	; set cursor position
 11495                              <1> 	; NOTE: Hardware cursor position will not be set
 11496                              <1> 	;   in any VGA modes (>7)
 11497                              <1> 	;   But, cursor position will be saved into
 11498                              <1> 	;   [CURSOR_POSN].
 11499                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
 11500                              <1> 	;   (page 0) for all graphics modes.
 11501                              <1> 
 11502 00002F84 668915[9E770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
 11503                              <1> 	; 04/08/2016
 11504                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
 11505                              <1> 	;call	_set_cpos
 11506 00002F8B C3                  <1> 	retn
 11507                              <1> 
 11508                              <1> vga_wtty_planar:
 11509                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
 11510                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
 11511                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
 11512 00002F8C E883FDFFFF          <1> 	call	write_gfx_char_pl4
 11513                              <1> vga_wtty_9:
 11514 00002F91 FEC2                <1> 	inc	dl ; xcurs++;
 11515                              <1> vga_wtty_10:
 11516                              <1> 	; Do we need to wrap ?
 11517                              <1> 	; if(xcurs==nbcols)
 11518 00002F93 3A15[A0660000]      <1> 	cmp	dl, [CRT_COLS] ; [VGA_COLS]
 11519 00002F99 7204                <1> 	jb	short vga_wtty_11 ; no
 11520 00002F9B 28D2                <1> 	sub	dl, dl ; xcurs=0;
 11521 00002F9D FEC6                <1> 	inc	dh ;  ycurs++;
 11522                              <1> vga_wtty_11:
 11523                              <1> 	; Do we need to scroll ?
 11524                              <1> 	; if(ycurs==nbrows)
 11525 00002F9F 3A35[A6660000]      <1> 	cmp	dh, [VGA_ROWS]
 11526 00002FA5 72DD                <1> 	jb	short vga_wtty_12 ; no
 11527                              <1> 	;
 11528                              <1> 	; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir)
 11529                              <1> 	; al = nblines = 1, bl = attr (color) = 0
 11530                              <1> 	; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0
 11531                              <1> 	; dir = SCROLL_UP
 11532                              <1> 	
 11533 00002FA7 B001                <1> 	mov	al, 1
 11534 00002FA9 28DB                <1> 	sub	bl, bl ; 0 ; blank/black line (attr=0) will be used
 11535                              <1> 	;sub	cx, cx ; 0,0
 11536                              <1> 	; 03/08/2022
 11537 00002FAB 29C9                <1> 	sub	ecx, ecx
 11538                              <1> 
 11539                              <1> 	; 06/08/2016
 11540 00002FAD 8A35[A6660000]      <1> 	mov	dh, [VGA_ROWS]
 11541 00002FB3 FECE                <1> 	dec	dh ; nbrows -1
 11542                              <1> 
 11543                              <1> 	;push	dx ; 04/08/2016
 11544                              <1> 	; 12/04/2021
 11545 00002FB5 52                  <1> 	push	edx
 11546 00002FB6 8A15[A0660000]      <1> 	mov	dl, [CRT_COLS]
 11547 00002FBC FECA                <1> 	dec	dl ; nbcols -1
 11548                              <1> 	
 11549 00002FBE 8A25[9E660000]      <1> 	mov	ah, [CRT_MODE]
 11550                              <1> 	
 11551                              <1> 	; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP);
 11552 00002FC4 E843F5FFFF          <1> 	call	vga_graphics_up
 11553                              <1> 	; 04/08/2016
 11554                              <1> 	;pop	dx
 11555                              <1> 	; 12/04/2021
 11556 00002FC9 5A                  <1> 	pop	edx
 11557                              <1> 
 11558                              <1> 	;dec	dh ; ycurs-=1
 11559 00002FCA EBB8                <1> 	jmp	short vga_wtty_12 
 11560                              <1> 
 11561                              <1> font_setup:
 11562                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 11563                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
 11564                              <1> 	; 09/07/2016
 11565                              <1> 	; character generator (font loading) functions
 11566                              <1> 	;
 11567                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11568                              <1> 	; vgabios-0.7a (2011)
 11569                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11570                              <1> 	; 'vgabios.c', 'int10_func'
 11571                              <1> 
 11572                              <1> 	; AX = 1100H ; Load User-Defined Font (EGA/VGA)
 11573                              <1> 	;
 11574                              <1>         ; BH =  height of each character (bytes per character definition)
 11575                              <1>         ; (BL = font block to load (EGA: 0-3; VGA: 0-7))
 11576                              <1> 	; CX =  number of characters to redefine (<=256)
 11577                              <1>         ; DX =  ASCII code of the first character defined at ES:BP
 11578                              <1>         ; EBP =	address of font-definition information
 11579                              <1> 	;	(in user's memory space)
 11580                              <1> 
 11581                              <1> 	; case 0x11:
 11582                              <1>      	; switch(GET_AL())
 11583                              <1>       	; {
 11584                              <1> 	; case 0x00:
 11585                              <1>         ; case 0x10:
 11586                              <1>         ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH());
 11587                              <1>         ; break;
 11588                              <1> 
 11589                              <1> 	; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA)
 11590 00002FCC 08C0                <1> 	or	al, al ; 0
 11591 00002FCE 7404                <1> 	jz	short font_setup_0
 11592 00002FD0 3C10                <1> 	cmp	al, 10h
 11593 00002FD2 7511                <1> 	jne	short font_setup_1	
 11594                              <1> font_setup_0:
 11595 00002FD4 E8CE000000          <1> 	call	transfer_user_fonts
 11596 00002FD9 721C                <1> 	jc	short font_setup_error
 11597 00002FDB E8AD010000          <1> 	call	load_text_user_pat
 11598 00002FE0 E9D6EAFFFF          <1>         jmp     VIDEO_RETURN 
 11599                              <1> font_setup_1:
 11600                              <1> 	; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA)
 11601                              <1> 	; case 0x01:
 11602                              <1>         ; case 0x11:
 11603                              <1>         ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL());
 11604                              <1>         ; break;
 11605 00002FE5 3C01                <1> 	cmp	al, 1
 11606 00002FE7 7404                <1> 	je	short font_setup_2
 11607 00002FE9 3C11                <1> 	cmp	al, 11h
 11608 00002FEB 7511                <1> 	jne	short font_setup_3	
 11609                              <1> font_setup_2:
 11610                              <1> 	; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA)
 11611                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
 11612 00002FED E8C9020000          <1> 	call	load_text_8_14_pat
 11613 00002FF2 E9C4EAFFFF          <1>         jmp     VIDEO_RETURN
 11614                              <1> font_setup_error:
 11615 00002FF7 29C0                <1> 	sub	eax, eax ; 0 -> fonts could not be loaded
 11616 00002FF9 E9C2EAFFFF          <1> 	jmp	_video_return
 11617                              <1> font_setup_3:
 11618                              <1> 	; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA)
 11619                              <1> 	; case 0x02:
 11620                              <1>         ; case 0x12:
 11621                              <1>         ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL());
 11622                              <1>         ; break;
 11623 00002FFE 3C02                <1> 	cmp	al, 2
 11624 00003000 7404                <1> 	je	short font_setup_4
 11625 00003002 3C12                <1> 	cmp	al, 12h
 11626 00003004 750A                <1> 	jne	short font_setup_5	
 11627                              <1> font_setup_4:
 11628                              <1> 	; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA)
 11629                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
 11630 00003006 E8E1020000          <1> 	call	load_text_8_8_pat
 11631 0000300B E9ABEAFFFF          <1>         jmp     VIDEO_RETURN
 11632                              <1> font_setup_5:
 11633                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA)
 11634                              <1> 	; case 0x04:
 11635                              <1>         ; case 0x14:
 11636                              <1>         ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL());
 11637                              <1>         ; break;
 11638 00003010 3C04                <1> 	cmp	al, 4
 11639 00003012 7404                <1> 	je	short font_setup_6
 11640 00003014 3C14                <1> 	cmp	al, 14h
 11641 00003016 750A                <1> 	jne	short font_setup_7	
 11642                              <1> font_setup_6:
 11643                              <1> 	; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA)
 11644                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
 11645 00003018 E819030000          <1> 	call	load_text_8_16_pat
 11646 0000301D E999EAFFFF          <1>         jmp     VIDEO_RETURN
 11647                              <1> font_setup_7:
 11648                              <1> 	; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed
 11649                              <1> 	; for TRDOS 386 (TRDOS v2.0) video functionality;
 11650                              <1> 	; because, originally EXT_PTR (font address) was used for
 11651                              <1> 	; chars 80h to 0FFh (after the first 128 ASCII char fonts), for
 11652                              <1> 	; CGA graphics mode; currenty, 'vgafont8' address has 256 chars!
 11653                              <1> 	; 
 11654                              <1> 	; case 0x20:
 11655                              <1>         ; biosfn_load_gfx_8_8_chars(ES,BP);
 11656                              <1>         ; break; 
 11657                              <1> 	; case 0x21:
 11658                              <1>         ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL());
 11659                              <1>         ; break;
 11660                              <1> 	; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA)
 11661                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
 11662                              <1>         ;                        01H = 14 rows
 11663                              <1>         ;                        02H = 25 rows
 11664                              <1>         ;                        03H = 43 rows
 11665                              <1>         ; CX   bytes per character definition
 11666                              <1>         ; DL   (when BL=0) custom number of character rows on screen
 11667                              <1>         ; EBP  address of font-definition information (user's mem space)
 11668                              <1> 
 11669 00003022 3C21                <1> 	cmp	al, 21h
 11670 00003024 7531                <1> 	jne	short font_setup_9
 11671                              <1> 
 11672                              <1> 	; TRDOS 386 modification !
 11673                              <1> 	; dh = 0 -> 256 characters
 11674                              <1> 	; dh = 80h -> second 128 characters
 11675                              <1> 	; dh = 0FFh -> first 128 characters
 11676                              <1> 
 11677                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
 11678                              <1> 	;push	ebx
 11679 00003026 51                  <1> 	push	ecx
 11680 00003027 52                  <1> 	push	edx
 11681 00003028 30D2                <1> 	xor	dl, dl
 11682 0000302A 88CF                <1> 	mov	bh, cl ; character height
 11683                              <1> 	;mov	cx, 100h ; 256
 11684                              <1> 	; 03/08/2022
 11685 0000302C 31C9                <1> 	xor 	ecx, ecx
 11686 0000302E FEC5                <1> 	inc	ch
 11687                              <1> 	; ecx = 100h
 11688 00003030 08F6                <1> 	or	dh, dh ; 0
 11689 00003032 7410                <1> 	jz	short  font_setup_8
 11690 00003034 FECD                <1> 	dec	ch ; cx = 0
 11691 00003036 80FEFF              <1> 	cmp	dh, 0FFh
 11692 00003039 7409                <1> 	je	short font_setup_8 ; 1st 128 chars
 11693                              <1> 	; 2nd 128 chars
 11694 0000303B 80FE80              <1> 	cmp	dh, 80h
 11695 0000303E 75B7                <1> 	jne	short font_setup_error ; invalid !
 11696 00003040 88F1                <1> 	mov	cl, dh
 11697 00003042 86D6                <1> 	xchg	dl, dh
 11698                              <1> 	; number of chars, cx = 80h 
 11699                              <1> 	; start char, dl = 80h
 11700                              <1> font_setup_8:	
 11701 00003044 E85E000000          <1> 	call	transfer_user_fonts
 11702 00003049 5A                  <1> 	pop	edx
 11703 0000304A 59                  <1> 	pop	ecx
 11704                              <1> 	;pop	ebx
 11705 0000304B 72AA                <1> 	jc	short font_setup_error
 11706                              <1> 	; ebp = user's font data address in system's memory space
 11707 0000304D E82F030000          <1> 	call	load_gfx_user_chars
 11708 00003052 E964EAFFFF          <1>         jmp     VIDEO_RETURN 
 11709                              <1> font_setup_9:
 11710                              <1> 	; case 0x22:
 11711                              <1>         ; biosfn_load_gfx_8_14_chars(GET_BL());
 11712                              <1>         ; break;
 11713 00003057 3C22                <1> 	cmp	al, 22h
 11714 00003059 750A                <1> 	jne	short font_setup_10
 11715 0000305B E85D030000          <1> 	call	load_gfx_8_14_chars	
 11716 00003060 E956EAFFFF          <1>         jmp     VIDEO_RETURN 
 11717                              <1> font_setup_10:	
 11718                              <1> 	; case 0x23:
 11719                              <1>         ; biosfn_load_gfx_8_8_dd_chars(GET_BL());
 11720                              <1>         ; break;
 11721 00003065 3C23                <1> 	cmp	al, 23h
 11722 00003067 750A                <1> 	jne	short font_setup_11
 11723 00003069 E890030000          <1> 	call	load_gfx_8_8_chars	
 11724 0000306E E948EAFFFF          <1>         jmp     VIDEO_RETURN 
 11725                              <1> font_setup_11:	
 11726                              <1> 	; case 0x24:
 11727                              <1>         ; biosfn_load_gfx_8_16_chars(GET_BL());
 11728                              <1>         ; break;
 11729 00003073 3C24                <1> 	cmp	al, 24h
 11730 00003075 750A                <1> 	jne	short font_setup_12
 11731 00003077 E8C3030000          <1> 	call	load_gfx_8_16_chars	
 11732 0000307C E93AEAFFFF          <1>         jmp     VIDEO_RETURN 
 11733                              <1> font_setup_12:
 11734                              <1>  	; case 0x30:
 11735                              <1>         ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX);
 11736                              <1>         ; break;
 11737 00003081 3C30                <1> 	cmp	al, 30h
 11738 00003083 750A                <1> 	jne	short font_setup_13			
 11739 00003085 E8F6030000          <1> 	call	get_font_info
 11740                              <1> 	; eax = return value (info: 4 bytes for 4 parms)
 11741                              <1> 	; eax = 0 -> invalid function (input)
 11742 0000308A E931EAFFFF          <1>         jmp     _video_return
 11743                              <1> font_setup_13:
 11744 0000308F 3C03                <1> 	cmp	al, 03h ; AX = 1103h	
 11745 00003091 750D                <1> 	jne	short font_setup_14
 11746                              <1> 	; biosfn_set_text_block_specifier:
 11747                              <1> 	; BL = font block selector code	
 11748                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
 11749                              <1> 	; (It is as BL = 0 for TRDOS 386)
 11750 00003093 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 11751                              <1> 	;mov	ah, bl
 11752 00003097 28E4                <1> 	sub	ah, ah ; 0
 11753                              <1> 	;mov	al, 03h
 11754 00003099 66EF                <1> 	out	dx, ax
 11755 0000309B E91BEAFFFF          <1> 	jmp     VIDEO_RETURN 
 11756                              <1> 	
 11757                              <1> font_setup_14:
 11758 000030A0 29C0                <1> 	sub	eax, eax ; 0 = invalid function
 11759 000030A2 E919EAFFFF          <1>         jmp     _video_return
 11760                              <1> 
 11761                              <1> transfer_user_fonts:
 11762                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
 11763                              <1> 	; 19/01/2021
 11764                              <1> 	; 09/01/2021
 11765                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
 11766                              <1> 
 11767                              <1> 	; BH =  height of each character (bytes per character)
 11768                              <1> 	; CX =  number of characters to redefine (<=256)
 11769                              <1>         ; DX =  ASCII code of the first character defined at EBP
 11770                              <1>         ; EBP =	address of font-definition information
 11771                              <1> 	;	(in user's memory space)
 11772                              <1> 
 11773                              <1> 	; Modified registers: eax, edx, ecx, esi, edi, ebp
 11774                              <1> 	;
 11775                              <1> 	; output:
 11776                              <1> 	;	ebp = user font data address in system memory
 11777                              <1> 
 11778 000030A7 81E2FFFF0000        <1> 	and	edx, 0FFFFh
 11779 000030AD 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
 11780 000030B3 7537                <1> 	jnz	short transfer_user_fonts_5
 11781                              <1> 
 11782 000030B5 09D2                <1> 	or	edx, edx
 11783 000030B7 7531                <1> 	jnz	short transfer_user_fonts_4
 11784 000030B9 09ED                <1> 	or	ebp, ebp
 11785 000030BB 752D                <1> 	jnz	short transfer_user_fonts_4
 11786                              <1> 
 11787                              <1> 	; cx = 0, dx = 0, ebp = 0
 11788                              <1> 	; copy system font to user font
 11789                              <1> 
 11790 000030BD B140                <1> 	mov	cl, 64 ; 64 dwords
 11791                              <1> 	
 11792 000030BF 80FF10              <1> 	cmp	bh, 16
 11793 000030C2 7417                <1> 	je	short transfer_user_fonts_2
 11794 000030C4 80FF08              <1> 	cmp	bh, 8
 11795 000030C7 7406                <1> 	je	short transfer_user_fonts_1
 11796                              <1> 
 11797 000030C9 BD[10560100]        <1> 	mov	ebp, vgafont14
 11798 000030CE C3                  <1> 	retn 
 11799                              <1> 
 11800                              <1> transfer_user_fonts_1:
 11801 000030CF BF00500900          <1> 	mov	edi, VGAFONT8USER
 11802 000030D4 BE[104E0100]        <1> 	mov	esi, vgafont8
 11803 000030D9 EB0A                <1> 	jmp	short transfer_user_fonts_3
 11804                              <1> 
 11805                              <1> transfer_user_fonts_2:
 11806 000030DB BF00400900          <1> 	mov	edi, VGAFONT16USER
 11807 000030E0 BE[10640100]        <1> 	mov	esi, vgafont16
 11808                              <1> transfer_user_fonts_3:
 11809 000030E5 89FD                <1> 	mov	ebp, edi
 11810 000030E7 F3A5                <1> 	rep	movsd
 11811 000030E9 C3                  <1> 	retn
 11812                              <1> 
 11813                              <1> transfer_user_fonts_4:
 11814 000030EA F9                  <1> 	stc	
 11815 000030EB C3                  <1> 	retn
 11816                              <1> 	
 11817                              <1> transfer_user_fonts_5:
 11818 000030EC 09ED                <1> 	or	ebp, ebp
 11819 000030EE 74FA                <1> 	jz	short transfer_user_fonts_4 ; invalid address !
 11820                              <1> 
 11821 000030F0 6681F90001          <1> 	cmp	cx, 256
 11822 000030F5 77F3                <1> 	ja	short transfer_user_fonts_4
 11823 000030F7 29D1                <1> 	sub	ecx, edx
 11824 000030F9 76EF                <1> 	jna	short transfer_user_fonts_4
 11825                              <1> 
 11826 000030FB 80FF0E              <1> 	cmp	bh, 14 ; 8x14 font
 11827                              <1> 		       ; (there is not an alternative buffer)
 11828 000030FE 7524                <1> 	jne	short transfer_user_fonts_6
 11829                              <1> 	
 11830                              <1> 	; use system's 8x14 font space if permission flag is 1
 11831 00003100 F605[32100300]80    <1> 	test	byte [ufont], 80h
 11832 00003107 74E1                <1> 	jz	short transfer_user_fonts_4 ; not allowed
 11833                              <1> 
 11834                              <1> 	; permission is given (for vgafont14 location etc.)
 11835                              <1> 	; (for permanent font modification)
 11836                              <1> 	;
 11837                              <1> 	; 19/01/2021
 11838                              <1> 	; Note: Permission flag can be set by 'root' while
 11839                              <1> 	;	system is not in multi tasking/user mode
 11840                              <1> 	;	while [multi_tasking] = 0 and [u.uid] = 0
 11841                              <1> 
 11842                              <1> 	;push	edx	
 11843                              <1> 	; 02/08/2022
 11844 00003109 87D1                <1> 	xchg	edx, ecx
 11845                              <1> 	;xor	ah, ah
 11846                              <1> 	; 02/08/2022
 11847 0000310B 31C0                <1> 	xor	eax, eax
 11848 0000310D 88F8                <1> 	mov	al, bh ; mov al, 14 
 11849                              <1> 	;mul	cx 
 11850                              <1> 	; 02/08/2022
 11851 0000310F F7E2                <1> 	mul	edx  ; char count * 14	
 11852                              <1> 	; 02/08/2022
 11853 00003111 89CA                <1> 	mov	edx, ecx ; ascii code
 11854 00003113 89C1                <1> 	mov	ecx, eax
 11855                              <1> 		; ecx = byte count 
 11856                              <1> 	;pop	edx
 11857                              <1> 	; 02/08/2022
 11858                              <1> 	;xor	eax, eax	
 11859 00003115 30E4                <1> 	xor	ah, ah
 11860 00003117 88F8                <1> 	mov	al, bh ; mov ax, 14 ; bytes per character
 11861                              <1> 	;mul	dx
 11862                              <1> 	;mov	dx, ax ; char offset
 11863                              <1> 	; 02/08/2022
 11864 00003119 F7E2                <1> 	mul	edx
 11865 0000311B 89C2                <1> 	mov	edx, eax ; char offset
 11866 0000311D BF[10560100]        <1> 	mov	edi, vgafont14
 11867 00003122 EB48                <1> 	jmp	short transfer_user_fonts_8			
 11868                              <1> transfer_user_fonts_6:
 11869 00003124 80FF08              <1> 	cmp	bh, 8 ; 8x8 font
 11870 00003127 7520                <1> 	jne	short transfer_user_fonts_7 ; 8x16 font
 11871                              <1> 	;shl	dx, 3 ; * 8
 11872                              <1> 	;shl	cx, 3 ; * 8
 11873                              <1> 	; 02/08/2022
 11874 00003129 C1E203              <1> 	shl	edx, 3 ; byte offset
 11875 0000312C C1E103              <1> 	shl	ecx, 3 ; byte count
 11876                              <1> 	; 09/01/2021
 11877 0000312F BF00500900          <1> 	mov	edi, VGAFONT8USER
 11878 00003134 F605[32100300]08    <1> 	test	byte [ufont], 8  ; already loaded ?	
 11879 0000313B 752F                <1> 	jnz	short transfer_user_fonts_8 ; yes
 11880 0000313D BE[104E0100]        <1> 	mov	esi, vgafont8
 11881 00003142 E839000000          <1> 	call	transfer_user_fonts_10
 11882 00003147 EB23                <1> 	jmp	short transfer_user_fonts_8
 11883                              <1> transfer_user_fonts_7:
 11884 00003149 80FF10              <1> 	cmp	bh, 16 ; 8x16 font
 11885 0000314C 759C                <1> 	jne	short transfer_user_fonts_4  ; invalid !
 11886                              <1> 	;shl	dx, 4 ; * 16
 11887                              <1> 	;shl	cx, 4 ; * 16
 11888                              <1> 	; 02/08/2022
 11889 0000314E C1E204              <1> 	shl	edx, 4 ; byte offset
 11890 00003151 C1E104              <1> 	shl	ecx, 4 ; byte count
 11891 00003154 BF00400900          <1>  	mov	edi, VGAFONT16USER
 11892 00003159 F605[32100300]10    <1> 	test	byte [ufont], 16  ; already loaded ?	
 11893 00003160 750A                <1> 	jnz	short transfer_user_fonts_8 ; yes
 11894 00003162 BE[10640100]        <1> 	mov	esi, vgafont16
 11895 00003167 E814000000          <1> 	call	transfer_user_fonts_10
 11896                              <1> transfer_user_fonts_8:
 11897 0000316C 01D7                <1> 	add	edi, edx ; char offset
 11898                              <1> 	; 09/07/2016
 11899                              <1> 	;and	ecx, 0FFFFh
 11900                              <1> 	; ECX = byte count
 11901                              <1> 	;push	ecx
 11902 0000316E 89EE                <1> 	mov	esi, ebp ; user's font buffer
 11903                              <1> 	; 09/01/2021
 11904 00003170 89FD                <1> 	mov	ebp, edi ; system addr for user's font
 11905                              <1> 	; 05/01/2021
 11906                              <1> 	;mov	edi, Cluster_Buffer  ; system buffer
 11907 00003172 E800DC0000          <1> 	call	transfer_from_user_buffer
 11908                              <1> 	;pop	ecx
 11909                              <1> 	; ecx = transfer (byte) count = character count
 11910 00003177 7206                <1> 	jc	short transfer_user_fonts_9
 11911                              <1> 	; 05/01/2021
 11912                              <1> 	;mov	ebp, Cluster_Buffer
 11913                              <1> 	
 11914 00003179 083D[32100300]      <1> 	or	byte [ufont], bh 
 11915                              <1> 			; 8x8 or 8x16 user font ready 
 11916                              <1> transfer_user_fonts_9:
 11917 0000317F C3                  <1> 	retn
 11918                              <1> 
 11919                              <1> transfer_user_fonts_10:
 11920                              <1> 	; 02/08/2022
 11921                              <1> 	; 09/01/2021
 11922 00003180 56                  <1> 	push	esi
 11923 00003181 57                  <1> 	push	edi
 11924 00003182 51                  <1> 	push	ecx
 11925                              <1> 	;mov	cx, 64
 11926                              <1> 	; 02/08/2022
 11927 00003183 31C9                <1> 	xor	ecx, ecx
 11928 00003185 B140                <1> 	mov	cl, 64
 11929 00003187 F3A5                <1> 	rep	movsd
 11930 00003189 59                  <1> 	pop	ecx
 11931 0000318A 5F                  <1> 	pop	edi
 11932 0000318B 5E                  <1> 	pop	esi
 11933 0000318C C3                  <1> 	retn
 11934                              <1> 
 11935                              <1> load_text_user_pat:
 11936                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
 11937                              <1> 	; 26/07/2016
 11938                              <1> 	; 09/07/2016
 11939                              <1> 	; load user defined (EGA/VGA) text fonts
 11940                              <1> 	;
 11941                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 11942                              <1> 	; vgabios-0.7a (2011)
 11943                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 11944                              <1> 	; 'vgabios.c', 'biosfn_load_text_user_pat'
 11945                              <1> 
 11946                              <1> 	; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH)
 11947                              <1> 
 11948                              <1> 	; get_font_access();
 11949                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 11950                              <1> 	; for(i=0;i<CX;i++)
 11951                              <1> 	; {
 11952                              <1> 	;  src = BP + i * BH;
 11953                              <1> 	;  dest = blockaddr + (DX + i) * 32;
 11954                              <1> 	;  memcpyb(0xA000, dest, ES, src, BH);
 11955                              <1> 	; }
 11956                              <1> 	; release_font_access();
 11957                              <1> 	; if(AL>=0x10)
 11958                              <1> 	; {
 11959                              <1> 	; set_scan_lines(BH);
 11960                              <1> 	; }
 11961                              <1> 
 11962 0000318D 50                  <1> 	push	eax
 11963 0000318E E839000000          <1> 	call	get_font_access
 11964 00003193 28DB                <1> 	sub	bl, bl ; i = 0
 11965                              <1> 	; 02/08/2022
 11966                              <1> 	; ecx <= 256
 11967 00003195 30ED                <1> 	xor	ch, ch
 11968                              <1> ltup_1:
 11969 00003197 88D8                <1> 	mov	al, bl
 11970 00003199 F6E7                <1> 	mul	bh	
 11971                              <1> 	;movzx	esi, ax
 11972                              <1> 	; 02/08/2022
 11973 0000319B 89C6                <1> 	mov	esi, eax
 11974 0000319D 01EE                <1> 	add	esi, ebp
 11975 0000319F 88D8                <1> 	mov	al, bl
 11976 000031A1 28E4                <1> 	sub	ah, ah
 11977                              <1> 	;add	ax, dx ; (DX + i)
 11978                              <1> 	;shl	ax, 5  ; * 32
 11979                              <1> 	; 02/08/2022
 11980 000031A3 01D0                <1> 	add	eax, edx
 11981 000031A5 C1E005              <1> 	shl	eax, 5
 11982                              <1> 	;movzx	edi, ax
 11983                              <1> 	; 02/08/2022
 11984 000031A8 89C7                <1> 	mov	edi, eax
 11985 000031AA 81C700000A00        <1> 	add	edi, 0A0000h
 11986 000031B0 51                  <1> 	push	ecx
 11987                              <1> 	;movzx	ecx, bh
 11988                              <1> 	; 02/08/2022
 11989 000031B1 88F9                <1> 	mov	cl, bh
 11990 000031B3 F3A4                <1> 	rep	movsb
 11991 000031B5 59                  <1> 	pop	ecx
 11992 000031B6 FEC3                <1> 	inc	bl
 11993 000031B8 38CB                <1> 	cmp	bl, cl
 11994 000031BA 75DB                <1> 	jne	short ltup_1
 11995                              <1> 	;
 11996 000031BC E83E000000          <1> 	call	release_font_access
 11997                              <1> 	;
 11998 000031C1 58                  <1> 	pop	eax
 11999                              <1> 	; if(AL>=0x10)
 12000 000031C2 3C10                <1> 	cmp	al, 10h
 12001 000031C4 7205                <1> 	jb	short ltup_2
 12002                              <1>    	; set_scan_lines(BH);
 12003 000031C6 E86F000000          <1> 	call	set_scan_lines
 12004                              <1> ltup_2:
 12005 000031CB C3                  <1> 	retn
 12006                              <1> 
 12007                              <1> get_font_access:
 12008                              <1> 	; 02/08/2022
 12009                              <1> 	; 09/07/2016
 12010                              <1> 	;
 12011                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12012                              <1> 	; vgabios-0.7a (2011)
 12013                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12014                              <1> 	; 'vgabios.c', 'get_font_access'
 12015                              <1> 
 12016                              <1> 	; get_font_access()
 12017 000031CC 52                  <1> 	push	edx
 12018 000031CD 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 12019                              <1> 	; 02/08/2022
 12020 000031D1 31C0                <1>  	xor	eax, eax
 12021                              <1> 	;mov	ax, 0100h
 12022 000031D3 B401                <1> 	mov	ah, 1
 12023                              <1> 	; ax = 0100h
 12024 000031D5 66EF                <1> 	out	dx, ax
 12025 000031D7 66B80204            <1> 	mov	ax, 0402h
 12026 000031DB 66EF                <1> 	out	dx, ax
 12027 000031DD 66B80407            <1> 	mov	ax, 0704h
 12028 000031E1 66EF                <1> 	out	dx, ax
 12029 000031E3 66B80003            <1> 	mov	ax, 0300h
 12030 000031E7 66EF                <1> 	out	dx, ax
 12031                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 12032                              <1> 	; 02/08/2022
 12033 000031E9 B2CE                <1> 	mov	dl, 0CEh
 12034 000031EB 66B80402            <1> 	mov	ax, 0204h
 12035 000031EF 66EF                <1> 	out	dx, ax
 12036 000031F1 66B80500            <1> 	mov	ax, 0005h
 12037 000031F5 66EF                <1> 	out	dx, ax
 12038 000031F7 66B80604            <1> 	mov	ax, 0406h
 12039 000031FB 66EF                <1> 	out	dx, ax
 12040 000031FD 5A                  <1> 	pop	edx
 12041 000031FE C3                  <1> 	retn
 12042                              <1> 
 12043                              <1> release_font_access:
 12044                              <1> 	; 02/08/2022
 12045                              <1> 	; 29/07/2016
 12046                              <1> 	; 09/07/2016
 12047                              <1> 	;
 12048                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12049                              <1> 	; vgabios-0.7a (2011)
 12050                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12051                              <1> 	; 'vgabios.c', 'release_font_access'
 12052                              <1> 
 12053 000031FF 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 12054                              <1> 	;mov	ax, 0100h
 12055                              <1> 	; 02/08/2022
 12056 00003203 29C0                <1> 	sub	eax, eax
 12057 00003205 B401                <1> 	mov	ah, 1
 12058                              <1> 	; ax = 0100h
 12059 00003207 66EF                <1> 	out	dx, ax
 12060 00003209 66B80203            <1> 	mov	ax, 0302h
 12061 0000320D 66EF                <1> 	out	dx, ax
 12062 0000320F 66B80403            <1> 	mov	ax, 0304h
 12063 00003213 66EF                <1> 	out	dx, ax
 12064 00003215 66B80003            <1> 	mov	ax, 0300h
 12065 00003219 66EF                <1> 	out	dx, ax
 12066                              <1> 	;mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
 12067                              <1>  	; 02/08/2022
 12068 0000321B B2CC                <1> 	mov	dl, 0CCh
 12069 0000321D EC                  <1> 	in	al, dx
 12070 0000321E 2401                <1> 	and	al, 01h
 12071 00003220 C0E002              <1> 	shl	al, 2
 12072 00003223 0C0A                <1> 	or	al, 0Ah
 12073 00003225 88C4                <1> 	mov	ah, al
 12074 00003227 B006                <1> 	mov	al, 06h
 12075                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 12076                              <1> 	; 02/08/2022
 12077 00003229 B2CE                <1> 	mov	dl, 0CEh
 12078 0000322B 66EF                <1> 	out	dx, ax
 12079 0000322D 66B80400            <1> 	mov	ax, 0004h
 12080 00003231 66EF                <1> 	out	dx, ax
 12081 00003233 66B80510            <1> 	mov	ax, 1005h
 12082 00003237 66EF                <1> 	out	dx, ax
 12083 00003239 C3                  <1> 	retn
 12084                              <1> 
 12085                              <1> set_scan_lines:
 12086                              <1> 	; 02/08/2022
 12087                              <1> 	; 09/07/2016
 12088                              <1> 	;
 12089                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12090                              <1> 	; vgabios-0.7a (2011)
 12091                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12092                              <1> 	; 'vgabios.c', 'set_scan_lines'
 12093                              <1> 
 12094                              <1> 	; set_scan_lines(lines)
 12095                              <1> 	; BH = lines
 12096                              <1> 
 12097                              <1> 	; outb(crtc_addr, 0x09);
 12098 0000323A 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS = 3D4h (always)
 12099 0000323E B009                <1> 	mov	al, 09h
 12100 00003240 EE                  <1> 	out	dx, al
 12101                              <1> 	; crtc_r9 = inb(crtc_addr+1);
 12102                              <1> 	;inc	dx ; 3D5h
 12103                              <1> 	; 02/08/2022
 12104 00003241 FEC2                <1> 	inc	dl
 12105 00003243 EC                  <1> 	in	al, dx
 12106                              <1> 	; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
 12107 00003244 24E0                <1> 	and	al, 0E0h
 12108 00003246 FECF                <1> 	dec	bh ; lines - 1
 12109 00003248 08F8                <1> 	or	al, bh
 12110                              <1> 	; outb(crtc_addr+1, crtc_r9);
 12111 0000324A EE                  <1> 	out	dx, al
 12112                              <1> 	;inc	bh 
 12113                              <1> 	; if(lines==8)
 12114                              <1> 	;cmp	bh, 8
 12115 0000324B 80FF07              <1> 	cmp	bh, 7
 12116 0000324E 7506                <1> 	jne	short ssl_1
 12117                              <1> 	; biosfn_set_cursor_shape(0x06,0x07);
 12118 00003250 66B90706            <1> 	mov	cx, 0607h
 12119 00003254 EB06                <1> 	jmp	short ssl_2
 12120                              <1> ssl_1:
 12121                              <1> 	; biosfn_set_cursor_shape(lines-4,lines-3);
 12122 00003256 88F9                <1> 	mov	cl, bh ; lines - 1
 12123 00003258 88CD                <1> 	mov	ch, cl ; lines - 1 (16 -> 15)
 12124 0000325A FECD                <1> 	dec	ch  ; lines - 2 (16 -> 14)
 12125                              <1> ssl_2:
 12126                              <1> 	; CH = start line, CL = stop line
 12127 0000325C B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
 12128 0000325E 66890D[B7660000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
 12129 00003265 E877F0FFFF          <1> 	call	m16	; output cx register
 12130                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines);
 12131 0000326A FEC7                <1> 	inc	bh ; lines
 12132 0000326C 883D[A2660000]      <1> 	mov	[CHAR_HEIGHT], bh
 12133                              <1> 	;  outb(crtc_addr, 0x12);
 12134 00003272 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS
 12135 00003276 B012                <1> 	mov	al, 12h
 12136 00003278 EE                  <1> 	out	dx, al
 12137                              <1> 	; vde = inb(crtc_addr+1);
 12138                              <1> 	;inc	dx
 12139                              <1> 	; 02/08/2022
 12140 00003279 FEC2                <1> 	inc	dl
 12141 0000327B EC                  <1> 	in	al, dx
 12142 0000327C 88C4                <1> 	mov	ah, al
 12143                              <1> 	; outb(crtc_addr, 0x07);
 12144                              <1> 	;dec	dx
 12145                              <1> 	; 02/08/2022
 12146 0000327E FECA                <1> 	dec	dl
 12147 00003280 B007                <1> 	mov	al, 07h
 12148 00003282 EE                  <1> 	out	dx, al
 12149                              <1> 	; ovl = inb(crtc_addr+1);
 12150                              <1> 	;inc	dx
 12151                              <1> 	; 02/08/2022
 12152 00003283 FEC2                <1> 	inc	dl
 12153 00003285 EC                  <1> 	in	al, dx
 12154                              <1> 	; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1);
 12155 00003286 88E2                <1> 	mov	dl, ah ; vde
 12156 00003288 88C6                <1> 	mov	dh, al ; ovl
 12157                              <1> 	;and	ax, 02h
 12158                              <1> 	;shl	ax, 7
 12159                              <1> 	; 02/08/2022
 12160 0000328A 31C0                <1> 	xor	eax, eax
 12161 0000328C 88F0                <1> 	mov	al, dh
 12162 0000328E 2402                <1> 	and	al, 2
 12163 00003290 C1E007              <1> 	shl	eax, 7
 12164                              <1> 	;mov	cx, ax ; (ovl & 0x02) << 7)	
 12165                              <1> 	; 02/08/2022
 12166 00003293 89C1                <1> 	mov	ecx, eax
 12167 00003295 28E4                <1> 	sub	ah, ah
 12168 00003297 88F0                <1> 	mov	al, dh ; ovl
 12169                              <1> 	;and	ax, 40h			
 12170                              <1> 	;shl	ax, 3  ; (ovl & 0x40) << 3)
 12171                              <1> 	;inc	ax ; + 1 
 12172                              <1> 	;add	ax, cx
 12173                              <1> 	; 02/08/2022	
 12174 00003299 2440                <1> 	and	al, 40h
 12175 0000329B C1E003              <1> 	shl	eax, 3
 12176 0000329E 40                  <1> 	inc	eax
 12177 0000329F 01C8                <1> 	add	eax, ecx
 12178 000032A1 30F6                <1> 	xor	dh, dh
 12179                              <1> 	;add	ax, dx ; + vde
 12180                              <1> 	; 02/08/2022
 12181 000032A3 01D0                <1> 	add	eax, edx
 12182                              <1> 	; rows = vde / lines;
 12183 000032A5 F6F7                <1> 	div	bh
 12184                              <1> 	;dec	al ; rows -1
 12185                              <1> 	; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1);
 12186 000032A7 A2[A6660000]        <1> 	mov	[VGA_ROWS], al ; rows (not 'rows-1' !)
 12187                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2);
 12188                              <1> 	;mov	ah, [CRT_COLS]
 12189                              <1> 	;mul	ah
 12190                              <1> 	; 17/11/2020
 12191 000032AC F625[A0660000]      <1> 	mul	byte [CRT_COLS]
 12192                              <1> 	;shl	ax, 1
 12193                              <1> 	; 02/08/2022
 12194 000032B2 D1E0                <1> 	shl	eax, 1
 12195 000032B4 66A3[14840100]      <1> 	mov 	[CRT_LEN], ax	
 12196 000032BA C3                  <1> 	retn
 12197                              <1> 
 12198                              <1> load_text_8_14_pat:
 12199                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
 12200                              <1> 	; 26/07/2016
 12201                              <1> 	; 25/07/2016
 12202                              <1> 	; 23/07/2016
 12203                              <1> 	; 09/07/2016
 12204                              <1> 	; load user defined (EGA/VGA) text fonts
 12205                              <1> 	;
 12206                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12207                              <1> 	; vgabios-0.7a (2011)
 12208                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12209                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_14_pat'
 12210                              <1> 
 12211                              <1> 	; biosfn_load_text_8_14_pat (AL,BL)
 12212                              <1> 
 12213                              <1> 	; get_font_access();
 12214                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12215                              <1> 	; for(i=0;i<0x100;i++)
 12216                              <1> 	; {
 12217                              <1> 	;  src = i * 14;
 12218                              <1> 	;  dest = blockaddr + i * 32;
 12219                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14);
 12220                              <1> 	; }
 12221                              <1> 	; release_font_access();
 12222                              <1> 	; if(AL>=0x10)
 12223                              <1> 	; {
 12224                              <1> 	; set_scan_lines(14);
 12225                              <1> 	; }
 12226                              <1> 
 12227 000032BB 50                  <1> 	push	eax
 12228 000032BC E80BFFFFFF          <1> 	call	get_font_access
 12229                              <1> 
 12230                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12231                              <1> 	;mov	dl, bl
 12232                              <1> 	;and	dl, 3
 12233                              <1> 	;shl	dx, 14
 12234                              <1> 	;xchg	dx, bx
 12235                              <1> 	;and	dl, 4
 12236                              <1> 	;shl	dx, 11
 12237                              <1> 	;add	dx, bx 	
 12238                              <1>  
 12239                              <1> 	;xor	dx, dx  ; blockaddr = 0
 12240                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
 12241                              <1> 
 12242 000032C1 28DB                <1> 	sub	bl, bl ; i = 0
 12243 000032C3 B70E                <1> 	mov	bh, 14
 12244 000032C5 BE[10560100]        <1> 	mov	esi, vgafont14
 12245 000032CA BF00000A00          <1> 	mov	edi, 0A0000h
 12246                              <1> 	; 02/08/2022
 12247 000032CF 29C9                <1> 	sub	ecx, ecx		
 12248                              <1> lt8_14_1:
 12249                              <1> 	;mov	al, bl
 12250                              <1> 	;mul	bh
 12251                              <1> 	;movzx	esi, ax
 12252                              <1> 	;add	esi, vgafont14
 12253                              <1> 	;mov	al, bl
 12254                              <1> 	;sub	ah, ah
 12255                              <1> 	;shl	ax, 5 ; * 32
 12256                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
 12257                              <1> 	;movzx	edi, ax ; dest
 12258                              <1> 	;add	edi, 0A0000h
 12259                              <1> 	;02/08/2022
 12260                              <1> 	;movzx	ecx, bh
 12261 000032D1 88F9                <1> 	mov	cl, bh
 12262 000032D3 F3A4                <1> 	rep	movsb
 12263 000032D5 83C712              <1> 	add	edi, 18 ; 32 - 14
 12264 000032D8 FEC3                <1> 	inc	bl
 12265 000032DA 75F5                <1> 	jnz	short lt8_14_1	
 12266                              <1> 	;
 12267 000032DC E81EFFFFFF          <1> 	call	release_font_access
 12268                              <1> 	;
 12269 000032E1 58                  <1> 	pop	eax
 12270                              <1> 	; if(AL>=0x10)
 12271 000032E2 3C10                <1> 	cmp	al, 10h
 12272 000032E4 7205                <1> 	jb	short lt8_14_4
 12273                              <1> 	; BH = 14
 12274                              <1>    	; set_scan_lines(14);
 12275 000032E6 E84FFFFFFF          <1> 	call	set_scan_lines
 12276                              <1> lt8_14_4:
 12277 000032EB C3                  <1> 	retn
 12278                              <1> 
 12279                              <1> load_text_8_8_pat:
 12280                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
 12281                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
 12282                              <1> 	; 26/07/2016
 12283                              <1> 	; 25/07/2016
 12284                              <1> 	; 23/07/2016
 12285                              <1> 	; 09/07/2016
 12286                              <1> 	; load user defined (EGA/VGA) text fonts
 12287                              <1> 	;
 12288                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12289                              <1> 	; vgabios-0.7a (2011)
 12290                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12291                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_8_pat'
 12292                              <1> 
 12293                              <1> 	; biosfn_load_text_8_8_pat (AL,BL)
 12294                              <1> 
 12295                              <1> 	; get_font_access();
 12296                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12297                              <1> 	; for(i=0;i<0x100;i++)
 12298                              <1> 	; {
 12299                              <1> 	;  src = i * 8;
 12300                              <1> 	;  dest = blockaddr + i * 32;
 12301                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8);
 12302                              <1> 	; }
 12303                              <1> 	; release_font_access();
 12304                              <1> 	; if(AL>=0x10)
 12305                              <1> 	; {
 12306                              <1> 	; set_scan_lines(8);
 12307                              <1> 	; }
 12308                              <1> 
 12309 000032EC 50                  <1> 	push	eax
 12310 000032ED E8DAFEFFFF          <1> 	call	get_font_access
 12311                              <1> 
 12312                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12313                              <1> 	;mov	dl, bl
 12314                              <1> 	;and	dl, 3
 12315                              <1> 	;shl	dx, 14
 12316                              <1> 	;xchg	dx, bx
 12317                              <1> 	;and	dl, 4
 12318                              <1> 	;shl	dx, 11
 12319                              <1> 	;add	dx, bx 	
 12320                              <1>  
 12321                              <1> 	;xor	dx, dx  ; blockaddr = 0
 12322                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
 12323                              <1> 
 12324 000032F2 28DB                <1> 	sub	bl, bl ; i = 0
 12325 000032F4 B708                <1> 	mov	bh, 8
 12326                              <1> 	;mov	esi, vgafont8
 12327 000032F6 BF00000A00          <1> 	mov	edi, 0A0000h
 12328                              <1> 
 12329                              <1> 	; 02/08/2022
 12330 000032FB 29C9                <1> 	sub	ecx, ecx
 12331                              <1> 
 12332                              <1> 	; 05/01/2021
 12333 000032FD F605[32100300]80    <1> 	test	byte [ufont], 80h
 12334 00003304 7410                <1> 	jz	short lt8_8_0
 12335                              <1> 		; user font permission (after set mode)
 12336 00003306 F605[32100300]08    <1>  	test	byte [ufont], 8
 12337 0000330D 7407                <1> 	jz	short lt8_8_0
 12338 0000330F BE00500900          <1> 	mov	esi, VGAFONT8USER
 12339 00003314 EB05                <1> 	jmp	short lt8_8_1
 12340                              <1> lt8_8_0:
 12341 00003316 BE[104E0100]        <1> 	mov	esi, vgafont8	
 12342                              <1> lt8_8_1:
 12343                              <1> 	;mov	al, bl
 12344                              <1> 	;mul	bh
 12345                              <1> 	;movzx	esi, ax
 12346                              <1> 	;add	esi, vgafont8
 12347                              <1> 	;mov	al, bl
 12348                              <1> 	;sub	ah, ah
 12349                              <1> 	;shl	ax, 5 ; * 32
 12350                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
 12351                              <1> 	;movzx	edi, ax ; dest
 12352                              <1> 	;add	edi, 0A0000h
 12353                              <1> 	; 02/08/2022
 12354                              <1> 	;movzx	ecx, bh 		
 12355 0000331B 88F9                <1> 	mov	cl, bh
 12356 0000331D F3A4                <1> 	rep	movsb
 12357 0000331F 83C718              <1> 	add	edi, 24 ; 32 - 8
 12358 00003322 FEC3                <1> 	inc	bl
 12359 00003324 75F5                <1> 	jnz	short lt8_8_1
 12360                              <1> 	;
 12361 00003326 E8D4FEFFFF          <1> 	call	release_font_access
 12362                              <1> 	;
 12363 0000332B 58                  <1> 	pop	eax
 12364                              <1> 	; if(AL>=0x10)
 12365 0000332C 3C10                <1> 	cmp	al, 10h
 12366 0000332E 7205                <1> 	jb	short lt8_8_2
 12367                              <1> 	; BH = 8
 12368                              <1>    	; set_scan_lines(8);
 12369 00003330 E805FFFFFF          <1> 	call	set_scan_lines
 12370                              <1> lt8_8_2:
 12371 00003335 C3                  <1> 	retn
 12372                              <1> 
 12373                              <1> load_text_8_16_pat:
 12374                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
 12375                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
 12376                              <1> 	; 26/07/2016
 12377                              <1> 	; 25/07/2016
 12378                              <1> 	; 23/07/2016
 12379                              <1> 	; 09/07/2016
 12380                              <1> 	; load user defined (EGA/VGA) text fonts
 12381                              <1> 	;
 12382                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12383                              <1> 	; vgabios-0.7a (2011)
 12384                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12385                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_16_pat'
 12386                              <1> 
 12387                              <1> 	; biosfn_load_text_8_16_pat (AL,BL)
 12388                              <1> 
 12389                              <1> 	; get_font_access();
 12390                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12391                              <1> 	; for(i=0;i<0x100;i++)
 12392                              <1> 	; {
 12393                              <1> 	;  src = i * 16;
 12394                              <1> 	;  dest = blockaddr + i * 32;
 12395                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16);
 12396                              <1> 	; }
 12397                              <1> 	; release_font_access();
 12398                              <1> 	; if(AL>=0x10)
 12399                              <1> 	; {
 12400                              <1> 	; set_scan_lines(16);
 12401                              <1> 	; }
 12402                              <1> 
 12403 00003336 50                  <1> 	push	eax
 12404 00003337 E890FEFFFF          <1> 	call	get_font_access
 12405                              <1> 
 12406                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
 12407                              <1> 	;mov	dl, bl
 12408                              <1> 	;and	dl, 3
 12409                              <1> 	;shl	dx, 14
 12410                              <1> 	;xchg	dx, bx
 12411                              <1> 	;and	dl, 4
 12412                              <1> 	;shl	dx, 11
 12413                              <1> 	;add	dx, bx 	
 12414                              <1>  
 12415                              <1> 	;xor	dx, dx  ; blockaddr = 0
 12416                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
 12417                              <1> 
 12418 0000333C 28DB                <1> 	sub	bl, bl ; i = 0
 12419 0000333E B710                <1> 	mov	bh, 16
 12420                              <1> 	;mov	esi, vgafont16
 12421 00003340 BF00000A00          <1> 	mov	edi, 0A0000h
 12422                              <1> 	;movzx	eax, bh
 12423                              <1> 	; 02/08/2022
 12424 00003345 29C0                <1> 	sub	eax, eax
 12425 00003347 88F8                <1> 	mov	al, bh
 12426                              <1> 
 12427                              <1> 	; 05/01/2021
 12428 00003349 F605[32100300]80    <1> 	test	byte [ufont], 80h
 12429 00003350 7410                <1> 	jz	short lt8_16_0
 12430                              <1> 		; user font permission (after set mode)
 12431 00003352 F605[32100300]10    <1>  	test	byte [ufont], 16
 12432 00003359 7407                <1> 	jz	short lt8_16_0
 12433 0000335B BE00400900          <1> 	mov	esi, VGAFONT16USER
 12434 00003360 EB05                <1> 	jmp	short lt8_16_1
 12435                              <1> lt8_16_0:
 12436 00003362 BE[10640100]        <1> 	mov	esi, vgafont16
 12437                              <1> lt8_16_1:
 12438                              <1> 	;mov	al, bl
 12439                              <1> 	;mul	bh
 12440                              <1> 	;movzx	esi, ax
 12441                              <1> 	;add	esi, vgafont16
 12442                              <1> 	;mov	al, bl ; i
 12443                              <1> 	;sub	ah, ah
 12444                              <1> 	;shl	ax, 5 ; * 32
 12445                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
 12446                              <1> 	;movzx	edi, ax ; dest
 12447                              <1> 	;add	edi, 0A0000h
 12448                              <1> 	;movzx	ecx, bh
 12449 00003367 89C1                <1> 	mov	ecx, eax ; 16	
 12450 00003369 F3A4                <1> 	rep	movsb
 12451 0000336B 01C7                <1> 	add	edi, eax ; add edi, 16
 12452 0000336D FEC3                <1> 	inc	bl
 12453 0000336F 75F6                <1> 	jnz	short lt8_16_1
 12454                              <1> 	;
 12455 00003371 E889FEFFFF          <1> 	call	release_font_access
 12456                              <1> 	;
 12457 00003376 58                  <1> 	pop	eax
 12458                              <1> 	; if(AL>=0x10)
 12459 00003377 3C10                <1> 	cmp	al, 10h
 12460 00003379 7205                <1> 	jb	short lt8_16_2
 12461                              <1> 	; BH = 16
 12462                              <1>    	; set_scan_lines(16);
 12463 0000337B E8BAFEFFFF          <1> 	call	set_scan_lines
 12464                              <1> lt8_16_2:
 12465 00003380 C3                  <1> 	retn
 12466                              <1> 
 12467                              <1> load_gfx_user_chars:
 12468                              <1> 	; 08/01/2021
 12469                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
 12470                              <1> 	; 08/08/2016
 12471                              <1> 	; 10/07/2016
 12472                              <1> 	; Setup User-Defined Font for Graphics Mode (VGA)
 12473                              <1> 	;
 12474                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12475                              <1> 	; vgabios-0.7a (2011)
 12476                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12477                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_user_chars'
 12478                              <1> 
 12479                              <1> 	; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL)
 12480                              <1> 	; /* set 0x43 INT pointer */
 12481                              <1>     	; write_word(0x0, 0x43*4, BP);
 12482                              <1>     	; write_word(0x0, 0x43*4+2, ES);
 12483                              <1> 	
 12484                              <1> 	; 08/01/2021
 12485                              <1> 		
 12486                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
 12487                              <1>         ;                        01H = 14 rows
 12488                              <1>         ;                        02H = 25 rows
 12489                              <1>         ;                        03H = 43 rows
 12490                              <1>         ; CX   bytes per character definition
 12491                              <1>         ; DL   (when BL=0) custom number of character rows on screen
 12492                              <1>         ; EBP  address of font-definition information (user's mem space)
 12493                              <1> 
 12494                              <1> 	; 05/01/2021
 12495                              <1> 	;xor	eax, eax
 12496                              <1> 	;dec	eax ; 0FFFFFFFFh (user defined fonts)
 12497                              <1> 	;mov	[VGA_INT43H], eax
 12498                              <1> 
 12499                              <1> 	; 08/01/2021
 12500                              <1> 	; ebp = video font data (buffer) address
 12501 00003381 892D[26840100]      <1> 	mov	[VGA_INT43H], ebp
 12502                              <1> 
 12503                              <1> 	; switch (BL) {
 12504                              <1> 	; case 0:
 12505                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
 12506                              <1> 	;    break;
 12507 00003387 20DB                <1> 	and	bl, bl
 12508 00003389 7508                <1> 	jnz	short l_gfx_uc_1
 12509 0000338B 8815[A6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
 12510 00003391 EB23                <1> 	jmp	short l_gfx_uc_4
 12511                              <1> l_gfx_uc_1:
 12512                              <1> 	; case 1:
 12513                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
 12514                              <1> 	;    break;
 12515 00003393 FECB                <1> 	dec	bl
 12516 00003395 7509                <1> 	jnz	short l_gfx_uc_2
 12517                              <1> 	; bl = 1
 12518 00003397 C605[A6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
 12519 0000339E EB16                <1> 	jmp	short l_gfx_uc_4
 12520                              <1> l_gfx_uc_2:
 12521 000033A0 FECB                <1> 	dec	bl
 12522 000033A2 740B                <1> 	jz	short l_gfx_uc_3 ; bl = 2
 12523 000033A4 FECB                <1> 	dec	bl
 12524 000033A6 750E                <1> 	jnz	short l_gfx_uc_4 ; bl > 3
 12525                              <1> 	; bl = 3
 12526                              <1> 	; case 3:
 12527                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
 12528                              <1> 	;    break;
 12529 000033A8 C605[A6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
 12530                              <1> l_gfx_uc_3:
 12531                              <1>     	; case 2:
 12532                              <1>     	; default:
 12533                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
 12534                              <1> 	;    break;
 12535                              <1> 	; bl = 2 or bl > 3
 12536 000033AF C605[A6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
 12537                              <1>     	; }
 12538                              <1> l_gfx_uc_4:
 12539                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX);
 12540 000033B6 880D[A2660000]      <1> 	mov	[CHAR_HEIGHT], cl
 12541                              <1> 	; }
 12542 000033BC C3                  <1> 	retn
 12543                              <1> 
 12544                              <1> load_gfx_8_14_chars:
 12545                              <1> 	; 08/08/2016
 12546                              <1> 	; 10/07/2016
 12547                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
 12548                              <1> 	;
 12549                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12550                              <1> 	; vgabios-0.7a (2011)
 12551                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12552                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_14_chars'
 12553                              <1> 
 12554                              <1> 	; biosfn_load_gfx_8_14_chars (BL)
 12555                              <1> 	; /* set 0x43 INT pointer */
 12556                              <1>     	; write_word(0x0, 0x43*4, &vgafont14);
 12557                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
 12558 000033BD C705[26840100]-     <1> 	mov	dword [VGA_INT43H], vgafont14
 12559 000033C3 [10560100]          <1>
 12560                              <1> 		
 12561                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
 12562                              <1>         ;                         01H = 14 rows
 12563                              <1>         ;                         02H = 25 rows
 12564                              <1>         ;                         03H = 43 rows
 12565                              <1>         ; DL    (when BL=0) custom number of char rows on screen
 12566                              <1> 
 12567                              <1> 	; switch (BL) {
 12568                              <1> 	; case 0:
 12569                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
 12570                              <1> 	;    break;
 12571 000033C7 20DB                <1> 	and	bl, bl
 12572 000033C9 7508                <1> 	jnz	short l_gfx_8_14c_1
 12573 000033CB 8815[A6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
 12574 000033D1 EB23                <1> 	jmp	short l_gfx_8_14c_4
 12575                              <1> l_gfx_8_14c_1:
 12576                              <1> 	; case 1:
 12577                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
 12578                              <1> 	;    break;
 12579 000033D3 FECB                <1> 	dec	bl
 12580 000033D5 7509                <1> 	jnz	short l_gfx_8_14c_2
 12581                              <1> 	; bl = 1
 12582 000033D7 C605[A6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
 12583 000033DE EB16                <1> 	jmp	short l_gfx_8_14c_4
 12584                              <1> l_gfx_8_14c_2:
 12585 000033E0 FECB                <1> 	dec	bl
 12586 000033E2 740B                <1> 	jz	short l_gfx_8_14c_3 ; bl = 2
 12587 000033E4 FECB                <1> 	dec	bl
 12588 000033E6 750E                <1> 	jnz	short l_gfx_8_14c_4 ; bl > 3
 12589                              <1> 	; bl = 3
 12590                              <1> 	; case 3:
 12591                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
 12592                              <1> 	;    break;
 12593 000033E8 C605[A6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
 12594                              <1> l_gfx_8_14c_3:
 12595                              <1>     	; case 2:
 12596                              <1>     	; default:
 12597                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
 12598                              <1> 	;    break;
 12599                              <1> 	; bl = 2 or bl > 3
 12600 000033EF C605[A6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !
 12601                              <1>     	; }
 12602                              <1> l_gfx_8_14c_4:
 12603                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14);
 12604 000033F6 C605[A2660000]0E    <1>         mov     byte [CHAR_HEIGHT], 14
 12605                              <1> 	; }
 12606 000033FD C3                  <1> 	retn	
 12607                              <1> 
 12608                              <1> load_gfx_8_8_chars:
 12609                              <1> 	; 08/08/2016
 12610                              <1> 	; 10/07/2016
 12611                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
 12612                              <1> 	;
 12613                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12614                              <1> 	; vgabios-0.7a (2011)
 12615                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12616                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars'
 12617                              <1> 
 12618                              <1> 	; biosfn_load_gfx_8_8_dd_chars (BL)
 12619                              <1> 	; /* set 0x43 INT pointer */
 12620                              <1>     	; write_word(0x0, 0x43*4, &vgafont8);
 12621                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
 12622 000033FE C705[26840100]-     <1> 	mov	dword [VGA_INT43H], vgafont8
 12623 00003404 [104E0100]          <1>
 12624                              <1> 		
 12625                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
 12626                              <1>         ;                         01H = 14 rows
 12627                              <1>         ;                         02H = 25 rows
 12628                              <1>         ;                         03H = 43 rows
 12629                              <1>         ; DL    (when BL=0) custom number of char rows on screen
 12630                              <1> 
 12631                              <1> 	; switch (BL) {
 12632                              <1> 	; case 0:
 12633                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
 12634                              <1> 	;    break;
 12635 00003408 20DB                <1> 	and	bl, bl
 12636 0000340A 7508                <1> 	jnz	short l_gfx_8_8c_1
 12637 0000340C 8815[A6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
 12638 00003412 EB23                <1> 	jmp	short l_gfx_8_8c_4 	
 12639                              <1> l_gfx_8_8c_1:
 12640                              <1> 	; case 1:
 12641                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
 12642                              <1> 	;    break;
 12643 00003414 FECB                <1> 	dec	bl
 12644 00003416 7509                <1> 	jnz	short l_gfx_8_8c_2
 12645                              <1> 	; bl = 1
 12646 00003418 C605[A6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
 12647 0000341F EB16                <1> 	jmp	short l_gfx_8_8c_4 	
 12648                              <1> l_gfx_8_8c_2:
 12649 00003421 FECB                <1> 	dec	bl
 12650 00003423 740B                <1> 	jz	short l_gfx_8_8c_3 ; bl = 2
 12651 00003425 FECB                <1> 	dec	bl
 12652 00003427 750E                <1> 	jnz	short l_gfx_8_8c_4 ; bl > 3
 12653                              <1> 	; bl = 3
 12654                              <1> 	; case 3:
 12655                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
 12656                              <1> 	;    break;
 12657 00003429 C605[A6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
 12658                              <1> l_gfx_8_8c_3:
 12659                              <1>     	; case 2:
 12660                              <1>     	; default:
 12661                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
 12662                              <1> 	;    break;
 12663                              <1> 	; bl = 2 or bl > 3
 12664 00003430 C605[A6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
 12665                              <1>     	; }
 12666                              <1> l_gfx_8_8c_4:
 12667                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8);
 12668 00003437 C605[A2660000]08    <1>         mov     byte [CHAR_HEIGHT], 8
 12669                              <1> 	; }
 12670 0000343E C3                  <1> 	retn
 12671                              <1> 
 12672                              <1> load_gfx_8_16_chars:
 12673                              <1> 	; 08/08/2016
 12674                              <1> 	; 10/07/2016
 12675                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
 12676                              <1> 	;
 12677                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12678                              <1> 	; vgabios-0.7a (2011)
 12679                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12680                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_16_chars'
 12681                              <1> 
 12682                              <1> 	; biosfn_load_gfx_8_16_chars (BL)
 12683                              <1> 	; /* set 0x43 INT pointer */
 12684                              <1>     	; write_word(0x0, 0x43*4, &vgafont16);
 12685                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
 12686 0000343F C705[26840100]-     <1> 	mov	dword [VGA_INT43H], vgafont16
 12687 00003445 [10640100]          <1>
 12688                              <1> 		
 12689                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
 12690                              <1>         ;                         01H = 14 rows
 12691                              <1>         ;                         02H = 25 rows
 12692                              <1>         ;                         03H = 43 rows
 12693                              <1>         ; DL    (when BL=0) custom number of char rows on screen
 12694                              <1> 
 12695                              <1> 	; switch (BL) {
 12696                              <1> 	; case 0:
 12697                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
 12698                              <1> 	;    break;
 12699 00003449 20DB                <1> 	and	bl, bl
 12700 0000344B 7508                <1> 	jnz	short l_gfx_8_16c_1
 12701 0000344D 8815[A6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
 12702 00003453 EB23                <1> 	jmp	short l_gfx_8_16c_4 	
 12703                              <1> l_gfx_8_16c_1:
 12704                              <1> 	; case 1:
 12705                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
 12706                              <1> 	;    break;
 12707 00003455 FECB                <1> 	dec	bl
 12708 00003457 7509                <1> 	jnz	short l_gfx_8_16c_2
 12709                              <1> 	; bl = 1
 12710 00003459 C605[A6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
 12711 00003460 EB16                <1> 	jmp	short l_gfx_8_16c_4
 12712                              <1> l_gfx_8_16c_2:
 12713 00003462 FECB                <1> 	dec	bl
 12714 00003464 740B                <1> 	jz	short l_gfx_8_16c_3 ; bl = 2
 12715 00003466 FECB                <1> 	dec	bl
 12716 00003468 750E                <1> 	jnz	short l_gfx_8_16c_4 ; bl > 3
 12717                              <1> 	; bl = 3
 12718                              <1> 	; case 3:
 12719                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
 12720                              <1> 	;    break;
 12721 0000346A C605[A6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
 12722                              <1> l_gfx_8_16c_3:
 12723                              <1>     	; case 2:
 12724                              <1>     	; default:
 12725                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
 12726                              <1> 	;    break;
 12727                              <1> 	; bl = 2 or bl > 3
 12728 00003471 C605[A6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
 12729                              <1>     	; }
 12730                              <1> l_gfx_8_16c_4:
 12731                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16);
 12732 00003478 C605[A2660000]10    <1>         mov     byte [CHAR_HEIGHT], 16
 12733                              <1> 	; }
 12734 0000347F C3                  <1> 	retn
 12735                              <1> 			
 12736                              <1> get_font_info:
 12737                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 12738                              <1> 	; 08/01/2021 (TRDOS 386 v2.0.3)
 12739                              <1> 	; 19/09/2016
 12740                              <1> 	; 08/08/2016
 12741                              <1> 	; 10/07/2016
 12742                              <1> 	; Get Current Character Generator Info (VGA)
 12743                              <1> 	;
 12744                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 12745                              <1> 	; vgabios-0.7a (2011)
 12746                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 12747                              <1> 	; 'vgabios.c', 'biosfn_get_font_info'
 12748                              <1> 
 12749                              <1> 	; Modified for TRDOS 386 !
 12750                              <1> 	;
 12751                              <1> 	; INPUT ->
 12752                              <1> 	;    AX = 1130h
 12753                              <1> 	;    BL = 0 -> Get info for current VGA font
 12754                              <1> 	;	       (BH = unused)
 12755                              <1> 	;    19/09/2016
 12756                              <1> 	;    BL > 0 -> Get requested character font data
 12757                              <1> 	;	 BL = 1 -> vgafont8
 12758                              <1> 	;        BL = 2 -> vgafont14
 12759                              <1> 	;	 BL = 3 -> vgafont16   
 12760                              <1> 	;	;08/01/2021
 12761                              <1> 	;	 BL = 4 -> user defined 8x8 font
 12762                              <1> 	;	 BL = 5 -> user defined 8x14 font
 12763                              <1> 	;	 BL = 6 -> user defined 8x16 font
 12764                              <1> 	;	 BL > 6 -> Invalid function (for now!)
 12765                              <1> 	;	 BH = ASCII code of the first character
 12766                              <1> 	;	 ECX = Number of characters from the 1st char
 12767                              <1> 	;	 ECX >= 256 -> All (256-BH) characters
 12768                              <1> 	;	 ECX = 0 -> All characters (BH = unused)
 12769                              <1> 	;        EDX = User's Buffer Address	
 12770                              <1> 	; OUTPUT ->
 12771                              <1> 	;    AL = height (scanlines), bytes per character
 12772                              <1> 	;    AH = screen rows
 12773                              <1> 	;    Byte 16-23 of EAX = number of columns
 12774                              <1> 	;    Byte 24-31 of EAX = 
 12775                              <1> 	;	  0 -> default font (not configured yet)
 12776                              <1> 	;	  0FFh -> user defined font
 12777                              <1> 	;	  14 = vgafont14
 12778                              <1> 	;	   8 = vgafont8
 12779                              <1> 	;	  16 = vgafont16
 12780                              <1> 	;   If BL input > 0 -> 
 12781                              <1> 	;       EAX = Actual transfer count
 12782                              <1> 	;
 12783 00003480 20DB                <1> 	and	bl, bl
 12784 00003482 740F                <1> 	jz	short gfi_1
 12785                              <1> 	; invalid function (input)
 12786                              <1> 	; 08/01/2021
 12787 00003484 80FB04              <1> 	cmp	bl, 4
 12788 00003487 7263                <1> 	jb	short gfi_5
 12789 00003489 7441                <1> 	je	short gfi_3	
 12790 0000348B 80FB06              <1> 	cmp	bl, 6
 12791 0000348E 744C                <1> 	je	short gfi_4
 12792                              <1> 	; bh = 5 or bh > 6
 12793                              <1> gfi_0:
 12794 00003490 31C0                <1> 	xor	eax, eax ; 0
 12795 00003492 C3                  <1> 	retn
 12796                              <1> gfi_1:
 12797 00003493 A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT]
 12798 00003498 8A25[A6660000]      <1> 	mov	ah, [VGA_ROWS]
 12799 0000349E C1E010              <1> 	shl	eax, 16
 12800 000034A1 A0[A0660000]        <1> 	mov	al, [CRT_COLS]
 12801 000034A6 8B0D[26840100]      <1> 	mov	ecx, [VGA_INT43H]
 12802 000034AC 21C9                <1> 	and	ecx, ecx
 12803 000034AE 7418                <1> 	jz	short gfi_2 ; 0 = default font
 12804                              <1> 	; 08/01/2021
 12805 000034B0 FECC                <1> 	dec	ah ; 0FFh
 12806 000034B2 81F900400900        <1> 	cmp	ecx, VGAFONT16USER
 12807 000034B8 740E                <1> 	je	short gfi_2
 12808 000034BA 81F900500900        <1> 	cmp	ecx, VGAFONT8USER
 12809 000034C0 7406                <1> 	je	short gfi_2	
 12810 000034C2 8A25[A2660000]      <1> 	mov	ah, [CHAR_HEIGHT] ; font size = height
 12811                              <1> gfi_2:
 12812 000034C8 C1C010              <1> 	rol	eax, 16
 12813 000034CB C3                  <1> 	retn
 12814                              <1> gfi_3:
 12815                              <1> 	; 08/01/2021
 12816 000034CC F605[32100300]08    <1> 	test	byte [ufont], 08h ; 8x8 user font
 12817 000034D3 74BB                <1> 	jz	short gfi_0 ; not loaded !
 12818 000034D5 BE00500900          <1> 	mov	esi, VGAFONT8USER ; *
 12819                              <1> 	;mov	bl, 8
 12820                              <1> 	;jmp	short gfi_8
 12821 000034DA EB4A                <1> 	jmp	short gfi_10
 12822                              <1> gfi_4:
 12823                              <1> 	; 08/01/2021
 12824 000034DC F605[32100300]10    <1> 	test	byte [ufont], 10h ; 8x16 user font
 12825 000034E3 74AB                <1> 	jz	short gfi_0 ; not loaded !
 12826 000034E5 BE00400900          <1> 	mov	esi, VGAFONT16USER ; *
 12827 000034EA EB15                <1> 	jmp	short gfi_7
 12828                              <1> gfi_5:
 12829 000034EC 80FB02              <1> 	cmp	bl, 2
 12830 000034EF 7230                <1> 	jb	short gfi_9
 12831 000034F1 7709                <1> 	ja	short gfi_6
 12832                              <1> 	; BL = 2 -> vgafont14
 12833 000034F3 BE[10560100]        <1> 	mov	esi, vgafont14 ; *
 12834 000034F8 B30E                <1> 	mov	bl, 14
 12835 000034FA EB07                <1> 	jmp	short gfi_8 
 12836                              <1> gfi_6:
 12837                              <1> 	; BL = 3 -> vgafont16
 12838 000034FC BE[10640100]        <1> 	mov	esi, vgafont16 ; *
 12839                              <1> gfi_7:
 12840 00003501 B310                <1> 	mov	bl, 16
 12841                              <1> gfi_8:
 12842 00003503 89D7                <1> 	mov	edi, edx ; **
 12843 00003505 09C9                <1> 	or	ecx, ecx
 12844 00003507 7421                <1> 	jz	short gfi_11 ; all chars from the 00h
 12845                              <1> 	;mov	al, bh ; character index
 12846                              <1> 	; 03/08/2022
 12847 00003509 0FB6C7              <1> 	movzx	eax, bh
 12848 0000350C F6E3                <1> 	mul	bl ; char index * char height/size
 12849                              <1> 	;movzx	edx, ax
 12850                              <1> 	; 03/08/2022
 12851                              <1> 	;add	esi, edx ; *
 12852 0000350E 01C6                <1> 	add	esi, eax
 12853 00003510 31D2                <1> 	xor	edx, edx
 12854 00003512 FECA                <1> 	dec	dl 
 12855                              <1> 	; edx = 0FFh = 255
 12856                              <1> 	;mov	dx, 255
 12857 00003514 28FA                <1> 	sub	dl, bh
 12858                              <1> 	;inc	dx	
 12859                              <1> 	; 03/08/2022
 12860 00003516 42                  <1> 	inc	edx
 12861 00003517 39D1                <1> 	cmp	ecx, edx
 12862 00003519 770F                <1> 	ja	short gfi_11
 12863 0000351B 7411                <1> 	je	short gfi_12
 12864 0000351D 89D1                <1> 	mov	ecx, edx
 12865 0000351F EB0D                <1> 	jmp	short gfi_12
 12866                              <1> gfi_9:
 12867                              <1> 	;BL = 1 -> vgafont8
 12868 00003521 BE[104E0100]        <1> 	mov	esi, vgafont8 ; *
 12869                              <1> gfi_10:
 12870 00003526 B308                <1> 	mov	bl, 8
 12871 00003528 EBD9                <1> 	jmp	short gfi_8
 12872                              <1> gfi_11:
 12873                              <1> 	;mov	ecx, 256
 12874                              <1> 	; 03/08/2022
 12875 0000352A 29C9                <1> 	sub	ecx, ecx
 12876 0000352C FEC5                <1> 	inc	ch
 12877                              <1> 	; ecx = 100h 
 12878                              <1> gfi_12:
 12879                              <1> 	; 08/01/2021
 12880 0000352E 89C8                <1> 	mov	eax, ecx ; character count
 12881 00003530 30FF                <1> 	xor	bh, bh
 12882 00003532 66F7E3              <1> 	mul	bx ; char count * char height/size
 12883 00003535 89C1                <1>  	mov	ecx, eax
 12884                              <1> 
 12885                              <1> 	; ESI = source address in system space
 12886                              <1> 	; EDI = user's buffer address
 12887                              <1> 	; ECX = transfer (byte) count
 12888 00003537 E8F1D70000          <1> 	call	transfer_to_user_buffer
 12889 0000353C 89C8                <1> 	mov	eax, ecx ; actual transfer count
 12890 0000353E C3                  <1> 	retn
 12891                              <1> 
 12892                              <1> set_all_palette_reg:
 12893                              <1> 	; 03/08/2022
 12894                              <1> 	; 10/08/2016
 12895                              <1> 	; Set All Palette Registers and Overscan
 12896                              <1> 	; EDX = Address of 17 bytes; 
 12897                              <1> 	; an rgbRGB value for each of 16 palette
 12898                              <1> 	; registers plus one for the border.
 12899                              <1> 
 12900 0000353F 89D6                <1> 	mov	esi, edx ; user buffer
 12901                              <1> 	;mov	ecx, 17
 12902                              <1> 	; 03/08/2022
 12903 00003541 29C9                <1> 	sub	ecx, ecx
 12904 00003543 B111                <1> 	mov	cl, 17
 12905 00003545 89E7                <1> 	mov	edi, esp
 12906 00003547 83EC14              <1> 	sub	esp, 20	 	 
 12907 0000354A E828D80000          <1> 	call	transfer_from_user_buffer
 12908                              <1> 	;jc	VIDEO_RETURN
 12909                              <1> 
 12910 0000354F 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12911 00003553 EC                  <1> 	in	al, dx
 12912                              <1> 	;mov	cl, 0
 12913                              <1> 	; 03/08/2022
 12914 00003554 28C9                <1> 	sub	cl, cl
 12915                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12916                              <1> 	; 03/08/2022
 12917 00003556 B2C0                <1> 	mov	dl, 0C0h
 12918                              <1> set_palette_loop:
 12919 00003558 88C8                <1> 	mov	al, cl
 12920 0000355A EE                  <1> 	out	dx, al
 12921 0000355B 8A07                <1> 	mov	al, [edi]
 12922 0000355D EE                  <1> 	out	dx, al
 12923 0000355E 47                  <1> 	inc	edi
 12924 0000355F FEC1                <1> 	inc	cl
 12925 00003561 80F910              <1> 	cmp	cl, 10h
 12926 00003564 75F2                <1> 	jne	short set_palette_loop
 12927 00003566 B011                <1> 	mov	al, 11h
 12928 00003568 EE                  <1> 	out	dx, al
 12929 00003569 8A07                <1> 	mov	al, [edi]
 12930 0000356B EE                  <1> 	out	dx, al
 12931 0000356C B020                <1> 	mov	al, 20h
 12932 0000356E EE                  <1> 	out	dx, al
 12933                              <1> 	; ifdef VBOX
 12934                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12935                              <1> 	; 03/08/2022
 12936 0000356F B2DA                <1> 	mov	dl, 0DAh
 12937 00003571 EC                  <1> 	in	al, dx
 12938                              <1> 	; endif ; VBOX
 12939 00003572 83C414              <1> 	add	esp, 20
 12940 00003575 E941E5FFFF          <1> 	jmp	VIDEO_RETURN
 12941                              <1> 	
 12942                              <1> 	; 07/08/2022
 12943                              <1> toggle_intensity:
 12944                              <1> 	; 03/08/2022
 12945                              <1> 	; 10/08/2016
 12946                              <1> 	; Select Foreground Blink or Bold Background
 12947                              <1> 	; BL = 00h = enable bold backgrounds
 12948                              <1> 	;	    (16 background colors)
 12949                              <1>         ;      01h = enable blinking foreground
 12950                              <1> 	;	    (8 background colors)
 12951                              <1> 
 12952 0000357A 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12953 0000357E EC                  <1> 	in	al, dx
 12954                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12955                              <1> 	; 03/08/2022
 12956 0000357F B2C0                <1> 	mov	dl, 0C0h
 12957 00003581 B010                <1> 	mov	al, 10h
 12958 00003583 EE                  <1> 	out	dx, al
 12959                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 12960                              <1> 	; 03/08/2022
 12961 00003584 FEC2                <1> 	inc	dl ; dx = 3C1h
 12962 00003586 EC                  <1> 	in	al, dx
 12963 00003587 24F7                <1> 	and	al, 0F7h
 12964 00003589 80E301              <1> 	and	bl, 01h
 12965 0000358C C0E303              <1> 	shl	bl, 3
 12966 0000358F 08D8                <1> 	or	al, bl
 12967                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 12968                              <1> 	; 03/08/2022
 12969 00003591 FECA                <1> 	dec	dl ; dx = 3C0h
 12970 00003593 EE                  <1> 	out	dx, al
 12971 00003594 B020                <1> 	mov	al, 20h
 12972 00003596 EE                  <1> 	out	dx, al
 12973                              <1> 	; ifdef VBOX
 12974                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 12975                              <1> 	; 03/08/2022
 12976 00003597 B2DA                <1> 	mov	dl, 0DAh
 12977 00003599 EC                  <1> 	in	al, dx
 12978                              <1> 	; endif ; VBOX
 12979 0000359A E91CE5FFFF          <1> 	jmp	VIDEO_RETURN
 12980                              <1> 
 12981                              <1> 	; 07/08/2022
 12982                              <1> vga_palf_unknown:
 12983 0000359F 29C0                <1> 	sub	eax, eax ; 0 = invalid function
 12984 000035A1 E91AE5FFFF          <1>         jmp     _video_return
 12985                              <1> 
 12986                              <1> 	; 07/08/2022
 12987                              <1> vga_palf_101B:
 12988 000035A6 3C1B                <1> 	cmp	al, 1Bh
 12989                              <1> 	;jne	short vga_palf_unknown
 12990 000035A8 77F5                <1> 	ja	short vga_palf_unknown
 12991                              <1>  
 12992 000035AA E810F6FFFF          <1> 	call	gray_scale_summing
 12993 000035AF E907E5FFFF          <1>         jmp     VIDEO_RETURN 
 12994                              <1> 	
 12995                              <1> vga_pal_funcs:
 12996                              <1> 	; 07/08/2022
 12997                              <1> 	; 10/08/2016
 12998                              <1> 	; VGA Palette functions
 12999                              <1> 	;
 13000                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 13001                              <1> 	; vgabios-0.7a (2011)
 13002                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
 13003                              <1> 	; 'vgabios.c', 'vgarom.asm'
 13004                              <1> 
 13005 000035B4 3C00                <1> 	cmp	al, 0
 13006 000035B6 7467                <1>         je      short set_single_palette_reg
 13007                              <1> vga_palf_1002:
 13008 000035B8 3C02                <1> 	cmp	al, 2
 13009 000035BA 7483                <1>         je      short set_all_palette_reg
 13010                              <1> 	; 07/08/2022
 13011 000035BC 7702                <1> 	ja	short vga_palf_1003
 13012 000035BE EB5D                <1> 	jmp	short set_overscan_border_color 
 13013                              <1> 	; 07/08/2022
 13014                              <1> ;vga_palf_1001:
 13015                              <1> ;	cmp	al, 1
 13016                              <1> ;	je	short set_overscan_border_color
 13017                              <1> vga_palf_1003:
 13018 000035C0 3C03                <1> 	cmp	al, 3
 13019 000035C2 74B6                <1> 	je	short toggle_intensity
 13020                              <1> vga_palf_1007:
 13021 000035C4 3C07                <1> 	cmp	al, 7
 13022 000035C6 747F                <1>         je      short get_single_palette_reg
 13023 000035C8 72D5                <1> 	jb	short vga_palf_unknown
 13024                              <1> vga_palf_1008:
 13025 000035CA 3C08                <1> 	cmp	al, 8
 13026 000035CC 7477                <1>         je      short read_overscan_border_color
 13027                              <1> vga_palf_1009:
 13028 000035CE 3C09                <1> 	cmp	al, 9
 13029                              <1> 	;je	short get_all_palette_reg
 13030                              <1> 	; 07/08/2022
 13031 000035D0 7505                <1> 	jne	short vga_palf_1010
 13032 000035D2 E966010000          <1> 	jmp	get_all_palette_reg
 13033                              <1> vga_palf_1010:
 13034 000035D7 3C10                <1> 	cmp	al, 10h
 13035                              <1> 	;je 	short set_single_dac_reg
 13036                              <1> 	; 07/08/2022
 13037 000035D9 7707                <1> 	ja	short vga_palf_1012
 13038 000035DB 72C2                <1> 	jb	short vga_palf_unknown
 13039 000035DD E908010000          <1> 	jmp	set_single_dac_reg
 13040                              <1> vga_palf_1012:
 13041 000035E2 3C12                <1> 	cmp	al, 12h
 13042                              <1> 	;je	short set_all_dac_reg
 13043                              <1> 	; 07/08/2022
 13044 000035E4 7707                <1> 	ja	short vga_palf_1013
 13045 000035E6 72B7                <1> 	jb	short vga_palf_unknown
 13046 000035E8 E916010000          <1> 	jmp	set_all_dac_reg	
 13047                              <1> vga_palf_1013:
 13048 000035ED 3C13                <1> 	cmp	al, 13h
 13049                              <1> 	;je	short select_video_dac_color_page
 13050                              <1> 	; 07/08/2022
 13051 000035EF 7505                <1> 	jne	short vga_palf_1015
 13052 000035F1 E992010000          <1> 	jmp	select_video_dac_color_page
 13053                              <1> vga_palf_1015:
 13054 000035F6 3C15                <1> 	cmp	al, 15h
 13055                              <1> 	;je	short read_single_dac_reg
 13056                              <1> 	; 07/08/2022
 13057 000035F8 7707                <1> 	ja	short vga_palf_1017
 13058 000035FA 72A3                <1> 	jb	short vga_palf_unknown
 13059 000035FC E98D000000          <1> 	jmp	read_single_dac_reg
 13060                              <1> vga_palf_1017:
 13061 00003601 3C17                <1> 	cmp	al, 17h
 13062                              <1> 	;je	short read_all_dac_reg
 13063                              <1> 	; 07/08/2022
 13064 00003603 7707                <1> 	ja	short vga_palf_1018
 13065 00003605 7298                <1> 	jb	short vga_palf_unknown
 13066 00003607 E9A0000000          <1> 	jmp	read_all_dac_reg
 13067                              <1> vga_palf_1018:
 13068 0000360C 3C18                <1> 	cmp	al, 18h
 13069 0000360E 7464                <1>         je	short set_pel_mask
 13070                              <1> vga_palf_1019:
 13071 00003610 3C19                <1> 	cmp	al, 19h
 13072 00003612 746C                <1>         je	short read_pel_mask
 13073                              <1> vga_palf_101A:
 13074 00003614 3C1A                <1> 	cmp	al, 1Ah
 13075                              <1>         ;je	short read_video_dac_state
 13076                              <1> 	; 07/08/2022
 13077 00003616 758E                <1> 	jne	short vga_palf_101B
 13078 00003618 E9AD010000          <1> 	jmp	read_video_dac_state
 13079                              <1> 
 13080                              <1> 	; 07/08/2022
 13081                              <1> set_overscan_border_color:
 13082                              <1> 	; 10/08/2016
 13083                              <1> 	; Set Overscan/Border Color Register
 13084                              <1> 	; BH = 6-bit RGB color to display 
 13085                              <1> 	;      for that attribute
 13086                              <1> 	
 13087 0000361D B311                <1> 	mov	bl, 11h
 13088                              <1>   	; 07/08/2022
 13089                              <1> 	;jmp	short set_single_palette_reg
 13090                              <1> 
 13091                              <1> set_single_palette_reg:
 13092                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 13093                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
 13094                              <1> 	; 10/08/2016
 13095                              <1> 	; Set One Palette Register
 13096                              <1> 	; BL = register number to set
 13097                              <1> 	;     (a 4-bit attribute nibble: 00h-0Fh)
 13098                              <1> 	; BH = 6-bit RGB color to display 
 13099                              <1> 	;      for that attribute
 13100                              <1> 
 13101 0000361F 80FB14              <1> 	cmp	bl, 14h
 13102                              <1> 	;;ja	short no_actl_reg1
 13103                              <1> 	;ja	VIDEO_RETURN
 13104                              <1> 	; 03/08/2022
 13105 00003622 7605                <1> 	jna	short sspr_1
 13106 00003624 E992E4FFFF          <1> 	jmp	VIDEO_RETURN
 13107                              <1> sspr_1:
 13108                              <1> 	;push	ax
 13109                              <1> 	;push	dx
 13110                              <1> 	; 12/04/2021
 13111 00003629 50                  <1> 	push	eax
 13112 0000362A 52                  <1> 	push	edx
 13113 0000362B 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13114 0000362F EC                  <1> 	in	al, dx
 13115                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13116                              <1> 	; 03/08/2022
 13117 00003630 B2C0                <1> 	mov	dl, 0C0h
 13118 00003632 88D8                <1> 	mov	al, bl
 13119 00003634 EE                  <1> 	out	dx, al
 13120 00003635 88F8                <1> 	mov	al, bh
 13121 00003637 EE                  <1> 	out	dx, al
 13122 00003638 B020                <1> 	mov	al, 20h
 13123 0000363A EE                  <1> 	out	dx, al
 13124                              <1> 	; ifdef VBOX
 13125                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13126                              <1> 	; 03/08/2022
 13127 0000363B B2DA                <1> 	mov	dl, 0DAh
 13128 0000363D EC                  <1> 	in	al, dx
 13129                              <1> 	; endif ; VBOX
 13130                              <1> 	;pop	dx
 13131                              <1> 	;pop	ax
 13132                              <1> 	; 12/04/2021
 13133 0000363E 5A                  <1> 	pop	edx
 13134 0000363F 58                  <1> 	pop	eax
 13135                              <1> ;no_actl_reg1:
 13136 00003640 E976E4FFFF          <1> 	jmp	VIDEO_RETURN
 13137                              <1> 
 13138                              <1> 	; 07/08/2022
 13139                              <1> read_overscan_border_color:
 13140                              <1> 	; 10/08/2016
 13141                              <1> 	; Read Overscan Register
 13142                              <1> 	; OUTPUT:
 13143                              <1> 	; BH = current rgbRGB value 
 13144                              <1> 	;      of the overscan/border register
 13145                              <1> 
 13146 00003645 B311                <1> 	mov	bl, 11h
 13147                              <1> 	; 07/08/2022
 13148                              <1> 	;jmp	short get_single_palette_reg
 13149                              <1> 
 13150                              <1> get_single_palette_reg:
 13151                              <1> 	; 03/08/2022
 13152                              <1> 	; 10/08/2016
 13153                              <1> 	; Read One Palette Register
 13154                              <1>         ; INPUT:
 13155                              <1> 	; BL = Palette register to read (00h-0Fh)
 13156                              <1> 	; OUTPUT:
 13157                              <1> 	; BH = Current rgbRGB value of specified register
 13158                              <1> 	;      for that attribute
 13159                              <1> 
 13160 00003647 80FB14              <1> 	cmp	bl, 14h
 13161                              <1> 	;;ja	short no_actl_reg2
 13162                              <1> 	;ja	VIDEO_RETURN
 13163                              <1> 	; 03/08/2022
 13164 0000364A 7605                <1> 	jna	short gspr_1
 13165 0000364C E96AE4FFFF          <1> 	jmp	VIDEO_RETURN
 13166                              <1> gspr_1:
 13167 00003651 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13168                              <1> 	; 03/08/2022
 13169 00003655 B2DA                <1> 	mov	dl, 0DAh
 13170 00003657 EC                  <1> 	in	al, dx
 13171                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13172                              <1> 	; 03/08/2022
 13173 00003658 B2C0                <1> 	mov	dl, 0C0h
 13174 0000365A 88D8                <1> 	mov	al, bl
 13175 0000365C EE                  <1> 	out	dx, al
 13176                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13177                              <1> 	; 03/08/2022
 13178 0000365D FEC2                <1> 	inc	dl ; dx = 3C1h
 13179 0000365F EC                  <1> 	in	al, dx
 13180 00003660 8844240D            <1> 	mov	[esp+13], al ; bh
 13181                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13182                              <1> 	; 03/08/2022
 13183 00003664 B2DA                <1> 	mov	dl, 0DAh
 13184 00003666 EC                  <1> 	in	al, dx
 13185                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13186                              <1> 	; 03/08/2022
 13187 00003667 B2C0                <1> 	mov	dl, 0C0h
 13188 00003669 B020                <1> 	mov	al, 20h
 13189 0000366B EE                  <1> 	out	dx, al
 13190                              <1> 	; ifdef VBOX
 13191                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13192                              <1> 	; 03/08/2022
 13193 0000366C B2DA                <1> 	mov	dl, 0DAh
 13194 0000366E EC                  <1> 	in	al, dx
 13195                              <1> 	; endif ; VBOX
 13196 0000366F E947E4FFFF          <1> 	jmp	VIDEO_RETURN
 13197                              <1> 
 13198                              <1> set_pel_mask:
 13199                              <1> 	; 10/08/2016
 13200                              <1> 	; BL = mask value
 13201 00003674 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
 13202 00003678 88D8                <1> 	mov	al, bl
 13203 0000367A EE                  <1> 	out	dx, al
 13204 0000367B E93BE4FFFF          <1> 	jmp	VIDEO_RETURN
 13205                              <1> 
 13206                              <1> read_pel_mask:
 13207                              <1> 	; 10/08/2016
 13208                              <1> 	; Output: BL = mask value 
 13209 00003680 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
 13210 00003684 EC                  <1> 	in	al, dx
 13211 00003685 8844240C            <1> 	mov	[esp+12], al ; bl
 13212 00003689 E92DE4FFFF          <1> 	jmp	VIDEO_RETURN
 13213                              <1> 
 13214                              <1> read_single_dac_reg:
 13215                              <1> 	; 02/08/2022
 13216                              <1> 	; 10/08/2016
 13217                              <1> 	; Read One DAC Color Register
 13218                              <1> 	; INPUT:
 13219                              <1> 	; BX = color register to read (0-255)
 13220                              <1> 	; OUTPUT:
 13221                              <1> 	; CH = green value (00h-3Fh)
 13222                              <1>         ; CL = blue value  (00h-3Fh)
 13223                              <1>         ; DH = red value   (00h-3Fh)
 13224                              <1> 
 13225 0000368E 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 13226 00003692 88D8                <1> 	mov	al, bl
 13227 00003694 EE                  <1> 	out	dx, al
 13228                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13229                              <1> 	; 02/08/2022
 13230 00003695 B2C9                <1> 	mov	dl, 0C9h
 13231 00003697 EC                  <1> 	in	al, dx
 13232 00003698 88442415            <1> 	mov	[esp+21], al ; dh
 13233 0000369C EC                  <1> 	in	al, dx
 13234 0000369D 88C5                <1> 	mov	ch, al
 13235 0000369F EC                  <1> 	in	al, dx
 13236 000036A0 88C1                <1> 	mov	cl, al
 13237 000036A2 66894C2410          <1> 	mov	[esp+16], cx ; cx
 13238 000036A7 E90FE4FFFF          <1> 	jmp	VIDEO_RETURN
 13239                              <1> 
 13240                              <1> read_all_dac_reg:
 13241                              <1> 	; 02/08/2022
 13242                              <1> 	; 12/08/2016
 13243                              <1> 	; 11/08/2016
 13244                              <1> 	; 10/08/2016
 13245                              <1> 	; Read a Block of DAC Color Registers
 13246                              <1>         ; BX = first DAC register to read (0-00FFh)
 13247                              <1>         ; ECX = number of registers to read (0-00FFh)
 13248                              <1>         ; EDX = addr of a buffer to hold R,G,B values
 13249                              <1> 	;	(CX*3 bytes long)
 13250                              <1> 
 13251 000036AC 89D7                <1> 	mov	edi, edx ; user buffer
 13252 000036AE 89CA                <1> 	mov	edx, ecx
 13253                              <1> 	;shl	dx, 1 ; *2
 13254                              <1> 	; 02/08/2022
 13255 000036B0 D1E2                <1> 	shl	edx, 1
 13256 000036B2 01CA                <1> 	add	edx, ecx ; edx = 3*ecx
 13257 000036B4 89E5                <1> 	mov	ebp, esp
 13258 000036B6 89EE                <1> 	mov	esi, ebp
 13259 000036B8 29D6                <1> 	sub	esi, edx
 13260 000036BA 6683E6FC            <1> 	and	si, 0FFFCh ; (dword alignment)
 13261 000036BE 89F4                <1> 	mov	esp, esi
 13262 000036C0 52                  <1> 	push	edx ; 3*ecx
 13263 000036C1 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 13264 000036C5 88D8                <1> 	mov	al, bl
 13265 000036C7 EE                  <1> 	out	dx, al
 13266 000036C8 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
 13267 000036CC 89F3                <1> 	mov	ebx, esi
 13268                              <1> read_dac_loop:
 13269 000036CE EC                  <1> 	in	al, dx
 13270 000036CF 8803                <1> 	mov	[ebx], al
 13271 000036D1 43                  <1> 	inc	ebx
 13272 000036D2 EC                  <1> 	in	al, dx
 13273 000036D3 8803                <1> 	mov	[ebx], al
 13274 000036D5 43                  <1> 	inc	ebx
 13275 000036D6 EC                  <1> 	in	al, dx
 13276 000036D7 8803                <1> 	mov	[ebx], al
 13277 000036D9 43                  <1> 	inc	ebx
 13278                              <1> 	;dec	cx
 13279                              <1> 	; 02/08/2022
 13280 000036DA 49                  <1> 	dec	ecx
 13281 000036DB 75F1                <1> 	jnz	short read_dac_loop
 13282 000036DD 59                  <1> 	pop	ecx ; 3*ecx
 13283                              <1> 	; ECX = transfer (byte) count
 13284                              <1> 	; ESI = source address in system space
 13285                              <1> 	; EDI = user's buffer address
 13286 000036DE E84AD60000          <1> 	call	transfer_to_user_buffer
 13287 000036E3 89EC                <1> 	mov	esp, ebp
 13288 000036E5 E9D1E3FFFF          <1> 	jmp	VIDEO_RETURN
 13289                              <1> 
 13290                              <1> set_single_dac_reg:
 13291                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 13292                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
 13293                              <1> 	; 10/08/2016
 13294                              <1> 	; Set One DAC Color Register
 13295                              <1> 	; BX = color register to set (0-255)
 13296                              <1>         ; CH = green value (00h-3Fh)
 13297                              <1>         ; CL = blue value  (00h-3Fh)
 13298                              <1>         ; DH = red value   (00h-3Fh)
 13299                              <1> 
 13300                              <1> 	;push	dx
 13301                              <1> 	; 12/04/2021
 13302 000036EA 52                  <1> 	push	edx
 13303 000036EB 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13304 000036EF 88D8                <1> 	mov	al, bl
 13305 000036F1 EE                  <1> 	out	dx, al
 13306                              <1> 	;;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13307                              <1> 	;inc	dx
 13308                              <1> 	; 03/08/2022
 13309 000036F2 FEC2                <1> 	inc	dl
 13310                              <1> 	;pop	ax
 13311                              <1> 	; 12/04/2021
 13312 000036F4 58                  <1> 	pop	eax
 13313 000036F5 88E0                <1> 	mov	al, ah
 13314 000036F7 EE                  <1> 	out	dx, al
 13315 000036F8 88E8                <1> 	mov	al, ch
 13316 000036FA EE                  <1> 	out	dx, al
 13317 000036FB 88C8                <1> 	mov	al, cl
 13318 000036FD EE                  <1> 	out	dx, al
 13319 000036FE E9B8E3FFFF          <1> 	jmp	VIDEO_RETURN
 13320                              <1> 
 13321                              <1> set_all_dac_reg:
 13322                              <1> 	; 02/08/2022 
 13323                              <1> 	; 12/08/2016
 13324                              <1> 	; 11/08/2016
 13325                              <1> 	; 10/08/2016
 13326                              <1> 	; Set a Block of DAC Color Register
 13327                              <1> 	; BX = first DAC register to set (0-00FFh)
 13328                              <1> 	; ECX = number of registers to set (0-00FFh)
 13329                              <1> 	; EDX = addr of a table of R,G,B values 
 13330                              <1> 	;	(it will be CX*3 bytes long)
 13331                              <1> 
 13332 00003703 89D6                <1> 	mov	esi, edx ; user buffer
 13333 00003705 89CA                <1> 	mov	edx, ecx
 13334                              <1> 	;shl	cx, 1 ; *2
 13335                              <1> 	; 02/08/2022
 13336 00003707 D1E1                <1> 	shl	ecx, 1
 13337 00003709 01D1                <1> 	add	ecx, edx ; ecx = 3*ecx
 13338 0000370B 89E5                <1> 	mov	ebp, esp
 13339 0000370D 89EF                <1> 	mov	edi, ebp
 13340 0000370F 29CF                <1> 	sub	edi, ecx
 13341 00003711 6683E7FC            <1> 	and	di, 0FFFCh ; (dword alignment)
 13342 00003715 89FC                <1> 	mov	esp, edi
 13343 00003717 E85BD60000          <1> 	call	transfer_from_user_buffer
 13344                              <1> 	;jc	VIDEO_RETURN
 13345                              <1> 
 13346 0000371C 89D1                <1> 	mov	ecx, edx
 13347 0000371E 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 13348 00003722 88D8                <1> 	mov	al, bl
 13349 00003724 EE                  <1> 	out	dx, al
 13350                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 13351                              <1> 	; 02/08/2022
 13352 00003725 FEC2                <1> 	inc	dl
 13353                              <1> set_dac_loop:
 13354 00003727 8A07                <1> 	mov	al, [edi]
 13355 00003729 EE                  <1> 	out	dx, al
 13356 0000372A 47                  <1> 	inc	edi
 13357 0000372B 8A07                <1> 	mov	al, [edi]
 13358 0000372D EE                  <1> 	out	dx, al
 13359 0000372E 47                  <1> 	inc	edi
 13360 0000372F 8A07                <1> 	mov	al, [edi]
 13361 00003731 EE                  <1> 	out	dx, al
 13362 00003732 47                  <1> 	inc	edi
 13363                              <1> 	;dec	cx
 13364                              <1> 	; 02/08/2022
 13365 00003733 49                  <1> 	dec	ecx
 13366 00003734 75F1                <1> 	jnz	short set_dac_loop
 13367 00003736 89EC                <1> 	mov	esp, ebp
 13368 00003738 E97EE3FFFF          <1> 	jmp	VIDEO_RETURN
 13369                              <1> 
 13370                              <1> get_all_palette_reg:
 13371                              <1> 	; 03/08/2022
 13372                              <1> 	; 10/08/2016
 13373                              <1> 	; Read All Palette Registers
 13374                              <1> 	; EDX = Address of 17-byte buffer 
 13375                              <1> 	;	to receive data
 13376                              <1> 	
 13377 0000373D 89D7                <1> 	mov	edi, edx
 13378 0000373F 89E3                <1> 	mov	ebx, esp
 13379 00003741 89DE                <1> 	mov	esi, ebx
 13380 00003743 83EC14              <1> 	sub	esp, 20	 
 13381                              <1> 
 13382 00003746 B100                <1> 	mov	cl, 0
 13383                              <1> get_palette_loop:
 13384 00003748 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13385 0000374C EC                  <1> 	in	al, dx
 13386                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13387                              <1> 	; 03/08/2022
 13388 0000374D B2C0                <1> 	mov	dl, 0C0h
 13389 0000374F 88C8                <1> 	mov	al, cl
 13390 00003751 EE                  <1> 	out	dx, al
 13391                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13392                              <1> 	; 03/08/2022
 13393                              <1> 	;mov	dl, 0C1h
 13394 00003752 FEC2                <1> 	inc	dl
 13395 00003754 EC                  <1> 	in	al, dx
 13396 00003755 8803                <1> 	mov	[ebx], al
 13397 00003757 43                  <1> 	inc	ebx
 13398 00003758 FEC1                <1> 	inc	cl
 13399 0000375A 80F910              <1> 	cmp	cl, 10h
 13400 0000375D 75E9                <1> 	jne	short get_palette_loop
 13401                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13402                              <1> 	; 03/08/2022
 13403 0000375F B2DA                <1> 	mov	dl, 0DAh
 13404 00003761 EC                  <1> 	in	al, dx
 13405                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13406                              <1> 	; 03/08/2022
 13407 00003762 B2C0                <1> 	mov	dl, 0C0h
 13408 00003764 B011                <1> 	mov	al, 11h
 13409 00003766 EE                  <1> 	out	dx, al
 13410                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13411                              <1> 	; 03/08/2022
 13412 00003767 FEC2                <1> 	inc	dl ; dx = 3C1h
 13413 00003769 EC                  <1> 	in	al, dx
 13414 0000376A 8803                <1> 	mov	[ebx], al
 13415                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13416                              <1> 	; 03/08/2022
 13417 0000376C B2DA                <1> 	mov	dl, 0DAh
 13418 0000376E EC                  <1> 	in	al, dx
 13419                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13420                              <1> 	; 03/08/2022
 13421 0000376F B2C0                <1> 	mov	dl, 0C0h
 13422 00003771 B020                <1> 	mov	al, 20h
 13423 00003773 EE                  <1> 	out	dx, al
 13424                              <1> 	; ifdef VBOX
 13425                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13426                              <1> 	; 03/08/2022
 13427 00003774 B2DA                <1> 	mov	dl, 0DAh
 13428 00003776 EC                  <1> 	in	al, dx
 13429                              <1> 	; endif ; VBOX
 13430                              <1> 
 13431                              <1> 	;mov	ecx, 17 ; transfer (byte) count
 13432                              <1> 	; 03/08/2022
 13433 00003777 29C9                <1> 	sub	ecx, ecx
 13434 00003779 B111                <1> 	mov	cl, 17	
 13435                              <1> 
 13436                              <1> 	; ESI = source address in system space
 13437                              <1> 	; EDI = user's buffer address
 13438 0000377B E8ADD50000          <1> 	call	transfer_to_user_buffer
 13439                              <1> 
 13440 00003780 83C414              <1> 	add	esp, 20
 13441 00003783 E933E3FFFF          <1> 	jmp	VIDEO_RETURN
 13442                              <1> 
 13443                              <1> select_video_dac_color_page:
 13444                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5, code optimization)
 13445                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
 13446                              <1> 	; 10/08/2016
 13447                              <1> 	; DAC Color Paging Functions
 13448                              <1> 	; BL = 00H = select color paging mode
 13449                              <1>         ;       BH = paging mode
 13450                              <1>         ;            00h = 4 blocks of 64 registers
 13451                              <1>         ;            01h = 16 blocks of 16 registers
 13452                              <1> 	; BL = 01H = activate color page
 13453                              <1>         ;       BH = DAC color page number
 13454                              <1>         ;            00h-03h (4-page/64-reg mode)
 13455                              <1>         ;            00h-0Fh (16-page/16-reg mode)
 13456                              <1> 
 13457 00003788 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13458 0000378C EC                  <1> 	in	al, dx
 13459                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13460                              <1> 	; 02/08/2022
 13461 0000378D B240                <1> 	mov	dl, 40h
 13462 0000378F B010                <1> 	mov	al, 10h
 13463 00003791 EE                  <1> 	out	dx, al
 13464                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13465                              <1> 	; 02/08/2022
 13466 00003792 FEC2                <1> 	inc	dl ; mov dl, 0C1h
 13467 00003794 EC                  <1> 	in	al, dx
 13468 00003795 80E301              <1> 	and	bl, 01h
 13469 00003798 750C                <1> 	jnz	short set_dac_page
 13470 0000379A 247F                <1> 	and	al, 07Fh
 13471 0000379C C0E707              <1> 	shl	bh, 7
 13472 0000379F 08F8                <1> 	or	al, bh
 13473                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13474                              <1> 	; 02/08/2022
 13475 000037A1 FECA                <1> 	dec	dl ; mov dl, 0C0h
 13476 000037A3 EE                  <1> 	out	dx, al
 13477 000037A4 EB19                <1> 	jmp	short set_actl_normal
 13478                              <1> set_dac_page:
 13479                              <1> 	;push	ax
 13480                              <1> 	; 12/04/2021
 13481 000037A6 50                  <1> 	push	eax
 13482 000037A7 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13483 000037AB EC                  <1> 	in	al, dx
 13484                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13485                              <1> 	; 02/08/2022
 13486 000037AC B2C0                <1> 	mov	dl, 0C0h
 13487 000037AE B014                <1> 	mov	al, 14h
 13488 000037B0 EE                  <1> 	out	dx, al
 13489                              <1> 	;pop	ax
 13490                              <1> 	; 12/04/2021
 13491 000037B1 58                  <1> 	pop	eax
 13492 000037B2 2480                <1> 	and	al, 80h
 13493 000037B4 7503                <1> 	jnz	short set_dac_16_page
 13494 000037B6 C0E702              <1> 	shl	bh, 2
 13495                              <1> set_dac_16_page:
 13496 000037B9 80E70F              <1> 	and	bh, 0Fh
 13497 000037BC 88F8                <1> 	mov	al, bh
 13498 000037BE EE                  <1> 	out	dx, al
 13499                              <1> set_actl_normal:
 13500 000037BF B020                <1> 	mov	al, 20h
 13501 000037C1 EE                  <1> 	out	dx, al
 13502                              <1> 	; ifdef VBOX
 13503                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13504                              <1> 	; 02/08/2022
 13505 000037C2 B2DA                <1> 	mov	dl, 0DAh
 13506 000037C4 EC                  <1> 	in	al, dx
 13507                              <1> 	; endif ; VBOX
 13508 000037C5 E9F1E2FFFF          <1> 	jmp	VIDEO_RETURN
 13509                              <1> 
 13510                              <1> read_video_dac_state:
 13511                              <1> 	; 10/08/2016
 13512                              <1> 	; Query DAC Color Paging State
 13513                              <1> 	; Output:
 13514                              <1> 	; BH = current active DAC color page
 13515                              <1>         ; BL = current active DAC paging mode
 13516                              <1> 
 13517 000037CA 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13518 000037CE EC                  <1> 	in	al, dx
 13519 000037CF 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13520 000037D3 B010                <1> 	mov	al, 10h
 13521 000037D5 EE                  <1> 	out	dx, al
 13522 000037D6 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13523 000037DA EC                  <1> 	in	al, dx
 13524 000037DB 88C3                <1> 	mov	bl, al
 13525 000037DD C0EB07              <1> 	shr	bl, 7
 13526 000037E0 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13527 000037E4 EC                  <1> 	in	al, dx
 13528 000037E5 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13529 000037E9 B014                <1> 	mov	al, 14h
 13530 000037EB EE                  <1> 	out	dx, al
 13531 000037EC 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 13532 000037F0 EC                  <1> 	in	al, dx
 13533 000037F1 88C7                <1> 	mov	bh, al
 13534 000037F3 80E70F              <1> 	and	bh, 0Fh
 13535 000037F6 F6C301              <1> 	test	bl, 01
 13536 000037F9 7503                <1> 	jnz	short get_dac_16_page
 13537 000037FB C0EF02              <1> 	shr	bh, 2
 13538                              <1> get_dac_16_page:
 13539 000037FE 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13540 00003802 EC                  <1> 	in	al, dx
 13541 00003803 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 13542 00003807 B020                <1> 	mov	al, 20h
 13543 00003809 EE                  <1> 	out	dx, al
 13544                              <1> 	; ifdef VBOX
 13545 0000380A 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 13546 0000380E EC                  <1> 	in	al, dx
 13547                              <1> 	; endif ; VBOX 
 13548 0000380F 66895C240C          <1> 	mov	[esp+12], bx ; bx
 13549 00003814 E9A2E2FFFF          <1> 	jmp	VIDEO_RETURN
 13550                              <1> 
 13551                              <1> ; 23/11/2020 - TRDOS 386 v2.0.3
 13552                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
 13553                              <1> ;	for TRDOS 386 v2 kernel (video bios)
 13554                              <1> 
 13555                              <1> ; BOCH/QEMU VBE2 VGA BIOS code 
 13556                              <1> ;	by Jeroen Janssen (2002)
 13557                              <1> ;	by Volker Rupper (2003-2020)
 13558                              <1> ; vbe.c (02/01/2020) 
 13559                              <1> 
 13560                              <1> ; vbe.h (02/01/2020)
 13561                              <1> 
 13562                              <1> VBE_DISPI_BANK_ADDRESS	equ	0A0000h
 13563                              <1> VBE_DISPI_BANK_SIZE_KB	equ	64
 13564                              <1> 
 13565                              <1> VBE_DISPI_MAX_XRES	equ	2560
 13566                              <1> VBE_DISPI_MAX_YRES	equ	1600
 13567                              <1> 
 13568                              <1> VBE_DISPI_IOPORT_INDEX	equ	01CEh
 13569                              <1> VBE_DISPI_IOPORT_DATA	equ	01CFh
 13570                              <1> 
 13571                              <1> VBE_DISPI_INDEX_ID	equ	00h
 13572                              <1> VBE_DISPI_INDEX_XRES	equ	01h
 13573                              <1> VBE_DISPI_INDEX_YRES	equ	02h
 13574                              <1> VBE_DISPI_INDEX_BPP	equ	03h
 13575                              <1> VBE_DISPI_INDEX_ENABLE	equ	04h
 13576                              <1> VBE_DISPI_INDEX_BANK	equ	05h
 13577                              <1> VBE_DISPI_INDEX_VIRT_WIDTH equ	06h
 13578                              <1> VBE_DISPI_INDEX_VIRT_HEIGHT equ	07h
 13579                              <1> VBE_DISPI_INDEX_X_OFFSET equ	08h
 13580                              <1> VBE_DISPI_INDEX_Y_OFFSET equ	09h
 13581                              <1> VBE_DISPI_INDEX_VIDEO_MEMORY_64K equ 0Ah
 13582                              <1> VBE_DISPI_INDEX_DDC	equ	0Bh
 13583                              <1> 
 13584                              <1> VBE_DISPI_ID0		equ	0B0C0h
 13585                              <1> VBE_DISPI_ID1		equ	0B0C1h
 13586                              <1> VBE_DISPI_ID2		equ	0B0C2h
 13587                              <1> VBE_DISPI_ID3		equ	0B0C3h
 13588                              <1> VBE_DISPI_ID4		equ	0B0C4h
 13589                              <1> VBE_DISPI_ID5		equ	0B0C5h
 13590                              <1> 
 13591                              <1> VBE_DISPI_DISABLED	equ	00h
 13592                              <1> VBE_DISPI_ENABLED	equ	01h
 13593                              <1> VBE_DISPI_GETCAPS	equ	02h
 13594                              <1> VBE_DISPI_8BIT_DAC	equ	20h
 13595                              <1> VBE_DISPI_LFB_ENABLED	equ	40h
 13596                              <1> VBE_DISPI_NOCLEARMEM	equ	80h
 13597                              <1> 
 13598                              <1> VBE_DISPI_LFB_PHYSICAL_ADDRESS equ 0E0000000h
 13599                              <1> 
 13600                              <1> ; ***
 13601                              <1> 
 13602                              <1> ;// VBE Return Status Info
 13603                              <1> ;// AL
 13604                              <1> VBE_RETURN_STATUS_SUPPORTED	equ	4Fh
 13605                              <1> VBE_RETURN_STATUS_UNSUPPORTED	equ	00h
 13606                              <1> ;// AH
 13607                              <1> VBE_RETURN_STATUS_SUCCESSFULL	equ	00h
 13608                              <1> VBE_RETURN_STATUS_FAILED	equ	01h
 13609                              <1> VBE_RETURN_STATUS_NOT_SUPPORTED	equ	02h
 13610                              <1> VBE_RETURN_STATUS_INVALID	equ	03h
 13611                              <1> 
 13612                              <1> ;// VBE Mode Numbers
 13613                              <1> 
 13614                              <1> VBE_MODE_VESA_DEFINED		equ	0100h
 13615                              <1> VBE_MODE_REFRESH_RATE_USE_CRTC	equ	0800h
 13616                              <1> VBE_MODE_LINEAR_FRAME_BUFFER	equ	4000h
 13617                              <1> VBE_MODE_PRESERVE_DISPLAY_MEMORY equ	8000h
 13618                              <1> 
 13619                              <1> ;// Mode Attributes
 13620                              <1> 
 13621                              <1> VBE_MODE_ATTRIBUTE_SUPPORTED		   equ	0001h
 13622                              <1> VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE equ	0002h
 13623                              <1> VBE_MODE_ATTRIBUTE_COLOR_MODE		   equ	0008h
 13624                              <1> VBE_MODE_ATTRIBUTE_GRAPHICS_MODE	   equ	0010h
 13625                              <1> VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE equ	0080h
 13626                              <1> VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE	   equ	0100h
 13627                              <1> VBE_MODE_ATTRIBUTE_INTERLACE_MODE	   equ	0200h
 13628                              <1> 
 13629                              <1> ;// Window attributes
 13630                              <1> 
 13631                              <1> VBE_WINDOW_ATTRIBUTE_RELOCATABLE equ	01h
 13632                              <1> VBE_WINDOW_ATTRIBUTE_READABLE	 equ	02h
 13633                              <1> VBE_WINDOW_ATTRIBUTE_WRITEABLE	 equ	04h
 13634                              <1> 
 13635                              <1> ;/* Video memory */
 13636                              <1> VGAMEM_GRAPH equ 0A000h
 13637                              <1> VGAMEM_CTEXT equ 0B800h
 13638                              <1> ;VGAMEM_MTEXT equ 0B000h
 13639                              <1> 
 13640                              <1> ;// Memory model
 13641                              <1> 
 13642                              <1> ;VBE_MEMORYMODEL_TEXT_MODE	equ	00h
 13643                              <1> ;VBE_MEMORYMODEL_CGA_GRAPHICS	equ	01h
 13644                              <1> ;VBE_MEMORYMODEL_PLANAR		equ	03h
 13645                              <1> VBE_MEMORYMODEL_PACKED_PIXEL	equ	04h
 13646                              <1> ;VBE_MEMORYMODEL_NON_CHAIN_4_256 equ	05h
 13647                              <1> VBE_MEMORYMODEL_DIRECT_COLOR	equ	06h
 13648                              <1> ;VBE_MEMORYMODEL_YUV		equ	07h
 13649                              <1> 
 13650                              <1> ;// DirectColorModeInfo
 13651                              <1> 
 13652                              <1> ;VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE equ 01h
 13653                              <1> VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE equ 02h
 13654                              <1> 
 13655                              <1> VBE_DISPI_TOTAL_VIDEO_MEMORY_MB	equ 16
 13656                              <1> 
 13657                              <1> ; 24/11/2020
 13658                              <1> ; vbe.c
 13659                              <1> 
 13660                              <1> %if 1
 13661                              <1> 
 13662                              <1> _vbe_biosfn_return_mode_info:
 13663                              <1> 	; 15/12/2020
 13664                              <1> 	; 12/12/2020
 13665                              <1> 	; Return VBE Mode Information	
 13666                              <1> 	; (call from 'sysvideo')
 13667                              <1> 	;
 13668                              <1> 	; Input:
 13669                              <1> 	;	cx = video (bios) mode
 13670                              <1> 	; Output:
 13671                              <1> 	;	cf = 0 -> (successful)
 13672                              <1> 	;	   MODE_INFO_LIST addr contains MODEINFO
 13673                              <1> 	;	cf = 1 -> error
 13674                              <1> 	;
 13675                              <1> 	; Modified registers: eax, edx, edi
 13676                              <1> 	;
 13677                              <1> 
 13678                              <1> 	; pushes for subroutine stack pops compatibility
 13679                              <1> 	
 13680                              <1> 	;push	ds  ; *
 13681                              <1> 	;push	es  ; **
 13682                              <1> 
 13683 00003819 55                  <1> 	push	ebp ; ***
 13684 0000381A 56                  <1> 	push	esi ; **** 
 13685                              <1> 	
 13686 0000381B 31FF                <1> 	xor	edi, edi  ; mov edi, 0
 13687                              <1> 
 13688 0000381D 803D[3F090000]03    <1> 	cmp	byte [vbe3], 3
 13689 00003824 7221                <1> 	jb	short _vbe_rmi_1
 13690                              <1> 
 13691                              <1> 	;sub	edi, edi  ; 0 = kernel call (sign)
 13692                              <1> 	;	; no transfer to user's buffer
 13693                              <1> 	
 13694                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
 13695                              <1> 
 13696 00003826 66B8014F            <1> 	mov	ax, 4F01h
 13697                              <1> 
 13698 0000382A E83EE0FFFF          <1> 	call	_vbe3_pmfn_return_mode_info
 13699                              <1> 
 13700 0000382F 6683F84F            <1> 	cmp	ax, 004Fh
 13701 00003833 7533                <1> 	jne	short _vbe_rmi_2 ; fail
 13702                              <1> 
 13703                              <1> 	; 15/12/2020
 13704                              <1> 	; cx = vbe video mode
 13705 00003835 80E501              <1> 	and	ch, 01h ; clear LFB flag
 13706 00003838 BEFE7B0900          <1> 	mov	esi, VBE3MODEINFOBLOCK - 2
 13707 0000383D 66890E              <1> 	mov	[esi], cx ; MODEINFO.mode
 13708 00003840 E8A5000000          <1> 	call	set_lfbinfo_table
 13709 00003845 EB22                <1> 	jmp	short _vbe_rmi_3  ; cf = 0 
 13710                              <1> _vbe_rmi_1:
 13711 00003847 803D[3F090000]02    <1> 	cmp	byte [vbe3], 2
 13712 0000384E 7219                <1> 	jb	short _vbe_rmi_3 ; cf = 1
 13713 00003850 A0[40090000]        <1> 	mov	al, [vbe2bios] ; 0C0h-0C5h for emu (*)
 13714 00003855 3CC0                <1> 	cmp	al, 0C0h ; BOCHS/QEMU/VIRTUALBOX (*) ? 
 13715 00003857 7210                <1> 	jb	short _vbe_rmi_3  ; cf = 1
 13716 00003859 3CC5                <1> 	cmp	al, 0C5h ; (*)
 13717 0000385B 770B                <1> 	ja	short _vbe_rmi_2 ; unknown vbios !? 
 13718                              <1> 	
 13719                              <1> 	;xor	edi, edi  ; 0 = kernel call (sign)
 13720                              <1> 	;	; no transfer to user's buffer
 13721                              <1> 
 13722                              <1> 	;mov	ax, 4F01h
 13723                              <1> 
 13724                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
 13725                              <1> 
 13726 0000385D E80A000000          <1> 	call	vbe_biosfn_return_mode_info
 13727 00003862 6683F84F            <1> 	cmp	ax, 004Fh ; successful ?
 13728 00003866 7401                <1> 	je	short _vbe_rmi_3  ; cf = 0
 13729                              <1> _vbe_rmi_2:
 13730 00003868 F9                  <1> 	stc
 13731                              <1> 	; cf = 1	
 13732                              <1> _vbe_rmi_3:
 13733 00003869 5E                  <1> 	pop	esi ; ****
 13734 0000386A 5D                  <1> 	pop	ebp ; ***
 13735                              <1> 	
 13736                              <1> 	;pop	es  ; **
 13737                              <1> 	;pop	ss  ; *
 13738                              <1> 	
 13739 0000386B C3                  <1> 	retn
 13740                              <1> 
 13741                              <1> 
 13742                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 13743                              <1> ; * ---------------------------------------------------------
 13744                              <1> ; * Function 01h - Return VBE Mode Information
 13745                              <1> ; * ---------------------------------------------------------
 13746                              <1> ; * Input:
 13747                              <1> ; *		AX = 4F01h
 13748                              <1> ; *		CX = Mode number
 13749                              <1> ; *    (ES:DI) EDI = Pointer to ModeInfoBlock structure	
 13750                              <1> ; * Output:
 13751                              <1> ; *		AX = VBE Return Status
 13752                              <1> ; * 
 13753                              <1> ; *----------------------------------------------------------
 13754                              <1> ; *
 13755                              <1> 
 13756                              <1> vbe_biosfn_return_mode_info:
 13757                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 13758                              <1> 	; 15/12/2020 
 13759                              <1> 	; 14/12/2020
 13760                              <1> 	; 12/12/2020
 13761                              <1> 	; 11/12/2020 (TRDOS 386 v2.0.3)
 13762                              <1> 	;
 13763                              <1> 	; Input:
 13764                              <1> 	;	cx = video (bios) mode
 13765                              <1> 	;      edi = ModeInfoBlock buffer address
 13766                              <1> 	;	     (in user's memory space)
 13767                              <1> 	;      (ax = 4F01h)
 13768                              <1> 	; Output:
 13769                              <1> 	;	ax = 004Fh (successful)
 13770                              <1> 	;	ah > 0 -> error
 13771                              <1> 	;
 13772                              <1> 	; Modified registers: esi
 13773                              <1> 
 13774                              <1> 	;;push	ds  ; *
 13775                              <1> 	;;push	es  ; **
 13776                              <1> 	;;push	ebp ; ***
 13777                              <1> 	;;push	esi ; **** 
 13778                              <1> 
 13779 0000386C F6C501              <1> 	test	ch, 1
 13780 0000386F 7505                <1> 	jnz	short vbe_rmi_1
 13781                              <1> 
 13782                              <1> 	; mode number < 100h
 13783                              <1> 	; CGA/VGA mode is not proper this VBE function 
 13784                              <1> 
 13785 00003871 29C0                <1> 	sub	eax, eax
 13786                              <1> vbe_rmi_0:	
 13787                              <1> 	;mov	ax, 0100h  ; Function is not supported
 13788 00003873 B401                <1> 	mov	ah, 1
 13789 00003875 C3                  <1> 	retn
 13790                              <1> vbe_rmi_1:
 13791 00003876 52                  <1> 	push	edx ; *****
 13792 00003877 51                  <1> 	push	ecx ; ******
 13793 00003878 53                  <1> 	push	ebx ; *******	
 13794 00003879 57                  <1> 	push	edi ; ********
 13795                              <1> 	
 13796                              <1> 	; 14/12/2020
 13797 0000387A 89CB                <1> 	mov	ebx, ecx
 13798                              <1>  			
 13799                              <1> 	;xor	eax, eax
 13800 0000387C 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
 13801 0000387F 883D[D10F0300]      <1> 	mov	[vbe_mode_x], bh
 13802                              <1> 	;and	bx, 1FFh
 13803 00003885 80E701              <1> 	and	bh, 1
 13804                              <1> 	;mov	bh, 1
 13805                              <1> 
 13806                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
 13807 00003888 E86A060000          <1> 	call	set_mode_info_list ; (alternative 2)
 13808                              <1> 
 13809                              <1> 	; eax = 0	
 13810                              <1> 
 13811                              <1> 	;mov	bx, [esi] ; mode
 13812                              <1> 
 13813                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
 13814                              <1> 	;call	mode_info_find_mode ; (alternative 1)
 13815                              <1> 
 13816 0000388D 09F6                <1> 	or	esi, esi
 13817                              <1> 	; 14/12/2020
 13818 0000388F 744C                <1> 	jz	short vbe_rmi_4	; VBE mode number is wrong
 13819                              <1> 				; or it is not supported
 13820                              <1> 
 13821                              <1> 	; 15/12/2020
 13822                              <1> 	;mov	bx, [esi] ; mode
 13823                              <1> 
 13824                              <1> 	; 12/12/2020
 13825                              <1> 	;call	set_lfbinfo_table
 13826                              <1> 
 13827 00003891 F605[D10F0300]40    <1> 	test	byte [vbe_mode_x], 40h ; LFB model ?
 13828 00003898 7404                <1> 	jz	short vbe_rmi_2
 13829                              <1> 	
 13830 0000389A C6461C01            <1> 	mov	byte [esi+MODEINFO.NumberOfBanks], 1
 13831                              <1> vbe_rmi_2:
 13832                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 13833                              <1> 	; 11/12/2020 (Erdogan Tan, video.s) 
 13834                              <1> 	; Bochs Graphics Adapter
 13835                              <1> 	; vendor_id: 1111h, device id: 1234h
 13836                              <1> 
 13837 0000389E E835070000          <1> 	call	pci_get_lfb_addr
 13838                              <1> 	;or	eax, eax
 13839 000038A3 7404                <1> 	jz	short vbe_rmi_3
 13840                              <1> 	; zf = 0, ax > 0 (high word of LFB address)
 13841                              <1> 	; set/change LFB address in MODEINFO structure
 13842 000038A5 6689462C            <1> 	mov	[esi+MODEINFO.PhysBasePtr+2], ax
 13843                              <1> 	; 12/12/2020
 13844                              <1> 	;mov	[edi+LFBINFO.LFB_addr+2], ax
 13845                              <1> vbe_rmi_3:
 13846                              <1> 	;test	byte [esi+MODEINFO.WinAAttributes], 1 
 13847                              <1> 	;		; VBE_WINDOW_ATTRIBUTE_RELOCATABLE = 1
 13848                              <1>         ;jz	short vbe_rmi_4
 13849                              <1> 	;; 11/12/2020
 13850                              <1> 	;; In fact, this is far call address in (Bochs/BGA) Video Bios
 13851                              <1> 	;; Direct user access to kernel subroutines is not possible 
 13852                              <1> 	;; in TRDOS 386. Also, TRDOS 386 kernel will support only LFB.
 13853                              <1> 	;; Bank select may be a seperate sysvideo function in future
 13854                              <1> 	;; (if it will be required).
 13855                              <1> 	;mov	dword [esi+MODEINFO.WinFuncPtr], dispi_set_bank_farcall
 13856                              <1> ;vbe_rmi_4:
 13857                              <1> 	; 12/12/2020
 13858 000038A9 E83C000000          <1> 	call	set_lfbinfo_table
 13859                              <1> 
 13860                              <1> 	; 11/12/2020
 13861                              <1> 	; copy 68 bytes of MODE_INFO_LIST to user
 13862                              <1> 
 13863 000038AE 8B3C24              <1> 	mov	edi, [esp]  ; user's buffer address
 13864                              <1> 	; 12/12/2020
 13865 000038B1 09FF                <1> 	or	edi, edi ; 0 = kernel call 
 13866                              <1> 			 ; (call from '_vbe_biosfn_return_mode_info')
 13867 000038B3 7431                <1> 	jz	short vbe_rmi_6
 13868                              <1> 
 13869                              <1> 	; 15/12/2020
 13870                              <1> 	; prepare 256 bytes MODEINFO buffer at VBE3MODEINFOBLOCK
 13871                              <1> 	; and then, copy buffer conttent to user's buffer
 13872 000038B5 57                  <1> 	push	edi
 13873 000038B6 BE[F00F0300]        <1> 	mov	esi, MODE_INFO_LIST + 2	; MODEINFO.ModeAttributes
 13874 000038BB BF007C0900          <1> 	mov	edi, VBE3MODEINFOBLOCK
 13875                              <1> 	;mov	ecx, 66/4  ; 66 bytes
 13876                              <1> 	; 03/08/2022
 13877 000038C0 29C9                <1> 	sub	ecx, ecx
 13878 000038C2 B110                <1> 	mov	cl, 66/4
 13879 000038C4 F3A5                <1> 	rep	movsd
 13880 000038C6 31C0                <1> 	xor	eax, eax
 13881 000038C8 B12F                <1> 	mov	cl, (256-68)/4 ; 188 bytes
 13882 000038CA F3AB                <1> 	rep	stosd
 13883 000038CC 66AB                <1> 	stosw	; 2 bytes
 13884 000038CE 5F                  <1> 	pop	edi
 13885 000038CF BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK
 13886                              <1> 	;mov	cx, 256 
 13887 000038D4 FEC5                <1> 	inc	ch ; cx = 256
 13888 000038D6 E852D40000          <1> 	call	transfer_to_user_buffer
 13889 000038DB 7309                <1> 	jnc	short vbe_rmi_5
 13890                              <1> vbe_rmi_4:
 13891                              <1> 	;mov	eax, 014Fh ; fail/error
 13892 000038DD 31C0                <1> 	xor	eax, eax
 13893 000038DF B401                <1> 	mov	ah, 01h
 13894                              <1> 	;jmp	short vbe_rmi_6
 13895 000038E1 E981000000          <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
 13896                              <1> vbe_rmi_5:
 13897                              <1> 	; 256 bytes of MODEINFO have been transferred to user
 13898                              <1> 	;mov	eax, 4Fh ; succesfull
 13899                              <1> vbe_rmi_6: ; 12/12/2020
 13900 000038E6 31C0                <1> 	xor	eax, eax
 13901                              <1> ;vbe_rmi_6:
 13902 000038E8 EB7D                <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
 13903                              <1> 
 13904                              <1> 	;pop	edi ; ********
 13905                              <1> 	;pop	ebx ; *******
 13906                              <1> 	;pop	ecx ; ******
 13907                              <1> 	;pop	edx ; *****	
 13908                              <1> 	
 13909                              <1> 	;;pop	esi ; ****
 13910                              <1> 	;;pop	ebp ; ***
 13911                              <1> 	;;pop	es  ; **
 13912                              <1> 	;;pop	ds  ; * 
 13913                              <1> 
 13914                              <1> 	;retn
 13915                              <1> 
 13916                              <1> set_lfbinfo_table:
 13917                              <1> 	; 19/12/2020
 13918                              <1> 	; 11/12/2020
 13919                              <1> 	; Set/Fill LFBINFO structure/table
 13920                              <1> 	;
 13921                              <1> 	; Input:
 13922                              <1> 	;	esi = Mode info list address 
 13923                              <1> 	; Output:
 13924                              <1> 	;	LFB_Info address is filled with LFBINFO
 13925                              <1> 	;	edi = LFB_Info address
 13926                              <1> 	;
 13927                              <1> 	; Modified registers: eax, edx (=0), edi
 13928                              <1> 
 13929 000038EA BF[DE0F0300]        <1> 	mov	edi, LFB_Info
 13930 000038EF 8B462A              <1> 	mov	eax, [esi+MODEINFO.PhysBasePtr]
 13931 000038F2 894702              <1> 	mov	[edi+LFBINFO.LFB_addr], eax ; LFB address
 13932                              <1> 	;mov	ax, [esi+MODEINFO.mode]
 13933 000038F5 668B06              <1> 	mov	ax, [esi]
 13934 000038F8 668907              <1> 	mov	[edi+LFBINFO.mode],ax
 13935 000038FB 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
 13936 000038FE 88470E              <1> 	mov	[edi+LFBINFO.bpp], al
 13937 00003901 29C0                <1> 	sub	eax, eax
 13938 00003903 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
 13939 00003907 6689470A            <1> 	mov	[edi+LFBINFO.X_res], ax
 13940 0000390B 89C2                <1> 	mov	edx, eax ; 19/12/2020
 13941 0000390D 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
 13942 00003911 6689470C            <1> 	mov	[edi+LFBINFO.Y_res], ax
 13943                              <1> 	; eax = Y_res ; screen height
 13944                              <1> 	; 19/12/2020	
 13945 00003915 F7E2                <1> 	mul	edx ; X_res*Y_res
 13946                              <1> 	; edx = 0
 13947 00003917 8A570E              <1> 	mov	dl, [edi+LFBINFO.bpp]
 13948                              <1> 	; Note:
 13949                              <1> 	; Bits per pixel may be 8,16,24,32 for TRDOS 386 v2.
 13950                              <1> 	; (4 bits for pixel is not used for VESA modes here)
 13951 0000391A C0EA03              <1> 	shr	dl, 3 ; convert bits to byte
 13952 0000391D F7E2                <1> 	mul	edx
 13953                              <1> 	; eax = screen/page/buffer size in bytes
 13954 0000391F 894706              <1> 	mov	[edi+LFBINFO.LFB_size], eax
 13955                              <1> 	; edx = 0
 13956                              <1> 	; clear reserved byte in LFBINFO structure/table
 13957 00003922 88570F              <1> 	mov	[edi+LFBINFO.reserved], dl ; not necessary
 13958 00003925 C3                  <1> 	retn
 13959                              <1> 
 13960                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 13961                              <1> ; * ---------------------------------------------------------
 13962                              <1> ; * Function 02h - Set VBE Mode
 13963                              <1> ; * ---------------------------------------------------------
 13964                              <1> ; * Input:
 13965                              <1> ; *		AX = 4F02h
 13966                              <1> ; *		BX = Desired Mode to set
 13967                              <1> ; * Output:
 13968                              <1> ; *		AX = VBE Return Status
 13969                              <1> ; * 
 13970                              <1> ; *----------------------------------------------------------
 13971                              <1> ; *
 13972                              <1> 
 13973                              <1> vbe_biosfn_set_mode:
 13974                              <1> 	; 07/03/2021
 13975                              <1> 	; 12/12/2020
 13976                              <1> 	; 11/12/2020 (LFBINFO table for VESA VBE modes)
 13977                              <1> 	; 27/11/2020
 13978                              <1> 	; 25/11/2020
 13979                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
 13980                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 13981                              <1> 	;
 13982                              <1> 	; Input:
 13983                              <1> 	;	bx = video (bios) mode
 13984                              <1> 	;	ax = 4F02h
 13985                              <1> 	; Output:
 13986                              <1> 	;	ax = 004Fh (successful)
 13987                              <1> 	;	ah > 0 -> error
 13988                              <1> 	;
 13989                              <1> 	; Modified registers: esi
 13990                              <1> 
 13991                              <1> 	; 27/11/2020
 13992                              <1> 
 13993                              <1> 	;;push	ds  ; *
 13994                              <1> 	;;push	es  ; **
 13995                              <1> 	;;push	ebp ; ***
 13996                              <1> 	;;push	esi ; **** 
 13997                              <1> 	
 13998                              <1> 	; 11/12/2020 			
 13999 00003926 52                  <1> 	push	edx ; *****
 14000 00003927 51                  <1> 	push	ecx ; ******
 14001 00003928 53                  <1> 	push	ebx ; *******	
 14002 00003929 57                  <1> 	push	edi ; ********
 14003                              <1> 
 14004                              <1> 	;xor	eax, eax
 14005 0000392A 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
 14006 0000392D 883D[D10F0300]      <1> 	mov	[vbe_mode_x], bh
 14007 00003933 80E701              <1> 	and	bh, 1
 14008 00003936 753C                <1> 	jnz	short vbe_sm_3  ; VESA VBE mode
 14009                              <1> 
 14010                              <1>  	;;test	bx, 4000h ; VBE_MODE_LINEAR_FRAME_BUFFER
 14011                              <1> 	;test	bh, 40h
 14012                              <1> 	;jz	short vbe_sm_0
 14013                              <1> 	;; lfb_flag
 14014                              <1> 	;mov	al, 40h	; VBE_DISPI_LFB_ENABLED
 14015                              <1> vbe_sm_0:
 14016                              <1> 	; 27/11/2020
 14017 00003938 B080                <1> 	mov	al, 80h
 14018                              <1> 	;test	bh, 80h ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 	
 14019                              <1> 	;jnz	short vbe_sm_1 ; no_clear
 14020                              <1> 	;; clear
 14021                              <1> 	;sub	al, al ; 0
 14022 0000393A 8405[D10F0300]      <1> 	test	[vbe_mode_x], al ; 80h
 14023 00003940 7402                <1> 	jz	short vbe_sm_1 ; clear display memory
 14024                              <1> 	; no_clear
 14025 00003942 08C3                <1> 	or	bl, al ; VBE_MODE_PRESERVE_DISPLAY_MEMORY
 14026                              <1> vbe_sm_1:
 14027                              <1> 	; check non vesa mode
 14028                              <1> 	;;cmp	bx, 100h ; VBE_MODE_VESA_DEFINED
 14029                              <1> 	;;jna	short vbe_sm_2
 14030                              <1> 	;and	bh, 1
 14031                              <1> 	;jnz	short vbe_sm_3 
 14032                              <1> 
 14033                              <1> 	; BX <= 1FFh
 14034                              <1> 
 14035                              <1> 	; 27/11/2020
 14036                              <1> 	;or	bl, al	; al = 80h if no_clear option is set 
 14037                              <1> 	;		; al = 0 if no_clear option is not set 
 14038                              <1> 
 14039                              <1> 	; 25/11/2020
 14040                              <1> 	; VBE DISPI will be disabled in 'biosfn_set_video_mode'
 14041                              <1>  
 14042                              <1> 	;xor	al, al ; 0 ; VBE_DISPI_DISABLED
 14043                              <1> 	;call	dispi_set_enable
 14044                              <1> 
 14045                              <1> 	; call the vgabios in order to set the video mode
 14046                              <1> 	; this allows for going back to textmode with a VBE call
 14047                              <1> 	; (some applications expect that to work)
 14048                              <1> 
 14049                              <1> 	;and	bx, 0FFh
 14050                              <1> 	
 14051                              <1> 	; 27/11/2020
 14052                              <1> biosfn_set_video_mode:
 14053                              <1> 	; _call: call subroutine
 14054                              <1> 	; 26/11/2020 (TRDOS 386 v2.0.3)
 14055                              <1> 	; (ref: vgabios.c, 02/01/2020, vruppert)
 14056                              <1> 	; Input:
 14057                              <1> 	;	bl = VGA video (bios) mode
 14058                              <1> 	; Output:
 14059                              <1> 	;	cf = 1 -> error
 14060                              <1> 	;	cf = 0 -> ok
 14061                              <1> 	;
 14062                              <1> 	; Modified registers: esi
 14063                              <1> 
 14064                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
 14065                              <1> 	
 14066                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
 14067 00003944 31C0                <1> 	xor	eax, eax ; 0 
 14068 00003946 E89C040000          <1> 	call	dispi_set_enable
 14069                              <1> 	
 14070 0000394B 88D8                <1> 	mov	al, bl
 14071                              <1> 	;jmp	_set_mode ; (in 'biosfn_set_video_mode' sub)
 14072 0000394D E87AE1FFFF          <1> 	call	_set_mode ; will return with cf=1 only if
 14073                              <1> 			; desired mode is not implemented
 14074                              <1> 	; _retn: return from subroutine
 14075 00003952 721A                <1> 	jc	short vbe_sm_2 ; 25/11/2020
 14076                              <1> 
 14077                              <1> 	; 26/11/2020
 14078 00003954 31C0                <1> 	xor	eax, eax 
 14079 00003956 A0[9E660000]        <1> 	mov	al, [CRT_MODE]
 14080                              <1> 	; 27/11/2020
 14081 0000395B 8A25[13840100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
 14082                              <1> 	;and	ah 80h
 14083 00003961 66A3[D20F0300]      <1> 	mov	[video_mode], ax ; bit 15 = no_clear flag
 14084                              <1> 				 ; bit 14 = 0 (not LFB model)
 14085                              <1> vbe_sm_ret1:
 14086                              <1> 	; 11/12/2020
 14087                              <1> 	; (vbe_rmi_4 and vbe_rmi_6 jump here)
 14088                              <1> 	; 27/11/2020
 14089 00003967 B04F                <1> 	mov	al, 4Fh ; Function call successful
 14090                              <1> 	; eax = 004Fh
 14091                              <1> vbe_sm_ret2:
 14092                              <1> 	; 11/12/2020
 14093 00003969 5F                  <1> 	pop	edi ; ********
 14094 0000396A 5B                  <1> 	pop	ebx ; *******
 14095 0000396B 59                  <1> 	pop	ecx ; ******
 14096 0000396C 5A                  <1> 	pop	edx ; *****
 14097                              <1> 
 14098                              <1> 	;;pop	esi ; ****
 14099                              <1> 	;;pop	ebp ; ***
 14100                              <1> 	;;pop	es  ; **
 14101                              <1> 	;;pop	ds  ; * 
 14102                              <1> 
 14103 0000396D C3                  <1> 	retn
 14104                              <1> 
 14105                              <1> vbe_sm_2:
 14106                              <1> 	;mov	ax, 0100h ; Function is not supported
 14107                              <1> 	; 27/11/2020
 14108 0000396E 31C0                <1> 	xor	eax, eax
 14109 00003970 B401                <1> 	mov	ah, 01h
 14110                              <1> 	; eax = 0100h
 14111                              <1> 	;retn
 14112 00003972 EBF5                <1> 	jmp	short vbe_sm_ret2
 14113                              <1> 
 14114                              <1> vbe_sm_3:
 14115                              <1> 	; 12/12/2020
 14116                              <1> 	; check current mode, if it is 03h
 14117                              <1> 	; save page contents and cursor positions
 14118 00003974 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 03h
 14119                              <1> 	;jne	short vbe_sm_0
 14120 0000397B 7505                <1> 	jne	short vbe_sm_4 ; 07/03/2021
 14121 0000397D E8ECE3FFFF          <1> 	call	save_mode3_multiscreen
 14122                              <1> 	; set current mode to extended (SVGA) mode
 14123                              <1> 	;mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
 14124                              <1> vbe_sm_4:
 14125                              <1> 	; 27/11/2020
 14126                              <1> 	; bx = mode (bit 0 to 8)
 14127                              <1> 
 14128                              <1> 	; 25/11/2020
 14129                              <1> 
 14130                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
 14131                              <1> 	;push	edi
 14132 00003982 E870050000          <1> 	call	set_mode_info_list ; (alternative 2)
 14133                              <1> 	;pop	edi
 14134                              <1> 
 14135                              <1> 	;mov	bx, [esi] ; mode
 14136                              <1> 
 14137                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
 14138                              <1> 	;call	mode_info_find_mode ; (alternative 1)
 14139                              <1> 
 14140 00003987 09F6                <1> 	or	esi, esi
 14141 00003989 74E3                <1> 	jz	short vbe_sm_2 ; VBE mode number is wrong
 14142                              <1> 			       ; or it is not supported
 14143                              <1> 
 14144                              <1> 	; 11/12/2020
 14145 0000398B 668B1E              <1> 	mov	bx, [esi] ; mode
 14146                              <1> 
 14147                              <1> 	; 27/11/2020
 14148 0000398E 0A3D[D10F0300]      <1> 	or	bh, [vbe_mode_x]
 14149                              <1> 
 14150                              <1> 	; save VESA VBE mode
 14151 00003994 66891D[D20F0300]    <1> 	mov	[video_mode], bx
 14152                              <1> 		; 27/11/2020
 14153                              <1> 		; bit 0 to 8 = VESA VBE mode
 14154                              <1> 		; bit 9 to 13 = 0 (bit 0 to 13 = mode)
 14155                              <1> 		; bit 14 = Linear/Flat Frame Buffer flag
 14156                              <1> 		; bit 15 = 'memory not cleared
 14157                              <1> 		;	   at last mode set' flag
 14158                              <1> 
 14159                              <1> 	; first disable current mode
 14160                              <1> 	; (when switching between vesa modes)
 14161                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
 14162                              <1> 
 14163                              <1> 	;mov	ax, VBE_DISPI_DISABLED ; 0
 14164 0000399B 29C0                <1> 	sub	eax, eax ; 0
 14165                              <1> 
 14166 0000399D E845040000          <1> 	call	dispi_set_enable
 14167                              <1> 
 14168                              <1> 	; 11/12/2020
 14169 000039A2 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
 14170                              <1> 	; ah = 0
 14171                              <1> 
 14172                              <1> 	;cmp	byte [esi+MODEINFO.BitsPerPixel], 8
 14173 000039A5 3C08                <1> 	cmp	al, 8
 14174 000039A7 750B                <1> 	jne	short vbe_sm_5
 14175                              <1> 
 14176                              <1> 	; 11/12/2020
 14177                              <1> 	;push	edi
 14178 000039A9 50                  <1> 	push	eax
 14179                              <1> 	; 'load_dac_palette(3);'
 14180 000039AA 56                  <1> 	push	esi
 14181 000039AB B403                <1> 	mov	ah, 3  ; palette3, 256 colors
 14182 000039AD E8BBF1FFFF          <1> 	call	load_dac_palette
 14183 000039B2 5E                  <1> 	pop	esi
 14184                              <1> 	; 11/12/2020
 14185 000039B3 58                  <1> 	pop	eax
 14186                              <1> 	;pop	edi
 14187                              <1> vbe_sm_5:	
 14188                              <1>   	;'dispi_set_bpp(cur_info->info.BitsPerPixel);'
 14189                              <1> 	; 11/12/2020 (al = bits per pixel, ah = 0)
 14190                              <1> 	;xor	ah, ah
 14191                              <1> 	;mov	al, [esi+MODEINFO.BitsPerPixel]
 14192 000039B4 E841040000          <1> 	call	dispi_set_bpp
 14193                              <1>         ;'dispi_set_xres(cur_info->info.XResolution);'
 14194 000039B9 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
 14195 000039BD E83E040000          <1> 	call	dispi_set_xres
 14196                              <1>         ;'dispi_set_yres(cur_info->info.YResolution);'
 14197 000039C2 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
 14198 000039C6 E83B040000          <1> 	call	dispi_set_yres
 14199                              <1> 
 14200                              <1> 	;'dispi_set_bank(0);'
 14201                              <1> 	;xor	ax, ax
 14202 000039CB 31C0                <1> 	xor	eax, eax ; 0
 14203 000039CD E83A040000          <1> 	call	dispi_set_bank
 14204                              <1>         ;'dispi_set_enable(VBE_DISPI_ENABLED|no_clear|lfb_flag);'
 14205                              <1> 	;mov	ax, di
 14206                              <1> 	; ah = 0 ; 27/11/2020
 14207 000039D2 A0[D10F0300]        <1> 	mov	al, [vbe_mode_x] ; restore VBE mode bit 14 & 15
 14208 000039D7 0C01                <1> 	or	al, 1 ; VBE_DISPI_ENABLED
 14209 000039D9 E809040000          <1> 	call	dispi_set_enable
 14210                              <1> 
 14211                              <1>         ; 'vga_compat_setup();'
 14212 000039DE E83E040000          <1> 	call	vga_compat_setup
 14213                              <1> 
 14214                              <1> 	; 11/12/2020
 14215 000039E3 E802FFFFFF          <1> 	call	set_lfbinfo_table
 14216                              <1> 
 14217                              <1> 	; 26/11/2020
 14218 000039E8 31C0                <1> 	xor	eax, eax
 14219 000039EA FEC8                <1> 	dec	al 
 14220 000039EC A2[9E660000]        <1> 	mov	[CRT_MODE], al ; 0FFh = VESA VBE mode sign
 14221                              <1> 
 14222                              <1> 	; 27/11/2020
 14223 000039F1 E971FFFFFF          <1> 	jmp	vbe_sm_ret1 ; Function call successful
 14224                              <1> 	
 14225                              <1> 	; 27/11/2020
 14226                              <1> 	;mov	al, 4Fh
 14227                              <1> 	;	; eax = 004Fh = Function call successful
 14228                              <1> 	;jmp	short vbe_sm_ret2
 14229                              <1> 
 14230                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions)
 14231                              <1> ; * ---------------------------------------------------------
 14232                              <1> ; * Function 03h - Return Current VBE Mode
 14233                              <1> ; * ---------------------------------------------------------
 14234                              <1> ; * Input:
 14235                              <1> ; *		AX = 4F03h
 14236                              <1> ; * Output:
 14237                              <1> ; *		AX = VBE Return Status
 14238                              <1> ; *		BX = Current VBE Mode
 14239                              <1> ; * 
 14240                              <1> ; *----------------------------------------------------------
 14241                              <1> ; *
 14242                              <1> 
 14243                              <1> vbe_biosfn_return_current_mode:
 14244                              <1> 	; 11/12/2020
 14245                              <1> 	; 27/11/2020 (TRDOS 386 v2.0.3)
 14246                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 14247                              <1> 	;
 14248                              <1> 	; Input:
 14249                              <1> 	;	none
 14250                              <1> 	; Output:
 14251                              <1> 	;	ax = 004Fh (successful)
 14252                              <1> 	;	ah > 0 -> error
 14253                              <1> 	;	bx = current video (bios) mode (if ah = 0)
 14254                              <1> 	;
 14255                              <1> 	; Modified registers: eax, ebx
 14256                              <1> 
 14257                              <1> 	; 27/11/2020
 14258                              <1> 
 14259                              <1> 	;;push	ds  ; *
 14260                              <1> 	;;push	es  ; **
 14261                              <1> 	;;push	ebp ; ***
 14262                              <1> 	;;push	esi ; **** 
 14263                              <1> 	 			
 14264                              <1> 	;push	edx ; *****
 14265                              <1> 
 14266                              <1> 	; (vbe.c)
 14267                              <1> 	;call	dispi_get_enable
 14268                              <1> 	;	; ax = vbe display interface status
 14269                              <1> 	;and	al, 1 ; VBE_DISPI_ENABLED
 14270                              <1> 	;jnz	short vbe_gm_1  ; VBE graphics mode
 14271                              <1> 
 14272 000039F6 A0[9E660000]        <1> 	mov	al, [CRT_MODE] ; current cga/vga mode
 14273 000039FB 3CFF                <1> 	cmp	al, 0FFh ; VBE extension signature
 14274 000039FD 720E                <1> 	jb	short vbe_gm_1 ; get CGA/VGA mode
 14275                              <1> 
 14276                              <1> 	; get VBE mode
 14277                              <1> vbe_gm_0:
 14278 000039FF 66A1[D20F0300]      <1> 	mov	ax, [video_mode]
 14279                              <1> 		; BX bits:
 14280                              <1> 		; bit 0 to 8 = VESA VBE video mode
 14281                              <1> 		; bit 9 to 13 = 0 
 14282                              <1> 		; bit 14 = last mode set LFB option
 14283                              <1> 		;	   1 - linear/flat frame buffer
 14284                              <1> 		;	   0 - windowed frame buffer
 14285                              <1> 		; bit 15 = last mode set no_clear option
 14286                              <1> 		;	   0 - video memory cleared
 14287                              <1> 		;	   1 - video memory not cleared
 14288                              <1> 	
 14289                              <1> vbe_gm_return:
 14290                              <1> 	;pop	edx ; ******
 14291 00003A05 0FB7D8              <1> 	movzx	ebx, ax
 14292                              <1> ;vbe_srs_retn:
 14293 00003A08 31C0                <1> 	xor	eax, eax ; 0
 14294 00003A0A B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
 14295 00003A0C C3                  <1> 	retn	
 14296                              <1> 
 14297                              <1> vbe_gm_1:
 14298                              <1> 	; legacy (old, standard) CGA/VGA bios video mode
 14299 00003A0D 8A25[13840100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
 14300                              <1> 		; BX bits: 
 14301                              <1> 		; bit 0 to 7 = video mode
 14302                              <1> 		; bit 8 to 13 = 0 
 14303                              <1> 		; bit 14 = 0 (not LFB mode) CGA/VGA
 14304                              <1> 		; bit 15 = 1 if [noclearmem] = 80h
 14305                              <1> 		;	   0 if [noclearmem] = 0
 14306 00003A13 EBF0                <1> 	jmp	short vbe_gm_return
 14307                              <1> 
 14308                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
 14309                              <1> ; * ---------------------------------------------------------
 14310                              <1> ; * Function 04h - Save/Restore State
 14311                              <1> ; * ---------------------------------------------------------
 14312                              <1> ; * Input:
 14313                              <1> ; *		AX = 4F04h
 14314                              <1> ; *             DL = 00h Return Save/Restore State buff size
 14315                              <1> ; *                  01h Save State
 14316                              <1> ; *                  02h Restore State
 14317                              <1> ; *             CX = Requested states
 14318                              <1> ; *		     bit 0 - controller hardware state
 14319                              <1> ; *		     bit 1 - BIOS data state
 14320                              <1> ; *		     bit 2 - DAC state
 14321                              <1> ; *		     bit 3 - register state
 14322                              <1> ; *    (ES:BX) EBX = Pointer to buffer (if DL <> 00h)
 14323                              <1> ; * Output:
 14324                              <1> ; *		AX = VBE Return Status
 14325                              <1> ; *		BX = Number of 64-byte blocks 
 14326                              <1> ; *		     to hold the state buffer (if DL=00h)
 14327                              <1> ; * 
 14328                              <1> ; *----------------------------------------------------------
 14329                              <1> ; *
 14330                              <1> 
 14331                              <1> vbe_biosfn_save_restore_state:
 14332                              <1> 	; 23/01/2021
 14333                              <1> 	; 16/01/2021
 14334                              <1> 	; 14/01/2021
 14335                              <1> 	; 13/01/2021
 14336                              <1> 	; 12/01/2021
 14337                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
 14338                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
 14339                              <1> 	;
 14340                              <1> 	; Input:
 14341                              <1> 	;	dl = sub function
 14342                              <1> 	;	cl = requested state
 14343                              <1> 	;      ebx = pointer to buffer (if dl<>00h) 
 14344                              <1> 	; Output:
 14345                              <1> 	;	ax = 004Fh (successful)
 14346                              <1> 	;	ah > 0 -> error
 14347                              <1> 	;	bx = Number of 64-byte blocks 
 14348                              <1> 	;	     to hold the state buffer (if DL=00h)
 14349                              <1> 
 14350                              <1> 	; Modified registers: eax, ebx, edi
 14351                              <1> 	
 14352                              <1> 	; 14/01/2021
 14353 00003A15 09DB                <1> 	or	ebx, ebx ; user's buffer address
 14354 00003A17 750A                <1> 	jnz	short _vbe_biosfn_save_restore_state
 14355                              <1> 
 14356 00003A19 20D2                <1> 	and	dl, dl
 14357 00003A1B 7406                <1> 	jz	short _vbe_biosfn_save_restore_state
 14358                              <1> 
 14359                              <1> 	; function failed
 14360                              <1> 	;mov	eax, 0100h
 14361                              <1> 	;xor	eax, eax
 14362                              <1> 	;inc	ah  ; eax = 0100h
 14363                              <1> 	; 16/01/2021
 14364 00003A1D B84F010000          <1> 	mov	eax, 014Fh
 14365 00003A22 C3                  <1> 	retn
 14366                              <1> 
 14367                              <1> _vbe_biosfn_save_restore_state:
 14368                              <1> 	; 23/01/2021
 14369                              <1> 	; 14/01/2021
 14370                              <1> 	; ebx = 0 if the caller is kernel ('sysvideo')
 14371                              <1> 
 14372                              <1> 	; 13/01/2021
 14373 00003A23 57                  <1> 	push	edi
 14374 00003A24 52                  <1> 	push	edx
 14375 00003A25 51                  <1> 	push	ecx
 14376                              <1> 
 14377                              <1> 	; 23/01/2021
 14378                              <1> 	; 12/01/2021
 14379 00003A26 80FA02              <1> 	cmp	dl, 2
 14380 00003A29 7757                <1> 	ja	short vbe_srs_7 ; 23/01/2021
 14381                              <1> 			; invalid sub function
 14382 00003A2B 83F90F              <1> 	cmp	ecx, 0Fh
 14383 00003A2E 7752                <1> 	ja	short vbe_srs_7 ; invalid !
 14384                              <1> 	
 14385 00003A30 20D2                <1> 	and	dl, dl
 14386 00003A32 7515                <1> 	jnz	short vbe_srs_4
 14387                              <1> 
 14388                              <1> 	; DL = 0
 14389                              <1> 	; Return Save/Restore State buffer size
 14390                              <1> 
 14391                              <1> 	;mov	ebx, ecx
 14392                              <1> 	;shl	bl, 1
 14393                              <1> 	;mov	bx, [ebx+vbestatebufsize]
 14394 00003A34 E881000000          <1> 	call	vbe_srs_gbs
 14395                              <1> 
 14396                              <1> ;	; 11/01/2021
 14397                              <1> ;	test	cl, 8
 14398                              <1> ;	jz	short vbe_srs_3
 14399                              <1> ;	; vbe_biosfn_read_video_state_size();
 14400                              <1> ;	; return 9 * 2;
 14401                              <1> ;	mov	bl, 18 ; register state size
 14402                              <1> ;vbe_srs_0:
 14403                              <1> ;	test	cl, 1
 14404                              <1> ;	jz	short vbe_srs_1
 14405                              <1> ;	; size += 0x46;
 14406                              <1> ;	add	bl, 70	; controller state size
 14407                              <1> ;vbe_srs_1:
 14408                              <1> ;	test	cl, 2
 14409                              <1> ;	jz	short vbe_srs_2
 14410                              <1> ;	; size += (5 + 8 + 5) * 2 + 6;
 14411                              <1> ;	;add	bl, 42 ; BIOS data state size ; Bochs/Plex86
 14412                              <1> ;	; 12/01/2021
 14413                              <1> ;	add	bl, 40 ; TRDOS 386 v2 VBIOS data state size
 14414                              <1> ;vbe_srs_2:
 14415                              <1> ;	test	cl, 4
 14416                              <1> ;	jz	short vbe_srs_3
 14417                              <1> ;	; size += 3 + 256 * 3 + 1;
 14418                              <1> ;	add	bx, 772 ; DAC state size
 14419                              <1> 
 14420                              <1> vbe_srs_3:
 14421 00003A39 6683C33F            <1> 	add	bx, 63
 14422 00003A3D 66C1EB06            <1> 	shr	bx, 6 ; / 64
 14423                              <1> 
 14424                              <1> vbe_srs_retn:
 14425 00003A41 31C0                <1> 	xor	eax, eax ; 0
 14426                              <1> vbe_srs_0:  ; 16/01/2021
 14427 00003A43 B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
 14428                              <1> ;vbe_srs_0:
 14429                              <1> 	; 13/01/2021
 14430 00003A45 59                  <1> 	pop	ecx
 14431 00003A46 5A                  <1> 	pop	edx
 14432 00003A47 5F                  <1> 	pop	edi	
 14433                              <1> 
 14434 00003A48 C3                  <1> 	retn
 14435                              <1> 
 14436                              <1> 	; 23/01/2021
 14437                              <1> ;vbe_srs_10:
 14438                              <1> 	;; 14/01/2021
 14439                              <1> 	; return to 'sysvideo'
 14440                              <1> 	;mov	ebx, ecx ; transfer count
 14441                              <1> 	;	; (byte count for saving current video state)
 14442                              <1> 	;jmp	short vbe_srs_retn 
 14443                              <1> 
 14444                              <1> vbe_srs_4:
 14445                              <1> 	; 23/01/2021
 14446 00003A49 80E10F              <1> 	and	cl, 0Fh ; 8, 4, 2, 1
 14447 00003A4C 7434                <1> 	jz	short vbe_srs_7 ; cx = 0 -> invalid !
 14448                              <1> 
 14449 00003A4E BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 14450                              <1> 
 14451 00003A53 80FA01              <1> 	cmp	dl, 1
 14452 00003A56 7730                <1> 	ja	short vbe_srs_8
 14453                              <1> 
 14454                              <1> 	; save video state
 14455                              <1> 
 14456 00003A58 F6C107              <1> 	test	cl, 07h ; 4, 2, 1
 14457 00003A5B 740A                <1> 	jz	short vbe_srs_5  ; vbe dispi regs state
 14458                              <1> 
 14459 00003A5D E884000000          <1> 	call	biosfn_save_video_state
 14460                              <1> 	; edi = current position
 14461                              <1> 	;	in VBE3SAVERESTOREBLOCK
 14462                              <1> 	; 	(VGA save_state offset)
 14463                              <1> 	; modified regs: edi, eax, edx, ch
 14464 00003A62 F6C108              <1> 	test	cl, 8
 14465 00003A65 7405                <1> 	jz	short vbe_srs_6
 14466                              <1> vbe_srs_5:
 14467 00003A67 E8AB010000          <1> 	call	vbe_biosfn_save_video_state
 14468                              <1> 	; edi = end position
 14469                              <1> 	;	in VBE3SAVERESTOREBLOCK
 14470                              <1> 	; 	(VGA save_state offset)
 14471                              <1> 	; modified regs: edi, eax, edx, ch
 14472                              <1> vbe_srs_6:
 14473                              <1> 	; 23/01/2021
 14474 00003A6C 21DB                <1> 	and	ebx, ebx 
 14475 00003A6E 74D1                <1> 	jz	short vbe_srs_retn ; the caller is kernel
 14476                              <1> 	
 14477 00003A70 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 14478 00003A75 29F7                <1> 	sub	edi, esi
 14479 00003A77 89F9                <1> 	mov	ecx, edi ; transfer count in bytes
 14480                              <1> 
 14481                              <1> 	;; 14/01/2021
 14482                              <1> 	;and	ebx, ebx 
 14483                              <1> 	;jz	short vbe_srs_10 ; the caller is kernel
 14484                              <1> 
 14485 00003A79 89DF                <1> 	mov	edi, ebx ; user's buffer address
 14486 00003A7B E8ADD20000          <1> 	call	transfer_to_user_buffer
 14487 00003A80 73BF                <1> 	jnc	short vbe_srs_retn
 14488                              <1> vbe_srs_7:
 14489                              <1> 	; // function failed
 14490                              <1> 	;mov	eax, 0100h
 14491 00003A82 31C0                <1> 	xor	eax, eax
 14492 00003A84 FEC4                <1> 	inc	ah  ; eax = 0100h
 14493                              <1> 	; 16/01/2021
 14494                              <1> 	; ax = 0014Fh
 14495                              <1> 	;retn
 14496                              <1> 	; 13/01/2021
 14497 00003A86 EBBB                <1> 	jmp	short vbe_srs_0
 14498                              <1> vbe_srs_8:
 14499                              <1> 	;cmp	dl, 2
 14500                              <1> 	;jne	short vbe_srs_7
 14501                              <1> 	;		; invalid sub function
 14502                              <1> 
 14503                              <1> 	; 14/01/2021
 14504 00003A88 09DB                <1> 	or	ebx, ebx ; user's buffer address
 14505                              <1> 	;jnz	short vbe_srs_11
 14506                              <1> 
 14507                              <1> 	; the caller is kernel ('sysvideo')
 14508                              <1> 	;jmp	short vbe_srs_12
 14509                              <1> 	; 23/01/2021
 14510 00003A8A 7414                <1> 	jz	short vbe_srs_12 ; 'sysvideo' call
 14511                              <1> vbe_srs_11:
 14512 00003A8C 89DE                <1> 	mov	esi, ebx ; user's buffer address
 14513                              <1> 	; 23/01/2021
 14514                              <1> 	;push	ebx
 14515                              <1> 	
 14516 00003A8E E827000000          <1> 	call	vbe_srs_gbs
 14517                              <1> 	
 14518                              <1> 	; restore video state
 14519                              <1> 
 14520                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 14521 00003A93 51                  <1> 	push	ecx
 14522 00003A94 89D9                <1> 	mov	ecx, ebx ; transfer count in bytes
 14523 00003A96 E8DCD20000          <1> 	call	transfer_from_user_buffer
 14524 00003A9B 59                  <1> 	pop	ecx
 14525                              <1> 	; 23/01/2021
 14526                              <1> 	;pop	ebx
 14527 00003A9C 89F3                <1> 	mov	ebx, esi
 14528 00003A9E 72E2                <1> 	jc	short vbe_srs_7
 14529                              <1> 
 14530                              <1> vbe_srs_12:
 14531                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
 14532 00003AA0 89FE                <1> 	mov	esi, edi
 14533                              <1> 
 14534 00003AA2 F6C107              <1> 	test	cl, 07h ; 4, 2, 1
 14535 00003AA5 740C                <1> 	jz	short vbe_srs_9	; vbe dispi regs state
 14536                              <1> 
 14537 00003AA7 E8A2010000          <1> 	call	biosfn_restore_video_state
 14538 00003AAC 72D4                <1> 	jc	short vbe_srs_7 ; invalid buffer content !
 14539                              <1> 	; esi = current position
 14540                              <1> 	;	in VBE3SAVERESTOREBLOCK
 14541                              <1> 	; 	(VGA save_state offset)
 14542                              <1> 	; modified regs: esi, eax, edx, ch
 14543 00003AAE F6C108              <1> 	test	cl, 8
 14544                              <1> 	;jz	short vbe_srs_10
 14545                              <1> 	; 23/01/2020
 14546 00003AB1 EB8E                <1> 	jmp	short vbe_srs_retn
 14547                              <1> vbe_srs_9:
 14548 00003AB3 E8F1020000          <1> 	call	vbe_biosfn_restore_video_state
 14549                              <1> 
 14550                              <1> 	; modified regs: esi, eax, edx, ch
 14551                              <1> 
 14552 00003AB8 EB87                <1> 	jmp	short vbe_srs_retn
 14553                              <1> 
 14554                              <1> ;vbe_srs_10:
 14555                              <1> ;	; successful
 14556                              <1> ;	xor	eax, eax ; 0
 14557                              <1> ;	mov	al, 4Fh ; ax = 004Fh (successful)
 14558                              <1> ;	retn
 14559                              <1> 
 14560                              <1> vbe_srs_gbs:
 14561                              <1> 	; return buffer size according to flags
 14562 00003ABA 89CB                <1> 	mov	ebx, ecx ; options/flags
 14563 00003ABC D0E3                <1> 	shl	bl, 1
 14564 00003ABE 668B9B[C63A0000]    <1> 	mov	bx, [ebx+vbestatebufsize]
 14565 00003AC5 C3                  <1> 	retn
 14566                              <1> 
 14567                              <1> vbestatebufsize:
 14568                              <1> 	; ----------------------------------------
 14569                              <1> 	; CL =	0  1   2    3    4    5    6    7
 14570                              <1> 	; ----------------------------------------
 14571 00003AC6 0000460028006E0004- <1> 	dw	0, 70, 40, 110, 772, 842, 812, 882
 14572 00003ACF 034A032C037203      <1>
 14573                              <1> 	; ----------------------------------------
 14574                              <1> 	; CL =	8   9   10  11   12   13   14   15
 14575                              <1> 	; ----------------------------------------
 14576 00003AD6 120058003A00800016- <1> 	dw	18, 88, 58, 128, 790, 860, 830, 900
 14577 00003ADF 035C033E038403      <1>
 14578                              <1> 
 14579                              <1> ; 11/01/2021
 14580                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
 14581                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
 14582                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
 14583                              <1> 
 14584                              <1> VGAREG_INPUT_STATUS	equ 3C2h
 14585                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
 14586                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
 14587                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
 14588                              <1> VGAREG_SEQU_DATA	equ 3C5h
 14589                              <1> 
 14590                              <1> VGAREG_PEL_MASK		equ 3C6h
 14591                              <1> VGAREG_DAC_STATE	equ 3C7h
 14592                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
 14593                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
 14594                              <1> VGAREG_DAC_DATA		equ 3C9h
 14595                              <1> 
 14596                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
 14597                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
 14598                              <1> 
 14599                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
 14600                              <1> VGAREG_GRDC_DATA	equ 3CFh
 14601                              <1> 
 14602                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
 14603                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
 14604                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
 14605                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
 14606                              <1> 
 14607                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
 14608                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
 14609                              <1> VGAREG_ACTL_RESET	equ 3DAh
 14610                              <1> 
 14611                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
 14612                              <1> VGAREG_CGA_MODECTL	equ 3D8h
 14613                              <1> VGAREG_CGA_PALETTE	equ 3D9h
 14614                              <1> 
 14615                              <1> biosfn_save_video_state:
 14616                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
 14617                              <1> 	; 22/01/2021
 14618                              <1> 	; 12/01/2021
 14619                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
 14620                              <1> 	; (vgabios.c)
 14621                              <1> 
 14622                              <1> 	; modified registers: eax, edx, edi, ch
 14623                              <1> 
 14624                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 14625                              <1> 
 14626                              <1> 	; input: edi = state buffer address
 14627                              <1> 
 14628 00003AE6 F6C101              <1> 	test	cl, 1
 14629 00003AE9 0F8485000000        <1> 	jz	bfn_svs_4
 14630                              <1> 
 14631 00003AEF 66BAC403            <1> 	mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
 14632 00003AF3 EC                  <1> 	in	al, dx
 14633 00003AF4 AA                  <1> 	stosb
 14634                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 14635 00003AF5 B2D4                <1> 	mov	dl, 0D4h
 14636 00003AF7 EC                  <1> 	in	al, dx
 14637 00003AF8 AA                  <1> 	stosb
 14638                              <1>   	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
 14639 00003AF9 B2CE                <1>         mov	dl, 0CEh
 14640 00003AFB EC                  <1> 	in	al, dx
 14641 00003AFC AA                  <1> 	stosb
 14642                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 14643 00003AFD B2DA                <1> 	mov	dl, 0DAh
 14644 00003AFF EC                  <1> 	in	al, dx
 14645                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 14646 00003B00 B2C0                <1> 	mov	dl, 0C0h
 14647 00003B02 EC                  <1> 	in	al, dx
 14648 00003B03 AA                  <1> 	stosb
 14649 00003B04 88C4                <1> 	mov	ah, al ; ar_index
 14650                              <1> 	;mov	dx, VGAREG_READ_FEATURE_CTL ; 3CAh
 14651 00003B06 B2CA                <1> 	mov	dl, 0CAh
 14652 00003B08 EC                  <1> 	in	al, dx
 14653 00003B09 AA                  <1> 	stosb
 14654                              <1> 	; (5 bytes are writen above)
 14655                              <1> 
 14656                              <1> 	; for(i=1;i<=4;i++){
 14657 00003B0A B001                <1> 	mov	al, 1
 14658                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 14659                              <1> 	;mov	dl, 0C4h
 14660 00003B0C B504                <1> 	mov	ch, 4
 14661                              <1> bfn_svs_0:
 14662                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
 14663                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 14664 00003B0E B2C4                <1> 	mov	dl, 0C4h
 14665 00003B10 EE                  <1> 	out	dx, al
 14666                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
 14667 00003B11 FEC2                <1> 	inc	dl  ; dx = 3C5h
 14668                              <1> 	; inb(VGAREG_SEQU_DATA)
 14669 00003B13 50                  <1> 	push	eax
 14670 00003B14 EC                  <1> 	in	al, dx
 14671 00003B15 AA                  <1> 	stosb	; (4 bytes in loop)
 14672 00003B16 58                  <1> 	pop	eax
 14673                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 14674                              <1> 	;dec	dl	
 14675 00003B17 FEC0                <1> 	inc	al  ; i++
 14676 00003B19 FECD                <1> 	dec	ch
 14677 00003B1B 75F1                <1> 	jnz	short bfn_svs_0
 14678                              <1> 
 14679                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
 14680 00003B1D 28C0                <1> 	sub	al, al ; 0
 14681 00003B1F EE                  <1> 	out	dx, al
 14682                              <1> 	; inb(VGAREG_SEQU_DATA)
 14683                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
 14684 00003B20 FEC2                <1> 	inc	dl  ; dx = 3C5h
 14685 00003B22 EC                  <1> 	in	al, dx
 14686 00003B23 AA                  <1> 	stosb	; (+1 byte)
 14687                              <1> 
 14688                              <1>         ; for(i=0;i<=0x18;i++) {
 14689 00003B24 28C0                <1> 	sub	al, al ; 0
 14690                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 14691                              <1> 	;mov	dl, 0D4h
 14692 00003B26 B519                <1> 	mov	ch, 25
 14693                              <1> bfn_svs_1:
 14694                              <1>         ; outb(crtc_addr,i);
 14695                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 14696 00003B28 B2D4                <1> 	mov	dl, 0D4h
 14697 00003B2A EE                  <1> 	out	dx, al
 14698                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
 14699 00003B2B FEC2                <1> 	inc	dl  ; dx = 3D5h
 14700                              <1> 	; inb(crtc_addr+1)
 14701 00003B2D 50                  <1> 	push	eax
 14702 00003B2E EC                  <1> 	in	al, dx
 14703 00003B2F AA                  <1> 	stosb	; (25 bytes in loop)
 14704 00003B30 58                  <1> 	pop	eax
 14705                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 14706                              <1> 	;dec	dl	
 14707 00003B31 FEC0                <1> 	inc	al  ; i++
 14708 00003B33 FECD                <1> 	dec	ch
 14709 00003B35 75F1                <1> 	jnz	short bfn_svs_1
 14710                              <1> 
 14711 00003B37 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
 14712                              <1>         ; for(i=0;i<=0x13;i++) {
 14713 00003B3A 28C0                <1> 	sub	al, al ; 0
 14714 00003B3C B514                <1> 	mov	ch, 20
 14715                              <1> bfn_svs_2:
 14716                              <1> 	; inb(VGAREG_ACTL_RESET);
 14717                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 14718 00003B3E B2DA                <1> 	mov	dl, 0DAh
 14719 00003B40 50                  <1> 	push	eax
 14720 00003B41 EC                  <1> 	in	al, dx
 14721 00003B42 8A0424              <1> 	mov	al, [esp]
 14722                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
 14723 00003B45 08E0                <1> 	or	al, ah
 14724                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 14725 00003B47 B2C0                <1> 	mov	dl, 0C0h
 14726 00003B49 EE                  <1> 	out	dx, al
 14727                              <1> 	;mov	dx, VGAREG_ACTL_READ_DATA ; 3C1h
 14728                              <1> 	;mov	dl, 0C1h
 14729 00003B4A FEC2                <1> 	inc	dl
 14730 00003B4C EC                  <1> 	in	al, dx
 14731 00003B4D AA                  <1> 	stosb	; (20 bytes in loop)
 14732 00003B4E 58                  <1> 	pop	eax
 14733 00003B4F FEC0                <1> 	inc	al  ; i++
 14734 00003B51 FECD                <1> 	dec	ch
 14735 00003B53 75E9                <1> 	jnz	short bfn_svs_2
 14736                              <1> 
 14737                              <1> 	; inb(VGAREG_ACTL_RESET);
 14738                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 14739 00003B55 B2DA                <1> 	mov	dl, 0DAh
 14740 00003B57 EC                  <1> 	in	al, dx
 14741                              <1> 
 14742                              <1>         ; for(i=0;i<=8;i++) {
 14743 00003B58 28C0                <1> 	sub	al, al ; 0
 14744                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 14745                              <1> 	;mov	dl, 0CEh
 14746 00003B5A B509                <1> 	mov	ch, 9
 14747                              <1> bfn_svs_3:
 14748                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
 14749                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 14750 00003B5C B2CE                <1> 	mov	dl, 0CEh
 14751 00003B5E EE                  <1> 	out	dx, al
 14752                              <1> 	; inb(VGAREG_ACTL_READ_DATA)
 14753 00003B5F 50                  <1> 	push	eax
 14754                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
 14755                              <1> 	;mov	dl, 0CFh
 14756 00003B60 FEC2                <1> 	inc	dl
 14757 00003B62 EC                  <1> 	in	al, dx
 14758 00003B63 AA                  <1> 	stosb	; (9 bytes in loop)
 14759 00003B64 58                  <1> 	pop	eax
 14760                              <1> 	;dec	dl
 14761 00003B65 FEC0                <1> 	inc	al  ; i++
 14762 00003B67 FECD                <1> 	dec	ch
 14763 00003B69 75F1                <1> 	jnz	short bfn_svs_3
 14764                              <1> 
 14765                              <1> 	; write_word(ES, BX, crtc_addr); BX+= 2;
 14766                              <1> 	; (offset 64)
 14767 00003B6B 66B8D403            <1> 	mov	ax, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 14768 00003B6F 66AB                <1> 	stosw	; (2 bytes (1 word))
 14769                              <1> 
 14770                              <1>         ; /* XXX: read plane latches */
 14771 00003B71 31C0                <1> 	xor	eax, eax  ; 0
 14772 00003B73 AB                  <1>        	stosd	; (4 bytes)
 14773                              <1> 
 14774                              <1> 	; (total 70 bytes are written above as controller hardware state)
 14775                              <1> 
 14776                              <1> bfn_svs_4:		
 14777                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 14778 00003B74 F6C102              <1> 	test	cl, 2
 14779 00003B77 7476                <1> 	jz	short bfn_svs_6
 14780                              <1> 
 14781                              <1> 	; VIDEO BIOS DATA
 14782                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
 14783                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
 14784                              <1>   
 14785                              <1>     	; if (CX & 2) {
 14786                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++;
 14787                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2;
 14788                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2;
 14789                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2;
 14790                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++;
 14791                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2;
 14792                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++;
 14793                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++;
 14794                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++;
 14795                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2;
 14796                              <1>         ;for(i=0;i<8;i++) {
 14797                              <1>         ;   write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i));
 14798                              <1>         ;   BX += 2;
 14799                              <1>         ;}
 14800                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2;
 14801                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++;
 14802                              <1>         ;/* current font */
 14803                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2;
 14804                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2;
 14805                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2;
 14806                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2;
 14807                              <1> 
 14808                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
 14809                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
 14810                              <1> 
 14811 00003B79 66B8D403            <1> 	mov	ax, 3D4h ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
 14812 00003B7D 66AB                <1> 	stosw
 14813 00003B7F A0[9E660000]        <1> 	mov	al, [CRT_MODE] ; Current video mode (0FFh for VESA VBE modes) 
 14814 00003B84 AA                  <1> 	stosb
 14815 00003B85 A0[9F660000]        <1> 	mov	al, [CRT_MODE_SET] ; 29h for mode 03h ; TRDOS 386 feature only !
 14816 00003B8A AA                  <1> 	stosb	
 14817 00003B8B 66A1[D20F0300]      <1>  	mov	ax, [video_mode] ; Current VESA VBE (SVGA, extended VGA) mode 
 14818 00003B91 66AB                <1> 	stosw			 ; (valid if [CRT_MODE] = 0FFh)	
 14819 00003B93 66A1[14840100]      <1> 	mov	ax, [CRT_LEN] ; page size (in bytes)
 14820 00003B99 66AB                <1> 	stosw
 14821 00003B9B 66A1[9C770100]      <1> 	mov	ax, [CRT_START] ; video page start offset
 14822 00003BA1 66AB                <1>  	stosw
 14823 00003BA3 A0[A0660000]        <1> 	mov	al, [CRT_COLS] ; nbcols, characters per row	
 14824 00003BA8 AA                  <1> 	stosb
 14825 00003BA9 A0[A6660000]        <1> 	mov	al, [VGA_ROWS] ; nbrows, (character) rows per page (not rows-1)
 14826 00003BAE AA                  <1> 	stosb
 14827 00003BAF A0[A2660000]        <1> 	mov	al, [CHAR_HEIGHT] ; character font height (8 or 16 or 14)
 14828 00003BB4 AA                  <1> 	stosb
 14829 00003BB5 A0[A3660000]        <1> 	mov	al, [VGA_VIDEO_CTL] ; ROM BIOS DATA AREA Offset 87h
 14830 00003BBA AA                  <1> 	stosb
 14831 00003BBB A0[A4660000]        <1> 	mov	al, [VGA_SWITCHES] ; feature bit switches
 14832 00003BC0 AA                  <1> 	stosb
 14833 00003BC1 A0[A5660000]        <1> 	mov	al, [VGA_MODESET_CTL] ; basic mode set options
 14834 00003BC6 AA                  <1> 	stosb
 14835                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
 14836                              <1> 	; (bochs/plex86 does not use and return those)
 14837 00003BC7 A0[A1660000]        <1> 	mov	al, [CRT_PALETTE] ; current color palette ; TRDOS 386 feature only !
 14838 00003BCC AA                  <1> 	stosb
 14839 00003BCD A0[AE770100]        <1> 	mov	al, [ACTIVE_PAGE] ; current video page 
 14840 00003BD2 AA                  <1> 	stosb
 14841 00003BD3 66A1[B7660000]      <1> 	mov	ax, [CURSOR_MODE] ; cursor type
 14842 00003BD9 66AB                <1> 	stosw
 14843                              <1> 	;mov	eax, [CURSOR_POSN] ; cursor position for video page 0 and 1 
 14844                              <1> 	;stosd
 14845                              <1> 	;mov	eax, [CURSOR_POSN+4] ; cursor position for video page 2 and 3 
 14846                              <1> 	;stosd
 14847                              <1> 	;mov	eax, [CURSOR_POSN+8] ; cursor position for video page 4 and 5 
 14848                              <1> 	;stosd
 14849                              <1> 	;mov	eax, [CURSOR_POSN+12] ; cursor position for video page 6 and 7 
 14850                              <1> 	;stosd
 14851 00003BDB 56                  <1> 	push	esi
 14852 00003BDC B504                <1> 	mov	ch, 4
 14853 00003BDE BE[9E770100]        <1> 	mov	esi, CURSOR_POSN
 14854                              <1> bfn_svs_5:
 14855 00003BE3 A5                  <1> 	movsd
 14856 00003BE4 FECD                <1> 	dec	ch
 14857 00003BE6 75FB                <1> 	jnz	short bfn_svs_5
 14858 00003BE8 5E                  <1> 	pop	esi
 14859                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
 14860                              <1> 	; (not accessable/meaningful address value by user)
 14861 00003BE9 A1[26840100]        <1> 	mov	eax, [VGA_INT43H] ; VGA current (default) font address
 14862 00003BEE AB                  <1> 	stosd
 14863                              <1> 	
 14864                              <1> 	; (total 40 bytes are written above as BIOS data state)
 14865                              <1> 
 14866                              <1> bfn_svs_6:
 14867                              <1> 	; 12/01/2021
 14868 00003BEF F6C104              <1> 	test	cl, 4
 14869 00003BF2 7422                <1> 	jz	short bfn_svs_8
 14870                              <1> 
 14871                              <1>   	;/* XXX: check this */
 14872                              <1> 		; /* read/write mode dac */
 14873                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++;
 14874                              <1> 	;	; /* pix address */
 14875                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++;
 14876                              <1>         ;write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++;
 14877                              <1>         ;// Set the whole dac always, from 0
 14878                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
 14879                              <1>         ;for(i=0;i<256*3;i++) {
 14880                              <1>         ;   write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++;
 14881                              <1>         ;}
 14882                              <1>         ;write_byte(ES, BX, 0); BX++; /* color select register */
 14883                              <1> 
 14884                              <1> 	; /* read/write mode dac */
 14885 00003BF4 66BAC703            <1>     	mov	dx, 3C7h ; VGAREG_DAC_STATE
 14886 00003BF8 EC                  <1> 	in	al, dx
 14887 00003BF9 AA                  <1> 	stosb
 14888                              <1> 	; /* pix address */
 14889                              <1>     	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 14890                              <1> 	;mov	dl, 0C8h
 14891 00003BFA FEC2                <1> 	inc	dl
 14892 00003BFC EC                  <1> 	in	al, dx
 14893 00003BFD AA                  <1> 	stosb
 14894                              <1>     	;mov	dx, VGAREG_PEL_MASK  ; 3C6h
 14895 00003BFE B2C6                <1> 	mov	dl, 0C6h
 14896 00003C00 EC                  <1> 	in	al, dx
 14897 00003C01 AA                  <1> 	stosb
 14898                              <1> 	;// Set the whole dac always, from 0
 14899 00003C02 30C0                <1> 	xor	al, al ; 0
 14900                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 14901 00003C04 B2C8                <1> 	mov	dl, 0C8h
 14902 00003C06 EE                  <1> 	out	dx, al
 14903                              <1> 
 14904 00003C07 51                  <1> 	push	ecx ; 22/01/2021
 14905                              <1> 	;for(i=0;i<256*3;i++) {
 14906                              <1> 	;mov	ecx, 256*3 ; 768 bytes
 14907                              <1> 	; 03/08/2022
 14908 00003C08 29C9                <1> 	sub	ecx, ecx
 14909 00003C0A B503                <1> 	mov	ch, 3
 14910                              <1> 	; ecx = 300h = 768
 14911                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 14912                              <1> 	;mov	dl, 0C9h
 14913 00003C0C FEC2                <1> 	inc	dl ; dx = 3C9h
 14914                              <1> bfn_svs_7:
 14915 00003C0E EC                  <1> 	in	al, dx
 14916 00003C0F AA                  <1> 	stosb
 14917 00003C10 E2FC                <1> 	loop	bfn_svs_7
 14918 00003C12 59                  <1> 	pop	ecx ; 22/01/2021
 14919                              <1> 
 14920                              <1> 	; /* color select register */
 14921 00003C13 28C0                <1> 	sub	al, al ; 0
 14922 00003C15 AA                  <1> 	stosb
 14923                              <1> 
 14924                              <1> 	; (total 772 bytes are written above as DAC state)
 14925                              <1> bfn_svs_8:
 14926 00003C16 C3                  <1> 	retn
 14927                              <1> 
 14928                              <1> vbe_biosfn_save_video_state:
 14929                              <1> 	; 23/01/2021
 14930                              <1> 	; 13/01/2021
 14931                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 14932                              <1> 	; (vbe.c)
 14933                              <1> 
 14934                              <1> 	; modified registers: eax, edx, edi, ch
 14935                              <1> 	
 14936                              <1> 	; input: edi = state buffer address
 14937                              <1> 	; output: 
 14938                              <1> 	;	 VBE DISPI register contents will be saved
 14939                              <1> 	;	 (18 bytes, 9 words)
 14940                              <1> 
 14941                              <1> 	; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 14942                              <1> 	; enable = inw(VBE_DISPI_IOPORT_DATA);
 14943                              <1>   	; write_word(ES, BX, enable);
 14944                              <1>  	; BX += 2;
 14945                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) 
 14946                              <1> 	;	return;
 14947                              <1> 	; for(i = VBE_DISPI_INDEX_XRES;
 14948                              <1> 	;		 i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
 14949                              <1> 	;    if (i != VBE_DISPI_INDEX_ENABLE) {
 14950                              <1> 	;        outw(VBE_DISPI_IOPORT_INDEX, i);
 14951                              <1> 	;        write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
 14952                              <1>         ;    BX += 2;
 14953                              <1> 	;        }
 14954                              <1> 	; }
 14955                              <1> 
 14956 00003C17 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 14957                              <1> 	;mov	eax, 04h  ; VBE_DISPI_INDEX_ENABLE
 14958                              <1> 	 ;03/08/2022
 14959 00003C1B 66EF                <1> 	out	dx, ax
 14960                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA	
 14961 00003C1D FEC2                <1> 	inc	dl
 14962 00003C1F 66ED                <1> 	in	ax, dx ; enable (status)
 14963 00003C21 66AB                <1> 	stosw 
 14964 00003C23 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 14965 00003C27 7505                <1> 	jnz	short vbe_bfn_svs_0
 14966                              <1> 	; 23/01/2021
 14967                              <1> 	; ax = 0
 14968                              <1> 	; VBE_DISPI_DISABLED
 14969                              <1> 	; 13/01/2021
 14970                              <1> 	; clear remain 8 bytes 
 14971                              <1> 	;xor	eax, eax
 14972 00003C29 AB                  <1> 	stosd	; 2
 14973 00003C2A AB                  <1> 	stosd	; 2
 14974 00003C2B AB                  <1> 	stosd	; 2
 14975 00003C2C AB                  <1> 	stosd	; 2
 14976 00003C2D C3                  <1> 	retn
 14977                              <1> vbe_bfn_svs_0:
 14978                              <1> 	; VBE_DISPI_ENABLED
 14979                              <1> 
 14980                              <1> 	;sub	eax, eax
 14981 00003C2E 28C0                <1> 	sub	al, al ; eax = 0
 14982                              <1> 	
 14983                              <1> 	; from VBE_DISPI_INDEX_XRES
 14984                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 14985                              <1> 
 14986 00003C30 B503                <1>  	mov	ch, 3
 14987                              <1> 	; al = 0 ; VBE_DISPI_INDEX_XRES - 1
 14988                              <1> 
 14989 00003C32 E804000000          <1> 	call	vbe_bfn_svs_1
 14990                              <1> 
 14991                              <1> 	; from VBE_DISPI_INDEX_BANK
 14992                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 14993                              <1> 
 14994 00003C37 FEC0                <1> 	inc	al 
 14995                              <1> 	; al = 4 ; VBE_DISPI_INDEX_BANK - 1
 14996                              <1> 
 14997 00003C39 B505                <1> 	mov	ch, 5
 14998                              <1> vbe_bfn_svs_1:
 14999 00003C3B FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 15000                              <1> 		   ;   to VBE_DISPI_INDEX_BPP	
 15001                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15002 00003C3D FECA                <1> 	dec	dl ; 1CEh
 15003 00003C3F 66EF                <1> 	out	dx, ax
 15004 00003C41 50                  <1> 	push	eax
 15005                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15006 00003C42 FEC2                <1> 	inc	dl ; 1CFh
 15007 00003C44 66ED                <1> 	in	ax, dx
 15008 00003C46 66AB                <1> 	stosw
 15009 00003C48 58                  <1> 	pop	eax
 15010 00003C49 FECD                <1> 	dec	ch
 15011 00003C4B 75EE                <1> 	jnz	short vbe_bfn_svs_1		
 15012 00003C4D C3                  <1> 	retn
 15013                              <1> 
 15014                              <1> biosfn_restore_video_state:
 15015                              <1> 	; 22/01/2021
 15016                              <1> 	; 13/01/2021
 15017                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 15018                              <1> 	; (vgabios.c)
 15019                              <1> 
 15020                              <1> 	; modified registers: eax, edx, esi, edi, ch
 15021                              <1> 
 15022                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
 15023                              <1> 
 15024                              <1> 	; input: esi = state buffer address
 15025                              <1> 
 15026 00003C4E F6C101              <1> 	test	cl, 1
 15027 00003C51 0F84A9000000        <1> 	jz	bfn_rvs_6
 15028                              <1> 
 15029 00003C57 66817E40D403        <1> 	cmp	word [esi+64], 3D4h ; must be 3D4h
 15030 00003C5D 7402                <1> 	je	short bfn_rvs_0  
 15031                              <1> 			; it is seen as valid buffer
 15032 00003C5F F9                  <1> 	stc
 15033 00003C60 C3                  <1> 	retn
 15034                              <1> 
 15035                              <1> bfn_rvs_0:
 15036 00003C61 89F7                <1> 	mov	edi, esi ; addr1
 15037 00003C63 83C605              <1> 	add	esi, 5 ; skip 1st 5 bytes for now
 15038                              <1> 
 15039                              <1> 	; // Reset Attribute Ctl flip-flop
 15040                              <1>         ; inb(VGAREG_ACTL_RESET);
 15041 00003C66 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 15042 00003C6A EC                  <1> 	in	al, dx
 15043                              <1> 
 15044                              <1> 	; for(i=1;i<=4;i++){
 15045 00003C6B B001                <1> 	mov	al, 1
 15046                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 15047                              <1> 	;mov	dl, 0C4h
 15048 00003C6D B504                <1> 	mov	ch, 4
 15049                              <1> bfn_rvs_1:
 15050                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
 15051                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 15052 00003C6F B2C4                <1> 	mov	dl, 0C4h
 15053 00003C71 EE                  <1> 	out	dx, al
 15054                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
 15055 00003C72 FEC2                <1> 	inc	dl  ; dx = 3C5h
 15056                              <1> 	; outb(VGAREG_SEQU_DATA)
 15057 00003C74 50                  <1> 	push	eax
 15058 00003C75 AC                  <1> 	lodsb	; (4 bytes in loop)
 15059 00003C76 EE                  <1> 	out	dx, al
 15060 00003C77 58                  <1> 	pop	eax
 15061                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 15062                              <1> 	;dec	dl	
 15063 00003C78 FEC0                <1> 	inc	al  ; i++
 15064 00003C7A FECD                <1> 	dec	ch
 15065 00003C7C 75F1                <1> 	jnz	short bfn_rvs_1
 15066                              <1> 
 15067                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
 15068 00003C7E 28C0                <1> 	sub	al, al ; 0
 15069 00003C80 EE                  <1> 	out	dx, al
 15070                              <1> 	; outb(VGAREG_SEQU_DATA)
 15071                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
 15072 00003C81 FEC2                <1> 	inc	dl  ; dx = 3C5h
 15073 00003C83 AC                  <1> 	lodsb	; (+1 byte)
 15074 00003C84 EE                  <1> 	out	dx, al
 15075                              <1> 
 15076                              <1> 	; // Disable CRTC write protection
 15077                              <1> 	; outw(crtc_addr,0x0011);
 15078                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15079 00003C85 B2D4                <1> 	mov	dl, 0D4h
 15080 00003C87 66B81100            <1> 	mov	ax, 11h
 15081 00003C8B 66EF                <1> 	out	dx, ax
 15082                              <1> 
 15083                              <1> 	; // Set CRTC regs
 15084                              <1>        
 15085                              <1> 	; for(i=0;i<=0x18;i++) {
 15086                              <1>         ;   if (i != 0x11) {
 15087 00003C8D 28C0                <1> 	sub	al, al ; 0
 15088                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15089                              <1> 	;mov	dl, 0D4h
 15090 00003C8F B519                <1> 	mov	ch, 25
 15091                              <1> bfn_rvs_2:
 15092                              <1>         ; outb(crtc_addr,i);
 15093                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15094 00003C91 B2D4                <1> 	mov	dl, 0D4h
 15095 00003C93 EE                  <1> 	out	dx, al
 15096                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
 15097 00003C94 FEC2                <1> 	inc	dl  ; dx = 3D5h
 15098                              <1> 	; inb(crtc_addr+1)
 15099 00003C96 50                  <1> 	push	eax
 15100 00003C97 AC                  <1> 	lodsb	; (25 bytes in loop)
 15101 00003C98 EE                  <1> 	out	dx, al
 15102 00003C99 58                  <1> 	pop	eax
 15103                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15104                              <1> 	;dec	dl
 15105 00003C9A FEC0                <1> 	inc	al  ; i++
 15106 00003C9C 3C11                <1> 	cmp	al, 17 ; 11h
 15107 00003C9E 7505                <1> 	jne	short bfn_rvs_3
 15108 00003CA0 AC                  <1> 	lodsb
 15109 00003CA1 88C4                <1> 	mov	ah, al ; *
 15110 00003CA3 B012                <1> 	mov	al, 18 
 15111                              <1> bfn_rvs_3:
 15112 00003CA5 FECD                <1> 	dec	ch
 15113 00003CA7 75E8                <1> 	jnz	short bfn_rvs_2
 15114                              <1> 
 15115                              <1> 	; // select crtc base address
 15116                              <1>         ; v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01;
 15117                              <1> 	;if (crtc_addr = 0x3d4)
 15118                              <1> 	;   v |= 0x01;
 15119                              <1> 	; outb(VGAREG_WRITE_MISC_OUTPUT, v);
 15120                              <1> 
 15121                              <1> 	;;mov	dx, VGAREG_READ_MISC_OUTPUT ; 3CCh
 15122                              <1> 	;mov	dl, 0CCh
 15123                              <1> 	;in	al, dl
 15124                              <1> 	;and	al, 1
 15125                              <1> 	;;mov	dx, VGAREG_WRITE_MISC_OUTPUT ; 3C2h
 15126                              <1> 	;mov	dl, 0C2h
 15127                              <1> 	;or	al, 1
 15128                              <1> 	;out	dx, al
 15129                              <1> 
 15130                              <1> 	; // enable write protection if needed
 15131                              <1> 	;outb(crtc_addr, 0x11);
 15132                              <1>         ;outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11));
 15133                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15134 00003CA9 B2D4                <1> 	mov	dl, 0D4h
 15135 00003CAB B011                <1> 	mov	al, 11h
 15136 00003CAD EE                  <1> 	out	dx, al
 15137 00003CAE 88E0                <1> 	mov	al, ah ; *
 15138 00003CB0 FEC2                <1> 	inc	dl ; dx = 3D5h
 15139 00003CB2 EE                  <1> 	out	dx, al
 15140                              <1> 
 15141                              <1> 	; // Set Attribute Ctl
 15142 00003CB3 8A6703              <1> 	mov	ah, [edi+3] ; addr1+3, ah = ar_index
 15143 00003CB6 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
 15144                              <1> 
 15145                              <1>         ; inb(VGAREG_ACTL_RESET);
 15146                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 15147 00003CB9 B2DA                <1> 	mov	dl, 0DAh
 15148 00003CBB EC                  <1> 	in	al, dx
 15149                              <1> 
 15150                              <1>         ; for(i=0;i<=0x13;i++) {
 15151 00003CBC 28C0                <1> 	sub	al, al ; 0
 15152 00003CBE B514                <1> 	mov	ch, 20
 15153                              <1> bfn_rvs_4:
 15154                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
 15155 00003CC0 50                  <1> 	push	eax
 15156 00003CC1 08E0                <1> 	or	al, ah
 15157                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 15158 00003CC3 B2C0                <1> 	mov	dl, 0C0h
 15159 00003CC5 EE                  <1> 	out	dx, al
 15160                              <1> 	;mov	dx, VGAREG_ACTL_WRITE_DATA ; 3C0h
 15161                              <1> 	;mov	dl, 0C0h
 15162 00003CC6 AC                  <1> 	lodsb	; (20 bytes in loop)
 15163 00003CC7 EE                  <1> 	out	dx, al
 15164 00003CC8 58                  <1> 	pop	eax
 15165 00003CC9 FEC0                <1> 	inc	al  ; i++
 15166 00003CCB FECD                <1> 	dec	ch
 15167 00003CCD 75F1                <1> 	jnz	short bfn_rvs_4
 15168                              <1> 
 15169                              <1> 	; outb(VGAREG_ACTL_ADDRESS, ar_index);
 15170                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 15171                              <1> 	;mov	dl, 0C0h
 15172 00003CCF 88E0                <1> 	mov	al, ah ; ar_index
 15173 00003CD1 EE                  <1> 	out	dx, al
 15174                              <1> 
 15175                              <1> 	; inb(VGAREG_ACTL_RESET);
 15176                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 15177 00003CD2 B2DA                <1> 	mov	dl, 0DAh
 15178 00003CD4 EC                  <1> 	in	al, dx
 15179                              <1> 
 15180                              <1>         ; for(i=0;i<=8;i++) {
 15181 00003CD5 28C0                <1> 	sub	al, al ; 0
 15182                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 15183                              <1> 	;mov	dl, 0CEh
 15184 00003CD7 B509                <1> 	mov	ch, 9
 15185                              <1> bfn_rvs_5:
 15186                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
 15187                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 15188 00003CD9 B2CE                <1> 	mov	dl, 0CEh
 15189 00003CDB EE                  <1> 	out	dx, al
 15190                              <1> 	; outb(VGAREG_ACTL_READ_DATA)
 15191 00003CDC 50                  <1> 	push	eax
 15192                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
 15193                              <1> 	;mov	dl, 0CFh
 15194 00003CDD FEC2                <1> 	inc	dl
 15195 00003CDF AC                  <1> 	lodsb	; (9 bytes in loop)
 15196 00003CE0 EE                  <1> 	out	dx, al
 15197 00003CE1 58                  <1> 	pop	eax
 15198                              <1> 	;dec	dl
 15199 00003CE2 FEC0                <1> 	inc	al  ; i++
 15200 00003CE4 FECD                <1> 	dec	ch
 15201 00003CE6 75F1                <1> 	jnz	short bfn_rvs_5
 15202                              <1> 
 15203                              <1> 	; BX += 2; /* crtc_addr */     ; 3D4h
 15204                              <1>         ; BX += 4; /* plane latches */ ; 0
 15205 00003CE8 83C606              <1> 	add	esi, 6	      
 15206 00003CEB 56                  <1> 	push	esi ; *	
 15207                              <1> 
 15208                              <1> 	;outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++;
 15209                              <1>         ;outb(crtc_addr, read_byte(ES, addr1)); addr1++;
 15210                              <1>         ;outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++;
 15211                              <1>         ;addr1++;
 15212                              <1>         ;outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++;
 15213                              <1> 
 15214 00003CEC 89FE                <1> 	mov	esi, edi ; start of state buffer
 15215                              <1> 
 15216                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
 15217 00003CEE B2C7                <1> 	mov	dl, 0C7h 
 15218 00003CF0 AC                  <1> 	lodsb
 15219 00003CF1 EE                  <1> 	out	dx, al
 15220                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 15221 00003CF2 B2D4                <1> 	mov	dl, 0D4h
 15222 00003CF4 AC                  <1> 	lodsb
 15223 00003CF5 EE                  <1> 	out	dx, al
 15224                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
 15225 00003CF6 B2CE                <1>         mov	dl, 0CEh
 15226 00003CF8 AC                  <1> 	lodsb
 15227 00003CF9 EE                  <1> 	out	dx, al
 15228 00003CFA AC                  <1> 	lodsb	; addr1++
 15229                              <1> 	;mov	dx, VGAREG_VGA_WRITE_FEATURE_CTL ; 3DAh
 15230 00003CFB B2DA                <1> 	mov	dl, 0DAh
 15231 00003CFD AC                  <1> 	lodsb
 15232 00003CFE EE                  <1> 	out	dx, al
 15233                              <1> 
 15234 00003CFF 5E                  <1> 	pop	esi ; *
 15235                              <1> 
 15236                              <1> 	; (total 70 bytes are read above as controller hardware state)
 15237                              <1> 
 15238                              <1> bfn_rvs_6:		
 15239                              <1> 	; 13/01/2021
 15240 00003D00 F6C102              <1> 	test	cl, 2
 15241 00003D03 747D                <1> 	jz	short bfn_rvs_9
 15242                              <1> 
 15243                              <1> 	; VIDEO BIOS DATA
 15244                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
 15245                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
 15246                              <1>   
 15247                              <1>     	; if (CX & 2) {
 15248                              <1> 	;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++;
 15249                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2;
 15250                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2;
 15251                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2;
 15252                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++;
 15253                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2;
 15254                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++;
 15255                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++;
 15256                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++;
 15257                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2;
 15258                              <1>         ;for(i=0;i<8;i++) {
 15259                              <1>         ;   write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX));
 15260                              <1>         ;   BX += 2;
 15261                              <1>         ;}
 15262                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2;
 15263                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++;
 15264                              <1>         ;/* current font */
 15265                              <1>         ;write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2;
 15266                              <1>         ;write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2;
 15267                              <1>         ;write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2;
 15268                              <1>         ;write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2;
 15269                              <1> 
 15270                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
 15271                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
 15272                              <1> 
 15273 00003D05 66AD                <1> 	lodsw	 ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
 15274                              <1> 	; skip 3D4h check if it is already checked
 15275 00003D07 F6C101              <1> 	test	cl, 1
 15276 00003D0A 7508                <1> 	jnz	short bfn_rvs_7
 15277 00003D0C 663DD403            <1> 	cmp	ax, 3D4h
 15278 00003D10 7402                <1> 	je	short bfn_rvs_7
 15279 00003D12 F9                  <1> 	stc
 15280 00003D13 C3                  <1> 	retn
 15281                              <1> bfn_rvs_7:
 15282 00003D14 AC                  <1> 	lodsb
 15283 00003D15 A2[9E660000]        <1> 	mov	[CRT_MODE], al ; Current video mode (0FFh for VESA VBE modes) 
 15284 00003D1A AC                  <1> 	lodsb
 15285 00003D1B A2[9F660000]        <1> 	mov	[CRT_MODE_SET], al ; 29h for mode 03h ; TRDOS 386 feature only !
 15286 00003D20 66AD                <1> 	lodsw	
 15287 00003D22 66A3[D20F0300]      <1>  	mov	[video_mode], ax ; Current VESA VBE (SVGA, extended VGA) mode 
 15288 00003D28 66AD                <1> 	lodsw		 ; (valid if [CRT_MODE] = 0FFh)	
 15289 00003D2A 66A3[14840100]      <1> 	mov	[CRT_LEN], ax ; page size (in bytes)
 15290 00003D30 66AD                <1> 	lodsw
 15291 00003D32 66A3[9C770100]      <1> 	mov	[CRT_START], ax ; video page start offset
 15292 00003D38 AC                  <1>  	lodsb
 15293 00003D39 A2[A0660000]        <1> 	mov	[CRT_COLS], al ; nbcols, characters per row
 15294 00003D3E AC                  <1> 	lodsb
 15295 00003D3F A2[A6660000]        <1> 	mov	[VGA_ROWS], al ; nbrows, (character) rows per page (not rows-1)
 15296 00003D44 AC                  <1> 	lodsb
 15297 00003D45 A2[A2660000]        <1> 	mov	[CHAR_HEIGHT], al ; character font height (8 or 16 or 14)
 15298 00003D4A AC                  <1> 	lodsb
 15299 00003D4B A2[A3660000]        <1> 	mov	[VGA_VIDEO_CTL], al ; ROM BIOS DATA AREA Offset 87h
 15300 00003D50 AC                  <1> 	lodsb
 15301 00003D51 A2[A4660000]        <1> 	mov	[VGA_SWITCHES], al ; feature bit switches
 15302 00003D56 AC                  <1> 	lodsb
 15303 00003D57 A2[A5660000]        <1> 	mov	[VGA_MODESET_CTL], al ; basic mode set options
 15304                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
 15305                              <1> 	; (bochs/plex86 does not use and return those)
 15306 00003D5C AC                  <1> 	lodsb
 15307 00003D5D A2[A1660000]        <1> 	mov	[CRT_PALETTE], al ; current color palette ; TRDOS 386 feature only !
 15308 00003D62 AC                  <1> 	lodsb
 15309 00003D63 A2[AE770100]        <1> 	mov	[ACTIVE_PAGE], al ; current video page 
 15310 00003D68 66AD                <1> 	lodsw
 15311 00003D6A 66A3[B7660000]      <1> 	mov	[CURSOR_MODE], ax ; cursor type
 15312                              <1> 	;lodsd
 15313                              <1> 	;mov	[CURSOR_POSN], eax ; cursor position for video page 0 and 1 
 15314                              <1> 	;lodsd
 15315                              <1> 	;mov	[CURSOR_POSN+4], eax ; cursor position for video page 2 and 3 
 15316                              <1> 	;lodsd
 15317                              <1> 	;mov	[CURSOR_POSN+8], eax ; cursor position for video page 4 and 5 
 15318                              <1> 	;lodsd
 15319                              <1> 	;mov	[CURSOR_POSN+12], eax ; cursor position for video page 6 and 7 
 15320 00003D70 B504                <1> 	mov	ch, 4
 15321 00003D72 BF[9E770100]        <1> 	mov	edi, CURSOR_POSN
 15322                              <1> bfn_rvs_8:
 15323 00003D77 A5                  <1> 	movsd
 15324 00003D78 FECD                <1> 	dec	ch
 15325 00003D7A 75FB                <1> 	jnz	short bfn_rvs_8
 15326                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
 15327                              <1> 	; (not accessable/meaningful address value by user)
 15328 00003D7C AD                  <1> 	lodsd
 15329 00003D7D A3[26840100]        <1> 	mov	[VGA_INT43H], eax ; VGA current (default) font address
 15330                              <1> 
 15331                              <1> 	; (total 40 bytes are read&written above as BIOS data state)
 15332                              <1> bfn_rvs_9:
 15333                              <1> 	; 13/01/2021
 15334 00003D82 F6C104              <1> 	test	cl, 4
 15335 00003D85 7421                <1> 	jz	short bfn_rvs_11
 15336                              <1> 
 15337                              <1> 	;BX++;
 15338                              <1>         ;v = read_byte(ES, BX); BX++;
 15339                              <1>         ;outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++;
 15340                              <1>         ;// Set the whole dac always, from 0
 15341                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
 15342                              <1>         ;for(i=0;i<256*3;i++) {
 15343                              <1>         ;   outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++;
 15344                              <1>         ;}
 15345                              <1>         ;BX++;
 15346                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS, v);
 15347                              <1> 
 15348                              <1> 	; /* read/write mode dac */
 15349 00003D87 AC                  <1> 	lodsb	; skip ; VGAREG_DAC_STATE
 15350 00003D88 AC                  <1> 	lodsb
 15351 00003D89 88C4                <1> 	mov	ah, al ; * ; v
 15352 00003D8B AC                  <1> 	lodsb
 15353 00003D8C 66BAC603            <1> 	mov	dx, VGAREG_PEL_MASK  ; 3C6h
 15354 00003D90 EE                  <1> 	out	dx, al
 15355                              <1> 	;// Set the whole dac always, from 0
 15356 00003D91 30C0                <1> 	xor	al, al ; 0
 15357                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 15358 00003D93 B2C8                <1> 	mov	dl, 0C8h
 15359 00003D95 EE                  <1> 	out	dx, al
 15360                              <1> 
 15361 00003D96 51                  <1> 	push	ecx ; 22/01/2021
 15362                              <1> 	;for(i=0;i<256*3;i++) {
 15363                              <1> 	;mov	ecx, 256*3 ; 768 bytes
 15364                              <1> 	; 03/08/2022
 15365 00003D97 29C9                <1> 	sub	ecx, ecx
 15366 00003D99 B503                <1> 	mov	ch, 3
 15367                              <1> 	; ecx = 300h = 768
 15368                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 15369                              <1> 	;mov	dl, 0C9h
 15370 00003D9B FEC2                <1> 	inc	dl ; dx = 3C9h
 15371                              <1> bfn_rvs_10:
 15372 00003D9D AC                  <1> 	lodsb
 15373 00003D9E EE                  <1> 	out	dx, al
 15374 00003D9F E2FC                <1> 	loop	bfn_rvs_10
 15375 00003DA1 59                  <1> 	pop	ecx ; 22/01/2021
 15376                              <1> 
 15377                              <1> 	; /* color select register */
 15378 00003DA2 AC                  <1> 	lodsb	 ; skip 
 15379                              <1> 	
 15380 00003DA3 88E0                <1> 	mov	al, ah ; * ; v
 15381                              <1> 
 15382                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 15383                              <1> 	;mov	dl, 0C8h
 15384 00003DA5 FECA                <1> 	dec	dl ; dx  = 3C8h
 15385 00003DA7 EE                  <1> 	out	dx, al ; * ; v
 15386                              <1> 	
 15387                              <1> 	; (total 772 bytes are read above as DAC state)
 15388                              <1> bfn_rvs_11:
 15389 00003DA8 C3                  <1> 	retn
 15390                              <1> 
 15391                              <1> vbe_biosfn_restore_video_state:
 15392                              <1> 	; 23/01/2021
 15393                              <1> 	; 13/01/2021 (TRDOS 386 v2.0.3)
 15394                              <1> 	; (vbe.c)
 15395                              <1> 
 15396                              <1> 	; modified registers: eax, edx, esi, ch
 15397                              <1> 	
 15398                              <1> 	; input: esi = state buffer address
 15399                              <1> 	; output: 
 15400                              <1> 	;	 VBE DISPI register contents will be restored
 15401                              <1> 	;	 (18 bytes, 9 words)
 15402                              <1> 
 15403                              <1>  	; enable = read_word(ES, BX);
 15404                              <1> 	; BX += 2;
 15405                              <1> 	;
 15406                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) {
 15407                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 15408                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 15409                              <1> 	; } else {
 15410                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
 15411                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 15412                              <1>         ;   BX += 2;
 15413                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
 15414                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 15415                              <1>         ;   BX += 2;
 15416                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
 15417                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 15418                              <1>         ;   BX += 2;
 15419                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 15420                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 15421                              <1> 	;
 15422                              <1>         ;  for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++)
 15423                              <1> 	;    {
 15424                              <1>         ;     outw(VBE_DISPI_IOPORT_INDEX, i);
 15425                              <1>         ;     outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 15426                              <1>         ;     BX += 2;
 15427                              <1>         ;    }
 15428                              <1>         ; }
 15429                              <1> 
 15430 00003DA9 66AD                <1> 	lodsw	; enable (status, enabled=1, disabled=0)
 15431 00003DAB 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15432                              <1> 	; 23/01/2021
 15433 00003DAF 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 15434 00003DB3 750B                <1> 	jnz	short vbe_bfn_rvs_1
 15435                              <1> 	; ax = 0
 15436                              <1> 	; VBE_DISPI_DISABLED
 15437                              <1> vbe_bfn_rvs_0:
 15438                              <1> 	; enable (disable) dispi
 15439                              <1> 	; dx = 01CEh ; VBE_DISPI_IOPORT_INDEX
 15440                              <1> 	; ah = 0
 15441 00003DB5 50                  <1> 	push	eax
 15442 00003DB6 B004                <1> 	mov	al, 04h	; VBE_DISPI_INDEX_ENABLE
 15443 00003DB8 66EF                <1> 	out	dx, ax
 15444                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15445 00003DBA FEC2                <1> 	inc	dl
 15446 00003DBC 58                  <1> 	pop	eax
 15447 00003DBD 66EF                <1> 	out	dx, ax ; enable (or disable)
 15448 00003DBF C3                  <1> 	retn
 15449                              <1> vbe_bfn_rvs_1:
 15450                              <1> 	; VBE_DISPI_ENABLED
 15451                              <1> 
 15452                              <1> 	; from VBE_DISPI_INDEX_XRES
 15453                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 15454                              <1> 
 15455 00003DC0 B503                <1>  	mov	ch, 3
 15456 00003DC2 28C0                <1> 	sub	al, al ; 0 ; VBE_DISPI_INDEX_XRES - 1
 15457                              <1> 	; ax = 0
 15458                              <1> 
 15459 00003DC4 E80B000000          <1> 	call	vbe_bfn_rvs_2
 15460                              <1> 
 15461                              <1>         ;outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 15462                              <1> 	;outw(VBE_DISPI_IOPORT_DATA, enable);
 15463                              <1> 
 15464                              <1> 	; 23/01/2021
 15465 00003DC9 B001                <1> 	mov	al, 1 ; VBE_DISPI_ENABLED
 15466                              <1> 	; ax = 1
 15467 00003DCB E8E5FFFFFF          <1> 	call	vbe_bfn_rvs_0
 15468                              <1> 
 15469                              <1> 	; from VBE_DISPI_INDEX_BANK
 15470                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 15471                              <1> 
 15472 00003DD0 B505                <1> 	mov	ch, 5
 15473                              <1> 	; 23/01/2021
 15474 00003DD2 B004                <1> 	mov	al, 4  ; VBE_DISPI_INDEX_BANK - 1
 15475                              <1> 	; ax = 4
 15476                              <1> vbe_bfn_rvs_2:
 15477 00003DD4 FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 15478                              <1> 		     ; to VBE_DISPI_INDEX_BPP	
 15479                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15480                              <1> 	;mov	dl, 0CEh
 15481 00003DD6 66EF                <1> 	out	dx, ax
 15482 00003DD8 50                  <1> 	push	eax
 15483                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15484 00003DD9 FEC2                <1> 	inc	dl ; 1CFh
 15485 00003DDB 66AD                <1> 	lodsw
 15486 00003DDD 66EF                <1> 	out	dx, ax
 15487 00003DDF 58                  <1> 	pop	eax
 15488 00003DE0 FECA                <1> 	dec	dl ; 1CEh
 15489 00003DE2 FECD                <1> 	dec	ch
 15490 00003DE4 75EE                <1> 	jnz	short vbe_bfn_rvs_2		
 15491 00003DE6 C3                  <1> 	retn
 15492                              <1> 
 15493                              <1> ; ---------------------------------------------------------
 15494                              <1>  
 15495                              <1> dispi_set_enable:
 15496                              <1> 	; 03/08/2022
 15497                              <1> 	; 23/11/2020
 15498                              <1> 	; Input:
 15499                              <1> 	;	ax = VBE_DISPI_ENABLED = 1
 15500                              <1> 	;	     or VBE_DISPI_DISABLED = 0
 15501                              <1> 	;
 15502                              <1> 	; Modified registers: none
 15503                              <1> 	
 15504                              <1> 	;push	edx
 15505                              <1> 	;push	eax
 15506                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15507                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 15508                              <1> 	;out	dx, ax
 15509                              <1> 	;pop	eax
 15510                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15511                              <1> 	;;mov	dl, 0CFh
 15512                              <1> 	;inc	dl
 15513                              <1> 	;out	dx, ax
 15514                              <1> 	;pop	edx
 15515                              <1> 	;retn
 15516                              <1> 
 15517                              <1> 	; 25/11/2020
 15518                              <1> 	; Modified registers: edx
 15519                              <1> 	;;push	edx
 15520                              <1> 	;mov	dx, 04h ; VBE_DISPI_INDEX_ENABLE
 15521                              <1> 	; 03/08/2022
 15522 00003DE7 28F6                <1> 	sub	dh, dh
 15523 00003DE9 B204                <1> 	mov	dl, 04h ; VBE_DISPI_INDEX_ENABLE
 15524                              <1> 
 15525                              <1> 	;;call	dispi_set_parms
 15526                              <1> 	;;pop	edx
 15527                              <1> 	;;retn
 15528                              <1> 	;jmp	short dispi_set_parms
 15529                              <1> 
 15530                              <1> dispi_set_parms:
 15531                              <1> 	; 03/08/2022
 15532                              <1> 	; 25/11/2020
 15533                              <1> 	; Input:
 15534                              <1> 	;	ax = data
 15535                              <1> 	;	dx = vbe dispi register index
 15536                              <1> 	;
 15537                              <1> 	; Modified registers: edx
 15538                              <1> 
 15539 00003DEB 50                  <1> 	push	eax
 15540                              <1> 	;mov	ax, dx
 15541                              <1> 	; 03/08/2022
 15542 00003DEC 89D0                <1> 	mov	eax, edx
 15543 00003DEE 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15544 00003DF2 66EF                <1> 	out	dx, ax
 15545 00003DF4 58                  <1> 	pop	eax
 15546                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15547                              <1> 	;mov	dl, 0CFh
 15548 00003DF5 FEC2                <1> 	inc	dl
 15549 00003DF7 66EF                <1> 	out	dx, ax
 15550 00003DF9 C3                  <1> 	retn
 15551                              <1> 
 15552                              <1> dispi_set_bpp:
 15553                              <1> 	; 03/08/2022
 15554                              <1> 	; 25/11/2020
 15555                              <1> 	; Input:
 15556                              <1> 	;	ax = Bits per pixel value
 15557                              <1> 	;	     (8,16,24,32)
 15558                              <1> 	;
 15559                              <1> 	; Modified registers: none
 15560                              <1> 
 15561                              <1> 	;push	edx
 15562                              <1> 	;push	eax
 15563                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15564                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 15565                              <1> 	;out	dx, ax
 15566                              <1> 	;pop	eax
 15567                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15568                              <1> 	;;mov	dl, 0CFh
 15569                              <1> 	;inc	dl
 15570                              <1> 	;out	dx, ax
 15571                              <1> 	;pop	edx
 15572                              <1> 	;retn
 15573                              <1> 
 15574                              <1> 	; 25/11/2020
 15575                              <1> 	; Modified registers: edx
 15576                              <1> 	;;push	edx
 15577                              <1> 	;mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 15578                              <1> 	; 03/08/2022
 15579 00003DFA 28F6                <1> 	sub	dh, dh
 15580 00003DFC B203                <1> 	mov	dl, 03h ; VBE_DISPI_INDEX_BPP	
 15581                              <1> 
 15582                              <1> 	;;call	dispi_set_parms
 15583                              <1> 	;;pop	edx
 15584                              <1> 	;;retn
 15585 00003DFE EBEB                <1> 	jmp	short dispi_set_parms
 15586                              <1> 
 15587                              <1> dispi_set_xres:
 15588                              <1> 	; 03/08/2022
 15589                              <1> 	; 25/11/2020
 15590                              <1> 	; Input:
 15591                              <1> 	;	ax = X resolution (screen witdh)
 15592                              <1> 	;	     (320,640,800,1024,1280,1920)
 15593                              <1> 	;
 15594                              <1> 	; Modified registers: none
 15595                              <1> 
 15596                              <1> 	;push	edx
 15597                              <1> 	;push	eax
 15598                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15599                              <1> 	;mov	ax, 01h	  ; VBE_DISPI_INDEX_XRES
 15600                              <1> 	;out	dx, ax
 15601                              <1> 	;pop	eax
 15602                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15603                              <1> 	;;mov	dl, 0CFh
 15604                              <1> 	;inc	dl
 15605                              <1> 	;out	dx, ax
 15606                              <1> 	;pop	edx
 15607                              <1> 	;retn
 15608                              <1> 
 15609                              <1> 	; 25/11/2020
 15610                              <1> 	; Modified registers: edx
 15611                              <1> 	;;push	edx
 15612                              <1> 	;mov	dx, 01h ; VBE_DISPI_INDEX_XRES
 15613                              <1> 	; 03/08/2022
 15614 00003E00 28F6                <1> 	sub	dh, dh
 15615 00003E02 B201                <1> 	mov	dl, 01h ; VBE_DISPI_INDEX_XRES
 15616                              <1> 	;;call	dispi_set_parms
 15617                              <1> 	;;pop	edx
 15618                              <1> 	;;retn
 15619 00003E04 EBE5                <1> 	jmp	short dispi_set_parms
 15620                              <1> 
 15621                              <1> dispi_set_yres:
 15622                              <1> 	; 03/08/2022
 15623                              <1> 	; 25/11/2020
 15624                              <1> 	; Input:
 15625                              <1> 	;	ax = Y resolution (screen height)
 15626                              <1> 	;	     (200,400,600,720,768,1080)
 15627                              <1> 	;
 15628                              <1> 	; Modified registers: none
 15629                              <1> 
 15630                              <1> 	;push	edx
 15631                              <1> 	;push	eax
 15632                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15633                              <1> 	;mov	ax, 02h	  ; VBE_DISPI_INDEX_YRES
 15634                              <1> 	;out	dx, ax
 15635                              <1> 	;pop	eax
 15636                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15637                              <1> 	;;mov	dl, 0CFh
 15638                              <1> 	;inc	dl
 15639                              <1> 	;out	dx, ax
 15640                              <1> 	;pop	edx
 15641                              <1> 	;retn
 15642                              <1> 
 15643                              <1> 	; 25/11/2020
 15644                              <1> 	; Modified registers: edx
 15645                              <1> 	;;push	edx
 15646                              <1> 	;mov	dx, 02h ; VBE_DISPI_INDEX_YRES
 15647                              <1> 	; 03/08/2022
 15648 00003E06 28F6                <1> 	sub	dh, dh
 15649 00003E08 B202                <1> 	mov	dl, 02h ; VBE_DISPI_INDEX_YRES
 15650                              <1> 	;;call	dispi_set_parms
 15651                              <1> 	;;pop	edx
 15652                              <1> 	;;retn
 15653 00003E0A EBDF                <1> 	jmp	short dispi_set_parms
 15654                              <1> 
 15655                              <1> dispi_set_bank:
 15656                              <1> 	; 03/08/2022
 15657                              <1> 	; 25/11/2020
 15658                              <1> 	; Input:
 15659                              <1> 	;	ax = video memory bank number
 15660                              <1> 	;
 15661                              <1> 	; Modified registers: none
 15662                              <1> 
 15663                              <1> 	;push	edx
 15664                              <1> 	;push	eax
 15665                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15666                              <1> 	;mov	ax, 05h	  ; VBE_DISPI_INDEX_BANK
 15667                              <1> 	;out	dx, ax
 15668                              <1> 	;pop	eax
 15669                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15670                              <1> 	;;mov	dl, 0CFh
 15671                              <1> 	;inc	dl
 15672                              <1> 	;out	dx, ax
 15673                              <1> 	;pop	edx
 15674                              <1> 	;retn
 15675                              <1> 	
 15676                              <1> 	; 25/11/2020
 15677                              <1> 	; Modified registers: edx
 15678                              <1> 	;;push	edx
 15679                              <1> 	;mov	dx, 05h	; VBE_DISPI_INDEX_BANK
 15680                              <1> 	; 03/08/2022
 15681 00003E0C 28F6                <1> 	sub	dh, dh
 15682 00003E0E B205                <1> 	mov	dl, 05h	; VBE_DISPI_INDEX_BANK
 15683                              <1> 	;;call	dispi_set_parms
 15684                              <1> 	;;pop	edx
 15685                              <1> 	;;retn
 15686 00003E10 EBD9                <1> 	jmp	short dispi_set_parms
 15687                              <1> 
 15688                              <1> dispi_get_enable:
 15689                              <1> 	; 03/08/2022
 15690                              <1> 	; 27/11/2020
 15691                              <1> 	; Input:
 15692                              <1> 	;	none
 15693                              <1> 	; Output:
 15694                              <1> 	;	ax = vbe dispi status
 15695                              <1> 	;
 15696                              <1> 	; Modified registers: eax
 15697                              <1> 	
 15698                              <1> 	;push	edx
 15699                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15700                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 15701                              <1> 	;out	dx, ax
 15702                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15703                              <1> 	;;mov	dl, 0CFh
 15704                              <1> 	;inc	dl
 15705                              <1> 	;in	ax, dx
 15706                              <1> 	;pop	edx
 15707                              <1> 	;retn
 15708                              <1> 
 15709                              <1> 	; 27/11/2020
 15710                              <1> 	; Modified registers: eax, edx
 15711                              <1> 	;;push	edx
 15712                              <1> 	;mov	ax, 04h ; VBE_DISPI_INDEX_ENABLE
 15713                              <1> 	; 03/08/2022
 15714 00003E12 28E4                <1> 	sub	ah, ah
 15715 00003E14 B004                <1> 	mov	al, 04h ; VBE_DISPI_INDEX_ENABLE
 15716                              <1> 
 15717                              <1> 	;;call	dispi_get_parms
 15718                              <1> 	;;pop	edx
 15719                              <1> 	;;retn
 15720                              <1> 	;jmp	short dispi_get_parms
 15721                              <1> 
 15722                              <1> dispi_get_parms:
 15723                              <1> 	; 25/11/2020
 15724                              <1> 	; Input:
 15725                              <1> 	;	ax = vbe dispi register index
 15726                              <1> 	; output:
 15727                              <1> 	;	ax = data
 15728                              <1> 	;
 15729                              <1> 	; Modified registers: eax, edx
 15730                              <1> 
 15731 00003E16 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 15732 00003E1A 66EF                <1> 	out	dx, ax
 15733                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 15734                              <1> 	;mov	dl, 0CFh
 15735 00003E1C FEC2                <1> 	inc	dl
 15736 00003E1E 66ED                <1> 	in	ax, dx
 15737 00003E20 C3                  <1> 	retn
 15738                              <1> 
 15739                              <1> vga_compat_setup:
 15740                              <1> 	; 03/08/2022
 15741                              <1> 	; 26/11/2020
 15742                              <1> 	; 25/11/2020
 15743                              <1> 	; VGA compatibility setup
 15744                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 15745                              <1> 	;
 15746                              <1> 	; Input:
 15747                              <1> 	;	none
 15748                              <1> 	;
 15749                              <1> 	; Modified registers: eax, edx
 15750                              <1> 	
 15751                              <1> 	; 26/11/2020
 15752                              <1>   	;push	eax
 15753                              <1>   	;push	edx
 15754                              <1> 
 15755                              <1>   	; set CRT X resolution
 15756 00003E21 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 15757                              <1>   	;mov	ax, 01h  ; VBE_DISPI_INDEX_XRES
 15758                              <1>   	; 03/08/2022
 15759 00003E25 31C0                <1> 	xor	eax, eax
 15760 00003E27 FEC0                <1> 	inc	al
 15761                              <1> 	; eax = 1
 15762 00003E29 66EF                <1> 	out	dx, ax
 15763                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 15764 00003E2B FEC2                <1>   	inc	dl
 15765 00003E2D 66ED                <1> 	in	ax, dx
 15766 00003E2F 50                  <1> 	push	eax
 15767 00003E30 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 15768 00003E34 66B81100            <1> 	mov	ax, 0011h ; Vertical retrace end register
 15769 00003E38 66EF                <1>   	out	dx, ax
 15770                              <1>   	;pop	eax
 15771                              <1>   	;push	eax
 15772 00003E3A 8B0424              <1>   	mov	eax, [esp]
 15773                              <1> 	;shr	ax, 3 ; / 8 for pixel to character
 15774                              <1> 	;dec	ax  ; - 1 (EGA or VGA?)
 15775                              <1>   	; 03/08/2022
 15776 00003E3D C1E803              <1> 	shr	eax, 3
 15777 00003E40 48                  <1>   	dec	eax
 15778 00003E41 88C4                <1> 	mov	ah, al
 15779 00003E43 B001                <1>   	mov	al, 01h ; Horizontal display end register
 15780 00003E45 66EF                <1>   	out	dx, ax
 15781 00003E47 58                  <1>   	pop	eax
 15782                              <1> 
 15783 00003E48 E89C000000          <1> 	call	vga_set_virt_width
 15784                              <1> 
 15785                              <1>   	; set CRT Y resolution
 15786                              <1> 	; 03/08/2022
 15787 00003E4D 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 15788 00003E51 66B80200            <1>   	mov	ax, 02h  ; VBE_DISPI_INDEX_YRES
 15789 00003E55 66EF                <1>   	out	dx, ax
 15790                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 15791                              <1> 	; 03/08/2022
 15792 00003E57 FEC2                <1>   	inc	dl
 15793 00003E59 66ED                <1> 	in	ax, dx
 15794 00003E5B 50                  <1> 	push	eax
 15795 00003E5C 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 15796 00003E60 88C4                <1>   	mov	ah, al
 15797 00003E62 B012                <1> 	mov	al, 12h ; Vertical display end register
 15798 00003E64 66EF                <1>   	out	dx, ax
 15799 00003E66 58                  <1>   	pop	eax
 15800 00003E67 B007                <1>   	mov	al, 07h	; Overflow register
 15801 00003E69 EE                  <1>   	out	dx, al
 15802                              <1>   	;inc	dx
 15803                              <1>   	; 03/08/2022
 15804 00003E6A FEC2                <1> 	inc	dl
 15805 00003E6C EC                  <1> 	in	al, dx ; read overflow register
 15806 00003E6D 24BD                <1>   	and	al, 0BDh ; clear VDE 9th and 10th bits	
 15807 00003E6F F6C401              <1>   	test	ah, 01h
 15808 00003E72 7402                <1>   	jz	short bit8_clear
 15809 00003E74 0C02                <1>   	or	al, 02h ; VDE 9th bit (bit 8) in bit 1
 15810                              <1> bit8_clear:
 15811 00003E76 F6C402              <1>   	test	ah, 02h
 15812 00003E79 7402                <1>   	jz	short bit9_clear
 15813 00003E7B 0C40                <1>   	or	al, 40h ; VDE 10th bit (bit 9) in bit 6
 15814                              <1> bit9_clear:
 15815 00003E7D EE                  <1>   	out	dx, al
 15816                              <1> 
 15817                              <1>   	; other settings
 15818                              <1>  	;mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 15819                              <1>   	; 03/08/2022
 15820 00003E7E B2D4                <1> 	mov	dl, 0D4h
 15821 00003E80 66B80900            <1> 	mov	ax, 0009h ; Maximum scan line register
 15822 00003E84 66EF                <1>   	out	dx, ax	; Reset
 15823 00003E86 B017                <1>   	mov	al, 17h ; Mode control register		
 15824 00003E88 EE                  <1>   	out	dx, al
 15825                              <1>  	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 15826 00003E89 FEC2                <1>   	inc	dl
 15827 00003E8B EC                  <1> 	in	al, dx	; Read mode control register
 15828 00003E8C 0C03                <1>   	or	al, 03h ; Set SRS and CMS bits
 15829 00003E8E EE                  <1>   	out	dx, al 
 15830                              <1>   	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 15831                              <1>   	; 03/08/2022
 15832 00003E8F B2DA                <1> 	mov	dl, 0DAh
 15833 00003E91 EC                  <1> 	in	al, dx	 ; clear flip-flop
 15834                              <1>   	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 15835                              <1>   	; 03/08/2022
 15836 00003E92 B2C0                <1> 	mov	dl, 0C0h
 15837 00003E94 B010                <1> 	mov	al, 10h	; Mode control register
 15838 00003E96 EE                  <1>   	out	dx, al
 15839                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 15840 00003E97 FEC2                <1> 	inc	dl
 15841 00003E99 EC                  <1> 	in	al, dx
 15842 00003E9A 0C01                <1> 	or	al, 01h ; select graphics mode
 15843                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 15844 00003E9C FECA                <1> 	dec	dl
 15845 00003E9E EE                  <1> 	out	dx, al ; Write to mode control register
 15846 00003E9F B020                <1> 	mov	al, 20h ; Palette RAM <-> display memory
 15847 00003EA1 EE                  <1> 	out	dx, al ; Write to attribute addr register
 15848                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 15849                              <1> 	; 03/08/2022
 15850 00003EA2 B2CE                <1> 	mov	dl, 0CEh 
 15851 00003EA4 66B80605            <1> 	mov	ax, 0506h ; Misc. register, graph, mm 1
 15852 00003EA8 66EF                <1> 	out	dx, ax
 15853                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 15854                              <1> 	; 03/08/2022
 15855 00003EAA B2C4                <1> 	mov	dl, 0C4h 
 15856 00003EAC 66B8020F            <1> 	mov	ax, 0F02h ; Map mask register, all planes
 15857 00003EB0 66EF                <1> 	out	dx, ax
 15858                              <1> 
 15859                              <1>   	; settings for >= 8bpp
 15860                              <1> 
 15861                              <1> 	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 15862                              <1> 	;mov	ax, 03h ; VBE_DISPI_INDEX_BPP
 15863                              <1> 	;out	dx, ax
 15864                              <1> 	;;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 15865                              <1> 	;inc	dl
 15866                              <1> 	;in	ax, dx
 15867                              <1> 	;cmp	al, 08h  ; < 8 bits per pixel
 15868                              <1> 	;jb	short vga_compat_end
 15869                              <1> 
 15870                              <1> 	;mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 15871                              <1> 	; 03/08/2022
 15872 00003EB2 B2D4                <1> 	mov	dl, 0D4h
 15873 00003EB4 B014                <1> 	mov	al, 14h  ; Underline location register
 15874 00003EB6 EE                  <1> 	out	dx, al
 15875                              <1> 	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 15876 00003EB7 FEC2                <1> 	inc	dl
 15877 00003EB9 EC                  <1> 	in	al, dx	
 15878 00003EBA 0C40                <1> 	or	al, 40h	 ; enable double word mode
 15879 00003EBC EE                  <1> 	out	dx, al
 15880                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 15881                              <1> 	; 03/08/2022
 15882 00003EBD B2DA                <1> 	mov	dl, 0DAh
 15883 00003EBF EC                  <1> 	in	al, dx	 ; clear flip-flop
 15884                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 15885                              <1> 	; 03/08/2022
 15886 00003EC0 B2C0                <1> 	mov	dl, 0C0h
 15887 00003EC2 B010                <1> 	mov	al, 10h	 ; Mode control register
 15888 00003EC4 EE                  <1> 	out	dx, al
 15889                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 15890 00003EC5 FEC2                <1> 	inc	dl
 15891 00003EC7 EC                  <1> 	in	al, dx
 15892 00003EC8 0C40                <1> 	or	al, 40h  ; Pixel clock select is 1
 15893                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 15894 00003ECA FECA                <1> 	dec	dl
 15895 00003ECC EE                  <1> 	out	dx, al	 ; update mode control reggister
 15896 00003ECD B020                <1> 	mov	al, 20h	 ; select display memory as PAS	
 15897 00003ECF EE                  <1> 	out	dx, al
 15898                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 15899                              <1> 	; 03/08/2022
 15900 00003ED0 B2C4                <1> 	mov	dl, 0C4h
 15901 00003ED2 B004                <1> 	mov	al, 04h	; Memory mode register
 15902 00003ED4 EE                  <1> 	out	dx, al
 15903                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
 15904 00003ED5 FEC2                <1> 	inc	dl
 15905 00003ED7 EC                  <1> 	in	al, dx
 15906 00003ED8 0C08                <1> 	or	al, 08h	; enable chain four
 15907 00003EDA EE                  <1> 	out	dx, al
 15908                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 15909                              <1> 	; 03/08/2022
 15910 00003EDB B2CE                <1> 	mov	dl, 0CEh
 15911 00003EDD B005                <1> 	mov	al, 05h	 ; Mode register	
 15912 00003EDF EE                  <1> 	out	dx, al
 15913                              <1> 	;mov	dx, 3CFh ; VGAREG_GRDC_DATA
 15914 00003EE0 FEC2                <1> 	inc	dl
 15915 00003EE2 EC                  <1> 	in	al, dx	
 15916 00003EE3 249F                <1> 	and	al, 9Fh	 ; clear shift register 
 15917 00003EE5 0C40                <1> 	or	al, 40h  ; set shift register to 2
 15918 00003EE7 EE                  <1> 	out	dx, al
 15919                              <1> 
 15920                              <1> vga_compat_end:
 15921                              <1>   	;pop	edx
 15922                              <1>   	;pop	eax
 15923 00003EE8 C3                  <1> 	retn
 15924                              <1> 
 15925                              <1> vga_set_virt_width:
 15926                              <1> 	; 03/08/2022
 15927                              <1> 	; 27/11/2020
 15928                              <1> 	; 25/11/2020
 15929                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 15930                              <1> 	;
 15931                              <1> 	; Input:
 15932                              <1> 	;	AX = resolution (screen width)
 15933                              <1> 	;
 15934                              <1> 	; Modified registers: eax, edx
 15935                              <1> 
 15936                              <1>   	;;push	ebx
 15937                              <1>   	;push	edx
 15938                              <1> 	;push	eax
 15939                              <1>   	;mov	ebx, eax
 15940                              <1>   	;call	dispi_get_bpp ; bits per pixel
 15941                              <1> 	;cmp	al, 4
 15942                              <1> 	;ja	short set_width_svga  ; 8, 16, 24, 32 
 15943                              <1> 	;shr	bx, 1
 15944                              <1> ;set_width_svga:
 15945                              <1> 	;shr	bx, 3
 15946                              <1> 	;mov	eax, [esp]
 15947                              <1> 	;shr	ax, 3	; / 8, bytes per row
 15948                              <1> 	; 03/08/2022
 15949 00003EE9 C1E803              <1> 	shr	eax, 3
 15950 00003EEC 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 15951                              <1> 	;mov	ah, bl	; 
 15952 00003EF0 88C4                <1> 	mov	ah, al	; width in bytes
 15953 00003EF2 B013                <1> 	mov	al, 13h	; offset register
 15954 00003EF4 66EF                <1> 	out	dx, ax	; index (3D4h) and data (3D5h)
 15955                              <1> 	;pop	eax
 15956                              <1> 	;pop  	edx
 15957                              <1> 	;;pop	ebx
 15958 00003EF6 C3                  <1> 	retn
 15959                              <1> 
 15960                              <1> ; 24/11/2020
 15961                              <1> 
 15962                              <1> struc bmi ; BOCHS/PLEX86 MODE INFO structure/table 
 15963 00000000 <res 00000002>      <1>  .mode:	  resw 1
 15964 00000002 <res 00000002>      <1>  .width:  resw 1
 15965 00000004 <res 00000002>      <1>  .height: resw 1
 15966 00000006 <res 00000002>      <1>  .depth:  resw 1
 15967                              <1>  .size:	
 15968                              <1> endstruc
 15969                              <1> 
 15970                              <1> ; 24/11/2020
 15971                              <1> struc MODEINFO
 15972 00000000 <res 00000002>      <1>  .mode:			resw 1  ; 1XXh
 15973 00000002 <res 00000002>      <1>  .ModeAttributes:	resw 1
 15974 00000004 <res 00000001>      <1>  .WinAAttributes:	resb 1
 15975 00000005 <res 00000001>      <1>  .WinBAttributes:	resb 1	; = 0
 15976 00000006 <res 00000002>      <1>  .WinGranularity:	resw 1
 15977 00000008 <res 00000002>      <1>  .WinSize:		resw 1
 15978 0000000A <res 00000002>      <1>  .WinASegment:		resw 1
 15979 0000000C <res 00000002>      <1>  .WinBSegment:		resw 1	; = 0
 15980 0000000E <res 00000004>      <1>  .WinFuncPtr:		resd 1	; = 0
 15981 00000012 <res 00000002>      <1>  .BytesPerScanLine:	resw 1
 15982 00000014 <res 00000002>      <1>  .XResolution:		resw 1
 15983 00000016 <res 00000002>      <1>  .YResolution:		resw 1
 15984 00000018 <res 00000001>      <1>  .XCharSize:		resb 1
 15985 00000019 <res 00000001>      <1>  .YCharSize:		resb 1
 15986 0000001A <res 00000001>      <1>  .NumberOfPlanes: 	resb 1
 15987 0000001B <res 00000001>      <1>  .BitsPerPixel:		resb 1
 15988 0000001C <res 00000001>      <1>  .NumberOfBanks:	resb 1
 15989 0000001D <res 00000001>      <1>  .MemoryModel:		resb 1
 15990 0000001E <res 00000001>      <1>  .BankSize:		resb 1	; = 0
 15991 0000001F <res 00000001>      <1>  .NumberOfImagePages: 	resb 1
 15992 00000020 <res 00000001>      <1>  .Reserved_page:	resb 1	; = 0
 15993 00000021 <res 00000001>      <1>  .RedMaskSize:		resb 1
 15994 00000022 <res 00000001>      <1>  .RedFieldPosition: 	resb 1
 15995 00000023 <res 00000001>      <1>  .GreenMaskSize:	resb 1
 15996 00000024 <res 00000001>      <1>  .GreenFieldPosition: 	resb 1
 15997 00000025 <res 00000001>      <1>  .BlueMaskSize:		resb 1
 15998 00000026 <res 00000001>      <1>  .BlueFieldPosition: 	resb 1
 15999 00000027 <res 00000001>      <1>  .RsvdMaskSize:		resb 1
 16000 00000028 <res 00000001>      <1>  .RsvdFieldPosition: 	resb 1
 16001 00000029 <res 00000001>      <1>  .DirectColorModeInfo: 	resb 1
 16002 0000002A <res 00000004>      <1>  .PhysBasePtr:		resd 1
 16003 0000002E <res 00000004>      <1>  .OffScreenMemOffset: 	resd 1	; = 0
 16004 00000032 <res 00000002>      <1>  .OffScreenMemSize: 	resw 1	; = 0
 16005 00000034 <res 00000002>      <1>  .LinBytesPerScanLine: 	resw 1
 16006 00000036 <res 00000001>      <1>  .BnkNumberOfPages: 	resb 1
 16007 00000037 <res 00000001>      <1>  .LinNumberOfPages: 	resb 1
 16008 00000038 <res 00000001>      <1>  .LinRedMaskSize:	resb 1
 16009 00000039 <res 00000001>      <1>  .LinRedFieldPosition1: resb 1
 16010 0000003A <res 00000001>      <1>  .LinGreenMaskSize1: 	resb 1
 16011 0000003B <res 00000001>      <1>  .LinGreenFieldPosition:resb 1
 16012 0000003C <res 00000001>      <1>  .LinBlueMaskSize: 	resb 1
 16013 0000003D <res 00000001>      <1>  .LinBlueFieldPosition:	resb 1
 16014 0000003E <res 00000001>      <1>  .LinRsvdMaskSize: 	resb 1
 16015 0000003F <res 00000001>      <1>  .LinRsvdFieldPosition:	resb 1
 16016 00000040 <res 00000004>      <1>  .MaxPixelClock:	resd 1	; = 0
 16017                              <1> .size:
 16018                              <1> endstruc
 16019                              <1> 
 16020                              <1> ; 10/12/2020
 16021                              <1> struc LFBINFO
 16022 00000000 <res 00000002>      <1>  .mode:			resw 1  ; 1XXh
 16023 00000002 <res 00000004>      <1>  .LFB_addr:		resd 1
 16024 00000006 <res 00000004>      <1>  .LFB_size:		resd 1
 16025 0000000A <res 00000002>      <1>  .X_res:		resw 1
 16026 0000000C <res 00000002>      <1>  .Y_res:		resw 1
 16027 0000000E <res 00000001>      <1>  .bpp:			resb 1
 16028 0000000F <res 00000001>      <1>  .reserved:		resb 1
 16029                              <1> .size:	; 16 bytes
 16030                              <1> endstruc
 16031                              <1> 
 16032                              <1> set_mode_info_list:
 16033                              <1> 	; 14/12/2020
 16034                              <1> 	; 11/12/2020
 16035                              <1> 	; 24/11/2020
 16036                              <1> 	; (vbetables-gen.c)
 16037                              <1> 	; Input:
 16038                              <1> 	;	BX = VBE mode (including bochs special modes) 
 16039                              <1> 	; Output:
 16040                              <1> 	;	;;EAX = MODE_INFO_LIST address
 16041                              <1> 	;	EAX = 0 ; 11/12/2020
 16042                              <1> 	;	ESI = MODE_INFO_LIST address ; 11/12/2020
 16043                              <1> 	;	(if mode is not found, ESI = 0)
 16044                              <1> 	;
 16045                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi 
 16046                              <1> 
 16047 00003EF7 BE[2A6A0000]        <1> 	mov	esi, b_vbe_modes ; bochs mode info base table
 16048 00003EFC BF[EE0F0300]        <1> 	mov	edi, MODE_INFO_LIST ; mode info list (4F01h)
 16049                              <1> sml_0:
 16050 00003F01 66AD                <1> 	lodsw	
 16051 00003F03 6639D8              <1> 	cmp	ax, bx ; is mode number same ?
 16052 00003F06 7410                <1> 	je	short sml_1 ; yes
 16053 00003F08 AD                  <1> 	lodsd
 16054 00003F09 66AD                <1> 	lodsw	
 16055 00003F0B 81FE[EA6A0000]      <1> 	cmp	esi, end_of_b_vbe_modes
 16056 00003F11 72EE                <1> 	jb	short sml_0
 16057                              <1> 	; not found
 16058 00003F13 31C0                <1> 	xor	eax, eax ; 0
 16059                              <1> 	; 11/12/2020
 16060 00003F15 31F6                <1> 	xor	esi, esi
 16061 00003F17 C3                  <1> 	retn
 16062                              <1> sml_1:
 16063 00003F18 66AB                <1> 	stosw	; mode
 16064 00003F1A AD                  <1> 	lodsd	; width, height
 16065                              <1> 	; 14/12/2020
 16066 00003F1B 89C1                <1> 	mov	ecx, eax
 16067 00003F1D 50                  <1> 	push	eax ; ***
 16068 00003F1E 29C0                <1> 	sub	eax, eax ; clear high word of eax
 16069 00003F20 66AD                <1> 	lodsw	; depth
 16070 00003F22 50                  <1> 	push	eax ; **
 16071                              <1> 
 16072                              <1> 	;add	al, 7 ; only for 15 bit colors (not used here)
 16073 00003F23 C0E803              <1> 	shr	al, 3 ; / 8
 16074                              <1> 	; 14/12/2020
 16075 00003F26 66F7E1              <1> 	mul	cx  ; pitch = width * ((depth+7)/8)
 16076                              <1> 		; ax = pitch
 16077 00003F29 50                  <1> 	push	eax ; * ; high word of eax = 0
 16078 00003F2A C1E910              <1> 	shr	ecx, 16
 16079                              <1> 	;mul	cx
 16080                              <1> 	;mov	cx, ax
 16081 00003F2D 31D2                <1> 	xor	edx, edx  ; clear high word of edx
 16082 00003F2F F7E1                <1> 	mul	ecx ; height * pitch
 16083 00003F31 89C1                <1> 	mov	ecx, eax
 16084 00003F33 B800000001          <1> 	mov	eax, VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024
 16085 00003F38 F7F1                <1> 	div	ecx
 16086                              <1> 		; eax = pages = vram_size / (height*pitch)
 16087                              <1> 	
 16088                              <1> 	;mov	cx, ax
 16089 00003F3A 89C1                <1> 	mov	ecx, eax ; pages 
 16090                              <1> 		
 16091 00003F3C 66B89B00            <1> 	mov	ax, MODE_ATTRIBUTES
 16092 00003F40 66AB                <1> 	stosw	; ModeAttributes
 16093 00003F42 B007                <1> 	mov	al, WINA_ATTRIBUTES
 16094 00003F44 AA                  <1> 	stosb	; WinAAttributes
 16095 00003F45 30C0                <1> 	xor	al, al ; WinBAttributes = 0
 16096 00003F47 AA                  <1> 	stosb
 16097 00003F48 66B84000            <1> 	mov	ax, VBE_DISPI_BANK_SIZE_KB
 16098 00003F4C 66AB                <1> 	stosw	; WinGranularity
 16099 00003F4E 66AB                <1> 	stosw	; WinSize
 16100 00003F50 66B800A0            <1> 	mov	ax, VGAMEM_GRAPH
 16101 00003F54 66AB                <1> 	stosw	; WinASegment
 16102 00003F56 29C0                <1> 	sub	eax, eax
 16103 00003F58 66AB                <1> 	stosw	; WinBSegment = 0
 16104 00003F5A AB                  <1> 	stosd	; WinFuncPtr = 0
 16105                              <1> 
 16106 00003F5B 58                  <1> 	pop	eax ; * ; pitch
 16107 00003F5C 89C3                <1> 	mov	ebx, eax  ; high word of ebx = 0 ; 14/12/2020
 16108 00003F5E 66AB                <1> 	stosw	; BytesPerScanLine
 16109                              <1> 
 16110 00003F60 5A                  <1> 	pop	edx ; ** ; depth (bits per pixel)
 16111 00003F61 58                  <1> 	pop	eax ; *** width, height
 16112                              <1> 
 16113                              <1>  	; // Mandatory information for VBE 1.2 and above
 16114                              <1> 
 16115 00003F62 66AB                <1> 	stosw	; XResolution (width)
 16116 00003F64 C1E810              <1> 	shr	eax, 16
 16117 00003F67 50                  <1> 	push	eax ; **** height
 16118 00003F68 66AB                <1> 	stosw	; YResolution (height)
 16119 00003F6A B008                <1> 	mov	al, 8
 16120 00003F6C AA                  <1>  	stosb	; XCharSize  ; char width
 16121 00003F6D B010                <1> 	mov	al, 16
 16122 00003F6F AA                  <1> 	stosb	; YCharSize  ; char height
 16123 00003F70 B001                <1> 	mov	al, 1
 16124 00003F72 AA                  <1> 	stosb	; NumberOfPlanes
 16125                              <1> 	;movzx	eax, dl
 16126 00003F73 88D0                <1> 	mov	al, dl ; eax <= 32
 16127 00003F75 AA                  <1> 	stosb	; BitsPerPixel
 16128                              <1> 	; Number of banks = (height * pitch + 65535) / 65536
 16129 00003F76 58                  <1> 	pop	eax ; **** ; height
 16130                              <1> 	; 14/12/2020
 16131 00003F77 52                  <1> 	push	edx ; ***** ; depth ; edx <= 32
 16132 00003F78 F7E3                <1> 	mul	ebx  ; pitch (ebx) * height (eax)
 16133                              <1> 	;mov	edx, [esp] ; *****
 16134                              <1> 	;mov	dl, [esp] ; *****
 16135 00003F7A 05FFFF0000          <1> 	add	eax, 65535
 16136 00003F7F C1E810              <1> 	shr	eax, 16 ; / 65536 ; <= 127 ; 14/12/2020
 16137 00003F82 AA                  <1> 	stosb	; NumberOfBanks
 16138                              <1> 	; 14/12/2020
 16139                              <1> 	;cmp	dl, 8 ; 8 bits per pixel
 16140 00003F83 803C2408            <1> 	cmp	byte [esp], 8
 16141 00003F87 7704                <1> 	ja	short sml_2
 16142 00003F89 B004                <1> 	mov	al, VBE_MEMORYMODEL_PACKED_PIXEL
 16143 00003F8B EB02                <1> 	jmp	short sml_3
 16144                              <1> sml_2:
 16145                              <1> 	; 16, 24, 32 bits per pixel
 16146 00003F8D B006                <1> 	mov	al, VBE_MEMORYMODEL_DIRECT_COLOR
 16147                              <1> sml_3:
 16148 00003F8F AA                  <1> 	stosb
 16149 00003F90 30C0                <1> 	xor	al, al ; 0
 16150 00003F92 AA                  <1> 	stosb	; BankSize = 0
 16151 00003F93 49                  <1> 	dec	ecx ; pages - 1
 16152                              <1> 	; NumberOfImagePages = 262 for 320x200x8 mode
 16153                              <1> 	;;mov	ax, 255
 16154                              <1> 	; 14/12/2020
 16155                              <1> 	;mov	al, 255
 16156 00003F94 FEC8                <1> 	dec	al ; 255
 16157 00003F96 39C1                <1> 	cmp	ecx, eax ; ecx <= 261, eax = 255 
 16158                              <1> 	;cmp	cx, ax
 16159 00003F98 7302                <1> 	jnb	short sml_4
 16160 00003F9A 88C8                <1> 	mov	al, cl	 
 16161                              <1> sml_4:
 16162 00003F9C AA                  <1> 	stosb	; NumberOfImagePages (1 byte)
 16163 00003F9D 28C0                <1> 	sub	al, al
 16164 00003F9F AA                  <1> 	stosb	; Reserved_page = 0
 16165 00003FA0 58                  <1> 	pop	eax ; ***** ; depth
 16166 00003FA1 88C1                <1> 	mov	cl, al
 16167                              <1> 	; eax < = 32
 16168 00003FA3 2C08                <1> 	sub	al, 8 ; 8->0, 16->8, 24->16, 32->24
 16169 00003FA5 BE[EA6A0000]        <1> 	mov	esi, direct_color_fields
 16170 00003FAA 01C6                <1> 	add	esi, eax
 16171 00003FAC 56                  <1> 	push	esi ; ******
 16172 00003FAD AD                  <1> 	lodsd	; RedMaskSize (AL), RedFieldPosition (AH)
 16173                              <1> 	     	; GreenMaskSize (16), GreenFieldPosition (24)
 16174 00003FAE AB                  <1> 	stosd
 16175 00003FAF AD                  <1> 	lodsd	; BlueMaskSize (AL), BlueFieldPosition (AH)
 16176                              <1> 	     	; RsvdMaskSize (16), RsvdFieldPosition (24)
 16177 00003FB0 AB                  <1> 	stosd
 16178 00003FB1 5E                  <1> 	pop	esi ; ******
 16179                              <1> 
 16180 00003FB2 30C0                <1> 	xor	al, al ; 0
 16181 00003FB4 80F920              <1> 	cmp	cl, 32
 16182 00003FB7 7202                <1> 	jb	short sml_5
 16183 00003FB9 B002                <1> 	mov	al, VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 16184                              <1> sml_5: 
 16185 00003FBB AA                  <1> 	stosb	; DirectColorModeInfo
 16186                              <1> 
 16187                              <1> 	; // Mandatory information for VBE 2.0 and above
 16188                              <1> 
 16189 00003FBC B8000000E0          <1> 	mov	eax, VBE_DISPI_LFB_PHYSICAL_ADDRESS
 16190 00003FC1 AB                  <1> 	stosd	; PhysBasePtr
 16191 00003FC2 29C0                <1> 	sub	eax, eax
 16192 00003FC4 AB                  <1> 	stosd	; OffScreenMemOffset = 0
 16193 00003FC5 66AB                <1> 	stosw	; OffScreenMemSize = 0
 16194                              <1> 
 16195                              <1> 	;// Mandatory information for VBE 3.0 and above
 16196                              <1> 
 16197                              <1> 	; ebx = pitch
 16198 00003FC7 6689D8              <1> 	mov	ax, bx
 16199                              <1> 	;stosw
 16200                              <1> 
 16201                              <1> 	;xor	al, al
 16202                              <1>      	;stosb	; BnkNumberOfPages = 0
 16203                              <1>      	;stosb	; LinNumberOfPages = 0
 16204                              <1> 
 16205 00003FCA AB                  <1> 	stosd	; pitch (word), 0 (byte), 0 (byte)  
 16206                              <1> 
 16207 00003FCB AD                  <1> 	lodsd	; LinRedMaskSize (AL), LinRedFieldPosition (AH)
 16208                              <1> 	     	; LinGreenMaskSize (16), LinGreenFieldPosition (24)
 16209 00003FCC AB                  <1> 	stosd
 16210 00003FCD AD                  <1> 	lodsd	; LinBlueMaskSize (AL), LinBlueFieldPosition (AH)
 16211                              <1> 	     	; LinRsvdMaskSize (16), LinRsvdFieldPosition (24)
 16212 00003FCE AB                  <1> 	stosd
 16213                              <1> 
 16214 00003FCF 29C0                <1> 	sub	eax, eax
 16215 00003FD1 AB                  <1> 	stosd	; MaxPixelClock = 0
 16216                              <1> 
 16217                              <1> 	;mov	eax, MODE_INFO_LIST
 16218                              <1> 	; 11/12/2020
 16219 00003FD2 BE[EE0F0300]        <1> 	mov	esi, MODE_INFO_LIST
 16220                              <1> 	
 16221 00003FD7 C3                  <1> 	retn	
 16222                              <1> 
 16223                              <1> ; end of set_mode_info_list ; edi = set_mode_info_list + 68
 16224                              <1> 
 16225                              <1> pci_get_lfb_addr:
 16226                              <1> 	; 11/12/2020
 16227                              <1> 	; Get linear frame buffer base from PCI
 16228                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 16229                              <1> 	;
 16230                              <1> 	; Input:
 16231                              <1> 	;	ax = PCI device vendor id
 16232                              <1> 	; Output:
 16233                              <1> 	;	ax  = LFB address (high 16 bit) (zf=0)
 16234                              <1> 	;	eax = 0 -> not found (error) (zf=1)
 16235                              <1> 	;
 16236                              <1> 	; Modified registers: eax
 16237                              <1> 
 16238 00003FD8 53                  <1> 	push	ebx
 16239 00003FD9 51                  <1> 	push	ecx
 16240 00003FDA 52                  <1> 	push	edx
 16241                              <1> 	;
 16242 00003FDB 89C3                <1> 	mov	ebx, eax
 16243 00003FDD 31C9                <1> 	xor	ecx, ecx
 16244 00003FDF 28D2                <1> 	sub	dl, dl	; mov dl, 0
 16245 00003FE1 E842000000          <1> 	call	pci_read_reg
 16246 00003FE6 6683F8FF            <1> 	cmp	ax, 0FFFFh
 16247 00003FEA 7417                <1> 	je	short pci_get_lfb_addr_fail
 16248                              <1> pci_get_lfb_addr_next_dev:
 16249 00003FEC 28D2                <1> 	sub	dl, dl ; mov dl, 0
 16250 00003FEE E835000000          <1> 	call	pci_read_reg
 16251 00003FF3 6639D8              <1> 	cmp	ax, bx	; check vendor
 16252 00003FF6 740F                <1> 	je	short pci_get_lfb_addr_found
 16253 00003FF8 6683C108            <1> 	add	cx, 08h
 16254 00003FFC 6681F90002          <1> 	cmp	cx, 200h ; search bus 0 and 1
 16255 00004001 72E9                <1> 	jb	short pci_get_lfb_addr_next_dev
 16256                              <1> pci_get_lfb_addr_fail:
 16257 00004003 31C0                <1> 	xor	eax, eax ; no LFB
 16258                              <1> 	; zf = 1
 16259 00004005 EB1D                <1> 	jmp	short pci_get_lfb_addr_return
 16260                              <1> pci_get_lfb_addr_found:
 16261 00004007 B210                <1> 	mov	dl, 10h	; I/O space 0
 16262 00004009 E81A000000          <1> 	call	pci_read_reg
 16263 0000400E 66A9F1FF            <1> 	test	ax, 0FFF1h
 16264 00004012 740D                <1> 	jz	short pci_get_lfb_addr_success
 16265 00004014 B214                <1> 	mov	dl, 14h ; I/O space 1
 16266 00004016 E80D000000          <1> 	call	pci_read_reg
 16267 0000401B 66A9F1FF            <1> 	test	ax, 0FFF1h
 16268 0000401F 75E2                <1> 	jnz	short pci_get_lfb_addr_fail
 16269                              <1> pci_get_lfb_addr_success:
 16270 00004021 C1E810              <1> 	shr	eax, 16 ; LFB address (hw)
 16271                              <1> 	; zf = 0
 16272                              <1> pci_get_lfb_addr_return:
 16273 00004024 5A                  <1> 	pop	edx
 16274 00004025 59                  <1> 	pop	ecx
 16275 00004026 5B                  <1> 	pop	ebx
 16276 00004027 C3                  <1> 	retn
 16277                              <1> 
 16278                              <1> pci_read_reg:
 16279                              <1> 	; 11/12/2020
 16280                              <1> 	; Read PCI register
 16281                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 16282                              <1> 	;
 16283                              <1> 	; Input:
 16284                              <1> 	;	cx = device/function
 16285                              <1> 	;	dl = register
 16286                              <1> 	; Output:
 16287                              <1> 	;	eax = value
 16288                              <1> 	;
 16289                              <1> 	; Modified registers: eax, edx
 16290                              <1> 
 16291 00004028 B800008000          <1> 	mov	eax, 00800000h 
 16292 0000402D 6689C8              <1> 	mov	ax, cx
 16293 00004030 C1E008              <1> 	shl	eax, 8
 16294 00004033 88D0                <1> 	mov	al, dl
 16295 00004035 66BAF80C            <1> 	mov	dx, 0CF8h
 16296 00004039 EF                  <1>  	out	dx, eax
 16297 0000403A 80C204              <1> 	add	dl, 4 ; mov dx, 0CFCh
 16298 0000403D ED                  <1> 	in	eax, dx
 16299 0000403E C3                  <1> 	retn
 16300                              <1> 
 16301                              <1> %endif
 16302                              <1> 
 16303                              <1> ; -----------
 16304                              <1> 
 16305                              <1> %if 0
 16306                              <1> 
 16307                              <1> mode_info_find_mode:
 16308                              <1> 	; 25/11/2020
 16309                              <1> 	; Input:
 16310                              <1> 	;	bx = VESA VBE2 video mode (+ bochs extensions)
 16311                              <1> 	; Output:
 16312                              <1> 	;	esi = mode info address (for BX input)
 16313                              <1> 	;	esi = 0 -> not found
 16314                              <1> 	;
 16315                              <1> 	; Modified registers: eax, esi
 16316                              <1> 
 16317                              <1> 	xor	eax, eax
 16318                              <1> 	mov	esi, MODE_INFO_LIST
 16319                              <1> mifm_1:
 16320                              <1> 	mov	ax, [esi]
 16321                              <1> 	cmp	ax, bx
 16322                              <1> 	je	short mifm_2
 16323                              <1> 	add	esi, MODEINFO.size ; add esi, 68
 16324                              <1> 	cmp	esi, VBE_VESA_MODE_END_OF_LIST
 16325                              <1> 	jb	short mifm_1
 16326                              <1> 	; not found
 16327                              <1> 	sub	esi, esi ; 0
 16328                              <1> mifm_2
 16329                              <1> 	retn
 16330                              <1> 
 16331                              <1> dispi_get_bpp:
 16332                              <1> 	; 28/11/2020
 16333                              <1> 	; Input:
 16334                              <1> 	;	none
 16335                              <1> 	; Output:
 16336                              <1> 	;	al = Bits per pixel
 16337                              <1> 	;	     (8,16,24,32)
 16338                              <1> 	;	ah = Bytes per pixel
 16339                              <1> 	;	     (1,2,3,4)	
 16340                              <1> 	;
 16341                              <1> 	; Modified registers: none
 16342                              <1> 
 16343                              <1> 	;push	edx
 16344                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 16345                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 16346                              <1> 	;out	dx, ax
 16347                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 16348                              <1> 	;;mov	dl, 0CFh
 16349                              <1> 	;inc	dl
 16350                              <1> 	;in	ax, dx
 16351                              <1> 	;mov	ah, al
 16352                              <1> 	;shr	ah, 3 ; / 8
 16353                              <1> 	;;test	al, 7 ; 15 bit graphics mode
 16354                              <1>  	;;jz	short get_bpp_noinc
 16355                              <1> 	;;inc	ah
 16356                              <1> ;;get_bpp_noinc:
 16357                              <1> 	;pop	edx
 16358                              <1> 	;retn
 16359                              <1> 
 16360                              <1> 	; 28/11/2020
 16361                              <1> 	; Modified registers: edx
 16362                              <1> 	;push	edx
 16363                              <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 16364                              <1> 	call	dispi_get_parms
 16365                              <1> 	;pop	edx
 16366                              <1> 	;retn
 16367                              <1> 	mov	ah, al
 16368                              <1> 	shr	ah, 3 ; / 8
 16369                              <1> 	;test	al, 7 ; 15 bit graphips mode
 16370                              <1>  	;jz	short get_bpp_noinc
 16371                              <1> 	;inc	ah
 16372                              <1> ;get_bpp_noinc:
 16373                              <1> 	;pop	edx
 16374                              <1> 	retn
 16375                              <1> 
 16376                              <1> restore_vesa_video_state:
 16377                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
 16378                              <1> 	; 14/01/2021
 16379                              <1> 	; 06/12/2020
 16380                              <1> 	; Input:
 16381                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 16382                              <1> 	; Output:
 16383                              <1> 	;	AX = 004Fh (successed)
 16384                              <1> 	;
 16385                              <1> 	;	eax = 0 -> buffer size problem
 16386                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 16387                              <1> 	;
 16388                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 16389                              <1> 
 16390                              <1> 	;movzx	ecx, word [vbe3stbufsize]  
 16391                              <1> 	;cmp	cx, 32 ; 32 * 64 bytes
 16392                              <1> 	;ja	short r_v_b_s_fail
 16393                              <1> 
 16394                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 16395                              <1> 	;shl	cx, 4 ; dword count for movsd
 16396                              <1> 	; 02/08/2022
 16397                              <1> 	shl	ecx, 4 ; <= 32*16 dwords (32*64 bytes)
 16398                              <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
 16399                              <1> 					; (vbe3 pmi buff)
 16400                              <1> 	mov	esi, VBE3VIDEOSTATE ; source (kernel buff)
 16401                              <1> 	rep	movsd
 16402                              <1> 
 16403                              <1> 	mov	ax, 4F04h
 16404                              <1> 	mov	dl, 02h ; restore
 16405                              <1> 	;mov	cx, 0Fh
 16406                              <1> 	mov	cl, 0Fh
 16407                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 16408                              <1> 	jmp	short int10h_32bit_pmi
 16409                              <1> 
 16410                              <1> ;s_v_b_s_fail:
 16411                              <1> ;r_v_b_s_fail:
 16412                              <1> ;	xor	eax, eax
 16413                              <1> ;	retn
 16414                              <1> 
 16415                              <1> save_vesa_video_state:
 16416                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
 16417                              <1> 	; 14/01/2021
 16418                              <1> 	; 06/12/2020
 16419                              <1> 	; Input:
 16420                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 16421                              <1> 	; Output:
 16422                              <1> 	;	AX = 004Fh (successed)
 16423                              <1> 	;
 16424                              <1> 	;	eax = 0 -> buffer size problem
 16425                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 16426                              <1> 	;
 16427                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 16428                              <1> 
 16429                              <1> 	;cmp	word [vbe33stbufsize], 32  
 16430                              <1> 	;			; 32 * 64 bytes
 16431                              <1> 	;ja	short s_v_b_s_fail
 16432                              <1> 
 16433                              <1> 	mov	ax, 4F04h
 16434                              <1> 	mov	dl, 01h ; save
 16435                              <1> 	;mov	cx, 0Fh
 16436                              <1> 	mov	cl, 0Fh
 16437                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 16438                              <1> 
 16439                              <1> 	call	int10h_32bit_pmi
 16440                              <1> 
 16441                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 16442                              <1> 	;shl	cx, 4 ; dword count for movsd
 16443                              <1> 	; 02/08/2022
 16444                              <1> 	shl	ecx, 4 ; <= 32*16 dwords (32*64 bytes)
 16445                              <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; destination
 16446                              <1> 					; (vbe3 pmi buff)
 16447                              <1> 	mov	edi, VBE3VIDEOSTATE ; source (kernel buff)
 16448                              <1> 	rep	movsd	
 16449                              <1> 	retn
 16450                              <1> 
 16451                              <1> dispi_set_bank_farcall:
 16452                              <1> 	; 03/08/2022
 16453                              <1> 	; 12/04/2021 (32 bit push/pop)
 16454                              <1> 	; 11/12/2020
 16455                              <1> 	; (This may be 'sysvideo' function, later)
 16456                              <1> 	;
 16457                              <1> 	; Input: 
 16458                              <1> 	;	bx = 0000h, set bank number
 16459                              <1> 	;	   = 0100h, get bank number
 16460                              <1> 	;	dx = bank number (if bx = 0)	
 16461                              <1> 	; Output:
 16462                              <1> 	;	dx = bank number
 16463                              <1> 		 	
 16464                              <1> 	cmp	bx, 0100h
 16465                              <1> 	je	short dispi_set_bank_farcall_get
 16466                              <1> 	or	bx, bx
 16467                              <1> 	;jnz	dispi_set_bank_farcall_error
 16468                              <1> 	; 03/08/2022
 16469                              <1> 	jz	short dsbfcall_1
 16470                              <1> 	jmp	dispi_set_bank_farcall_error
 16471                              <1> dsbfcall_1:
 16472                              <1> 	mov	ax, dx
 16473                              <1> 	;push	dx
 16474                              <1> 	;push	ax
 16475                              <1> 	; 12/04/2021
 16476                              <1> 	push	edx
 16477                              <1> 	push	eax
 16478                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 16479                              <1> 	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 16480                              <1> 	out	dx, ax
 16481                              <1> 	;pop	ax
 16482                              <1> 	; 12/04/2021
 16483                              <1> 	pop	eax
 16484                              <1> 	;;mov	dx, VBE_DISPI_IOPORT_DATA
 16485                              <1> 	;mov	dl, 0CFh
 16486                              <1> 	inc	dl ; 1CFh = VBE_DISPI_IOPORT_DATA
 16487                              <1> 	out	dx, ax
 16488                              <1> 	in	ax, dx
 16489                              <1> 	;pop	dx
 16490                              <1> 	; 12/04/2021
 16491                              <1> 	pop	edx
 16492                              <1> 	cmp	dx, ax
 16493                              <1> 	jne	short dispi_set_bank_farcall_error
 16494                              <1> 	mov	ax, 004Fh
 16495                              <1> 	retn	; retf for real mode far call
 16496                              <1> dispi_set_bank_farcall_get:
 16497                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 16498                              <1> 	; 03/08/2022
 16499                              <1> 	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 16500                              <1> 	out	dx, ax
 16501                              <1> 	;;mov	dx, VBE_DISPI_IOPORT_DATA
 16502                              <1> 	;mov	dl, 0CFh
 16503                              <1> 	; 03/08/2022
 16504                              <1> 	inc	dl ; 1CFh = VBE_DISPI_IOPORT_DATA
 16505                              <1> 	in	ax, dx
 16506                              <1> 	mov	dx, ax
 16507                              <1> 	retn	; retf for real mode far call
 16508                              <1> dispi_set_bank_farcall_error:
 16509                              <1> 	mov	ax, 014Fh
 16510                              <1> 	retn	; retf for real mode far call
 16511                              <1> 
 16512                              <1> %endif
 16513                              <1> 
 16514                              <1> ; % include 'vidata.s' ; VIDEO DATA
 16515                              <1> 
 16516                              <1> ; /// End Of VIDEO FUNCTIONS ///
 16517                                  
 16518                                  setup_rtc_int:
 16519                                  ; source: http://wiki.osdev.org/RTC
 16520 0000403F FA                      	cli		; disable interrupts
 16521                                  	; default int frequency is 1024 Hz (Lower 4 bits of register A is 0110b or 6)
 16522                                  	; in order to change this ...
 16523                                  	; frequency  = 32768 >> (rate-1) --> 32768 >> 5 = 1024
 16524                                  	; (rate must be above 2 and not over 15)
 16525                                  	; new rate = 15 --> 32768 >> (15-1) = 2 Hz
 16526 00004040 B08A                    	mov	al, 8Ah 
 16527 00004042 E670                    	out	70h, al ; set index to register A, disable NMI
 16528 00004044 90                      	nop
 16529 00004045 E471                    	in	al, 71h ; get initial value of register A
 16530 00004047 88C4                    	mov 	ah, al
 16531 00004049 80E4F0                  	and	ah, 0F0h
 16532 0000404C B08A                    	mov	al, 8Ah 
 16533 0000404E E670                    	out	70h, al ; reset index to register A
 16534 00004050 88E0                    	mov	al, ah
 16535 00004052 0C0F                    	or	al, 0Fh	; new rate (0Fh -> 15)
 16536 00004054 E671                    	out	71h, al ; write only our rate to A. Note, rate is the bottom 4 bits. 
 16537                                  	; enable RTC interrupt
 16538 00004056 B08B                    	mov	al, 8Bh ;
 16539 00004058 E670                    	out	70h, al ; select register B and disable NMI
 16540 0000405A 90                      	nop
 16541 0000405B E471                    	in	al, 71h ; read the current value of register B
 16542 0000405D 88C4                    	mov	ah, al  ;
 16543 0000405F B08B                    	mov 	al, 8Bh ;
 16544 00004061 E670                    	out	70h, al ; set the index again (a read will reset the index to register B)	
 16545 00004063 88E0                    	mov	al, ah  ;
 16546 00004065 0C40                    	or	al, 40h ;
 16547 00004067 E671                    	out	71h, al ; write the previous value ORed with 0x40. This turns on bit 6 of register B
 16548 00004069 FB                      	sti
 16549 0000406A C3                      	retn
 16550                                  
 16551                                  ; Write memory information
 16552                                  ; 29/01/2016
 16553                                  ; 06/11/2014
 16554                                  ; 14/08/2015 
 16555                                  memory_info:	
 16556 0000406B A1[84770100]            	mov	eax, [memory_size] ; in pages
 16557 00004070 50                      	push	eax
 16558 00004071 C1E00C                  	shl	eax, 12		   ; in bytes
 16559 00004074 BB0A000000              	mov	ebx, 10
 16560 00004079 89D9                    	mov	ecx, ebx	   ; 10
 16561 0000407B BE[4D3A0100]            	mov	esi, mem_total_b_str	
 16562 00004080 E8D3000000              	call	bintdstr
 16563 00004085 58                      	pop	eax
 16564 00004086 B107                    	mov	cl, 7
 16565 00004088 BE[713A0100]            	mov	esi, mem_total_p_str
 16566 0000408D E8C6000000              	call	bintdstr	
 16567                                  	; 14/08/2015
 16568 00004092 E8DE000000              	call	calc_free_mem
 16569                                  	; edx = calculated free pages
 16570                                  	; ecx = 0
 16571 00004097 A1[88770100]            	mov 	eax, [free_pages]
 16572 0000409C 39D0                    	cmp	eax, edx ; calculated free mem value 
 16573                                  		; and initial free mem value are same or not?
 16574 0000409E 751D                    	jne 	short pmim ; print mem info with '?' if not
 16575 000040A0 52                      	push 	edx ; free memory in pages	
 16576                                  	;mov 	eax, edx
 16577 000040A1 C1E00C                  	shl	eax, 12 ; convert page count
 16578                                  			; to byte count
 16579 000040A4 B10A                    	mov	cl, 10
 16580 000040A6 BE[913A0100]            	mov	esi, free_mem_b_str
 16581 000040AB E8A8000000              	call	bintdstr
 16582 000040B0 58                      	pop	eax
 16583 000040B1 B107                    	mov	cl, 7
 16584 000040B3 BE[B53A0100]            	mov	esi, free_mem_p_str
 16585 000040B8 E89B000000              	call	bintdstr
 16586                                  pmim:
 16587 000040BD BE[3B3A0100]            	mov	esi, msg_memory_info
 16588                                  	;
 16589 000040C2 B407                    	mov	ah, 07h ; Black background, 
 16590                                  			; light gray forecolor
 16591                                  print_kmsg: ; 29/01/2016
 16592 000040C4 8825[AF770100]          	mov	[ccolor], ah
 16593                                  pkmsg_loop:
 16594 000040CA AC                      	lodsb
 16595 000040CB 08C0                    	or	al, al
 16596 000040CD 7410                    	jz	short pkmsg_ok
 16597 000040CF 56                      	push	esi
 16598                                  	; 13/05/2016
 16599 000040D0 0FB61D[AF770100]        	movzx	ebx, byte [ccolor]
 16600                                  			; Video page 0 (bh=0)
 16601 000040D7 E842E1FFFF              	call	_write_tty
 16602 000040DC 5E                      	pop	esi
 16603 000040DD EBEB                    	jmp	short pkmsg_loop
 16604                                  pkmsg_ok:
 16605 000040DF C3                      	retn
 16606                                  
 16607                                  ; 19/12/2020
 16608                                  ; temporary
 16609                                  ; Write default liner frame buffer address
 16610                                  ;
 16611                                  default_lfb_info:	
 16612 000040E0 66A1[CC0E0000]          	mov	ax, [def_LFB_addr] ; high word
 16613 000040E6 E829000000              	call	wordtohex
 16614 000040EB A3[293B0100]            	mov	dword [lfb_addr_str], eax
 16615 000040F0 BE[123B0100]            	mov	esi, msg_lfb_addr
 16616 000040F5 B40F                    	mov	ah, 0Fh ; Black background, 
 16617                                  			; white forecolor
 16618 000040F7 EBCB                    	jmp	short print_kmsg
 16619                                  
 16620                                  ; Convert binary number to hexadecimal string
 16621                                  ; 10/05/2015  
 16622                                  ; dsectpm.s (28/02/2015)
 16623                                  ; Retro UNIX 386 v1 - Kernel v0.2.0.6  
 16624                                  ; 01/12/2014
 16625                                  ; 25/11/2014
 16626                                  ;
 16627                                  bytetohex:
 16628                                  	; INPUT ->
 16629                                  	; 	AL = byte (binary number)
 16630                                  	; OUTPUT ->
 16631                                  	;	AX = hexadecimal string
 16632                                  	;
 16633 000040F9 53                      	push	ebx
 16634 000040FA 31DB                    	xor	ebx, ebx
 16635 000040FC 88C3                    	mov	bl, al
 16636 000040FE C0EB04                  	shr	bl, 4
 16637 00004101 8A9B[47410000]          	mov	bl, [ebx+hexchrs] 	 	
 16638 00004107 86D8                    	xchg	bl, al
 16639 00004109 80E30F                  	and	bl, 0Fh
 16640 0000410C 8AA3[47410000]          	mov	ah, [ebx+hexchrs] 
 16641 00004112 5B                      	pop	ebx	
 16642 00004113 C3                      	retn
 16643                                  
 16644                                  wordtohex:
 16645                                  	; INPUT ->
 16646                                  	; 	AX = word (binary number)
 16647                                  	; OUTPUT ->
 16648                                  	;	EAX = hexadecimal string
 16649                                  	;
 16650 00004114 53                      	push	ebx
 16651 00004115 31DB                    	xor	ebx, ebx
 16652 00004117 86E0                    	xchg	ah, al
 16653 00004119 6650                    	push	ax ; * save ax
 16654 0000411B 88E3                    	mov	bl, ah
 16655 0000411D C0EB04                  	shr	bl, 4
 16656 00004120 8A83[47410000]          	mov	al, [ebx+hexchrs]
 16657 00004126 88E3                    	mov	bl, ah
 16658 00004128 80E30F                  	and	bl, 0Fh
 16659 0000412B 8AA3[47410000]          	mov	ah, [ebx+hexchrs]
 16660 00004131 C1E010                  	shl	eax, 16 ; ax -> hw of eax
 16661 00004134 6658                    	pop	ax ; * restore ax 
 16662 00004136 5B                      	pop	ebx
 16663 00004137 EBC0                    	jmp	short bytetohex
 16664                                  	;mov	bl, al
 16665                                  	;shr	bl, 4
 16666                                  	;mov	bl, [ebx+hexchrs]
 16667                                  	;xchg	bl, al	 	
 16668                                  	;and	bl, 0Fh
 16669                                  	;mov	ah, [ebx+hexchrs] 
 16670                                  	;pop	ebx	
 16671                                  	;retn
 16672                                  
 16673                                  dwordtohex:
 16674                                  	; INPUT ->
 16675                                  	; 	EAX = dword (binary number)
 16676                                  	; OUTPUT ->
 16677                                  	;	EDX:EAX = hexadecimal string
 16678                                  	;
 16679 00004139 50                      	push	eax
 16680 0000413A C1E810                  	shr	eax, 16
 16681 0000413D E8D2FFFFFF              	call	wordtohex
 16682 00004142 89C2                    	mov	edx, eax
 16683 00004144 58                      	pop	eax
 16684                                  	;call	wordtohex
 16685                                  	;retn
 16686                                  	; 18/04/2021
 16687 00004145 EBCD                    	jmp	short wordtohex
 16688                                  
 16689                                  ; 10/05/2015
 16690                                  hex_digits:
 16691                                  hexchrs:
 16692 00004147 303132333435363738-     	db '0123456789ABCDEF'
 16693 00004150 39414243444546     
 16694                                  ; 19/01/2021 - VESA EDID ready flag (4Fh)
 16695 00004157 00                      edid:	db 0
 16696                                  
 16697                                  ; Convert binary number to decimal/numeric string
 16698                                  ; 06/11/2014
 16699                                  ; Temporary Code
 16700                                  ;
 16701                                  
 16702                                  bintdstr:
 16703                                  	; EAX = binary number
 16704                                  	; ESI = decimal/numeric string address
 16705                                  	; EBX = divisor (10)
 16706                                  	; ECX = string length (<=10)
 16707 00004158 01CE                    	add	esi, ecx
 16708                                  btdstr0:
 16709 0000415A 4E                      	dec	esi
 16710 0000415B 31D2                    	xor	edx, edx
 16711 0000415D F7F3                    	div	ebx
 16712 0000415F 80C230                  	add	dl, 30h
 16713 00004162 8816                    	mov	[esi], dl
 16714 00004164 FEC9                    	dec	cl
 16715 00004166 740C                    	jz	short btdstr2 ; 08/09/2016
 16716 00004168 09C0                    	or	eax, eax
 16717 0000416A 75EE                    	jnz	short btdstr0
 16718                                  btdstr1:
 16719 0000416C 4E                      	dec	esi
 16720 0000416D C60620                          mov     byte [esi], 20h ; blank space
 16721 00004170 FEC9                    	dec	cl
 16722 00004172 75F8                    	jnz	short btdstr1
 16723                                  btdstr2:
 16724 00004174 C3                      	retn
 16725                                  
 16726                                  ; Calculate free memory pages on M.A.T.
 16727                                  ; 06/11/2014
 16728                                  ; Temporary Code
 16729                                  ;
 16730                                  
 16731                                  calc_free_mem:
 16732 00004175 31D2                    	xor	edx, edx
 16733                                  	;xor	ecx, ecx
 16734 00004177 668B0D[98770100]        	mov	cx, [mat_size] ; in pages
 16735 0000417E C1E10A                  	shl	ecx, 10	; 1024 dwords per page
 16736 00004181 BE00001000              	mov	esi, MEM_ALLOC_TBL
 16737                                  cfm0:
 16738 00004186 AD                      	lodsd
 16739 00004187 51                      	push	ecx
 16740 00004188 B920000000              	mov	ecx, 32
 16741                                  cfm1:
 16742 0000418D D1E8                    	shr	eax, 1
 16743 0000418F 7301                    	jnc	short cfm2
 16744 00004191 42                      	inc	edx
 16745                                  cfm2:
 16746 00004192 E2F9                    	loop	cfm1
 16747 00004194 59                      	pop	ecx
 16748 00004195 E2EF                    	loop	cfm0
 16749 00004197 C3                      	retn
 16750                                  
 16751                                  %include 'diskio.s'  ; 07/03/2015
 16752                              <1> ; ****************************************************************************
 16753                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskio.s
 16754                              <1> ; ----------------------------------------------------------------------------
 16755                              <1> ; Last Update: 11/08/2022 (Previous: 18/04/2021 - Kernel v2.0.4)
 16756                              <1> ; ----------------------------------------------------------------------------
 16757                              <1> ; Beginning: 24/01/2016
 16758                              <1> ; ----------------------------------------------------------------------------
 16759                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 16760                              <1> ; ----------------------------------------------------------------------------
 16761                              <1> ; Turkish Rational DOS
 16762                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 16763                              <1> ;
 16764                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 16765                              <1> ; diskio.inc (22/08/2015)
 16766                              <1> ;
 16767                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
 16768                              <1> ; ****************************************************************************
 16769                              <1> ; Ref: Retro UNIX 386 v1.1 (Kernel v0.2.1.5) 'diskio' modification: 12/07/2022
 16770                              <1> 
 16771                              <1> ; Retro UNIX 386 v1 Kernel - DISKIO.INC
 16772                              <1> ; Last Modification: 22/08/2015
 16773                              <1> ; 	(Initialized Disk Parameters Data is in 'DISKDATA.INC') 
 16774                              <1> ; 	(Uninitialized Disk Parameters Data is in 'DISKBSS.INC') 
 16775                              <1> 
 16776                              <1> ; DISK I/O SYSTEM - Erdogan Tan (Retro UNIX 386 v1 project)
 16777                              <1> 
 16778                              <1> ; ///////// DISK I/O SYSTEM ///////////////
 16779                              <1> 
 16780                              <1> ; 11/04/2021
 16781                              <1> ;; 06/02/2015
 16782                              <1> ;diskette_io:
 16783                              <1> 	;clc ; 20/07/2020
 16784                              <1> 	;pushfd
 16785                              <1> 	;push 	cs
 16786                              <1> 	;;call 	DISKETTE_IO_1
 16787                              <1> 	;;retn
 16788                              <1> 	
 16789                              <1> ;;;;;; DISKETTE I/O ;;;;;;;;;;;;;;;;;;;; 06/02/2015 ;;;
 16790                              <1> ;//////////////////////////////////////////////////////
 16791                              <1> 
 16792                              <1> ; DISKETTE I/O - Erdogan Tan (Retro UNIX 386 v1 project)
 16793                              <1> ; 20/02/2015
 16794                              <1> ; 06/02/2015 (unix386.s)
 16795                              <1> ; 16/12/2014 - 02/01/2015 (dsectrm2.s)
 16796                              <1> ;
 16797                              <1> ; Code (DELAY) modifications - AWARD BIOS 1999 (ADISK.EQU, COMMON.MAC)
 16798                              <1> ;
 16799                              <1> ; ADISK.EQU
 16800                              <1> 
 16801                              <1> ;----- Wait control constants 
 16802                              <1> 
 16803                              <1> ;amount of time to wait while RESET is active.
 16804                              <1> 
 16805                              <1> WAITCPU_RESET_ON	EQU	21		;Reset on must last at least 14us
 16806                              <1> 						;at 250 KBS xfer rate.
 16807                              <1> 						;see INTEL MCS, 1985, pg. 5-456
 16808                              <1> 
 16809                              <1> WAITCPU_FOR_STATUS	EQU	100		;allow 30 microseconds for
 16810                              <1> 						;status register to become valid
 16811                              <1> 						;before re-reading.
 16812                              <1> 
 16813                              <1> ;After sending a byte to NEC, status register may remain
 16814                              <1> ;incorrectly set for 24 us.
 16815                              <1> 
 16816                              <1> WAITCPU_RQM_LOW		EQU	24		;number of loops to check for
 16817                              <1> 						;RQM low.
 16818                              <1> 
 16819                              <1> ; COMMON.MAC
 16820                              <1> ;
 16821                              <1> ;	Timing macros
 16822                              <1> ;
 16823                              <1> 
 16824                              <1> %macro 		SIODELAY 0 			; SHORT IODELAY
 16825                              <1> 		jmp short $+2
 16826                              <1> %endmacro		
 16827                              <1> 
 16828                              <1> %macro		IODELAY  0			; NORMAL IODELAY
 16829                              <1> 		jmp short $+2
 16830                              <1> 		jmp short $+2
 16831                              <1> %endmacro
 16832                              <1> 
 16833                              <1> %macro		NEWIODELAY 0
 16834                              <1> 		out 0EBh, al
 16835                              <1> %endmacro 
 16836                              <1> 
 16837                              <1> ; (According to) AWARD BIOS 1999 - ATORGS.ASM (dw -> equ, db -> equ)
 16838                              <1> ;;; WAIT_FOR_MEM
 16839                              <1> ;WAIT_FDU_INT_LO	equ	017798		; 2.5 secs in 30 micro units.
 16840                              <1> ;WAIT_FDU_INT_HI	equ	1
 16841                              <1> WAIT_FDU_INT_LH		equ	83334		; 27/02/2015 (2.5 seconds waiting)
 16842                              <1> ;;; WAIT_FOR_PORT
 16843                              <1> ;WAIT_FDU_SEND_LO	equ	16667		; .5 secons in 30 us units.
 16844                              <1> ;WAIT_FDU_SEND_HI	equ	0
 16845                              <1> WAIT_FDU_SEND_LH	equ 	16667		; 27/02/2015	
 16846                              <1> ;Time to wait while waiting for each byte of NEC results = .5
 16847                              <1> ;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
 16848                              <1> ;WAIT_FDU_RESULTS_LO	equ	16667		; .5 seconds in 30 micro units.
 16849                              <1> ;WAIT_FDU_RESULTS_HI	equ	0
 16850                              <1> WAIT_FDU_RESULTS_LH	equ	16667  ; 27/02/2015
 16851                              <1> ;;; WAIT_REFRESH
 16852                              <1> ;amount of time to wait for head settle, per unit in parameter
 16853                              <1> ;table = 1 ms.
 16854                              <1> WAIT_FDU_HEAD_SETTLE	equ	33		; 1 ms in 30 micro units.
 16855                              <1> 
 16856                              <1> 
 16857                              <1> ; //////////////// DISKETTE I/O ////////////////
 16858                              <1> 
 16859                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - POSTEQU.INC)
 16860                              <1> 
 16861                              <1> ;----------------------------------------
 16862                              <1> ;	EQUATES USED BY POST AND BIOS	:
 16863                              <1> ;----------------------------------------
 16864                              <1> 
 16865                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
 16866                              <1> ;PORT_A		EQU	060H		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
 16867                              <1> ;PORT_B		EQU	061H		; PORT B READ/WRITE DIAGNOSTIC REGISTER
 16868                              <1> ;REFRESH_BIT	EQU	00010000B	; REFRESH TEST BIT
 16869                              <1> 
 16870                              <1> ;----------------------------------------
 16871                              <1> ;	CMOS EQUATES FOR THIS SYSTEM	:
 16872                              <1> ;-------------------------------------------------------------------------------
 16873                              <1> ;CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
 16874                              <1> ;CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
 16875                              <1> ;NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
 16876                              <1> 					;  HIGH BIT OF CMOS LOCATION ADDRESS
 16877                              <1> 
 16878                              <1> ;---------- CMOS TABLE LOCATION ADDRESS'S ## -----------------------------------
 16879                              <1> CMOS_DISKETTE	EQU	010H		; DISKETTE DRIVE TYPE BYTE	      ;
 16880                              <1> ;		EQU	011H		; - RESERVED			      ;C
 16881                              <1> CMOS_DISK	EQU	012H		; FIXED DISK TYPE BYTE		      ;H
 16882                              <1> ;		EQU	013H		; - RESERVED			      ;E
 16883                              <1> CMOS_EQUIP	EQU	014H		; EQUIPMENT WORD LOW BYTE	      ;C
 16884                              <1> 
 16885                              <1> ;---------- DISKETTE EQUATES ---------------------------------------------------
 16886                              <1> INT_FLAG	EQU	10000000B	; INTERRUPT OCCURRENCE FLAG
 16887                              <1> DSK_CHG 	EQU	10000000B	; DISKETTE CHANGE FLAG MASK BIT
 16888                              <1> DETERMINED	EQU	00010000B	; SET STATE DETERMINED IN STATE BITS
 16889                              <1> HOME		EQU	00010000B	; TRACK 0 MASK
 16890                              <1> SENSE_DRV_ST	EQU	00000100B	; SENSE DRIVE STATUS COMMAND
 16891                              <1> TRK_SLAP	EQU	030H		; CRASH STOP (48 TPI DRIVES)
 16892                              <1> QUIET_SEEK	EQU	00AH		; SEEK TO TRACK 10
 16893                              <1> ;MAX_DRV 	EQU	2		; MAX NUMBER OF DRIVES
 16894                              <1> HD12_SETTLE	EQU	15		; 1.2 M HEAD SETTLE TIME
 16895                              <1> HD320_SETTLE	EQU	20		; 320 K HEAD SETTLE TIME
 16896                              <1> MOTOR_WAIT	EQU	37		; 2 SECONDS OF COUNTS FOR MOTOR TURN OFF
 16897                              <1> 
 16898                              <1> ;---------- DISKETTE ERRORS ----------------------------------------------------
 16899                              <1> ;TIME_OUT	EQU	080H		; ATTACHMENT FAILED TO RESPOND
 16900                              <1> ;BAD_SEEK	EQU	040H		; SEEK OPERATION FAILED
 16901                              <1> BAD_NEC 	EQU	020H		; DISKETTE CONTROLLER HAS FAILED
 16902                              <1> BAD_CRC 	EQU	010H		; BAD CRC ON DISKETTE READ
 16903                              <1> MED_NOT_FND	EQU	00CH		; MEDIA TYPE NOT FOUND
 16904                              <1> DMA_BOUNDARY	EQU	009H		; ATTEMPT TO DMA ACROSS 64K BOUNDARY
 16905                              <1> BAD_DMA 	EQU	008H		; DMA OVERRUN ON OPERATION
 16906                              <1> MEDIA_CHANGE	EQU	006H		; MEDIA REMOVED ON DUAL ATTACH CARD
 16907                              <1> RECORD_NOT_FND	EQU	004H		; REQUESTED SECTOR NOT FOUND
 16908                              <1> WRITE_PROTECT	EQU	003H		; WRITE ATTEMPTED ON WRITE PROTECT DISK
 16909                              <1> BAD_ADDR_MARK	EQU	002H		; ADDRESS MARK NOT FOUND
 16910                              <1> BAD_CMD 	EQU	001H		; BAD COMMAND PASSED TO DISKETTE I/O
 16911                              <1> 
 16912                              <1> ;---------- DISK CHANGE LINE EQUATES -------------------------------------------
 16913                              <1> NOCHGLN 	EQU	001H		; NO DISK CHANGE LINE AVAILABLE
 16914                              <1> CHGLN		EQU	002H		; DISK CHANGE LINE AVAILABLE
 16915                              <1> 
 16916                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS ---------------------------------------
 16917                              <1> TRK_CAPA	EQU	00000001B	; 80 TRACK CAPABILITY
 16918                              <1> FMT_CAPA	EQU	00000010B	; MULTIPLE FORMAT CAPABILITY (1.2M)
 16919                              <1> DRV_DET 	EQU	00000100B	; DRIVE DETERMINED
 16920                              <1> MED_DET 	EQU	00010000B	; MEDIA DETERMINED BIT
 16921                              <1> DBL_STEP	EQU	00100000B	; DOUBLE STEP BIT
 16922                              <1> RATE_MSK	EQU	11000000B	; MASK FOR CLEARING ALL BUT RATE
 16923                              <1> RATE_500	EQU	00000000B	; 500 KBS DATA RATE
 16924                              <1> RATE_300	EQU	01000000B	; 300 KBS DATA RATE
 16925                              <1> RATE_250	EQU	10000000B	; 250 KBS DATA RATE
 16926                              <1> STRT_MSK	EQU	00001100B	; OPERATION START RATE MASK
 16927                              <1> SEND_MSK	EQU	11000000B	; MASK FOR SEND RATE BITS
 16928                              <1> 
 16929                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS COMPATIBILITY -------------------------
 16930                              <1> M3D3U		EQU	00000000B	; 360 MEDIA/DRIVE NOT ESTABLISHED
 16931                              <1> M3D1U		EQU	00000001B	; 360 MEDIA,1.2DRIVE NOT ESTABLISHED
 16932                              <1> M1D1U		EQU	00000010B	; 1.2 MEDIA/DRIVE NOT ESTABLISHED
 16933                              <1> MED_UNK 	EQU	00000111B	; NONE OF THE ABOVE
 16934                              <1> 
 16935                              <1> ;---------- INTERRUPT EQUATES --------------------------------------------------
 16936                              <1> ;EOI		EQU	020H		; END OF INTERRUPT COMMAND TO 8259
 16937                              <1> ;INTA00		EQU	020H		; 8259 PORT
 16938                              <1> INTA01		EQU	021H		; 8259 PORT
 16939                              <1> INTB00		EQU	0A0H		; 2ND 8259
 16940                              <1> INTB01		EQU	0A1H		;
 16941                              <1> 
 16942                              <1> ;-------------------------------------------------------------------------------
 16943                              <1> DMA08		EQU	008H		; DMA STATUS REGISTER PORT ADDRESS
 16944                              <1> DMA		EQU	000H		; DMA CH.0 ADDRESS REGISTER PORT ADDRESS
 16945                              <1> DMA18		EQU	0D0H		; 2ND DMA STATUS PORT ADDRESS
 16946                              <1> DMA1		EQU	0C0H		; 2ND DMA CH.0 ADDRESS REGISTER ADDRESS
 16947                              <1> ;-------------------------------------------------------------------------------
 16948                              <1> ;TIMER		EQU	040H		; 8254 TIMER - BASE ADDRESS
 16949                              <1> 
 16950                              <1> ;-------------------------------------------------------------------------------
 16951                              <1> DMA_PAGE	EQU	081H		; START OF DMA PAGE REGISTERS
 16952                              <1> 
 16953                              <1> ; 06/02/2015 (unix386.s, protected mode modifications)
 16954                              <1> ; (unix386.s <-- dsectrm2.s)
 16955                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - DSEG.INC)
 16956                              <1> 
 16957                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
 16958                              <1> ; 10/12/2014
 16959                              <1> ;
 16960                              <1> ;int40h:
 16961                              <1> ;	pushf
 16962                              <1> ;	push 	cs
 16963                              <1> ;	;cli
 16964                              <1> ;	call 	DISKETTE_IO_1
 16965                              <1> ;	retn
 16966                              <1> 
 16967                              <1> ; DSKETTE ----- 04/21/86 DISKETTE BIOS
 16968                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
 16969                              <1> ;
 16970                              <1> 
 16971                              <1> ;-- INT13H ---------------------------------------------------------------------
 16972                              <1> ; DISKETTE I/O
 16973                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO THE 5 1/4 INCH 360 KB,
 16974                              <1> ;	1.2 MB, 720 KB AND 1.44 MB DISKETTE DRIVES.
 16975                              <1> ; INPUT
 16976                              <1> ;	(AH) =  00H RESET DISKETTE SYSTEM
 16977                              <1> ;		HARD RESET TO NEC, PREPARE COMMAND, RECALIBRATE REQUIRED
 16978                              <1> ;		ON ALL DRIVES
 16979                              <1> ;------------------------------------------------------------------------------- 
 16980                              <1> ;	(AH)= 01H  READ THE STATUS OF THE SYSTEM INTO (AH)
 16981                              <1> ;		@DISKETTE_STATUS FROM LAST OPERATION IS USED
 16982                              <1> ;-------------------------------------------------------------------------------
 16983                              <1> ;	REGISTERS FOR READ/WRITE/VERIFY/FORMAT
 16984                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
 16985                              <1> ;	(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
 16986                              <1> ;	(CH) - TRACK NUMBER (NOT VALUE CHECKED)
 16987                              <1> ;		MEDIA	DRIVE	TRACK NUMBER
 16988                              <1> ;		320/360	320/360	    0-39
 16989                              <1> ;		320/360	1.2M	    0-39
 16990                              <1> ;		1.2M	1.2M	    0-79
 16991                              <1> ;		720K	720K	    0-79
 16992                              <1> ;		1.44M	1.44M	    0-79	
 16993                              <1> ;	(CL) - 	SECTOR NUMBER (NOT VALUE CHECKED, NOT USED FOR FORMAT)
 16994                              <1> ;		MEDIA	DRIVE	SECTOR NUMBER
 16995                              <1> ;		320/360	320/360	     1-8/9
 16996                              <1> ;		320/360	1.2M	     1-8/9
 16997                              <1> ;		1.2M	1.2M	     1-15
 16998                              <1> ;		720K	720K	     1-9
 16999                              <1> ;		1.44M	1.44M	     1-18		
 17000                              <1> ;	(AL)	NUMBER OF SECTORS (NOT VALUE CHECKED)
 17001                              <1> ;		MEDIA	DRIVE	MAX NUMBER OF SECTORS
 17002                              <1> ;		320/360	320/360	     8/9
 17003                              <1> ;		320/360	1.2M	     8/9
 17004                              <1> ;		1.2M	1.2M	     15
 17005                              <1> ;		720K	720K	      9
 17006                              <1> ;		1.44M	1.44M	     18
 17007                              <1> ;
 17008                              <1> ;	(ES:BX) - ADDRESS OF BUFFER (NOT REQUIRED FOR VERIFY)
 17009                              <1> ;
 17010                              <1> ;-------------------------------------------------------------------------------
 17011                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY
 17012                              <1> ;-------------------------------------------------------------------------------
 17013                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY
 17014                              <1> ;-------------------------------------------------------------------------------
 17015                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS
 17016                              <1> ;-------------------------------------------------------------------------------
 17017                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK
 17018                              <1> ;		(ES,BX) MUST POINT TO THE COLLECTION OF DESIRED ADDRESS FIELDS
 17019                              <1> ;		FOR THE	TRACK. EACH FIELD IS COMPOSED OF 4 BYTES, (C,H,R,N),
 17020                              <1> ;		WHERE C = TRACK NUMBER, H=HEAD NUMBER, R = SECTOR NUMBER, 
 17021                              <1> ;		N= NUMBER OF BYTES PER SECTOR (00=128,01=256,02=512,03=1024),
 17022                              <1> ;		THERE MUST BE ONE ENTRY FOR EVERY SECTOR ON THE TRACK.
 17023                              <1> ;		THIS INFORMATION IS USED TO FIND THE REQUESTED SECTOR DURING 
 17024                              <1> ;		READ/WRITE ACCESS.
 17025                              <1> ;		PRIOR TO FORMATTING A DISKETTE, IF THERE EXISTS MORE THAN
 17026                              <1> ;		ONE SUPPORTED MEDIA FORMAT TYPE WITHIN THE DRIVE IN QUESTION,
 17027                              <1> ;		THEN "SET DASD TYPE" (INT 13H, AH = 17H) OR 'SET MEDIA TYPE'
 17028                              <1> ;		(INT 13H, AH =  18H) MUST BE CALLED TO SET THE DISKETTE TYPE
 17029                              <1> ;		THAT IS TO BE FORMATTED. IF "SET DASD TYPE" OR "SET MEDIA TYPE"
 17030                              <1> ;		IS NOT CALLED, THE FORMAT ROUTINE WILL ASSUME THE 
 17031                              <1> ;		MEDIA FORMAT TO BE THE MAXIMUM CAPACITY OF THE DRIVE.
 17032                              <1> ;
 17033                              <1> ;		THESE PARAMETERS OF DISK BASE MUST BE CHANGED IN ORDER TO
 17034                              <1> ;		FORMAT THE FOLLOWING MEDIAS:
 17035                              <1> ;		---------------------------------------------
 17036                              <1> ;		: MEDIA  :     DRIVE      : PARM 1 : PARM 2 :
 17037                              <1> ;		---------------------------------------------
 17038                              <1> ;		: 320K	 : 320K/360K/1.2M :  50H   :   8    :
 17039                              <1> ;		: 360K	 : 320K/360K/1.2M :  50H   :   9    :
 17040                              <1> ;		: 1.2M	 : 1.2M           :  54H   :  15    :
 17041                              <1> ;		: 720K	 : 720K/1.44M     :  50H   :   9    :
 17042                              <1> ;		: 1.44M	 : 1.44M          :  6CH   :  18    :		  	
 17043                              <1> ;		---------------------------------------------
 17044                              <1> ;		NOTES: - PARM 1 = GAP LENGTH FOR FORMAT
 17045                              <1> ;		       - PARM 2 = EOT (LAST SECTOR ON TRACK)
 17046                              <1> ;		       - DISK BASE IS POINTED BY DISK POINTER LOCATED
 17047                              <1> ;			 AT ABSOLUTE ADDRESS 0:78.
 17048                              <1> ;		       - WHEN FORMAT OPERATIONS ARE COMPLETE, THE PARAMETERS
 17049                              <1> ;			 SHOULD BE RESTORED TO THEIR RESPECTIVE INITIAL VALUES.			
 17050                              <1> ;-------------------------------------------------------------------------------
 17051                              <1> ;	(AH) = 08H READ DRIVE PARAMETERS
 17052                              <1> ;	REGISTERS
 17053                              <1> ;	  INPUT
 17054                              <1> ;	    (DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
 17055                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
 17056                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
 17057                              <1> ;	  OUTPUT
 17058                              <1> ;	    (ES:DI) POINTS TO DRIVE PARAMETER TABLE
 17059                              <1> ; 	    *** TRDOS 386 note: floppy disk parameter table (16 bytes)
 17060                              <1> ;	    will be returned to user in EBX, buffer address *** 27/05/2016 ***		
 17061                              <1> ;					
 17062                              <1> ;	    (CH) - LOW ORDER 8 OF 10 BITS MAXIMUM NUMBER OF TRACKS
 17063                              <1> ;	    (CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
 17064                              <1> ;	           BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
 17065                              <1> ;	    (DH) - MAXIMUM HEAD NUMBER
 17066                              <1> ;	    (DL) - NUMBER OF DISKETTE DRIVES INSTALLED
 17067                              <1> ;	    (BH) - 0
 17068                              <1> ;	    (BL) - BITS 7 THRU 4 - 0
 17069                              <1> ;	           BITS 3 THRU 0 - VALID DRIVE TYPE VALUE IN CMOS
 17070                              <1> ;	    (AX) - 0
 17071                              <1> ;	 UNDER THE FOLLOWING CIRCUMSTANCES:
 17072                              <1> ;	    (1) THE DRIVE NUMBER IS INVALID,
 17073                              <1> ;	    (2) THE DRIVE TYPE IS UNKNOWN AND CMOS IS NOT PRESENT, 
 17074                              <1> ;	    (3) THE DRIVE TYPE IS UNKNOWN AND CMOS IS BAD,
 17075                              <1> ;	    (4) OR THE DRIVE TYPE IS UNKNOWN AND THE CMOS DRIVE TYPE IS INVALID
 17076                              <1> ;	    THEN ES,AX,BX,CX,DH,DI=0 ; DL=NUMBER OF DRIVES. 
 17077                              <1> ;	    IF NO DRIVES ARE PRESENT THEN: ES,AX,BX,CX,DX,DI=0.
 17078                              <1> ;	    @DISKETTE_STATUS = 0 AND CY IS RESET.
 17079                              <1> ;-------------------------------------------------------------------------------
 17080                              <1> ;	(AH)= 15H  READ DASD TYPE
 17081                              <1> ;	OUTPUT REGISTERS
 17082                              <1> ;	(AH) - ON RETURN IF CARRY FLAG NOT SET, OTHERWISE ERROR	
 17083                              <1> ;		00 - DRIVE NOT PRESENT	
 17084                              <1> ;		01 - DISKETTE, NO CHANGE LINE AVAILABLE
 17085                              <1> ;		02 - DISKETTE, CHANGE LINE AVAILABLE	
 17086                              <1> ;		03 - RESERVED (FIXED DISK)
 17087                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
 17088                              <1> ;-------------------------------------------------------------------------------
 17089                              <1> ;	(AH)= 16H  DISK CHANGE LINE STATUS
 17090                              <1> ;	OUTPUT REGISTERS
 17091                              <1> ;	(AH) - 00 - DISK CHANGE LINE NOT ACTIVE	
 17092                              <1> ;	       06 - DISK CHANGE LINE ACTIVE & CARRY BIT ON
 17093                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
 17094                              <1> ;-------------------------------------------------------------------------------
 17095                              <1> ;	(AH)= 17H  SET DASD TYPE FOR FORMAT
 17096                              <1> ;	INPUT REGISTERS
 17097                              <1> ;	(AL) -	00 - NOT USED	
 17098                              <1> ;		01 - DISKETTE 320/360K IN 360K DRIVE	
 17099                              <1> ;		02 - DISKETTE 360K IN 1.2M DRIVE
 17100                              <1> ;		03 - DISKETTE 1.2M IN 1.2M DRIVE
 17101                              <1> ;		04 - DISKETTE 720K IN 720K DRIVE
 17102                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED:
 17103                              <1> ;	       (DO NOT USE WHEN DISKETTE ATTACH CARD USED)
 17104                              <1> ;-------------------------------------------------------------------------------
 17105                              <1> ;	(AH)= 18H  SET MEDIA TYPE FOR FORMAT
 17106                              <1> ;	INPUT REGISTERS
 17107                              <1> ;	(CH) - LOW ORDER 8 OF 10 BITS MAXIMUM TRACKS
 17108                              <1> ;	(CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
 17109                              <1> ;	       BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
 17110                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHACKED)
 17111                              <1> ;	OUTPUT REGISTERS:
 17112                              <1> ;	(ES:DI) - POINTER TO DRIVE PARAMETERS TABLE FOR THIS MEDIA TYPE,
 17113                              <1> ;		  UNCHANGED IF (AH) IS NON-ZERO
 17114                              <1> ;	(AH) - 00H, CY = 0, TRACK AND SECTORS/TRACK COMBINATION IS SUPPORTED
 17115                              <1> ;	     - 01H, CY = 1, FUNCTION IS NOT AVAILABLE
 17116                              <1> ;	     - 0CH, CY = 1, TRACK AND SECTORS/TRACK COMBINATION IS NOT SUPPORTED
 17117                              <1> ;	     - 80H, CY = 1, TIME OUT (DISKETTE NOT PRESENT)		
 17118                              <1> ;-------------------------------------------------------------------------------
 17119                              <1> ;	DISK CHANGE STATUS IS ONLY CHECKED WHEN A MEDIA SPECIFIED IS OTHER
 17120                              <1> ;	THAN 360 KB DRIVE. IF THE DISK CHANGE LINE IS FOUND TO BE
 17121                              <1> ;	ACTIVE THE FOLLOWING ACTIONS TAKE PLACE:
 17122                              <1> ;		ATTEMPT TO RESET DISK CHANGE LINE TO INACTIVE STATE. 
 17123                              <1> ;		IF ATTEMPT SUCCEEDS SET DASD TYPE FOR FORMAT AND RETURN DISK 
 17124                              <1> ;		CHANGE ERROR CODE
 17125                              <1> ;		IF ATTEMPT FAILS RETURN TIMEOUT ERROR CODE AND SET DASD TYPE 
 17126                              <1> ;		TO A PREDETERMINED STATE INDICATING MEDIA TYPE UNKNOWN.
 17127                              <1> ;	IF THE DISK CHANGE LINE IN INACTIVE PERFORM SET DASD TYPE FOR FORMAT.
 17128                              <1> ;
 17129                              <1> ; DATA VARIABLE -- @DISK_POINTER
 17130                              <1> ;	DOUBLE WORD POINTER TO THE CURRENT SET OF DISKETTE PARAMETERS
 17131                              <1> ;-------------------------------------------------------------------------------
 17132                              <1> ; OUTPUT FOR ALL FUNCTIONS
 17133                              <1> ;	AH = STATUS OF OPERATION
 17134                              <1> ;		STATUS BITS ARE DEFINED IN THE EQUATES FOR @DISKETTE_STATUS
 17135                              <1> ;		VARIABLE IN THE DATA SEGMENT OF THIS MODULE
 17136                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN, EXCEPT FOR READ DASD
 17137                              <1> ;		TYPE AH=(15)).
 17138                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)
 17139                              <1> ;	FOR READ/WRITE/VERIFY
 17140                              <1> ;		DS,BX,DX,CX PRESERVED
 17141                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISKETTE CODE, THE APPROPRIATE 
 17142                              <1> ;		ACTION IS TO RESET THE DISKETTE, THEN RETRY THE OPERATION.
 17143                              <1> ;		ON READ ACCESSES, NO MOTOR START DELAY IS TAKEN, SO THAT 
 17144                              <1> ;		THREE RETRIES ARE REQUIRED ON READS TO ENSURE THAT THE 
 17145                              <1> ;		PROBLEM IS NOT DUE TO MOTOR START-UP.
 17146                              <1> ;-------------------------------------------------------------------------------
 17147                              <1> ;
 17148                              <1> ; DISKETTE STATE MACHINE - ABSOLUTE ADDRESS 40:90 (DRIVE A) & 91 (DRIVE B)
 17149                              <1> ;
 17150                              <1> ;   -----------------------------------------------------------------
 17151                              <1> ;   |       |       |       |       |       |       |       |       |
 17152                              <1> ;   |   7   |   6   |   5   |   4   |   3   |   2   |   1   |   0   |
 17153                              <1> ;   |       |       |       |       |       |       |       |       |
 17154                              <1> ;   -----------------------------------------------------------------
 17155                              <1> ;	|	|	|	|	|	|	|	|
 17156                              <1> ;	|	|	|	|	|	-----------------
 17157                              <1> ;	|	|	|	|	|		|
 17158                              <1> ;	|	|	|	|    RESERVED		|
 17159                              <1> ;	|	|	|	|		  PRESENT STATE
 17160                              <1> ;	|	|	|	|	000: 360K IN 360K DRIVE UNESTABLISHED
 17161                              <1> ;	|	|	|	|	001: 360K IN 1.2M DRIVE UNESTABLISHED
 17162                              <1> ;	|	|	|	|	010: 1.2M IN 1.2M DRIVE UNESTABLISHED
 17163                              <1> ;	|	|	|	|	011: 360K IN 360K DRIVE ESTABLISHED
 17164                              <1> ;	|	|	|	|	100: 360K IN 1.2M DRIVE ESTABLISHED
 17165                              <1> ;	|	|	|	|	101: 1.2M IN 1.2M DRIVE ESTABLISHED
 17166                              <1> ;	|	|	|	|	110: RESERVED
 17167                              <1> ;	|	|	|	|	111: NONE OF THE ABOVE
 17168                              <1> ;	|	|	|	|
 17169                              <1> ;	|	|	|	------>	MEDIA/DRIVE ESTABLISHED
 17170                              <1> ;	|	|	|
 17171                              <1> ;	|	|	-------------->	DOUBLE STEPPING REQUIRED (360K IN 1.2M
 17172                              <1> ;	|	|			DRIVE)
 17173                              <1> ;	|	|
 17174                              <1> ;	------------------------------>	DATA TRANSFER RATE FOR THIS DRIVE:
 17175                              <1> ;
 17176                              <1> ;						00: 500 KBS
 17177                              <1> ;						01: 300 KBS
 17178                              <1> ;						10: 250 KBS
 17179                              <1> ;						11: RESERVED
 17180                              <1> ;
 17181                              <1> ;
 17182                              <1> ;-------------------------------------------------------------------------------
 17183                              <1> ; STATE OPERATION STARTED - ABSOLUTE ADDRESS 40:92 (DRIVE A) & 93 (DRIVE B)
 17184                              <1> ;-------------------------------------------------------------------------------
 17185                              <1> ; PRESENT CYLINDER NUMBER - ABSOLUTE ADDRESS 40:94 (DRIVE A) & 95 (DRIVE B)
 17186                              <1> ;-------------------------------------------------------------------------------
 17187                              <1> 
 17188                              <1> struc MD
 17189 00000000 <res 00000001>      <1> 	.SPEC1		resb	1	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 17190 00000001 <res 00000001>      <1> 	.SPEC2		resb	1	; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 17191 00000002 <res 00000001>      <1> 	.OFF_TIM	resb	1	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 17192 00000003 <res 00000001>      <1> 	.BYT_SEC	resb	1	; 512 BYTES/SECTOR
 17193 00000004 <res 00000001>      <1> 	.SEC_TRK	resb	1	; EOT (LAST SECTOR ON TRACK)
 17194 00000005 <res 00000001>      <1> 	.GAP		resb	1	; GAP LENGTH
 17195 00000006 <res 00000001>      <1> 	.DTL		resb	1	; DTL
 17196 00000007 <res 00000001>      <1> 	.GAP3		resb	1	; GAP LENGTH FOR FORMAT
 17197 00000008 <res 00000001>      <1> 	.FIL_BYT	resb	1	; FILL BYTE FOR FORMAT
 17198 00000009 <res 00000001>      <1> 	.HD_TIM		resb	1	; HEAD SETTLE TIME (MILLISECONDS)
 17199 0000000A <res 00000001>      <1> 	.STR_TIM	resb	1	; MOTOR START TIME (1/8 SECONDS)
 17200 0000000B <res 00000001>      <1> 	.MAX_TRK	resb	1	; MAX. TRACK NUMBER
 17201 0000000C <res 00000001>      <1> 	.RATE		resb	1	; DATA TRANSFER RATE
 17202                              <1> endstruc
 17203                              <1> 
 17204                              <1> BIT7OFF	EQU	7FH
 17205                              <1> BIT7ON	EQU	80H
 17206                              <1> 
 17207                              <1> ; 30/08/2020 - TRDOS 386 v2
 17208                              <1> 
 17209                              <1> ;;int13h: ; 16/02/2015
 17210                              <1> ;; 16/02/2015 - 21/02/2015
 17211                              <1> ; 17/07/2022 - TRDOS 386 v2.0.5
 17212                              <1> ;int40h:
 17213                              <1> ;; 11/04/2021
 17214                              <1> ;diskette_io:
 17215                              <1> ;	clc ; 20/07/2020
 17216                              <1> ;	pushfd
 17217                              <1> ;	push 	cs
 17218                              <1> ;	call 	DISKETTE_IO_1
 17219                              <1> ;	retn
 17220                              <1> 
 17221                              <1> 	; 09/08/2022
 17222                              <1> 	; 06/08/2022
 17223                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
 17224                              <1> 	; (jump from DISK_IO)
 17225                              <1> DISKETTE_IO_1:
 17226                              <1> 	;sti ; 17/07/2022		; INTERRUPTS BACK ON
 17227                              <1> 	
 17228                              <1> 	;push	ebp			; USER REGISTER
 17229                              <1> 	;push	edi			; USER REGISTER
 17230                              <1> 	;push	edx			; HEAD #, DRIVE # OR USER REGISTER
 17231                              <1> 	;push	ebx			; BUFFER OFFSET PARAMETER OR REGISTER
 17232                              <1> 	;push	ecx			; TRACK #-SECTOR # OR USER REGISTER
 17233                              <1> 	;mov	ebp, esp		; BP     => PARAMETER LIST DEP. ON AH
 17234                              <1> 					; [BP]   = SECTOR #
 17235                              <1> 					; [BP+1] = TRACK #
 17236                              <1> 					; [BP+2] = BUFFER OFFSET
 17237                              <1> 					; FOR RETURN OF DRIVE PARAMETERS:
 17238                              <1> 					; CL/[BP] = BITS 7&6 HI BITS OF MAX CYL
 17239                              <1> 					; 	    BITS 0-5 MAX SECTORS/TRACK
 17240                              <1> 					; CH/[BP+1] = LOW 8 BITS OF MAX CYL.
 17241                              <1> 					; BL/[BP+2] = BITS 7-4 = 0
 17242                              <1> 					;	      BITS 3-0 = VALID CMOS TYPE
 17243                              <1> 					; BH/[BP+3] = 0
 17244                              <1> 					; DL/[BP+4] = # DRIVES INSTALLED
 17245                              <1> 					; DH/[BP+5] = MAX HEAD #
 17246                              <1> 					; DI/[BP+6] = OFFSET TO DISK BASE
 17247                              <1> 	;push	es ; 06/02/2015	
 17248                              <1> 	;push	ds			; BUFFER SEGMENT PARM OR USER REGISTER
 17249                              <1> 	;push	esi			; USER REGISTERS
 17250                              <1> 	;;call	DDS			; SEGMENT OF BIOS DATA AREA TO DS
 17251                              <1> 	;;mov	cx, cs
 17252                              <1> 	;;mov	ds, cx
 17253                              <1> 	;mov	cx, KDATA
 17254                              <1> 	;mov	ds, cx
 17255                              <1> 	;mov	es, cx
 17256                              <1> 
 17257                              <1> 	; 17/07/2022
 17258                              <1> 	; Registers are also on stack 
 17259                              <1> 	; (with same contents) 
 17260                              <1> 	; in following order:
 17261                              <1> 	;
 17262                              <1> 	;    ebx = esp+20
 17263                              <1> 	;    ecx = esp+16
 17264                              <1> 	;    edx = esp+12
 17265                              <1> 	;    esi = esp+8
 17266                              <1> 	;    edi = esp+4
 17267                              <1> 	;
 17268                              <1> 	; [esp] = caller's return address (from 'DISK_IO')	
 17269                              <1> 	;
 17270                              <1> 	; cs = KCODE == KDATA
 17271                              <1> 	; ds = es = ss = KDATA
 17272                              <1> 
 17273                              <1> 	; 17/07/2022
 17274 00004198 55                  <1> 	push	ebp
 17275 00004199 89DD                <1> 	mov	ebp, ebx
 17276                              <1> 
 17277                              <1> 	;cmp	ah, (FNC_TAE-FNC_TAB)/2	; CHECK FOR > LARGEST FUNCTION
 17278 0000419B 80FC19              <1> 	cmp	ah, (FNC_TAE-FNC_TAB)/4	; 18/02/2015
 17279                              <1> 	;jb	short OK_FUNC		; FUNCTION OK
 17280                              <1> 	;mov	ah, 14h			; REPLACE WITH KNOWN INVALID FUNCTION
 17281                              <1> 	; 09/08/2022
 17282 0000419E 730F                <1> 	jnb	short INV_FUNC
 17283                              <1> OK_FUNC:
 17284 000041A0 80FC01              <1> 	cmp	ah, 1			; RESET OR STATUS ?
 17285 000041A3 760C                <1> 	jbe	short OK_DRV		; IF RESET OR STATUS DRIVE ALWAYS OK
 17286 000041A5 80FC08              <1> 	cmp	ah, 8			; READ DRIVE PARMS ?
 17287 000041A8 7407                <1> 	je	short OK_DRV		; IF SO DRIVE CHECKED LATER
 17288 000041AA 80FA01              <1> 	cmp	dl, 1			; DRIVES 0 AND 1 OK
 17289 000041AD 7602                <1> 	jbe	short OK_DRV		; IF 0 OR 1 THEN JUMP
 17290                              <1> INV_FUNC:
 17291 000041AF B414                <1> 	mov	ah, 14h			; REPLACE WITH KNOWN INVALID FUNCTION
 17292                              <1> OK_DRV:
 17293                              <1> 	; 17/07/2022
 17294                              <1> 	;xor	ecx, ecx
 17295                              <1> 	;;mov	esi, ecx ; 08/02/2015
 17296                              <1> 	;mov	edi, ecx ; 08/02/2015
 17297                              <1> 	;mov	cl, ah			; CL = FUNCTION
 17298                              <1> 	;;xor	ch, ch			; CX = FUNCTION
 17299                              <1> 	;;shl	cl, 1			; FUNCTION TIMES 2
 17300                              <1> 	;shl	cl, 2 ; 20/02/2015	; FUNCTION TIMES 4 (for 32 bit offset)
 17301                              <1> 	;mov	ebx, FNC_TAB		; LOAD START OF FUNCTION TABLE
 17302                              <1> 	;add	ebx, ecx		; ADD OFFSET INTO TABLE => ROUTINE
 17303                              <1> 
 17304                              <1> 	; 17/07/2022	
 17305 000041B1 29DB                <1> 	sub	ebx, ebx
 17306 000041B3 88E3                <1> 	mov	bl, ah			; BL = FUNCTION	
 17307 000041B5 C0E302              <1> 	shl	bl, 2 ; * 4
 17308 000041B8 81C3[D7410000]      <1> 	add	ebx, FNC_TAB		; [EBX] = FUNCTION ADDRESS
 17309                              <1> 	
 17310 000041BE 88F4                <1> 	mov	ah, dh			; AX = HEAD #,# OF SECTORS OR DASD TYPE
 17311                              <1> 	;xor	dh, dh			; DX = DRIVE #
 17312                              <1> 	;mov	si, ax			; SI = HEAD #,# OF SECTORS OR DASD TYPE
 17313                              <1> 	;mov	di, dx			; DI = DRIVE #
 17314                              <1> 	
 17315 000041C0 0FB7F0              <1> 	movzx	esi, ax			; ESI = HEAD #,# OF SECTORS OR DASD TYPE
 17316 000041C3 0FB6FA              <1> 	movzx	edi, dl			; EDI = DRIVE # 
 17317                              <1> 
 17318                              <1> 	; CH = cylinder number (low 8 bit)
 17319                              <1> 	; CL = sector number (and high 2 bits of cylinder number)
 17320                              <1> 
 17321                              <1> 	; 06/08/2022
 17322                              <1> 	; 11/12/2014
 17323                              <1>         ;mov	[cfd], dl               ; current floppy drive (for 'GET_PARM')        
 17324                              <1> 	; 06/08/2022
 17325                              <1> 	; EDI = (current) DRIVE #
 17326                              <1> 	;
 17327 000041C6 8A25[08780100]      <1> 	mov	ah, [DSKETTE_STATUS]	; LOAD STATUS TO AH FOR STATUS FUNCTION
 17328 000041CC C605[08780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; INITIALIZE FOR ALL OTHERS
 17329                              <1> 
 17330                              <1> ;	THROUGHOUT THE DISKETTE BIOS, THE FOLLOWING INFORMATION IS CONTAINED IN
 17331                              <1> ;	THE FOLLOWING MEMORY LOCATIONS AND REGISTERS. NOT ALL DISKETTE BIOS
 17332                              <1> ;	FUNCTIONS REQUIRE ALL OF THESE PARAMETERS.
 17333                              <1> ;
 17334                              <1> ;		DI	: DRIVE #
 17335                              <1> ;		SI-HI	: HEAD #
 17336                              <1> ;		SI-LOW	: # OF SECTORS OR DASD TYPE FOR FORMAT
 17337                              <1> ;		ES	: BUFFER SEGMENT
 17338                              <1> ;		[BP]	: SECTOR #
 17339                              <1> ;		[BP+1]	: TRACK #
 17340                              <1> ;		[BP+2]	: BUFFER OFFSET
 17341                              <1> ;
 17342                              <1> ;	ACROSS CALLS TO SUBROUTINES THE CARRY FLAG (CY=1), WHERE INDICATED IN 
 17343                              <1> ;	SUBROUTINE PROLOGUES, REPRESENTS AN EXCEPTION RETURN (NORMALLY AN ERROR 
 17344                              <1> ;	CONDITION). IN MOST CASES, WHEN CY = 1, @DSKETTE_STATUS CONTAINS THE 
 17345                              <1> ;	SPECIFIC ERROR CODE.
 17346                              <1> 
 17347                              <1> 	; 17/07/2022
 17348                              <1> 	; EBX = pointer to function address
 17349                              <1> 	; EBP = buffer address
 17350                              <1> 	; EDI = drive number (0 or 1)
 17351                              <1> 	; ESI = head number (byte 1) and sector count or disk type (byte 0)
 17352                              <1> 	; CH = cylinder number (low 8 bit)
 17353                              <1> 	; CL = sector number (and high 2 bits of cylinder number)
 17354                              <1> 
 17355                              <1> 					; (AH) = @DSKETTE_STATUS
 17356 000041D3 FF13                <1> 	call	dword [ebx]		; CALL THE REQUESTED FUNCTION
 17357                              <1> 	
 17358                              <1> 	;pop	esi			; RESTORE ALL REGISTERS
 17359                              <1> 	;pop	ds
 17360                              <1> 	;pop	es	; 06/02/2015
 17361                              <1> 	;pop	ecx
 17362                              <1> 	;pop	ebx
 17363                              <1> 	;pop	edx
 17364                              <1> 	;pop	edi
 17365                              <1> 	;mov	ebp, esp
 17366                              <1> 	;push	eax
 17367                              <1> 	;pushfd
 17368                              <1> 	;pop	eax
 17369                              <1> 	;;mov	[bp+6], ax
 17370                              <1> 	;mov	[ebp+12], eax  ; 18/02/2015, flags
 17371                              <1> 	;pop	eax
 17372                              <1> 	;pop	ebp
 17373                              <1> 	;iretd
 17374                              <1> 
 17375                              <1> 	; 17/07/2022
 17376 000041D5 5D                  <1> 	pop	ebp
 17377                              <1> 
 17378                              <1> 	; 17/07/2022
 17379                              <1> 	; Stack order:
 17380                              <1> 	;    ebx = esp+20
 17381                              <1> 	;    ecx = esp+16
 17382                              <1> 	;    edx = esp+12
 17383                              <1> 	;    esi = esp+8
 17384                              <1> 	;    edi = esp+4
 17385                              <1> 	;
 17386                              <1> 	; [esp] = caller's return address (from 'DISK_IO')
 17387                              <1> 
 17388                              <1> 	; CF = disk i/o status (1 = error)
 17389                              <1> 	; AH = error code (if > 0 and cf = 1)
 17390                              <1> 
 17391                              <1> 	; 17/07/2022
 17392 000041D6 C3                  <1> 	retn	; return to the caller of 'DISK_IO' 
 17393                              <1> 
 17394                              <1> ;-------------------------------------------------------------------------------
 17395                              <1> ; DW --> dd (06/02/2015)
 17396 000041D7 [3B420000]          <1> FNC_TAB	dd	DSK_RESET		; AH = 00H; RESET
 17397 000041DB [A6420000]          <1> 	dd	DSK_STATUS		; AH = 01H; STATUS
 17398 000041DF [B6420000]          <1> 	dd	DSK_READ		; AH = 02H; READ
 17399 000041E3 [C3420000]          <1> 	dd	DSK_WRITE		; AH = 03H; WRITE
 17400 000041E7 [CB430000]          <1> 	dd	DSK_VERF		; AH = 04H; VERIFY
 17401 000041EB [DB430000]          <1> 	dd	DSK_FORMAT		; AH = 05H; FORMAT
 17402 000041EF [59440000]          <1> 	dd	FNC_ERR			; AH = 06H; INVALID
 17403 000041F3 [59440000]          <1> 	dd	FNC_ERR			; AH = 07H; INVALID
 17404 000041F7 [65440000]          <1> 	dd	DSK_PARMS		; AH = 08H; READ DRIVE PARAMETERS
 17405 000041FB [59440000]          <1> 	dd	FNC_ERR			; AH = 09H; INVALID
 17406 000041FF [59440000]          <1> 	dd	FNC_ERR			; AH = 0AH; INVALID
 17407 00004203 [59440000]          <1> 	dd	FNC_ERR			; AH = 0BH; INVALID
 17408 00004207 [59440000]          <1> 	dd	FNC_ERR			; AH = 0CH; INVALID
 17409 0000420B [59440000]          <1> 	dd	FNC_ERR			; AH = 0DH; INVALID
 17410 0000420F [59440000]          <1> 	dd	FNC_ERR			; AH = 0EH; INVALID
 17411 00004213 [59440000]          <1> 	dd	FNC_ERR			; AH = 0FH; INVALID
 17412 00004217 [59440000]          <1> 	dd	FNC_ERR			; AH = 10H; INVALID
 17413 0000421B [59440000]          <1> 	dd	FNC_ERR			; AH = 11H; INVALID
 17414 0000421F [59440000]          <1> 	dd	FNC_ERR			; AH = 12H; INVALID
 17415 00004223 [59440000]          <1> 	dd	FNC_ERR			; AH = 13H; INVALID
 17416 00004227 [59440000]          <1> 	dd	FNC_ERR			; AH = 14H; INVALID
 17417 0000422B [22450000]          <1> 	dd	DSK_TYPE		; AH = 15H; READ DASD TYPE
 17418 0000422F [42450000]          <1> 	dd	DSK_CHANGE		; AH = 16H; CHANGE STATUS
 17419 00004233 [71450000]          <1> 	dd	FORMAT_SET		; AH = 17H; SET DASD TYPE
 17420 00004237 [E6450000]          <1> 	dd	SET_MEDIA		; AH = 18H; SET MEDIA TYPE	
 17421                              <1> FNC_TAE EQU     $                       ; END
 17422                              <1> 
 17423                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
 17424                              <1> ;-------------------------------------------------------------------------------
 17425                              <1> ; DISK_RESET	(AH = 00H)	
 17426                              <1> ;		RESET THE DISKETTE SYSTEM.
 17427                              <1> ;
 17428                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17429                              <1> ;-------------------------------------------------------------------------------
 17430                              <1> DSK_RESET:
 17431                              <1> 	; 17/07/2022
 17432 0000423B 66BAF203            <1> 	mov	dx, 03F2h		; ADAPTER CONTROL PORT
 17433 0000423F FA                  <1> 	cli				; NO INTERRUPTS
 17434 00004240 A0[06780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
 17435 00004245 243F                <1> 	and	al, 00111111b		; KEEP SELECTED AND MOTOR ON BITS
 17436 00004247 C0C004              <1> 	rol	al, 4			; MOTOR VALUE TO HIGH NIBBLE
 17437                              <1> 					; DRIVE SELECT TO LOW NIBBLE
 17438 0000424A 0C08                <1> 	or	al, 00001000b		; TURN ON INTERRUPT ENABLE
 17439 0000424C EE                  <1> 	out	dx, al			; RESET THE ADAPTER
 17440 0000424D C605[05780100]00    <1> 	mov	byte [SEEK_STATUS], 0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
 17441                              <1> 	;jmp	$+2			; WAIT FOR I/O
 17442                              <1> 	;jmp	$+2			; WAIT FOR I/O (TO INSURE MINIMUM
 17443                              <1> 					;      PULSE WIDTH)
 17444                              <1> 	; 19/12/2014
 17445                              <1> 	NEWIODELAY
 17446 00004254 E6EB                <2>  out 0EBh, al
 17447                              <1> 
 17448                              <1> 	; 17/12/2014 
 17449                              <1> 	; AWARD BIOS 1999 - RESETDRIVES (ADISK.ASM)
 17450 00004256 B915000000          <1> 	mov	ecx, WAITCPU_RESET_ON	; cx = 21 -- Min. 14 micro seconds !?
 17451                              <1> wdw1:
 17452                              <1> 	NEWIODELAY   ; 27/02/2015
 17453 0000425B E6EB                <2>  out 0EBh, al
 17454 0000425D E2FC                <1> 	loop	wdw1
 17455                              <1> 	;
 17456 0000425F 0C04                <1> 	or	al, 00000100b		; TURN OFF RESET BIT
 17457 00004261 EE                  <1> 	out	dx, al			; RESET THE ADAPTER
 17458                              <1> 	; 16/12/2014
 17459                              <1> 	IODELAY
 17460 00004262 EB00                <2>  jmp short $+2
 17461 00004264 EB00                <2>  jmp short $+2
 17462                              <1> 	;
 17463                              <1> 	;sti				; ENABLE THE INTERRUPTS
 17464 00004266 E8D10A0000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
 17465 0000426B 7230                <1> 	jc	short DR_ERR		; IF ERROR, RETURN IT
 17466                              <1> 	;mov	cx, 11000000b		; CL = EXPECTED @NEC_STATUS
 17467                              <1> 	; 17/07/2022
 17468                              <1> 	;xor	ch, ch
 17469 0000426D B1C0                <1> 	mov	cl, 11000000b
 17470                              <1> NXT_DRV:
 17471                              <1> 	;push	cx			; SAVE FOR CALL
 17472                              <1> 	; 11/04/2021
 17473 0000426F 51                  <1> 	push	ecx
 17474 00004270 B8[9C420000]        <1> 	mov	eax, DR_POP_ERR 	; LOAD NEC_OUTPUT ERROR ADDRESS
 17475 00004275 50                  <1> 	push	eax			; "
 17476 00004276 B408                <1> 	mov	ah, 08h			; SENSE INTERRUPT STATUS COMMAND
 17477 00004278 E8B7090000          <1> 	call	NEC_OUTPUT
 17478 0000427D 58                  <1> 	pop	eax			; THROW AWAY ERROR RETURN
 17479 0000427E E8E80A0000          <1> 	call	RESULTS			; READ IN THE RESULTS
 17480                              <1> 	;pop	cx			; RESTORE AFTER CALL
 17481                              <1> 	; 11/04/2021
 17482 00004283 59                  <1> 	pop	ecx
 17483 00004284 7217                <1> 	jc	short DR_ERR		; ERROR RETURN
 17484 00004286 3A0D[09780100]      <1> 	cmp	cl, [NEC_STATUS]	; TEST FOR DRIVE READY TRANSITION
 17485 0000428C 750F                <1> 	jnz	short DR_ERR		; EVERYTHING OK
 17486 0000428E FEC1                <1> 	inc	cl			; NEXT EXPECTED @NEC_STATUS
 17487 00004290 80F9C3              <1> 	cmp	cl, 11000011b		; ALL POSSIBLE DRIVES CLEARED
 17488 00004293 76DA                <1> 	jbe	short NXT_DRV		; FALL THRU IF 11000100B OR >
 17489                              <1> 	;
 17490 00004295 E8F4030000          <1> 	call	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
 17491                              <1> RESBAC:
 17492                              <1> 	; 06/08/2022
 17493 0000429A EB10                <1> 	jmp	short SETUP_END_X
 17494                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
 17495                              <1> 	;;mov	bx, si			; GET SAVED AL TO BL
 17496                              <1> 	;; 17/07/2022
 17497                              <1> 	;mov	ebx, esi		
 17498                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
 17499                              <1> 	;retn		
 17500                              <1> 
 17501                              <1> DR_POP_ERR:
 17502                              <1> 	;pop	cx			; CLEAR STACK
 17503                              <1> 	; 11/04/2021
 17504 0000429C 59                  <1> 	pop	ecx
 17505                              <1> DR_ERR:
 17506 0000429D 800D[08780100]20    <1> 	or	byte [DSKETTE_STATUS], BAD_NEC ; SET ERROR CODE
 17507                              <1> 	;jmp	short RESBAC		; RETURN FROM RESET
 17508                              <1> 	; 06/08/2022
 17509 000042A4 EB06                <1> 	jmp	short SETUP_END_X
 17510                              <1> 
 17511                              <1> ;-------------------------------------------------------------------------------
 17512                              <1> ; DISK_STATUS	(AH = 01H)
 17513                              <1> ;	DISKETTE STATUS.
 17514                              <1> ;
 17515                              <1> ; ON ENTRY:	AH : STATUS OF PREVIOUS OPERATION
 17516                              <1> ;
 17517                              <1> ; ON EXIT:	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF PREVIOUS OPERATION.
 17518                              <1> ;-------------------------------------------------------------------------------
 17519                              <1> DSK_STATUS:
 17520 000042A6 8825[08780100]      <1> 	mov	[DSKETTE_STATUS], ah	; PUT BACK FOR SETUP END
 17521                              <1> SETUP_END_X:	; 06/08/2022
 17522 000042AC E8FD000000          <1> 	call	SETUP_END		; VARIOUS CLEANUPS
 17523                              <1> 	;mov	bx, si			; GET SAVED AL TO BL
 17524                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
 17525                              <1> 	; 06/08/2022
 17526 000042B1 89F3                <1> 	mov	ebx, esi
 17527 000042B3 88D8                <1> 	mov	al, bl
 17528 000042B5 C3                  <1> 	retn		
 17529                              <1> 
 17530                              <1> ;-------------------------------------------------------------------------------
 17531                              <1> ; DISK_READ	(AH = 02H)	
 17532                              <1> ;	DISKETTE READ.
 17533                              <1> ;
 17534                              <1> ; ON ENTRY:	DI	: DRIVE #
 17535                              <1> ;		SI-HI	: HEAD #
 17536                              <1> ;		SI-LOW	: # OF SECTORS
 17537                              <1> ;		ES	: BUFFER SEGMENT
 17538                              <1> ;		[BP]	: SECTOR #
 17539                              <1> ;		[BP+1]	: TRACK #
 17540                              <1> ;		[BP+2]	: BUFFER OFFSET
 17541                              <1> ;
 17542                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17543                              <1> ;-------------------------------------------------------------------------------
 17544                              <1> 
 17545                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
 17546                              <1> 
 17547                              <1> DSK_READ:
 17548 000042B6 8025[06780100]7F    <1> 	and	byte [MOTOR_STATUS], 01111111b ; INDICATE A READ OPERATION
 17549 000042BD 66B846E6            <1> 	mov	ax, 0E646h		; AX = NEC COMMAND, DMA COMMAND
 17550                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
 17551                              <1> 	;retn
 17552                              <1> 	; 06/08/2022
 17553 000042C1 EB0B                <1> 	jmp	short RD_WR_VF
 17554                              <1> 
 17555                              <1> ;-------------------------------------------------------------------------------
 17556                              <1> ; DISK_WRITE	(AH = 03H)
 17557                              <1> ;	DISKETTE WRITE.
 17558                              <1> ;
 17559                              <1> ; ON ENTRY:	DI	: DRIVE #
 17560                              <1> ;		SI-HI	: HEAD #
 17561                              <1> ;		SI-LOW	: # OF SECTORS
 17562                              <1> ;		ES	: BUFFER SEGMENT
 17563                              <1> ;		[BP]	: SECTOR #
 17564                              <1> ;		[BP+1]	: TRACK #
 17565                              <1> ;		[BP+2]	: BUFFER OFFSET
 17566                              <1> ;
 17567                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17568                              <1> ;-------------------------------------------------------------------------------
 17569                              <1> 
 17570                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
 17571                              <1> 
 17572                              <1> DSK_WRITE:
 17573 000042C3 66B84AC5            <1> 	mov	ax, 0C54Ah		; AX = NEC COMMAND, DMA COMMAND
 17574 000042C7 800D[06780100]80    <1> 	or	byte [MOTOR_STATUS], 10000000b ; INDICATE WRITE OPERATION
 17575                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
 17576                              <1> 	;retn
 17577                              <1> 	; 06/08/2022
 17578                              <1> 	;jmp	short RD_WR_VF
 17579                              <1> 
 17580                              <1> 	; 09/08/2022
 17581                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 17582                              <1> ;-------------------------------------------------------------------------------
 17583                              <1> ; RD_WR_VF
 17584                              <1> ;	COMMON READ, WRITE AND VERIFY: 
 17585                              <1> ;	MAIN LOOP FOR STATE RETRIES.
 17586                              <1> ;
 17587                              <1> ; ON ENTRY:	AH = READ/WRITE/VERIFY NEC PARAMETER
 17588                              <1> ;		AL = READ/WRITE/VERIFY DMA PARAMETER
 17589                              <1> ;
 17590                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17591                              <1> ;-------------------------------------------------------------------------------
 17592                              <1> RD_WR_VF:
 17593                              <1> 	; 11/08/2022
 17594                              <1> 	; 09/08/2022
 17595                              <1> 	; 07/08/2022
 17596                              <1> 	; 06/08/2022
 17597                              <1> 	; 11/04/2021 (32 bit push/pop, AX -> EAX)
 17598 000042CE 50                  <1> 	push	eax			; SAVE DMA, NEC PARAMETERS
 17599 000042CF E803040000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 17600 000042D4 E86A040000          <1> 	call	SETUP_STATE		; INITIALIZE START AND END RATE
 17601 000042D9 58                  <1> 	pop	eax			; RESTORE READ/WRITE/VERIFY
 17602                              <1> DO_AGAIN:
 17603 000042DA 50                  <1> 	push	eax			; SAVE READ/WRITE/VERIFY PARAMETER
 17604 000042DB E8F8040000          <1> 	call	MED_CHANGE		; MEDIA CHANGE AND RESET IF CHANGED
 17605 000042E0 58                  <1> 	pop	eax			; RESTORE READ/WRITE/VERIFY
 17606                              <1> 	;jc	short RWV_END		; MEDIA CHANGE ERROR OR TIME-OUT
 17607                              <1> 	; 07/08/2022
 17608 000042E1 7305                <1> 	jnc	short RWV
 17609 000042E3 E9BC000000          <1> 	jmp	RWV_END
 17610                              <1> RWV:
 17611 000042E8 50                  <1> 	push	eax			; SAVE READ/WRITE/VERIFY PARAMETER
 17612 000042E9 8AB7[13780100]      <1> 	mov	dh, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
 17613 000042EF 80E6C0              <1> 	and	dh, RATE_MSK		; KEEP ONLY RATE
 17614 000042F2 E83E080000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL (AL)
 17615                              <1> 	;;20/02/2015
 17616                              <1> 	;;jc	short RWV_ASSUME	; ERROR IN CMOS
 17617 000042F7 7447                <1> 	jz	short RWV_ASSUME ; 20/02/2015
 17618 000042F9 3C01                <1> 	cmp	al, 1			; 40 TRACK DRIVE?
 17619 000042FB 750D                <1> 	jne	short RWV_1		; NO, BYPASS CMOS VALIDITY CHECK
 17620 000042FD F687[13780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; CHECK FOR 40 TRACK DRIVE
 17621 00004304 7411                <1> 	jz	short RWV_2		; YES, CMOS IS CORRECT
 17622                              <1> 	;mov	al, 2			; CHANGE TO 1.2M
 17623                              <1> 	; 06/08/2022
 17624 00004306 FEC0                <1> 	inc	al ; al = 2
 17625 00004308 EB0D                <1> 	jmp	short RWV_2
 17626                              <1> RWV_1:
 17627                              <1> 	; 09/08/2022
 17628                              <1> 	;jb	short RWV_2		; NO DRIVE SPECIFIED, CONTINUE
 17629 0000430A F687[13780100]01    <1> 	test    byte [DSK_STATE+edi], TRK_CAPA ; IS IT REALLY 40 TRACK?
 17630 00004311 7504                <1> 	jnz	short RWV_2		; NO, 80 TRACK
 17631 00004313 B001                <1> 	mov	al, 1			; IT IS 40 TRACK, FIX CMOS VALUE
 17632 00004315 EB00                <1> 	jmp	short rwv_3
 17633                              <1> RWV_2:
 17634                              <1> 	; 09/08/2022
 17635                              <1> 	;or	al, al			; TEST FOR NO DRIVE
 17636                              <1> 	;jz	short RWV_ASSUME	; ASSUME TYPE, USE MAX TRACK
 17637                              <1> rwv_3:
 17638 00004317 E855030000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL.
 17639 0000431C 7222                <1> 	jc	short RWV_ASSUME	; TYPE NOT IN TABLE (BAD CMOS)
 17640                              <1> 
 17641                              <1> ;-----	SEARCH FOR MEDIA/DRIVE PARAMETER TABLE
 17642                              <1> 
 17643 0000431E 57                  <1> 	push	edi			; SAVE DRIVE #
 17644                              <1> 	; 09/08/2022
 17645                              <1> 	;xor	ebx, ebx		; EBX = INDEX TO DR_TYPE TABLE
 17646 0000431F BB[78640000]        <1> 	mov	ebx, DR_TYPE
 17647                              <1> 	;mov	ecx, DR_CNT		; ECX = LOOP COUNT
 17648 00004324 B106                <1> 	mov	cl, DR_CNT
 17649                              <1> RWV_DR_SEARCH:
 17650                              <1> 	;mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
 17651 00004326 8A23                <1> 	mov	ah, [ebx]
 17652 00004328 80E47F              <1> 	and	ah, BIT7OFF		; MASK OUT MSB
 17653 0000432B 38E0                <1> 	cmp	al, ah			; DRIVE TYPE MATCH?
 17654                              <1> 	; 09/08/2022
 17655                              <1> 	;cmp	dl, ah
 17656 0000432D 7509                <1> 	jne	short RWV_NXT_MD	; NO, CHECK NEXT DRIVE TYPE
 17657                              <1> RWV_DR_FND:
 17658                              <1> 	;mov	edi, [DR_TYPE+ebx+1] 	; EDI = MEDIA/DRIVE PARAMETER TABLE
 17659 0000432F 43                  <1> 	inc	ebx
 17660 00004330 8B3B                <1> 	mov	edi, [ebx]
 17661 00004332 4B                  <1> 	dec	ebx
 17662                              <1> RWV_MD_SEARH:
 17663 00004333 3A770C              <1>         cmp	dh, [edi+MD.RATE]       ; MATCH?
 17664 00004336 741D                <1> 	je	short RWV_MD_FND	; YES, GO GET 1ST SPECIFY BYTE
 17665                              <1> RWV_NXT_MD:
 17666 00004338 83C305              <1> 	add	ebx, 5			; CHECK NEXT DRIVE TYPE
 17667                              <1> 	;loop	RWV_DR_SEARCH
 17668 0000433B FEC9                <1> 	dec	cl
 17669 0000433D 75E7                <1> 	jnz	short RWV_DR_SEARCH 
 17670 0000433F 5F                  <1> 	pop	edi			; RESTORE DRIVE #
 17671                              <1> 
 17672                              <1> ;-----	ASSUME PRIMARY DRIVE IS INSTALLED AS SHIPPED
 17673                              <1> 
 17674                              <1> RWV_ASSUME:
 17675 00004340 BB[96640000]        <1> 	mov	ebx, MD_TBL1		; POINT TO 40 TRACK 250 KBS
 17676 00004345 F687[13780100]01    <1> 	test 	byte [DSK_STATE+edi], TRK_CAPA ; TEST FOR 80 TRACK
 17677 0000434C 740A                <1> 	jz	short RWV_MD_FND1	; MUST BE 40 TRACK
 17678 0000434E BB[B0640000]        <1> 	mov	ebx, MD_TBL3		; POINT TO 80 TRACK 500 KBS
 17679 00004353 EB03                <1> 	jmp	short RWV_MD_FND1	; GO SPECIFY PARAMTERS
 17680                              <1> 
 17681                              <1> ;-----	CS:BX POINTS TO MEDIA/DRIVE PARAMETER TABLE
 17682                              <1> 	 			
 17683                              <1> RWV_MD_FND:
 17684 00004355 89FB                <1> 	mov	ebx, edi		; BX = MEDIA/DRIVE PARAMETER TABLE
 17685 00004357 5F                  <1> 	pop	edi			; RESTORE DRIVE #
 17686                              <1> 	
 17687                              <1> ;-----	SEND THE SPECIFY COMMAND TO THE CONTROLLER
 17688                              <1> 
 17689                              <1> RWV_MD_FND1:
 17690 00004358 E85A030000          <1> 	call	SEND_SPEC_MD
 17691 0000435D E8E3040000          <1> 	call	CHK_LASTRATE		; ZF=1 ATTEMP RATE IS SAME AS LAST RATE
 17692 00004362 7405                <1> 	jz	short RWV_DBL		; YES,SKIP SEND RATE COMMAND
 17693 00004364 E8BC040000          <1> 	call	SEND_RATE		; SEND DATA RATE TO NEC
 17694                              <1> RWV_DBL:
 17695 00004369 53                  <1> 	push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
 17696 0000436A E825070000          <1> 	call	SETUP_DBL		; CHECK FOR DOUBLE STEP
 17697 0000436F 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
 17698 00004370 7225                <1> 	jc	short CHK_RET		; ERROR FROM READ ID, POSSIBLE RETRY
 17699                              <1> 	;pop	eax			; RESTORE NEC COMMAND
 17700                              <1> 	;push	eax			; SAVE NEC COMMAND
 17701                              <1> 	; 09/08/2022
 17702 00004372 8B0424              <1> 	mov	eax, [esp]
 17703                              <1> 	;push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
 17704 00004375 E8E0040000          <1> 	call	DMA_SETUP		; SET UP THE DMA
 17705                              <1> 	;pop	ebx
 17706 0000437A 58                  <1> 	pop	eax			; RESTORE NEC COMMAND
 17707 0000437B 7231                <1> 	jc	short RWV_BAC		; CHECK FOR DMA BOUNDARY ERROR
 17708 0000437D 50                  <1> 	push	eax			; SAVE NEC COMMAND
 17709 0000437E 53                  <1> 	push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
 17710                              <1> 	; 11/08/2022
 17711 0000437F 8B5C2420            <1> 	mov	ebx, [esp+32] ; ECX
 17712 00004383 E866050000          <1> 	call	NEC_INIT		; INITIALIZE NEC
 17713 00004388 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
 17714 00004389 720C                <1> 	jc	short CHK_RET		; ERROR - EXIT
 17715 0000438B E88C050000          <1> 	call	RWV_COM			; OP CODE COMMON TO READ/WRITE
 17716 00004390 7205                <1> 	jc	short CHK_RET		; ERROR - EXIT
 17717 00004392 E8D2050000          <1> 	call	NEC_TERM		; TERMINATE, GET STATUS, ETC.
 17718                              <1> CHK_RET:
 17719 00004397 E871060000          <1> 	call	RETRY			; CHECK FOR, SETUP RETRY
 17720 0000439C 58                  <1> 	pop	eax			; RESTORE READ/WRITE PARAMETER
 17721 0000439D 7305                <1> 	jnc	short RWV_END		; CY = 0 NO RETRY
 17722 0000439F E936FFFFFF          <1>         jmp	DO_AGAIN                ; CY = 1 MEANS RETRY
 17723                              <1> RWV_END:
 17724 000043A4 E81C060000          <1> 	call	DSTATE			; ESTABLISH STATE IF SUCCESSFUL
 17725 000043A9 E8AE060000          <1> 	call	NUM_TRANS		; AL = NUMBER TRANSFERRED
 17726                              <1> RWV_BAC:				; BAD DMA ERROR ENTRY
 17727                              <1> 	; 06/08/2022
 17728                              <1> 	;push	eax			; SAVE NUMBER TRANSFERRED
 17729                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 17730                              <1> 	;pop	eax			; RESTORE NUMBER TRANSFERRED
 17731                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
 17732                              <1> 	;retn
 17733                              <1> 
 17734                              <1> ;-------------------------------------------------------------------------------
 17735                              <1> ; SETUP_END
 17736                              <1> ;	RESTORES @MOTOR_COUNT TO PARAMETER PROVIDED IN TABLE 
 17737                              <1> ;	AND LOADS @DSKETTE_STATUS TO AH, AND SETS CY.
 17738                              <1> ;
 17739                              <1> ; ON EXIT:
 17740                              <1> ;	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17741                              <1> ;-------------------------------------------------------------------------------
 17742                              <1> SETUP_END:
 17743                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 17744                              <1> 	;mov	dl, 2			; GET THE MOTOR WAIT PARAMETER
 17745                              <1> 	;push	ax			; SAVE NUMBER TRANSFERRED
 17746                              <1> 	; 11/04/2021
 17747 000043AE 50                  <1> 	push	eax
 17748                              <1> 	; 06/08/2022
 17749 000043AF B002                <1> 	mov	al, 2			; GET THE MOTOR WAIT PARAMETER		
 17750 000043B1 E888070000          <1> 	call	GET_PARM
 17751 000043B6 8825[07780100]      <1> 	mov	[MOTOR_COUNT], ah	; STORE UPON RETURN
 17752                              <1> 	;pop	ax			; RESTORE NUMBER TRANSFERRED
 17753                              <1> 	; 11/04/2021
 17754 000043BC 58                  <1> 	pop	eax
 17755 000043BD 8A25[08780100]      <1> 	mov	ah, [DSKETTE_STATUS]	; GET STATUS OF OPERATION
 17756 000043C3 08E4                <1> 	or	ah, ah			; CHECK FOR ERROR
 17757 000043C5 7403                <1> 	jz	short NUN_ERR		; NO ERROR
 17758 000043C7 30C0                <1> 	xor	al, al			; CLEAR NUMBER RETURNED
 17759                              <1> 	; 06/08/2022
 17760 000043C9 F9                  <1> 	stc
 17761                              <1> NUN_ERR: 
 17762                              <1> 	;cmp	ah, 1			; SET THE CARRY FLAG TO INDICATE
 17763                              <1> 	;cmc				; SUCCESS OR FAILURE
 17764 000043CA C3                  <1> 	retn
 17765                              <1> 
 17766                              <1> ;-------------------------------------------------------------------------------
 17767                              <1> ; DISK_VERF	(AH = 04H)
 17768                              <1> ;	DISKETTE VERIFY.
 17769                              <1> ;
 17770                              <1> ; ON ENTRY:	DI	: DRIVE #
 17771                              <1> ;		SI-HI	: HEAD #
 17772                              <1> ;		SI-LOW	: # OF SECTORS
 17773                              <1> ;		ES	: BUFFER SEGMENT
 17774                              <1> ;		[BP]	: SECTOR #
 17775                              <1> ;		[BP+1]	: TRACK #
 17776                              <1> ;		[BP+2]	: BUFFER OFFSET
 17777                              <1> ;
 17778                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17779                              <1> ;-------------------------------------------------------------------------------
 17780                              <1> DSK_VERF:
 17781 000043CB 8025[06780100]7F    <1> 	and	byte [MOTOR_STATUS], 01111111b ; INDICATE A READ OPERATION
 17782 000043D2 66B842E6            <1> 	mov	ax, 0E642h		; AX = NEC COMMAND, DMA COMMAND
 17783                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
 17784                              <1> 	;retn
 17785                              <1> 	; 06/08/2022
 17786 000043D6 E9F3FEFFFF          <1> 	jmp	RD_WR_VF
 17787                              <1> 
 17788                              <1> ;-------------------------------------------------------------------------------
 17789                              <1> ; DISK_FORMAT	(AH = 05H)
 17790                              <1> ;	DISKETTE FORMAT.
 17791                              <1> ;
 17792                              <1> ; ON ENTRY:	DI	: DRIVE #
 17793                              <1> ;		SI-HI	: HEAD #
 17794                              <1> ;		SI-LOW	: # OF SECTORS
 17795                              <1> ;		ES	: BUFFER SEGMENT
 17796                              <1> ;		[BP]	: SECTOR #
 17797                              <1> ;		[BP+1]	: TRACK #
 17798                              <1> ;		[BP+2]	: BUFFER OFFSET
 17799                              <1> ;		@DISK_POINTER POINTS TO THE PARAMETER TABLE OF THIS DRIVE
 17800                              <1> ;
 17801                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17802                              <1> ;-------------------------------------------------------------------------------
 17803                              <1> DSK_FORMAT:
 17804                              <1> 	; 11/08/2022
 17805                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 17806 000043DB E8F7020000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 17807 000043E0 E89F030000          <1> 	call	FMT_INIT		; ESTABLISH STATE IF UNESTABLISHED
 17808 000043E5 800D[06780100]80    <1> 	or	byte [MOTOR_STATUS], 10000000b ; INDICATE WRITE OPERATION
 17809 000043EC E8E7030000          <1> 	call	MED_CHANGE		; CHECK MEDIA CHANGE AND RESET IF SO
 17810 000043F1 7261                <1>         jc      short FM_DON            ; MEDIA CHANGED, SKIP
 17811 000043F3 E896020000          <1> 	call	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
 17812 000043F8 E848040000          <1> 	call	CHK_LASTRATE		; ZF=1 ATTEMPT RATE IS SAME AS LAST RATE
 17813 000043FD 7405                <1>         jz      short FM_WR             ; YES, SKIP SPECIFY COMMAND
 17814 000043FF E821040000          <1> 	call	SEND_RATE		; SEND DATA RATE TO CONTROLLER
 17815                              <1> FM_WR:
 17816 00004404 E8C8040000          <1> 	call	FMTDMA_SET		; SET UP THE DMA FOR FORMAT
 17817 00004409 7249                <1>         jc      short FM_DON            ; RETURN WITH ERROR
 17818 0000440B B44D                <1> 	mov	ah, 04Dh		; ESTABLISH THE FORMAT COMMAND
 17819                              <1> 	; 11/08/2022
 17820 0000440D 8B5C2418            <1> 	mov	ebx, [esp+24] ; ECX
 17821 00004411 E8D8040000          <1> 	call	NEC_INIT		; INITIALIZE THE NEC
 17822 00004416 723C                <1> 	jc	short FM_DON            ; ERROR - EXIT
 17823 00004418 B8[54440000]        <1>         mov     eax, FM_DON             ; LOAD ERROR ADDRESS
 17824 0000441D 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
 17825                              <1> 	;mov	dl, 3			; BYTES/SECTOR VALUE TO NEC
 17826                              <1> 	; 06/08/2022
 17827 0000441E B003                <1> 	mov	al, 3
 17828 00004420 E819070000          <1> 	call	GET_PARM
 17829 00004425 E80A080000          <1> 	call	NEC_OUTPUT
 17830                              <1> 	;mov	dl, 4			; SECTORS/TRACK VALUE TO NEC
 17831                              <1> 	; 06/08/2022
 17832 0000442A B004                <1> 	mov	al, 4
 17833 0000442C E80D070000          <1> 	call	GET_PARM
 17834 00004431 E8FE070000          <1> 	call	NEC_OUTPUT
 17835                              <1> 	;mov	dl, 7			; GAP LENGTH VALUE TO NEC
 17836                              <1> 	; 06/08/2022
 17837 00004436 B007                <1> 	mov	al, 7
 17838 00004438 E801070000          <1> 	call	GET_PARM
 17839 0000443D E8F2070000          <1> 	call	NEC_OUTPUT
 17840                              <1> 	;mov	dl, 8			; FILLER BYTE TO NEC
 17841                              <1> 	; 06/08/2022
 17842 00004442 B008                <1> 	mov	al, 8
 17843 00004444 E8F5060000          <1> 	call	GET_PARM
 17844 00004449 E8E6070000          <1> 	call	NEC_OUTPUT
 17845 0000444E 58                  <1> 	pop	eax			; THROW AWAY ERROR
 17846 0000444F E815050000          <1> 	call	NEC_TERM		; TERMINATE, RECEIVE STATUS, ETC,
 17847                              <1> FM_DON:
 17848                              <1> 	; 06/08/2022
 17849                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 17850                              <1> 	; 06/08/2022
 17851 00004454 E953FEFFFF          <1> 	jmp	SETUP_END_X
 17852                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
 17853                              <1> 	;; 06/08/2022
 17854                              <1> 	;mov	ebx, esi		; GET SAVED AL TO BL
 17855                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
 17856                              <1> 	;retn
 17857                              <1> 
 17858                              <1> ;-------------------------------------------------------------------------------
 17859                              <1> ; FNC_ERR
 17860                              <1> ;	INVALID FUNCTION REQUESTED OR INVALID DRIVE: 
 17861                              <1> ;	SET BAD COMMAND IN STATUS.
 17862                              <1> ;
 17863                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 17864                              <1> ;-------------------------------------------------------------------------------
 17865                              <1> FNC_ERR:				; INVALID FUNCTION REQUEST
 17866                              <1> 	;mov	ax, si
 17867                              <1> 	; 06/08/2022
 17868 00004459 89F0                <1> 	mov	eax, esi		; RESTORE AL
 17869 0000445B B401                <1> 	mov	ah, BAD_CMD		; SET BAD COMMAND ERROR
 17870 0000445D 8825[08780100]      <1> 	mov	[DSKETTE_STATUS], ah	; STORE IN DATA AREA
 17871 00004463 F9                  <1> 	stc				; SET CARRY INDICATING ERROR
 17872 00004464 C3                  <1> 	retn
 17873                              <1> 
 17874                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 17875                              <1> ; 30/08/2020
 17876                              <1> ; 29/08/2020
 17877                              <1> ; 01/06/2016
 17878                              <1> ; 28/05/2016
 17879                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v.2.0)
 17880                              <1> ;-------------------------------------------------------------------------------
 17881                              <1> ; DISK_PARMS	(AH = 08H)	
 17882                              <1> ;	READ DRIVE PARAMETERS.
 17883                              <1> ;
 17884                              <1> ; ON ENTRY:	DI : DRIVE #
 17885                              <1> ;		; 27/05/2016
 17886                              <1> ;		EBX = Buffer Address for floppy disk parameters table (16 bytes)
 17887                              <1> ;
 17888                              <1> ; ON EXIT:	CL/[BP]   = BITS 7 & 6 HI 2 BITS OF MAX CYLINDER
 17889                              <1> ;		            BITS 0-5 MAX SECTORS/TRACK
 17890                              <1> ;		CH/[BP+1] = LOW 8 BITS OF MAX CYLINDER
 17891                              <1> ;		BL/[BP+2] = BITS 7-4 = 0
 17892                              <1> ;		            BITS 3-0 = VALID CMOS DRIVE TYPE
 17893                              <1> ;		BH/[BP+3] = 0
 17894                              <1> ;		DL/[BP+4] = # DRIVES INSTALLED (VALUE CHECKED)
 17895                              <1> ;		DH/[BP+5] = MAX HEAD #
 17896                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
 17897                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
 17898                              <1> ;		;DI/[BP+6] = OFFSET TO DISK_BASE
 17899                              <1> ;		;ES        = SEGMENT OF DISK_BASE
 17900                              <1> ;
 17901                              <1> ;		AX        = 0
 17902                              <1> ;
 17903                              <1> ;		NOTE : THE ABOVE INFORMATION IS STORED IN THE USERS STACK AT
 17904                              <1> ;		       THE LOCATIONS WHERE THE MAIN ROUTINE WILL POP THEM
 17905                              <1> ;		       INTO THE APPROPRIATE REGISTERS BEFORE RETURNING TO THE
 17906                              <1> ;		       CALLER.
 17907                              <1> ;-------------------------------------------------------------------------------
 17908                              <1> DSK_PARMS:
 17909                              <1> 	; 09/08/2022
 17910                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 17911                              <1> 	;
 17912                              <1> 	; Registers on stack:
 17913                              <1> 	;    ebx = esp+28
 17914                              <1> 	;    ecx = esp+24
 17915                              <1> 	;    edx = esp+20
 17916                              <1> 	;    esi = esp+16
 17917                              <1> 	;    edi = esp+12
 17918                              <1> 	;    return address from DSKETTE_IO_1 = esp+8
 17919                              <1> 	;    ebp = esp+4
 17920                              <1> 	;    return address from DSK_PARMS = esp
 17921                              <1> 	;
 17922                              <1> 	; INPUT:
 17923                              <1> 	;   ebp = buffer address
 17924                              <1> 	;   edi = drive number (0 or 1)
 17925                              <1> 	
 17926                              <1> 	; OUTPUT:
 17927                              <1> 	;   ebx = [esp+28] ((BL = cmos type, BH = 0))
 17928                              <1> 	;   ecx = [esp+24] ((CL = sectors per track, CH = tracks - 1))
 17929                              <1> 	;   edx = [esp+20] ((DL = floppy drive count, DH = heads - 1))
 17930                              <1> 	;   user's buffer = FDPT table
 17931                              <1> 			 
 17932 00004465 E86D020000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
 17933                              <1>      	
 17934                              <1> 	;;mov	word [bp+2], 0		; DRIVE TYPE = 0
 17935                              <1>      	;;mov	ax, [EQUIP_FLAG]	; LOAD EQUIPMENT FLAG FOR # DISKETTES
 17936                              <1>      	;;and	al, 11000001b		; KEEP DISKETTE DRIVE BITS
 17937                              <1>      	;;mov	dl, 2			; DISKETTE DRIVES = 2
 17938                              <1>      	;;cmp	al, 01000001b		; 2 DRIVES INSTALLED ?
 17939                              <1>      	;;jz	short STO_DL		; IF YES JUMP
 17940                              <1>      	;;dec	dl			; DISKETTE DRIVES = 1
 17941                              <1>      	;;cmp	al, 00000001b		; 1 DRIVE INSTALLED ?
 17942                              <1>      	;;jnz	short NON_DRV		; IF NO JUMP
 17943                              <1> 	
 17944 0000446A 29D2                <1> 	sub	edx, edx
 17945 0000446C 66A1[FC640000]      <1> 	mov     ax, [fd0_type]
 17946 00004472 6621C0              <1> 	and     ax, ax
 17947 00004475 747C                <1>         jz      short NON_DRV
 17948 00004477 FEC2                <1> 	inc     dl
 17949 00004479 20E4                <1> 	and     ah, ah
 17950 0000447B 7402                <1> 	jz      short STO_DL
 17951 0000447D FEC2                <1> 	inc     dl
 17952                              <1> STO_DL:
 17953                              <1> 	; 30/08/2020
 17954                              <1> 	;cmp	dx, di
 17955                              <1> 	; 06/08/2022
 17956 0000447F 39FA                <1> 	cmp	edx, edi
 17957 00004481 7670                <1> 	jna	short NON_DRV
 17958                              <1> 	;
 17959                              <1> 	;;mov	[bp+4], dl		; STORE NUMBER OF DRIVES
 17960                              <1> 	;mov	[ebp+8], edx ; 20/02/2015	 	
 17961                              <1> 
 17962                              <1> 	; 06/08/2022
 17963 00004483 FEC6                <1> 	inc	dh ; number of heads - 1 
 17964                              <1> 	; dh = 1
 17965                              <1> 	; dl = number of floppy/diskette drives (DL)
 17966 00004485 89542414            <1> 	mov	[esp+20], edx
 17967                              <1> 
 17968                              <1> 	; 11/04/2021
 17969                              <1> 	;cmp	di, 1			; CHECK FOR VALID DRIVE
 17970                              <1> 	;;ja	short NON_DRV1		; DRIVE INVALID
 17971                              <1> 	;ja	NON_DRV1 ; 29/08/2020
 17972                              <1> 	;	
 17973                              <1> 	;;mov	byte [bp+5], 1		; MAXIMUM HEAD NUMBER =	1
 17974                              <1> 	; 06/08/2022
 17975                              <1> 	;mov	byte [ebp+9], 1 ; 20/02/2015	
 17976                              <1> 	
 17977 00004489 E8A7060000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
 17978                              <1> 	;;20/02/2015
 17979                              <1> 	;;jc	short CHK_EST		; IF CMOS BAD CHECKSUM ESTABLISHED
 17980                              <1> 	;;or	al, al			; TEST FOR NO DRIVE TYPE
 17981 0000448E 740F                <1> 	jz	short CHK_EST		; JUMP IF SO
 17982 00004490 E8DC010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
 17983 00004495 7208                <1> 	jc	short CHK_EST		; TYPE NOT IN TABLE (POSSIBLE BAD CMOS)
 17984                              <1> 	;mov	[bp+2], al		; STORE VALID CMOS DRIVE TYPE
 17985                              <1>         ;mov	[ebp+4], al ; 06/02/2015
 17986 00004497 8A4B04              <1> 	mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
 17987 0000449A 8A6B0B              <1>         mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
 17988 0000449D EB36                <1> 	jmp	short STO_CX		; CMOS GOOD, USE CMOS
 17989                              <1> CHK_EST:
 17990 0000449F 8AA7[13780100]      <1> 	mov	ah, [DSK_STATE+edi]	; LOAD STATE FOR THIS DRIVE
 17991 000044A5 F6C410              <1> 	test	ah, MED_DET		; CHECK FOR ESTABLISHED STATE
 17992 000044A8 744D                <1> 	jz	short NON_DRV1		; CMOS BAD/INVALID OR UNESTABLISHED
 17993                              <1> USE_EST:
 17994 000044AA 80E4C0              <1> 	and	ah, RATE_MSK		; ISOLATE STATE
 17995 000044AD 80FC80              <1> 	cmp	ah, RATE_250		; RATE 250 ?
 17996 000044B0 755C                <1> 	jne	short USE_EST2		; NO, GO CHECK OTHER RATE
 17997                              <1> 
 17998                              <1> ;-----	DATA RATE IS 250 KBS, TRY 360 KB TABLE FIRST
 17999                              <1> 
 18000 000044B2 B001                <1> 	mov	al, 1			; DRIVE TYPE 1 (360KB)
 18001 000044B4 E8B8010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
 18002 000044B9 8A4B04              <1>         mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
 18003 000044BC 8A6B0B              <1>         mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
 18004 000044BF F687[13780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; 80 TRACK ?
 18005 000044C6 740D                <1> 	jz	short STO_CX		; MUST BE 360KB DRIVE 
 18006                              <1> 
 18007                              <1> ;-----	IT IS 1.44 MB DRIVE
 18008                              <1> 
 18009                              <1> PARM144:
 18010 000044C8 B004                <1> 	mov	al, 4			; DRIVE TYPE 4 (1.44MB)
 18011 000044CA E8A2010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
 18012 000044CF 8A4B04              <1> 	mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
 18013 000044D2 8A6B0B              <1> 	mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
 18014                              <1> STO_CX:
 18015                              <1> 	;mov	[ebp], ecx		; SAVE POINTER IN STACK FOR RETURN
 18016                              <1> 	; 06/08/2022
 18017 000044D5 894C2418            <1> 	mov	[esp+24], ecx ; spt (cl), tracks - 1 (ch)
 18018                              <1> ES_DI:
 18019                              <1> 	;mov	[bp+6], bx		; ADDRESS OF MEDIA/DRIVE PARM TABLE 
 18020                              <1> 	;mov	[ebp+12], ebx ; 06/02/2015
 18021                              <1> 	;mov	ax, cs			; SEGMENT MEDIA/DRIVE PARAMETER TABLE
 18022                              <1> 	;mov	es, ax			; ES IS SEGMENT OF TABLE
 18023                              <1> 	;
 18024                              <1> 	; 28/05/2016
 18025                              <1> 	; 27/05/2016
 18026                              <1> 	; return floppy disk parameters table to user
 18027                              <1> 	; in user's buffer, which is pointed by EBX
 18028                              <1> 	
 18029                              <1> 	; 09/08/2022
 18030                              <1> 	;movzx	eax, al
 18031 000044D9 29C9                <1> 	sub	ecx, ecx
 18032 000044DB 88C1                <1> 	mov	cl, al
 18033                              <1> 	;;mov	[ebp+4], eax  ; ebx	; drive type (for floppy drives)
 18034                              <1> 	; 06/08/2022
 18035                              <1> 	;mov	[esp+28], eax ; drive type	
 18036                              <1> 	; 09/08/2022
 18037 000044DD 894C241C            <1> 	mov	[esp+28], ecx ; drive type
 18038                              <1> 
 18039                              <1> 	; 06/08/2022
 18040                              <1> 	;push	edi
 18041                              <1> 	
 18042                              <1> 	;mov	edi, [ebp+4]  		; ebx (input), user's buffer address
 18043                              <1> 	; 06/08/2022
 18044                              <1> 	;mov	edi, ebp ; [esp+28] ; user's buffer address
 18045                              <1> 	;
 18046                              <1> 	;; 29/08/2020
 18047                              <1> 	;or	edi, edi
 18048                              <1> 	;jz	short no_copy_fdpt
 18049                              <1> 	; 06/08/2022
 18050 000044E1 09ED                <1> 	or	ebp, ebp ; [esp+28] = ebx ; user's buffer address if > 0
 18051 000044E3 740B                <1> 	jz	short DP_OUT
 18052                              <1> 	; 06/08/2022
 18053                              <1> 	;push	edi
 18054 000044E5 89EF                <1> 	mov	edi, ebp
 18055                              <1> 	;
 18056                              <1> 	; 06/08/2022
 18057                              <1> 	; 01/06/2016 (Int 33h, disk type return for floppy disks, in BL)
 18058                              <1> 	;mov	[user_buffer], eax	; 01/06/2016 (overwrite ebx return value)
 18059                              <1> 	
 18060                              <1> 	;(Int 33h, Function 08h will replace user's buffer addr with disk type!)
 18061                              <1> 	;
 18062 000044E7 89DE                <1> 	mov	esi, ebx 		; floppy disk parameter table (16 bytes)
 18063                              <1> 	;mov	ecx, 16 ; 16 bytes
 18064                              <1>         ; 09/08/2022
 18065                              <1> 	; ecx < 256
 18066                              <1> 	; 06/08/2022
 18067                              <1> 	;sub	ecx, ecx
 18068 000044E9 B110                <1> 	mov	cl, 16
 18069 000044EB E83DC80000          <1> 	call    transfer_to_user_buffer ; trdosk6.s (16/05/2016)
 18070                              <1> no_copy_fdpt:
 18071                              <1> 	; 06/08/2022
 18072                              <1> 	;pop	edi	
 18073                              <1> DP_OUT:
 18074                              <1> 	; 06/08/2022
 18075                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 18076                              <1> 	;xor	ax, ax			; CLEAR
 18077                              <1> 	; 06/08/2022
 18078 000044F0 31C0                <1> 	xor	eax, eax
 18079                              <1> 	;clc
 18080 000044F2 C3                  <1> 	retn
 18081                              <1> 
 18082                              <1> ;-----	NO DRIVE PRESENT HANDLER
 18083                              <1> 
 18084                              <1> NON_DRV:
 18085                              <1> 	;;mov	byte [bp+4], 0		; CLEAR NUMBER OF DRIVES
 18086                              <1> 	;mov	[ebp+8], edx ; 0 ; 20/02/2015
 18087                              <1> 	; 06/08/2022
 18088 000044F3 89542414            <1> 	mov	[esp+20], edx ; 0 ; number of floppy drives and heads are 0
 18089                              <1> NON_DRV1:
 18090 000044F7 6681FF8000          <1> 	cmp	di, 80h			; CHECK FOR FIXED MEDIA TYPE REQUEST
 18091 000044FC 7206                <1> 	jb	short NON_DRV2		; CONTINUE IF NOT REQUEST FALL THROUGH
 18092                              <1> 
 18093                              <1> ;-----	FIXED DISK REQUEST FALL THROUGH ERROR
 18094                              <1> 	
 18095                              <1> 	; 06/08/2022
 18096                              <1> 	;call	XLAT_OLD		; ELSE TRANSLATE TO COMPATIBLE MODE
 18097                              <1> 	;mov	ax, si			; RESTORE AL
 18098                              <1> 	; 06/08/2022
 18099 000044FE 89F0                <1> 	mov	eax, esi
 18100 00004500 B401                <1> 	mov	ah, BAD_CMD		; SET BAD COMMAND ERROR
 18101 00004502 F9                  <1> 	stc
 18102 00004503 C3                  <1> 	retn
 18103                              <1> 
 18104                              <1> NON_DRV2:
 18105                              <1> 	;xor	ax, ax			; CLEAR PARMS IF NO DRIVES OR CMOS BAD
 18106 00004504 31C0                <1> 	xor	eax, eax	
 18107                              <1> 	;mov	[ebp], ax		; TRACKS, SECTORS/TRACK = 0
 18108                              <1> 	; 06/08/2022
 18109 00004506 89442418            <1> 	mov	[esp+24], eax ; spt and max. track number is 0
 18110                              <1> 
 18111                              <1> 	;;mov	[bp+5], ah		; HEAD = 0
 18112                              <1> 	; 06/08/2022
 18113                              <1> 	;mov	[ebp+9], ah ; 06/02/2015
 18114                              <1> 	; 06/08/2022
 18115                              <1> 	;mov	[esp+21], ah ; 0	
 18116                              <1> 
 18117                              <1> 	;;mov	[bp+6], ax		; OFFSET TO DISK_BASE = 0
 18118                              <1> 	; 06/08/2022
 18119                              <1> 	;mov	[ebp+12], eax
 18120                              <1> 	
 18121                              <1> 	;;mov	es, ax			; ES IS SEGMENT OF TABLE
 18122                              <1> 	;jmp	short DP_OUT
 18123                              <1> 
 18124                              <1> 	; 06/08/2022
 18125                              <1> 	; 30/08/2020
 18126                              <1> 	;call	XLAT_OLD
 18127                              <1> 	;;mov	ah, NOT_RDY ; drive not ready
 18128 0000450A B407                <1> 	mov	ah, INIT_FAIL ; DRIVE PARAMETER ACTIVITY FAILED 
 18129 0000450C F9                  <1> 	stc	; cf -> 1, ah = 'drive not ready' error code
 18130 0000450D C3                  <1> 	retn		
 18131                              <1> 
 18132                              <1> ;-----	DATA RATE IS EITHER 300 KBS OR 500 KBS, TRY 1.2 MB TABLE FIRST
 18133                              <1> 
 18134                              <1> USE_EST2:
 18135 0000450E B002                <1> 	mov	al, 2			; DRIVE TYPE 2 (1.2MB)
 18136 00004510 E85C010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
 18137 00004515 8A4B04              <1>         mov     cl, [ebx+MD.SEC_TRK]    ; GET SECTOR/TRACK
 18138 00004518 8A6B0B              <1>         mov     ch, [ebx+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
 18139 0000451B 80FC40              <1> 	cmp	ah, RATE_300		; RATE 300 ?
 18140 0000451E 74B5                <1> 	jz	short STO_CX		; MUST BE 1.2MB DRIVE
 18141 00004520 EBA6                <1> 	jmp	short PARM144		; ELSE, IT IS 1.44MB DRIVE 
 18142                              <1> 
 18143                              <1> ; 30/08/2020
 18144                              <1> 
 18145                              <1> ;-------------------------------------------------------------------------------
 18146                              <1> ; DISK_TYPE (AH = 15H)	
 18147                              <1> ;	THIS ROUTINE RETURNS THE TYPE OF MEDIA INSTALLED.
 18148                              <1> ;
 18149                              <1> ;  ON ENTRY:	DI = DRIVE #
 18150                              <1> ;
 18151                              <1> ;  ON EXIT:	AH = DRIVE TYPE, CY=0
 18152                              <1> ;-------------------------------------------------------------------------------
 18153                              <1> DSK_TYPE:
 18154                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 18155 00004522 E8B0010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 18156 00004527 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET PRESENT STATE INFORMATION
 18157 0000452D 08C0                <1> 	or	al, al			; CHECK FOR NO DRIVE
 18158 0000452F 740D                <1> 	jz	short NO_DRV
 18159 00004531 B401                <1> 	mov	ah, NOCHGLN		; NO CHANGE LINE FOR 40 TRACK DRIVE
 18160 00004533 A801                <1> 	test	al, TRK_CAPA		; IS THIS DRIVE AN 80 TRACK DRIVE?
 18161 00004535 7402                <1> 	jz	short DT_BACK		; IF NO JUMP
 18162 00004537 B402                <1> 	mov	ah, CHGLN		; CHANGE LINE FOR 80 TRACK DRIVE
 18163                              <1> DT_BACK:
 18164                              <1> 	; 06/08/2022
 18165                              <1> 	;;push	ax			; SAVE RETURN VALUE
 18166                              <1> 	; 11/04/2021
 18167                              <1> 	;push	eax
 18168                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 18169                              <1> 	;; 11/04/2021
 18170                              <1> 	;pop	eax
 18171                              <1> 	;; pop	ax
 18172                              <1> 	;clc				; NO ERROR
 18173                              <1> 	;mov	bx, si			; GET SAVED AL TO BL
 18174                              <1> 	; 06/08/2022
 18175 00004539 89F3                <1> 	mov	ebx, esi
 18176 0000453B 88D8                <1> 	mov	al, bl			; PUT BACK FOR RETURN
 18177 0000453D C3                  <1> 	retn
 18178                              <1> NO_DRV:	
 18179                              <1> 	;xor	ah, ah			; NO DRIVE PRESENT OR UNKNOWN
 18180                              <1> 	;jmp	short DT_BACK
 18181                              <1> 	
 18182                              <1> 	; 06/08/2022
 18183                              <1> 	; 30/08/2020
 18184                              <1> 	;call	XLAT_OLD
 18185 0000453E 29C0                <1> 	sub	eax, eax
 18186 00004540 F9                  <1> 	stc	; cf = 1 -> drive not ready, ah = 0 (disk type = 0)
 18187 00004541 C3                  <1> 	retn
 18188                              <1> 
 18189                              <1> ;-------------------------------------------------------------------------------
 18190                              <1> ; DISK_CHANGE	(AH = 16H)
 18191                              <1> ;	THIS ROUTINE RETURNS THE STATE OF THE DISK CHANGE LINE.
 18192                              <1> ;
 18193                              <1> ; ON ENTRY:	DI = DRIVE #
 18194                              <1> ;
 18195                              <1> ; ON EXIT:	AH = @DSKETTE_STATUS
 18196                              <1> ;		     00 - DISK CHANGE LINE INACTIVE, CY = 0
 18197                              <1> ;		     06 - DISK CHANGE LINE ACTIVE, CY = 1
 18198                              <1> ;-------------------------------------------------------------------------------
 18199                              <1> DSK_CHANGE:
 18200                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 18201 00004542 E890010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 18202 00004547 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET MEDIA STATE INFORMATION
 18203 0000454D 08C0                <1> 	or	al, al			; DRIVE PRESENT ?
 18204 0000454F 7417                <1> 	jz	short DC_NON		; JUMP IF NO DRIVE
 18205 00004551 A801                <1> 	test	al, TRK_CAPA		; 80 TRACK DRIVE ?
 18206 00004553 7407                <1> 	jz	short SETIT		; IF SO , CHECK CHANGE LINE
 18207                              <1> DC0:
 18208 00004555 E86B080000          <1>         call    READ_DSKCHNG            ; GO CHECK STATE OF DISK CHANGE LINE
 18209 0000455A 7407                <1> 	jz	short FINIS		; CHANGE LINE NOT ACTIVE
 18210                              <1> SETIT:	
 18211 0000455C C605[08780100]06    <1> 	mov	byte [DSKETTE_STATUS], MEDIA_CHANGE ; INDICATE MEDIA REMOVED
 18212                              <1> 
 18213                              <1> FINIS:	; 06/08/2022
 18214                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 18215                              <1> 	; 06/08/2022
 18216 00004563 E944FDFFFF          <1> 	jmp	SETUP_END_X
 18217                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
 18218                              <1> 	;; 06/08/2022
 18219                              <1> 	;mov	ebx, esi		; GET SAVED AL TO BL
 18220                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
 18221                              <1> 	;retn
 18222                              <1> DC_NON:
 18223 00004568 800D[08780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT ; SET TIMEOUT, NO DRIVE
 18224 0000456F EBF2                <1> 	jmp	short FINIS
 18225                              <1> 
 18226                              <1> ;-------------------------------------------------------------------------------
 18227                              <1> ; FORMAT_SET	(AH = 17H)
 18228                              <1> ;	THIS ROUTINE IS USED TO ESTABLISH THE TYPE OF MEDIA TO BE USED
 18229                              <1> ;	FOR THE FOLLOWING FORMAT OPERATION.
 18230                              <1> ;
 18231                              <1> ; ON ENTRY:	SI LOW = DASD TYPE FOR FORMAT
 18232                              <1> ;		DI     = DRIVE #
 18233                              <1> ;
 18234                              <1> ; ON EXIT:	@DSKETTE_STATUS REFLECTS STATUS
 18235                              <1> ;		AH = @DSKETTE_STATUS
 18236                              <1> ;		CY = 1 IF ERROR
 18237                              <1> ;-------------------------------------------------------------------------------
 18238                              <1> FORMAT_SET:
 18239 00004571 E861010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 18240                              <1> 	;push	si			; SAVE DASD TYPE
 18241                              <1> 	; 11/04/2021
 18242 00004576 56                  <1> 	push	esi
 18243                              <1> 	;mov	ax, si			; AH = ? , AL = DASD TYPE
 18244                              <1> 	;xor	ah, ah			; AH = 0 , AL = DASD TYPE
 18245                              <1> 	;mov	si, ax			; SI = DASD TYPE
 18246                              <1> 	; 11/04/2021
 18247 00004577 89F0                <1> 	mov	eax, esi
 18248 00004579 0FB6F0              <1> 	movzx	esi, al	
 18249 0000457C 80A7[13780100]0F    <1> 	and	byte [DSK_STATE+edi], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
 18250                              <1> 	;dec	si			; CHECK FOR 320/360K MEDIA & DRIVE
 18251                              <1> 	; 11/04/2021
 18252 00004583 4E                  <1> 	dec	esi
 18253 00004584 7509                <1> 	jnz	short NOT_320		; BYPASS IF NOT
 18254 00004586 808F[13780100]90    <1> 	or	byte [DSK_STATE+edi], MED_DET+RATE_250 ; SET TO 320/360
 18255 0000458D EB45                <1> 	jmp	short S0
 18256                              <1> 
 18257                              <1> NOT_320:
 18258 0000458F E844020000          <1> 	call	MED_CHANGE		; CHECK FOR TIME_OUT
 18259 00004594 803D[08780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT
 18260 0000459B 7437                <1> 	jz	short S0		; IF TIME OUT TELL CALLER
 18261                              <1> S3:
 18262                              <1> 	;dec	si			; CHECK FOR 320/360K IN 1.2M DRIVE
 18263                              <1> 	; 11/04/2021
 18264 0000459D 4E                  <1> 	dec	esi
 18265 0000459E 7509                <1> 	jnz	short NOT_320_12	; BYPASS IF NOT
 18266 000045A0 808F[13780100]70    <1> 	OR	byte [DSK_STATE+edi], MED_DET+DBL_STEP+RATE_300 ; SET STATE
 18267 000045A7 EB2B                <1> 	jmp	short S0
 18268                              <1> 
 18269                              <1> NOT_320_12:
 18270                              <1> 	;dec	si			; CHECK FOR 1.2M MEDIA IN 1.2M DRIVE
 18271                              <1> 	; 11/04/2021
 18272 000045A9 4E                  <1> 	dec	esi
 18273 000045AA 7509                <1> 	jnz	short NOT_12		; BYPASS IF NOT
 18274 000045AC 808F[13780100]10    <1> 	or	byte [DSK_STATE+edi], MED_DET+RATE_500 ; SET STATE VARIABLE
 18275 000045B3 EB1F                <1> 	jmp	short S0		; RETURN TO CALLER
 18276                              <1> 
 18277                              <1> NOT_12:	
 18278                              <1> 	;dec	si			; CHECK FOR SET DASD TYPE 04
 18279                              <1> 	; 11/04/2021
 18280 000045B5 4E                  <1> 	dec	esi
 18281 000045B6 7525                <1> 	jnz	short FS_ERR		; BAD COMMAND EXIT IF NOT VALID TYPE
 18282                              <1> 
 18283 000045B8 F687[13780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE DETERMINED ?
 18284 000045BF 740B                <1> 	jz	short ASSUME		; IF STILL NOT DETERMINED ASSUME
 18285 000045C1 B050                <1> 	mov	al, MED_DET+RATE_300
 18286 000045C3 F687[13780100]02    <1>         test    byte [DSK_STATE+edi], FMT_CAPA ; MULTIPLE FORMAT CAPABILITY ?
 18287 000045CA 7502                <1> 	jnz	short OR_IT_IN		; IF 1.2 M THEN DATA RATE 300
 18288                              <1> 
 18289                              <1> ASSUME:
 18290 000045CC B090                <1> 	mov	al, MED_DET+RATE_250	; SET UP
 18291                              <1> 
 18292                              <1> OR_IT_IN:
 18293 000045CE 0887[13780100]      <1> 	or	[DSK_STATE+edi], al	; OR IN THE CORRECT STATE
 18294                              <1> S0:
 18295                              <1> 	; 06/08/2022
 18296                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 18297 000045D4 E8D5FDFFFF          <1> 	call	SETUP_END		; VARIOUS CLEANUPS
 18298                              <1> 	;pop	BX			; GET SAVED AL TO BL
 18299                              <1> 	; 11/04/2021
 18300 000045D9 5B                  <1> 	pop	ebx
 18301 000045DA 88D8                <1> 	mov	al, bl			; PUT BACK FOR RETURN
 18302 000045DC C3                  <1> 	retn
 18303                              <1> 
 18304                              <1> FS_ERR:
 18305 000045DD C605[08780100]01    <1> 	mov	byte [DSKETTE_STATUS], BAD_CMD ; UNKNOWN STATE,BAD COMMAND
 18306 000045E4 EBEE                <1> 	jmp	short S0
 18307                              <1> 
 18308                              <1> ;-------------------------------------------------------------------------------
 18309                              <1> ; SET_MEDIA	(AH = 18H)
 18310                              <1> ;	THIS ROUTINE SETS THE TYPE OF MEDIA AND DATA RATE 
 18311                              <1> ;	TO BE USED FOR THE FOLLOWING FORMAT OPERATION.
 18312                              <1> ;
 18313                              <1> ; ON ENTRY:
 18314                              <1> ;	[BP]	= SECTOR PER TRACK
 18315                              <1> ;	[BP+1]	= TRACK #
 18316                              <1> ;	DI	= DRIVE #
 18317                              <1> ;
 18318                              <1> ; ON EXIT:
 18319                              <1> ;	@DSKETTE_STATUS REFLECTS STATUS
 18320                              <1> ;	IF NO ERROR:
 18321                              <1> ;		AH = 0
 18322                              <1> ;		CY = 0
 18323                              <1> ;		ES = SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
 18324                              <1> ;		DI/[BP+6] = OFFSET OF MEDIA/DRIVE PARAMETER TABLE
 18325                              <1> ;	IF ERROR:	
 18326                              <1> ;		AH = @DSKETTE_STATUS
 18327                              <1> ;		CY = 1
 18328                              <1> ;-------------------------------------------------------------------------------
 18329                              <1> SET_MEDIA:
 18330                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 18331 000045E6 E8EC000000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
 18332 000045EB F687[13780100]01    <1>         test    byte [DSK_STATE+edi], TRK_CAPA ; CHECK FOR CHANGE LINE AVAILABLE
 18333 000045F2 7415                <1> 	jz	short SM_CMOS		; JUMP IF 40 TRACK DRIVE
 18334 000045F4 E8DF010000          <1> 	call	MED_CHANGE		; RESET CHANGE LINE
 18335 000045F9 803D[08780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT TELL CALLER
 18336 00004600 746A                <1> 	je	short SM_RTN
 18337 00004602 C605[08780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS
 18338                              <1> SM_CMOS:
 18339 00004609 E827050000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
 18340                              <1> 	;;20/02/2015
 18341                              <1> 	;;jc	short MD_NOT_FND	; ERROR IN CMOS
 18342                              <1> 	;;or	al, al			; TEST FOR NO DRIVE
 18343 0000460E 745C                <1> 	jz	short SM_RTN		; RETURN IF SO
 18344 00004610 E85C000000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
 18345 00004615 7233                <1> 	jc	short MD_NOT_FND	; TYPE NOT IN TABLE (BAD CMOS)
 18346 00004617 57                  <1> 	push	edi			; SAVE REG.
 18347 00004618 31DB                <1> 	xor	ebx, ebx		; BX = INDEX TO DR. TYPE TABLE
 18348 0000461A B906000000          <1> 	mov	ecx, DR_CNT		; CX = LOOP COUNT
 18349                              <1> DR_SEARCH:
 18350 0000461F 8AA3[78640000]      <1> 	mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
 18351 00004625 80E47F              <1> 	and	ah, BIT7OFF		; MASK OUT MSB
 18352 00004628 38E0                <1> 	cmp	al, ah			; DRIVE TYPE MATCH ?
 18353 0000462A 7518                <1> 	jne	short NXT_MD		; NO, CHECK NEXT DRIVE TYPE
 18354                              <1> DR_FND:
 18355 0000462C 8BBB[79640000]      <1> 	mov	edi, [DR_TYPE+ebx+1] 	; DI = MEDIA/DRIVE PARAM TABLE
 18356                              <1> MD_SEARCH:
 18357 00004632 8A6704              <1>         mov	ah, [edi+MD.SEC_TRK]    ; GET SECTOR/TRACK
 18358                              <1> 	;cmp	[ebp], ah		; MATCH?
 18359                              <1> 	; 06/08/2022
 18360 00004635 38642418            <1> 	cmp	[esp+24], ah  ; CL ; spt	
 18361 00004639 7509                <1> 	jne	short NXT_MD		; NO, CHECK NEXT MEDIA
 18362 0000463B 8A670B              <1>         mov     ah, [edi+MD.MAX_TRK]    ; GET MAX. TRACK #
 18363                              <1> 	;cmp 	[ebp+1], ah		; MATCH?
 18364                              <1> 	; 06/08/2022
 18365 0000463E 38642419            <1> 	cmp	[esp+25], ah  ; CH ; heads - 1
 18366 00004642 740F                <1> 	je	short MD_FND		; YES, GO GET RATE
 18367                              <1> NXT_MD:
 18368                              <1> 	;add	bx, 3			; CHECK NEXT DRIVE TYPE
 18369 00004644 83C305              <1>         add	ebx, 5 ; 18/02/2015
 18370 00004647 E2D6                <1> 	loop	DR_SEARCH
 18371 00004649 5F                  <1> 	pop	edi			; RESTORE REG.
 18372                              <1> MD_NOT_FND:
 18373 0000464A C605[08780100]0C    <1> 	mov	byte [DSKETTE_STATUS], MED_NOT_FND ; ERROR, MEDIA TYPE NOT FOUND
 18374 00004651 EB19                <1> 	jmp	short SM_RTN		; RETURN
 18375                              <1> MD_FND:
 18376 00004653 8A470C              <1>         mov	al, [edi+MD.RATE]       ; GET RATE
 18377 00004656 3C40                <1> 	cmp	al, RATE_300		; DOUBLE STEP REQUIRED FOR RATE 300
 18378 00004658 7502                <1> 	jne	short MD_SET
 18379 0000465A 0C20                <1> 	or	al, DBL_STEP
 18380                              <1> MD_SET:
 18381                              <1> 	;;mov	[bp+6], di		; SAVE TABLE POINTER IN STACK
 18382                              <1> 	; 06/08/2022
 18383                              <1> 	;mov	[ebp+12], edi ; 18/02/2015
 18384                              <1> 	
 18385 0000465C 0C10                <1> 	or	al, MED_DET		; SET MEDIA ESTABLISHED
 18386 0000465E 5F                  <1> 	pop	edi
 18387 0000465F 80A7[13780100]0F    <1> 	and	byte [DSK_STATE+edi], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
 18388 00004666 0887[13780100]      <1> 	or	[DSK_STATE+edi], al
 18389                              <1> 	;mov	ax, cs			; SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
 18390                              <1> 	;mov	es, ax			; ES IS SEGMENT OF TABLE
 18391                              <1> SM_RTN:
 18392                              <1> 	; 06/08/2022
 18393                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 18394                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
 18395                              <1> 	;retn
 18396                              <1> 	; 06/08/2022
 18397 0000466C E93DFDFFFF          <1> 	jmp	SETUP_END
 18398                              <1> 
 18399                              <1> ;----------------------------------------------------------------
 18400                              <1> ; DR_TYPE_CHECK							:
 18401                              <1> ;	CHECK IF THE GIVEN DRIVE TYPE IN REGISTER (AL)		:
 18402                              <1> ;	IS SUPPORTED IN BIOS DRIVE TYPE TABLE			:
 18403                              <1> ; ON ENTRY:							:
 18404                              <1> ;	AL = DRIVE TYPE						:
 18405                              <1> ; ON EXIT:							:
 18406                              <1> ;	CY = 0 	DRIVE TYPE SUPPORTED				:
 18407                              <1> ;	     EBX = OFFSET TO MEDIA/DRIVE PARAMETER TABLE	:
 18408                              <1> ;	CY = 1	DRIVE TYPE NOT SUPPORTED 			:
 18409                              <1> ; REGISTERS ALTERED: EBX, AH ; 11/07/2022 			:
 18410                              <1> ;----------------------------------------------------------------
 18411                              <1> DR_TYPE_CHECK:
 18412                              <1> 	; 09/08/2022 - TRDOS 386 Kernel v2.0.5 
 18413                              <1> 	; 12/07/2022
 18414                              <1> 	; 11/07/2022
 18415                              <1> 	; 08/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 18416                              <1> 	; 24/12/2021
 18417                              <1> 	;push	eax ; 11/07/2022
 18418                              <1> 	;push	ecx ; 08/07/2022
 18419                              <1> 	;xor	ebx,ebx			; EBX = INDEX TO DR_TYPE TABLE
 18420 00004671 BB[78640000]        <1> 	mov	ebx, DR_TYPE
 18421                              <1> 	;;mov	ecx, DR_CNT		; ECX = LOOP COUNT
 18422                              <1> 	;mov	cl, DR_CNT
 18423 00004676 B406                <1> 	mov	ah, DR_CNT ; 11/07/2022
 18424                              <1> TYPE_CHK:	
 18425                              <1> 	;;mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
 18426                              <1> 	;mov	ah, [ebx]
 18427                              <1> 	;cmp	al, ah			; DRIVE TYPE MATCH?
 18428 00004678 3A03                <1> 	cmp	al, [ebx] ; 11/07/2022
 18429 0000467A 740E                <1> 	je	short DR_TYPE_VALID	; YES, RETURN WITH CARRY RESET
 18430                              <1> 	; 16/02/2015 (32 bit address modification)
 18431 0000467C 83C305              <1> 	add	ebx, 5			; CHECK NEXT DRIVE TYPE
 18432                              <1> 	;loop	TYPE_CHK
 18433                              <1> 	;dec	cl
 18434 0000467F FECC                <1> 	dec	ah ; 11/07/2022
 18435 00004681 75F5                <1> 	jnz	short TYPE_CHK
 18436                              <1> 	;
 18437 00004683 BB[D7640000]        <1> 	mov	ebx, MD_TBL6		; 1.44MB fd parameter table
 18438                              <1> 					; Default for GET_PARM (11/12/2014)
 18439                              <1> 	;
 18440 00004688 F9                  <1> 	stc				; DRIVE TYPE NOT FOUND IN TABLE
 18441                              <1> 	;jmp	short TYPE_RTN
 18442                              <1> 	; 12/07/2022
 18443 00004689 C3                  <1> 	retn
 18444                              <1> DR_TYPE_VALID:
 18445                              <1> 	;mov	ebx, [DR_TYPE+ebx+1] 	; EBX = MEDIA TABLE
 18446 0000468A 43                  <1> 	inc	ebx
 18447 0000468B 8B1B                <1> 	mov	ebx, [ebx]
 18448                              <1> TYPE_RTN:
 18449                              <1> 	;pop	ecx ; 08/07/2022
 18450                              <1> 	; 24/12/2021
 18451                              <1> 	;pop	eax ; 11/07/2022
 18452 0000468D C3                  <1> 	retn	
 18453                              <1> 		
 18454                              <1> ;----------------------------------------------------------------
 18455                              <1> ; SEND_SPEC							:
 18456                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
 18457                              <1> ;	THE DRIVE PARAMETER TABLE POINTED BY @DISK_POINTER	:
 18458                              <1> ; ON ENTRY:	@DISK_POINTER = DRIVE PARAMETER TABLE		:
 18459                              <1> ; ON EXIT:	NONE						:	
 18460                              <1> ; REGISTERS ALTERED: CX, DX					:
 18461                              <1> ;----------------------------------------------------------------		
 18462                              <1> SEND_SPEC:
 18463                              <1> 	; 06/08/2022
 18464 0000468E 50                  <1> 	push	eax			; SAVE AX
 18465 0000468F B8[B5460000]        <1> 	mov	eax, SPECBAC		; LOAD ERROR ADDRESS
 18466 00004694 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
 18467 00004695 B403                <1> 	mov	ah, 03h			; SPECIFY COMMAND
 18468 00004697 E898050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18469                              <1> 	;sub	dl, dl			; FIRST SPECIFY BYTE
 18470                              <1> 	; 06/08/2022
 18471 0000469C 28C0                <1> 	sub	al, al ; 0 
 18472 0000469E E89B040000          <1> 	call	GET_PARM		; GET PARAMETER TO AH
 18473 000046A3 E88C050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18474                              <1> 	;mov	dl, 1			; SECOND SPECIFY BYTE
 18475                              <1> 	; 06/08/2022
 18476 000046A8 B001                <1> 	mov	al, 1
 18477 000046AA E88F040000          <1> 	call	GET_PARM		; GET PARAMETER TO AH
 18478 000046AF E880050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18479 000046B4 58                  <1> 	pop	eax			; POP ERROR RETURN
 18480                              <1> SPECBAC:
 18481 000046B5 58                  <1> 	pop	eax			; RESTORE ORIGINAL AX VALUE
 18482 000046B6 C3                  <1> 	retn
 18483                              <1> 
 18484                              <1> ;----------------------------------------------------------------
 18485                              <1> ; SEND_SPEC_MD							:
 18486                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
 18487                              <1> ;	THE MEDIA/DRIVE PARAMETER TABLE POINTED BY (CS:BX)	:
 18488                              <1> ; ON ENTRY:	CS:BX = MEDIA/DRIVE PARAMETER TABLE		:
 18489                              <1> ; ON EXIT:	NONE						:	
 18490                              <1> ; REGISTERS ALTERED: AX						:
 18491                              <1> ;----------------------------------------------------------------		
 18492                              <1> SEND_SPEC_MD:
 18493 000046B7 50                  <1> 	push	eax			; SAVE RATE DATA
 18494 000046B8 B8[D5460000]        <1> 	mov	eax, SPEC_ESBAC		; LOAD ERROR ADDRESS
 18495 000046BD 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
 18496 000046BE B403                <1> 	mov	ah, 03h			; SPECIFY COMMAND
 18497 000046C0 E86F050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18498 000046C5 8A23                <1>         mov     ah, [ebx+MD.SPEC1]      ; GET 1ST SPECIFY BYTE
 18499 000046C7 E868050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18500 000046CC 8A6301              <1>         mov     ah, [ebx+MD.SPEC2]      ; GET SECOND SPECIFY BYTE
 18501 000046CF E860050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
 18502 000046D4 58                  <1> 	pop	eax			; POP ERROR RETURN
 18503                              <1> SPEC_ESBAC:
 18504 000046D5 58                  <1> 	pop	eax			; RESTORE ORIGINAL AX VALUE
 18505 000046D6 C3                  <1> 	retn
 18506                              <1> 
 18507                              <1> ;-------------------------------------------------------------------------------
 18508                              <1> ; XLAT_NEW  
 18509                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM COMPATIBLE
 18510                              <1> ;	MODE TO NEW ARCHITECTURE.
 18511                              <1> ;
 18512                              <1> ; ON ENTRY:	DI = DRIVE #
 18513                              <1> ;-------------------------------------------------------------------------------
 18514                              <1> XLAT_NEW:
 18515                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 18516                              <1> 	; 11/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 18517 000046D7 83FF01              <1> 	cmp	edi, 1			; VALID DRIVE
 18518 000046DA 7709                <1> 	ja	short XN_OUT		; IF INVALID BACK
 18519 000046DC 80BF[13780100]00    <1> 	cmp	byte [DSK_STATE+edi], 0	; NO DRIVE ?
 18520 000046E3 7401                <1> 	jz	short DO_DET		; IF NO DRIVE ATTEMPT DETERMINE
 18521                              <1> 	
 18522                              <1> 	;;mov	cx, di			; CX = DRIVE NUMBER
 18523                              <1> 	;mov	ecx, edi
 18524                              <1> 	;or	cl, cl
 18525                              <1> 	;jz	short XN_0
 18526                              <1> 	;shl	cl, 2			; CL = SHIFT COUNT, A=0, B=4
 18527                              <1> 	;mov	al, [HF_CNTRL]		; DRIVE INFORMATION
 18528                              <1> 	;ror	al, cl			; TO LOW NIBBLE
 18529                              <1> ;XN_0:	
 18530                              <1> 	;and	al, DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
 18531                              <1>         ;and	byte [DSK_STATE+edi], ~(DRV_DET+FMT_CAPA+TRK_CAPA)
 18532                              <1> 	;or	[DSK_STATE+edi], al	; UPDATE DRIVE STATE
 18533                              <1> XN_OUT:
 18534 000046E5 C3                  <1> 	retn
 18535                              <1> 
 18536                              <1> DO_DET:
 18537                              <1> 	;call	DRIVE_DET		; TRY TO DETERMINE
 18538                              <1> 	;retn
 18539                              <1> 	;jmp	DRIVE_DET
 18540                              <1> 
 18541                              <1> ;-------------------------------------------------------------------------------
 18542                              <1> ; DRIVE_DET
 18543                              <1> ;	DETERMINES WHETHER DRIVE IS 80 OR 40 TRACKS AND
 18544                              <1> ;	UPDATES STATE INFORMATION ACCORDINGLY.
 18545                              <1> ; ON ENTRY:	DI = DRIVE #
 18546                              <1> ;-------------------------------------------------------------------------------
 18547                              <1> DRIVE_DET:
 18548                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 18549                              <1> 	; 08/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 18550 000046E6 E88E040000          <1> 	call	MOTOR_ON		; TURN ON MOTOR IF NOT ALREADY ON
 18551 000046EB E8FA050000          <1> 	call	RECAL			; RECALIBRATE DRIVE
 18552 000046F0 724E                <1> 	jc	short DD_BAC		; ASSUME NO DRIVE PRESENT
 18553 000046F2 B530                <1> 	mov	ch, TRK_SLAP		; SEEK TO TRACK 48
 18554 000046F4 E872050000          <1> 	call	SEEK
 18555 000046F9 7245                <1> 	jc	short DD_BAC		; ERROR NO DRIVE
 18556 000046FB B50B                <1> 	mov	ch, QUIET_SEEK+1	; SEEK TO TRACK 10
 18557                              <1> SK_GIN:
 18558 000046FD FECD                <1> 	dec	ch			; DECREMENT TO NEXT TRACK
 18559                              <1> 	;push	cx			; SAVE TRACK
 18560                              <1> 	; 11/04/2021
 18561 000046FF 51                  <1> 	push	ecx
 18562 00004700 E866050000          <1> 	call	SEEK
 18563 00004705 723A                <1> 	jc	short POP_BAC		; POP AND RETURN
 18564 00004707 B8[41470000]        <1> 	mov	eax, POP_BAC		; LOAD NEC OUTPUT ERROR ADDRESS
 18565 0000470C 50                  <1> 	push	eax
 18566 0000470D B404                <1> 	mov	ah, SENSE_DRV_ST	; SENSE DRIVE STATUS COMMAND BYTE
 18567 0000470F E820050000          <1> 	call	NEC_OUTPUT		; OUTPUT TO NEC
 18568                              <1> 	;mov	ax, di			; AL = DRIVE
 18569                              <1> 	; 06/08/2022
 18570 00004714 89F8                <1> 	mov	eax, edi
 18571 00004716 88C4                <1> 	mov	ah, al			; AH = DRIVE
 18572 00004718 E817050000          <1> 	call	NEC_OUTPUT		; OUTPUT TO NEC
 18573 0000471D E849060000          <1> 	call	RESULTS			; GO GET STATUS
 18574 00004722 58                  <1> 	pop	eax			; THROW AWAY ERROR ADDRESS
 18575                              <1> 	;pop	cx			; RESTORE TRACK
 18576                              <1> 	; 11/04/2021
 18577 00004723 59                  <1> 	pop	ecx
 18578 00004724 F605[09780100]10    <1> 	test	byte [NEC_STATUS], HOME	; TRACK 0 ?
 18579 0000472B 74D0                <1> 	jz	short SK_GIN		; GO TILL TRACK 0
 18580 0000472D 08ED                <1> 	or	ch, ch			; IS HOME AT TRACK 0
 18581 0000472F 7408                <1> 	jz	short IS_80		; MUST BE 80 TRACK DRIVE
 18582                              <1> 
 18583                              <1> ;	DRIVE IS A 360; SET DRIVE TO DETERMINED;
 18584                              <1> ;	SET MEDIA TO DETERMINED AT RATE 250.
 18585                              <1> 
 18586 00004731 808F[13780100]94    <1> 	or	byte [DSK_STATE+edi], DRV_DET+MED_DET+RATE_250
 18587 00004738 C3                  <1> 	retn				; ALL INFORMATION SET
 18588                              <1> IS_80:
 18589 00004739 808F[13780100]01    <1> 	or	byte [DSK_STATE+edi], TRK_CAPA ; SETUP 80 TRACK CAPABILITY
 18590                              <1> DD_BAC:
 18591 00004740 C3                  <1> 	retn
 18592                              <1> POP_BAC:
 18593                              <1> 	;pop	cx			; THROW AWAY
 18594                              <1> 	; 11/04/2021
 18595 00004741 59                  <1> 	pop	ecx
 18596 00004742 C3                  <1> 	retn
 18597                              <1> 
 18598                              <1> 
 18599                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 18600                              <1> 
 18601                              <1> %if 0
 18602                              <1> 
 18603                              <1> ;-------------------------------------------------------------------------------
 18604                              <1> ; XLAT_OLD 
 18605                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM NEW
 18606                              <1> ;	ARCHITECTURE TO COMPATIBLE MODE.
 18607                              <1> ;
 18608                              <1> ; ON ENTRY:	DI = DRIVE
 18609                              <1> ;-------------------------------------------------------------------------------
 18610                              <1> XLAT_OLD:
 18611                              <1> 	cmp	edi, 1			; VALID DRIVE ?
 18612                              <1> 	ja	short XO_OUT            ; IF INVALID BACK
 18613                              <1>         cmp	byte [DSK_STATE+edi], 0	; NO DRIVE ?
 18614                              <1> 	jz	short XO_OUT		; IF NO DRIVE TRANSLATE DONE
 18615                              <1> 
 18616                              <1> ;-----	TEST FOR SAVED DRIVE INFORMATION ALREADY SET
 18617                              <1> 
 18618                              <1> 	;mov	cx, di			; CX = DRIVE NUMBER
 18619                              <1> 	; 06/08/2022
 18620                              <1> 	mov	ecx, edi
 18621                              <1> 	shl	cl, 2			; CL = SHIFT COUNT, A=0, B=4
 18622                              <1> 	mov	ah, FMT_CAPA		; LOAD MULTIPLE DATA RATE BIT MASK
 18623                              <1> 	ror	ah, cl			; ROTATE BY MASK
 18624                              <1> 	test	[HF_CNTRL], ah		; MULTIPLE-DATA RATE DETERMINED ?
 18625                              <1> 	jnz	short SAVE_SET		; IF SO, NO NEED TO RE-SAVE
 18626                              <1> 
 18627                              <1> ;-----	ERASE DRIVE BITS IN @HF_CNTRL FOR THIS DRIVE
 18628                              <1> 
 18629                              <1> 	mov	ah, DRV_DET+FMT_CAPA+TRK_CAPA ; MASK TO KEEP
 18630                              <1> 	ror	ah, cl			; FIX MASK TO KEEP
 18631                              <1> 	not	ah			; TRANSLATE MASK
 18632                              <1> 	and	[HF_CNTRL], ah		; KEEP BITS FROM OTHER DRIVE INTACT
 18633                              <1> 
 18634                              <1> ;-----	ACCESS CURRENT DRIVE BITS AND STORE IN @HF_CNTRL
 18635                              <1> 
 18636                              <1> 	mov	al, [DSK_STATE+edi]	; ACCESS STATE
 18637                              <1> 	and	al, DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
 18638                              <1> 	ror	al, cl			; FIX FOR THIS DRIVE
 18639                              <1> 	or	[HF_CNTRL], al		; UPDATE SAVED DRIVE STATE
 18640                              <1> 
 18641                              <1> ;-----	TRANSLATE TO COMPATIBILITY MODE
 18642                              <1> 
 18643                              <1> SAVE_SET:
 18644                              <1> 	mov	ah, [DSK_STATE+edi]	; ACCESS STATE
 18645                              <1> 	mov	bh, ah			; TO BH FOR LATER
 18646                              <1> 	and	ah, RATE_MSK		; KEEP ONLY RATE
 18647                              <1> 	cmp	ah, RATE_500		; RATE 500 ?
 18648                              <1> 	jz	short CHK_144		; YES 1.2/1.2 OR 1.44/1.44
 18649                              <1> 	mov	al, M3D1U		; AL = 360 IN 1.2 UNESTABLISHED
 18650                              <1> 	cmp	ah, RATE_300		; RATE 300 ?
 18651                              <1> 	jnz	short CHK_250		; NO, 360/360, 720/720 OR 720/1.44
 18652                              <1> 	test	bh, DBL_STEP		; CHECK FOR DOUBLE STEP
 18653                              <1> 	jnz	short TST_DET		; MUST BE 360 IN 1.2
 18654                              <1> UNKNO:
 18655                              <1> 	mov	al, MED_UNK		; NONE OF THE ABOVE
 18656                              <1> 	jmp	short AL_SET		; PROCESS COMPLETE
 18657                              <1> CHK_144:
 18658                              <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
 18659                              <1> 	;;20/02/2015
 18660                              <1> 	;;jc	short UNKNO		; ERROR, SET 'NONE OF ABOVE'
 18661                              <1> 	jz	short UNKNO ;; 20/02/2015
 18662                              <1> 	cmp	al, 2			; 1.2MB DRIVE ?
 18663                              <1> 	jne	short UNKNO		; NO, GO SET 'NONE OF ABOVE'
 18664                              <1> 	mov	al, M1D1U		; AL = 1.2 IN 1.2 UNESTABLISHED
 18665                              <1> 	jmp	short TST_DET
 18666                              <1> CHK_250:
 18667                              <1> 	mov	al, M3D3U		; AL = 360 IN 360 UNESTABLISHED
 18668                              <1> 	cmp	ah, RATE_250		; RATE 250 ?
 18669                              <1> 	jnz	short UNKNO		; IF SO FALL IHRU
 18670                              <1> 	test	bh, TRK_CAPA		; 80 TRACK CAPABILITY ?
 18671                              <1> 	jnz	short UNKNO		; IF SO JUMP, FALL THRU TEST DET
 18672                              <1> TST_DET:
 18673                              <1> 	test	bh, MED_DET		; DETERMINED ?
 18674                              <1> 	jz	short AL_SET		; IF NOT THEN SET
 18675                              <1> 	add	al, 3			; MAKE DETERMINED/ESTABLISHED
 18676                              <1> AL_SET:
 18677                              <1> 	and	byte [DSK_STATE+edi], ~(DRV_DET+FMT_CAPA+TRK_CAPA) ; CLEAR DRIVE
 18678                              <1> 	or	[DSK_STATE+edi], al	; REPLACE WITH COMPATIBLE MODE
 18679                              <1> XO_OUT:
 18680                              <1> 	retn
 18681                              <1> 
 18682                              <1> %endif
 18683                              <1> 
 18684                              <1> ;-------------------------------------------------------------------------------
 18685                              <1> ; SETUP_STATE:	INITIALIZES START AND END RATES.
 18686                              <1> ;-------------------------------------------------------------------------------
 18687                              <1> SETUP_STATE:
 18688 00004743 F687[13780100]10    <1> 	test	byte [DSK_STATE+edi], MED_DET ; MEDIA DETERMINED ?
 18689 0000474A 7537                <1> 	jnz	short J1C		; NO STATES IF DETERMINED
 18690 0000474C 66B84000            <1>         mov     ax, (RATE_500*256)+RATE_300 ; AH = START RATE, AL = END RATE
 18691 00004750 F687[13780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE ?
 18692 00004757 740D                <1> 	jz	short AX_SET		; DO NOT KNOW DRIVE
 18693 00004759 F687[13780100]02    <1> 	test	byte [DSK_STATE+edi], FMT_CAPA ; MULTI-RATE?
 18694 00004760 7504                <1> 	jnz	short AX_SET		; JUMP IF YES
 18695 00004762 66B88080            <1>         mov     ax, RATE_250*257	; START A END RATE 250 FOR 360 DRIVE
 18696                              <1> AX_SET:	
 18697 00004766 80A7[13780100]1F    <1> 	and	byte [DSK_STATE+edi], ~(RATE_MSK+DBL_STEP) ; TURN OFF THE RATE
 18698 0000476D 08A7[13780100]      <1> 	or	[DSK_STATE+edi], ah	; RATE FIRST TO TRY
 18699 00004773 8025[10780100]F3    <1> 	and	byte [LASTRATE], ~STRT_MSK ; ERASE LAST TO TRY RATE BITS
 18700 0000477A C0C804              <1> 	ror	al, 4			; TO OPERATION LAST RATE LOCATION
 18701 0000477D 0805[10780100]      <1> 	or	[LASTRATE], al		; LAST RATE
 18702                              <1> J1C:	
 18703 00004783 C3                  <1> 	retn
 18704                              <1> 
 18705                              <1> ;-------------------------------------------------------------------------------
 18706                              <1> ;  FMT_INIT: ESTABLISH STATE IF UNESTABLISHED AT FORMAT TIME.
 18707                              <1> ;-------------------------------------------------------------------------------
 18708                              <1> FMT_INIT:
 18709 00004784 F687[13780100]10    <1> 	test	byte [DSK_STATE+edi], MED_DET ; IS MEDIA ESTABLISHED
 18710 0000478B 7546                <1> 	jnz	short F1_OUT		; IF SO RETURN
 18711 0000478D E8A3030000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
 18712                              <1> 	;; 20/02/2015
 18713                              <1> 	;;jc	short CL_DRV		; ERROR IN CMOS ASSUME NO DRIVE
 18714 00004792 7440                <1> 	jz	short CL_DRV ;; 20/02/2015
 18715 00004794 FEC8                <1> 	dec	al			; MAKE ZERO ORIGIN
 18716                              <1> 	;;JS	short CL_DRV		; NO DRIVE IF AL 0
 18717 00004796 8AA7[13780100]      <1> 	mov	ah, [DSK_STATE+edi]	; AH = CURRENT STATE
 18718 0000479C 80E40F              <1> 	and	ah, ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR
 18719 0000479F 08C0                <1> 	or	al, al			; CHECK FOR 360
 18720 000047A1 7505                <1> 	jnz	short N_360		; IF 360 WILL BE 0
 18721 000047A3 80CC90              <1> 	or	ah, MED_DET+RATE_250	; ESTABLISH MEDIA
 18722 000047A6 EB25                <1> 	jmp	short SKP_STATE		; SKIP OTHER STATE PROCESSING
 18723                              <1> N_360:	
 18724 000047A8 FEC8                <1> 	dec	al			; 1.2 M DRIVE
 18725 000047AA 7505                <1> 	jnz	short N_12		; JUMP IF NOT
 18726                              <1> F1_RATE:
 18727 000047AC 80CC10              <1> 	or	ah, MED_DET+RATE_500	; SET FORMAT RATE
 18728 000047AF EB1C                <1> 	jmp	short SKP_STATE		; SKIP OTHER STATE PROCESSING
 18729                              <1> N_12:	
 18730 000047B1 FEC8                <1> 	dec	al			; CHECK FOR TYPE 3
 18731 000047B3 750F                <1> 	jnz	short N_720		; JUMP IF NOT
 18732 000047B5 F6C404              <1> 	test	ah, DRV_DET		; IS DRIVE DETERMINED
 18733 000047B8 7410                <1> 	jz	short ISNT_12		; TREAT AS NON 1.2 DRIVE
 18734 000047BA F6C402              <1> 	test	ah, FMT_CAPA		; IS 1.2M
 18735 000047BD 740B                <1> 	jz	short ISNT_12		; JUMP IF NOT
 18736 000047BF 80CC50              <1> 	or	ah, MED_DET+RATE_300	; RATE 300
 18737 000047C2 EB09                <1> 	jmp	short SKP_STATE		; CONTINUE
 18738                              <1> N_720:
 18739 000047C4 FEC8                <1> 	dec	al			; CHECK FOR TYPE 4
 18740 000047C6 750C                <1> 	jnz	short CL_DRV		; NO DRIVE, CMOS BAD
 18741 000047C8 EBE2                <1> 	jmp	SHORT F1_RATE
 18742                              <1> ISNT_12: 
 18743 000047CA 80CC90              <1> 	or	ah, MED_DET+RATE_250	; MUST BE RATE 250
 18744                              <1> SKP_STATE:
 18745 000047CD 88A7[13780100]      <1> 	mov	[DSK_STATE+edi], ah	; STORE AWAY
 18746                              <1> F1_OUT:
 18747 000047D3 C3                  <1> 	retn
 18748                              <1> CL_DRV:	
 18749 000047D4 30E4                <1> 	xor	ah, ah			; CLEAR STATE
 18750 000047D6 EBF5                <1> 	jmp	short SKP_STATE		; SAVE IT
 18751                              <1> 
 18752                              <1> ;-------------------------------------------------------------------------------
 18753                              <1> ; MED_CHANGE	
 18754                              <1> ;	CHECKS FOR MEDIA CHANGE, RESETS MEDIA CHANGE, 
 18755                              <1> ;	CHECKS MEDIA CHANGE AGAIN.
 18756                              <1> ;
 18757                              <1> ; ON EXIT:	CY = 1 MEANS MEDIA CHANGE OR TIMEOUT
 18758                              <1> ;		@DSKETTE_STATUS = ERROR CODE
 18759                              <1> ;-------------------------------------------------------------------------------
 18760                              <1> MED_CHANGE:
 18761                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 18762 000047D8 E8E8050000          <1> 	call	READ_DSKCHNG		; READ DISK CHANCE LINE STATE
 18763 000047DD 7445                <1> 	jz	short MC_OUT		; BYPASS HANDLING DISK CHANGE LINE
 18764 000047DF 80A7[13780100]EF    <1> 	and	byte [DSK_STATE+edi], ~MED_DET ; CLEAR STATE FOR THIS DRIVE
 18765                              <1> 
 18766                              <1> ;	THIS SEQUENCE ENSURES WHENEVER A DISKETTE IS CHANGED THAT
 18767                              <1> ;	ON THE NEXT OPERATION THE REQUIRED MOTOR START UP TIME WILL
 18768                              <1> ;	BE WAITED. (DRIVE MOTOR MAY GO OFF UPON DOOR OPENING).
 18769                              <1> 
 18770                              <1> 	;mov	cx, di			; CL = DRIVE 0
 18771                              <1> 	; 06/08/2022
 18772 000047E6 89F9                <1> 	mov	ecx, edi
 18773 000047E8 B001                <1> 	mov	al, 1			; MOTOR ON BIT MASK
 18774 000047EA D2E0                <1> 	shl	al, cl			; TO APPROPRIATE POSITION
 18775 000047EC F6D0                <1> 	not	al			; KEEP ALL BUT MOTOR ON
 18776 000047EE FA                  <1> 	cli				; NO INTERRUPTS
 18777 000047EF 2005[06780100]      <1> 	and	[MOTOR_STATUS], al	; TURN MOTOR OFF INDICATOR
 18778 000047F5 FB                  <1> 	sti				; INTERRUPTS ENABLED
 18779 000047F6 E87E030000          <1> 	call	MOTOR_ON		; TURN MOTOR ON
 18780                              <1> 
 18781                              <1> ;-----	THIS SEQUENCE OF SEEKS IS USED TO RESET DISKETTE CHANGE SIGNAL
 18782                              <1> 
 18783 000047FB E83BFAFFFF          <1> 	call	DSK_RESET		; RESET NEC
 18784 00004800 B501                <1> 	mov	ch, 1			; MOVE TO CYLINDER 1
 18785 00004802 E864040000          <1> 	call	SEEK			; ISSUE SEEK
 18786 00004807 30ED                <1> 	xor	ch, ch			; MOVE TO CYLINDER 0
 18787 00004809 E85D040000          <1> 	call	SEEK			; ISSUE SEEK
 18788 0000480E C605[08780100]06    <1> 	mov	byte [DSKETTE_STATUS], MEDIA_CHANGE ; STORE IN STATUS
 18789                              <1> OK1:
 18790 00004815 E8AB050000          <1> 	call	READ_DSKCHNG		; CHECK MEDIA CHANGED AGAIN
 18791 0000481A 7407                <1> 	jz	short OK2		; IF ACTIVE, NO DISKETTE, TIMEOUT
 18792                              <1> OK4:
 18793 0000481C C605[08780100]80    <1> 	mov	byte [DSKETTE_STATUS], TIME_OUT ; TIMEOUT IF DRIVE EMPTY
 18794                              <1> OK2:		
 18795 00004823 F9                  <1> 	stc				; MEDIA CHANGED, SET CY
 18796                              <1> MC_OUT:	; 06/08/2022 (cf = 0)
 18797 00004824 C3                  <1> 	retn
 18798                              <1> ;MC_OUT:
 18799                              <1> 	;clc				; NO MEDIA CHANGED, CLEAR CY
 18800                              <1> 	;retn
 18801                              <1> 
 18802                              <1> ;-------------------------------------------------------------------------------
 18803                              <1> ; SEND_RATE
 18804                              <1> ;	SENDS DATA RATE COMMAND TO NEC
 18805                              <1> ; ON ENTRY:	DI = DRIVE #
 18806                              <1> ; ON EXIT:	NONE
 18807                              <1> ; REGISTERS ALTERED: DX
 18808                              <1> ;-------------------------------------------------------------------------------
 18809                              <1> SEND_RATE:
 18810                              <1> 	;push	ax			; SAVE REG.
 18811                              <1> 	; 11/04/2021
 18812 00004825 50                  <1> 	push	eax
 18813 00004826 8025[10780100]3F    <1> 	and	byte [LASTRATE], ~SEND_MSK ; ELSE CLEAR LAST RATE ATTEMPTED
 18814 0000482D 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
 18815 00004833 24C0                <1> 	and	al, SEND_MSK		; KEEP ONLY RATE BITS
 18816 00004835 0805[10780100]      <1> 	or	[LASTRATE], al		; SAVE NEW RATE FOR NEXT CHECK
 18817 0000483B C0C002              <1> 	rol	al, 2			; MOVE TO BIT OUTPUT POSITIONS
 18818 0000483E 66BAF703            <1> 	mov	dx, 03F7h		; OUTPUT NEW DATA RATE
 18819 00004842 EE                  <1> 	out	dx, al
 18820                              <1> 	;pop	ax			; RESTORE REG.
 18821                              <1> 	; 11/04/2021
 18822 00004843 58                  <1> 	pop	eax
 18823 00004844 C3                  <1> 	retn
 18824                              <1> 
 18825                              <1> ;-------------------------------------------------------------------------------
 18826                              <1> ; CHK_LASTRATE
 18827                              <1> ;	CHECK PREVIOUS DATE RATE SNT TO THE CONTROLLER.
 18828                              <1> ; ON ENTRY:
 18829                              <1> ;	DI = DRIVE #
 18830                              <1> ; ON EXIT:
 18831                              <1> ;	ZF =  1 DATA RATE IS THE SAME AS THE LAST RATE SENT TO NEC
 18832                              <1> ;	ZF =  0 DATA RATE IS DIFFERENT FROM LAST RATE
 18833                              <1> ; REGISTERS ALTERED: DX
 18834                              <1> ;-------------------------------------------------------------------------------
 18835                              <1> CHK_LASTRATE:
 18836                              <1> 	; 13/07/2022 - TRDOS 386 v2.0.5
 18837                              <1> 	;push	ax			; SAVE REG.
 18838                              <1> 	; 11/04/2021
 18839 00004845 50                  <1> 	push	eax
 18840                              <1> 	; 13/07/2022 (BugFix)
 18841 00004846 8A25[10780100]      <1> 	mov	ah, [LASTRATE] 		; GET LAST DATA RATE SELECTED
 18842 0000484C 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
 18843 00004852 6625C0C0            <1>         and	ax, SEND_MSK*257        ; KEEP ONLY RATE BITS OF BOTH
 18844 00004856 38E0                <1> 	cmp	al, ah			; COMPARE TO PREVIOUSLY TRIED
 18845                              <1> 					; ZF = 1 RATE IS THE SAME
 18846                              <1> 	;pop	ax			; RESTORE REG.
 18847                              <1> 	; 11/04/2021
 18848 00004858 58                  <1> 	pop	eax
 18849 00004859 C3                  <1> 	retn
 18850                              <1> 
 18851                              <1> ;-------------------------------------------------------------------------------
 18852                              <1> ; DMA_SETUP
 18853                              <1> ;	THIS ROUTINE SETS UP THE DMA FOR READ/WRITE/VERIFY OPERATIONS.
 18854                              <1> ;
 18855                              <1> ; ON ENTRY:	AL = DMA COMMAND
 18856                              <1> ;
 18857                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 18858                              <1> ;-------------------------------------------------------------------------------
 18859                              <1> 
 18860                              <1> ; SI = Head #, # of Sectors or DASD Type
 18861                              <1> 
 18862                              <1> ; 22/08/2015
 18863                              <1> ; 08/02/2015 - Protected Mode Modification
 18864                              <1> ; 06/02/2015 - 07/02/2015
 18865                              <1> ; NOTE: Buffer address must be in 1st 16MB of Physical Memory (24 bit limit).
 18866                              <1> ; (DMA Addres = Physical Address)
 18867                              <1> ; (Retro UNIX 386 v1 Kernel/System Mode Virtual Address = Physical Address)
 18868                              <1> ;
 18869                              <1> ; 09/08/2022
 18870                              <1> ; 06/08/2022
 18871                              <1> ; 04/02/2016 (clc)
 18872                              <1> ; 20/02/2015 modification (source: AWARD BIOS 1999, DMA_SETUP)
 18873                              <1> ; 16/12/2014 (IODELAY)
 18874                              <1> 
 18875                              <1> DMA_SETUP:
 18876                              <1> 	; 09/08/2022
 18877                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 18878                              <1> 	;; 20/02/2015
 18879                              <1> 	;;mov	edx, [ebp+4] 		; Buffer address
 18880                              <1> 	; 06/08/2022
 18881                              <1> 	;mov	edx, ebp ; buffer address
 18882                              <1> 	;test	edx, 0FF000000h		; 16 MB limit (22/08/2015, bugfix)
 18883 0000485A F7C5000000FF        <1> 	test	ebp, 0FF000000h
 18884 00004860 7566                <1> 	jnz	short dma_bnd_err_stc
 18885                              <1> 	; 09/08/2022
 18886 00004862 89EA                <1> 	mov	edx, ebp
 18887                              <1> 	;
 18888                              <1> 	;;push	ax			; DMA command
 18889                              <1> 	; 11/04/2021
 18890 00004864 50                  <1> 	push	eax
 18891                              <1> 	; 06/08/2022
 18892                              <1> 	;push	edx			; *
 18893                              <1> 	;mov	dl, 3			; GET BYTES/SECTOR PARAMETER
 18894                              <1> 	; 06/08/2022
 18895 00004865 B003                <1> 	mov	al, 3			; GET BYTES/SECTOR PARAMETER
 18896 00004867 E8D2020000          <1> 	call	GET_PARM		; 
 18897 0000486C 88E1                <1> 	mov	cl, ah 			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
 18898                              <1> 	;mov	ax, si			; Sector count
 18899                              <1> 	; 06/08/2022
 18900 0000486E 89F0                <1> 	mov	eax, esi
 18901 00004870 88C4                <1> 	mov	ah, al			; AH = # OF SECTORS
 18902 00004872 28C0                <1> 	sub	al, al			; AL = 0, AX = # SECTORS * 256
 18903                              <1> 	;shr	ax, 1			; AX = # SECTORS * 128
 18904                              <1> 	; 06/08/2022
 18905 00004874 D1E8                <1> 	shr	eax, 1
 18906                              <1> 	;shl	ax, cl			; SHIFT BY PARAMETER VALUE
 18907                              <1> 	;dec	ax			; -1 FOR DMA VALUE
 18908                              <1> 	;mov	cx, ax
 18909 00004876 D3E0                <1> 	shl	eax, cl
 18910 00004878 48                  <1> 	dec	eax
 18911 00004879 89C1                <1> 	mov	ecx, eax
 18912                              <1> 	; 06/08/2022
 18913                              <1> 	;pop	edx			; *
 18914                              <1> 	;;pop	ax
 18915                              <1> 	; 11/04/2021
 18916 0000487B 58                  <1> 	pop	eax
 18917 0000487C 3C42                <1> 	cmp	al, 42h
 18918 0000487E 7507                <1>         jne     short NOT_VERF
 18919                              <1> 	; 09/08/2022
 18920 00004880 BA0000FF00          <1> 	mov	edx, 0FF0000h
 18921                              <1> 	; 06/08/2022
 18922                              <1> 	;mov	ebp, 0FF0000h
 18923 00004885 EB08                <1> 	jmp	short J33
 18924                              <1> NOT_VERF:
 18925 00004887 6601CA              <1> 	add	dx, cx			; check for overflow
 18926 0000488A 723D                <1> 	jc	short dma_bnd_err
 18927                              <1> 	;
 18928 0000488C 6629CA              <1> 	sub	dx, cx			; Restore start address
 18929                              <1> J33:
 18930 0000488F FA                  <1> 	cli				; DISABLE INTERRUPTS DURING DMA SET-UP
 18931 00004890 E60C                <1> 	out	DMA+12, al		; SET THE FIRST/LA5T F/F
 18932                              <1> 	IODELAY				; WAIT FOR I/O
 18933 00004892 EB00                <2>  jmp short $+2
 18934 00004894 EB00                <2>  jmp short $+2
 18935 00004896 E60B                <1> 	out	DMA+11, al		; OUTPUT THE MODE BYTE
 18936                              <1> 	;mov	eax, edx		; Buffer address
 18937                              <1> 	; 06/08/2022
 18938                              <1> 	;mov	eax, ebp
 18939                              <1> 	; 09/08/2022
 18940 00004898 89D0                <1> 	mov	eax, edx
 18941 0000489A E604                <1> 	out	DMA+4, al		; OUTPUT LOW ADDRESS
 18942                              <1> 	IODELAY				; WAIT FOR I/O
 18943 0000489C EB00                <2>  jmp short $+2
 18944 0000489E EB00                <2>  jmp short $+2
 18945 000048A0 88E0                <1> 	mov	al, ah
 18946 000048A2 E604                <1> 	out	DMA+4, al		; OUTPUT HIGH ADDRESS
 18947 000048A4 C1E810              <1> 	shr	eax, 16
 18948                              <1> 	IODELAY				; I/O WAIT STATE
 18949 000048A7 EB00                <2>  jmp short $+2
 18950 000048A9 EB00                <2>  jmp short $+2
 18951 000048AB E681                <1> 	out	081h, al		; OUTPUT HIGHEST BITS TO PAGE REGISTER
 18952                              <1> 	IODELAY
 18953 000048AD EB00                <2>  jmp short $+2
 18954 000048AF EB00                <2>  jmp short $+2
 18955                              <1> 	;mov	ax, cx			; Byte count - 1
 18956                              <1> 	; 06/08/2022
 18957 000048B1 89C8                <1> 	mov	eax, ecx
 18958 000048B3 E605                <1> 	out	DMA+5, al		; LOW BYTE OF COUNT
 18959                              <1> 	IODELAY				; WAIT FOR I/O
 18960 000048B5 EB00                <2>  jmp short $+2
 18961 000048B7 EB00                <2>  jmp short $+2
 18962 000048B9 88E0                <1> 	mov	al, ah
 18963 000048BB E605                <1> 	out	DMA+5, al		; HIGH BYTE OF COUNT
 18964                              <1> 	IODELAY
 18965 000048BD EB00                <2>  jmp short $+2
 18966 000048BF EB00                <2>  jmp short $+2
 18967 000048C1 FB                  <1> 	sti				; RE-ENABLE INTERRUPTS
 18968 000048C2 B002                <1> 	mov	al, 2			; MODE FOR 8237
 18969 000048C4 E60A                <1> 	out	DMA+10, al		; INITIALIZE THE DISKETTE CHANNEL
 18970                              <1> 
 18971 000048C6 F8                  <1> 	clc	; 04/02/2016
 18972 000048C7 C3                  <1> 	retn
 18973                              <1> 
 18974                              <1> dma_bnd_err_stc:
 18975 000048C8 F9                  <1> 	stc
 18976                              <1> dma_bnd_err:
 18977 000048C9 C605[08780100]09    <1> 	mov	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
 18978 000048D0 C3                  <1> 	retn				; CY SET BY ABOVE IF ERROR
 18979                              <1> 
 18980                              <1> ;; 16/12/2014
 18981                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
 18982                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
 18983                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 18984                              <1> ;;	IODELAY
 18985                              <1> ;; 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
 18986                              <1> ;;	;SIODELAY
 18987                              <1> ;;      ;cmp	AL,42H			; DMA VERIFY COMMAND
 18988                              <1> ;;      ;JNE	short NOT_VERF		; NO
 18989                              <1> ;;      ;xor	AX,AX			; START ADDRESS
 18990                              <1> ;;      ;jmp	SHORT J33
 18991                              <1> ;;;NOT_VERF:	
 18992                              <1> ;;	;mov	AX,ES			; GET THE ES VALUE
 18993                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
 18994                              <1> ;;	;mov	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
 18995                              <1> ;;	;and	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
 18996                              <1> ;;	;add	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
 18997                              <1> ;;	mov	eax,[ebp+4] ; 06/02/2015	
 18998                              <1> ;;	;jnc	short J33
 18999                              <1> ;;	;inc	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
 19000                              <1> ;;;J33:
 19001                              <1> ;;	push	eax			; SAVE START ADDRESS
 19002                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
 19003                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19004                              <1> ;;	IODELAY
 19005                              <1> ;;	mov	AL,AH
 19006                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
 19007                              <1> ;;	shr	eax, 16	     ; 07/02/2015
 19008                              <1> ;;	;mov	AL,CH			; GET HIGH 4 BITS
 19009                              <1> ;;	;jmp	$+2			; I/O WAIT STATE
 19010                              <1> ;;	IODELAY
 19011                              <1> ;;	;and	AL,00001111B
 19012                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
 19013                              <1> ;;	;SIODELAY
 19014                              <1> ;;
 19015                              <1> ;;;----- DETERMINE COUNT
 19016                              <1> ;;	sub	eax, eax ; 08/02/2015
 19017                              <1> ;;	mov	AX,SI			; AL =  # OF SECTORS
 19018                              <1> ;;	xchg	AL,AH			; AH =  # OF SECTORS
 19019                              <1> ;;	sub	AL,AL			; AL = 0, AX = # SECTORS * 256
 19020                              <1> ;;	SHR	AX,1			; AX = # SECTORS * 128
 19021                              <1> ;;	push	AX			; SAVE # OF SECTORS * 128
 19022                              <1> ;;	mov	DL,3			; GET BYTES/SECTOR PARAMETER
 19023                              <1> ;;	call	GET_PARM		; "
 19024                              <1> ;;	mov	CL,AH			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
 19025                              <1> ;;	pop	AX			; AX = # SECTORS * 128
 19026                              <1> ;;	SHL	AX,CL			; SHIFT BY PARAMETER VALUE
 19027                              <1> ;;	dec	AX			; -1 FOR DMA VALUE
 19028                              <1> ;;	push	eax  ; 08/02/2015	; SAVE COUNT VALUE
 19029                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
 19030                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19031                              <1> ;;	IODELAY
 19032                              <1> ;;	mov	AL,AH
 19033                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
 19034                              <1> ;;	;IODELAY
 19035                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
 19036                              <1> ;;	pop	ecx  ; 08/02/2015 	; RECOVER COUNT VALUE
 19037                              <1> ;;	pop	eax  ; 08/02/2015	; RECOVER ADDRESS VALUE
 19038                              <1> ;;	;add	AX, CX			; ADD, TEST FOR 64K OVERFLOW
 19039                              <1> ;;	add	ecx,eax ; 08/02/2015
 19040                              <1> ;;	mov	AL, 2			; MODE FOR 8237
 19041                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19042                              <1> ;;	SIODELAY
 19043                              <1> ;;	OUT	DMA+10,AL		; INITIALIZE THE DISKETTE CHANNEL
 19044                              <1> ;;	;jnc	short NO_BAD		; CHECK FOR ERROR
 19045                              <1> ;;	jc	short dma_bnd_err ; 08/02/2015
 19046                              <1> ;;	and	ecx,0FFF00000h	; 16 MB limit
 19047                              <1> ;;	jz	short NO_BAD
 19048                              <1> ;;dma_bnd_err:
 19049                              <1> ;;	mov	byte [DSKETTE_STATUS],DMA_BOUNDARY ; SET ERROR
 19050                              <1> ;;NO_BAD:
 19051                              <1> ;;	retn				; CY SET BY ABOVE IF ERROR
 19052                              <1> 
 19053                              <1> ;-------------------------------------------------------------------------------
 19054                              <1> ; FMTDMA_SET
 19055                              <1> ;	THIS ROUTINE SETS UP THE DMA CONTROLLER FOR A FORMAT OPERATION.
 19056                              <1> ;
 19057                              <1> ; ON ENTRY:	NOTHING REQUIRED
 19058                              <1> ;
 19059                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 19060                              <1> ;-------------------------------------------------------------------------------
 19061                              <1> 
 19062                              <1> FMTDMA_SET:
 19063                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19064                              <1> 	;; 20/02/2015 modification	
 19065                              <1> 	;;mov	edx, [ebp+4] 		; Buffer address
 19066                              <1> 	; 06/08/2022
 19067                              <1> 	;mov	edx, ebp ; buffer address
 19068                              <1> 	; 06/08/2022
 19069                              <1> 	;test	edx, 0FF000000h		; 16 MB limit
 19070 000048D1 F7C5000000FF        <1> 	test	ebp, 0FF000000h
 19071 000048D7 75EF                <1> 	jnz	short dma_bnd_err_stc
 19072                              <1> 	;
 19073                              <1> 	;;push	dx			; *
 19074                              <1> 	;; 11/04/2021
 19075                              <1> 	; 06/08/2022
 19076                              <1> 	;push	edx
 19077                              <1> 	;mov	dl, 4			; SECTORS/TRACK VALUE IN PARM TABLE
 19078                              <1> 	; 06/08/2022
 19079 000048D9 B004                <1> 	mov	al, 4			; SECTORS/TRACK VALUE IN PARM TABLE				
 19080 000048DB E85E020000          <1> 	call	GET_PARM		; "
 19081 000048E0 88E0                <1> 	mov	al, ah			; AL = SECTORS/TRACK VALUE
 19082 000048E2 28E4                <1> 	sub	ah, ah			; AX = SECTORS/TRACK VALUE
 19083                              <1> 	;shl	ax, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
 19084                              <1> 	; 06/08/2022
 19085 000048E4 C1E002              <1> 	shl	eax, 2
 19086                              <1> 	;dec	ax			; -1 FOR DMA VALUE
 19087 000048E7 48                  <1> 	dec	eax
 19088                              <1> 	;mov	cx, ax
 19089 000048E8 89C1                <1> 	mov	ecx, eax
 19090                              <1> 	;;pop	dx			; *
 19091                              <1> 	;; 11/04/2021
 19092                              <1> 	; 06/08/2022
 19093                              <1> 	;pop	edx
 19094                              <1> 	; 06/08/2022
 19095 000048EA B04A                <1> 	mov	al, 04Ah
 19096                              <1> 	;
 19097 000048EC EB99                <1> 	jmp	short NOT_VERF ; 06/08/2022	
 19098                              <1> 
 19099                              <1> ;; 06/08/2022	
 19100                              <1> ;	add	dx, cx			; check for overflow
 19101                              <1> ;	jc	short dma_bnd_err
 19102                              <1> ;	;
 19103                              <1> ;	sub	dx, cx			; Restore start address
 19104                              <1> ;	;
 19105                              <1> ;	;mov	al, 04Ah		; WILL WRITE TO THE DISKETTE
 19106                              <1> ;	cli				; DISABLE INTERRUPTS DURING DMA SET-UP
 19107                              <1> ;	out	DMA+12, al		; SET THE FIRST/LA5T F/F
 19108                              <1> ;	IODELAY				; WAIT FOR I/O
 19109                              <1> ;	out	DMA+11, al		; OUTPUT THE MODE BYTE
 19110                              <1> ;	mov	eax, edx		; Buffer address
 19111                              <1> ;	out	DMA+4, al		; OUTPUT LOW ADDRESS
 19112                              <1> ;	IODELAY				; WAIT FOR I/O
 19113                              <1> ;	mov	al, ah
 19114                              <1> ;	out	DMA+4, al		; OUTPUT HIGH ADDRESS
 19115                              <1> ;	shr	eax, 16
 19116                              <1> ;	IODELAY				; I/O WAIT STATE
 19117                              <1> ;	out	081h, al		; OUTPUT HIGHEST BITS TO PAGE REGISTER
 19118                              <1> ;	IODELAY
 19119                              <1> ;	;mov	ax, cx			; Byte count - 1
 19120                              <1> ;	; 06/08/2022
 19121                              <1> ;	mov	eax, ecx
 19122                              <1> ;	out	DMA+5, al		; LOW BYTE OF COUNT
 19123                              <1> ;	IODELAY				; WAIT FOR I/O
 19124                              <1> ;	mov	al, ah
 19125                              <1> ;	out	DMA+5, al		; HIGH BYTE OF COUNT
 19126                              <1> ;	IODELAY
 19127                              <1> ;	sti				; RE-ENABLE INTERRUPTS
 19128                              <1> ;	mov	al, 2			; MODE FOR 8237
 19129                              <1> ;	out	DMA+10, al		; INITIALIZE THE DISKETTE CHANNEL
 19130                              <1> ;
 19131                              <1> ;	; 06/08/2022
 19132                              <1> ;	clc
 19133                              <1> ;	retn
 19134                              <1> 
 19135                              <1> ;; 08/02/2015 - Protected Mode Modification
 19136                              <1> ;;	mov	AL,04AH			; WILL WRITE TO THE DISKETTE
 19137                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
 19138                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
 19139                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19140                              <1> ;;	IODELAY
 19141                              <1> ;;	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
 19142                              <1> ;;	;mov	AX,ES			; GET THE ES VALUE
 19143                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
 19144                              <1> ;;	;mov	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
 19145                              <1> ;;	;and	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
 19146                              <1> ;;	;add	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
 19147                              <1> ;;	;jnc	short J33A
 19148                              <1> ;;	;inc	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
 19149                              <1> ;;	mov	eax,[ebp+4] ; 08/02/2015
 19150                              <1> ;;;J33A:
 19151                              <1> ;;	push	eax ; 08/02/2015	; SAVE START ADDRESS
 19152                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
 19153                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19154                              <1> ;;	IODELAY
 19155                              <1> ;;	mov	AL,AH
 19156                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
 19157                              <1> ;;	shr 	eax,16 ; 08/02/2015
 19158                              <1> ;;	;mov	AL,CH			; GET HIGH 4 BITS
 19159                              <1> ;;	;jmp	$+2			; I/O WAIT STATE
 19160                              <1> ;;	IODELAY
 19161                              <1> ;;	;and	AL,00001111B
 19162                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
 19163                              <1> ;;
 19164                              <1> ;;;----- DETERMINE COUNT
 19165                              <1> ;;	sub	eax,eax ; 08/02/2015
 19166                              <1> ;;	mov	DL,4			; SECTORS/TRACK VALUE IN PARM TABLE
 19167                              <1> ;;	call	GET_PARM		; "
 19168                              <1> ;;	xchg	AL,AH			; AL = SECTORS/TRACK VALUE
 19169                              <1> ;;	sub	AH,AH			; AX = SECTORS/TRACK VALUE
 19170                              <1> ;;	SHL	AX,2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
 19171                              <1> ;;	dec	AX			; -1 FOR DMA VALUE
 19172                              <1> ;;	push	eax 	; 08/02/2015	; SAVE # OF BYTES TO BE TRANSFERED
 19173                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
 19174                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19175                              <1> ;;	IODELAY
 19176                              <1> ;;	mov	AL,AH
 19177                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
 19178                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
 19179                              <1> ;;	pop	ecx	; 08/02/2015	; RECOVER COUNT VALUE
 19180                              <1> ;;	pop	eax	; 08/02/2015	; RECOVER ADDRESS VALUE
 19181                              <1> ;;	;add	AX,CX			; ADD, TEST FOR 64K OVERFLOW
 19182                              <1> ;;	add	ecx,eax ; 08/02/2015
 19183                              <1> ;;	mov	AL,2			; MODE FOR 8237
 19184                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
 19185                              <1> ;;	SIODELAY
 19186                              <1> ;;	OUT	DMA+10,AL		; INITIALIZE THE DISKETTE CHANNEL
 19187                              <1> ;;	;jnc	short FMTDMA_OK		; CHECK FOR ERROR
 19188                              <1> ;;	jc	short fmtdma_bnd_err ; 08/02/2015
 19189                              <1> ;;	and	ecx,0FFF00000h	; 16 MB limit
 19190                              <1> ;;	jz	short FMTDMA_OK
 19191                              <1> ;;	stc	; 20/02/2015
 19192                              <1> ;;fmtdma_bnd_err:
 19193                              <1> ;;	mov	byte [DSKETTE_STATUS],DMA_BOUNDARY ; SET ERROR
 19194                              <1> ;;FMTDMA_OK:
 19195                              <1> ;;	retn				; CY SET BY ABOVE IF ERROR
 19196                              <1> 
 19197                              <1> ;-------------------------------------------------------------------------------
 19198                              <1> ; NEC_INIT	
 19199                              <1> ;	THIS ROUTINE SEEKS TO THE REQUESTED TRACK AND INITIALIZES
 19200                              <1> ;	THE NEC FOR THE READ/WRITE/VERIFY/FORMAT OPERATION.
 19201                              <1> ;
 19202                              <1> ; ON ENTRY:	AH = NEC COMMAND TO BE PERFORMED
 19203                              <1> ;
 19204                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 19205                              <1> ;-------------------------------------------------------------------------------
 19206                              <1> NEC_INIT:
 19207                              <1> 	; 11/08/2022
 19208                              <1> 	; EBX = user's ECX register content (on stack)
 19209                              <1> 	; 10/08/2022
 19210                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19211                              <1> 	;push	ax			; SAVE NEC COMMAND
 19212                              <1> 	; 11/04/2021
 19213 000048EE 50                  <1> 	push	eax
 19214 000048EF E885020000          <1> 	call	MOTOR_ON		; TURN MOTOR ON FOR SPECIFIC DRIVE
 19215                              <1> 
 19216                              <1> ;-----	DO THE SEEK OPERATION
 19217                              <1> 
 19218                              <1> 	;mov	ch, [ebp+1]		; CH = TRACK #
 19219                              <1> 	; 10/08/2022
 19220 000048F4 88FD                <1> 	mov	ch, bh ; CH = TRACK #
 19221 000048F6 E870030000          <1> 	call	SEEK			; MOVE TO CORRECT TRACK
 19222                              <1> 	;pop	ax			; RECOVER COMMAND
 19223                              <1> 	; 11/04/2021
 19224 000048FB 58                  <1> 	pop	eax
 19225 000048FC 721D                <1> 	jc	short ER_1		; ERROR ON SEEK
 19226 000048FE BB[1B490000]        <1> 	mov	ebx, ER_1		; LOAD ERROR ADDRESS
 19227 00004903 53                  <1> 	push	ebx			; PUSH NEC_OUT ERROR RETURN
 19228                              <1> 
 19229                              <1> ;-----	SEND OUT THE PARAMETERS TO THE CONTROLLER
 19230                              <1> 
 19231 00004904 E82B030000          <1> 	call	NEC_OUTPUT		; OUTPUT THE OPERATION COMMAND
 19232                              <1> 	;mov	ax, si			; AH = HEAD #
 19233                              <1> 	; 06/08/2022
 19234 00004909 89F0                <1> 	mov	eax, esi
 19235 0000490B 89FB                <1> 	mov	ebx, edi		; BL = DRIVE #
 19236 0000490D C0E402              <1> 	sal	ah, 2			; MOVE IT TO BIT 2
 19237 00004910 80E404              <1> 	and	ah, 00000100b		; ISOLATE THAT BIT
 19238 00004913 08DC                <1> 	or	ah, bl			; OR IN THE DRIVE NUMBER
 19239 00004915 E81A030000          <1> 	call	NEC_OUTPUT		; FALL THRU CY SET IF ERROR
 19240 0000491A 5B                  <1> 	pop	ebx			; THROW AWAY ERROR RETURN
 19241                              <1> ER_1:
 19242 0000491B C3                  <1> 	retn
 19243                              <1> 
 19244                              <1> ;-------------------------------------------------------------------------------
 19245                              <1> ; RWV_COM
 19246                              <1> ;	THIS ROUTINE SENDS PARAMETERS TO THE NEC SPECIFIC TO THE 
 19247                              <1> ;	READ/WRITE/VERIFY OPERATIONS.
 19248                              <1> ;
 19249                              <1> ; ON ENTRY:	CS:BX = ADDRESS OF MEDIA/DRIVE PARAMETER TABLE
 19250                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 19251                              <1> ;-------------------------------------------------------------------------------
 19252                              <1> RWV_COM:
 19253                              <1> 	; 11/08/2022
 19254                              <1> 	; 10/08/2022
 19255                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19256 0000491C B8[68490000]        <1> 	mov	eax, ER_2		; LOAD ERROR ADDRESS
 19257 00004921 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
 19258                              <1> 	;mov	ah, [ebp+1]		; OUTPUT TRACK #
 19259                              <1> 	; 11/08/2022
 19260 00004922 8A642425            <1> 	mov	ah, [esp+37] ; CH = OUTPUT TRACK #
 19261 00004926 E809030000          <1> 	call	NEC_OUTPUT
 19262                              <1> 	;mov	ax, si			; OUTPUT HEAD #
 19263                              <1> 	; 06/08/2022
 19264 0000492B 89F0                <1> 	mov	eax, esi
 19265 0000492D E802030000          <1> 	call	NEC_OUTPUT
 19266                              <1> 	;mov	ah, [ebp]		; OUTPUT SECTOR #
 19267                              <1> 	; 11/08/2022
 19268 00004932 8A642424            <1> 	mov	ah, [esp+36] ; CL = OUTPUT SECTOR #
 19269 00004936 E8F9020000          <1> 	call	NEC_OUTPUT
 19270                              <1> 	;mov	dl, 3			; BYTES/SECTOR PARAMETER FROM BLOCK
 19271                              <1> 	; 06/08/2022
 19272 0000493B B003                <1> 	mov	al, 3
 19273 0000493D E8FC010000          <1> 	call	GET_PARM 		; ... TO THE NEC
 19274 00004942 E8ED020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
 19275                              <1> 	;mov	dl, 4			; EOT PARAMETER FROM BLOCK
 19276                              <1> 	; 06/08/2022
 19277 00004947 B004                <1> 	mov	al, 4
 19278 00004949 E8F0010000          <1> 	call	GET_PARM 		; ... TO THE NEC
 19279 0000494E E8E1020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
 19280 00004953 8A6305              <1> 	mov	ah, [ebx+MD.GAP]        ; GET GAP LENGTH
 19281                              <1> _R15:
 19282 00004956 E8D9020000          <1> 	call	NEC_OUTPUT
 19283                              <1> 	;mov	dl, 6			; DTL PARAMETER PROM BLOCK
 19284                              <1> 	; 06/08/2022
 19285 0000495B B006                <1> 	mov	al, 6
 19286 0000495D E8DC010000          <1> 	call	GET_PARM		; ... TO THE NEC
 19287 00004962 E8CD020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
 19288 00004967 58                  <1> 	pop	eax			; THROW AWAY ERROR EXIT
 19289                              <1> ER_2:
 19290 00004968 C3                  <1> 	retn
 19291                              <1> 
 19292                              <1> ;-------------------------------------------------------------------------------
 19293                              <1> ; NEC_TERM
 19294                              <1> ;	THIS ROUTINE WAITS FOR THE OPERATION THEN ACCEPTS THE STATUS 
 19295                              <1> ;	FROM THE NEC FOR THE READ/WRITE/VERIFY/FORWAT OPERATION.
 19296                              <1> ;
 19297                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 19298                              <1> ;-------------------------------------------------------------------------------
 19299                              <1> NEC_TERM:
 19300                              <1> 
 19301                              <1> ;-----	LET THE OPERATION HAPPEN
 19302                              <1> 
 19303 00004969 56                  <1> 	push	esi			; SAVE HEAD #, # OF SECTORS
 19304 0000496A E8CD030000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
 19305 0000496F 9C                  <1> 	pushf
 19306 00004970 E8F6030000          <1> 	call	RESULTS			; GET THE NEC STATUS
 19307 00004975 724B                <1> 	jc	short SET_END_POP
 19308 00004977 9D                  <1> 	popf
 19309 00004978 723E                <1> 	jc	short SET_END		; LOOK FOR ERROR
 19310                              <1> 
 19311                              <1> ;-----	CHECK THE RESULTS RETURNED BY THE CONTROLLER
 19312                              <1> 
 19313 0000497A FC                  <1> 	cld				; SET THE CORRECT DIRECTION
 19314 0000497B BE[09780100]        <1> 	mov	esi, NEC_STATUS		; POINT TO STATUS FIELD
 19315 00004980 AC                  <1> 	lodsb				; GET ST0
 19316 00004981 24C0                <1> 	and	AL, 11000000B		; TEST FOR NORMAL TERMINATION
 19317 00004983 7433                <1> 	jz	short SET_END
 19318 00004985 3C40                <1> 	cmp	AL,01000000B		; TEST FOR ABNORMAL TERMINATION
 19319 00004987 7527                <1> 	jnz	short J18		; NOT ABNORMAL, BAD NEC
 19320                              <1> 
 19321                              <1> ;-----	ABNORMAL TERMINATION, FIND OUT WHY
 19322                              <1> 
 19323 00004989 AC                  <1> 	lodsb				; GET ST1
 19324 0000498A D0E0                <1> 	sal	al, 1			; TEST FOR EDT FOUND
 19325 0000498C B404                <1> 	mov	ah, RECORD_NOT_FND
 19326 0000498E 7222                <1> 	jc	short J19
 19327 00004990 C0E002              <1> 	sal	al, 2
 19328 00004993 B410                <1> 	mov	ah, BAD_CRC
 19329 00004995 721B                <1> 	jc	short J19
 19330 00004997 D0E0                <1> 	sal	al, 1			; TEST FOR DMA OVERRUN
 19331 00004999 B408                <1> 	mov	ah, BAD_DMA
 19332 0000499B 7215                <1> 	jc	short J19
 19333 0000499D C0E002              <1> 	sal	al, 2			; TEST FOR RECORD NOT FOUND
 19334 000049A0 B404                <1> 	mov	ah, RECORD_NOT_FND
 19335 000049A2 720E                <1> 	jc	short J19
 19336 000049A4 D0E0                <1> 	sal	al, 1
 19337 000049A6 B403                <1> 	mov	ah, WRITE_PROTECT	; TEST FOR WRITE_PROTECT
 19338 000049A8 7208                <1> 	jc	short J19
 19339 000049AA D0E0                <1> 	sal	al, 1			; TEST MISSING ADDRESS MARK
 19340 000049AC B402                <1> 	mov	ah, BAD_ADDR_MARK
 19341 000049AE 7202                <1> 	jc	short J19
 19342                              <1> 
 19343                              <1> ;----- 	NEC MUST HAVE FAILED
 19344                              <1> J18:
 19345 000049B0 B420                <1> 	mov	ah, BAD_NEC
 19346                              <1> J19:
 19347 000049B2 0825[08780100]      <1> 	or	[DSKETTE_STATUS], ah
 19348                              <1> SET_END:
 19349 000049B8 803D[08780100]01    <1> 	cmp	byte [DSKETTE_STATUS], 1 ; SET ERROR CONDITION
 19350 000049BF F5                  <1> 	cmc
 19351 000049C0 5E                  <1> 	pop	esi
 19352 000049C1 C3                  <1> 	retn				; RESTORE HEAD #, # OF SECTORS
 19353                              <1> 
 19354                              <1> SET_END_POP:
 19355 000049C2 9D                  <1> 	popf
 19356 000049C3 EBF3                <1> 	jmp	short SET_END
 19357                              <1> 
 19358                              <1> ;-------------------------------------------------------------------------------
 19359                              <1> ; DSTATE:	ESTABLISH STATE UPON SUCCESSFUL OPERATION.
 19360                              <1> ;-------------------------------------------------------------------------------
 19361                              <1> DSTATE:
 19362 000049C5 803D[08780100]00    <1> 	cmp	byte [DSKETTE_STATUS], 0 ; CHECK FOR ERROR
 19363 000049CC 753E                <1> 	jnz	short SETBAC		; IF ERROR JUMP
 19364 000049CE 808F[13780100]10    <1> 	or	byte [DSK_STATE+edi], MED_DET
 19365                              <1> 					; NO ERROR, MARK MEDIA AS DETERMINED
 19366 000049D5 F687[13780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE DETERMINED ?
 19367 000049DC 752E                <1> 	jnz	short SETBAC		; IF DETERMINED NO TRY TO DETERMINE
 19368 000049DE 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; LOAD STATE
 19369 000049E4 24C0                <1> 	and	al, RATE_MSK		; KEEP ONLY RATE
 19370 000049E6 3C80                <1> 	cmp	al, RATE_250		; RATE 250 ?
 19371 000049E8 751B                <1> 	jne	short M_12		; NO, MUST BE 1.2M OR 1.44M DRIVE
 19372                              <1> 
 19373                              <1> ;----- 	CHECK IF IT IS 1.44M
 19374                              <1> 
 19375 000049EA E846010000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
 19376                              <1> 	;;20/02/2015
 19377                              <1> 	;;jc	short M_12		; CMOS BAD
 19378 000049EF 7414                <1> 	jz	short M_12 ;; 20/02/2015
 19379 000049F1 3C04                <1> 	cmp	al, 4			; 1.44MB DRIVE ?
 19380 000049F3 7410                <1> 	je	short M_12		; YES
 19381                              <1> M_720:
 19382 000049F5 80A7[13780100]FD    <1> 	and	byte [DSK_STATE+edi], ~FMT_CAPA ; TURN OFF FORMAT CAPABILITY
 19383 000049FC 808F[13780100]04    <1> 	or	byte [DSK_STATE+edi], DRV_DET ; MARK DRIVE DETERMINED
 19384 00004A03 EB07                <1> 	jmp	short SETBAC		; BACK
 19385                              <1> M_12:	
 19386 00004A05 808F[13780100]06    <1> 	or	byte [DSK_STATE+edi], DRV_DET+FMT_CAPA 
 19387                              <1> 					; TURN ON DETERMINED & FMT CAPA
 19388                              <1> SETBAC:
 19389 00004A0C C3                  <1> 	retn
 19390                              <1> 
 19391                              <1> ;-------------------------------------------------------------------------------
 19392                              <1> ; RETRY	
 19393                              <1> ;	DETERMINES WHETHER A RETRY IS NECESSARY. 
 19394                              <1> ;	IF RETRY IS REQUIRED THEN STATE INFORMATION IS UPDATED FOR RETRY.
 19395                              <1> ;
 19396                              <1> ; ON EXIT:	CY = 1 FOR RETRY, CY = 0 FOR NO RETRY
 19397                              <1> ;-------------------------------------------------------------------------------
 19398                              <1> RETRY:
 19399                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19400 00004A0D 803D[08780100]00    <1> 	cmp	byte [DSKETTE_STATUS], 0 ; GET STATUS OF OPERATION
 19401 00004A14 7445                <1> 	jz	short NO_RETRY		; SUCCESSFUL OPERATION
 19402 00004A16 803D[08780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT NO RETRY
 19403 00004A1D 743C                <1> 	jz	short NO_RETRY
 19404 00004A1F 8AA7[13780100]      <1> 	mov	ah, [DSK_STATE+edi]	; GET MEDIA STATE OF DRIVE
 19405 00004A25 F6C410              <1> 	test	ah, MED_DET		; ESTABLISHED/DETERMINED ?
 19406 00004A28 7531                <1> 	jnz	short NO_RETRY		; IF ESTABLISHED STATE THEN TRUE ERROR
 19407 00004A2A 80E4C0              <1> 	and	ah, RATE_MSK		; ISOLATE RATE
 19408 00004A2D 8A2D[10780100]      <1> 	mov	ch, [LASTRATE]		; GET START OPERATION STATE
 19409 00004A33 C0C504              <1> 	rol	ch, 4			; TO CORRESPONDING BITS
 19410 00004A36 80E5C0              <1> 	and	ch, RATE_MSK		; ISOLATE RATE BITS
 19411 00004A39 38E5                <1> 	cmp	ch, ah			; ALL RATES TRIED
 19412 00004A3B 741E                <1> 	je	short NO_RETRY		; IF YES, THEN TRUE ERROR
 19413                              <1> 
 19414                              <1> ;	SETUP STATE INDICATOR FOR RETRY ATTEMPT TO NEXT RATE
 19415                              <1> ;	 00000000B (500) -> 10000000B	(250)
 19416                              <1> ;	 10000000B (250) -> 01000000B	(300)
 19417                              <1> ;	 01000000B (300) -> 00000000B	(500)
 19418                              <1> 
 19419 00004A3D 80FC01              <1> 	cmp	ah, RATE_500+1		; SET CY FOR RATE 500
 19420 00004A40 D0DC                <1> 	rcr	ah, 1			; TO NEXT STATE
 19421 00004A42 80E4C0              <1> 	and	ah, RATE_MSK		; KEEP ONLY RATE BITS
 19422 00004A45 80A7[13780100]1F    <1> 	and	byte [DSK_STATE+edi], ~(RATE_MSK+DBL_STEP)
 19423                              <1> 					; RATE, DBL STEP OFF
 19424 00004A4C 08A7[13780100]      <1> 	or	[DSK_STATE+edi], ah	; TURN ON NEW RATE
 19425 00004A52 C605[08780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0  ; RESET STATUS FOR RETRY
 19426 00004A59 F9                  <1> 	stc				; SET CARRY FOR RETRY
 19427 00004A5A C3                  <1> 	retn				; RETRY RETURN
 19428                              <1> 
 19429                              <1> NO_RETRY:
 19430                              <1> 	; 06/08/2022
 19431                              <1> 	;clc				; CLEAR CARRY NO RETRY
 19432 00004A5B C3                  <1> 	retn				; NO RETRY RETURN
 19433                              <1> 
 19434                              <1> ;-------------------------------------------------------------------------------
 19435                              <1> ; NUM_TRANS
 19436                              <1> ;	THIS ROUTINE CALCULATES THE NUMBER OF SECTORS THAT WERE
 19437                              <1> ;	ACTUALLY TRANSFERRED TO/FROM THE DISKETTE.
 19438                              <1> ;
 19439                              <1> ; ON ENTRY:	[BP+1] = TRACK
 19440                              <1> ;		SI-HI  = HEAD
 19441                              <1> ;		[BP]   = START SECTOR
 19442                              <1> ;
 19443                              <1> ; ON EXIT:	AL = NUMBER ACTUALLY TRANSFERRED
 19444                              <1> ;-------------------------------------------------------------------------------
 19445                              <1> NUM_TRANS:
 19446                              <1> 	; 10/08/2022
 19447                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19448 00004A5C 30C0                <1> 	xor	al, al			; CLEAR FOR ERROR
 19449                              <1> 	;cmp	byte [DSKETTE_STATUS], 0
 19450 00004A5E 3805[08780100]      <1> 	cmp	[DSKETTE_STATUS], al ; 0 ; CHECK FOR ERROR
 19451 00004A64 752D                <1> 	jnz	short NT_OUT		; IF ERROR 0 TRANSFERRED
 19452                              <1> 	;mov	dl, 4			; SECTORS/TRACK OFFSET TO DL
 19453                              <1> 	; 06/08/2022
 19454 00004A66 B004                <1> 	mov	al, 4
 19455 00004A68 E8D1000000          <1> 	call	GET_PARM		; AH = SECTORS/TRACK
 19456 00004A6D 8A1D[0E780100]      <1> 	mov	bl, [NEC_STATUS+5]	; GET ENDING SECTOR
 19457                              <1> 	;mov	cx, si			; CH = HEAD # STARTED
 19458                              <1> 	; 06/08/2022
 19459 00004A73 89F1                <1> 	mov	ecx, esi
 19460 00004A75 3A2D[0D780100]      <1> 	cmp	ch, [NEC_STATUS+4]	; GET HEAD ENDED UP ON
 19461 00004A7B 750E                <1> 	jnz	short DIF_HD		; IF ON SAME HEAD, THEN NO ADJUST
 19462 00004A7D 8A2D[0C780100]      <1> 	mov	ch, [NEC_STATUS+3]	; GET TRACK ENDED UP ON
 19463                              <1> 	;cmp	ch, [ebp+1]		; IS IT ASKED FOR TRACK
 19464                              <1> 	; 10/08/2022
 19465 00004A83 3A6C241D            <1> 	cmp	ch, [esp+29] ; CH = TRACK #
 19466 00004A87 7404                <1> 	jz	short SAME_TRK		; IF SAME TRACK NO INCREASE
 19467 00004A89 00E3                <1> 	add	bl, ah			; ADD SECTORS/TRACK
 19468                              <1> DIF_HD:
 19469 00004A8B 00E3                <1> 	add	bl, ah			; ADD SECTORS/TRACK
 19470                              <1> SAME_TRK:
 19471                              <1> 	;sub	bl, [ebp]		; SUBTRACT START FROM END
 19472                              <1> 	; 10/08/2022
 19473 00004A8D 2A5C241C            <1> 	sub	bl, [esp+28] ; CL = SECTOR #	
 19474 00004A91 88D8                <1> 	mov	al, bl			; TO AL
 19475                              <1> NT_OUT:
 19476 00004A93 C3                  <1> 	retn
 19477                              <1> 
 19478                              <1> ;-------------------------------------------------------------------------------
 19479                              <1> ; SETUP_DBL
 19480                              <1> ;	CHECK DOUBLE STEP.
 19481                              <1> ;
 19482                              <1> ; ON ENTRY :	DI = DRIVE
 19483                              <1> ;
 19484                              <1> ; ON EXIT :	CY = 1 MEANS ERROR
 19485                              <1> ;-------------------------------------------------------------------------------
 19486                              <1> SETUP_DBL:
 19487                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19488 00004A94 8AA7[13780100]      <1> 	mov	ah, [DSK_STATE+edi]	; ACCESS STATE
 19489 00004A9A F6C410              <1> 	test	ah, MED_DET		; ESTABLISHED STATE ?
 19490 00004A9D 7578                <1> 	jnz	short NO_DBL		; IF ESTABLISHED THEN DOUBLE DONE
 19491                              <1> 
 19492                              <1> ;-----	CHECK FOR TRACK 0 TO SPEED UP ACKNOWLEDGE OF UNFORMATTED DISKETTE
 19493                              <1> 
 19494 00004A9F C605[05780100]00    <1> 	mov	byte [SEEK_STATUS], 0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
 19495 00004AA6 E8CE000000          <1> 	call	MOTOR_ON		; ENSURE MOTOR STAY ON
 19496 00004AAB B500                <1> 	mov	ch, 0			; LOAD TRACK 0
 19497 00004AAD E8B9010000          <1> 	call	SEEK			; SEEK TO TRACK 0
 19498 00004AB2 E861000000          <1> 	call	READ_ID			; READ ID FUNCTION
 19499 00004AB7 7243                <1> 	jc	short SD_ERR		; IF ERROR NO TRACK 0
 19500                              <1> 
 19501                              <1> ;-----	INITIALIZE START AND MAX TRACKS (TIMES 2 FOR BOTH HEADS)
 19502                              <1> 
 19503 00004AB9 66B95004            <1> 	mov	cx, 0450h 		; START, MAX TRACKS
 19504 00004ABD F687[13780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; TEST FOR 80 TRACK CAPABILITY
 19505 00004AC4 7402                <1> 	jz	short CNT_OK		; IF NOT COUNT IS SETUP
 19506 00004AC6 B1A0                <1> 	mov	cl, 0A0h		; MAXIMUM TRACK 1.2 MB
 19507                              <1> 
 19508                              <1> ;	ATTEMPT READ ID OF ALL TRACKS, ALL HEADS UNTIL SUCCESS; UPON SUCCESS,
 19509                              <1> ;	MUST SEE IF ASKED FOR TRACK IN SINGLE STEP MODE = TRACK ID READ; IF NOT
 19510                              <1> ;	THEN SET DOUBLE STEP ON.
 19511                              <1> 
 19512                              <1> CNT_OK:
 19513                              <1> 	; 11/04/2021 (32 bit push/pop)
 19514 00004AC8 C605[07780100]FF    <1>         mov     byte [MOTOR_COUNT], 0FFh ; ENSURE MOTOR STAYS ON FOR OPERATION
 19515 00004ACF 51                  <1> 	push	ecx			; SAVE TRACK, COUNT
 19516 00004AD0 C605[08780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS, EXPECT ERRORS
 19517                              <1> 	;xor	ax, ax			; CLEAR AX
 19518                              <1> 	; 06/08/2022
 19519 00004AD7 31C0                <1> 	xor	eax, eax
 19520 00004AD9 D0ED                <1> 	shr	ch, 1			; HALVE TRACK, CY = HEAD
 19521 00004ADB C0D003              <1> 	rcl	al, 3			; AX = HEAD IN CORRECT BIT
 19522 00004ADE 50                  <1> 	push	eax			; SAVE HEAD
 19523 00004ADF E887010000          <1> 	call	SEEK			; SEEK TO TRACK
 19524 00004AE4 58                  <1> 	pop	eax			; RESTORE HEAD
 19525                              <1> 	;or	di, ax			; DI = HEAD OR'ED DRIVE
 19526                              <1> 	; 06/08/2022
 19527 00004AE5 09C7                <1> 	or	edi, eax
 19528 00004AE7 E82C000000          <1> 	call	READ_ID			; READ ID HEAD 0
 19529 00004AEC 9C                  <1> 	pushf				; SAVE RETURN FROM READ_ID
 19530 00004AED 6681E7FB00          <1> 	and	di, 11111011b		; TURN OFF HEAD 1 BIT
 19531 00004AF2 9D                  <1> 	popf				; RESTORE ERROR RETURN
 19532 00004AF3 59                  <1> 	pop	ecx			; RESTORE COUNT
 19533 00004AF4 7308                <1> 	jnc	short DO_CHK		; IF OK, ASKED = RETURNED TRACK ?
 19534 00004AF6 FEC5                <1> 	inc	ch			; INC FOR NEXT TRACK
 19535 00004AF8 38CD                <1> 	cmp	ch, cl			; REACHED MAXIMUM YET
 19536 00004AFA 75CC                <1> 	jnz	short CNT_OK		; CONTINUE TILL ALL TRIED
 19537                              <1> 
 19538                              <1> ;-----	FALL THRU, READ ID FAILED FOR ALL TRACKS
 19539                              <1> 
 19540                              <1> SD_ERR:	
 19541 00004AFC F9                  <1> 	stc				; SET CARRY FOR ERROR
 19542 00004AFD C3                  <1> 	retn				; SETUP_DBL ERROR EXIT
 19543                              <1> 
 19544                              <1> DO_CHK:
 19545 00004AFE 8A0D[0C780100]      <1> 	mov	cl, [NEC_STATUS+3]	; LOAD RETURNED TRACK
 19546 00004B04 888F[15780100]      <1> 	mov	[DSK_TRK+edi], cl	; STORE TRACK NUMBER
 19547 00004B0A D0ED                <1> 	shr	ch, 1			; HALVE TRACK
 19548 00004B0C 38CD                <1> 	cmp	ch, cl			; IS IT THE SAME AS ASKED FOR TRACK
 19549 00004B0E 7407                <1> 	jz	short NO_DBL		; IF SAME THEN NO DOUBLE STEP
 19550 00004B10 808F[13780100]20    <1> 	or	byte [DSK_STATE+edi], DBL_STEP ; TURN ON DOUBLE STEP REQUIRED
 19551                              <1> NO_DBL:
 19552                              <1> 	; 06/08/2022
 19553                              <1> 	;clc				; CLEAR ERROR FLAG
 19554 00004B17 C3                  <1> 	retn
 19555                              <1> 
 19556                              <1> ;-------------------------------------------------------------------------------
 19557                              <1> ; READ_ID
 19558                              <1> ;	READ ID FUNCTION.
 19559                              <1> ;
 19560                              <1> ; ON ENTRY:	DI : BIT 2 = HEAD; BITS 1,0 = DRIVE
 19561                              <1> ;
 19562                              <1> ; ON EXIT: 	DI : BIT 2 IS RESET, BITS 1,0 = DRIVE
 19563                              <1> ;		@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
 19564                              <1> ;-------------------------------------------------------------------------------
 19565                              <1> READ_ID:
 19566                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19567 00004B18 B8[344B0000]        <1> 	mov	eax, ER_3		; MOVE NEC OUTPUT ERROR ADDRESS
 19568 00004B1D 50                  <1> 	push	eax
 19569 00004B1E B44A                <1> 	mov	ah, 4Ah			; READ ID COMMAND
 19570 00004B20 E80F010000          <1> 	call	NEC_OUTPUT		; TO CONTROLLER
 19571                              <1> 	;mov	ax, di			; DRIVE # TO AH, HEAD 0
 19572                              <1> 	; 06/08/2022
 19573 00004B25 89F8                <1> 	mov	eax, edi
 19574 00004B27 88C4                <1> 	mov	ah, al
 19575 00004B29 E806010000          <1> 	call	NEC_OUTPUT		; TO CONTROLLER
 19576 00004B2E E836FEFFFF          <1> 	call	NEC_TERM		; WAIT FOR OPERATION, GET STATUS
 19577 00004B33 58                  <1> 	pop	eax			; THROW AWAY ERROR ADDRESS
 19578                              <1> ER_3:
 19579 00004B34 C3                  <1> 	retn
 19580                              <1> 
 19581                              <1> ;-------------------------------------------------------------------------------
 19582                              <1> ; CMOS_TYPE
 19583                              <1> ;	RETURNS DISKETTE TYPE FROM CMOS
 19584                              <1> ;
 19585                              <1> ; ON ENTRY:	DI = DRIVE #
 19586                              <1> ;
 19587                              <1> ; ON EXIT:	AL = TYPE; CY REFLECTS STATUS
 19588                              <1> ;-------------------------------------------------------------------------------
 19589                              <1> 
 19590                              <1> CMOS_TYPE: ; 11/12/2014
 19591 00004B35 8A87[FC640000]      <1> 	mov	al, [edi+fd0_type]
 19592 00004B3B 20C0                <1> 	and 	al, al ; 18/12/2014
 19593 00004B3D C3                  <1> 	retn
 19594                              <1> 
 19595                              <1> ;CMOS_TYPE:
 19596                              <1> ;	mov	al, CMOS_DIAG		; CMOS DIAGNOSTIC STATUS BYTE ADDRESS
 19597                              <1> ;	call	CMOS_READ		; GET CMOS STATUS
 19598                              <1> ;	test	al, BAD_BAT+BAD_CKSUM	; BATTERY GOOD AND CHECKSUM VALID
 19599                              <1> ;	stc				; SET CY = 1 INDICATING ERROR FOR RETURN
 19600                              <1> ;	jnz	short BAD_CM		; ERROR IF EITHER BIT ON
 19601                              <1> ;	mov	al, CMOS_DISKETTE	; ADDRESS OF DISKETTE BYTE IN CMOS
 19602                              <1> ;	call	CMOS_READ		; GET DISKETTE BYTE
 19603                              <1> ;	or	di, di			; SEE WHICH DRIVE IN QUESTION
 19604                              <1> ;	jnz	short TB		; IF DRIVE 1, DATA IN LOW NIBBLE
 19605                              <1> ;	ror	al, 4			; EXCHANGE NIBBLES IF SECOND DRIVE
 19606                              <1> ;TB:
 19607                              <1> ;	and	al, 0Fh			; KEEP ONLY DRIVE DATA, RESET CY, 0
 19608                              <1> ;BAD_CM:
 19609                              <1> ;	retn				; CY, STATUS OF READ
 19610                              <1> 
 19611                              <1> ;-------------------------------------------------------------------------------
 19612                              <1> ; GET_PARM
 19613                              <1> ;	THIS ROUTINE FETCHES THE INDEXED POINTER FROM THE DISK_BASE
 19614                              <1> ;	BLOCK POINTED TO BY THE DATA VARIABLE @DISK_POINTER. A BYTE FROM
 19615                              <1> ;	THAT TABLE IS THEN MOVED INTO AH, THE INDEX OF THAT BYTE BEING
 19616                              <1> ;	THE PARAMETER IN DL.
 19617                              <1> ;
 19618                              <1> ; ON ENTRY:	DL = INDEX OF BYTE TO BE FETCHED
 19619                              <1> ;
 19620                              <1> ; ON EXIT:	AH = THAT BYTE FROM BLOCK
 19621                              <1> ;		AL, DH DESTROYED
 19622                              <1> ;-------------------------------------------------------------------------------
 19623                              <1> GET_PARM:
 19624                              <1> 	; 09/08/2022
 19625                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19626                              <1> 	; AL = INDEX
 19627                              <1> 	; EDI = (current) DRIVE #
 19628                              <1> 	;;push	ds
 19629                              <1> 	;push	esi
 19630                              <1>     	;;sub	ax, ax			; DS = 0, BIOS DATA AREA
 19631                              <1>     	;;mov	ds, ax
 19632                              <1> 	;;mov	ax, cs
 19633                              <1> 	;;mov	ds, ax
 19634                              <1> 	; 08/02/2015 (protected mode modifications, bx -> ebx)
 19635                              <1> 	;xchg	edx, ebx		; BL = INDEX
 19636                              <1> 	; 06/08/2022
 19637 00004B3E 53                  <1> 	push	ebx			; SAVE EBX	
 19638                              <1> 	;movzx	ebx, dl			; EBX = INDEX
 19639 00004B3F 0FB6D8              <1> 	movzx	ebx, al ; 06/08/2022
 19640                              <1> 	;;sub	bh, bh			; BX = INDEX
 19641                              <1> 	;and	ebx, 0FFh
 19642                              <1>     	;;lds	si, [DISK_POINTER]	; POINT TO BLOCK
 19643                              <1> 	;
 19644                              <1> 	; 17/12/2014
 19645                              <1> 	;mov	ax, [cfd]		; current (AL) and previous fd (AH)
 19646                              <1> 	; 06/08/2022
 19647 00004B42 89F8                <1> 	mov	eax, edi		; EDI = DRIVE #
 19648                              <1> 	;cmp	al, ah
 19649 00004B44 3A05[ED640000]      <1> 	cmp	al, [pfd]	
 19650 00004B4A 7423                <1> 	je	short gpndc
 19651 00004B4C A2[ED640000]        <1> 	mov	[pfd], al		; current drive -> previous drive
 19652 00004B51 53                  <1> 	push	ebx ; 08/02/2015
 19653                              <1> 	;mov	bl, al 
 19654                              <1> 	;; 11/12/2014
 19655                              <1> 	;mov	al, [ebx+fd0_type]	; Drive type (0,1,2,3,4)
 19656                              <1> 	; 09/08/2022
 19657 00004B52 8A87[FC640000]      <1> 	mov	al, [edi+fd0_type]	; Drive type (0,1,2,3,4)
 19658                              <1> 	; 18/12/2014
 19659 00004B58 20C0                <1> 	and	al, al
 19660 00004B5A 7507                <1> 	jnz	short gpdtc
 19661 00004B5C BB[D7640000]        <1> 	mov	ebx, MD_TBL6		; 1.44 MB param. tbl. (default)
 19662 00004B61 EB05                <1>         jmp     short gpdpu
 19663                              <1> gpdtc:	
 19664 00004B63 E809FBFFFF          <1> 	call	DR_TYPE_CHECK
 19665                              <1> 	; cf = 1 -> ebx points to 1.44MB fd parameter table (default)
 19666                              <1> gpdpu:
 19667 00004B68 891D[74640000]      <1> 	mov	[DISK_POINTER], ebx
 19668 00004B6E 5B                  <1> 	pop	ebx
 19669                              <1> gpndc:
 19670                              <1> 	;mov	esi, [DISK_POINTER] ; 08/02/2015, si -> esi
 19671                              <1> 	; 06/08/2022
 19672 00004B6F 031D[74640000]      <1> 	add	ebx, [DISK_POINTER]
 19673                              <1> 	;mov	ah, [esi+ebx]		; GET THE WORD
 19674 00004B75 8A23                <1> 	mov	ah, [ebx]
 19675                              <1> 	;xchg	edx, ebx		; RESTORE BX
 19676                              <1> 	; 06/08/2022
 19677 00004B77 5B                  <1> 	pop	ebx			; RESTORE EBX
 19678                              <1> 	;pop	esi
 19679                              <1> 	;;pop	ds
 19680 00004B78 C3                  <1> 	retn
 19681                              <1> 
 19682                              <1> ;-------------------------------------------------------------------------------
 19683                              <1> ; MOTOR_ON
 19684                              <1> ;	TURN MOTOR ON AND WAIT FOR MOTOR START UP TIME. THE @MOTOR_COUNT
 19685                              <1> ;	IS REPLACED WITH A SUFFICIENTLY HIGH NUMBER (0FFH) TO ENSURE
 19686                              <1> ;	THAT THE MOTOR DOES NOT GO OFF DURING THE OPERATION. IF THE
 19687                              <1> ;	MOTOR NEEDED TO BE TURNED ON, THE MULTI-TASKING HOOK FUNCTION
 19688                              <1> ;	(AX=90FDH, INT 15) IS CALLED TELLING THE OPERATING SYSTEM
 19689                              <1> ;	THAT THE BIOS IS ABOUT TO WAIT FOR MOTOR START UP. IF THIS
 19690                              <1> ;	FUNCTION RETURNS WITH CY = 1, IT MEANS THAT THE MINIMUM WAIT
 19691                              <1> ;	HAS BEEN COMPLETED. AT THIS POINT A CHECK IS MADE TO ENSURE
 19692                              <1> ;	THAT THE MOTOR WASN'T TURNED OFF BY THE TIMER. IF THE HOOK DID
 19693                              <1> ;	NOT WAIT, THE WAIT FUNCTION (AH=086H) IS CALLED TO WAIT THE
 19694                              <1> ;	PRESCRIBED AMOUNT OF TIME. IF THE CARRY FLAG IS SET ON RETURN,
 19695                              <1> ;	IT MEANS THAT THE FUNCTION IS IN USE AND DID NOT PERFORM THE
 19696                              <1> ;	WAIT. A TIMER 1 WAIT LOOP WILL THEN DO THE WAIT.
 19697                              <1> ;
 19698                              <1> ; ON ENTRY:	DI = DRIVE #
 19699                              <1> ; ON EXIT:	AX,CX,DX DESTROYED
 19700                              <1> ;-------------------------------------------------------------------------------
 19701                              <1> MOTOR_ON:
 19702                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 19703 00004B79 53                  <1> 	push	ebx			; SAVE REG.
 19704 00004B7A E825000000          <1> 	call	TURN_ON			; TURN ON MOTOR
 19705 00004B7F 7221                <1> 	jc	short MOT_IS_ON		; IF CY=1 NO WAIT
 19706                              <1> 	; 06/08/2022
 19707                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 19708 00004B81 E851FBFFFF          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
 19709                              <1> 	;call	TURN_ON 		; CHECK AGAIN IF MOTOR ON
 19710                              <1> 	;jc	short MOT_IS_ON		; IF NO WAIT MEANS IT IS ON
 19711                              <1> M_WAIT:
 19712                              <1> 	;mov	dl, 10			; GET THE MOTOR WAIT PARAMETER
 19713                              <1> 	; 06/08/2022
 19714 00004B86 B00A                <1> 	mov	al, 10
 19715 00004B88 E8B1FFFFFF          <1> 	call	GET_PARM
 19716                              <1> 	;mov	al, ah			; AL = MOTOR WAIT PARAMETER
 19717                              <1> 	;xor	ah, ah			; AX = MOTOR WAIT PARAMETER
 19718                              <1> 	;cmp	al, 8			; SEE IF AT LEAST A SECOND IS SPECIFIED
 19719 00004B8D 80FC08              <1> 	cmp	ah, 8
 19720                              <1> 	;jae	short GP2		; IF YES, CONTINUE
 19721 00004B90 7702                <1> 	ja	short J13
 19722                              <1> 	;mov	al, 8			; ONE SECOND WAIT FOR MOTOR START UP
 19723 00004B92 B408                <1> 	mov	ah, 8
 19724                              <1> 
 19725                              <1> ;-----	AS CONTAINS NUMBER OF 1/8 SECONDS (125000 MICROSECONDS) TO WAIT
 19726                              <1> GP2:	
 19727                              <1> ;----- 	FOLLOWING LOOPS REQUIRED WHEN RTC WAIT FUNCTION IS ALREADY IN USE
 19728                              <1> J13:					; WAIT FOR 1/8 SECOND PER (AL)
 19729                              <1> 	;mov	ecx, 8286		; COUNT FOR 1/8 SECOND AT 15.085737 US
 19730                              <1> 	; 11/04/2021
 19731 00004B94 B947100000          <1> 	mov	ecx, 4167 ; count of 30 micro seconds * (1/8) 
 19732 00004B99 E8C6D7FFFF          <1> 	call	WAITF			; GO TO FIXED WAIT ROUTINE
 19733                              <1> 	;dec	al			; DECREMENT TIME VALUE
 19734 00004B9E FECC                <1> 	dec	ah
 19735 00004BA0 75F2                <1> 	jnz	short J13		; ARE WE DONE YET
 19736                              <1> MOT_IS_ON:
 19737 00004BA2 5B                  <1> 	pop	ebx			; RESTORE REG.
 19738 00004BA3 C3                  <1> 	retn
 19739                              <1> 
 19740                              <1> ;-------------------------------------------------------------------------------
 19741                              <1> ; TURN_ON
 19742                              <1> ;	TURN MOTOR ON AND RETURN WAIT STATE.
 19743                              <1> ;
 19744                              <1> ; ON ENTRY:	DI = DRIVE #
 19745                              <1> ;
 19746                              <1> ; ON EXIT:	CY = 0 MEANS WAIT REQUIRED
 19747                              <1> ;		CY = 1 MEANS NO WAIT REQUIRED
 19748                              <1> ;		AX,BX,CX,DX DESTROYED
 19749                              <1> ;-------------------------------------------------------------------------------
 19750                              <1> TURN_ON:
 19751 00004BA4 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
 19752 00004BA6 88D9                <1> 	mov	cl, bl			; CL = DRIVE #
 19753 00004BA8 C0C304              <1> 	rol	bl, 4			; BL = DRIVE SELECT
 19754 00004BAB FA                  <1> 	cli				; NO INTERRUPTS WHILE DETERMINING STATUS
 19755 00004BAC C605[07780100]FF    <1> 	mov	byte [MOTOR_COUNT], 0FFh ; ENSURE MOTOR STAYS ON FOR OPERATION
 19756 00004BB3 A0[06780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
 19757 00004BB8 2430                <1> 	and	al, 00110000b		; KEEP ONLY DRIVE SELECT BITS
 19758 00004BBA B401                <1> 	mov	ah, 1			; MASK FOR DETERMINING MOTOR BIT
 19759 00004BBC D2E4                <1> 	shl	ah, cl			; AH = MOTOR ON, A=00000001, B=00000010
 19760                              <1> 
 19761                              <1> ;  AL = DRIVE SELECT FROM @MOTOR_STATUS
 19762                              <1> ;  BL = DRIVE SELECT DESIRED
 19763                              <1> ;  AH = MOTOR ON MASK DESIRED
 19764                              <1> 
 19765 00004BBE 38D8                <1> 	cmp	al, bl			; REQUESTED DRIVE ALREADY SELECTED ?
 19766 00004BC0 7508                <1> 	jnz	short TURN_IT_ON	; IF NOT SELECTED JUMP
 19767 00004BC2 8425[06780100]      <1> 	test	ah, [MOTOR_STATUS]	; TEST MOTOR ON BIT
 19768 00004BC8 7535                <1> 	jnz	short NO_MOT_WAIT	; JUMP IF MOTOR ON AND SELECTED
 19769                              <1> 
 19770                              <1> TURN_IT_ON:
 19771 00004BCA 08DC                <1> 	or	ah, bl			; AH = DRIVE SELECT AND MOTOR ON
 19772 00004BCC 8A3D[06780100]      <1> 	mov	bh, [MOTOR_STATUS]	; SAVE COPY OF @MOTOR_STATUS BEFORE
 19773 00004BD2 80E70F              <1> 	and	bh, 00001111b		; KEEP ONLY MOTOR BITS
 19774 00004BD5 8025[06780100]CF    <1> 	and	byte [MOTOR_STATUS], 11001111b ; CLEAR OUT DRIVE SELECT
 19775 00004BDC 0825[06780100]      <1> 	or	[MOTOR_STATUS], ah	; OR IN DRIVE SELECTED AND MOTOR ON
 19776 00004BE2 A0[06780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
 19777 00004BE7 88C3                <1> 	mov	bl, al			; BL=@MOTOR_STATUS AFTER, BH=BEFORE
 19778 00004BE9 80E30F              <1> 	and	bl, 00001111b		; KEEP ONLY MOTOR BITS
 19779 00004BEC FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
 19780 00004BED 243F                <1> 	and	al, 00111111b		; STRIP AWAY UNWANTED BITS
 19781 00004BEF C0C004              <1> 	rol	al, 4			; PUT BITS IN DESIRED POSITIONS
 19782 00004BF2 0C0C                <1> 	or	al, 00001100b		; NO RESET, ENABLE DMA/INTERRUPT
 19783 00004BF4 66BAF203            <1> 	mov	dx, 03F2h		; SELECT DRIVE AND TURN ON MOTOR
 19784 00004BF8 EE                  <1> 	out	dx, al
 19785 00004BF9 38FB                <1> 	cmp	bl, bh			; NEW MOTOR TURNED ON ?
 19786                              <1> 	;jz	short NO_MOT_WAIT	; NO WAIT REQUIRED IF JUST SELECT
 19787 00004BFB 7403                <1> 	je	short no_mot_w1 ; 27/02/2015 
 19788 00004BFD F8                  <1> 	clc				; (re)SET CARRY MEANING WAIT
 19789 00004BFE C3                  <1> 	retn
 19790                              <1> 
 19791                              <1> NO_MOT_WAIT:
 19792 00004BFF FB                  <1> 	sti
 19793                              <1> no_mot_w1: ; 27/02/2015
 19794 00004C00 F9                  <1> 	stc				; SET NO WAIT REQUIRED
 19795                              <1> 	;sti				; INTERRUPTS BACK ON
 19796 00004C01 C3                  <1> 	retn
 19797                              <1> 
 19798                              <1> ;-------------------------------------------------------------------------------
 19799                              <1> ; HD_WAIT
 19800                              <1> ;	WAIT FOR HEAD SETTLE TIME.
 19801                              <1> ;
 19802                              <1> ; ON ENTRY:	DI = DRIVE #
 19803                              <1> ;
 19804                              <1> ; ON EXIT:	AX,BX,CX,DX DESTROYED
 19805                              <1> ;-------------------------------------------------------------------------------
 19806                              <1> HD_WAIT:
 19807                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 19808                              <1> 	;mov	dl,9			; GET HEAD SETTLE PARAMETER
 19809                              <1> 	; 06/08/2022
 19810 00004C02 B009                <1> 	mov	al, 9
 19811 00004C04 E835FFFFFF          <1> 	call	GET_PARM
 19812 00004C09 08E4                <1> 	or	ah, ah	; 17/12/2014
 19813 00004C0B 7519                <1> 	jnz	short DO_WAT
 19814 00004C0D F605[06780100]80    <1>         test    byte [MOTOR_STATUS], 10000000b ; SEE IF A WRITE OPERATION
 19815                              <1> 	;jz	short ISNT_WRITE	; IF NOT, DO NOT ENFORCE ANY VALUES
 19816                              <1> 	;or	ah, ah			; CHECK FOR ANY WAIT?
 19817                              <1> 	;jnz	short DO_WAT		; IF THERE DO NOT ENFORCE
 19818 00004C14 741D                <1> 	jz	short HW_DONE
 19819 00004C16 B40F                <1> 	mov	ah, HD12_SETTLE		; LOAD 1.2M HEAD SETTLE MINIMUM
 19820 00004C18 8A87[13780100]      <1> 	mov	al, [DSK_STATE+edi]	; LOAD STATE
 19821 00004C1E 24C0                <1> 	and	al, RATE_MSK		; KEEP ONLY RATE
 19822 00004C20 3C80                <1> 	cmp	al, RATE_250		; 1.2 M DRIVE ?
 19823 00004C22 7502                <1> 	jnz	short DO_WAT		; DEFAULT HEAD SETTLE LOADED
 19824                              <1> ;GP3:
 19825 00004C24 B414                <1> 	mov	ah, HD320_SETTLE	; USE 320/360 HEAD SETTLE
 19826                              <1> ;	jmp	short DO_WAT
 19827                              <1> 
 19828                              <1> ;ISNT_WRITE:
 19829                              <1> ;	or	ah, ah			; CHECK FOR NO WAIT
 19830                              <1> ;	jz	short HW_DONE		; IF NOT WRITE AND 0 ITS OK
 19831                              <1> 
 19832                              <1> ;-----	AH CONTAINS NUMBER OF MILLISECONDS TO WAIT
 19833                              <1> DO_WAT:
 19834                              <1> ;	mov	al, ah			; AL = # MILLISECONDS
 19835                              <1> ;	;xor	ah, ah			; AX = # MILLISECONDS
 19836                              <1> J29:					; 	1 MILLISECOND LOOP
 19837                              <1> 	;;mov	cx, WAIT_FDU_HEAD_SETTLE ; 33 ; 1 ms in 30 micro units.
 19838                              <1> 	;mov	ecx, 66			; COUNT AT 15.085737 US PER COUNT
 19839                              <1> 	; 11/04/2021
 19840                              <1> 	;mov	ecx, WAIT_FDU_HEAD_SETTLE ; 33
 19841                              <1> 	; 06/08/2022
 19842 00004C26 29C9                <1> 	sub	ecx, ecx
 19843 00004C28 B121                <1> 	mov	cl, WAIT_FDU_HEAD_SETTLE ; 33
 19844 00004C2A E835D7FFFF          <1> 	call	WAITF			; DELAY FOR 1 MILLISECOND
 19845                              <1> 	;dec	al			; DECREMENT THE COUNT
 19846 00004C2F FECC                <1> 	dec	ah
 19847 00004C31 75F3                <1> 	jnz	short J29		; DO AL MILLISECOND # OF TIMES
 19848                              <1> HW_DONE:
 19849 00004C33 C3                  <1> 	retn
 19850                              <1> 
 19851                              <1> ;-------------------------------------------------------------------------------
 19852                              <1> ; NEC_OUTPUT
 19853                              <1> ;	THIS ROUTINE SENDS A BYTE TO THE NEC CONTROLLER AFTER TESTING
 19854                              <1> ;	FOR CORRECT DIRECTION AND CONTROLLER READY THIS ROUTINE WILL
 19855                              <1> ;	TIME OUT IF THE BYTE IS NOT ACCEPTED WITHIN A REASONABLE AMOUNT
 19856                              <1> ;	OF TIME, SETTING THE DISKETTE STATUS ON COMPLETION.
 19857                              <1> ; 
 19858                              <1> ; ON ENTRY: 	AH = BYTE TO BE OUTPUT
 19859                              <1> ;
 19860                              <1> ; ON EXIT:	CY = 0  SUCCESS
 19861                              <1> ;		CY = 1  FAILURE -- DISKETTE STATUS UPDATED
 19862                              <1> ;		        IF A FAILURE HAS OCCURRED, THE RETURN IS MADE ONE LEVEL
 19863                              <1> ;		        HIGHER THAN THE CALLER OF NEC OUTPUT. THIS REMOVES THE
 19864                              <1> ;		        REQUIREMENT OF TESTING AFTER EVERY CALL OF NEC_OUTPUT.
 19865                              <1> ;		AX,CX,DX DESTROYED
 19866                              <1> ;-------------------------------------------------------------------------------
 19867                              <1> 
 19868                              <1> ; 09/12/2014 [Erdogan Tan] 
 19869                              <1> ;	(from 'PS2 Hardware Interface Tech. Ref. May 88', Page 09-05.)
 19870                              <1> ; Diskette Drive Controller Status Register (3F4h)
 19871                              <1> ;	This read only register facilitates the transfer of data between
 19872                              <1> ;	the system microprocessor and the controller.
 19873                              <1> ; Bit 7 - When set to 1, the Data register is ready to transfer data 
 19874                              <1> ;	  with the system micrprocessor.
 19875                              <1> ; Bit 6 - The direction of data transfer. If this bit is set to 0,
 19876                              <1> ;	  the transfer is to the controller.
 19877                              <1> ; Bit 5 - When this bit is set to 1, the controller is in the non-DMA mode.
 19878                              <1> ; Bit 4 - When this bit is set to 1, a Read or Write command is being executed.
 19879                              <1> ; Bit 3 - Reserved.
 19880                              <1> ; Bit 2 - Reserved.
 19881                              <1> ; Bit 1 - When this bit is set to 1, dskette drive 1 is in the seek mode.
 19882                              <1> ; Bit 0 - When this bit is set to 1, dskette drive 1 is in the seek mode.
 19883                              <1> 
 19884                              <1> ; Data Register (3F5h)
 19885                              <1> ; This read/write register passes data, commands and parameters, and provides
 19886                              <1> ; diskette status information.
 19887                              <1>   		
 19888                              <1> NEC_OUTPUT:
 19889                              <1> 	; 09/08/2022
 19890                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 19891                              <1> 	;
 19892                              <1> 	;push	bx			; SAVE REG.
 19893 00004C34 66BAF403            <1> 	mov	dx, 03F4h		; STATUS PORT
 19894                              <1> 	;mov	bl,2			; HIGH ORDER COUNTER
 19895                              <1> 	;xor	cx, cx			; COUNT FOR TIME OUT
 19896                              <1> 	; 16/12/2014
 19897                              <1> 	; waiting for (max.) 0.5 seconds
 19898                              <1>         ;;mov	byte [wait_count], 0 ;; 27/02/2015
 19899                              <1> 	;
 19900                              <1> 	; 17/12/2014
 19901                              <1> 	; Modified from AWARD BIOS 1999 - ADISK.ASM - SEND_COMMAND
 19902                              <1> 	;
 19903                              <1> 	;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
 19904                              <1> 	;		go on.
 19905                              <1> 	;INPUT:
 19906                              <1> 	;	AH=Mask for isolation bits.
 19907                              <1> 	;	AL=pattern to look for.
 19908                              <1> 	;	DX=Port to test for
 19909                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
 19910                              <1> 	;	     (normally 30 microseconds per period.)
 19911                              <1> 	;
 19912                              <1> 	;WFP_SHORT:  
 19913                              <1> 	;	Wait for port if refresh cycle is short (15-80 Us range).
 19914                              <1> 	;
 19915                              <1> 
 19916                              <1> ;	mov	bl, WAIT_FDU_SEND_HI+1	; 0+1
 19917                              <1> ;	mov	cx, WAIT_FDU_SEND_LO	; 16667
 19918 00004C38 B91B410000          <1> 	mov	ecx, WAIT_FDU_SEND_LH   ; 16667 (27/02/2015)
 19919                              <1> ;
 19920                              <1> ;WFPS_OUTER_LP:
 19921                              <1> ;	;
 19922                              <1> ;WFPS_CHECK_PORT:
 19923                              <1> J23:
 19924 00004C3D EC                  <1> 	in	al, dx			; GET STATUS
 19925 00004C3E 24C0                <1> 	and	al, 11000000b		; KEEP STATUS AND DIRECTION
 19926 00004C40 3C80                <1> 	cmp	al, 10000000b		; STATUS 1 AND DIRECTION 0 ?
 19927 00004C42 7418                <1> 	jz	short J27		; STATUS AND DIRECTION OK
 19928                              <1> WFPS_HI:
 19929 00004C44 E461                <1> 	in	al, PORT_B  ; 061h	; SYS1	; wait for hi to lo
 19930 00004C46 A810                <1> 	test	al, 010h		; transition on memory
 19931 00004C48 75FA                <1> 	jnz	short WFPS_HI		; refresh.
 19932                              <1> WFPS_LO:
 19933 00004C4A E461                <1> 	in	al, PORT_B		; SYS1
 19934 00004C4C A810                <1> 	test	al, 010h
 19935 00004C4E 74FA                <1> 	jz	short WFPS_LO
 19936                              <1> 	;loop	short WFPS_CHECK_PORT
 19937 00004C50 E2EB                <1> 	loop	J23	; 27/02/2015
 19938                              <1> ;	;
 19939                              <1> ;	dec	bl
 19940                              <1> ;	jnz	short WFPS_OUTER_LP
 19941                              <1> ;	jmp	short WFPS_TIMEOUT	; fail
 19942                              <1> ;J23:
 19943                              <1> ;	in	al, dx			; GET STATUS
 19944                              <1> ;	and	al, 11000000b		; KEEP STATUS AND DIRECTION
 19945                              <1> ;	cmp	al, 10000000b		; STATUS 1 AND DIRECTION 0 ?
 19946                              <1> ;	jz	short J27		; STATUS AND DIRECTION OK
 19947                              <1> 	;loop	J23			; CONTINUE TILL CX EXHAUSTED
 19948                              <1> 	;dec	bl			; DECREMENT COUNTER
 19949                              <1> 	;jnz	short J23		; REPEAT TILL DELAY FINISHED, CX = 0
 19950                              <1>    
 19951                              <1> 	;;27/02/2015
 19952                              <1> 	;16/12/2014
 19953                              <1>         ;;cmp	byte [wait_count], 10   ; (10/18.2 seconds)
 19954                              <1> 	;;jb	short J23
 19955                              <1> 
 19956                              <1> ;WFPS_TIMEOUT:
 19957                              <1> 
 19958                              <1> ;-----	FALL THRU TO ERROR RETURN
 19959                              <1> 
 19960 00004C52 800D[08780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT
 19961                              <1> 	;pop	bx			; RESTORE REG.
 19962 00004C59 58                  <1> 	pop	eax ; 08/02/2015	; DISCARD THE RETURN ADDRESS
 19963 00004C5A F9                  <1> 	stc				; INDICATE ERROR TO CALLER
 19964 00004C5B C3                  <1> 	retn
 19965                              <1> 
 19966                              <1> ;-----	DIRECTION AND STATUS OK; OUTPUT BYTE
 19967                              <1> 
 19968                              <1> J27:	
 19969 00004C5C 88E0                <1> 	mov	al, ah			; GET BYTE TO OUTPUT
 19970                              <1> 	;inc	dx			; DATA PORT = STATUS PORT + 1
 19971                              <1> 	; 06/08/2022
 19972 00004C5E FEC2                <1> 	inc	dl
 19973 00004C60 EE                  <1> 	out	dx, al			; OUTPUT THE BYTE
 19974                              <1> 	;;NEWIODELAY  ;; 27/02/2015
 19975                              <1> 	; 27/02/2015
 19976                              <1> 	;pushf				; SAVE FLAGS
 19977                              <1> 	; 09/08/2022
 19978                              <1> 	; cf = 0, zf = 1
 19979                              <1> 	;mov	ecx, 3			; 30 TO 45 MICROSECONDS WAIT FOR
 19980                              <1> 	; 11/04/2021
 19981                              <1> 	;mov	ecx, 2 
 19982                              <1> 	; 06/08/2022
 19983 00004C61 29C9                <1> 	sub	ecx, ecx
 19984 00004C63 B102                <1> 	mov	cl, 2
 19985 00004C65 E8FAD6FFFF          <1> 	call 	WAITF			; NEC FLAGS UPDATE CYCLE
 19986                              <1> 	; 09/08/2022
 19987                              <1> 	; cf = 0, zf = 1
 19988                              <1> 	;popf				; RESTORE FLAGS FOR EXIT
 19989                              <1> 	;pop	bx			; RESTORE REG
 19990 00004C6A C3                  <1> 	retn				; CY = 0 FROM TEST INSTRUCTION
 19991                              <1> 
 19992                              <1> ;-------------------------------------------------------------------------------
 19993                              <1> ; SEEK
 19994                              <1> ;	THIS ROUTINE WILL MOVE THE HEAD ON THE NAMED DRIVE TO THE NAMED
 19995                              <1> ;	TRACK. IF THE DRIVE HAS NOT BEEN ACCESSED SINCE THE DRIVE
 19996                              <1> ;	RESET COMMAND WAS ISSUED, THE DRIVE WILL BE RECALIBRATED.
 19997                              <1> ;
 19998                              <1> ; ON ENTRY:	DI = DRIVE #
 19999                              <1> ;		CH = TRACK #
 20000                              <1> ;
 20001                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
 20002                              <1> ;		AX,BX,CX DX DESTROYED
 20003                              <1> ;-------------------------------------------------------------------------------
 20004                              <1> SEEK:
 20005 00004C6B 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
 20006 00004C6D B001                <1> 	mov	al, 1			; ESTABLISH MASK FOR RECALIBRATE TEST
 20007                              <1> 	; 06/08/2022
 20008                              <1> 	;xchg	cl, bl			; SET DRIVE VALUE INTO CL
 20009                              <1> 	;rol	al, cl			; SHIFT MASK BY THE DRIVE VALUE
 20010                              <1> 	;xchg	cl, bl			; RECOVER TRACK VALUE
 20011                              <1> 	; 06/08/2022
 20012 00004C6F 84C3                <1> 	test	bl, al ; test bl, 1
 20013 00004C71 7402                <1> 	jz	short seek_0
 20014 00004C73 FEC0                <1> 	inc	al ; shl al, 1
 20015                              <1> seek_0:
 20016 00004C75 8405[05780100]      <1> 	test	al, [SEEK_STATUS]	; TEST FOR RECALIBRATE REQUIRED
 20017 00004C7B 7526                <1> 	jnz	short J28A		; JUMP IF RECALIBRATE NOT REQUIRED
 20018                              <1> 
 20019 00004C7D 0805[05780100]      <1> 	or	[SEEK_STATUS], al	; TURN ON THE NO RECALIBRATE BIT IN FLAG
 20020 00004C83 E862000000          <1> 	call	RECAL			; RECALIBRATE DRIVE
 20021 00004C88 730E                <1> 	jnc	short AFT_RECAL		; RECALIBRATE DONE
 20022                              <1> 
 20023                              <1> ;-----	ISSUE RECALIBRATE FOR 80 TRACK DISKETTES
 20024                              <1> 
 20025 00004C8A C605[08780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR OUT INVALID STATUS
 20026 00004C91 E854000000          <1> 	call	RECAL			; RECALIBRATE DRIVE
 20027 00004C96 7251                <1> 	jc	short RB		; IF RECALIBRATE FAILS TWICE THEN ERROR
 20028                              <1> 
 20029                              <1> AFT_RECAL:
 20030 00004C98 C687[15780100]00    <1>         mov     byte [DSK_TRK+edi], 0	; SAVE NEW CYLINDER AS PRESENT POSITION
 20031 00004C9F 08ED                <1> 	or	ch, ch			; CHECK FOR SEEK TO TRACK 0
 20032 00004CA1 743F                <1> 	jz	short DO_WAIT		; HEAD SETTLE, CY = 0 IF JUMP
 20033                              <1> 
 20034                              <1> ;-----	DRIVE IS IN SYNCHRONIZATION WITH CONTROLLER, SEEK TO TRACK
 20035                              <1> 
 20036 00004CA3 F687[13780100]20    <1> J28A:	test	byte [DSK_STATE+edi], DBL_STEP ; CHECK FOR DOUBLE STEP REQUIRED
 20037 00004CAA 7402                <1> 	jz	short _R7		; SINGLE STEP REQUIRED BYPASS DOUBLE
 20038 00004CAC D0E5                <1> 	shl	ch, 1			; DOUBLE NUMBER OF STEP TO TAKE
 20039                              <1> 
 20040 00004CAE 3AAF[15780100]      <1> _R7:	cmp	ch, [DSK_TRK+edi]	; SEE IF ALREADY AT THE DESIRED TRACK
 20041 00004CB4 7433                <1> 	je	short RB		; IF YES, DO NOT NEED TO SEEK
 20042                              <1> 
 20043 00004CB6 BA[E94C0000]        <1> 	mov	edx, NEC_ERR		; LOAD RETURN ADDRESS
 20044 00004CBB 52                  <1> 	push	edx ; (*)		; ON STACK FOR NEC OUTPUT ERROR
 20045 00004CBC 88AF[15780100]      <1> 	mov	[DSK_TRK+edi], ch	; SAVE NEW CYLINDER AS PRESENT POSITION
 20046 00004CC2 B40F                <1> 	mov	ah, 0Fh			; SEEK COMMAND TO NEC
 20047 00004CC4 E86BFFFFFF          <1> 	call	NEC_OUTPUT
 20048 00004CC9 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
 20049 00004CCB 88DC                <1> 	mov	ah, bl			; OUTPUT DRIVE NUMBER
 20050 00004CCD E862FFFFFF          <1> 	call	NEC_OUTPUT
 20051 00004CD2 8AA7[15780100]      <1> 	mov	ah, [DSK_TRK+edi]	; GET CYLINDER NUMBER
 20052 00004CD8 E857FFFFFF          <1> 	call	NEC_OUTPUT
 20053 00004CDD E827000000          <1> 	call	CHK_STAT_2		; ENDING INTERRUPT AND SENSE STATUS
 20054                              <1> 
 20055                              <1> ;-----	WAIT FOR HEAD SETTLE
 20056                              <1> 
 20057                              <1> DO_WAIT:
 20058 00004CE2 9C                  <1> 	pushf				; SAVE STATUS
 20059 00004CE3 E81AFFFFFF          <1> 	call	HD_WAIT			; WAIT FOR HEAD SETTLE TIME
 20060 00004CE8 9D                  <1> 	popf				; RESTORE STATUS
 20061                              <1> RB:
 20062                              <1> NEC_ERR:
 20063                              <1> 	; 08/02/2015 (code trick here from original IBM PC/AT DISKETTE.ASM)
 20064                              <1> 	; (*) nec_err -> retn (push edx -> pop edx) -> nec_err -> retn
 20065 00004CE9 C3                  <1> 	retn				; RETURN TO CALLER
 20066                              <1> 
 20067                              <1> ;-------------------------------------------------------------------------------
 20068                              <1> ; RECAL
 20069                              <1> ;	RECALIBRATE DRIVE
 20070                              <1> ;
 20071                              <1> ; ON ENTRY:	DI = DRIVE #
 20072                              <1> ;
 20073                              <1> ; ON EXIT:	CY REFLECTS STATUS OF OPERATION.
 20074                              <1> ;-------------------------------------------------------------------------------
 20075                              <1> RECAL:
 20076                              <1> 	;push	cx
 20077                              <1> 	; 11/04/2021
 20078 00004CEA 51                  <1> 	push	ecx
 20079 00004CEB B8[074D0000]        <1> 	mov	eax, RC_BACK		; LOAD NEC_OUTPUT ERROR
 20080 00004CF0 50                  <1> 	push	eax
 20081 00004CF1 B407                <1> 	mov	ah, 07h			; RECALIBRATE COMMAND
 20082 00004CF3 E83CFFFFFF          <1> 	call	NEC_OUTPUT
 20083 00004CF8 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
 20084 00004CFA 88DC                <1> 	mov	ah, bl
 20085 00004CFC E833FFFFFF          <1> 	call	NEC_OUTPUT		; OUTPUT THE DRIVE NUMBER
 20086 00004D01 E803000000          <1> 	call	CHK_STAT_2		; GET THE INTERRUPT AND SENSE INT STATUS
 20087 00004D06 58                  <1> 	pop	eax			; THROW AWAY ERROR
 20088                              <1> RC_BACK:
 20089                              <1> 	;pop	cx
 20090                              <1> 	; 11/04/2021
 20091 00004D07 59                  <1> 	pop	ecx
 20092 00004D08 C3                  <1> 	retn
 20093                              <1> 
 20094                              <1> ;-------------------------------------------------------------------------------
 20095                              <1> ; CHK_STAT_2
 20096                              <1> ;	THIS ROUTINE HANDLES THE INTERRUPT RECEIVED AFTER RECALIBRATE,
 20097                              <1> ;	OR SEEK TO THE ADAPTER. THE INTERRUPT IS WAITED FOR, THE
 20098                              <1> ;	INTERRUPT STATUS SENSED, AND THE RESULT RETURNED TO THE CALLER.
 20099                              <1> ;
 20100                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
 20101                              <1> ;-------------------------------------------------------------------------------
 20102                              <1> CHK_STAT_2:
 20103 00004D09 B8[314D0000]        <1>         mov     eax, CS_BACK            ; LOAD NEC_OUTPUT ERROR ADDRESS
 20104 00004D0E 50                  <1> 	push	eax
 20105 00004D0F E828000000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
 20106 00004D14 721A                <1> 	jc	short J34		; IF ERROR, RETURN IT
 20107 00004D16 B408                <1> 	mov	ah, 08h			; SENSE INTERRUPT STATUS COMMAND
 20108 00004D18 E817FFFFFF          <1> 	call	NEC_OUTPUT
 20109 00004D1D E849000000          <1> 	call	RESULTS			; READ IN THE RESULTS
 20110 00004D22 720C                <1> 	jc	short J34
 20111 00004D24 A0[09780100]        <1> 	mov	al, [NEC_STATUS]	; GET THE FIRST STATUS BYTE
 20112 00004D29 2460                <1> 	and	al, 01100000B		; ISOLATE THE BITS
 20113 00004D2B 3C60                <1> 	cmp	al, 01100000B		; TEST FOR CORRECT VALUE
 20114 00004D2D 7403                <1> 	jz	short J35		; IF ERROR, GO MARK IT
 20115 00004D2F F8                  <1> 	clc				; GOOD RETURN
 20116                              <1> J34:
 20117 00004D30 58                  <1> 	pop	eax			; THROW AWAY ERROR RETURN
 20118                              <1> CS_BACK:
 20119 00004D31 C3                  <1> 	retn
 20120                              <1> J35:
 20121 00004D32 800D[08780100]40    <1> 	or	byte [DSKETTE_STATUS], BAD_SEEK
 20122 00004D39 F9                  <1> 	stc				; ERROR RETURN CODE
 20123 00004D3A EBF4                <1> 	jmp	short J34
 20124                              <1> 
 20125                              <1> ;-------------------------------------------------------------------------------
 20126                              <1> ; WAIT_INT
 20127                              <1> ;	THIS ROUTINE WAITS FOR AN INTERRUPT TO OCCUR A TIME OUT ROUTINE
 20128                              <1> ;	TAKES PLACE DURING THE WAIT, SO THAT AN ERROR MAY BE RETURNED
 20129                              <1> ;	IF THE DRIVE IS NOT READY.
 20130                              <1> ;
 20131                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
 20132                              <1> ;-------------------------------------------------------------------------------
 20133                              <1> 
 20134                              <1> ; 17/12/2014
 20135                              <1> ; 2.5 seconds waiting !
 20136                              <1> ;(AWARD BIOS - 1999, WAIT_FDU_INT_LOW, WAIT_FDU_INT_HI)
 20137                              <1> ; amount of time to wait for completion interrupt from NEC.
 20138                              <1> 
 20139                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 20140                              <1> WAIT_INT:
 20141 00004D3C FB                  <1> 	sti				; TURN ON INTERRUPTS, JUST IN CASE
 20142                              <1> 	; 06/08/2022
 20143                              <1> 	;clc				; CLEAR TIMEOUT INDICATOR
 20144                              <1> 	;
 20145                              <1> 	;mov	bl, 10			; CLEAR THE COUNTERS
 20146                              <1> 	;xor	cx, cx			; FOR 2 SECOND WAIT
 20147                              <1> 
 20148                              <1> 	; Modification from AWARD BIOS - 1999 (ATORGS.ASM, WAIT
 20149                              <1> 	;
 20150                              <1> 	;WAIT_FOR_MEM:	
 20151                              <1> 	;	Waits for a bit at a specified memory location pointed
 20152                              <1> 	;	to by ES:[DI] to become set.
 20153                              <1> 	;INPUT:
 20154                              <1> 	;	AH= Mask to test with.
 20155                              <1> 	;	ES:[DI] = memory location to watch.
 20156                              <1> 	;	BH:CX= Number of memory refresh periods to delay.
 20157                              <1> 	;	     (normally 30 microseconds per period.)
 20158                              <1> 
 20159                              <1> 	; waiting for (max.) 2.5 secs in 30 micro units.
 20160                              <1> ;	mov 	cx, WAIT_FDU_INT_LO		; 017798
 20161                              <1> ;;	mov 	bl, WAIT_FDU_INT_HI
 20162                              <1> ;	mov 	bl, WAIT_FDU_INT_HI + 1
 20163                              <1> 	; 27/02/2015
 20164 00004D3D B986450100          <1> 	mov 	ecx, WAIT_FDU_INT_LH	; 83334 (2.5 seconds)		
 20165                              <1> WFMS_CHECK_MEM:
 20166 00004D42 F605[05780100]80    <1> 	test	byte [SEEK_STATUS], INT_FLAG
 20167                              <1> 					; TEST FOR INTERRUPT OCCURRING
 20168 00004D49 7516                <1>         jnz     short J37
 20169                              <1> WFMS_HI:
 20170 00004D4B E461                <1> 	in	al, PORT_B  ; 061h	; SYS1, wait for lo to hi
 20171 00004D4D A810                <1> 	test	al, 010h		; transition on memory
 20172 00004D4F 75FA                <1> 	jnz	short WFMS_HI		; refresh.
 20173                              <1> WFMS_LO:
 20174 00004D51 E461                <1> 	in	al, PORT_B		; SYS1
 20175 00004D53 A810                <1> 	test	al, 010h
 20176 00004D55 74FA                <1> 	jz	short WFMS_LO
 20177 00004D57 E2E9                <1>         loop	WFMS_CHECK_MEM
 20178                              <1> 
 20179                              <1> ;WFMS_OUTER_LP:
 20180                              <1> ;;	or	bl, bl			; check outer counter
 20181                              <1> ;;	jz	short J36A		; WFMS_TIMEOUT
 20182                              <1> ;	dec	bl
 20183                              <1> ;	jz	short J36A	
 20184                              <1> ;	jmp	short WFMS_CHECK_MEM
 20185                              <1> 
 20186                              <1> 	; 17/12/2014
 20187                              <1> 	; 16/12/2014
 20188                              <1> ;	mov	byte [wait_count], 0	; Reset (INT 08H) counter
 20189                              <1> ;J36:
 20190                              <1> ;	test	byte [SEEK_STATUS], INT_FLAG
 20191                              <1> ;					; TEST FOR INTERRUPT OCCURRING
 20192                              <1> ;	jnz	short J37
 20193                              <1> 
 20194                              <1> 	; 16/12/2014
 20195                              <1> 	;loop	J36			; COUNT DOWN WHILE WAITING
 20196                              <1> 	;dec	bl			; SECOND LEVEL COUNTER
 20197                              <1> 	;jnz	short J36
 20198                              <1> ;       cmp     byte [wait_count], 46   ; (46/18.2 seconds)
 20199                              <1> ;	jb	short J36
 20200                              <1> 
 20201                              <1> ;WFMS_TIMEOUT:
 20202                              <1> ;J36A:
 20203 00004D59 800D[08780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT ; NOTHING HAPPENED
 20204 00004D60 F9                  <1> 	stc				; ERROR RETURN
 20205                              <1> J37:
 20206 00004D61 9C                  <1> 	pushf				; SAVE CURRENT CARRY
 20207 00004D62 8025[05780100]7F    <1> 	and	byte [SEEK_STATUS], ~INT_FLAG ; TURN OFF INTERRUPT FLAG
 20208 00004D69 9D                  <1> 	popf				; RECOVER CARRY
 20209 00004D6A C3                  <1> 	retn				; GOOD RETURN CODE
 20210                              <1> 
 20211                              <1> ;-------------------------------------------------------------------------------
 20212                              <1> ; RESULTS
 20213                              <1> ;	THIS ROUTINE WILL READ ANYTHING THAT THE NEC CONTROLLER RETURNS 
 20214                              <1> ;	FOLLOWING AN INTERRUPT.
 20215                              <1> ;
 20216                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
 20217                              <1> ;		AX,BX,CX,DX DESTROYED
 20218                              <1> ;-------------------------------------------------------------------------------
 20219                              <1> RESULTS:
 20220                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 20221 00004D6B 57                  <1> 	push	edi
 20222 00004D6C BF[09780100]        <1> 	mov	edi, NEC_STATUS		; POINTER TO DATA AREA
 20223 00004D71 B307                <1> 	mov	bl, 7			; MAX STATUS BYTES
 20224 00004D73 66BAF403            <1> 	mov	dx, 03F4h		; STATUS PORT
 20225                              <1> 
 20226                              <1> ;-----	WAIT FOR REQUEST FOR MASTER
 20227                              <1> 
 20228                              <1> _R10: 
 20229                              <1> 	; 16/12/2014
 20230                              <1> 	; wait for (max) 0.5 seconds
 20231                              <1> 	;mov	bh, 2			; HIGH ORDER COUNTER
 20232                              <1> 	;xor	cx, cx			; COUNTER
 20233                              <1> 
 20234                              <1> 	;Time to wait while waiting for each byte of NEC results = .5
 20235                              <1> 	;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
 20236                              <1> 	; 27/02/2015
 20237 00004D77 B91B410000          <1> 	mov 	ecx, WAIT_FDU_RESULTS_LH ; 16667  
 20238                              <1> 	;mov	cx, WAIT_FDU_RESULTS_LO  ; 16667
 20239                              <1> 	;mov	bh, WAIT_FDU_RESULTS_HI+1 ; 0+1
 20240                              <1> 
 20241                              <1> WFPSR_OUTER_LP:
 20242                              <1> 	;
 20243                              <1> WFPSR_CHECK_PORT:
 20244                              <1> J39:					; WAIT FOR MASTER
 20245 00004D7C EC                  <1> 	in	al, dx			; GET STATUS
 20246 00004D7D 24C0                <1> 	and	al, 11000000b		; KEEP ONLY STATUS AND DIRECTION
 20247 00004D7F 3CC0                <1> 	cmp	al, 11000000b		; STATUS 1 AND DIRECTION 1 ?
 20248 00004D81 7418                <1> 	jz	short J42		; STATUS AND DIRECTION OK
 20249                              <1> WFPSR_HI:
 20250 00004D83 E461                <1> 	in	al, PORT_B	; 061h	; SYS1	; wait for hi to lo
 20251 00004D85 A810                <1> 	test	al, 010h		; transition on memory
 20252 00004D87 75FA                <1> 	jnz	short WFPSR_HI		; refresh.
 20253                              <1> WFPSR_LO:
 20254 00004D89 E461                <1> 	in	al, PORT_B		; SYS1
 20255 00004D8B A810                <1> 	test	al, 010h
 20256 00004D8D 74FA                <1> 	jz	SHORT WFPSR_LO
 20257 00004D8F E2EB                <1> 	loop	WFPSR_CHECK_PORT
 20258                              <1> 
 20259                              <1> 	;; 27/02/2015
 20260                              <1> 	;;dec	bh
 20261                              <1> 	;;jnz	short WFPSR_OUTER_LP
 20262                              <1> 	;jmp	short WFPSR_TIMEOUT	; fail
 20263                              <1> 
 20264                              <1> 	;;mov	byte [wait_count], 0
 20265                              <1> ;J39:					; WAIT FOR MASTER
 20266                              <1> ;	in	al, dx			; GET STATUS
 20267                              <1> ;	and	al, 11000000b		; KEEP ONLY STATUS AND DIRECTION
 20268                              <1> ;	cmp	al, 11000000b		; STATUS 1 AND DIRECTION 1 ?
 20269                              <1> ;	jz	short J42		; STATUS AND DIRECTION OK
 20270                              <1> 	;loop	J39			; LOOP TILL TIMEOUT
 20271                              <1> 	;dec	bh			; DECREMENT HIGH ORDER COUNTER
 20272                              <1> 	;jnz	short J39		; REPEAT TILL DELAY DONE
 20273                              <1> 	;
 20274                              <1> 	;;cmp	byte [wait_count], 10  ; (10/18.2 seconds)
 20275                              <1> 	;;jb	short J39	
 20276                              <1> 
 20277                              <1> ;WFPSR_TIMEOUT:
 20278 00004D91 800D[08780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT
 20279 00004D98 F9                  <1> 	stc				; SET ERROR RETURN
 20280 00004D99 EB28                <1> 	jmp	short POPRES		; POP REGISTERS AND RETURN
 20281                              <1> 
 20282                              <1> ;-----	READ IN THE STATUS
 20283                              <1> 
 20284                              <1> J42:
 20285 00004D9B EB00                <1> 	jmp	$+2			; I/O DELAY
 20286                              <1> 	;inc	dx			; POINT AT DATA PORT
 20287                              <1> 	; 06/08/2022
 20288 00004D9D FEC2                <1> 	inc	dl
 20289 00004D9F EC                  <1> 	in	al, dx			; GET THE DATA
 20290                              <1> 	; 16/12/2014
 20291                              <1> 	NEWIODELAY
 20292 00004DA0 E6EB                <2>  out 0EBh, al
 20293 00004DA2 8807                <1>         mov     [edi], al		; STORE THE BYTE
 20294 00004DA4 47                  <1> 	inc	edi			; INCREMENT THE POINTER
 20295                              <1> 
 20296                              <1> 	; 16/12/2014
 20297                              <1> ;	push	cx
 20298                              <1> ;	mov	cx, 30
 20299                              <1> ;wdw2:
 20300                              <1> ;	NEWIODELAY
 20301                              <1> ;	loop	wdw2
 20302                              <1> ;	pop	cx
 20303                              <1> 
 20304                              <1> 	;;mov	ecx, 3			; MINIMUM 24 MICROSECONDS FOR NEC
 20305                              <1> 	; 11/04/2021
 20306                              <1> 	;mov	ecx, 2
 20307                              <1> 	; 06/08/2022
 20308 00004DA5 29C9                <1> 	sub	ecx, ecx
 20309 00004DA7 B102                <1> 	mov	cl, 2
 20310 00004DA9 E8B6D5FFFF          <1> 	call	WAITF			; WAIT 30 TO 45 MICROSECONDS
 20311                              <1> 	;dec	dx			; POINT AT STATUS PORT
 20312                              <1> 	; 06/08/2022
 20313 00004DAE FECA                <1> 	dec	dl
 20314 00004DB0 EC                  <1> 	in	al, dx			; GET STATUS
 20315                              <1> 	; 16/12/2014
 20316                              <1> 	NEWIODELAY
 20317 00004DB1 E6EB                <2>  out 0EBh, al
 20318                              <1> 	;
 20319 00004DB3 A810                <1> 	test	al, 00010000b		; TEST FOR NEC STILL BUSY
 20320 00004DB5 740C                <1> 	jz	short POPRES		; RESULTS DONE ?
 20321                              <1> 
 20322 00004DB7 FECB                <1> 	dec	bl			; DECREMENT THE STATUS COUNTER
 20323 00004DB9 75BC                <1>         jnz     short _R10              ; GO BACK FOR MORE
 20324 00004DBB 800D[08780100]20    <1> 	or	byte [DSKETTE_STATUS], BAD_NEC ; TOO MANY STATUS BYTES
 20325 00004DC2 F9                  <1> 	stc				; SET ERROR FLAG
 20326                              <1> 
 20327                              <1> ;-----	RESULT OPERATION IS DONE
 20328                              <1> POPRES:
 20329 00004DC3 5F                  <1> 	pop	edi
 20330 00004DC4 C3                  <1> 	retn				; RETURN WITH CARRY SET
 20331                              <1> 
 20332                              <1> ;-------------------------------------------------------------------------------
 20333                              <1> ; READ_DSKCHNG
 20334                              <1> ;	READS THE STATE OF THE DISK CHANGE LINE.
 20335                              <1> ;
 20336                              <1> ; ON ENTRY:	DI = DRIVE #
 20337                              <1> ;
 20338                              <1> ; ON EXIT:	DI = DRIVE #
 20339                              <1> ;		ZF = 0 : DISK CHANGE LINE INACTIVE
 20340                              <1> ;		ZF = 1 : DISK CHANGE LINE ACTIVE
 20341                              <1> ;		AX,CX,DX DESTROYED
 20342                              <1> ;-------------------------------------------------------------------------------
 20343                              <1> READ_DSKCHNG:
 20344 00004DC5 E8AFFDFFFF          <1> 	call	MOTOR_ON		; TURN ON THE MOTOR IF OFF
 20345 00004DCA 66BAF703            <1> 	mov	dx, 03F7h		; ADDRESS DIGITAL INPUT REGISTER
 20346 00004DCE EC                  <1> 	in	al, dx			; INPUT DIGITAL INPUT REGISTER
 20347 00004DCF A880                <1> 	test	al, DSK_CHG		; CHECK FOR DISK CHANGE LINE ACTIVE
 20348 00004DD1 C3                  <1> 	retn				; RETURN TO CALLER WITH ZERO FLAG SET
 20349                              <1> 
 20350                              <1> fdc_int:  
 20351                              <1> 	  ; 30/07/2015	
 20352                              <1> 	  ; 16/02/2015
 20353                              <1> ;int_0Eh: ; 11/12/2014
 20354                              <1> 
 20355                              <1> ;--- HARDWARE INT 0EH -- ( IRQ LEVEL 6 ) ---------------------------------------
 20356                              <1> ; DISK_INT
 20357                              <1> ;	THIS ROUTINE HANDLES THE DISKETTE INTERRUPT.
 20358                              <1> ;
 20359                              <1> ; ON EXIT:	THE INTERRUPT FLAG IS SET IN @SEEK_STATUS.
 20360                              <1> ;-------------------------------------------------------------------------------
 20361                              <1> DISK_INT_1:
 20362                              <1> 	;push	AX			; SAVE WORK REGISTER
 20363                              <1> 	; 11/04/2021
 20364 00004DD2 50                  <1> 	push	eax
 20365 00004DD3 1E                  <1> 	push	ds
 20366 00004DD4 66B81000            <1> 	mov	ax, KDATA
 20367 00004DD8 8ED8                <1> 	mov 	ds, ax
 20368 00004DDA 800D[05780100]80    <1>         or	byte [SEEK_STATUS], INT_FLAG ; TURN ON INTERRUPT OCCURRED
 20369 00004DE1 B020                <1> 	mov     al, EOI			; END OF INTERRUPT MARKER
 20370 00004DE3 E620                <1> 	out	INTA00, al		; INTERRUPT CONTROL PORT
 20371 00004DE5 1F                  <1> 	pop	ds
 20372                              <1> 	;pop	ax			; RECOVER REGISTER
 20373                              <1> 	; 11/04/2021
 20374 00004DE6 58                  <1> 	pop	eax
 20375 00004DE7 CF                  <1> 	iretd				; RETURN FROM INTERRUPT
 20376                              <1> 
 20377                              <1> ;-------------------------------------------------------------------------------
 20378                              <1> ; DSKETTE_SETUP
 20379                              <1> ;	THIS ROUTINE DOES A PRELIMINARY CHECK TO SEE WHAT TYPE OF
 20380                              <1> ;	DISKETTE DRIVES ARE ATTACH TO THE SYSTEM.
 20381                              <1> ;-------------------------------------------------------------------------------
 20382                              <1> 
 20383                              <1> ; 09/08/2022 - TRDOS 386 Kernel v2.0.5
 20384                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
 20385                              <1> 
 20386                              <1> DSKETTE_SETUP:
 20387                              <1> 	;push	ax			; SAVE REGISTERS
 20388                              <1> 	;push	bx
 20389                              <1> 	;push	cx
 20390 00004DE8 52                  <1> 	push	edx
 20391                              <1> 	;push	di
 20392                              <1> 	;;push	ds
 20393                              <1> 	; 14/12/2014
 20394                              <1> 	;mov	word [DISK_POINTER], MD_TBL6
 20395                              <1> 	;mov	[DISK_POINTER+2], cs
 20396                              <1> 	;
 20397                              <1> 	;or	byte [RTC_WAIT_FLAG], 1	; NO RTC WAIT, FORCE USE OF LOOP
 20398 00004DE9 31FF                <1> 	xor	edi, edi		; INITIALIZE DRIVE POINTER
 20399                              <1> 	; 09/08/2022
 20400                              <1> 	;mov	esi, eax
 20401 00004DEB 31C0                <1> 	xor	eax, eax ; eax = 0
 20402 00004DED 66A3[13780100]      <1> 	mov	[DSK_STATE], ax		; INITIALIZE STATES
 20403 00004DF3 8025[10780100]33    <1> 	and	byte [LASTRATE], ~(STRT_MSK+SEND_MSK) ; CLEAR START & SEND
 20404 00004DFA 800D[10780100]C0    <1> 	or	byte [LASTRATE], SEND_MSK ; INITIALIZE SENT TO IMPOSSIBLE
 20405 00004E01 A2[05780100]        <1> 	mov	[SEEK_STATUS], al	; INDICATE RECALIBRATE NEEDED
 20406 00004E06 A2[07780100]        <1> 	mov	[MOTOR_COUNT], al	; INITIALIZE MOTOR COUNT
 20407 00004E0B A2[06780100]        <1> 	mov	[MOTOR_STATUS], al	; INITIALIZE DRIVES TO OFF STATE
 20408 00004E10 A2[08780100]        <1> 	mov	[DSKETTE_STATUS], al	; NO ERRORS
 20409                              <1> 	;
 20410                              <1> 	; 28/02/2015
 20411                              <1> 	;mov	word [cfd], 100h 
 20412 00004E15 E821F4FFFF          <1> 	call	DSK_RESET
 20413 00004E1A 5A                  <1> 	pop	edx
 20414 00004E1B F8                  <1> 	clc	; 29/05/2016
 20415 00004E1C C3                  <1> 	retn
 20416                              <1> 
 20417                              <1> ;SUP0:
 20418                              <1> ;	call	DRIVE_DET		; DETERMINE DRIVE
 20419                              <1> ;	call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
 20420                              <1> ;	; 02/01/2015
 20421                              <1> ;	;inc	di			; POINT TO NEXT DRIVE
 20422                              <1> ;	;cmp	di, MAX_DRV		; SEE IF DONE
 20423                              <1> ;	;jnz	short SUP0		; REPEAT FOR EACH ORIVE
 20424                              <1> ;       cmp     byte [fd1_type], 0	
 20425                              <1> ;	jna	short sup1
 20426                              <1> ;	or	di, di
 20427                              <1> ;	jnz	short sup1
 20428                              <1> ;	inc	di
 20429                              <1> ;       jmp     short SUP0
 20430                              <1> ;sup1:
 20431                              <1> ;	mov	byte [SEEK_STATUS], 0	; FORCE RECALIBRATE
 20432                              <1> ;	;and	byte [RTC_WAIT_FLAG], 0FEh ; ALLOW FOR RTC WAIT
 20433                              <1> ;	call	SETUP_END		; VARIOUS CLEANUPS
 20434                              <1> ;	;;pop	ds			; RESTORE CALLERS REGISTERS
 20435                              <1> ;	;pop	di
 20436                              <1> ;	pop	edx
 20437                              <1> ;	;pop	cx
 20438                              <1> ;	;pop	bx
 20439                              <1> ;	;pop	ax
 20440                              <1> ;	retn
 20441                              <1> 
 20442                              <1> ;//////////////////////////////////////////////////////
 20443                              <1> ;; END OF DISKETTE I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 20444                              <1> 
 20445                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4) 
 20446                              <1> 
 20447                              <1> ; 11/04/2021
 20448                              <1> ;int13h: ; 21/02/2015
 20449                              <1> 	;pushfd
 20450                              <1> 	;push 	cs
 20451                              <1> 	;;call 	DISK_IO
 20452                              <1> 	;;retn
 20453                              <1> 
 20454                              <1> ;;;;;; DISK I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21/02/2015 ;;;
 20455                              <1> ;/////////////////////////////////////////////////////////////////////
 20456                              <1> 
 20457                              <1> ; DISK I/O - Erdogan Tan (Retro UNIX 386 v1 project)
 20458                              <1> ; 18/02/2016
 20459                              <1> ; 17/02/2016
 20460                              <1> ; 23/02/2015
 20461                              <1> ; 21/02/2015 (unix386.s)
 20462                              <1> ; 22/12/2014 - 14/02/2015 (dsectrm2.s)
 20463                              <1> ;
 20464                              <1> ; Original Source Code:
 20465                              <1> ; DISK ----- 09/25/85 FIXED DISK BIOS
 20466                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
 20467                              <1> ;
 20468                              <1> ; Modifications: by reference of AWARD BIOS 1999 (D1A0622) 
 20469                              <1> ;		 Source Code - ATORGS.ASM, AHDSK.ASM
 20470                              <1> ;
 20471                              <1> 
 20472                              <1> ;The wait for controller to be not busy is 10 seconds.
 20473                              <1> ;10,000,000 / 30 = 333,333. 333,333 decimal = 051615h
 20474                              <1> ;;WAIT_HDU_CTLR_BUSY_LO	equ 1615h		
 20475                              <1> ;;WAIT_HDU_CTLR_BUSY_HI	equ 05h
 20476                              <1> WAIT_HDU_CTRL_BUSY_LH	equ 51615h	; 21/02/2015		
 20477                              <1> 
 20478                              <1> ;The wait for controller to issue completion interrupt is 10 seconds.
 20479                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
 20480                              <1> ;;WAIT_HDU_INT_LO	equ 1615h
 20481                              <1> ;;WAIT_HDU_INT_HI	equ 05h
 20482                              <1> WAIT_HDU_INT_LH		equ 51615h	; 21/02/2015
 20483                              <1> 
 20484                              <1> ;The wait for Data request on read and write longs is
 20485                              <1> ;2000 us. (?)
 20486                              <1> ;;WAIT_HDU_DRQ_LO	equ 1000	; 03E8h
 20487                              <1> ;;WAIT_HDU_DRQ_HI	equ 0
 20488                              <1> WAIT_HDU_DRQ_LH		equ 1000	; 21/02/2015
 20489                              <1> 
 20490                              <1> ; Port 61h (PORT_B)
 20491                              <1> SYS1	equ 61h		; PORT_B  (diskette.inc)
 20492                              <1> 
 20493                              <1> ; 23/12/2014
 20494                              <1> %define CMD_BLOCK       ebp-8  ; 21/02/2015
 20495                              <1> 
 20496                              <1> ;--- INT 13H -------------------------------------------------------------------
 20497                              <1> ;									       :
 20498                              <1> ; FIXED DISK I/O INTERFACE						       :
 20499                              <1> ;									       :
 20500                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO 5 1/4" FIXED DISKS THROUGH           :
 20501                              <1> ;	THE IBM FIXED DISK CONTROLLER.					       :
 20502                              <1> ;									       :
 20503                              <1> ;	THE  BIOS  ROUTINES  ARE  MEANT  TO  BE  ACCESSED  THROUGH	       :
 20504                              <1> ;	SOFTWARE  INTERRUPTS  ONLY.    ANY  ADDRESSES  PRESENT	IN	       :
 20505                              <1> ;	THESE  LISTINGS  ARE  INCLUDED	 ONLY	FOR  COMPLETENESS,	       :
 20506                              <1> ;	NOT  FOR  REFERENCE.  APPLICATIONS   WHICH  REFERENCE  ANY	       :
 20507                              <1> ;	ABSOLUTE  ADDRESSES  WITHIN  THE  CODE	SEGMENTS  OF  BIOS	       :
 20508                              <1> ;	VIOLATE  THE  STRUCTURE  AND  DESIGN  OF  BIOS. 		       :
 20509                              <1> ;									       :
 20510                              <1> ;------------------------------------------------------------------------------:
 20511                              <1> ;									       :
 20512                              <1> ; INPUT  (AH)= HEX COMMAND VALUE					       :
 20513                              <1> ;									       :
 20514                              <1> ;	(AH)= 00H  RESET DISK (DL = 80H,81H) / DISKETTE 		       :
 20515                              <1> ;	(AH)= 01H  READ THE STATUS OF THE LAST DISK OPERATION INTO (AL)        :
 20516                              <1> ;		    NOTE: DL < 80H - DISKETTE				       :
 20517                              <1> ;			  DL > 80H - DISK				       :
 20518                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY 		       :
 20519                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY		       :
 20520                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS				       :
 20521                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK				       :
 20522                              <1> ;	(AH)= 06H  UNUSED						       :
 20523                              <1> ;	(AH)= 07H  UNUSED						       :
 20524                              <1> ;	(AH)= 08H  RETURN THE CURRENT DRIVE PARAMETERS			       :
 20525                              <1> ;	(AH)= 09H  INITIALIZE DRIVE PAIR CHARACTERISTICS		       :
 20526                              <1> ;		    INTERRUPT 41 POINTS TO DATA BLOCK FOR DRIVE 0	       :
 20527                              <1> ;		    INTERRUPT 46 POINTS TO DATA BLOCK FOR DRIVE 1	       :
 20528                              <1> ;	(AH)= 0AH  READ LONG						       :
 20529                              <1> ;	(AH)= 0BH  WRITE LONG  (READ & WRITE LONG ENCOMPASS 512 + 4 BYTES ECC) :
 20530                              <1> ;	(AH)= 0CH  SEEK 						       :
 20531                              <1> ;	(AH)= 0DH  ALTERNATE DISK RESET (SEE DL)			       :
 20532                              <1> ;	(AH)= 0EH  UNUSED						       :
 20533                              <1> ;	(AH)= 0FH  UNUSED						       :
 20534                              <1> ;	(AH)= 10H  TEST DRIVE READY					       :
 20535                              <1> ;	(AH)= 11H  RECALIBRATE						       :
 20536                              <1> ;	(AH)= 12H  UNUSED						       :
 20537                              <1> ;	(AH)= 13H  UNUSED						       :
 20538                              <1> ;	(AH)= 14H  CONTROLLER INTERNAL DIAGNOSTIC			       :
 20539                              <1> ;	(AH)= 15H  READ DASD TYPE					       :
 20540                              <1> ;									       :
 20541                              <1> ;-------------------------------------------------------------------------------
 20542                              <1> ;									       :
 20543                              <1> ;	REGISTERS USED FOR FIXED DISK OPERATIONS			       :
 20544                              <1> ;									       :
 20545                              <1> ;		(DL)	-  DRIVE NUMBER     (80H-81H FOR DISK. VALUE CHECKED)  :
 20546                              <1> ;		(DH)	-  HEAD NUMBER	    (0-15 ALLOWED, NOT VALUE CHECKED)  :
 20547                              <1> ;		(CH)	-  CYLINDER NUMBER  (0-1023, NOT VALUE CHECKED)(SEE CL):
 20548                              <1> ;		(CL)	-  SECTOR NUMBER    (1-17, NOT VALUE CHECKED)	       :
 20549                              <1> ;									       :
 20550                              <1> ;			   NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED     :
 20551                              <1> ;				 IN THE HIGH 2 BITS OF THE CL REGISTER	       :
 20552                              <1> ;				 (10 BITS TOTAL)			       :
 20553                              <1> ;									       :
 20554                              <1> ;		(AL)	-  NUMBER OF SECTORS (MAXIMUM POSSIBLE RANGE 1-80H,    :
 20555                              <1> ;					      FOR READ/WRITE LONG 1-79H)       :
 20556                              <1> ;									       :
 20557                              <1> ;		(ES:BX) -  ADDRESS OF BUFFER FOR READS AND WRITES,	       :
 20558                              <1> ;			   (NOT REQUIRED FOR VERIFY)			       :
 20559                              <1> ;									       :
 20560                              <1> ;		FORMAT (AH=5) ES:BX POINTS TO A 512 BYTE BUFFER. THE FIRST     :
 20561                              <1> ;			   2*(SECTORS/TRACK) BYTES CONTAIN F,N FOR EACH SECTOR.:
 20562                              <1> ;			   F = 00H FOR A GOOD SECTOR			       :
 20563                              <1> ;			       80H FOR A BAD SECTOR			       :
 20564                              <1> ;			   N = SECTOR NUMBER				       :
 20565                              <1> ;			   FOR AN INTERLEAVE OF 2 AND 17 SECTORS/TRACK	       :
 20566                              <1> ;			   THE TABLE SHOULD BE: 			       :
 20567                              <1> ;									       :
 20568                              <1> ;		   DB	   00H,01H,00H,0AH,00H,02H,00H,0BH,00H,03H,00H,0CH     :
 20569                              <1> ;		   DB	   00H,04H,00H,0DH,00H,05H,00H,0EH,00H,06H,00H,0FH     :
 20570                              <1> ;		   DB	   00H,07H,00H,10H,00H,08H,00H,11H,00H,09H	       :
 20571                              <1> ;									       :
 20572                              <1> ;-------------------------------------------------------------------------------
 20573                              <1> 
 20574                              <1> ;-------------------------------------------------------------------------------
 20575                              <1> ; OUTPUT								       :
 20576                              <1> ;	AH = STATUS OF CURRENT OPERATION				       :
 20577                              <1> ;	     STATUS BITS ARE DEFINED IN THE EQUATES BELOW		       :
 20578                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN)			       :
 20579                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)			       :
 20580                              <1> ;									       :
 20581                              <1> ;	NOTE:	ERROR 11H  INDICATES THAT THE DATA READ HAD A RECOVERABLE      :
 20582                              <1> ;		ERROR WHICH WAS CORRECTED BY THE ECC ALGORITHM.  THE DATA      :
 20583                              <1> ;		IS PROBABLY GOOD,   HOWEVER THE BIOS ROUTINE INDICATES AN      :
 20584                              <1> ;		ERROR TO ALLOW THE CONTROLLING PROGRAM A CHANCE TO DECIDE      :
 20585                              <1> ;		FOR ITSELF.  THE  ERROR  MAY  NOT  RECUR  IF  THE DATA IS      :
 20586                              <1> ;		REWRITTEN.						       :
 20587                              <1> ;									       :
 20588                              <1> ;	IF DRIVE PARAMETERS WERE REQUESTED (DL >= 80H), 		       :
 20589                              <1> ;	   INPUT:							       :
 20590                              <1> ;	     (DL) = DRIVE NUMBER					       :	
 20591                              <1> ;	     ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)						       :	 	
 20592                              <1> ;	     EBX = Buffer address for fixed disk parameters table (32 bytes)   :
 20593                              <1> ;	   OUTPUT:							       :
 20594                              <1> ;	     (DL) = NUMBER OF CONSECUTIVE ACKNOWLEDGING DRIVES ATTACHED (1-2)  :
 20595                              <1> ;		    (CONTROLLER CARD ZERO TALLY ONLY)			       :
 20596                              <1> ;	     (DH) = MAXIMUM USEABLE VALUE FOR HEAD NUMBER		       :
 20597                              <1> ;	     (CH) = MAXIMUM USEABLE VALUE FOR CYLINDER NUMBER		       :
 20598                              <1> ;	     (CL) = MAXIMUM USEABLE VALUE FOR SECTOR NUMBER		       :
 20599                              <1> ;		    AND CYLINDER NUMBER HIGH BITS			       :
 20600                              <1> ;									       :
 20601                              <1> ;	IF READ DASD TYPE WAS REQUESTED,				       :
 20602                              <1> ;									       :
 20603                              <1> ;	AH = 0 - NOT PRESENT						       :
 20604                              <1> ;	     1 - DISKETTE - NO CHANGE LINE AVAILABLE			       :
 20605                              <1> ;	     2 - DISKETTE - CHANGE LINE AVAILABLE			       :
 20606                              <1> ;	     3 - FIXED DISK						       :
 20607                              <1> ;									       :
 20608                              <1> ;	CX,DX = NUMBER OF 512 BYTE BLOCKS WHEN AH = 3			       :
 20609                              <1> ;									       :
 20610                              <1> ;	REGISTERS WILL BE PRESERVED EXCEPT WHEN THEY ARE USED TO RETURN        :
 20611                              <1> ;	INFORMATION.							       :
 20612                              <1> ;									       :
 20613                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISK CODE, THE APPROPRIATE        :
 20614                              <1> ;		ACTION IS TO RESET THE DISK, THEN RETRY THE OPERATION.	       :
 20615                              <1> ;									       :
 20616                              <1> ;-------------------------------------------------------------------------------
 20617                              <1> 
 20618                              <1> SENSE_FAIL	EQU	0FFH		; NOT IMPLEMENTED
 20619                              <1> NO_ERR		EQU	0E0H		; STATUS ERROR/ERROR REGISTER=0
 20620                              <1> WRITE_FAULT	EQU	0CCH		; WRITE FAULT ON SELECTED DRIVE
 20621                              <1> UNDEF_ERR	EQU	0BBH		; UNDEFINED ERROR OCCURRED
 20622                              <1> NOT_RDY 	EQU	0AAH		; DRIVE NOT READY
 20623                              <1> TIME_OUT	EQU	80H		; ATTACHMENT FAILED TO RESPOND
 20624                              <1> BAD_SEEK	EQU	40H		; SEEK OPERATION FAILED
 20625                              <1> BAD_CNTLR	EQU	20H		; CONTROLLER HAS FAILED
 20626                              <1> DATA_CORRECTED	EQU	11H		; ECC CORRECTED DATA ERROR
 20627                              <1> BAD_ECC 	EQU	10H		; BAD ECC ON DISK READ
 20628                              <1> BAD_TRACK	EQU	0BH		; NOT IMPLEMENTED
 20629                              <1> BAD_SECTOR	EQU	0AH		; BAD SECTOR FLAG DETECTED
 20630                              <1> ;DMA_BOUNDARY	EQU	09H		; DATA EXTENDS TOO FAR
 20631                              <1> INIT_FAIL	EQU	07H		; DRIVE PARAMETER ACTIVITY FAILED
 20632                              <1> BAD_RESET	EQU	05H		; RESET FAILED
 20633                              <1> ;RECORD_NOT_FND	EQU	04H		; REQUESTED SECTOR NOT FOUND
 20634                              <1> ;BAD_ADDR_MARK	EQU	02H		; ADDRESS MARK NOT FOUND
 20635                              <1> ;BAD_CMD 	EQU	01H		; BAD COMMAND PASSED TO DISK I/O
 20636                              <1> 
 20637                              <1> ;--------------------------------------------------------
 20638                              <1> ;							:
 20639                              <1> ; FIXED DISK PARAMETER TABLE				:
 20640                              <1> ;  -  THE TABLE IS COMPOSED OF A BLOCK DEFINED AS:	:
 20641                              <1> ;							:
 20642                              <1> ;  +0	(1 WORD) - MAXIMUM NUMBER OF CYLINDERS		:
 20643                              <1> ;  +2	(1 BYTE) - MAXIMUM NUMBER OF HEADS		:
 20644                              <1> ;  +3	(1 WORD) - NOT USED/SEE PC-XT			:
 20645                              <1> ;  +5	(1 WORD) - STARTING WRITE PRECOMPENSATION CYL	:
 20646                              <1> ;  +7	(1 BYTE) - MAXIMUM ECC DATA BURST LENGTH	:
 20647                              <1> ;  +8	(1 BYTE) - CONTROL BYTE 			:
 20648                              <1> ;		   BIT	  7 DISABLE RETRIES -OR-	:
 20649                              <1> ;		   BIT	  6 DISABLE RETRIES		:
 20650                              <1> ;		   BIT	  3 MORE THAN 8 HEADS		:
 20651                              <1> ;  +9	(3 BYTES)- NOT USED/SEE PC-XT			:
 20652                              <1> ; +12	(1 WORD) - LANDING ZONE 			:
 20653                              <1> ; +14	(1 BYTE) - NUMBER OF SECTORS/TRACK		:
 20654                              <1> ; +15	(1 BYTE) - RESERVED FOR FUTURE USE		:
 20655                              <1> ;							:
 20656                              <1> ;	 - TO DYNAMICALLY DEFINE A SET OF PARAMETERS	:
 20657                              <1> ;	   BUILD A TABLE FOR UP TO 15 TYPES AND PLACE	:
 20658                              <1> ;	   THE CORRESPONDING VECTOR INTO INTERRUPT 41	:
 20659                              <1> ;	   FOR DRIVE 0 AND INTERRUPT 46 FOR DRIVE 1.	:
 20660                              <1> ;							:
 20661                              <1> ;--------------------------------------------------------
 20662                              <1> 
 20663                              <1> ;--------------------------------------------------------
 20664                              <1> ;							:
 20665                              <1> ; HARDWARE SPECIFIC VALUES				:
 20666                              <1> ;							:
 20667                              <1> ;  -  CONTROLLER I/O PORT				:
 20668                              <1> ;							:
 20669                              <1> ;     > WHEN READ FROM: 				:
 20670                              <1> ;	HF_PORT+0 - READ DATA (FROM CONTROLLER TO CPU)	:
 20671                              <1> ;	HF_PORT+1 - GET ERROR REGISTER			:
 20672                              <1> ;	HF_PORT+2 - GET SECTOR COUNT			:
 20673                              <1> ;	HF_PORT+3 - GET SECTOR NUMBER			:
 20674                              <1> ;	HF_PORT+4 - GET CYLINDER LOW			:
 20675                              <1> ;	HF_PORT+5 - GET CYLINDER HIGH (2 BITS)		:
 20676                              <1> ;	HF_PORT+6 - GET SIZE/DRIVE/HEAD 		:
 20677                              <1> ;	HF_PORT+7 - GET STATUS REGISTER 		:
 20678                              <1> ;							:
 20679                              <1> ;     > WHEN WRITTEN TO:				:
 20680                              <1> ;	HF_PORT+0 - WRITE DATA (FROM CPU TO CONTROLLER) :
 20681                              <1> ;	HF_PORT+1 - SET PRECOMPENSATION CYLINDER	:
 20682                              <1> ;	HF_PORT+2 - SET SECTOR COUNT			:
 20683                              <1> ;	HF_PORT+3 - SET SECTOR NUMBER			:
 20684                              <1> ;	HF_PORT+4 - SET CYLINDER LOW			:
 20685                              <1> ;	HF_PORT+5 - SET CYLINDER HIGH (2 BITS)		:
 20686                              <1> ;	HF_PORT+6 - SET SIZE/DRIVE/HEAD 		:
 20687                              <1> ;	HF_PORT+7 - SET COMMAND REGISTER		:
 20688                              <1> ;							:
 20689                              <1> ;--------------------------------------------------------
 20690                              <1> 
 20691                              <1> ;HF_PORT 	EQU	01F0H	; DISK PORT
 20692                              <1> ;HF1_PORT	equ	0170h	
 20693                              <1> ;HF_REG_PORT	EQU	03F6H
 20694                              <1> ;HF1_REG_PORT	equ	0376h
 20695                              <1> 
 20696                              <1> HDC1_BASEPORT	equ	1F0h
 20697                              <1> HDC2_BASEPORT	equ	170h		
 20698                              <1> 
 20699 00004E1D 90                  <1> align 2
 20700                              <1> 
 20701                              <1> ;-----		STATUS REGISTER
 20702                              <1> 
 20703                              <1> ST_ERROR	EQU	00000001B	;
 20704                              <1> ST_INDEX	EQU	00000010B	;
 20705                              <1> ST_CORRCTD	EQU	00000100B	; ECC CORRECTION SUCCESSFUL
 20706                              <1> ST_DRQ		EQU	00001000B	;
 20707                              <1> ST_SEEK_COMPL	EQU	00010000B	; SEEK COMPLETE
 20708                              <1> ST_WRT_FLT	EQU	00100000B	; WRITE FAULT
 20709                              <1> ST_READY	EQU	01000000B	;
 20710                              <1> ST_BUSY 	EQU	10000000B	;
 20711                              <1> 
 20712                              <1> ;-----		ERROR REGISTER
 20713                              <1> 
 20714                              <1> ERR_DAM 	EQU	00000001B	; DATA ADDRESS MARK NOT FOUND
 20715                              <1> ERR_TRK_0	EQU	00000010B	; TRACK 0 NOT FOUND ON RECAL
 20716                              <1> ERR_ABORT	EQU	00000100B	; ABORTED COMMAND
 20717                              <1> ;		EQU	00001000B	; NOT USED
 20718                              <1> ERR_ID		EQU	00010000B	; ID NOT FOUND
 20719                              <1> ;		EQU	00100000B	; NOT USED
 20720                              <1> ERR_DATA_ECC	EQU	01000000B
 20721                              <1> ERR_BAD_BLOCK	EQU	10000000B
 20722                              <1> 
 20723                              <1> 
 20724                              <1> RECAL_CMD	EQU	00010000B	; DRIVE RECAL	(10H)
 20725                              <1> READ_CMD	EQU	00100000B	;	READ	(20H)
 20726                              <1> WRITE_CMD	EQU	00110000B	;	WRITE	(30H)
 20727                              <1> VERIFY_CMD	EQU	01000000B	;	VERIFY	(40H)
 20728                              <1> FMTTRK_CMD	EQU	01010000B	; FORMAT TRACK	(50H)
 20729                              <1> INIT_CMD	EQU	01100000B	;   INITIALIZE	(60H)
 20730                              <1> SEEK_CMD	EQU	01110000B	;	SEEK	(70H)
 20731                              <1> DIAG_CMD	EQU	10010000B	; DIAGNOSTIC	(90H)
 20732                              <1> SET_PARM_CMD	EQU	10010001B	; DRIVE PARMS	(91H)
 20733                              <1> NO_RETRIES	EQU	00000001B	; CHD MODIFIER	(01H)
 20734                              <1> ECC_MODE	EQU	00000010B	; CMD MODIFIER	(02H)
 20735                              <1> BUFFER_MODE	EQU	00001000B	; CMD MODIFIER	(08H)
 20736                              <1> 
 20737                              <1> ;MAX_FILE	EQU	2
 20738                              <1> ;S_MAX_FILE	EQU	2
 20739                              <1> MAX_FILE	equ	4		; 22/12/2014
 20740                              <1> S_MAX_FILE	equ	4		; 22/12/2014
 20741                              <1> 
 20742                              <1> DELAY_1 	EQU	25H		; DELAY FOR OPERATION COMPLETE
 20743                              <1> DELAY_2 	EQU	0600H		; DELAY FOR READY
 20744                              <1> DELAY_3 	EQU	0100H		; DELAY FOR DATA REQUEST
 20745                              <1> 
 20746                              <1> HF_FAIL 	EQU	08H		; CMOS FLAG IN BYTE 0EH
 20747                              <1> 
 20748                              <1> ;-----		COMMAND BLOCK REFERENCE
 20749                              <1> 
 20750                              <1> ;CMD_BLOCK      EQU     BP-8            ; @CMD_BLOCK REFERENCES BLOCK HEAD IN SS
 20751                              <1> 					;  (BP) POINTS TO COMMAND BLOCK TAIL
 20752                              <1> 					;	AS DEFINED BY THE "ENTER" PARMS
 20753                              <1> ; 19/12/2014
 20754                              <1> ORG_VECTOR	equ	4*13h		; INT 13h vector
 20755                              <1> DISK_VECTOR	equ	4*40h		; INT 40h vector (for floppy disks)
 20756                              <1> ;HDISK_INT	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
 20757                              <1> ;HDISK_INT1	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
 20758                              <1> ;HDISK_INT2	equ	4*77h		; Secondary HDC - Hardware interrupt (IRQ15)
 20759                              <1> ;HF_TBL_VEC	equ	4*41h		; Pointer to 1st fixed disk parameter table
 20760                              <1> ;HF1_TBL_VEC	equ	4*46h		; Pointer to 2nd fixed disk parameter table
 20761                              <1> 
 20762                              <1> align 2
 20763                              <1> 
 20764                              <1> ;----------------------------------------------------------------
 20765                              <1> ; FIXED DISK I/O SETUP						:
 20766                              <1> ;								:
 20767                              <1> ;  -  ESTABLISH TRANSFER VECTORS FOR THE FIXED DISK		:
 20768                              <1> ;  -  PERFORM POWER ON DIAGNOSTICS				:
 20769                              <1> ;     SHOULD AN ERROR OCCUR A "1701" MESSAGE IS DISPLAYED       :
 20770                              <1> ;								:
 20771                              <1> ;----------------------------------------------------------------
 20772                              <1> 
 20773                              <1> ; 09/08/2022
 20774                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 20775                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
 20776                              <1> 
 20777                              <1> DISK_SETUP:
 20778                              <1> 	;CLI
 20779                              <1> 	;;mov	ax, ABS0 		; GET ABSOLUTE SEGMENT
 20780                              <1> 	;xor	ax, ax
 20781                              <1> 	;mov	ds, ax			; SET SEGMENT REGISTER
 20782                              <1> 	;mov	ax, [ORG_VECTOR] 	; GET DISKETTE VECTOR
 20783                              <1> 	;mov	[DISK_VECTOR], ax	;  INTO INT 40H
 20784                              <1> 	;mov	ax, [ORG_VECTOR+2]
 20785                              <1> 	;mov	[DISK_VECTOR+2], ax
 20786                              <1> 	;mov	word [ORG_VECTOR], DISK_IO ; FIXED DISK HANDLER
 20787                              <1> 	;mov	[ORG_VECTOR+2], cs
 20788                              <1> 	; 1st controller (primary master, slave)   - IRQ 14
 20789                              <1> 	;;mov	word [HDISK_INT], HD_INT   ; FIXED DISK INTERRUPT
 20790                              <1> 	;mov	word [HDISK_INT1], HD_INT  ;
 20791                              <1> 	;;mov	[HDISK_INT+2], cs
 20792                              <1> 	;mov	[HDISK_INT1+2], cs
 20793                              <1> 	; 2nd controller (secondary master, slave) - IRQ 15
 20794                              <1> 	;mov	word [HDISK_INT2], HD1_INT ;
 20795                              <1> 	;mov	[HDISK_INT2+2], cs
 20796                              <1> 	;
 20797                              <1> 	;;mov	word [HF_TBL_VEC], HD0_DPT	; PARM TABLE DRIVE 80
 20798                              <1> 	;;mov	word [HF_TBL_VEC+2], DPT_SEGM
 20799                              <1> 	;;mov	word [HF1_TBL_VEC], HD1_DPT	; PARM TABLE DRIVE 81
 20800                              <1> 	;;mov	word [HF1_TBL_VEC+2], DPT_SEGM
 20801                              <1> 	;push	cs
 20802                              <1> 	;pop	ds
 20803                              <1> 	;mov	word [HDPM_TBL_VEC], HD0_DPT	; PARM TABLE DRIVE 80h
 20804                              <1> 	;mov	word [HDPM_TBL_VEC+2], DPT_SEGM
 20805 00004E1E C705[1C780100]0000- <1> 	mov 	dword [HDPM_TBL_VEC], (DPT_SEGM*16)+HD0_DPT
 20806 00004E26 0900                <1>
 20807                              <1> 	;mov	word [HDPS_TBL_VEC], HD1_DPT	; PARM TABLE DRIVE 81h
 20808                              <1> 	;mov	word [HDPS_TBL_VEC+2], DPT_SEGM
 20809 00004E28 C705[20780100]2000- <1> 	mov 	dword [HDPS_TBL_VEC], (DPT_SEGM*16)+HD1_DPT
 20810 00004E30 0900                <1>
 20811                              <1> 	;mov	word [HDSM_TBL_VEC], HD2_DPT	; PARM TABLE DRIVE 82h
 20812                              <1> 	;mov	word [HDSM_TBL_VEC+2], DPT_SEGM
 20813 00004E32 C705[24780100]4000- <1> 	mov 	dword [HDSM_TBL_VEC], (DPT_SEGM*16)+HD2_DPT
 20814 00004E3A 0900                <1>
 20815                              <1> 	;mov	word [HDSS_TBL_VEC], HD3_DPT	; PARM TABLE DRIVE 83h
 20816                              <1> 	;mov	word [HDSS_TBL_VEC+2], DPT_SEGM
 20817 00004E3C C705[28780100]6000- <1> 	mov 	dword [HDSS_TBL_VEC], (DPT_SEGM*16)+HD3_DPT
 20818 00004E44 0900                <1>
 20819                              <1> 	;
 20820                              <1> 	;;in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
 20821                              <1> 	;;;and	al, 0BFh
 20822                              <1> 	;;and	al, 3Fh			; enable IRQ 14 and IRQ 15
 20823                              <1> 	;;;jmp	$+2
 20824                              <1> 	;;IODELAY
 20825                              <1> 	;;out	INTB01, al
 20826                              <1> 	;;IODELAY
 20827                              <1> 	;;in	al, INTA01		; LET INTERRUPTS PASS THRU TO
 20828                              <1> 	;;and	al, 0FBh 		;  SECOND CHIP
 20829                              <1> 	;;;jmp	$+2
 20830                              <1> 	;;IODELAY
 20831                              <1> 	;;out	INTA01, al
 20832                              <1> 	;
 20833                              <1> 	;sti
 20834                              <1> 	;;push	ds			; MOVE ABS0 POINTER TO
 20835                              <1> 	;;pop	es			; EXTRA SEGMENT POINTER
 20836                              <1> 	;;;call	DDS			; ESTABLISH DATA SEGMENT
 20837                              <1> 	;;mov	byte [DISK_STATUS1], 0 	; RESET THE STATUS INDICATOR
 20838                              <1> 	;;mov	byte [HF_NUM], 0	; ZERO NUMBER OF FIXED DISKS
 20839                              <1> 	;;mov	byte [CONTROL_BYTE], 0
 20840                              <1> 	;;mov	byte [PORT_OFF], 0	; ZERO CARD OFFSET
 20841                              <1> 	; 20/12/2014 - private code by Erdogan Tan
 20842                              <1> 		      ; (out of original PC-AT, PC-XT BIOS code)
 20843                              <1> 	;mov	si, hd0_type
 20844 00004E46 BE[FE640000]        <1> 	mov	esi, hd0_type
 20845                              <1> 	;;mov	cx, 4
 20846                              <1> 	;mov	ecx, 4
 20847                              <1> 	; 06/08/2022
 20848 00004E4B 29C9                <1> 	sub	ecx, ecx
 20849 00004E4D B104                <1> 	mov	cl, 4
 20850                              <1> hde_l:
 20851 00004E4F AC                  <1> 	lodsb
 20852 00004E50 3C80                <1> 	cmp	al, 80h			; 8?h = existing
 20853 00004E52 7206                <1> 	jb	short _L4
 20854 00004E54 FE05[18780100]      <1> 	inc	byte [HF_NUM]		; + 1 hard (fixed) disk drives
 20855                              <1> _L4: ; 26/02/2015
 20856 00004E5A E2F3                <1> 	loop	hde_l	
 20857                              <1> ;_L4:					; 0 <= [HF_NUM] =< 4
 20858                              <1> ;L4:
 20859                              <1> 	;; 31/12/2014 - cancel controller diagnostics here
 20860                              <1> 	;;;mov 	cx, 3  ; 26/12/2014 (Award BIOS 1999)
 20861                              <1> 	;;mov 	cl, 3
 20862                              <1> 	;;
 20863                              <1> 	;;mov	DL, 80H			; CHECK THE CONTROLLER
 20864                              <1> ;;hdc_dl:
 20865                              <1> 	;;mov	AH, 14H			; USE CONTROLLER DIAGNOSTIC COMMAND
 20866                              <1> 	;;INT	13H			; CALL BIOS WITH DIAGNOSTIC COMMAND
 20867                              <1> 	;;;jc	short CTL_ERRX		; DISPLAY ERROR MESSAGE IF BAD RETURN
 20868                              <1> 	;;;jc	short POD_DONE ;22/12/2014
 20869                              <1> 	;;jnc	short hdc_reset0
 20870                              <1> 	;;loop	hdc_dl
 20871                              <1> 	;;; 27/12/2014
 20872                              <1> 	;;stc
 20873                              <1> 	;;retn
 20874                              <1> 	;
 20875                              <1> ;;hdc_reset0:
 20876                              <1> 	; 18/01/2015
 20877 00004E5C 8A0D[18780100]      <1> 	mov	cl, [HF_NUM]
 20878 00004E62 20C9                <1> 	and	cl, cl
 20879 00004E64 740D                <1> 	jz	short POD_DONE
 20880                              <1> 	;
 20881 00004E66 B27F                <1> 	mov	dl, 7Fh
 20882                              <1> hdc_reset1:
 20883 00004E68 FEC2                <1> 	inc	dl
 20884                              <1> 	;; 31/12/2015
 20885                              <1> 	;;push	dx
 20886                              <1> 	;;push	cx
 20887                              <1> 	;;push	ds
 20888                              <1> 	;;sub	ax, ax
 20889                              <1> 	;;mov	ds, ax
 20890                              <1> 	;;mov	ax, [TIMER_LOW]		; GET START TIMER COUNTS
 20891                              <1> 	;;pop	ds
 20892                              <1> 	;;mov	bx, ax
 20893                              <1> 	;;add	ax, 6*182		; 60 SECONDS* 18.2
 20894                              <1> 	;;mov	cx, ax
 20895                              <1> 	;;mov	word [wait_count], 0	; 22/12/2014 (reset wait counter)
 20896                              <1> 	;;
 20897                              <1> 	;; 31/12/2014 - cancel HD_RESET_1
 20898                              <1> 	;;call	HD_RESET_1		; SET UP DRIVE 0, (1,2,3)
 20899                              <1> 	;;pop	cx
 20900                              <1> 	;;pop	dx
 20901                              <1> 	;;
 20902                              <1> 	; 18/01/2015
 20903 00004E6A B40D                <1> 	mov	ah, 0Dh ; ALTERNATE RESET
 20904                              <1> 	;int	13h
 20905 00004E6C E8CC000000          <1> 	call	int13h
 20906 00004E71 E2F5                <1> 	loop	hdc_reset1
 20907                              <1> 	;clc 	; 29/05/2016
 20908                              <1> POD_DONE:
 20909 00004E73 C3                  <1> 	retn
 20910                              <1> 
 20911                              <1> ;;-----	POD_ERROR
 20912                              <1> 
 20913                              <1> ;;CTL_ERRX:
 20914                              <1> ;	;mov	SI,OFFSET F1782 	; CONTROLLER ERROR
 20915                              <1> ;	;call	SET_FAIL		; DO NOT IPL FROM DISK
 20916                              <1> ;	;call	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
 20917                              <1> ;	;jmp	short POD_DONE
 20918                              <1> 
 20919                              <1> ;;HD_RESET_1:
 20920                              <1> ;;	;push	BX			; SAVE TIMER LIMITS
 20921                              <1> ;;	;push	CX
 20922                              <1> ;;RES_1: mov	AH,09H			; SET DRIVE PARAMETERS
 20923                              <1> ;;	INT	13H
 20924                              <1> ;;	jc	short RES_2
 20925                              <1> ;;	mov	AH,11h			; RECALIBRATE DRIVE
 20926                              <1> ;;	INT	13H
 20927                              <1> ;;	jnc	short RES_CK		; DRIVE OK
 20928                              <1> ;;RES_2: ;call	POD_TCHK		; CHECK TIME OUT
 20929                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
 20930                              <1> ;;					; (30 seconds)		
 20931                              <1> ;;	;cmc
 20932                              <1> ;;	;jnc	short RES_1
 20933                              <1> ;;	jb	short RES_1
 20934                              <1> ;;;RES_FL: ;mov	SI,OFFSET F1781 	; INDICATE DISK 1 FAILURE;
 20935                              <1> ;;	;test	DL,1
 20936                              <1> ;;	;jnz	short RES_E1
 20937                              <1> ;;	;mov	SI,OFFSET F1780 	; INDICATE DISK 0 FAILURE
 20938                              <1> ;;	;call	SET_FAIL		; DO NOT TRY TO IPL DISK 0
 20939                              <1> ;;	;jmp	SHORT RES_E1
 20940                              <1> ;;RES_ER: ; 22/12/2014
 20941                              <1> ;;RES_OK:
 20942                              <1> ;;	;pop	CX			; RESTORE TIMER LIMITS
 20943                              <1> ;;	;pop	BX
 20944                              <1> ;;	retn
 20945                              <1> ;;
 20946                              <1> ;;RES_RS: mov	AH,00H			; RESET THE DRIVE
 20947                              <1> ;;	INT	13H
 20948                              <1> ;;RES_CK: mov	AH,08H			; GET MAX CYLINDER,HEAD,SECTOR
 20949                              <1> ;;	mov	BL,DL			; SAVE DRIVE CODE
 20950                              <1> ;;	INT	13H
 20951                              <1> ;;	jc	short RES_ER
 20952                              <1> ;;	mov	[NEC_STATUS],CX 	; SAVE MAX CYLINDER, SECTOR
 20953                              <1> ;;	mov	DL,BL			; RESTORE DRIVE CODE
 20954                              <1> ;;RES_3: mov	AX,0401H		; VERIFY THE LAST SECTOR
 20955                              <1> ;;	INT	13H
 20956                              <1> ;;	jnc	short RES_OK		; VERIFY OK
 20957                              <1> ;;	cmp	AH,BAD_SECTOR		; OK ALSO IF JUST ID READ
 20958                              <1> ;;	JE	short RES_OK
 20959                              <1> ;;	cmp	AH,DATA_CORRECTED
 20960                              <1> ;;	JE	short RES_OK
 20961                              <1> ;;	cmp	AH,BAD_ECC
 20962                              <1> ;;	JE	short RES_OK
 20963                              <1> ;;	;call	POD_TCHK		; CHECK FOR TIME OUT
 20964                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
 20965                              <1> ;;					; (60 seconds)		
 20966                              <1> ;;	cmc
 20967                              <1> ;;	jc	short RES_ER		; FAILED
 20968                              <1> ;;	mov	CX,[NEC_STATUS] 	; GET SECTOR ADDRESS, AND CYLINDER
 20969                              <1> ;;	mov	AL,CL			; SEPARATE OUT SECTOR NUMBER
 20970                              <1> ;;	and	AL,3FH
 20971                              <1> ;;	dec	AL			; TRY PREVIOUS ONE
 20972                              <1> ;;	jz	short RES_RS		; WE'VE TRIED ALL SECTORS ON TRACK
 20973                              <1> ;;	and	CL,0C0H 		; KEEP CYLINDER BITS
 20974                              <1> ;;	OR	CL,AL			; MERGE SECTOR WITH CYLINDER BITS
 20975                              <1> ;;	mov	[NEC_STATUS],CX 	; SAVE CYLINDER, NEW SECTOR NUMBER
 20976                              <1> ;;	jmp	short RES_3		; TRY AGAIN
 20977                              <1> ;;;RES_ER: mov	SI,OFFSET F1791 	; INDICATE DISK 1 ERROR
 20978                              <1> ;;	;test	DL,1
 20979                              <1> ;;	;jnz	short RES_E1
 20980                              <1> ;;	;mov	SI,OFFSET F1790 	; INDICATE DISK 0 ERROR
 20981                              <1> ;;;RES_E1:
 20982                              <1> ;;	;call	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
 20983                              <1> ;;;RES_OK:
 20984                              <1> ;;	;pop	CX			; RESTORE TIMER LIMITS
 20985                              <1> ;;	;pop	BX
 20986                              <1> ;;	;retn
 20987                              <1> ;
 20988                              <1> ;;SET_FAIL:
 20989                              <1> ;	;mov	AX,X*(CMOS_DIAG+NMI)	; GET CMOS ERROR BYTE
 20990                              <1> ;	;call	CMOS_READ
 20991                              <1> ;	;OR	AL,HF_FAIL		; SET DO NOT IPL FROM DISK FLAG
 20992                              <1> ;	;xchg	AH,AL			; SAVE IT
 20993                              <1> ;	;call	CMOS_WRITE		; PUT IT OUT
 20994                              <1> ;	;retn
 20995                              <1> ;
 20996                              <1> ;;POD_TCHK:				; CHECK FOR 30 SECOND TIME OUT
 20997                              <1> ;	;pop	AX			; SAVE RETURN
 20998                              <1> ;	;pop	CX			; GET TIME OUT LIMITS
 20999                              <1> ;	;pop	BX
 21000                              <1> ;	;push	BX			; AND SAVE THEM AGAIN
 21001                              <1> ;	;push	CX
 21002                              <1> ;	;push	AX
 21003                              <1> ;	;push	ds
 21004                              <1> ;	;xor	ax, ax
 21005                              <1> ;	;mov	ds, ax			; RESTORE RETURN
 21006                              <1> ;	;mov	AX, [TIMER_LOW]		; AX = CURRENT TIME
 21007                              <1> ;	;				; BX = START TIME
 21008                              <1> ;	;				; CX = END TIME
 21009                              <1> ;	;pop	ds
 21010                              <1> ;	;cmp	BX,CX
 21011                              <1> ;	;JB	short TCHK1		; START < END
 21012                              <1> ;	;cmp	BX,AX
 21013                              <1> ;	;JB	short TCHKG		; END < START < CURRENT
 21014                              <1> ;	;jmp	SHORT TCHK2		; END, CURRENT < START
 21015                              <1> ;;TCHK1: cmp	AX,BX
 21016                              <1> ;;	JB	short TCHKNG		; CURRENT < START < END
 21017                              <1> ;;TCHK2: cmp	AX,CX
 21018                              <1> ;;	JB	short TCHKG		; START < CURRENT < END
 21019                              <1> ;;					; OR CURRENT < END < START
 21020                              <1> ;;TCHKNG: STC				; CARRY SET INDICATES TIME OUT
 21021                              <1> ;;	retn
 21022                              <1> ;;TCHKG: CLC				; INDICATE STILL TIME
 21023                              <1> ;;	retn
 21024                              <1> ;;
 21025                              <1> ;;int_13h:
 21026                              <1> 
 21027                              <1> ;----------------------------------------
 21028                              <1> ;	FIXED DISK BIOS ENTRY POINT	:
 21029                              <1> ;----------------------------------------
 21030                              <1> 
 21031                              <1> ; 17/07/2022
 21032                              <1> ; 16/07/2022
 21033                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
 21034                              <1> ; 15/01/2017
 21035                              <1> ; 14/01/2017
 21036                              <1> ; 07/01/2017
 21037                              <1> ; 02/01/2017
 21038                              <1> ; 01/06/2016
 21039                              <1> ; 16/05/2016, 27/05/2016, 28/05/2016, 29/05/2016
 21040                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 21041                              <1> int33h: ; DISK I/O
 21042                              <1> 	; 29/05/2016
 21043 00004E74 80642408FE          <1> 	and	byte [esp+8], 11111110b  ; clear carry bit of eflags register
 21044                              <1> 
 21045                              <1> 	; 13/07/2022
 21046 00004E79 06                  <1> 	push	es
 21047                              <1> 	; 16/05/2016
 21048 00004E7A 1E                  <1> 	push	ds
 21049 00004E7B 53                  <1> 	push	ebx ; user's buffer address (virtual)
 21050                              <1> 	; 13/07/2022
 21051 00004E7C 51                  <1> 	push	ecx
 21052 00004E7D 52                  <1> 	push	edx
 21053 00004E7E 56                  <1> 	push	esi
 21054 00004E7F 57                  <1> 	push	edi
 21055                              <1> 
 21056                              <1> 	;mov	bx, KDATA ; System (Kernel's) data segment
 21057                              <1> 	;mov	ds, bx
 21058                              <1> 	; 13/07/2022
 21059 00004E80 66BF1000            <1> 	mov	di, KDATA
 21060 00004E84 8EDF                <1> 	mov	ds, di
 21061 00004E86 8EC7                <1> 	mov	es, di
 21062                              <1> 
 21063                              <1> 	;;15/01/2017
 21064                              <1> 	; 14/01/2017
 21065                              <1> 	; 02/01/2017
 21066                              <1> 	;;mov	byte [intflg], 33h  ; disk io interrupt 
 21067                              <1> 	;pop	ebx
 21068                              <1> 
 21069                              <1> 	; 13/07/2022
 21070                              <1> 	;pop	dword [user_buffer] ; 01/06/2016
 21071 00004E88 891D[08840100]      <1> 	mov	[user_buffer], ebx		
 21072                              <1> 
 21073 00004E8E C605[427D0100]00    <1> 	mov	byte [scount], 0 ; sector count for transfer
 21074 00004E95 80FC03              <1> 	cmp	ah, 03h ; chs write
 21075 00004E98 773C                <1> 	ja	short int33h_2
 21076 00004E9A 7407                <1> 	je	short int33h_0
 21077 00004E9C 80FC02              <1> 	cmp	ah, 02h ; chs read
 21078 00004E9F 7267                <1> 	jb	short int33h_5
 21079 00004EA1 EB5A                <1> 	jmp	short int33h_4
 21080                              <1> int33h_0:
 21081                              <1> 	;; 17/07/2022 - 64K r/w buffer limit check ?
 21082                              <1> 	;cmp	al, 80h ; 128	
 21083                              <1> 	;ja	short int33h_8 ; error
 21084                              <1> 	;; 17/07/2022 - zero r/w count check ?
 21085                              <1> 	;or	al, al
 21086                              <1> 	;jz	short int33h_8 ; error
 21087                              <1> 	
 21088                              <1> 	; 17/07/2022 (buffer limit and zero count check)
 21089 00004EA3 FEC8                <1> 	dec	al
 21090 00004EA5 781A                <1> 	js	short int33h_8 ; error
 21091 00004EA7 FEC0                <1> 	inc	al	
 21092                              <1> 
 21093                              <1> 	; transfer user's buffer content to sector buffer
 21094 00004EA9 51                  <1> 	push	ecx
 21095 00004EAA 0FB6C8              <1> 	movzx	ecx, al
 21096                              <1> int33h_1:
 21097                              <1> 	; 13/07/2022
 21098                              <1> 	;push	esi
 21099                              <1> 	;mov	esi, [user_buffer]
 21100 00004EAD 89DE                <1> 	mov	esi, ebx
 21101                              <1> 	; esi = user's buffer address (virtual, ebx)
 21102                              <1> 	;push	edi
 21103                              <1> 	;push	es
 21104 00004EAF 50                  <1> 	push	eax
 21105                              <1> 	;mov	ax, KDATA
 21106                              <1> 	;mov	es, ax
 21107 00004EB0 BF00000700          <1> 	mov	edi, Cluster_Buffer
 21108 00004EB5 C1E109              <1> 	shl	ecx, 9 ; * 512
 21109 00004EB8 E8BABE0000          <1> 	call	transfer_from_user_buffer
 21110                              <1> 		; (ecx and eax will be modified)
 21111 00004EBD 58                  <1> 	pop	eax
 21112                              <1> 	; 13/07/2022
 21113                              <1> 	;pop	es
 21114                              <1> 	;pop	edi
 21115                              <1> 	;pop	esi
 21116 00004EBE 59                  <1> 	pop	ecx
 21117 00004EBF 7347                <1> 	jnc	short int33h_5
 21118                              <1> 
 21119                              <1> 	;mov	ebx, [user_buffer] ; 01/06/2016
 21120                              <1> 	;pop	ds
 21121                              <1> 
 21122                              <1> int33h_8:
 21123                              <1> 	; 13/07/2022
 21124 00004EC1 B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
 21125                              <1> int33h_9:
 21126 00004EC6 5F                  <1> 	pop	edi
 21127 00004EC7 5E                  <1> 	pop	esi
 21128 00004EC8 5A                  <1> 	pop	edx
 21129 00004EC9 59                  <1> 	pop	ecx
 21130 00004ECA 5B                  <1> 	pop	ebx
 21131 00004ECB 1F                  <1> 	pop	ds
 21132 00004ECC 07                  <1> 	pop	es
 21133                              <1> 
 21134                              <1> 	; 13/07/2022
 21135 00004ECD 7305                <1> 	jnc	short int33h_7
 21136                              <1> 
 21137                              <1> 	;;15/01/2017
 21138                              <1> 	; 02/01/2017
 21139                              <1> 	;cli
 21140                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
 21141                              <1> 	;
 21142                              <1> 	; (*) 29/05/2016
 21143                              <1> 	; (*) retf 4 ; skip eflags on stack
 21144                              <1> 
 21145                              <1> 	; 29/05/2016 -set carry flag on stack-
 21146                              <1> 	; [esp] = EIP
 21147                              <1> 	; [esp+4] = CS
 21148                              <1> 	; [esp+8] = E-FLAGS
 21149 00004ECF 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
 21150                              <1> 	; [esp+12] = ESP (user)
 21151                              <1> 	; [esp+16] = SS (User)
 21152                              <1> 	;
 21153                              <1> 	; 13/07/2022
 21154                              <1> int33h_7:	
 21155 00004ED4 FA                  <1> 	cli
 21156                              <1> 	;;15/01/2017
 21157                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
 21158                              <1> 	; cf = 0  ; use eflags which is in stack
 21159 00004ED5 CF                  <1> 	iretd	
 21160                              <1> 
 21161                              <1> 	; (*) 29/05/2016 - 'retf 4' intruction causes to stack fault
 21162                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
 21163                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
 21164                              <1> 	; // RETF instruction:
 21165                              <1> 	;
 21166                              <1> 	; IF OperandMode=32 THEN
 21167                              <1>  	;    Load CS:EIP from stack;
 21168                              <1>  	;    Set CS RPL to CPL;
 21169                              <1>  	;    Increment ESP by 8 plus the immediate offset if it exists;
 21170                              <1>  	;    Load SS:ESP from stack;
 21171                              <1>  	; ELSE (* OperandMode=16 *)
 21172                              <1>  	;    Load CS:IP from stack;
 21173                              <1>  	;    Set CS RPL to CPL;
 21174                              <1>  	;    Increment ESP by 4 plus the immediate offset if it exists;
 21175                              <1> 	;    Load SS:ESP from stack;
 21176                              <1>  	; FI;
 21177                              <1> 	;
 21178                              <1> 	; //
 21179                              <1> 
 21180                              <1> int33h_2:
 21181 00004ED6 80FC05              <1> 	cmp	ah, 05h ; format track
 21182 00004ED9 7709                <1> 	ja	short int33h_3
 21183 00004EDB 722B                <1> 	jb	short int33h_5
 21184 00004EDD 51                  <1> 	push	ecx
 21185                              <1> 	;mov	ecx, 1
 21186                              <1> 	; 17/07/2022
 21187 00004EDE 31C9                <1> 	xor	ecx, ecx
 21188 00004EE0 FEC1                <1> 	inc	cl
 21189                              <1> 	; ecx = 1
 21190 00004EE2 EBC9                <1> 	jmp	short int33h_1
 21191                              <1> int33h_3:
 21192 00004EE4 80FC1C              <1> 	cmp	ah, 1Ch ; LBA write
 21193 00004EE7 771F                <1> 	ja	short int33h_5
 21194 00004EE9 74B8                <1> 	je	short int33h_0
 21195 00004EEB 80FC1B              <1> 	cmp	ah, 1Bh ; LBA read
 21196 00004EEE 740D                <1> 	je	short int33h_4
 21197 00004EF0 80FC08              <1> 	cmp	ah, 08h ; get disk parameters
 21198 00004EF3 7513                <1> 	jne	short int33h_5
 21199                              <1> 	; 01/06/2016
 21200 00004EF5 8B1D[08840100]      <1> 	mov	ebx, [user_buffer] ; user's buffer address
 21201 00004EFB EB10                <1> 	jmp	short int33h_6
 21202                              <1> int33h_4:
 21203                              <1> 	;; 17/07/2022 - 64K r/w buffer limit check ?
 21204                              <1> 	;cmp	al, 80h ; 128	
 21205                              <1> 	;ja	short int33h_8 ; error
 21206                              <1> 	;; 17/07/2022 - zero r/w count check ?
 21207                              <1> 	;or	al, al
 21208                              <1> 	;jz	short int33h_8 ; error
 21209                              <1> 
 21210                              <1> 	; 17/07/2022 (buffer limit and zero count check)
 21211 00004EFD FEC8                <1> 	dec	al
 21212 00004EFF 78C0                <1> 	js	short int33h_8 ; error
 21213 00004F01 FEC0                <1> 	inc	al
 21214                              <1> 
 21215 00004F03 A2[427D0100]        <1> 	mov	byte [scount], al ; <= 128 sectors
 21216                              <1> int33h_5:
 21217 00004F08 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; max. 65536 bytes
 21218                              <1> 				    ; buf. addr: 70000h	
 21219                              <1> 	;mov	byte [ClusterBuffer_Valid], 0
 21220                              <1> int33h_6:
 21221                              <1> 	; 13/07/2022
 21222                              <1> 	;pop	ds
 21223                              <1> 	;pushfd
 21224                              <1> 	;push 	cs
 21225                              <1> 	
 21226 00004F0D E83B000000          <1> 	call 	DISK_IO
 21227                              <1> 	
 21228                              <1> 	;;mov	ebx, [cs:user_buffer] ; 01/06/2016
 21229                              <1> 	;mov	ebx, [user_buffer] ; 13/07/2022 
 21230 00004F12 72B2                <1> 	jc	short int33h_9
 21231                              <1> 	;
 21232                              <1> 	;cmp	byte [cs:scount], 0
 21233                              <1> 	;jna	short int33h_7	
 21234 00004F14 803D[427D0100]00    <1> 	cmp	byte [scount], 0 ; 13/07/2022
 21235 00004F1B 76A9                <1> 	jna	short int33h_9
 21236                              <1> 
 21237                              <1> 	; 13/07/2022
 21238                              <1> 
 21239                              <1> 	; transfer sector buffer content to user's buffer
 21240                              <1> 	;push	es
 21241                              <1> 	;push	ds
 21242                              <1> 	;push	eax
 21243                              <1> 	;mov	ax, KDATA
 21244                              <1> 	;mov	ds, ax
 21245                              <1> 	;mov	es, ax
 21246                              <1> 	;push	ecx
 21247                              <1> 	;push	esi
 21248                              <1> 	;push	edi
 21249                              <1> 	
 21250                              <1> 	; 13/07/2022
 21251 00004F1D 50                  <1> 	push	eax
 21252 00004F1E 0FB60D[427D0100]    <1> 	movzx	ecx, byte [scount]
 21253 00004F25 C1E109              <1> 	shl	ecx, 9 ; * 512 bytes
 21254                              <1> 	;mov	edi, ebx ; user's buffer address
 21255 00004F28 8B3D[08840100]      <1> 	mov	edi, [user_buffer] ; 13/07/2022
 21256 00004F2E BE00000700          <1> 	mov	esi, Cluster_Buffer
 21257 00004F33 E8F5BD0000          <1> 	call	transfer_to_user_buffer 
 21258                              <1> 		; (ecx and eax will be modified)
 21259 00004F38 58                  <1> 	pop	eax
 21260                              <1> 
 21261                              <1> 	; 13/07/2022
 21262 00004F39 7286                <1> 	jc	short int33h_8 ; eax = 0FFh
 21263 00004F3B EB89                <1> 	jmp	short int33h_9 ; cf = 0
 21264                              <1> 
 21265                              <1> 	;pop	edi
 21266                              <1> 	;pop	esi
 21267                              <1> 	;pop	ecx
 21268                              <1> 	;pop	eax
 21269                              <1> 	;pop	ds
 21270                              <1> 	;pop	es
 21271                              <1> 	;jc	short int33h_8
 21272                              <1> ;int33h_7:
 21273                              <1> 	;cli
 21274                              <1> 	;;;15/01/2017
 21275                              <1> 	;;;mov	byte [ss:intflg], 0 ; 07/01/2017
 21276                              <1> 	;; cf = 0  ; use eflags which is in stack
 21277                              <1> 	;iretd	
 21278                              <1> ;int33h_8:
 21279                              <1> 	;mov	eax, 0FFh ; Unknown error !?
 21280                              <1> 	; 13/07/2022
 21281                              <1> 	;xor	eax, eax
 21282                              <1> 	;dec	al  ; eax = 0FFh	
 21283                              <1> 	;jmp	short int33h_9
 21284                              <1> 	 
 21285                              <1> ;int33h_9:
 21286                              <1> 	;; cf = 1
 21287                              <1> 	;
 21288                              <1> 	;; (*) 29/05/2016	
 21289                              <1> 	;; (*) retf 4 ; skip eflags on stack
 21290                              <1> 	;; Note: This 'retf 4' was wrong, -it was causing
 21291                              <1> 	;;       to stack errors in ring 3-
 21292                              <1> 	;;	POP sequence of 'retf 4' is as
 21293                              <1> 	;;       "eip, cs, eflags, esp, ss, +4 bytes" 
 21294                              <1>         ;;       it is not as "eip, cs, +4 bytes, esp, ss" ! 
 21295                              <1> 	;
 21296                              <1> 	;; 29/05/2016 -set carry flag on stack-
 21297                              <1> 	;or	byte [esp+8], 1  ; set carry bit of eflags register
 21298                              <1> 	;;iretd
 21299                              <1> 	;jmp	short int33h_7 ; 07/01/2017
 21300                              <1> 
 21301                              <1> ;; 11/04/2021
 21302                              <1> ;int13h: ; 21/02/2015
 21303                              <1> ;	clc ; 11/04/2021
 21304                              <1> ;	pushfd
 21305                              <1> ;	push 	cs
 21306                              <1> ;	call 	DISK_IO
 21307                              <1> ;	retn
 21308                              <1> 
 21309                              <1> int13h:
 21310                              <1> 	; 13/07/2022 - TRDOS 386 v2.0.5
 21311                              <1> 	; Note: DISK_IO sets registers on stack
 21312                              <1> 	; 	as return parameters. So,
 21313                              <1> 	;	stack order (at the entry of 'DISK_IO')
 21314                              <1> 	;	must be same with 'int33h:' as above.
 21315                              <1> 		
 21316                              <1> 	;push	es ; not necessary
 21317                              <1> 	;push	ds ; not necessary
 21318                              <1> 	;
 21319                              <1> 	; following pushes are necessary
 21320                              <1> 	; for setting registers -return values- in DISK_IO
 21321 00004F3D 53                  <1> 	push	ebx
 21322 00004F3E 51                  <1> 	push	ecx
 21323 00004F3F 52                  <1> 	push	edx
 21324 00004F40 56                  <1> 	push	esi
 21325 00004F41 57                  <1> 	push	edi
 21326                              <1> 	;push	ebp
 21327                              <1> 	;mov	ebp, esp
 21328                              <1> 	; edi = ebp+4
 21329                              <1> 	; esi = ebp+8
 21330                              <1> 	; edx = ebp+12
 21331                              <1> 	; ecx = ebp+16
 21332                              <1> 	; ebx = ebp+20
 21333                              <1> 	;
 21334 00004F42 E806000000          <1> 	call	DISK_IO
 21335                              <1> 	;
 21336 00004F47 5F                  <1> 	pop	edi
 21337 00004F48 5E                  <1> 	pop	esi
 21338 00004F49 5A                  <1> 	pop	edx
 21339 00004F4A 59                  <1> 	pop	ecx
 21340 00004F4B 5B                  <1> 	pop	ebx	
 21341                              <1> 	;
 21342                              <1> 	;pop	ds
 21343                              <1> 	;pop	es
 21344                              <1> 	;
 21345 00004F4C C3                  <1> 	retn
 21346                              <1> 
 21347                              <1> ; 10/08/2022
 21348                              <1> ; 07/08/2022
 21349                              <1> ; 17/07/2022
 21350                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
 21351                              <1> ; 18/04/2021 - TRDOS 386 v2.0.4
 21352                              <1> ; 11/04/2021 - TRDOS 386 v2.0.3
 21353                              <1> ; 30/08/2020
 21354                              <1> ; 09/12/2017
 21355                              <1> ; 29/05/2016
 21356                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
 21357                              <1> 
 21358                              <1> DISK_IO:
 21359                              <1> 	; 10/08/2022
 21360                              <1> 	; 17/07/2022
 21361                              <1> 	; 13/07/2022
 21362                              <1> 	; Registers are also on stack 
 21363                              <1> 	; (with same contents) 
 21364                              <1> 	; in following order:
 21365                              <1> 	;
 21366                              <1> 	;    ebx = esp+20
 21367                              <1> 	;    ecx = esp+16
 21368                              <1> 	;    edx = esp+12
 21369                              <1> 	;    esi = esp+8
 21370                              <1> 	;    edi = esp+4
 21371                              <1> 
 21372                              <1> 	; cs = KCODE (== KDATA base address)
 21373                              <1> 	; ss = KDATA
 21374                              <1> 	; ds = KDATA
 21375                              <1> 	; es = KDATA
 21376                              <1> 
 21377                              <1> 	; 17/07/2022
 21378 00004F4D FB                  <1> 	sti				; ENABLE INTERRUPTS
 21379                              <1> 
 21380 00004F4E 80FA80              <1> 	cmp	dl, 80h			; TEST FOR FIXED DISK DRIVE
 21381                              <1> 	;jae	short A1		; YES, HANDLE HERE
 21382                              <1> 	;;;int	40h			; DISKETTE HANDLER
 21383                              <1> 	;;call	int40h
 21384                              <1> 	;jb	DISKETTE_IO_1
 21385                              <1> ;RET_2:
 21386                              <1> 	;;retf	2			; BACK TO CALLER
 21387                              <1> 	;retf	4
 21388                              <1> 	; 11/04/2021
 21389 00004F51 7305                <1> 	jnb	short A1
 21390 00004F53 E940F2FFFF          <1> 	jmp	DISKETTE_IO_1
 21391                              <1> A1:
 21392                              <1> 	;sti	 ; 17/07/2022		; ENABLE INTERRUPTS
 21393                              <1> 	
 21394                              <1> 	;; 04/01/2015
 21395                              <1> 	;;or	ah, ah
 21396                              <1> 	;;jnz	short A2
 21397                              <1> 	;;int	40h			; RESET NEC WHEN AH=0
 21398                              <1> 	;;sub	ah, ah
 21399                              <1> 	
 21400 00004F58 80FA83              <1> 	cmp	dl, (80h + S_MAX_FILE - 1)
 21401                              <1> 	;ja	short RET_2
 21402 00004F5B 760A                <1> 	jna	short _A0
 21403                              <1> 	
 21404                              <1> 	; 13/07/2022
 21405                              <1> 	; (here, DS is KDATA segment already) 
 21406                              <1> 	;
 21407                              <1> 	; 29/05/2016
 21408                              <1> 	;push	ds
 21409                              <1> 	; 11/04/2021
 21410                              <1> 	;push	eax
 21411                              <1> 	;mov	ax, KDATA
 21412                              <1> 	;mov	ds, ax
 21413                              <1> 	; 11/04/2021
 21414                              <1> 	;pop	eax
 21415                              <1> 	
 21416 00004F5D B4AA                <1> 	mov     ah, 0AAh        ; Hard disk drive not ready !
 21417                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
 21418 00004F5F 8825[17780100]      <1> 	mov     byte [DISK_STATUS1], ah
 21419                              <1> 	; 13/07/2022
 21420                              <1> 	;pop	ds
 21421                              <1> 	;jmp	short RET_2
 21422 00004F65 F9                  <1> 	stc
 21423 00004F66 C3                  <1> 	retn
 21424                              <1> _A0:
 21425                              <1> 	; 18/01/2015
 21426 00004F67 08E4                <1> 	or	ah, ah
 21427 00004F69 742C                <1> 	jz	short A4
 21428 00004F6B 80FC0D              <1> 	cmp	ah, 0Dh	; Alternate reset
 21429 00004F6E 7504                <1> 	jne	short A2
 21430 00004F70 28E4                <1> 	sub	ah, ah	; Reset
 21431 00004F72 EB23                <1> 	jmp	short A4
 21432                              <1> A2:
 21433                              <1> 	; 13/07/2022
 21434 00004F74 80FC08              <1> 	cmp	ah, 08h			; GET PARAMETERS IS A SPECIAL CASE
 21435 00004F77 7505                <1> 	jne	short A3
 21436 00004F79 E9AC030000          <1>         jmp	GET_PARM_N
 21437                              <1> A3:	
 21438                              <1> 	; 13/07/2022
 21439 00004F7E 80FC15              <1> 	cmp	ah, 15h			; READ DASD TYPE IS ALSO
 21440 00004F81 7514                <1> 	jne	short A4
 21441 00004F83 E947030000          <1>         jmp	READ_DASD_TYPE	; Return Drive Type
 21442                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
 21443                              <1> 	; 13/07/2022
 21444                              <1> int33h_bad_cmd:
 21445                              <1> 	; 16/05/2016
 21446                              <1> 	; 30/01/2015
 21447                              <1> 	; 29/05/2016
 21448                              <1> 	;push	ds
 21449                              <1> 	;push	eax
 21450                              <1> 	;mov	ax, KDATA
 21451                              <1> 	;mov	ds, ax
 21452                              <1> 	;pop	eax
 21453                              <1> 
 21454 00004F88 B401                <1> 	mov	ah, BAD_CMD
 21455 00004F8A 8825[17780100]      <1> 	mov     [DISK_STATUS1], ah ; BAD_CMD  ; COMMAND ERROR
 21456                              <1>         ;jmp	short RET_2
 21457                              <1> 	; 13/07/2022
 21458                              <1> ;RET_2:
 21459                              <1> 	; (*) 29/05/2016
 21460                              <1> 	; (*) retf 4
 21461                              <1> 	;or	byte [esp+8], 1 ; set carry bit of eflags register
 21462                              <1> 	;iretd
 21463                              <1> 	
 21464                              <1> 	; 13/07/2022
 21465 00004F90 F9                  <1> 	stc
 21466                              <1> 	; cf = 1, ah = BAD_CMD
 21467 00004F91 C3                  <1> 	retn
 21468                              <1> _A4:
 21469                              <1> 	; 13/07/2022
 21470                              <1> 	; 02/02/2015
 21471 00004F92 80FC1D              <1> 	cmp	ah, 1Dh			; (Temporary for Retro UNIX 386 v1)
 21472                              <1> 	; 12/01/2015
 21473                              <1> 	;cmc
 21474                              <1> 	;jnc	short A4
 21475                              <1> 	; 13/07/2022
 21476 00004F95 73F1                <1> 	jnb	short int33h_bad_cmd	
 21477                              <1> A4:					; SAVE REGISTERS DURING OPERATION
 21478 00004F97 C8080000            <1> 	enter	8, 0			; SAVE (BP) AND MAKE ROOM FOR @CMD_BLOCK
 21479                              <1> 	
 21480                              <1> 	; 13/07/2022
 21481                              <1> 	; ENTER 8, 0
 21482                              <1> 	;;push	ebp
 21483                              <1> 	;;mov	ebp, esp
 21484                              <1> 	;;sub	esp, 8
 21485                              <1> 	;
 21486                              <1> 	;push	ebx			;  IN THE STACK, THE COMMAND BLOCK IS:
 21487                              <1> 	;push	ecx			;   @CMD_BLOCK == BYTE PTR [BP]-8
 21488                              <1> 	;push	edx
 21489                              <1> 	;push	esi
 21490                              <1> 	;push	edi
 21491                              <1> 
 21492                              <1> 	; 13/07/2022
 21493                              <1> 	; edi = ebp+8
 21494                              <1> 	; esi = ebp+12
 21495                              <1> 	; edx = ebp+16
 21496                              <1> 	; ecx = ebp+20
 21497                              <1> 	; ebx = ebp+24
 21498                              <1> 
 21499                              <1> 	;;04/01/2015
 21500                              <1> 	;;or	ah, ah			; CHECK FOR RESET
 21501                              <1> 	;;jnz	short A5
 21502                              <1> 	;;mov	dl, 80h			; FORCE DRIVE 80 FOR RESET
 21503                              <1> ;;A5:	
 21504                              <1> 	; 13/07/2022
 21505 00004F9B E880000000          <1> 	call	DISK_IO_CONT		; PERFORM THE OPERATION
 21506                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
 21507 00004FA0 8A25[17780100]      <1> 	mov	ah, [DISK_STATUS1]	; GET STATUS FROM OPERATION
 21508                              <1> 	;(*) cmp ah, 1			; SET THE CARRY FLAG TO INDICATE
 21509                              <1> 					; SUCCESS OR FAILURE
 21510                              <1> 	;pop	edi			; RESTORE REGISTERS
 21511                              <1> 	;pop	esi
 21512                              <1> 	;pop	edx
 21513                              <1> 	;pop	ecx
 21514                              <1> 	;pop	ebx
 21515                              <1> 	
 21516 00004FA6 C9                  <1> 	leave				; ADJUST (SP) AND RESTORE (BP)
 21517                              <1> 	
 21518                              <1> 	;retf	2			; THROW AWAY SAVED FLAGS
 21519                              <1> 	; (*) 29/05/2016
 21520                              <1> 	; (*) retf 4
 21521                              <1> 	
 21522                              <1> 	; 13/07/2022
 21523 00004FA7 80FC01              <1> 	cmp	ah, 1
 21524                              <1> 	;jc	short _A5 
 21525                              <1> 	;or	byte [esp+8], 1 ; set carry bit of eflags register
 21526                              <1> ;_A5:
 21527                              <1> 	;iretd
 21528                              <1> 	; 10/08/2022
 21529 00004FAA F5                  <1> 	cmc
 21530                              <1> 	; 13/07/2022
 21531 00004FAB C3                  <1> 	retn
 21532                              <1> 
 21533                              <1> ; 21/02/2015
 21534                              <1> ;       dw --> dd
 21535                              <1> 	; 13/07/2022
 21536                              <1> D1:					; FUNCTION TRANSFER TABLE
 21537 00004FAC [64510000]          <1> 	dd	DISK_RESET		; 00h
 21538 00004FB0 [C4510000]          <1> 	dd	RETURN_STATUS		; 01h
 21539 00004FB4 [D7510000]          <1> 	dd	DISK_READ		; 02h
 21540 00004FB8 [33520000]          <1> 	dd	DISK_WRITE		; 03h
 21541 00004FBC [B7520000]          <1> 	dd	DISK_VERF		; 04h
 21542 00004FC0 [A4520000]          <1> 	dd	FMT_TRK 		; 05h
 21543 00004FC4 [5A510000]          <1> 	dd	BAD_COMMAND		; 06h	FORMAT BAD SECTORS
 21544 00004FC8 [5A510000]          <1> 	dd	BAD_COMMAND		; 07h	FORMAT DRIVE
 21545 00004FCC [5A510000]          <1> 	dd	BAD_COMMAND		; 08h	RETURN PARAMETERS
 21546 00004FD0 [AA530000]          <1> 	dd	INIT_DRV		; 09h
 21547 00004FD4 [D1510000]          <1> 	dd	RD_LONG 		; 0Ah
 21548 00004FD8 [2D520000]          <1> 	dd	WR_LONG 		; 0Bh
 21549 00004FDC [1B540000]          <1> 	dd	DISK_SEEK		; 0Ch
 21550 00004FE0 [64510000]          <1> 	dd	DISK_RESET		; 0Dh
 21551 00004FE4 [5A510000]          <1> 	dd	BAD_COMMAND		; 0Eh	READ BUFFER
 21552 00004FE8 [5A510000]          <1> 	dd	BAD_COMMAND		; 0Fh	WRITE BUFFER
 21553 00004FEC [43540000]          <1> 	dd	TST_RDY 		; 10h
 21554 00004FF0 [67540000]          <1> 	dd	HDISK_RECAL		; 11h
 21555 00004FF4 [5A510000]          <1> 	dd	BAD_COMMAND		; 12h	MEMORY DIAGNOSTIC
 21556 00004FF8 [5A510000]          <1> 	dd	BAD_COMMAND		; 13h	DRIVE DIAGNOSTIC
 21557 00004FFC [9D540000]          <1> 	dd	CTLR_DIAGNOSTIC 	; 14h	CONTROLLER DIAGNOSTIC
 21558                              <1> 	;; 02/02/2015 (Temporary - Retro UNIX 386 v1 - DISK I/O test)
 21559 00005000 [5A510000]          <1> 	dd	BAD_COMMAND		; 15h
 21560 00005004 [5A510000]          <1> 	dd	BAD_COMMAND		; 16h
 21561 00005008 [5A510000]          <1> 	dd	BAD_COMMAND		; 17h
 21562 0000500C [5A510000]          <1> 	dd	BAD_COMMAND		; 18h
 21563 00005010 [5A510000]          <1> 	dd	BAD_COMMAND		; 19h
 21564 00005014 [5A510000]          <1> 	dd	BAD_COMMAND		; 1Ah
 21565 00005018 [D7510000]          <1> 	dd	DISK_READ		; 1Bh ; LBA read
 21566 0000501C [33520000]          <1> 	dd	DISK_WRITE		; 1Ch ; LBA write
 21567                              <1> D1L     EQU    $ - D1
 21568                              <1> 
 21569                              <1> 	; 07/08/2022
 21570                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
 21571                              <1> DISK_IO_CONT:
 21572                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
 21573                              <1> 	; 11/04/2021
 21574 00005020 80FC01              <1> 	cmp	ah, 01h			; RETURN STATUS
 21575 00005023 7505                <1> 	jne	short SU0
 21576 00005025 E99A010000          <1> 	jmp	RETURN_STATUS
 21577                              <1> SU0:
 21578 0000502A C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; RESET THE STATUS INDICATOR
 21579                              <1> 	; 13/07/2022
 21580 00005031 89DE                <1> 	mov	esi, ebx ; 21/02/2015	; SAVE DATA ADDRESS
 21581 00005033 8A1D[18780100]      <1> 	mov	bl, [HF_NUM]		; GET NUMBER OF DRIVES
 21582 00005039 80E27F              <1> 	and	dl, 7Fh			; GET DRIVE AS 0 OR 1
 21583                              <1> 					; (get drive number as 0 to 3)
 21584                              <1> 	; 14/02/2015 
 21585 0000503C 38D3                <1> 	cmp	bl, dl
 21586                              <1> 	;jbe	short BAD_COMMAND	; INVALID DRIVE
 21587                              <1> 	; 07/08/2022
 21588 0000503E 7705                <1> 	ja	short SU0X
 21589 00005040 E915010000          <1> 	jmp	BAD_COMMAND
 21590                              <1> SU0X:
 21591                              <1> 	;;03/01/2015
 21592 00005045 29DB                <1> 	sub	ebx, ebx
 21593 00005047 88D3                <1> 	mov	bl, dl
 21594 00005049 883D[2C780100]      <1> 	mov	[LBAMode], bh 	; 0
 21595                              <1> 	
 21596                              <1> 	;test	byte [ebx+hd0_type], 1 	; LBA ready ?
 21597                              <1> 	;jz	short su1		; no
 21598                              <1> 	;inc	byte [LBAMode]
 21599                              <1> ;su1:
 21600                              <1> 	; 11/04/2021 (32 bit push/pop)
 21601                              <1> 	; 21/02/2015 (32 bit modification)
 21602                              <1> 	; 04/01/2015
 21603 0000504F 50                  <1> 	push	eax ; ***
 21604                              <1> 	;push	es  ; **
 21605 00005050 52                  <1> 	push	edx ; *
 21606 00005051 50                  <1> 	push	eax ; ****
 21607 00005052 E8ED050000          <1> 	call	GET_VEC 		; GET DISK PARAMETERS
 21608                              <1> 	; 02/02/2015
 21609                              <1> 	;mov	ax, [ES:BX+16] ; I/O port base address (1F0h, 170h)
 21610 00005057 668B4310            <1> 	mov	ax, [ebx+16]
 21611 0000505B 66A3[EE640000]      <1> 	mov	[HF_PORT], ax
 21612                              <1> 	;mov	dx, [ES:BX+18] ; control port address (3F6h, 376h)
 21613 00005061 668B5312            <1> 	mov	dx, [ebx+18]
 21614 00005065 668915[F0640000]    <1> 	mov	[HF_REG_PORT], dx
 21615                              <1> 	;mov	al, [ES:BX+20] ; head register upper nibble (A0h,B0h,E0h,F0h)
 21616 0000506C 8A4314              <1> 	mov	al, [ebx+20]
 21617                              <1> 	; 23/02/2015
 21618 0000506F A840                <1> 	test	al, 40h	 ; LBA bit (bit 6)
 21619 00005071 7406                <1> 	jz 	short su1
 21620 00005073 FE05[2C780100]      <1> 	inc	byte [LBAMode] ; 1 
 21621                              <1> su1: 	 
 21622 00005079 C0E804              <1> 	shr 	al, 4
 21623 0000507C 2401                <1> 	and	al, 1			
 21624 0000507E A2[F2640000]        <1> 	mov	[hf_m_s], al 
 21625                              <1> 	;
 21626                              <1> 	; 03/01/2015
 21627                              <1> 	;mov	al, [ES:BX+8]		; GET CONTROL BYTE MODIFIER
 21628 00005083 8A4308              <1> 	mov	al, [ebx+8]
 21629                              <1> 	;mov	dx, [HF_REG_PORT]	; Device Control register
 21630 00005086 EE                  <1> 	out	dx, al			; SET EXTRA HEAD OPTION
 21631                              <1> 					; -here-
 21632                              <1> 					; Control Byte: (= 08h)
 21633                              <1> 					;  bit 0 - 0
 21634                              <1> 					;  bit 1 - nIEN (1 = disable irq)
 21635                              <1> 					;  bit 2 - SRST (software RESET)
 21636                              <1> 					;  bit 3 - use extra heads (8 to 15)
 21637                              <1> 					;          -always set to 1-	
 21638                              <1> 					;  (bits 3 to 7 are reserved
 21639                              <1> 					;          for ATA devices)
 21640 00005087 8A25[19780100]      <1> 	mov	ah, [CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
 21641 0000508D 80E4C0              <1> 	and	ah, 0C0h 		; CONTROL BYTE
 21642 00005090 08C4                <1> 	or	ah, al
 21643 00005092 8825[19780100]      <1> 	mov	[CONTROL_BYTE], ah
 21644                              <1> 	
 21645                              <1> 	; 11/04/2021 (32 bit push/pop)
 21646                              <1> 	; 04/01/2015
 21647 00005098 58                  <1> 	pop	eax ; ****
 21648 00005099 5A                  <1> 	pop	edx ; * ; 14/02/2015
 21649 0000509A 20E4                <1> 	and	ah, ah	; Reset function ?
 21650 0000509C 7506                <1> 	jnz	short su2
 21651                              <1> 	;pop	es ; **
 21652 0000509E 58                  <1> 	pop	eax ; ***
 21653 0000509F E9C0000000          <1>         jmp     DISK_RESET
 21654                              <1> su2:
 21655 000050A4 803D[2C780100]00    <1> 	cmp	byte [LBAMode], 0
 21656 000050AB 765F                <1> 	jna	short su3
 21657                              <1> 	;
 21658                              <1> 	; 02/02/2015 (LBA read/write function calls)
 21659 000050AD 80FC1B              <1> 	cmp	ah, 1Bh
 21660 000050B0 720B                <1> 	jb	short lbarw1
 21661 000050B2 80FC1C              <1> 	cmp	ah, 1Ch
 21662 000050B5 775A                <1> 	ja 	short invldfnc
 21663                              <1> 	;;pop	edx ; * ; 14/02/2015
 21664                              <1> 	;mov	ax, cx ; Lower word of LBA address (bits 0-15)
 21665 000050B7 89C8                <1> 	mov	eax, ecx ; LBA address (21/02/2015)
 21666                              <1> 	; 13/07/2022
 21667 000050B9 88D1                <1> 	mov	cl, dl ; 14/02/2015
 21668 000050BB EB2F                <1> 	jmp	short lbarw2
 21669                              <1> 
 21670                              <1> lbarw1:
 21671                              <1> 	; convert CHS to LBA
 21672                              <1> 	;
 21673                              <1> 	; LBA calculation - AWARD BIOS - 1999 - AHDSK.ASM
 21674                              <1> 	; LBA = "# of Heads" * Sectors/Track * Cylinder + Head * Sectors/Track
 21675                              <1> 	;	+ Sector - 1
 21676                              <1> 	; 11/04/2021 (32 bit push/pop)
 21677 000050BD 52                  <1> 	push	edx ; * ;; 14/02/2015
 21678                              <1> 	;xor	dh, dh
 21679 000050BE 31D2                <1> 	xor	edx, edx
 21680                              <1> 	;mov	dl, [ES:BX+14]	; sectors per track (logical)
 21681 000050C0 8A530E              <1> 	mov	dl, [ebx+14]
 21682                              <1> 	;xor	ah, ah
 21683 000050C3 31C0                <1> 	xor	eax, eax
 21684                              <1> 	;mov	al, [ES:BX+2]	; heads (logical) 	
 21685 000050C5 8A4302              <1> 	mov	al, [ebx+2]
 21686 000050C8 FEC8                <1> 	dec	al
 21687 000050CA 6640                <1> 	inc	ax		; 0 = 256
 21688 000050CC 66F7E2              <1> 	mul 	dx
 21689                              <1> 		; AX = # of Heads * Sectors/Track
 21690 000050CF 6689CA              <1> 	mov	dx, cx
 21691                              <1> 	;and	cx, 3Fh	 ; sector  (1 to 63)
 21692 000050D2 83E13F              <1> 	and	ecx, 3Fh
 21693 000050D5 86D6                <1> 	xchg	dl, dh
 21694 000050D7 C0EE06              <1> 	shr	dh, 6
 21695                              <1> 		; DX = cylinder (0 to 1023)
 21696                              <1> 	;mul 	dx
 21697                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder
 21698 000050DA F7E2                <1> 	mul	edx
 21699 000050DC FEC9                <1> 	dec	cl ; sector - 1
 21700                              <1> 	;add	ax, cx
 21701                              <1> 	;adc	dx, 0
 21702                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder + Sector - 1
 21703 000050DE 01C8                <1> 	add	eax, ecx
 21704                              <1> 	; 11/04/2021 (32 bit push/pop)
 21705 000050E0 59                  <1> 	pop	ecx ; * ; ch = head, cl = drive number (zero based)
 21706                              <1> 	;push	dx
 21707                              <1> 	;push	ax
 21708 000050E1 50                  <1> 	push	eax
 21709                              <1> 	; 13/07/2022
 21710 000050E2 29C0                <1> 	sub	eax, eax
 21711                              <1> 	;mov	al, [ES:BX+14]	; sectors per track (logical)	
 21712 000050E4 8A430E              <1> 	mov	al, [ebx+14]
 21713 000050E7 F6E5                <1> 	mul	ch
 21714                              <1> 		; AX = Head * Sectors/Track
 21715                              <1>         ; 13/07/2022
 21716                              <1> 	;movzx	eax, ax ; 09/12/2017
 21717                              <1> 	;pop	dx
 21718 000050E9 5A                  <1> 	pop	edx
 21719                              <1> 	;add	ax, dx
 21720                              <1> 	;pop	dx
 21721                              <1> 	;adc	dx, 0 ; add carry bit
 21722 000050EA 01D0                <1> 	add	eax, edx
 21723                              <1> lbarw2:
 21724 000050EC 29D2                <1> 	sub	edx, edx ; 21/02/2015
 21725 000050EE 88CA                <1> 	mov	dl, cl ; 21/02/2015
 21726 000050F0 C645F800            <1>         mov     byte [CMD_BLOCK], 0 ; Features Register
 21727                              <1> 				; NOTE: Features register (1F1h, 171h)
 21728                              <1> 				; is not used for ATA device R/W functions. 
 21729                              <1> 				; It is old/obsolete 'write precompensation'
 21730                              <1> 				; register and error register
 21731                              <1> 				; for old ATA/IDE devices.
 21732                              <1> 	; 18/01/2014
 21733                              <1> 	;mov	ch, [hf_m_s]	; Drive 0 (master) or 1 (slave)
 21734 000050F4 8A0D[F2640000]      <1> 	mov	cl, [hf_m_s]
 21735                              <1> 	;shl	ch, 4		; bit 4 (drive bit)
 21736                              <1> 	;or	ch, 0E0h	; bit 5 = 1
 21737                              <1> 				; bit 6 = 1 = LBA mode
 21738                              <1> 				; bit 7 = 1
 21739 000050FA 80C90E              <1> 	or	cl, 0Eh ; 1110b
 21740                              <1> 	;and	dh, 0Fh		; LBA byte 4 (bits 24 to 27)
 21741 000050FD 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh
 21742 00005102 C1E11C              <1> 	shl	ecx, 28 ; 21/02/2015
 21743                              <1> 	;or	dh, ch
 21744 00005105 09C8                <1> 	or	eax, ecx	
 21745                              <1> 	;;mov	[CMD_BLOCK+2], al ; LBA byte 1 (bits 0 to 7)
 21746                              <1> 				  ; (Sector Number Register)
 21747                              <1> 	;;mov	[CMD_BLOCK+3], ah ; LBA byte 2 (bits 8 to 15)
 21748                              <1> 				  ; (Cylinder Low Register)
 21749                              <1> 	;mov	[CMD_BLOCK+2], ax ; LBA byte 1, 2
 21750                              <1> 	;mov	[CMD_BLOCK+4], dl ; LBA byte 3 (bits 16 to 23)
 21751                              <1> 				  ; (Cylinder High Register)
 21752                              <1> 	;;mov	[CMD_BLOCK+5], dh ; LBA byte 4 (bits 24 to 27)
 21753                              <1> 				  ; (Drive/Head Register)
 21754                              <1> 	
 21755                              <1> 	;mov	[CMD_BLOCK+4], dx ; LBA byte 4, LBA & DEV select bits
 21756 00005107 8945FA              <1> 	mov	[CMD_BLOCK+2], eax ; 21/02/2015
 21757                              <1> 	; 14/02/2015
 21758                              <1> 	;mov	dl, cl ; Drive number (INIT_DRV)		
 21759 0000510A EB36                <1> 	jmp	short su4
 21760                              <1> su3:
 21761                              <1> 	; 07/08/2022
 21762                              <1> 	; 13/07/2022
 21763                              <1> 	; 02/02/2015 
 21764                              <1> 	; (1Bh & 1Ch functions are not valid for CHS mode) 
 21765 0000510C 80FC14              <1> 	cmp 	ah, 14h
 21766 0000510F 7603                <1> 	jna 	short chsfnc
 21767                              <1> invldfnc:
 21768                              <1>         ; 14/02/2015  
 21769                              <1> 	;pop	es ; **
 21770                              <1> 	; 11/04/2021
 21771 00005111 58                  <1> 	pop	eax ; *** 
 21772 00005112 EB46                <1>         jmp     short BAD_COMMAND
 21773                              <1> chsfnc:	
 21774                              <1> 	;mov	ax, [ES:BX+5]		; GET WRITE PRE-COMPENSATION CYLINDER
 21775 00005114 668B4305            <1> 	mov	ax, [ebx+5]
 21776                              <1> 	;shr	ax, 2
 21777                              <1> 	; 07/08/2022
 21778 00005118 C1E802              <1> 	shr	eax, 2
 21779 0000511B 8845F8              <1> 	mov	[CMD_BLOCK], al
 21780                              <1> 	
 21781                              <1> 	;;mov	al, [ES:BX+8]		; GET CONTROL BYTE MODIFIER
 21782                              <1> 	;;push	edx ; *
 21783                              <1> 	;;mov	dx, [HF_REG_PORT]
 21784                              <1> 	;;out	dx, al			; SET EXTRA HEAD OPTION
 21785                              <1> 	;;pop	edx ; * 
 21786                              <1> 	;;pop	es  ; **
 21787                              <1> 	;;mov	ah, [CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
 21788                              <1> 	;;and	ah, 0C0h 		; CONTROL BYTE	
 21789                              <1> 	;;or	ah, al
 21790                              <1> 	;;mov	[CONTROL_BYTE], ah
 21791                              <1> 	
 21792 0000511E 88C8                <1> 	mov	al, cl			; GET SECTOR NUMBER
 21793 00005120 243F                <1> 	and	al, 3Fh
 21794 00005122 8845FA              <1> 	mov	[CMD_BLOCK+2], al
 21795 00005125 886DFB              <1> 	mov	[CMD_BLOCK+3], ch 	; GET CYLINDER NUMBER
 21796 00005128 88C8                <1> 	mov	al, cl
 21797 0000512A C0E806              <1> 	shr	al, 6
 21798 0000512D 8845FC              <1> 	mov	[CMD_BLOCK+4], al 	; CYLINDER HIGH ORDER 2 BITS
 21799                              <1> 	
 21800                              <1> 	;;05/01/2015
 21801                              <1> 	;;mov	al, dl			; DRIVE NUMBER
 21802 00005130 A0[F2640000]        <1> 	mov	al, [hf_m_s]
 21803 00005135 C0E004              <1> 	shl	al, 4
 21804 00005138 80E60F              <1> 	and	dh, 0Fh			; HEAD NUMBER
 21805 0000513B 08F0                <1> 	or	al, dh
 21806                              <1> 	;or	al, 80h or 20h
 21807 0000513D 0CA0                <1> 	or	al, 80h+20h		; ECC AND 512 BYTE SECTORS
 21808 0000513F 8845FD              <1> 	mov	[CMD_BLOCK+5], al 	; ECC/SIZE/DRIVE/HEAD
 21809                              <1> su4:
 21810                              <1> 	;pop	es ; **
 21811                              <1>         ;; 14/02/2015
 21812                              <1>         ;;pop	ax
 21813                              <1>         ;;mov	[CMD_BLOCK+1], al	; SECTOR COUNT
 21814                              <1>         ;;push	ax
 21815                              <1>         ;;mov	al, ah			; GET INTO LOW BYTE
 21816                              <1>         ;;xor	ah, ah			; ZERO HIGH BYTE
 21817                              <1>         ;;sal	ax, 1			; *2 FOR TABLE LOOKUP
 21818                              <1>         ; 11/04/2021
 21819 00005142 58                  <1> 	pop	eax ; *** 
 21820 00005143 8845F9              <1>         mov     [CMD_BLOCK+1], al
 21821 00005146 29DB                <1>         sub	ebx, ebx
 21822                              <1> 	;xor	bh, bh
 21823 00005148 88E3                <1> 	mov     bl, ah
 21824                              <1>         ;sal	bx, 1
 21825                              <1>         ; 17/07/2022
 21826 0000514A C1E302              <1> 	sal	ebx, 2	; 32 bit offset (21/02/2015)
 21827                              <1> 	;mov	si, ax			; PUT INTO SI FOR BRANCH
 21828                              <1>         ; 13/07/2022
 21829                              <1> 	;cmp	bx, D1L			; TEST WITHIN RANGE
 21830                              <1> 	;jnb	short BAD_COMMAND_POP
 21831 0000514D 83FB74              <1> 	cmp	ebx, D1L		; TEST WITHIN RANGE
 21832 00005150 7308                <1> 	jnb	short BAD_COMMAND
 21833                              <1>         ;xchg	bx, si
 21834 00005152 87DE                <1>         xchg	ebx, esi
 21835                              <1> 	;;;pop	ax			; RESTORE AX
 21836                              <1> 	;;;pop	bx			; AND DATA ADDRESS
 21837                              <1> 	
 21838                              <1> 	;;push	cx
 21839                              <1> 	;;push	ax			; ADJUST ES:BX
 21840                              <1> 	;mov	cx, bx			; GET 3 HIGH ORDER NIBBLES OF BX
 21841                              <1> 	;shr	cx, 4
 21842                              <1> 	;mov	ax, es
 21843                              <1> 	;add	ax, cx
 21844                              <1> 	;mov	es, ax
 21845                              <1> 	;and	bx, 000Fh		; ES:BX CHANGED TO ES:000X
 21846                              <1> 	;;pop	ax
 21847                              <1> 	;;pop	cx
 21848                              <1> 	;;jmp	word [CS:SI+D1]
 21849                              <1> 	;jmp	word [SI+D1]
 21850                              <1> 	
 21851 00005154 FFA6[AC4F0000]      <1> 	jmp	dword [esi+D1]
 21852                              <1> 
 21853                              <1> 	; 07/08/2022
 21854                              <1> 	; 13/07/2022
 21855                              <1> BAD_COMMAND:
 21856 0000515A C605[17780100]01    <1>         mov	byte [DISK_STATUS1], BAD_CMD ; COMMAND ERROR
 21857 00005161 B000                <1> 	mov	al, 0
 21858 00005163 C3                  <1> 	retn
 21859                              <1> 
 21860                              <1> ; 09/08/2022
 21861                              <1> ; 07/08/2022
 21862                              <1> ; 17/07/2022
 21863                              <1> ; 16/07/2022 - TRDOS 386 v2.0.5
 21864                              <1> ; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 21865                              <1> 
 21866                              <1> ;----------------------------------------
 21867                              <1> ;	RESET THE DISK SYSTEM  (AH=00H) :
 21868                              <1> ;----------------------------------------
 21869                              <1> 
 21870                              <1> ; 18-1-2015 : one controller reset (not other one)
 21871                              <1> 
 21872                              <1> DISK_RESET:
 21873 00005164 FA                  <1> 	cli
 21874 00005165 E4A1                <1> 	in	al, INTB01		; GET THE MASK REGISTER
 21875                              <1> 	;jmp	$+2
 21876                              <1> 	IODELAY
 21877 00005167 EB00                <2>  jmp short $+2
 21878 00005169 EB00                <2>  jmp short $+2
 21879                              <1> 	;and	al, 0BFh 		; ENABLE FIXED DISK INTERRUPT
 21880 0000516B 243F                <1> 	and	al, 3Fh			; 22/12/2014 (IRQ 14 & IRQ 15)
 21881 0000516D E6A1                <1> 	out	INTB01, al
 21882 0000516F FB                  <1> 	sti				; START INTERRUPTS
 21883                              <1> 	; 14/02/2015
 21884                              <1> 	;mov	di, dx
 21885                              <1> 	; 24/12/2021
 21886 00005170 89D7                <1> 	mov	edi, edx	
 21887                              <1> 	; 04/01/2015
 21888                              <1> 	;xor	di,di
 21889                              <1> drst0:
 21890 00005172 B004                <1> 	mov	al, 04h  ; bit 2 - SRST 
 21891                              <1> 	;mov	dx, HF_REG_PORT
 21892 00005174 668B15[F0640000]    <1> 	mov	dx, [HF_REG_PORT]
 21893 0000517B EE                  <1> 	out	dx, al			; RESET
 21894                              <1> ;	mov	cx, 10			; DELAY COUNT
 21895                              <1> ;DRD:	dec	cx
 21896                              <1> ;	jnz	short DRD		; WAIT 4.8 MICRO-SEC
 21897                              <1> 	;mov	cx, 2			; wait for 30 micro seconds	
 21898                              <1>         ;mov	ecx, 2 ; 21/02/2015
 21899                              <1> 	; 10/07/2022
 21900 0000517C 29C9                <1> 	sub	ecx, ecx
 21901 0000517E B102                <1> 	mov	cl, 2
 21902 00005180 E8DFD1FFFF          <1> 	call    WAITF                   ; (Award Bios 1999 - WAIT_REFRESH,
 21903                              <1>                                         ; 40 micro seconds)
 21904 00005185 A0[19780100]        <1> 	mov	al, [CONTROL_BYTE]
 21905 0000518A 240F                <1> 	and	al, 0Fh			; SET HEAD OPTION
 21906 0000518C EE                  <1> 	out	dx, al			; TURN RESET OFF
 21907 0000518D E8FD030000          <1> 	call	NOT_BUSY
 21908 00005192 7514                <1> 	jnz	short DRERR		; TIME OUT ON RESET
 21909 00005194 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 21910 0000519B FEC2                <1> 	inc	dl  ; HF_PORT+1
 21911                              <1> 	; 02/01/2015 - Award BIOS 1999 - AHDSK.ASM
 21912                              <1>         ;mov	cl, 10
 21913                              <1>         ;mov	ecx, 10 ; 21/02/2015
 21914                              <1> 	; 17/07/2022
 21915                              <1> 	;xor	ecx, ecx
 21916 0000519D B10A                <1> 	mov	cl, 10
 21917                              <1> drst1:
 21918 0000519F EC                  <1> 	in	al, dx			; GET RESET STATUS
 21919 000051A0 3C01                <1> 	cmp	al, 1
 21920                              <1> 	; 04/01/2015
 21921 000051A2 740C                <1> 	jz	short drst2
 21922                              <1> 	;jnz	short DRERR		; BAD RESET STATUS
 21923                              <1>         	; Drive/Head Register - bit 4
 21924                              <1> 	;loop	drst1
 21925                              <1> 	; 17/07/2022
 21926 000051A4 FEC9                <1> 	dec	cl
 21927 000051A6 75F7                <1> 	jnz	short drst1
 21928                              <1> DRERR:	
 21929 000051A8 C605[17780100]05    <1> 	mov	byte [DISK_STATUS1], BAD_RESET ; CARD FAILED
 21930 000051AF C3                  <1> 	retn
 21931                              <1> drst2:
 21932                              <1> 	; 14/02/2015
 21933                              <1> 	;mov	dx, di
 21934                              <1> 	; 07/08/2022
 21935 000051B0 89FA                <1> 	mov	edx, edi
 21936                              <1> ;drst3:
 21937                              <1> ;	; 05/01/2015
 21938                              <1> ;	shl 	di, 1
 21939                              <1> ;	; 04/01/2015
 21940                              <1> ;	mov	ax, [di+hd_cports]
 21941                              <1> ;	cmp	ax, [HF_REG_PORT]
 21942                              <1> ;	je	short drst4
 21943                              <1> ;	mov	[HF_REG_PORT], ax
 21944                              <1> ;	; 03/01/2015
 21945                              <1> ;	mov	ax, [di+hd_ports]
 21946                              <1> ;       mov     [HF_PORT], ax
 21947                              <1> ;	; 05/01/2014
 21948                              <1> ;	shr	di, 1
 21949                              <1> ;	; 04/01/2015
 21950                              <1> ;	jmp	short drst0	; reset other controller
 21951                              <1> ;drst4:
 21952                              <1> ;	; 05/01/2015
 21953                              <1> ;	shr	di, 1
 21954                              <1> ;	mov	al, [di+hd_dregs]
 21955                              <1> ;	and	al, 10h ; bit 4 only
 21956                              <1> ;	shr	al, 4 ; bit 4  -> bit 0
 21957                              <1> ;	mov	[hf_m_s], al ; (0 = master, 1 = slave)
 21958                              <1> 	;
 21959                              <1> ; 09/08/2022
 21960                              <1> ; (('INIT_DRV' prodedure sets [CMD_BLOCKS+5] value))
 21961                              <1> ;
 21962                              <1> ;	mov	al, [hf_m_s] ; 18/01/2015
 21963                              <1> ;	test	al, 1
 21964                              <1> ;	;jnz	short drst6
 21965                              <1> ;       jnz     short drst4
 21966                              <1> ;	and	byte [CMD_BLOCK+5], 0EFh ; SET TO DRIVE 0
 21967                              <1> ;drst5:
 21968                              <1> drst3:
 21969 000051B2 E8F3010000          <1> 	call	INIT_DRV		; SET MAX HEADS
 21970                              <1> 	;mov	dx, di
 21971 000051B7 E8AB020000          <1> 	call	HDISK_RECAL		; RECAL TO RESET SEEK SPEED
 21972                              <1> 	; 04/01/2014
 21973                              <1> ;	inc	di
 21974                              <1> ;	mov	dx, di
 21975                              <1> ;	cmp	dl, [HF_NUM]
 21976                              <1> ;	jb	short drst3
 21977                              <1> ;DRE:
 21978 000051BC C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; IGNORE ANY SET UP ERRORS
 21979 000051C3 C3                  <1> 	retn
 21980                              <1> ;drst6:
 21981                              <1> drst4:		; Drive/Head Register - bit 4
 21982                              <1> ;	or	byte [CMD_BLOCK+5], 010h ; SET TO DRIVE 1
 21983                              <1> ;       ;jmp    short drst5
 21984                              <1> ;       jmp     short drst3
 21985                              <1> 
 21986                              <1> ;----------------------------------------
 21987                              <1> ;	DISK STATUS ROUTINE  (AH = 01H) :
 21988                              <1> ;----------------------------------------
 21989                              <1> 
 21990                              <1> RETURN_STATUS:
 21991 000051C4 A0[17780100]        <1> 	mov	al, [DISK_STATUS1]	; OBTAIN PREVIOUS STATUS
 21992 000051C9 C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0	; RESET STATUS
 21993 000051D0 C3                  <1> 	retn
 21994                              <1> 
 21995                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 21996                              <1> 
 21997                              <1> ;----------------------------------------
 21998                              <1> ;	READ LONG	     (AH = 0AH) :
 21999                              <1> ;----------------------------------------
 22000                              <1> 
 22001                              <1> RD_LONG:
 22002                              <1> 	;mov	@CMD_BLOCK+6, READ_CMD OR ECC_MODE
 22003 000051D1 C645FE22            <1> 	mov     byte [CMD_BLOCK+6], READ_CMD + ECC_MODE 
 22004 000051D5 EB04                <1> 	jmp	short COMMANDI
 22005                              <1> 
 22006                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22007                              <1> 
 22008                              <1> ;----------------------------------------
 22009                              <1> ;	DISK READ ROUTINE    (AH = 02H) :
 22010                              <1> ;----------------------------------------
 22011                              <1> 
 22012                              <1> DISK_READ:
 22013 000051D7 C645FE20            <1> 	mov	byte [CMD_BLOCK+6], READ_CMD
 22014                              <1>         ;jmp	COMMANDI
 22015                              <1> 
 22016                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22017                              <1> 
 22018                              <1> ;----------------------------------------
 22019                              <1> ; COMMANDI				:
 22020                              <1> ;	REPEATEDLY INPUTS DATA TILL	:
 22021                              <1> ;	NSECTOR RETURNS ZERO		:
 22022                              <1> ;----------------------------------------
 22023                              <1> COMMANDI:
 22024                              <1> 	; 16/07/2022 
 22025                              <1> 	;	(check 64K boundary is not needed)
 22026                              <1> 	;call	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
 22027                              <1> 	;jc	short CMD_ABORT
 22028                              <1> 
 22029                              <1> 	;mov	di, bx
 22030 000051DB 89DF                <1> 	mov	edi, ebx ; 21/02/2015
 22031 000051DD E80B030000          <1> 	call	COMMAND 		; OUTPUT COMMAND
 22032 000051E2 7548                <1> 	jnz	short CMD_ABORT
 22033                              <1> CMD_I1:
 22034 000051E4 E876030000          <1> 	call	_WAIT			; WAIT FOR DATA REQUEST INTERRUPT
 22035 000051E9 7541                <1> 	jnz	short TM_OUT		; TIME OUT
 22036                              <1> cmd_i1x:
 22037                              <1> 	; 18/02/2016
 22038                              <1> 	;;mov	cx, 256			; SECTOR SIZE IN WORDS
 22039                              <1> 	;mov	ecx, 256 ; 21/02/2015	
 22040                              <1> 	; 16/07/2022
 22041 000051EB 29C9                <1> 	sub	ecx, ecx
 22042 000051ED FEC5                <1> 	inc	ch  ; ecx = 256
 22043                              <1> 	;mov	dh, HF_PORT
 22044 000051EF 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22045 000051F6 FA                  <1> 	cli
 22046 000051F7 FC                  <1> 	cld
 22047 000051F8 F3666D              <1> 	rep	insw			; GET THE SECTOR
 22048 000051FB FB                  <1> 	sti
 22049                              <1> 
 22050 000051FC F645FE02            <1> 	test	byte [CMD_BLOCK+6], ECC_MODE ; CHECK FOR NORMAL INPUT
 22051 00005200 7418                <1> 	jz	short CMD_I3
 22052 00005202 E8AF030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
 22053 00005207 7223                <1> 	jc	short TM_OUT
 22054                              <1> 	;mov	dx, HF_PORT
 22055 00005209 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22056                              <1> 	;;mov	cx, 4			; GET ECC BYTES
 22057                              <1> 	;mov 	ecx, 4 ; mov cx, 4
 22058                              <1> 	; 16/07/2022
 22059 00005210 31C9                <1>  	xor	ecx, ecx
 22060 00005212 B104                <1> 	mov	cl, 4
 22061                              <1> CMD_I2:
 22062 00005214 EC                  <1> 	in	al, dx
 22063 00005215 8807                <1> 	mov 	[edi], al ; 21/02/2015	; GO SLOW FOR BOARD
 22064 00005217 47                  <1> 	inc	edi
 22065 00005218 E2FA                <1> 	loop	CMD_I2
 22066                              <1> CMD_I3: 
 22067                              <1> 	; wait for 400 ns
 22068 0000521A 80C207              <1> 	add 	dl, 7
 22069 0000521D EC                  <1> 	in	al, dx
 22070 0000521E EC                  <1> 	in	al, dx
 22071 0000521F EC                  <1> 	in	al, dx
 22072                              <1> 	;
 22073 00005220 E8DE010000          <1> 	call	CHECK_STATUS
 22074 00005225 7505                <1> 	jnz	short CMD_ABORT		; ERROR RETURNED
 22075 00005227 FE4DF9              <1> 	dec	byte [CMD_BLOCK+1]	; CHECK FOR MORE
 22076                              <1> 	;jnz	short CMD_I1
 22077 0000522A 75BF                <1> 	jnz	short cmd_i1x ; 18/02/2016
 22078                              <1> CMD_ABORT:
 22079                              <1> TM_OUT: 
 22080 0000522C C3                  <1> 	retn
 22081                              <1> 
 22082                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22083                              <1> 
 22084                              <1> ;----------------------------------------
 22085                              <1> ;	WRITE LONG	     (AH = 0BH) :
 22086                              <1> ;----------------------------------------
 22087                              <1> 
 22088                              <1> WR_LONG:
 22089                              <1> 	;mov	@CMD_BLOCK+6, WRITE_CMD OR ECC_MODE
 22090 0000522D C645FE32            <1> 	mov	byte [CMD_BLOCK+6], WRITE_CMD + ECC_MODE
 22091 00005231 EB04                <1> 	jmp	short COMMANDO
 22092                              <1> 
 22093                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22094                              <1> 	
 22095                              <1> ;----------------------------------------
 22096                              <1> ;	DISK WRITE ROUTINE   (AH = 03H) :
 22097                              <1> ;----------------------------------------
 22098                              <1> 
 22099                              <1> DISK_WRITE:
 22100 00005233 C645FE30            <1> 	mov	byte [CMD_BLOCK+6], WRITE_CMD
 22101                              <1> 	;jmp	COMMANDO
 22102                              <1> 
 22103                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22104                              <1> 
 22105                              <1> ;----------------------------------------
 22106                              <1> ; COMMANDO				:
 22107                              <1> ;	REPEATEDLY OUTPUTS DATA TILL	:
 22108                              <1> ;	NSECTOR RETURNS ZERO		:
 22109                              <1> ;----------------------------------------
 22110                              <1> COMMANDO:
 22111                              <1> 	; 16/07/2022 
 22112                              <1> 	;	(check 64K boundary is not needed)
 22113                              <1> 	;call	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
 22114                              <1> 	;jc	short CMD_ABORT
 22115                              <1> CMD_OF: 
 22116 00005237 89DE                <1> 	mov	esi, ebx ; 21/02/2015
 22117 00005239 E8AF020000          <1> 	call	COMMAND 		; OUTPUT COMMAND
 22118 0000523E 75EC                <1> 	jnz	short CMD_ABORT
 22119 00005240 E871030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
 22120 00005245 72E5                <1> 	jc	short TM_OUT		; TOO LONG
 22121                              <1> CMD_O1: 
 22122                              <1> 	; 16/07/2022
 22123 00005247 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22124                              <1> 
 22125                              <1> 	;mov	ecx, 256 ; 21/02/2015
 22126 0000524E 31C9                <1> 	xor	ecx, ecx
 22127 00005250 FEC5                <1> 	inc	ch
 22128                              <1> 	; ecx = 256
 22129 00005252 FA                  <1> 	cli
 22130 00005253 FC                  <1> 	cld
 22131 00005254 F3666F              <1> 	rep	outsw
 22132 00005257 FB                  <1> 	sti
 22133                              <1> 
 22134 00005258 F645FE02            <1> 	test	byte [CMD_BLOCK+6], ECC_MODE ; CHECK FOR NORMAL OUTPUT
 22135 0000525C 7418                <1> 	jz	short CMD_O3
 22136 0000525E E853030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
 22137 00005263 72C7                <1> 	jc	short TM_OUT
 22138                              <1> 	;mov	dx, HF_PORT
 22139 00005265 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22140                              <1> 					; OUTPUT THE ECC BYTES
 22141                              <1> 	;mov	ecx, 4  ; mov cx, 4
 22142                              <1> 	; 16/07/2022
 22143 0000526C 29C9                <1> 	sub	ecx, ecx
 22144 0000526E B104                <1> 	mov	cl, 4
 22145                              <1> CMD_O2:
 22146 00005270 8A06                <1> 	mov	al, [esi]
 22147 00005272 EE                  <1> 	out	dx, al
 22148 00005273 46                  <1> 	inc	esi
 22149 00005274 E2FA                <1> 	loop	CMD_O2
 22150                              <1> CMD_O3:
 22151 00005276 E8E4020000          <1> 	call	_WAIT			; WAIT FOR SECTOR COMPLETE INTERRUPT
 22152 0000527B 75AF                <1> 	jnz	short TM_OUT		; ERROR RETURNED
 22153 0000527D E881010000          <1> 	call	CHECK_STATUS
 22154 00005282 75A8                <1> 	jnz	short CMD_ABORT
 22155 00005284 F605[11780100]08    <1> 	test	byte [HF_STATUS], ST_DRQ ; CHECK FOR MORE
 22156 0000528B 75BA                <1> 	jnz	short CMD_O1
 22157                              <1> 	;mov	dx, HF_PORT+2		; CHECK RESIDUAL SECTOR COUNT
 22158 0000528D 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22159 00005294 80C202              <1> 	add	dl, 2
 22160                              <1> 	;inc	dl
 22161                              <1> 	;inc	dl
 22162 00005297 EC                  <1> 	in	al, dx			;
 22163 00005298 A8FF                <1> 	test	al, 0FFh 		;
 22164 0000529A 7407                <1> 	jz	short CMD_O4		; COUNT = 0 OK
 22165 0000529C C605[17780100]BB    <1> 	mov	byte [DISK_STATUS1], UNDEF_ERR 
 22166                              <1> 					; OPERATION ABORTED - PARTIAL TRANSFER
 22167                              <1> CMD_O4:
 22168 000052A3 C3                  <1> 	retn
 22169                              <1> 
 22170                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22171                              <1> 
 22172                              <1> ;----------------------------------------
 22173                              <1> ;	FORMATTING	     (AH = 05H) :
 22174                              <1> ;----------------------------------------
 22175                              <1> 
 22176                              <1> FMT_TRK:				; FORMAT TRACK (AH = 005H)
 22177 000052A4 C645FE50            <1> 	mov	byte [CMD_BLOCK+6], FMTTRK_CMD
 22178                              <1> 	;push	es
 22179                              <1> 	;push	bx
 22180 000052A8 53                  <1> 	push	ebx
 22181 000052A9 E896030000          <1> 	call	GET_VEC 		; GET DISK PARAMETERS ADDRESS
 22182                              <1> 	;mov	al, [ES:BX+14]		; GET SECTORS/TRACK
 22183 000052AE 8A430E              <1> 	mov	al, [ebx+14]
 22184 000052B1 8845F9              <1> 	mov	[CMD_BLOCK+1], al	; SET SECTOR COUNT IN COMMAND
 22185 000052B4 5B                  <1> 	pop	ebx
 22186                              <1> 	;pop	bx
 22187                              <1> 	;pop	es
 22188 000052B5 EB80                <1> 	jmp	short CMD_OF		; GO EXECUTE THE COMMAND
 22189                              <1> 
 22190                              <1> ;----------------------------------------
 22191                              <1> ;	DISK VERIFY	     (AH = 04H) :
 22192                              <1> ;----------------------------------------
 22193                              <1> 
 22194                              <1> DISK_VERF:
 22195 000052B7 C645FE40            <1> 	mov	byte [CMD_BLOCK+6], VERIFY_CMD
 22196 000052BB E82D020000          <1> 	call	COMMAND
 22197 000052C0 750C                <1> 	jnz	short VERF_EXIT		; CONTROLLER STILL BUSY
 22198 000052C2 E898020000          <1> 	call	_WAIT			; (Original: CALL WAIT)	
 22199 000052C7 7505                <1> 	jnz	short VERF_EXIT		; TIME OUT
 22200 000052C9 E835010000          <1> 	call	CHECK_STATUS
 22201                              <1> VERF_EXIT:
 22202 000052CE C3                  <1> 	retn
 22203                              <1> 
 22204                              <1> ;----------------------------------------
 22205                              <1> ;	READ DASD TYPE	     (AH = 15H) :
 22206                              <1> ;----------------------------------------
 22207                              <1> 
 22208                              <1> RETURN_DRIVE_TYPE:
 22209                              <1> 	; 10/08/2022
 22210                              <1> 	; 13/07/2022
 22211                              <1> 	; (Ref: Programmer's Guide to the AMIBIOS -Page 214-, 1992)
 22212                              <1> 	;
 22213                              <1> 	; INPUT:
 22214                              <1> 	;	DL = Disk number (>= 80h)
 22215                              <1> 	;   TRDOS 386 v2.0.5 Feature:
 22216                              <1> 	;	If AL = 0FFh, return disk size in ECX
 22217                              <1> 	;		otherwise in CX:DX
 22218                              <1> 	; OUTPUT:
 22219                              <1> 	;	AH = 00h - No drive present
 22220                              <1> 	;	   = 03h - Hard disk drive
 22221                              <1> 	;	CF = 0 - No error
 22222                              <1> 	;	   = 1 - Error  	 
 22223                              <1> 	;   TRDOS 386 v2.0.5 Feature:
 22224                              <1> 	;	AL = 00h - LBA not ready !	
 22225                              <1> 	;	   = 01h - LBA ready 
 22226                              <1> 	;		(28 bit or 48 bit LBA r/w depending
 22227                              <1> 	;		on disk size in CX:DX)
 22228                              <1> 	;	CX:DX = Number of 512 byte sectors
 22229                              <1> 	;
 22230                              <1> 	; (Note: High words of ECX and EDX will be zero at return)
 22231                              <1> 	; ((If AL input is 0FFh, disk size will be in ECX only))
 22232                              <1> 
 22233                              <1> READ_DASD_TYPE:
 22234                              <1> READ_D_T:				; GET DRIVE PARAMETERS
 22235                              <1> 	;push	ds			; SAVE REGISTERS
 22236                              <1> 	
 22237                              <1> 	;;push	es
 22238                              <1> 	; 18/04/2021
 22239                              <1> 	;push	ebx
 22240                              <1> 	;;call	DDS			; ESTABLISH ADDRESSING
 22241                              <1> 	;;push	cs
 22242                              <1> 	;;pop	ds
 22243                              <1>         
 22244                              <1> 	; 18/04/2021
 22245                              <1> 	;mov	bx, KDATA
 22246                              <1> 	;mov	ds, bx
 22247                              <1> 	;;mov	es, bx
 22248                              <1> 	;mov	byte [DISK_STATUS1], 0
 22249                              <1> 	;mov	bl, [HF_NUM]		; GET NUMBER OF DRIVES
 22250                              <1> 	;and	dl, 7Fh			; GET DRIVE NUMBER
 22251                              <1> 	;cmp	bl, dl
 22252                              <1> 	;jbe	short RDT_NOT_PRESENT 	; RETURN DRIVE NOT PRESENT
 22253                              <1> 	
 22254                              <1> 	;mov	ax, KDATA
 22255                              <1> 	;mov	ds, ax
 22256                              <1> 	
 22257 000052CF C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0
 22258 000052D6 8A0D[18780100]      <1> 	mov	cl, [HF_NUM]
 22259 000052DC 80E27F              <1> 	and	dl, 7Fh
 22260 000052DF 38D1                <1> 	cmp	cl, dl
 22261 000052E1 7631                <1> 	jbe	short RDT_NOT_PRESENT
 22262                              <1> 
 22263                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
 22264                              <1> 	
 22265                              <1> 	;call	GET_VEC 		; GET DISK PARAMETER ADDRESS
 22266                              <1> 	;
 22267                              <1> 	;;mov	al, [ES:BX+2]		; HEADS
 22268                              <1> 	;mov	al, [ebx+2]  ; heads (logical)
 22269                              <1> 	;;;mov	cl, [ES:BX+14]
 22270                              <1> 	;;mov	cl, [ebx+14]
 22271                              <1> 	;; 17/04/2021
 22272                              <1> 	;mov	ah, [ebx+14] ; sectors per track (logical)
 22273                              <1> 	;;imul	cl			; * NUMBER OF SECTORS
 22274                              <1> 	;;mov	cx, [ES:BX]		; MAX NUMBER OF CYLINDERS
 22275                              <1> 	;mov	cx, [ebx]    ; cylinders (logical)
 22276                              <1> 	;; 02/01/2015 
 22277                              <1> 	;; ** leave the last cylinder as reserved for diagnostics **
 22278                              <1> 	;; (Also in Award BIOS - 1999, AHDSK.ASM, FUN15 -> sub ax, 1)
 22279                              <1> 	;dec	cx			; LEAVE ONE FOR DIAGNOSTICS
 22280                              <1> 	;;imul	cx			; NUMBER OF SECTORS	 	
 22281                              <1> 	;; 17/04/2021
 22282                              <1> 	;mul	ah
 22283                              <1> 	;; ax = spt*heads
 22284                              <1> 	;mul	cx	 
 22285                              <1> 	;; dx:ax = number of sectors
 22286                              <1> 	;
 22287                              <1> 	;mov	cx, dx			; HIGH ORDER HALF
 22288                              <1> 	;mov	dx, ax			; LOW ORDER HALF
 22289                              <1> 
 22290                              <1> 	; 18/04/2021
 22291 000052E3 B102                <1> 	mov	cl, 2
 22292 000052E5 00CA                <1> 	add	dl, cl ; hd0 = 2
 22293                              <1> 
 22294                              <1> 	; 13/07/2022
 22295 000052E7 0FB6D2              <1> 	movzx	edx, dl
 22296 000052EA 8A9A[1E650000]      <1> 	mov	bl, [edx+drv.status]
 22297 000052F0 80E301              <1> 	and	bl, 1 ; LBA ready bit (bit 0) 
 22298                              <1> 
 22299 000052F3 D2E2                <1> 	shl	dl, cl ; * 4
 22300                              <1> 	
 22301                              <1> 	;mov	eax, [edx+drv.size]
 22302                              <1> 	;mov	dx, ax
 22303                              <1> 	;shr	eax, 16
 22304                              <1> 	;mov	cx, ax
 22305                              <1> 
 22306 000052F5 8B8A[02650000]      <1> 	mov	ecx, [edx+drv.size]
 22307                              <1> 
 22308                              <1> 	; 13/07/2022
 22309                              <1> 	;cmp	al, 0FFh   ; return disk size in ecx ?
 22310                              <1> 	;je	short RDT1 ; yes
 22311 000052FB FEC0                <1> 	inc	al  ; 0FFh -> 0
 22312 000052FD 740A                <1> 	jz	short RDT1
 22313                              <1> 
 22314 000052FF 6689CA              <1> 	mov	dx, cx
 22315 00005302 C1E910              <1> 	shr	ecx, 16
 22316                              <1> 
 22317                              <1> 	; 13/07/2022
 22318                              <1> 	; ebx = esp+20
 22319                              <1> 	; ecx = esp+16
 22320                              <1> 	; edx = esp+12
 22321                              <1> 	; esi = esp+8
 22322                              <1> 	; edi = esp+4
 22323                              <1> 
 22324                              <1> 	; return disk size in user's registers
 22325 00005305 8954240C            <1> 	mov	[esp+12], edx
 22326                              <1> 	; cx:dx = disk size
 22327                              <1> RDT1:
 22328                              <1> 	;mov	[esp+16], ecx
 22329                              <1> 
 22330                              <1> 	;;sub	al, al
 22331 00005309 29C0                <1> 	sub	eax, eax
 22332 0000530B B403                <1> 	mov	ah, 03h			; INDICATE FIXED DISK
 22333 0000530D 88D8                <1> 	mov	al, bl
 22334                              <1> 	; al = 1 -> LBA r/w ready/applicable
 22335                              <1> 	;    = 0 -> LBA r/w not ready/applicable	 
 22336                              <1> 	; cf = 0
 22337                              <1> RDT2:
 22338 0000530F 894C2410            <1> 	mov	[esp+16], ecx	
 22339                              <1> ;RDT2:
 22340                              <1> 	; 13/07/2022
 22341                              <1> 	; 18/04/2021
 22342                              <1> 	;pop	ebx			; RESTORE REGISTERS
 22343                              <1> 	;;pop	es
 22344                              <1> 	;pop	ds
 22345                              <1> 	; (*) clc			; CLEAR CARRY
 22346                              <1> 	;retf	2
 22347                              <1> 	; (*) 29/05/2016
 22348                              <1> 	; (*) retf 4
 22349                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
 22350                              <1> 	;iretd
 22351                              <1> 
 22352                              <1> 	; 13/07/2022
 22353                              <1> 	; [DISK_STATUS1] = 0
 22354                              <1> 	; ah = 3
 22355                              <1> 	; al = 0 or 1 (LBA ready)
 22356                              <1> 	; cf = 0	
 22357                              <1> 	
 22358 00005313 C3                  <1> 	retn
 22359                              <1> 
 22360                              <1> RDT_NOT_PRESENT:
 22361                              <1> 	;;sub	ax, ax			; DRIVE NOT PRESENT RETURN
 22362                              <1> 	;; 18/04/2021
 22363                              <1> 	;sub	eax, eax
 22364                              <1> 	;;mov	cx, ax			; ZERO BLOCK COUNT
 22365                              <1> 	;;mov	dx, ax
 22366                              <1> 	;mov	ecx, eax
 22367                              <1> 	;mov	edx, eax
 22368                              <1> 	;jmp	short RDT2
 22369                              <1> 	; 13/07/2022
 22370 00005314 29C9                <1> 	sub	ecx, ecx
 22371 00005316 88C1                <1> 	mov	cl, al ; if AL = 0FFh, disk size will be in ECX
 22372                              <1> 		       ; if not, disk size will be in CX:DX 
 22373 00005318 29C0                <1> 	sub	eax, eax
 22374 0000531A FEC1                <1> 	inc	cl ; 0FFh -> 0
 22375 0000531C 80F901              <1> 	cmp	cl, 1
 22376 0000531F 72EE                <1> 	jb	short RDT2 ; ecx = 0
 22377                              <1> 	; 10/08/2022
 22378 00005321 28C9                <1> 	sub	cl, cl
 22379                              <1> 	; ecx = 0
 22380 00005323 8944240C            <1> 	mov	[esp+12], eax ; edx = 0
 22381 00005327 F9                  <1> 	stc
 22382 00005328 EBE5                <1> 	jmp	short RDT2 ; cf = 1, eax = 0	
 22383                              <1> 
 22384                              <1> ; 10/08/2022
 22385                              <1> ; 07/08/2022
 22386                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
 22387                              <1> ; 28/05/2016
 22388                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
 22389                              <1> 
 22390                              <1> ;----------------------------------------
 22391                              <1> ;	GET PARAMETERS	     (AH = 08H) :
 22392                              <1> ;----------------------------------------
 22393                              <1> 
 22394                              <1> GET_PARM_N:
 22395                              <1> 	; ebx = user's buffer address for parameters table
 22396                              <1> 	; 10/08/2022
 22397                              <1> 	; 13/07/2022
 22398                              <1> 	; (if ebx = 0, HDPT will not be returned to user)
 22399                              <1> 	;	
 22400                              <1> ;GET_PARM:				; GET DRIVE PARAMETERS
 22401                              <1> 	;push	ds			; SAVE REGISTERS
 22402                              <1> 	;push	es
 22403                              <1> 	
 22404                              <1> 	;push	ebx
 22405 0000532A 89DF                <1> 	mov	edi, ebx ; 13/07/2022 	
 22406                              <1> 
 22407                              <1> 	; 13/07/2022
 22408                              <1> 	; ((IBM PC XT-286 ROM BIOS source code remainders))
 22409                              <1> 	;;mov	ax, ABS0 		; ESTABLISH ADDRESSING
 22410                              <1> 	;;mov	ds, ax
 22411                              <1> 	
 22412                              <1> 	;;test	dl, 1			; CHECK FOR DRIVE 1
 22413                              <1> 	;;jz	short G0
 22414                              <1> 	;;les	bx, @HF1_TBL_VEC
 22415                              <1> 	;;jmp	short G1
 22416                              <1> ;;G0:	
 22417                              <1> 	;les	bx, @HF_TBL_VEC
 22418                              <1> ;;G1:
 22419                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
 22420                              <1> 	
 22421                              <1> 	; 13/07/2022
 22422                              <1> 	; 22/12/2014
 22423                              <1> 	;;push	cs
 22424                              <1> 	;;pop	ds
 22425                              <1> 	;mov	bx, KDATA
 22426                              <1> 	;mov	ds, bx
 22427                              <1> 	;mov	es, bx	; 27/05/2016
 22428                              <1> 	;
 22429                              <1> 	; 18/04/2021
 22430 0000532C 29C9                <1> 	sub	ecx, ecx
 22431                              <1> 	;
 22432 0000532E 80EA80              <1> 	sub	dl, 80h
 22433 00005331 80FA04              <1> 	cmp	dl, MAX_FILE		; TEST WITHIN RANGE
 22434 00005334 7344                <1> 	jae	short G2 ; 13/07/2022
 22435                              <1> 	;
 22436                              <1>  	; 21/02/2015
 22437 00005336 31DB                <1> 	xor	ebx, ebx
 22438                              <1> 	; 18/04/2021
 22439                              <1> 	;sub	ecx, ecx
 22440                              <1> 	; 22/12/2014
 22441 00005338 88D3                <1> 	mov	bl, dl
 22442                              <1> 	;xor	bh, bh  
 22443 0000533A C0E302              <1> 	shl	bl, 2			; convert index to offset
 22444                              <1> 	;add	bx, HF_TBL_VEC
 22445 0000533D 81C3[1C780100]      <1> 	add	ebx, HF_TBL_VEC
 22446                              <1> 	;mov	ax, [bx+2]
 22447                              <1> 	;mov	es, ax			; dpt segment
 22448                              <1> 	;mov	bx, [bx]		; dpt offset
 22449 00005343 8B1B                <1> 	mov	ebx, [ebx] ; 32 bit offset	
 22450                              <1> 	; 18/04/2021
 22451 00005345 29D2                <1> 	sub	edx, edx
 22452 00005347 8815[17780100]      <1>  	mov	[DISK_STATUS1], dl ; 0
 22453                              <1> 
 22454                              <1> 	;mov	byte [DISK_STATUS1], 0
 22455                              <1>         ;mov	ax, [ES:BX]		; MAX NUMBER OF CYLINDERS
 22456 0000534D 668B03              <1> 	mov	ax, [ebx]
 22457                              <1> 	;;sub	ax, 2			; ADJUST FOR 0-N
 22458 00005350 6648                <1> 	dec	ax			; max. cylinder number
 22459 00005352 88C5                <1> 	mov	ch, al
 22460 00005354 66250003            <1> 	and	ax, 0300h		; HIGH TWO BITS OF CYLINDER
 22461                              <1> 	;shr	ax, 1
 22462                              <1> 	;shr	ax, 1
 22463                              <1> 	; 13/07/2022
 22464                              <1> 	;shr	ax, 2
 22465                              <1> 	; 07/08/2022
 22466 00005358 C1E802              <1> 	shr	eax, 2
 22467                              <1> 	;or	al, [ES:BX+14]		; SECTORS
 22468 0000535B 0A430E              <1> 	or	al, [ebx+14]
 22469 0000535E 88C1                <1> 	mov	cl, al
 22470                              <1> 	;mov	dh, [ES:BX+2]		; HEADS
 22471 00005360 8A7302              <1> 	mov	dh, [ebx+2]
 22472 00005363 FECE                <1> 	dec	dh			; 0-N RANGE
 22473 00005365 8A15[18780100]      <1> 	mov	dl, [HF_NUM]		; DRIVE COUNT
 22474                              <1> 	;;sub	ax, ax
 22475                              <1> 	; 18/04/2021
 22476                              <1> 	;sub	eax, eax
 22477                              <1> 
 22478                              <1> 	; 27/12/2014 
 22479                              <1> 	;mov	di, bx			; HDPT offset
 22480                              <1> 
 22481                              <1> 	; 13/07/2022
 22482                              <1> 	; ebx = esp+20
 22483                              <1> 	; ecx = esp+16
 22484                              <1> 	; edx = esp+12
 22485                              <1> 	; esi = esp+8
 22486                              <1> 	; edi = esp+4
 22487                              <1> 
 22488                              <1> 	; 13/07/2022
 22489                              <1> 	; set return register contents/values
 22490 0000536B 894C2410            <1> 	mov	[esp+16], ecx
 22491 0000536F 8954240C            <1> 	mov	[esp+12], edx
 22492                              <1> 
 22493                              <1> 	; is hard disk parameters table requested ?
 22494 00005373 09FF                <1> 	or	edi, edi ; (edi = [ebp+24] = ebx)
 22495 00005375 751B                <1> 	jnz	short G3 ; yes
 22496                              <1> 
 22497 00005377 29C0                <1> 	sub	eax, eax	
 22498                              <1> 
 22499                              <1> 	; [DISK_STATUS1] = 0
 22500                              <1> 	; eax = 0
 22501                              <1> 	; cf = 0
 22502                              <1> 
 22503 00005379 C3                  <1> 	retn
 22504                              <1> 
 22505                              <1> G2:
 22506                              <1> 	;mov	ah, INIT_FAIL
 22507                              <1> 	;mov	byte [DISK_STATUS1], ah ; (INIT_FAIL)
 22508                              <1> 	;				; OPERATION FAILED
 22509                              <1> 	;sub	al, al
 22510                              <1> 	;sub	dx, dx
 22511                              <1> 	;sub	cx, cx
 22512                              <1> 	; 18/04/2021
 22513 0000537A 29C0                <1> 	sub	eax, eax
 22514 0000537C B407                <1> 	mov	ah, INIT_FAIL
 22515 0000537E 8825[17780100]      <1> 	mov     [DISK_STATUS1], ah	; OPERATION FAILED
 22516                              <1> 
 22517                              <1> 	; 13/07/2022
 22518                              <1> 	;sub	edx, edx
 22519                              <1> 	;sub	ecx, ecx
 22520                              <1> 	; ecx = 0
 22521 00005384 894C240C            <1> 	mov	[esp+12], ecx ; 0 ; edx (heads-1, drive count)
 22522 00005388 894C2410            <1> 	mov	[esp+16], ecx ; 0 ; ecx (cylinders-1, sectors)
 22523 0000538C 894C2414            <1> 	mov	[esp+20], ecx ; 0 ; ebx (HDPT address)
 22524                              <1> 
 22525 00005390 F9                  <1> 	stc
 22526 00005391 C3                  <1> 	retn
 22527                              <1> 
 22528                              <1> 	; 13/07/2022
 22529                              <1> 	; 29/05/2016 (*)
 22530                              <1> 	;;stc				; SET ERROR FLAG
 22531                              <1> 	;;jmp	short G5
 22532                              <1> 	;jmp	short _G6
 22533                              <1> 
 22534                              <1> G3:	
 22535                              <1> 	; 27/05/2016
 22536                              <1> 	; return fixed disk parameters table to user
 22537                              <1> 	; in user's buffer, which is pointed by EBX
 22538                              <1> 	
 22539                              <1> 	;xchg	edi, [esp]		; ebx (input)-> edi, edi -> [esp]
 22540                              <1> 	; 13/07/2022
 22541                              <1> 	;pop	edi
 22542                              <1> 	; edi = user's buffer address
 22543                              <1> 	;push	esi
 22544 00005392 89DE                <1> 	mov	esi, ebx		; hard disk parameter table (32 bytes)	
 22545                              <1> 	;mov	ebx, edi		; ebx = user's buffer address
 22546 00005394 51                  <1> 	push	ecx
 22547                              <1> 	;push	eax
 22548                              <1> 	;mov	ecx, 32 ; 32 bytes
 22549 00005395 30ED                <1> 	xor	ch, ch
 22550 00005397 B120                <1> 	mov	cl, 32
 22551                              <1> 	; ecx = 32
 22552 00005399 E88FB90000          <1> 	call	transfer_to_user_buffer ; trdosk6.s (16/05/2016)
 22553                              <1> 	;pop	eax
 22554 0000539E 59                  <1> 	pop	ecx
 22555                              <1> 	; 10/08/2022
 22556                              <1> 	;pop	esi
 22557                              <1> 	;pop	edi
 22558 0000539F 7306                <1> 	jnc	short G4
 22559                              <1> 	; 29/05/2016 (*)
 22560 000053A1 B8FF000000          <1> 	mov	eax, 0FFh ; unknown error !
 22561                              <1> 	; [DISK_STATUS1] = 0
 22562                              <1> 	; ah = 0, al = 0FFh
 22563                              <1> 	; cf = 1
 22564                              <1> 	
 22565 000053A6 C3                  <1> 	retn
 22566                              <1> ;_G6:
 22567                              <1> 	;or	byte [esp+16], 1 ; set carry bit of eflags register
 22568                              <1> ;G5:
 22569                              <1> 	; 27/05/2016
 22570                              <1> 	;pop	ebx			; RESTORE REGISTERS
 22571                              <1> 	;pop	es
 22572                              <1> 	;pop	ds
 22573                              <1> 	;;retf	2
 22574                              <1> 	; (*) 29/05/2016
 22575                              <1> 	; (*) retf 4
 22576                              <1> 	; (*) or byte [esp+8], 1 ; set carry bit of eflags register
 22577                              <1> 	;iretd
 22578                              <1> 
 22579                              <1> G4:
 22580                              <1> 	; 13/07/2022
 22581 000053A7 31C0                <1> 	xor	eax, eax
 22582                              <1> 
 22583                              <1> 	; [user_buffer] = [ebp+24] = HDPT
 22584                              <1> 	; [DISK_STATUS1] = 0
 22585                              <1> 	; eax = 0
 22586                              <1> 	; cf = 0
 22587                              <1> 
 22588 000053A9 C3                  <1> 	retn
 22589                              <1> 
 22590                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22591                              <1> 	
 22592                              <1> ;----------------------------------------
 22593                              <1> ;	INITIALIZE DRIVE     (AH = 09H) :
 22594                              <1> ;----------------------------------------
 22595                              <1> 	; 03/01/2015
 22596                              <1> 	; According to ATA-ATAPI specification v2.0 to v5.0
 22597                              <1> 	; logical sector per logical track
 22598                              <1> 	; and logical heads - 1 would be set but
 22599                              <1> 	; it is seen as it will be good
 22600                              <1> 	; if physical parameters will be set here
 22601                              <1> 	; because, number of heads <= 16.
 22602                              <1> 	; (logical heads usually more than 16)
 22603                              <1> 	; NOTE: ATA logical parameters (software C, H, S)
 22604                              <1> 	;	== INT 13h physical parameters
 22605                              <1> 
 22606                              <1> ;INIT_DRV:
 22607                              <1> ;	mov	byte [CMD_BLOCK+6], SET_PARM_CMD
 22608                              <1> ;	call	GET_VEC 		; ES:BX -> PARAMETER BLOCK
 22609                              <1> ;	mov	al, [es:bx+2]		; GET NUMBER OF HEADS
 22610                              <1> ;	dec	al			; CONVERT TO 0-INDEX
 22611                              <1> ;	mov	ah, [CMD_BLOCK+5] 	; GET SDH REGISTER
 22612                              <1> ;	and	ah, 0F0h 		; CHANGE HEAD NUMBER
 22613                              <1> ;	or	ah, al			; TO MAX HEAD
 22614                              <1> ;	mov	[CMD_BLOCK+5], ah
 22615                              <1> ;	mov	al, [es:bx+14]		; MAX SECTOR NUMBER
 22616                              <1> ;	mov	[CMD_BLOCK+1], al
 22617                              <1> ;	sub	ax, ax
 22618                              <1> ;	mov	[CMD_BLOCK+3], al 	; ZERO FLAGS
 22619                              <1> ;	call	COMMAND 		; TELL CONTROLLER
 22620                              <1> ;	jnz	short INIT_EXIT		; CONTROLLER BUSY ERROR
 22621                              <1> ;	call	NOT_BUSY		; WAIT FOR IT TO BE DONE
 22622                              <1> ;	jnz	short INIT_EXIT		; TIME OUT
 22623                              <1> ;	call	CHECK_STATUS
 22624                              <1> ;INIT_EXIT:
 22625                              <1> ;	retn
 22626                              <1> 
 22627                              <1> ; 16/07/2022 - TRDOS 386 v2.0.5
 22628                              <1> 
 22629                              <1> ; 04/01/2015
 22630                              <1> ; 02/01/2015 - Derived from from AWARD BIOS 1999
 22631                              <1> ;				 AHDSK.ASM - INIT_DRIVE
 22632                              <1> INIT_DRV:
 22633                              <1> 	;xor	ah,ah
 22634 000053AA 31C0                <1> 	xor	eax, eax ; 21/02/2015
 22635 000053AC B00B                <1> 	mov	al, 11 ; Physical heads from translated HDPT
 22636 000053AE 3825[2C780100]      <1>         cmp     [LBAMode], ah   ; 0
 22637 000053B4 7702                <1> 	ja	short idrv0
 22638 000053B6 B002                <1> 	mov	al, 2  ; Physical heads from standard HDPT
 22639                              <1> idrv0:
 22640                              <1> 	; DL = drive number (0 based)
 22641 000053B8 E887020000          <1> 	call	GET_VEC
 22642                              <1> 	;push	bx
 22643 000053BD 53                  <1> 	push	ebx ; 21/02/2015
 22644                              <1> 	;add	bx, ax
 22645 000053BE 01C3                <1> 	add	ebx, eax
 22646                              <1> 	;; 05/01/2015
 22647 000053C0 8A25[F2640000]      <1> 	mov	ah, [hf_m_s] ; drive number (0= master, 1= slave)
 22648                              <1> 	;;and 	ah, 1 
 22649 000053C6 C0E404              <1> 	shl	ah, 4
 22650 000053C9 80CCA0              <1> 	or	ah, 0A0h  ; Drive/Head register - 10100000b (A0h)	
 22651                              <1> 	;mov	al, [es:bx]
 22652 000053CC 8A03                <1> 	mov	al, [ebx] ; 21/02/2015
 22653 000053CE FEC8                <1> 	dec	al	 ; last head number 
 22654                              <1> 	;and	al, 0Fh
 22655 000053D0 08E0                <1> 	or	al, ah	 ; lower 4 bits for head number
 22656                              <1> 	;
 22657 000053D2 C645FE91            <1> 	mov	byte [CMD_BLOCK+6], SET_PARM_CMD
 22658 000053D6 8845FD              <1> 	mov	[CMD_BLOCK+5], al
 22659                              <1> 	;pop	bx
 22660 000053D9 5B                  <1> 	pop	ebx
 22661 000053DA 29C0                <1> 	sub	eax, eax ; 21/02/2015
 22662 000053DC B004                <1> 	mov	al, 4	; Physical sec per track from translated HDPT
 22663 000053DE 803D[2C780100]00    <1> 	cmp	byte [LBAMode], 0
 22664 000053E5 7702                <1> 	ja	short idrv1
 22665 000053E7 B00E                <1> 	mov	al, 14	; Physical sec per track from standard HDPT
 22666                              <1> idrv1:
 22667                              <1> 	;xor	ah, ah
 22668                              <1> 	;add	bx, ax
 22669 000053E9 01C3                <1> 	add	ebx, eax ; 21/02/2015
 22670                              <1> 	;mov	al, [es:bx]
 22671                              <1> 			; sector number
 22672 000053EB 8A03                <1> 	mov	al, [ebx]
 22673 000053ED 8845F9              <1> 	mov	[CMD_BLOCK+1], al
 22674 000053F0 28C0                <1> 	sub	al, al
 22675 000053F2 8845FB              <1> 	mov	[CMD_BLOCK+3], al ; ZERO FLAGS
 22676 000053F5 E8F3000000          <1> 	call	COMMAND 	  ; TELL CONTROLLER
 22677 000053FA 751E                <1> 	jnz	short INIT_EXIT	  ; CONTROLLER BUSY ERROR
 22678 000053FC E88E010000          <1> 	call	NOT_BUSY	  ; WAIT FOR IT TO BE DONE
 22679 00005401 7517                <1> 	jnz	short INIT_EXIT	  ; TIME OUT
 22680                              <1> 	; 16/07/2022
 22681                              <1> 	;call	CHECK_STATUS
 22682                              <1> 	;jmp	short CHECK_STATUS
 22683                              <1> ;INIT_EXIT:
 22684                              <1> 	;retn
 22685                              <1> 
 22686                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22687                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 22688                              <1> 
 22689                              <1> ;----------------------------------------
 22690                              <1> ;	CHECK FIXED DISK STATUS 	:
 22691                              <1> ;----------------------------------------
 22692                              <1> CHECK_STATUS:
 22693 00005403 E8D9010000          <1> 	call	CHECK_ST		; CHECK THE STATUS BYTE
 22694                              <1> 	;jnz	short CHECK_S1		; AN ERROR WAS FOUND
 22695                              <1> 	; 10/07/2022
 22696 00005408 7510                <1> 	jnz	short CHECK_S2
 22697 0000540A A801                <1> 	test	al, ST_ERROR		; WERE THERE ANY OTHER ERRORS
 22698 0000540C 7405                <1> 	jz	short CHECK_S1		; NO ERROR REPORTED
 22699 0000540E E80E020000          <1> 	call	CHECK_ER		; ERROR REPORTED
 22700                              <1> CHECK_S1:
 22701 00005413 803D[17780100]00    <1> 	cmp	byte [DISK_STATUS1], 0 	; SET STATUS FOR CALLER
 22702                              <1> CHECK_S2:
 22703                              <1> INIT_EXIT:	; 10/07/2022
 22704 0000541A C3                  <1> 	retn
 22705                              <1> 
 22706                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22707                              <1> 
 22708                              <1> ;----------------------------------------
 22709                              <1> ;	SEEK		     (AH = 0CH) :
 22710                              <1> ;----------------------------------------
 22711                              <1> 
 22712                              <1> DISK_SEEK:
 22713 0000541B C645FE70            <1>         mov	byte [CMD_BLOCK+6], SEEK_CMD
 22714 0000541F E8C9000000          <1> 	call	COMMAND
 22715 00005424 751C                <1> 	jnz	short DS_EXIT		; CONTROLLER BUSY ERROR
 22716 00005426 E834010000          <1> 	call	_WAIT
 22717 0000542B 7515                <1>         jnz	short DS_EXIT		; TIME OUT ON SEEK
 22718 0000542D E8D1FFFFFF          <1> 	call	CHECK_STATUS
 22719 00005432 803D[17780100]40    <1>         cmp	byte [DISK_STATUS1], BAD_SEEK
 22720 00005439 7507                <1> 	jne	short DS_EXIT
 22721 0000543B C605[17780100]00    <1>         mov	byte [DISK_STATUS1], 0
 22722                              <1> DS_EXIT:
 22723 00005442 C3                  <1> 	retn
 22724                              <1> 
 22725                              <1> ;----------------------------------------
 22726                              <1> ;	TEST DISK READY      (AH = 10H) :
 22727                              <1> ;----------------------------------------
 22728                              <1> 
 22729                              <1> TST_RDY:				; WAIT FOR CONTROLLER
 22730 00005443 E847010000          <1> 	call	NOT_BUSY
 22731 00005448 751C                <1> 	jnz	short TR_EX
 22732 0000544A 8A45FD              <1> 	mov	al, [CMD_BLOCK+5] 	; SELECT DRIVE
 22733 0000544D 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22734 00005454 80C206              <1> 	add	dl, 6
 22735 00005457 EE                  <1> 	out	dx, al
 22736 00005458 E884010000          <1> 	call	CHECK_ST		; CHECK STATUS ONLY
 22737 0000545D 7507                <1> 	jnz	short TR_EX
 22738 0000545F C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; WIPE OUT DATA CORRECTED ERROR
 22739                              <1> TR_EX:	
 22740 00005466 C3                  <1> 	retn
 22741                              <1> 
 22742                              <1> ;----------------------------------------
 22743                              <1> ;	RECALIBRATE	     (AH = 11H) :
 22744                              <1> ;----------------------------------------
 22745                              <1> 
 22746                              <1> HDISK_RECAL:
 22747 00005467 C645FE10            <1>         mov	byte [CMD_BLOCK+6], RECAL_CMD ; 10h, 16
 22748 0000546B E87D000000          <1> 	call	COMMAND 		; START THE OPERATION
 22749 00005470 7523                <1> 	jnz	short RECAL_EXIT	; ERROR
 22750 00005472 E8E8000000          <1> 	call	_WAIT			; WAIT FOR COMPLETION
 22751 00005477 7407                <1> 	jz	short RECAL_X 		; TIME OUT ONE OK ?
 22752 00005479 E8E1000000          <1> 	call	_WAIT			; WAIT FOR COMPLETION LONGER
 22753 0000547E 7515                <1> 	jnz	short RECAL_EXIT	; TIME OUT TWO TIMES IS ERROR
 22754                              <1> RECAL_X:
 22755 00005480 E87EFFFFFF          <1> 	call	CHECK_STATUS
 22756 00005485 803D[17780100]40    <1> 	cmp	byte [DISK_STATUS1], BAD_SEEK ; SEEK NOT COMPLETE
 22757 0000548C 7507                <1> 	jne	short RECAL_EXIT	; IS OK
 22758 0000548E C605[17780100]00    <1> 	mov	byte [DISK_STATUS1], 0
 22759                              <1> RECAL_EXIT:
 22760 00005495 803D[17780100]00    <1>         cmp	byte [DISK_STATUS1], 0
 22761 0000549C C3                  <1> 	retn
 22762                              <1> 
 22763                              <1> ;----------------------------------------
 22764                              <1> ;      CONTROLLER DIAGNOSTIC (AH = 14H) :
 22765                              <1> ;----------------------------------------
 22766                              <1> 
 22767                              <1> CTLR_DIAGNOSTIC:
 22768                              <1> 	; 07/08/2022 - TRDOS 386 v2.0.5
 22769 0000549D FA                  <1> 	cli				; DISABLE INTERRUPTS WHILE CHANGING MASK
 22770 0000549E E4A1                <1> 	in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
 22771                              <1> 	;and	al, 0BFH
 22772 000054A0 243F                <1> 	and	al, 3Fh			; enable IRQ 14 & IRQ 15
 22773                              <1> 	;jmp	$+2
 22774                              <1> 	IODELAY
 22775 000054A2 EB00                <2>  jmp short $+2
 22776 000054A4 EB00                <2>  jmp short $+2
 22777 000054A6 E6A1                <1> 	out	INTB01, al
 22778                              <1> 	IODELAY
 22779 000054A8 EB00                <2>  jmp short $+2
 22780 000054AA EB00                <2>  jmp short $+2
 22781 000054AC E421                <1> 	in	al, INTA01		; LET INTERRUPTS PASS THRU TO
 22782 000054AE 24FB                <1> 	and	al, 0FBh 		;  SECOND CHIP
 22783                              <1> 	;jmp	$+2
 22784                              <1> 	IODELAY
 22785 000054B0 EB00                <2>  jmp short $+2
 22786 000054B2 EB00                <2>  jmp short $+2
 22787 000054B4 E621                <1> 	out	INTA01, al
 22788 000054B6 FB                  <1> 	sti
 22789 000054B7 E8D3000000          <1> 	call	NOT_BUSY		; WAIT FOR CARD
 22790 000054BC 7526                <1> 	jnz	short CD_ERR		; BAD CARD
 22791                              <1> 	;mov	dx, PORT+7
 22792 000054BE 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22793 000054C5 80C207              <1> 	add	dl, 7
 22794 000054C8 B090                <1> 	mov	al, DIAG_CMD		; START DIAGNOSE
 22795 000054CA EE                  <1> 	out	dx, al
 22796 000054CB E8BF000000          <1> 	call	NOT_BUSY		; WAIT FOR IT TO COMPLETE
 22797 000054D0 B480                <1> 	mov	ah, TIME_OUT
 22798 000054D2 7512                <1> 	jnz	short CD_EXIT 		; TIME OUT ON DIAGNOSTIC
 22799                              <1> 	;mov	dx, HF_PORT+1		; GET ERROR REGISTER
 22800 000054D4 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22801 000054DB FEC2                <1> 	inc	dl
 22802 000054DD EC                  <1> 	in	al, dx
 22803                              <1> 	; 07/08/2022
 22804                              <1> 	;mov	[HF_ERROR], al		; SAVE IT
 22805 000054DE B400                <1> 	mov	ah, 0
 22806 000054E0 3C01                <1> 	cmp	al, 1			; CHECK FOR ALL OK
 22807 000054E2 7402                <1> 	je	short CD_EXIT
 22808                              <1> CD_ERR:
 22809 000054E4 B420                <1> 	mov	ah, BAD_CNTLR
 22810                              <1> CD_EXIT:
 22811 000054E6 8825[17780100]      <1> 	mov	[DISK_STATUS1], ah
 22812 000054EC C3                  <1> 	retn
 22813                              <1> 
 22814                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22815                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 22816                              <1> 
 22817                              <1> ;--------------------------------------------------------
 22818                              <1> ; COMMAND						:
 22819                              <1> ;	THIS ROUTINE OUTPUTS THE COMMAND BLOCK		:
 22820                              <1> ; OUTPUT						:
 22821                              <1> ;	BL = STATUS					:
 22822                              <1> ;	BH = ERROR REGISTER				:
 22823                              <1> ;--------------------------------------------------------
 22824                              <1> 
 22825                              <1> COMMAND:
 22826                              <1> 	;push	ebx ; 10/07/2022	; WAIT FOR SEEK COMPLETE AND READY
 22827                              <1> 	;;mov	ecx, DELAY_2		; SET INITIAL DELAY BEFORE TEST
 22828                              <1> COMMAND1:
 22829                              <1> 	;;push	ecx			; SAVE LOOP COUNT
 22830 000054ED E851FFFFFF          <1> 	call	TST_RDY 		; CHECK DRIVE READY
 22831                              <1> 	;;pop	ecx
 22832                              <1> 	;pop	ebx ; 10/07/2022
 22833 000054F2 7418                <1> 	jz	short COMMAND2		; DRIVE IS READY
 22834 000054F4 803D[17780100]80    <1>         cmp	byte [DISK_STATUS1], TIME_OUT ; TST_RDY TIMED OUT--GIVE UP
 22835                              <1> 	;jz	short CMD_TIMEOUT
 22836                              <1> 	;;loop	COMMAND1		; KEEP TRYING FOR A WHILE
 22837                              <1> 	;jmp	short COMMAND4		; ITS NOT GOING TO GET READY
 22838 000054FB 7507                <1> 	jne	short COMMAND4
 22839                              <1> CMD_TIMEOUT:
 22840 000054FD C605[17780100]20    <1> 	mov	byte [DISK_STATUS1], BAD_CNTLR
 22841                              <1> COMMAND4:
 22842                              <1> 	;;pop	ebx ; 10/07/2022
 22843 00005504 803D[17780100]00    <1>         cmp	byte [DISK_STATUS1], 0	; SET CONDITION CODE FOR CALLER
 22844 0000550B C3                  <1> 	retn
 22845                              <1> COMMAND2:
 22846                              <1> 	;;pop	ebx ; 10/07/2022
 22847                              <1> 	;push	edi ; 10/07/2022
 22848 0000550C C605[12780100]00    <1> 	mov	byte [HF_INT_FLAG], 0	; RESET INTERRUPT FLAG
 22849 00005513 FA                  <1> 	cli				; INHIBIT INTERRUPTS WHILE CHANGING MASK
 22850 00005514 E4A1                <1> 	in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
 22851                              <1> 	;and	al, 0BFh
 22852 00005516 243F                <1> 	and	al, 3Fh			; Enable IRQ 14 & 15
 22853                              <1> 	;jmp	$+2
 22854                              <1> 	IODELAY
 22855 00005518 EB00                <2>  jmp short $+2
 22856 0000551A EB00                <2>  jmp short $+2
 22857 0000551C E6A1                <1> 	out	INTB01, al
 22858 0000551E E421                <1> 	in	al, INTA01		; LET INTERRUPTS PASS THRU TO
 22859 00005520 24FB                <1> 	and	al, 0FBh 		; SECOND CHIP
 22860                              <1> 	;jmp	$+2
 22861                              <1> 	IODELAY
 22862 00005522 EB00                <2>  jmp short $+2
 22863 00005524 EB00                <2>  jmp short $+2
 22864 00005526 E621                <1> 	out	INTA01, al
 22865 00005528 FB                  <1> 	sti
 22866                              <1> 	;xor	edi, edi		; INDEX THE COMMAND TABLE
 22867                              <1> 	; 10/07/2022
 22868 00005529 31C9                <1> 	xor	ecx, ecx
 22869                              <1> 	;mov	dx, HF_PORT+1		; DISK ADDRESS
 22870 0000552B 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22871 00005532 FEC2                <1> 	inc	dl
 22872 00005534 F605[19780100]C0    <1> 	test	byte [CONTROL_BYTE], 0C0h ; CHECK FOR RETRY SUPPRESSION
 22873 0000553B 7411                <1> 	jz	short COMMAND3
 22874 0000553D 8A45FE              <1> 	mov	al, [CMD_BLOCK+6] 	; YES-GET OPERATION CODE
 22875 00005540 24F0                <1> 	and	al, 0F0h 		; GET RID OF MODIFIERS
 22876 00005542 3C20                <1> 	cmp	al, 20h			; 20H-40H IS READ, WRITE, VERIFY
 22877 00005544 7208                <1> 	jb	short COMMAND3
 22878 00005546 3C40                <1> 	cmp	al, 40h
 22879 00005548 7704                <1> 	ja	short COMMAND3
 22880 0000554A 804DFE01            <1> 	or	byte [CMD_BLOCK+6], NO_RETRIES 
 22881                              <1> 					; VALID OPERATION FOR RETRY SUPPRESS
 22882                              <1> COMMAND3:
 22883                              <1> 	;mov	al, [CMD_BLOCK+edi]	; GET THE COMMAND STRING BYTE
 22884                              <1> 	; 10/07/2022
 22885 0000554E 8A440DF8            <1> 	mov	al, [CMD_BLOCK+ecx]
 22886 00005552 EE                  <1> 	out	dx, al			; GIVE IT TO CONTROLLER
 22887                              <1> 	IODELAY
 22888 00005553 EB00                <2>  jmp short $+2
 22889 00005555 EB00                <2>  jmp short $+2
 22890                              <1> 	;inc	edi			; NEXT BYTE IN COMMAND BLOCK
 22891                              <1> 	; 10/07/2022
 22892 00005557 41                  <1> 	inc	ecx
 22893                              <1> 	;inc	dx			; NEXT DISK ADAPTER REGISTER
 22894 00005558 42                  <1> 	inc	edx   ; 10/07/2022	
 22895                              <1> 	;cmp	di, 7 ; 01/01/2015	; ALL DONE?
 22896                              <1> 	;jne	short COMMAND3		; NO--GO DO NEXT ONE
 22897 00005559 80F907              <1> 	cmp	cl, 7 ; 10/07/2022
 22898 0000555C 72F0                <1> 	jb	short COMMAND3
 22899                              <1> 	;pop	edi ; 10/07/2022
 22900 0000555E C3                  <1> 	retn				; ZERO FLAG IS SET
 22901                              <1> 
 22902                              <1> ;CMD_TIMEOUT:
 22903                              <1> ;	mov	byte [DISK_STATUS1], BAD_CNTLR
 22904                              <1> ;COMMAND4:
 22905                              <1> ;	pop	ebx
 22906                              <1> ;	cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
 22907                              <1> ;	retn
 22908                              <1> 
 22909                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22910                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 22911                              <1> 
 22912                              <1> ;----------------------------------------
 22913                              <1> ;	WAIT FOR INTERRUPT		:
 22914                              <1> ;----------------------------------------
 22915                              <1> ;WAIT:
 22916                              <1> _WAIT:
 22917 0000555F FB                  <1> 	sti				; MAKE SURE INTERRUPTS ARE ON
 22918                              <1> 	;sub	cx, cx			; SET INITIAL DELAY BEFORE TEST
 22919                              <1> 	;clc
 22920                              <1> 	;mov	ax, 9000h		; DEVICE WAIT INTERRUPT
 22921                              <1> 	;int	15h
 22922                              <1> 	;jc	short WT2		; DEVICE TIMED OUT
 22923                              <1> 	;mov	bl, DELAY_1		; SET DELAY COUNT
 22924                              <1> 
 22925                              <1> 	;mov	bl, WAIT_HDU_INT_HI
 22926                              <1> 	;; 21/02/2015
 22927                              <1> 	;;mov	bl, WAIT_HDU_INT_HI + 1
 22928                              <1> 	;;mov	cx, WAIT_HDU_INT_LO
 22929 00005560 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH
 22930                              <1> 					; (AWARD BIOS -> WAIT_FOR_MEM)
 22931                              <1> ;-----	WAIT LOOP
 22932                              <1> 
 22933                              <1> WT1:	
 22934                              <1> 	;test	byte [HF_INT_FLAG], 80h	; TEST FOR INTERRUPT
 22935 00005565 F605[12780100]C0    <1> 	test 	byte [HF_INT_FLAG], 0C0h
 22936                              <1> 	;loopz	WT1
 22937 0000556C 7512                <1> 	jnz	short WT3		; INTERRUPT--LETS GO
 22938                              <1> 	;dec	bl
 22939                              <1> 	;jnz	short WT1		; KEEP TRYING FOR A WHILE
 22940                              <1> 
 22941                              <1> WT1_hi:
 22942 0000556E E461                <1> 	in	al, SYS1 ; 61h (PORT_B)	; wait for lo to hi
 22943 00005570 A810                <1> 	test	al, 10h			; transition on memory
 22944 00005572 75FA                <1> 	jnz	short WT1_hi		; refresh.
 22945                              <1> WT1_lo:
 22946 00005574 E461                <1> 	in	al, SYS1 		; 061h (PORT_B)	
 22947 00005576 A810                <1> 	test	al, 10h			
 22948 00005578 74FA                <1> 	jz	short WT1_lo
 22949 0000557A E2E9                <1> 	loop	WT1
 22950                              <1> 	;;or	bl, bl
 22951                              <1> 	;;jz	short WT2	
 22952                              <1> 	;;dec	bl
 22953                              <1> 	;;jmp	short WT1
 22954                              <1> 	;dec	bl
 22955                              <1> 	;jnz	short WT1	
 22956                              <1> WT2:	
 22957                              <1> 	; 10/07/2022
 22958                              <1> 	;mov	byte [DISK_STATUS1], TIME_OUT ; REPORT TIME OUT ERROR
 22959 0000557C B080                <1> 	mov	al, TIME_OUT
 22960 0000557E EB07                <1> 	jmp	short WT4
 22961                              <1> WT3:
 22962                              <1> 	;mov	byte [DISK_STATUS1], 0
 22963                              <1> 	;mov	byte [HF_INT_FLAG], 0
 22964 00005580 28C0                <1> 	sub	al, al ; 0
 22965 00005582 A2[12780100]        <1> 	mov	byte [HF_INT_FLAG], al
 22966                              <1> WT4:
 22967                              <1> NB2:	
 22968 00005587 A2[17780100]        <1> 	mov	byte [DISK_STATUS1], al
 22969                              <1> 
 22970                              <1> 	;cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
 22971 0000558C 20C0                <1> 	and	al, al
 22972                              <1> 	; zf = 0 -> time out, zf = 1 -> ok
 22973 0000558E C3                  <1> 	retn
 22974                              <1> 
 22975                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 22976                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 22977                              <1> 
 22978                              <1> ;----------------------------------------
 22979                              <1> ;	WAIT FOR CONTROLLER NOT BUSY	:
 22980                              <1> ;----------------------------------------
 22981                              <1> NOT_BUSY:
 22982 0000558F FB                  <1> 	sti				; MAKE SURE INTERRUPTS ARE ON
 22983                              <1> 	;push	ebx
 22984                              <1> 	;sub	cx, cx			; SET INITIAL DELAY BEFORE TEST
 22985 00005590 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 22986 00005597 80C207              <1> 	add	dl, 7			; Status port (HF_PORT+7)
 22987                              <1> 	;mov	bl, DELAY_1
 22988                              <1> 					; wait for 10 seconds
 22989                              <1> 	;mov 	cx, WAIT_HDU_INT_LO	; 1615h
 22990                              <1> 	;;mov 	bl, WAIT_HDU_INT_HI	;   05h
 22991                              <1> 	;mov	bl, WAIT_HDU_INT_HI + 1
 22992 0000559A B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH  ; 21/02/2015
 22993                              <1> 	;
 22994                              <1> 	;;mov	byte [wait_count], 0    ; Reset wait counter
 22995                              <1> NB1:	
 22996 0000559F EC                  <1> 	in	al, dx			; CHECK STATUS
 22997                              <1> 	;test	al, ST_BUSY
 22998 000055A0 2480                <1> 	and	al, ST_BUSY
 22999                              <1> 	;loopnz NB1
 23000 000055A2 74E3                <1> 	jz	short NB2 ; al = 0	; NOT BUSY--LETS GO
 23001                              <1> 	;dec	bl			
 23002                              <1> 	;jnz	short NB1		; KEEP TRYING FOR A WHILE
 23003                              <1> 
 23004                              <1> NB1_hi: 
 23005 000055A4 E461                <1> 	in	al, SYS1		; wait for hi to lo
 23006 000055A6 A810                <1> 	test	al, 010h		; transition on memory
 23007 000055A8 75FA                <1> 	jnz	short NB1_hi		; refresh.
 23008                              <1> NB1_lo: 
 23009 000055AA E461                <1> 	in	al, SYS1
 23010 000055AC A810                <1> 	test	al, 010h
 23011 000055AE 74FA                <1> 	jz	short NB1_lo
 23012 000055B0 E2ED                <1> 	loop	NB1
 23013                              <1> 	;dec	bl
 23014                              <1> 	;jnz	short NB1
 23015                              <1> 	;
 23016                              <1> 	;;cmp	byte [wait_count], 182  ; 10 seconds (182 timer ticks)
 23017                              <1> 	;;jb	short NB1
 23018                              <1> 	;
 23019                              <1> 	;mov	byte [DISK_STATUS1], TIME_OUT ; REPORT TIME OUT ERROR
 23020                              <1> 	;jmp	short NB3
 23021 000055B2 B080                <1> 	mov	al, TIME_OUT
 23022                              <1> ;NB2:	
 23023 000055B4 EBD1                <1> 	jmp	short NB2 ; 10/07/2022
 23024                              <1> 
 23025                              <1> ;	;mov	byte [DISK_STATUS1], 0
 23026                              <1> ;;NB3:	
 23027                              <1> ;	;pop	ebx
 23028                              <1> ;	mov	[DISK_STATUS1], al	;;; will be set after return
 23029                              <1> ;	;cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
 23030                              <1> ;	or	al, al			; (zf = 0 --> timeout)
 23031                              <1> ;	retn
 23032                              <1> 
 23033                              <1> ;----------------------------------------
 23034                              <1> ;	WAIT FOR DATA REQUEST		:
 23035                              <1> ;----------------------------------------
 23036                              <1> WAIT_DRQ:
 23037                              <1> 	;mov	cx, DELAY_3
 23038                              <1> 	;mov	dx, HF_PORT+7
 23039 000055B6 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 23040 000055BD 80C207              <1> 	add	dl, 7
 23041                              <1> 	;;mov	bl, WAIT_HDU_DRQ_HI	; 0
 23042                              <1> 	;mov	cx, WAIT_HDU_DRQ_LO	; 1000 (30 milli seconds)
 23043                              <1> 					; (but it is written as 2000
 23044                              <1> 					; micro seconds in ATORGS.ASM file
 23045                              <1> 					; of Award Bios - 1999, D1A0622)
 23046 000055C0 B9E8030000          <1> 	mov 	ecx, WAIT_HDU_DRQ_LH ; 21/02/2015 
 23047                              <1> WQ_1:
 23048 000055C5 EC                  <1> 	in	al, dx			; GET STATUS
 23049 000055C6 A808                <1> 	test	al, ST_DRQ		; WAIT FOR DRQ
 23050 000055C8 7516                <1> 	jnz	short WQ_OK
 23051                              <1> 	;loop	WQ_1			; KEEP TRYING FOR A SHORT WHILE
 23052                              <1> WQ_hi:	
 23053 000055CA E461                <1> 	in	al, SYS1		; wait for hi to lo
 23054 000055CC A810                <1> 	test	al, 010h		; transition on memory
 23055 000055CE 75FA                <1> 	jnz	short WQ_hi		; refresh.
 23056                              <1> WQ_lo:  
 23057 000055D0 E461                <1> 	in	al, SYS1
 23058 000055D2 A810                <1> 	test	al, 010h
 23059 000055D4 74FA                <1> 	jz	short WQ_lo
 23060 000055D6 E2ED                <1> 	loop	WQ_1
 23061                              <1> 
 23062 000055D8 C605[17780100]80    <1> 	mov	byte [DISK_STATUS1], TIME_OUT ; ERROR
 23063 000055DF F9                  <1> 	stc
 23064                              <1> WQ_OK:
 23065 000055E0 C3                  <1> 	retn
 23066                              <1> ;WQ_OK:
 23067                              <1> 	;clc
 23068                              <1> 	;ret
 23069                              <1> 
 23070                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 23071                              <1> 
 23072                              <1> ;----------------------------------------
 23073                              <1> ;	CHECK FIXED DISK STATUS BYTE	:
 23074                              <1> ;----------------------------------------
 23075                              <1> CHECK_ST:
 23076                              <1> 	;mov	dx, HF_PORT+7		; GET THE STATUS
 23077 000055E1 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]
 23078 000055E8 80C207              <1> 	add	dl, 7
 23079                              <1> 	
 23080                              <1> 	; 17/02/2016
 23081                              <1> 	;(http://wiki.osdev.org/ATA_PIO_Mode)
 23082                              <1> 	;"delay 400ns to allow drive to set new values of BSY and DRQ"
 23083 000055EB EC                  <1> 	in	al, dx
 23084                              <1> 	;in	al, dx ; 100ns
 23085                              <1> 	;in	al, dx ; 100ns
 23086                              <1>  	;in	al, dx ; 100ns
 23087                              <1> 	NEWIODELAY ; 18/02/2016 (AWARD BIOS - 1999, 'CKST' in AHSDK.ASM)
 23088 000055EC E6EB                <2>  out 0EBh, al
 23089                              <1> 	;
 23090                              <1> 
 23091                              <1> 	; 16/07/2022
 23092 000055EE A2[11780100]        <1> 	mov	[HF_STATUS], al
 23093                              <1> 	;mov	ah, 0
 23094 000055F3 28E4                <1> 	sub	ah, ah ; 0
 23095 000055F5 A880                <1> 	test	al, ST_BUSY		; IF STILL BUSY
 23096 000055F7 751A                <1> 	jnz	short CKST_EXIT		; REPORT OK
 23097 000055F9 B4CC                <1> 	mov	ah, WRITE_FAULT
 23098 000055FB A820                <1> 	test 	al, ST_WRT_FLT		; CHECK FOR WRITE FAULT
 23099 000055FD 7514                <1> 	jnz	short CKST_EXIT
 23100 000055FF B4AA                <1> 	mov	ah, NOT_RDY
 23101 00005601 A840                <1> 	test	al, ST_READY		; CHECK FOR NOT READY
 23102 00005603 740E                <1> 	jz	short CKST_EXIT
 23103 00005605 B440                <1> 	mov	ah, BAD_SEEK
 23104 00005607 A810                <1> 	test	al, ST_SEEK_COMPL	; CHECK FOR SEEK NOT COMPLETE
 23105 00005609 7408                <1> 	jz	short CKST_EXIT
 23106 0000560B B411                <1> 	mov	ah, DATA_CORRECTED
 23107 0000560D A804                <1> 	test	al, ST_CORRCTD		; CHECK FOR CORRECTED ECC
 23108 0000560F 7502                <1> 	jnz	short CKST_EXIT
 23109                              <1> 	;mov	ah, 0
 23110 00005611 30E4                <1> 	xor	ah, ah ; 0
 23111                              <1> CKST_EXIT:
 23112 00005613 8825[17780100]      <1> 	mov	[DISK_STATUS1], ah	; SET ERROR FLAG
 23113 00005619 80FC11              <1> 	cmp	ah, DATA_CORRECTED	; KEEP GOING WITH DATA CORRECTED
 23114 0000561C 7402                <1> 	je	short CKST_EX1
 23115                              <1> 	;cmp	ah, 0
 23116 0000561E 20E4                <1> 	and	ah, ah
 23117                              <1> CKST_EX1:
 23118 00005620 C3                  <1> 	retn
 23119                              <1> 
 23120                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 23121                              <1> 
 23122                              <1> ;----------------------------------------
 23123                              <1> ;	CHECK FIXED DISK ERROR REGISTER :
 23124                              <1> ;----------------------------------------
 23125                              <1> CHECK_ER:
 23126                              <1> 	;mov	dx, HF_PORT+1		; GET THE ERROR REGISTER
 23127 00005621 668B15[EE640000]    <1> 	mov	dx, [HF_PORT]		;
 23128 00005628 FEC2                <1> 	inc	dl
 23129 0000562A EC                  <1> 	in	al, dx
 23130                              <1> 	; 16/07/2022
 23131                              <1> 	;mov	[HF_ERROR], al
 23132                              <1> 	;push	ebx  ; 21/02/2015
 23133 0000562B 29C9                <1> 	sub	ecx, ecx
 23134                              <1> 	;mov	ecx, 8			; TEST ALL 8 BITS
 23135 0000562D B108                <1> 	mov	cl, 8
 23136                              <1> CK1:	
 23137 0000562F D0E0                <1> 	shl	al, 1			; MOVE NEXT ERROR BIT TO CARRY
 23138 00005631 7202                <1> 	jc	short CK2		; FOUND THE ERROR
 23139 00005633 E2FA                <1> 	loop	CK1			; KEEP TRYING
 23140                              <1> CK2:
 23141                              <1> 	;mov	ebx, ERR_TBL		; COMPUTE ADDRESS OF
 23142                              <1> 	;add	ebx, ecx		; ERROR CODE
 23143 00005635 81C1[E4640000]      <1> 	add	ecx, ERR_TBL ; 16/07/2022	
 23144                              <1> 
 23145                              <1> 	;;;mov	ah, byte [cs:bx]	; GET ERROR CODE
 23146                              <1> 	;;mov	ah, [bx]
 23147                              <1> 	;mov	ah, [ebx] ; 21/02/2015
 23148 0000563B 8A21                <1> 	mov	ah, [ecx]	
 23149                              <1> CKEX:
 23150 0000563D 8825[17780100]      <1> 	mov	[DISK_STATUS1], ah	; SAVE ERROR CODE
 23151                              <1> 	; 16/07/2022
 23152                              <1> 	;pop	ebx
 23153                              <1> 	;;cmp	ah, 0
 23154                              <1> 	;and	ah, ah
 23155 00005643 C3                  <1> 	retn
 23156                              <1> 
 23157                              <1> ;--------------------------------------------------------
 23158                              <1> ; CHECK_DMA						:
 23159                              <1> ;  -CHECK ES:BX AND # SECTORS TO MAKE SURE THAT IT WILL :
 23160                              <1> ;   FIT WITHOUT SEGMENT OVERFLOW.			:
 23161                              <1> ;  -ES:BX HAS BEEN REVISED TO THE FORMAT SSSS:000X	:
 23162                              <1> ;  -OK IF # SECTORS < 80H (7FH IF LONG READ OR WRITE)	:
 23163                              <1> ;  -OK IF # SECTORS = 80H (7FH) AND BX <= 00H (04H)	:
 23164                              <1> ;  -ERROR OTHERWISE					:
 23165                              <1> ;--------------------------------------------------------
 23166                              <1> 
 23167                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
 23168                              <1> 	; (not needed for hard disks and 32 bit OS)
 23169                              <1> 
 23170                              <1> ;CHECK_DMA:
 23171                              <1> ;	; 11/04/2021 (32 bit push/pop)
 23172                              <1> ;	push	eax			; SAVE REGISTERS
 23173                              <1> ;	mov	ax, 8000h		; AH = MAX # SECTORS
 23174                              <1> ;					; AL = MAX OFFSET
 23175                              <1> ;	test	byte [CMD_BLOCK+6], ECC_MODE
 23176                              <1> ;	jz	short CKD1
 23177                              <1> ;	mov	ah, 7F04h		; ECC IS 4 MORE BYTES
 23178                              <1> ;CKD1:	
 23179                              <1> ;	cmp	ah, [CMD_BLOCK+1] 	; NUMBER OF SECTORS
 23180                              <1> ;	ja	short CKDOK		; IT WILL FIT
 23181                              <1> ;	jb	short CKDERR		; TOO MANY
 23182                              <1> ;	cmp	al, bl			; CHECK OFFSET ON MAX SECTORS
 23183                              <1> ;	;jb	short CKDERR		; ERROR
 23184                              <1> ;	jnb	short CKDOK ; 16/07/2022
 23185                              <1> ;;CKDOK:	
 23186                              <1> ;	;clc				; CLEAR CARRY
 23187                              <1> ;	;pop	eax
 23188                              <1> ;	;retn				; NORMAL RETURN
 23189                              <1> ;CKDERR:
 23190                              <1> ;	;stc				; INDICATE ERROR
 23191                              <1> ;	mov	byte [DISK_STATUS1], DMA_BOUNDARY
 23192                              <1> ;CKDOK:
 23193                              <1> ;	pop	eax
 23194                              <1> ;	retn
 23195                              <1> 
 23196                              <1> ;----------------------------------------
 23197                              <1> ;	SET UP EBX-> DISK PARMS		:
 23198                              <1> ;----------------------------------------
 23199                              <1> 					
 23200                              <1> ; INPUT -> DL = 0 based drive number
 23201                              <1> ; OUTPUT -> EBX = disk parameter table address
 23202                              <1> 
 23203                              <1> GET_VEC:
 23204                              <1> 	;sub	ax, ax			; GET DISK PARAMETER ADDRESS
 23205                              <1> 	;mov	es, ax
 23206                              <1> 	;test	dl, 1
 23207                              <1> 	;jz	short GV_0
 23208                              <1> ;	les	bx, [HF1_TBL_VEC] 	; ES:BX -> DRIVE PARAMETERS
 23209                              <1> ;	jmp	short GV_EXIT
 23210                              <1> ;GV_0:
 23211                              <1> ;	les 	bx,[HF_TBL_VEC]		; ES:BX -> DRIVE PARAMETERS
 23212                              <1> ;
 23213 00005644 31DB                <1> 	xor	ebx, ebx
 23214 00005646 88D3                <1> 	mov	bl, dl
 23215                              <1> 	;02/01/2015
 23216                              <1> 	;xor	bh, bh
 23217                              <1> 	;shl	bl, 1			; port address offset
 23218                              <1> 	;mov	ax, [bx+hd_ports]	; Base port address (1F0h, 170h)
 23219                              <1> 	;shl	bl, 1			; dpt pointer offset
 23220 00005648 C0E302              <1> 	shl	bl, 2
 23221                              <1> 	;add	bx, HF_TBL_VEC		; Disk parameter table pointer
 23222 0000564B 81C3[1C780100]      <1> 	add	ebx, HF_TBL_VEC ; 21/02/2015
 23223                              <1> 	;push	word [bx+2]		; dpt segment
 23224                              <1> 	;pop	es
 23225                              <1> 	;mov	bx, [bx]		; dpt offset
 23226 00005651 8B1B                <1> 	mov	ebx, [ebx]		
 23227                              <1> ;GV_EXIT:
 23228 00005653 C3                  <1> 	retn
 23229                              <1> 
 23230                              <1> hdc1_int: ; 21/02/2015
 23231                              <1> ;--- HARDWARE INT 76H -- ( IRQ LEVEL 14 ) -----------------------
 23232                              <1> ;								:
 23233                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
 23234                              <1> ;								:
 23235                              <1> ;----------------------------------------------------------------
 23236                              <1> 
 23237                              <1> ; 22/12/2014
 23238                              <1> ; IBM PC-XT Model 286 System BIOS Source Code - DISK.ASM (HD_INT)
 23239                              <1> ;	 '11/15/85'
 23240                              <1> ; AWARD BIOS 1999 (D1A0622) 
 23241                              <1> ;	Source Code - ATORGS.ASM (INT_HDISK, INT_HDISK1)
 23242                              <1> 
 23243                              <1> ;int_76h:
 23244                              <1> HD_INT:
 23245                              <1> 	; 11/04/2021 (32 bit push/pop)
 23246 00005654 50                  <1> 	push	eax
 23247 00005655 1E                  <1> 	push	ds
 23248                              <1> 	;call	DDS
 23249                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
 23250 00005656 66B81000            <1> 	mov	ax, KDATA
 23251 0000565A 8ED8                <1> 	mov 	ds, ax
 23252                              <1> 	;
 23253                              <1> 	;;mov	@HF_INT_FLAG,0FFH	; ALL DONE
 23254                              <1>         ;mov	byte [CS:HF_INT_FLAG], 0FFh
 23255 0000565C C605[12780100]FF    <1> 	mov	byte [HF_INT_FLAG], 0FFh
 23256                              <1> 	;
 23257 00005663 52                  <1> 	push	edx
 23258 00005664 66BAF701            <1> 	mov	dx, HDC1_BASEPORT+7	; Status Register (1F7h)
 23259                              <1> 					; Clear Controller
 23260                              <1> Clear_IRQ1415:				; (Award BIOS - 1999)
 23261 00005668 EC                  <1> 	in	al, dx			;
 23262 00005669 5A                  <1> 	pop	edx
 23263                              <1> 	NEWIODELAY
 23264 0000566A E6EB                <2>  out 0EBh, al
 23265                              <1> 	;
 23266 0000566C B020                <1> 	mov	al, EOI			; NON-SPECIFIC END OF INTERRUPT
 23267 0000566E E6A0                <1> 	out	INTB00, al		; FOR CONTROLLER #2
 23268                              <1> 	;jmp	$+2			; WAIT
 23269                              <1> 	NEWIODELAY
 23270 00005670 E6EB                <2>  out 0EBh, al
 23271 00005672 E620                <1> 	out	INTA00, al		; FOR CONTROLLER #1
 23272 00005674 1F                  <1> 	pop	ds
 23273                              <1> 	;sti				; RE-ENABLE INTERRUPTS
 23274                              <1> 	;mov	ax, 9100h		; DEVICE POST
 23275                              <1> 	;int	15h			;  INTERRUPT
 23276                              <1> irq15_iret: ; 25/02/2015
 23277 00005675 58                  <1> 	pop	eax
 23278 00005676 CF                  <1> 	iretd				; RETURN FROM INTERRUPT
 23279                              <1> 
 23280                              <1> hdc2_int: ; 21/02/2015
 23281                              <1> ;--- HARDWARE INT 77H -- ( IRQ LEVEL 15 ) -----------------------
 23282                              <1> ;								:
 23283                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
 23284                              <1> ;								:
 23285                              <1> ;----------------------------------------------------------------
 23286                              <1> 
 23287                              <1> ;int_77h:
 23288                              <1> HD1_INT:
 23289                              <1> 	; 11/04/2021 (32 bit push/pop)
 23290 00005677 50                  <1> 	push	eax
 23291                              <1> 	; Check if that is a spurious IRQ (from slave PIC)
 23292                              <1> 	; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
 23293 00005678 B00B                <1> 	mov	al, 0Bh  ; In-Service Register
 23294 0000567A E6A0                <1> 	out	0A0h, al
 23295 0000567C EB00                <1>         jmp short $+2
 23296 0000567E EB00                <1> 	jmp short $+2
 23297 00005680 E4A0                <1> 	in	al, 0A0h
 23298 00005682 2480                <1> 	and 	al, 80h ; bit 7 (is it real IRQ 15 or fake?)
 23299 00005684 74EF                <1> 	jz	short irq15_iret ; Fake (spurious) IRQ, do not send EOI)
 23300                              <1> 	;
 23301 00005686 1E                  <1> 	push	ds
 23302                              <1> 	;call	DDS
 23303                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
 23304 00005687 66B81000            <1> 	mov	ax, KDATA
 23305 0000568B 8ED8                <1> 	mov 	ds, ax
 23306                              <1> 	;
 23307                              <1> 	;;mov	@HF_INT_FLAG,0FFH	; ALL DONE
 23308                              <1>         ;or	byte [CS:HF_INT_FLAG],0C0h 
 23309 0000568D 800D[12780100]C0    <1> 	or	byte [HF_INT_FLAG], 0C0h
 23310                              <1> 	;
 23311 00005694 52                  <1> 	push	edx
 23312 00005695 66BA7701            <1> 	mov	dx, HDC2_BASEPORT+7	; Status Register (177h)
 23313                              <1> 					; Clear Controller (Award BIOS 1999)
 23314 00005699 EBCD                <1> 	jmp	short Clear_IRQ1415
 23315                              <1> 
 23316                              <1> ;%include 'diskdata.inc' ; 11/03/2015
 23317                              <1> ;%include 'diskbss.inc' ; 11/03/2015
 23318                              <1> 
 23319                              <1> ;////////////////////////////////////////////////////////////////////
 23320                              <1> ;; END OF DISK I/O SYTEM ///
 23321                                  %include 'memory.s'  ; 09/03/2015
 23322                              <1> ; ****************************************************************************
 23323                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.4 - memory.s
 23324                              <1> ; ----------------------------------------------------------------------------
 23325                              <1> ; Last Update: 17/04/2021
 23326                              <1> ; ----------------------------------------------------------------------------
 23327                              <1> ; Beginning: 24/01/2016
 23328                              <1> ; ----------------------------------------------------------------------------
 23329                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 23330                              <1> ; ----------------------------------------------------------------------------
 23331                              <1> ; Turkish Rational DOS
 23332                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 23333                              <1> ;
 23334                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 23335                              <1> ; memory.inc (18/10/2015)
 23336                              <1> ; ****************************************************************************
 23337                              <1> 
 23338                              <1> ; MEMORY.ASM - Retro UNIX 386 v1 MEMORY MANAGEMENT FUNCTIONS (PROCEDURES)
 23339                              <1> ; Retro UNIX 386 v1 Kernel (unix386.s, v0.2.0.14) - MEMORY.INC
 23340                              <1> ; Last Modification: 18/10/2015
 23341                              <1> 
 23342                              <1> ; ///////// MEMORY MANAGEMENT FUNCTIONS (PROCEDURES) ///////////////
 23343                              <1> 
 23344                              <1> ;;04/11/2014 (unix386.s)	
 23345                              <1> ;PDE_A_PRESENT	equ	1		; Present flag for PDE
 23346                              <1> ;PDE_A_WRITE	equ 	2		; Writable (write permission) flag
 23347                              <1> ;PDE_A_USER	equ	4		; User (non-system/kernel) page flag
 23348                              <1> ;;
 23349                              <1> ;PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
 23350                              <1> ;PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
 23351                              <1> ;PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
 23352                              <1> ;PTE_A_ACCESS   equ	32		; Accessed flag (bit 5) ; 09/03/2015
 23353                              <1> 
 23354                              <1> ; 27/04/2015
 23355                              <1> ; 09/03/2015
 23356                              <1> PAGE_SIZE 	equ 4096		; page size in bytes
 23357                              <1> PAGE_SHIFT 	equ 12			; page table shift count
 23358                              <1> PAGE_D_SHIFT 	equ 22	; 12 + 10	; page directory shift count
 23359                              <1> PAGE_OFF	equ 0FFFh		; 12 bit byte offset in page frame
 23360                              <1> PTE_MASK 	equ 03FFh		; page table entry mask
 23361                              <1> PTE_DUPLICATED  equ 200h		; duplicated page sign (AVL bit 0)
 23362                              <1> PDE_A_CLEAR	equ 0F000h		; to clear PDE attribute bits
 23363                              <1> PTE_A_CLEAR	equ 0F000h		; to clear PTE attribute bits
 23364                              <1> LOGIC_SECT_SIZE equ 512			; logical sector size
 23365                              <1> ERR_MAJOR_PF	equ 0E0h		; major error: page fault
 23366                              <1> ERR_MINOR_IM	equ 4 ;15/10/2016 (1->4); insufficient (out of) memory
 23367                              <1> ERR_MINOR_PV	equ 6 ;15/10/2016 (1->4); protection violation
 23368                              <1> SWP_DISK_READ_ERR 	   equ 40
 23369                              <1> SWP_DISK_NOT_PRESENT_ERR   equ 41
 23370                              <1> SWP_SECTOR_NOT_PRESENT_ERR equ 42
 23371                              <1> SWP_NO_FREE_SPACE_ERR      equ 43
 23372                              <1> SWP_DISK_WRITE_ERR         equ 44
 23373                              <1> SWP_NO_PAGE_TO_SWAP_ERR    equ 45
 23374                              <1> PTE_A_ACCESS_BIT equ 5  ; Bit 5 (accessed flag)        
 23375                              <1> SECTOR_SHIFT     equ 3  ; sector shift (to convert page block number)
 23376                              <1> ; 12/07/2016
 23377                              <1> PTE_SHARED	 equ 400h		; AVL bit 1, direct memory access bit	
 23378                              <1> 					; (Indicates that the page is not allocated
 23379                              <1> 					; for the process, it is a shared or system
 23380                              <1>                                         ; page, it must not be deallocated!)
 23381                              <1> ; 14/12/2020
 23382                              <1> ; (Linear Frame Buffer - video memory mark : AVL bit 1, outside M.A.T.)
 23383                              <1> PDE_EXTERNAL	equ 400h	; Page directory entry for external memory blocks
 23384                              <1> PTE_EXTERNAL	equ 400h	; Allocated kernel pages for Linear Frame Buffer
 23385                              <1> 				; (Out of memory allocation table)	
 23386                              <1> 
 23387                              <1> ;
 23388                              <1> ;; Retro Unix 386 v1 - paging method/principles
 23389                              <1> ;;
 23390                              <1> ;; 10/10/2014
 23391                              <1> ;; RETRO UNIX 386 v1 - PAGING METHOD/PRINCIPLES
 23392                              <1> ;;
 23393                              <1> ;; KERNEL PAGE MAP: 1 to 1 physical memory page map
 23394                              <1> ;;	(virtual address = physical address)
 23395                              <1> ;; KERNEL PAGE TABLES:
 23396                              <1> ;;	Kernel page directory and all page tables are
 23397                              <1> ;;	on memory as initialized, as equal to physical memory
 23398                              <1> ;;	layout. Kernel pages can/must not be swapped out/in.
 23399                              <1> ;;
 23400                              <1> ;;	what for: User pages may be swapped out, when accessing
 23401                              <1> ;;	a page in kernel/system mode, if it would be swapped out,
 23402                              <1> ;;	kernel would have to swap it in! But it is also may be
 23403                              <1> ;;	in use by a user process. (In system/kernel mode
 23404                              <1> ;;	kernel can access all memory pages even if they are
 23405                              <1> ;;	reserved/allocated for user processes. Swap out/in would
 23406                              <1> ;;	cause conflicts.) 
 23407                              <1> ;;	
 23408                              <1> ;;	As result of these conditions,
 23409                              <1> ;;	all kernel pages must be initialized as equal to 
 23410                              <1> ;;	physical layout for preventing page faults. 
 23411                              <1> ;;	Also, calling "allocate page" procedure after
 23412                              <1> ;;	a page fault can cause another page fault (double fault)
 23413                              <1> ;;	if all kernel page tables would not be initialized.
 23414                              <1> ;;
 23415                              <1> ;;	[first_page] = Beginning of users space, as offset to 
 23416                              <1> ;;	memory allocation table. (double word aligned)
 23417                              <1> ;;
 23418                              <1> ;;	[next_page] = first/next free space to be searched
 23419                              <1> ;;	as offset to memory allocation table. (dw aligned)
 23420                              <1> ;;
 23421                              <1> ;;	[last_page] = End of memory (users space), as offset
 23422                              <1> ;;	to memory allocation table. (double word aligned)
 23423                              <1> ;;
 23424                              <1> ;; USER PAGE TABLES:
 23425                              <1> ;;	Demand paging (& 'copy on write' allocation method) ...
 23426                              <1> ;;		'ready only' marked copies of the 
 23427                              <1> ;;		parent process's page table entries (for
 23428                              <1> ;;		same physical memory).
 23429                              <1> ;;		(A page will be copied to a new page after
 23430                              <1> ;;		 if it causes R/W page fault.)
 23431                              <1> ;;
 23432                              <1> ;;	Every user process has own (different)
 23433                              <1> ;;	page directory and page tables.	
 23434                              <1> ;;
 23435                              <1> ;;	Code starts at virtual address 0, always.
 23436                              <1> ;;	(Initial value of EIP is 0 in user mode.)
 23437                              <1> ;;	(Programs can be written/developed as simple
 23438                              <1> ;;	 flat memory programs.)
 23439                              <1> ;;
 23440                              <1> ;; MEMORY ALLOCATION STRATEGY:
 23441                              <1> ;;	Memory page will be allocated by kernel only 
 23442                              <1> ;;		(in kernel/system mode only).
 23443                              <1> ;;	* After a
 23444                              <1> ;;	  - 'not present' page fault
 23445                              <1> ;;	  - 'writing attempt on read only page' page fault 	 	
 23446                              <1> ;;	* For loading (opening, reading) a file or disk/drive
 23447                              <1> ;;	* As responce to 'allocate additional memory blocks' 
 23448                              <1> ;;	  request by running process.
 23449                              <1> ;;	* While creating a process, allocating a new buffer,
 23450                              <1> ;;	  new page tables etc.
 23451                              <1> ;;
 23452                              <1> ;;	At first,
 23453                              <1> ;;	- 'allocate page' procedure will be called;
 23454                              <1> ;,	   if it will return with a valid (>0) physical address
 23455                              <1> ;;	   (that means the relevant M.A.T. bit has been RESET)	
 23456                              <1> ;;	   relevant memory page/block will be cleared (zeroed).
 23457                              <1> ;;	- 'allocate page' will be called for allocating page
 23458                              <1> ;;	   directory, page table and running space (data/code).
 23459                              <1> ;;	- every successful 'allocate page' call will decrease
 23460                              <1> ;;	  'free_pages' count (pointer).
 23461                              <1> ;;	- 'out of (insufficient) memory error' will be returned
 23462                              <1> ;;	  if 'free_pages' points to a ZERO.
 23463                              <1> ;;	- swapping out and swapping in (if it is not a new page)
 23464                              <1> ;;	  procedures will be called as responce to 'out of memory'
 23465                              <1> ;;	  error except errors caused by attribute conflicts.
 23466                              <1> ;;	 (swapper functions)	 
 23467                              <1> ;;					
 23468                              <1> ;;	At second,
 23469                              <1> ;;	- page directory entry will be updated then page table
 23470                              <1> ;;	  entry will be updated.		
 23471                              <1> ;;
 23472                              <1> ;; MEMORY ALLOCATION TABLE FORMAT:
 23473                              <1> ;;	- M.A.T. has a size according to available memory as
 23474                              <1> ;;	  follows:
 23475                              <1> ;;		  - 1 (allocation) bit per 1 page (4096 bytes)
 23476                              <1> ;;		  - a bit with value of 0 means allocated page
 23477                              <1> ;;		  - a bit with value of 1 means a free page
 23478                              <1> ;,	- 'free_pages' pointer holds count of free pages
 23479                              <1> ;;	  depending on M.A.T.
 23480                              <1> ;;		(NOTE: Free page count will not be checked
 23481                              <1> ;;		again -on M.A.T.- after initialization. 
 23482                              <1> ;;		Kernel will trust on initial count.)
 23483                              <1> ;,	- 'free_pages' count will be decreased by allocation
 23484                              <1> ;;	  and it will be increased by deallocation procedures.
 23485                              <1> ;;	
 23486                              <1> ;;	- Available memory will be calculated during
 23487                              <1> ;;	  the kernel's initialization stage (in real mode).
 23488                              <1> ;;	  Memory allocation table and kernel page tables 
 23489                              <1> ;;	  will be formatted/sized as result of available
 23490                              <1> ;;	  memory calculation before paging is enabled.
 23491                              <1> ;;
 23492                              <1> ;; For 4GB Available/Present Memory: (max. possible memory size)
 23493                              <1> ;;	- Memory Allocation Table size will be 128 KB.
 23494                              <1> ;;	- Memory allocation for kernel page directory size 
 23495                              <1> ;;	  is always 4 KB. (in addition to total allocation size
 23496                              <1> ;;	  for page tables)
 23497                              <1> ;;	- Memory allocation for kernel page tables (1024 tables)
 23498                              <1> ;;	  is 4 MB (1024*4*1024 bytes).
 23499                              <1> ;;	- User (available) space will be started 
 23500                              <1> ;;	  at 6th MB of the memory (after 1MB+4MB).
 23501                              <1> ;;	- The first 640 KB is for kernel's itself plus
 23502                              <1> ;;	  memory allocation table and kernel's page directory
 23503                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
 23504                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
 23505                              <1> ;; 	  for buffers.
 23506                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
 23507                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
 23508                              <1> ;;	- Kernel page tables start at 100000h (2nd MB)
 23509                              <1> ;;
 23510                              <1> ;; For 1GB Available Memory:
 23511                              <1> ;;	- Memory Allocation Table size will be 32 KB.
 23512                              <1> ;;	- Memory allocation for kernel page directory size 
 23513                              <1> ;;	  is always 4 KB. (in addition to total allocation size
 23514                              <1> ;;	  for page tables)
 23515                              <1> ;;	- Memory allocation for kernel page tables (256 tables)
 23516                              <1> ;;	  is 1 MB (256*4*1024 bytes).
 23517                              <1> ;;	- User (available) space will be started 
 23518                              <1> ;;	  at 3th MB of the memory (after 1MB+1MB).
 23519                              <1> ;;	- The first 640 KB is for kernel's itself plus
 23520                              <1> ;;	  memory allocation table and kernel's page directory
 23521                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
 23522                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
 23523                              <1> ;; 	  for buffers.
 23524                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
 23525                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
 23526                              <1> ;;	- Kernel page tables start at 100000h (2nd MB).	
 23527                              <1> ;;
 23528                              <1> ;;
 23529                              <1> 
 23530                              <1> 
 23531                              <1> ;;************************************************************************************
 23532                              <1> ;; 
 23533                              <1> ;; RETRO UNIX 386 v1 - Paging (Method for Copy On Write paging principle)
 23534                              <1> ;; DEMAND PAGING - PARENT&CHILD PAGE TABLE DUPLICATION PRINCIPLES (23/04/2015)
 23535                              <1> 
 23536                              <1> ;; Main factor: "sys fork" system call 
 23537                              <1> ;;	
 23538                              <1> ;; 		FORK
 23539                              <1> ;;                      |----> parent - duplicated PTEs, read only pages
 23540                              <1> ;;  writable pages ---->|
 23541                              <1> ;;                      |----> child - duplicated PTEs, read only pages
 23542                              <1> ;; 
 23543                              <1> ;; AVL bit (0) of Page Table Entry is used as duplication sign 
 23544                              <1> ;; 
 23545                              <1> ;; AVL Bit 0 [PTE Bit 9] = 'Duplicated PTE belongs to child' sign/flag (if it is set)
 23546                              <1> ;; Note: Dirty bit (PTE bit 6) may be used instead of AVL bit 0 (PTE bit 9)
 23547                              <1> ;;       -while R/W bit is 0-. 
 23548                              <1> ;; 
 23549                              <1> ;; Duplicate page tables with writable pages (the 1st sys fork in the process):
 23550                              <1> ;; # Parent's Page Table Entries are updated to point same pages as read only, 
 23551                              <1> ;;   as duplicated PTE bit  -AVL bit 0, PTE bit 9- are reset/clear.
 23552                              <1> ;; # Then Parent's Page Table is copied to Child's Page Table.
 23553                              <1> ;; # Child's Page Table Entries are updated as duplicated child bit
 23554                              <1> ;;   -AVL bit 0, PTE bit 9- is set.	  
 23555                              <1> ;; 
 23556                              <1> ;; Duplicate page tables with read only pages (several sys fork system calls):
 23557                              <1> ;; # Parent's read only pages are copied to new child pages. 
 23558                              <1> ;;   Parent's PTE attributes are not changed.
 23559                              <1> ;;   (Because, there is another parent-child fork before this fork! We must not
 23560                              <1> ;;    destroy/mix previous fork result).
 23561                              <1> ;; # Child's Page Table Entries (which are corresponding to Parent's 
 23562                              <1> ;;   read only pages) are set as writable (while duplicated PTE bit is clear). 
 23563                              <1> ;; # Parent's PTEs with writable page attribute are updated to point same pages 
 23564                              <1> ;;   as read only, (while) duplicated PTE bit is reset (clear).
 23565                              <1> ;; # Parent's Page Table Entries (with writable page attribute) are duplicated 
 23566                              <1> ;;   as Child's Page Table Entries without copying actual page.
 23567                              <1> ;; # Child 's Page Table Entries (which are corresponding to Parent's writable 
 23568                              <1> ;;   pages) are updated as duplicated PTE bit (AVL bit 0, PTE bit 9- is set.
 23569                              <1> ;; 
 23570                              <1> ;; !? WHAT FOR (duplication after duplication):
 23571                              <1> ;; In UNIX method for sys fork (a typical 'fork' application in /etc/init)
 23572                              <1> ;; program/executable code continues from specified location as child process, 
 23573                              <1> ;; returns back previous code location as parent process, every child after 
 23574                              <1> ;; every sys fork uses last image of code and data just prior the fork.
 23575                              <1> ;; Even if the parent code changes data, the child will not see the changed data 
 23576                              <1> ;; after the fork. In Retro UNIX 8086 v1, parent's process segment (32KB)
 23577                              <1> ;; was copied to child's process segment (all of code and data) according to
 23578                              <1> ;; original UNIX v1 which copies all of parent process code and data -core- 
 23579                              <1> ;; to child space -core- but swaps that core image -of child- on to disk.
 23580                              <1> ;; If I (Erdogan Tan) would use a method of to copy parent's core
 23581                              <1> ;; (complete running image of parent process) to the child process; 
 23582                              <1> ;; for big sizes, i would force Retro UNIX 386 v1 to spend many memory pages 
 23583                              <1> ;; and times only for a sys fork. (It would excessive reservation for sys fork,
 23584                              <1> ;; because sys fork usually is prior to sys exec; sys exec always establishes
 23585                              <1> ;; a new/fresh core -running space-, by clearing all code/data content). 
 23586                              <1> ;; 'Read Only' page flag ensures page fault handler is needed only for a few write
 23587                              <1> ;; attempts between sys fork and sys exec, not more... (I say so by thinking 
 23588                              <1> ;; of "/etc/init" content, specially.) sys exec will clear page tables and
 23589                              <1> ;; new/fresh pages will be used to load and run new executable/program.
 23590                              <1> ;; That is what for i have preferred "copy on write", "duplication" method
 23591                              <1> ;; for sharing same read only pages between parent and child processes.
 23592                              <1> ;; That is a pitty i have to use new private flag (AVL bit 0, "duplicated PTE 
 23593                              <1> ;; belongs to child" sign) for cooperation on duplicated pages between a parent 
 23594                              <1> ;; and it's child processes; otherwise parent process would destroy data belongs
 23595                              <1> ;; to its child or vice versa; or some pages would remain unclaimed 
 23596                              <1> ;; -deallocation problem-.
 23597                              <1> ;; Note: to prevent conflicts, read only pages must not be swapped out... 
 23598                              <1> ;; 
 23599                              <1> ;; WHEN PARENT TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
 23600                              <1> ;; # Page fault handler will do those:
 23601                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
 23602                              <1> ;;   - If it is reset/clear, there is a child uses same page.
 23603                              <1> ;;   - Parent's read only page -previous page- is copied to a new writable page. 
 23604                              <1> ;;   - Parent's PTE is updated as writable page, as unique page (AVL=0)
 23605                              <1> ;;   - (Page fault handler whill check this PTE later, if child process causes to
 23606                              <1> ;;     page fault due to write attempt on read only page. Of course, the previous 
 23607                              <1> ;;     read only page will be converted to writable and unique page which belongs
 23608                              <1> ;;     to child process.)	
 23609                              <1> ;; WHEN CHILD TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
 23610                              <1> ;; # Page fault handler will do those:
 23611                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
 23612                              <1> ;;   - If it is set, there is a parent uses -or was using- same page.
 23613                              <1> ;;   - Same PTE address within parent's page table is checked if it has same page
 23614                              <1> ;;     address or not. 
 23615                              <1> ;;   - If parent's PTE has same address, child will continue with a new writable page.
 23616                              <1> ;;     Parent's PTE will point to same (previous) page as writable, unique (AVL=0).	
 23617                              <1> ;;   - If parent's PTE has different address, child will continue with it's 
 23618                              <1> ;;     own/same page but read only flag (0) will be changed to writable flag (1) and
 23619                              <1> ;;     'duplicated PTE (belongs to child)' flag/sign will be cleared/reset. 	  	
 23620                              <1> ;; 
 23621                              <1> ;; NOTE: When a child process is terminated, read only flags of parent's page tables
 23622                              <1> ;;       will be set as writable (and unique) in case of child process was using 
 23623                              <1> ;;       same pages with duplicated child PTE sign... Depending on sys fork and 
 23624                              <1> ;;       duplication method details, it is not possible multiple child processes
 23625                              <1> ;;       were using same page with duplicated PTEs.
 23626                              <1> ;; 
 23627                              <1> ;;************************************************************************************   
 23628                              <1> 
 23629                              <1> ;; 08/10/2014
 23630                              <1> ;; 11/09/2014 - Retro UNIX 386 v1 PAGING (further) draft
 23631                              <1> ;;		by Erdogan Tan (Based on KolibriOS 'memory.inc')
 23632                              <1> 
 23633                              <1> ;; 'allocate_page' code is derived and modified from KolibriOS
 23634                              <1> ;; 'alloc_page' procedure in 'memory.inc' 
 23635                              <1> ;; (25/08/2014, Revision: 5057) file 
 23636                              <1> ;; by KolibriOS Team (2004-2012)
 23637                              <1> 
 23638                              <1> allocate_page:
 23639                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 23640                              <1> 	;	 (temporary modifications)
 23641                              <1> 	; 01/07/2015
 23642                              <1> 	; 05/05/2015
 23643                              <1> 	; 30/04/2015
 23644                              <1> 	; 16/10/2014
 23645                              <1> 	; 08/10/2014
 23646                              <1> 	; 09/09/2014 (Retro UNIX 386 v1 - beginning)
 23647                              <1> 	;
 23648                              <1> 	; INPUT -> none
 23649                              <1> 	;
 23650                              <1> 	; OUTPUT ->
 23651                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
 23652                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is RESET)
 23653                              <1> 	;
 23654                              <1> 	;	CF = 1 and EAX = 0 
 23655                              <1> 	; 		   if there is not a free page to be allocated	
 23656                              <1> 	;
 23657                              <1> 	; Modified Registers -> none (except EAX)
 23658                              <1> 	;
 23659 0000569B A1[88770100]        <1> 	mov	eax, [free_pages]
 23660 000056A0 21C0                <1> 	and	eax, eax
 23661 000056A2 7438                <1> 	jz	short out_of_memory
 23662                              <1> 	;
 23663 000056A4 53                  <1> 	push	ebx
 23664 000056A5 51                  <1> 	push	ecx
 23665                              <1> 	;
 23666 000056A6 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table offset
 23667 000056AB 89D9                <1> 	mov	ecx, ebx
 23668                              <1>  				     ; NOTE: 32 (first_page) is initial
 23669                              <1> 				     ; value of [next_page].
 23670                              <1> 				     ; It points to the first available
 23671                              <1> 				     ; page block for users (ring 3) ...	
 23672                              <1> 				     ; (MAT offset 32 = 1024/32)	
 23673                              <1> 				     ; (at the of the first 4 MB)		
 23674 000056AD 031D[8C770100]      <1> 	add	ebx, [next_page] ; Free page searching starts from here
 23675                              <1> 				 ; next_free_page >> 5
 23676 000056B3 030D[90770100]      <1> 	add	ecx, [last_page] ; Free page searching ends here
 23677                              <1> 				 ; (total_pages - 1) >> 5
 23678                              <1> al_p_scan:
 23679 000056B9 39CB                <1> 	cmp	ebx, ecx
 23680 000056BB 770A                <1> 	ja	short al_p_notfound
 23681                              <1> 	;
 23682                              <1> 	; 01/07/2015
 23683                              <1> 	; AMD64 Architecture Programmers Manual
 23684                              <1> 	; Volume 3:
 23685                              <1> 	; General-Purpose and System Instructions
 23686                              <1> 	;
 23687                              <1> 	; BSF - Bit Scan Forward
 23688                              <1> 	;
 23689                              <1> 	;   Searches the value in a register or a memory location
 23690                              <1> 	;   (second operand) for the least-significant set bit. 
 23691                              <1> 	;   If a set bit is found, the instruction clears the zero flag (ZF)
 23692                              <1> 	;   and stores the index of the least-significant set bit in a destination
 23693                              <1> 	;   register (first operand). If the second operand contains 0, 
 23694                              <1> 	;   the instruction sets ZF to 1 and does not change the contents of the 
 23695                              <1> 	;   destination register. The bit index is an unsigned offset from bit 0 
 23696                              <1> 	;   of the searched value
 23697                              <1> 	;
 23698 000056BD 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
 23699                              <1> 			   ; Clear ZF if a bit is found set (1) and 
 23700                              <1> 			   ; loads the destination with an index to
 23701                              <1> 			   ; first set bit. (0 -> 31) 
 23702                              <1> 			   ; Sets ZF to 1 if no bits are found set.
 23703 000056C0 751C                <1> 	jnz	short al_p_found ; ZF = 0 -> a free page has been found
 23704                              <1> 			 ;
 23705                              <1> 			 ; NOTE:  a Memory Allocation Table bit 
 23706                              <1> 			 ;	  with value of 1 means 
 23707                              <1> 			 ;	  the corresponding page is free 
 23708                              <1> 			 ;	  (Retro UNIX 386 v1 feature only!)
 23709 000056C2 83C304              <1> 	add	ebx, 4
 23710                              <1> 			 ; We return back for searching next page block
 23711                              <1> 			 ; NOTE: [free_pages] is not ZERO; so, 
 23712                              <1> 			 ;	 we always will find at least 1 free page here.
 23713 000056C5 EBF2                <1>         jmp     short al_p_scan
 23714                              <1> 	;
 23715                              <1> al_p_notfound:
 23716 000056C7 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
 23717 000056CD 890D[8C770100]      <1> 	mov	[next_page], ecx ; next/first free page = last page 
 23718                              <1> 				 ; (deallocate_page procedure will change it)
 23719 000056D3 31C0                <1> 	xor	eax, eax
 23720 000056D5 A3[88770100]        <1> 	mov	[free_pages], eax ; 0
 23721 000056DA 59                  <1> 	pop	ecx
 23722 000056DB 5B                  <1> 	pop	ebx
 23723                              <1> 	;
 23724                              <1> ; 17/04/2021
 23725                              <1> ; ('swap_out' procedure call is disabled as temporary)
 23726                              <1> 
 23727                              <1> out_of_memory:
 23728                              <1> ;	call	swap_out
 23729                              <1> ;	jnc	short al_p_ok  ; [free_pages] = 0, re-allocation by swap_out
 23730                              <1> ;	;
 23731                              <1> ;	sub 	eax, eax ; 0
 23732 000056DC F9                  <1> 	stc
 23733 000056DD C3                  <1> 	retn
 23734                              <1> 
 23735                              <1> al_p_found:
 23736 000056DE 89D9                <1> 	mov	ecx, ebx
 23737 000056E0 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
 23738 000056E6 890D[8C770100]      <1> 	mov	[next_page], ecx ; Set first free page searching start
 23739                              <1> 				 ; address/offset (to the next)
 23740 000056EC FF0D[88770100]      <1>         dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
 23741                              <1> 	;
 23742 000056F2 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
 23743                              <1> 				 ; is copied into the Carry Flag and then cleared
 23744                              <1> 				 ; in the destination.
 23745                              <1> 				 ;
 23746                              <1> 				 ; Reset the bit which is corresponding to the 
 23747                              <1> 				 ; (just) allocated page.
 23748                              <1> 	; 01/07/2015 (4*8 = 32, 1 allocation byte = 8 pages)	
 23749 000056F5 C1E103              <1> 	shl	ecx, 3		 ; (page block offset * 32) + page index
 23750 000056F8 01C8                <1> 	add	eax, ecx	 ; = page number
 23751 000056FA C1E00C              <1> 	shl	eax, 12		 ; physical address of the page (flat/real value)
 23752                              <1> 	; EAX = physical address of memory page
 23753                              <1> 	;
 23754                              <1> 	; NOTE: The relevant page directory and page table entry will be updated
 23755                              <1> 	;       according to this EAX value...
 23756 000056FD 59                  <1> 	pop	ecx
 23757 000056FE 5B                  <1> 	pop	ebx
 23758                              <1> al_p_ok:
 23759 000056FF C3                  <1> 	retn
 23760                              <1> 
 23761                              <1> make_page_dir:
 23762                              <1> 	; 18/04/2015
 23763                              <1> 	; 12/04/2015
 23764                              <1> 	; 23/10/2014
 23765                              <1> 	; 16/10/2014
 23766                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23767                              <1> 	;
 23768                              <1> 	; INPUT ->
 23769                              <1> 	;	none
 23770                              <1> 	; OUTPUT ->
 23771                              <1> 	;	(EAX = 0)
 23772                              <1> 	;	cf = 1 -> insufficient (out of) memory error
 23773                              <1> 	;	cf = 0 ->
 23774                              <1> 	;	u.pgdir = page directory (physical) address of the current
 23775                              <1> 	;		  process/user.
 23776                              <1> 	;
 23777                              <1> 	; Modified Registers -> EAX
 23778                              <1> 	;
 23779 00005700 E896FFFFFF          <1> 	call	allocate_page
 23780 00005705 7216                <1> 	jc	short mkpd_error
 23781                              <1> 	;
 23782 00005707 A3[74010300]        <1> 	mov	[u.pgdir], eax    ; Page dir address for current user/process
 23783                              <1> 				  ; (Physical address)
 23784                              <1> clear_page:
 23785                              <1> 	; 18/04/2015
 23786                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23787                              <1> 	;
 23788                              <1> 	; INPUT ->
 23789                              <1> 	;	EAX = physical address of the page
 23790                              <1> 	; OUTPUT ->
 23791                              <1> 	;	all bytes of the page will be cleared
 23792                              <1> 	;
 23793                              <1> 	; Modified Registers -> none
 23794                              <1> 	;
 23795 0000570C 57                  <1> 	push	edi
 23796 0000570D 51                  <1> 	push	ecx
 23797 0000570E 50                  <1> 	push	eax
 23798 0000570F B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
 23799 00005714 89C7                <1> 	mov	edi, eax
 23800 00005716 31C0                <1> 	xor	eax, eax
 23801 00005718 F3AB                <1> 	rep	stosd
 23802 0000571A 58                  <1> 	pop	eax
 23803 0000571B 59                  <1> 	pop	ecx
 23804 0000571C 5F                  <1> 	pop	edi
 23805                              <1> mkpd_error:
 23806                              <1> mkpt_error:
 23807 0000571D C3                  <1> 	retn
 23808                              <1> 
 23809                              <1> make_page_table:
 23810                              <1> 	; 23/06/2015
 23811                              <1> 	; 18/04/2015
 23812                              <1> 	; 12/04/2015
 23813                              <1> 	; 16/10/2014
 23814                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23815                              <1> 	;
 23816                              <1> 	; INPUT ->
 23817                              <1> 	;	EBX = virtual (linear) address
 23818                              <1> 	;	ECX = page table attributes (lower 12 bits)
 23819                              <1> 	;	      (higher 20 bits must be ZERO)
 23820                              <1> 	;	      (bit 0 must be 1)	 
 23821                              <1> 	;	u.pgdir = page directory (physical) address
 23822                              <1> 	; OUTPUT ->
 23823                              <1> 	;	EDX = Page directory entry address
 23824                              <1> 	;	EAX = Page table address
 23825                              <1> 	;	cf = 1 -> insufficient (out of) memory error
 23826                              <1> 	;	cf = 0 -> page table address in the PDE (EDX)
 23827                              <1> 	;
 23828                              <1> 	; Modified Registers -> EAX, EDX
 23829                              <1> 	;
 23830 0000571E E878FFFFFF          <1> 	call	allocate_page
 23831 00005723 72F8                <1> 	jc	short mkpt_error
 23832 00005725 E811000000          <1> 	call	set_pde	
 23833 0000572A EBE0                <1> 	jmp	short clear_page
 23834                              <1> 
 23835                              <1> make_page:
 23836                              <1> 	; 24/07/2015
 23837                              <1> 	; 23/06/2015 ; (Retro UNIX 386 v1 - beginning)
 23838                              <1> 	;
 23839                              <1> 	; INPUT ->
 23840                              <1> 	;	EBX = virtual (linear) address
 23841                              <1> 	;	ECX = page attributes (lower 12 bits)
 23842                              <1> 	;	      (higher 20 bits must be ZERO)
 23843                              <1> 	;	      (bit 0 must be 1)	 
 23844                              <1> 	;	u.pgdir = page directory (physical) address
 23845                              <1> 	; OUTPUT ->
 23846                              <1> 	;	EBX = Virtual address
 23847                              <1> 	;	(EDX = PTE value)
 23848                              <1> 	;	EAX = Physical address
 23849                              <1> 	;	cf = 1 -> insufficient (out of) memory error
 23850                              <1> 	;
 23851                              <1> 	; Modified Registers -> EAX, EDX
 23852                              <1> 	;
 23853 0000572C E86AFFFFFF          <1> 	call	allocate_page
 23854 00005731 7207                <1> 	jc	short mkp_err
 23855 00005733 E821000000          <1> 	call	set_pte	
 23856 00005738 73D2                <1> 	jnc	short clear_page ; 18/04/2015
 23857                              <1> mkp_err:
 23858 0000573A C3                  <1> 	retn
 23859                              <1> 
 23860                              <1> 
 23861                              <1> set_pde:	; Set page directory entry (PDE)
 23862                              <1> 	; 20/07/2015
 23863                              <1> 	; 18/04/2015
 23864                              <1> 	; 12/04/2015
 23865                              <1> 	; 23/10/2014
 23866                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23867                              <1> 	;
 23868                              <1> 	; INPUT ->
 23869                              <1> 	;	EAX = physical address
 23870                              <1> 	;	      (use present value if EAX = 0)
 23871                              <1> 	;	EBX = virtual (linear) address
 23872                              <1> 	;	ECX = page table attributes (lower 12 bits)
 23873                              <1> 	;	      (higher 20 bits must be ZERO)
 23874                              <1> 	;	      (bit 0 must be 1)	 
 23875                              <1> 	;	u.pgdir = page directory (physical) address
 23876                              <1> 	; OUTPUT ->
 23877                              <1> 	;	EDX = PDE address
 23878                              <1> 	;	EAX = page table address (physical)
 23879                              <1> 	;	;(CF=1 -> Invalid page address)
 23880                              <1> 	;
 23881                              <1> 	; Modified Registers -> EDX
 23882                              <1> 	;
 23883 0000573B 89DA                <1> 	mov	edx, ebx
 23884 0000573D C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22
 23885 00005740 C1E202              <1> 	shl	edx, 2 ; offset to page directory (1024*4)
 23886 00005743 0315[74010300]      <1> 	add	edx, [u.pgdir]
 23887                              <1> 	;
 23888 00005749 21C0                <1> 	and	eax, eax
 23889 0000574B 7506                <1> 	jnz	short spde_1
 23890                              <1> 	;
 23891 0000574D 8B02                <1> 	mov	eax, [edx]  ; old PDE value
 23892                              <1> 	;test	al, 1
 23893                              <1> 	;jz	short spde_2
 23894 0000574F 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h  ; clear lower 12 bits
 23895                              <1> spde_1:
 23896                              <1> 	;and	cx, 0FFFh
 23897 00005753 8902                <1> 	mov	[edx], eax
 23898 00005755 66090A              <1> 	or	[edx], cx
 23899 00005758 C3                  <1> 	retn
 23900                              <1> ;spde_2: ; error
 23901                              <1> ;	stc
 23902                              <1> ;	retn
 23903                              <1> 
 23904                              <1> set_pte:	; Set page table entry (PTE)
 23905                              <1> 	; 24/07/2015
 23906                              <1> 	; 20/07/2015
 23907                              <1> 	; 23/06/2015
 23908                              <1> 	; 18/04/2015
 23909                              <1> 	; 12/04/2015
 23910                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23911                              <1> 	;
 23912                              <1> 	; INPUT ->
 23913                              <1> 	;	EAX = physical page address
 23914                              <1> 	;	      (use present value if EAX = 0)
 23915                              <1> 	;	EBX = virtual (linear) address
 23916                              <1> 	;	ECX = page attributes (lower 12 bits)
 23917                              <1> 	;	      (higher 20 bits must be ZERO)
 23918                              <1> 	;	      (bit 0 must be 1)	 
 23919                              <1> 	;	u.pgdir = page directory (physical) address
 23920                              <1> 	; OUTPUT ->
 23921                              <1> 	;	EAX = physical page address
 23922                              <1> 	;	(EDX = PTE value)
 23923                              <1> 	;	EBX = virtual address
 23924                              <1> 	;
 23925                              <1> 	;	CF = 1 -> error
 23926                              <1> 	;
 23927                              <1> 	; Modified Registers -> EAX, EDX
 23928                              <1> 	;
 23929 00005759 50                  <1> 	push	eax
 23930 0000575A A1[74010300]        <1> 	mov	eax, [u.pgdir] ; 20/07/2015
 23931 0000575F E837000000          <1> 	call 	get_pde
 23932                              <1> 		; EDX = PDE address
 23933                              <1> 		; EAX = PDE value
 23934 00005764 5A                  <1> 	pop	edx ; physical page address
 23935 00005765 722A                <1> 	jc	short spte_err ; PDE not present
 23936                              <1> 	;
 23937 00005767 53                  <1> 	push	ebx ; 24/07/2015
 23938 00005768 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
 23939                              <1> 			    ; EDX = PT address (physical)	
 23940 0000576C C1EB0C              <1> 	shr	ebx, PAGE_SHIFT ; 12
 23941 0000576F 81E3FF030000        <1> 	and	ebx, PTE_MASK	; 03FFh
 23942                              <1> 			 ; clear higher 10 bits (PD bits)
 23943 00005775 C1E302              <1> 	shl	ebx, 2   ; offset to page table (1024*4)
 23944 00005778 01C3                <1> 	add	ebx, eax
 23945                              <1> 	;
 23946 0000577A 8B03                <1> 	mov	eax, [ebx] ; Old PTE value
 23947 0000577C A801                <1> 	test	al, 1
 23948 0000577E 740C                <1> 	jz	short spte_0
 23949 00005780 09D2                <1> 	or	edx, edx
 23950 00005782 750F                <1> 	jnz	short spte_1
 23951 00005784 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 bits
 23952 00005788 89C2                <1> 	mov	edx, eax
 23953 0000578A EB09                <1> 	jmp	short spte_2	
 23954                              <1> spte_0:
 23955                              <1> 	; If this PTE contains a swap (disk) address,
 23956                              <1> 	; it can be updated by using 'swap_in' procedure
 23957                              <1> 	; only!
 23958 0000578C 21C0                <1> 	and	eax, eax
 23959 0000578E 7403                <1> 	jz	short spte_1
 23960                              <1> 	; 24/07/2015
 23961                              <1> 	; swapped page ! (on disk)
 23962 00005790 5B                  <1> 	pop	ebx
 23963                              <1> spte_err:
 23964 00005791 F9                  <1> 	stc
 23965 00005792 C3                  <1> 	retn
 23966                              <1> spte_1: 
 23967 00005793 89D0                <1> 	mov	eax, edx
 23968                              <1> spte_2:
 23969 00005795 09CA                <1> 	or	edx, ecx
 23970                              <1> 	; 23/06/2015
 23971 00005797 8913                <1> 	mov	[ebx], edx ; PTE value in EDX
 23972                              <1> 	; 24/07/2015
 23973 00005799 5B                  <1> 	pop	ebx
 23974 0000579A C3                  <1> 	retn
 23975                              <1> 
 23976                              <1> get_pde:	; Get present value of the relevant PDE
 23977                              <1> 	; 20/07/2015
 23978                              <1> 	; 18/04/2015
 23979                              <1> 	; 12/04/2015
 23980                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
 23981                              <1> 	;
 23982                              <1> 	; INPUT ->
 23983                              <1> 	;	EBX = virtual (linear) address
 23984                              <1> 	;	EAX = page directory (physical) address
 23985                              <1> 	; OUTPUT ->
 23986                              <1> 	;	EDX = Page directory entry address
 23987                              <1> 	;	EAX = Page directory entry value
 23988                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
 23989                              <1> 	; Modified Registers -> EDX, EAX
 23990                              <1> 	;
 23991 0000579B 89DA                <1> 	mov	edx, ebx
 23992 0000579D C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22  (12+10)
 23993 000057A0 C1E202              <1> 	shl 	edx, 2 ; offset to page directory (1024*4)
 23994 000057A3 01C2                <1> 	add	edx, eax ; page directory address (physical)
 23995 000057A5 8B02                <1> 	mov	eax, [edx]
 23996 000057A7 A801                <1> 	test	al, PDE_A_PRESENT ; page table is present or not !
 23997 000057A9 751F                <1> 	jnz	short gpte_retn
 23998 000057AB F9                  <1> 	stc
 23999                              <1> gpde_retn:	
 24000 000057AC C3                  <1> 	retn
 24001                              <1> 
 24002                              <1> get_pte:
 24003                              <1> 		; Get present value of the relevant PTE
 24004                              <1> 	; 29/07/2015
 24005                              <1> 	; 20/07/2015
 24006                              <1> 	; 18/04/2015
 24007                              <1> 	; 12/04/2015
 24008                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
 24009                              <1> 	;
 24010                              <1> 	; INPUT ->
 24011                              <1> 	;	EBX = virtual (linear) address
 24012                              <1> 	;	EAX = page directory (physical) address
 24013                              <1> 	; OUTPUT ->
 24014                              <1> 	;	EDX = Page table entry address (if CF=0)
 24015                              <1> 	;	      Page directory entry address (if CF=1)
 24016                              <1> 	;            (Bit 0 value is 0 if PT is not present)
 24017                              <1> 	;	EAX = Page table entry value (page address)
 24018                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
 24019                              <1> 	; Modified Registers -> EAX, EDX
 24020                              <1> 	;
 24021 000057AD E8E9FFFFFF          <1> 	call 	get_pde
 24022 000057B2 72F8                <1> 	jc	short gpde_retn	; page table is not present
 24023                              <1> 	;jnc	short gpte_1
 24024                              <1> 	;retn
 24025                              <1> ;gpte_1:
 24026 000057B4 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
 24027 000057B8 89DA                <1> 	mov	edx, ebx
 24028 000057BA C1EA0C              <1> 	shr	edx, PAGE_SHIFT ; 12
 24029 000057BD 81E2FF030000        <1> 	and	edx, PTE_MASK	; 03FFh
 24030                              <1> 			 ; clear higher 10 bits (PD bits)
 24031 000057C3 C1E202              <1> 	shl	edx, 2 ; offset from start of page table (1024*4)
 24032 000057C6 01C2                <1> 	add	edx, eax
 24033 000057C8 8B02                <1> 	mov	eax, [edx]
 24034                              <1> gpte_retn:
 24035 000057CA C3                  <1> 	retn
 24036                              <1> 
 24037                              <1> deallocate_page_dir:
 24038                              <1> 	; 15/09/2015
 24039                              <1> 	; 05/08/2015
 24040                              <1> 	; 30/04/2015
 24041                              <1> 	; 28/04/2015
 24042                              <1> 	; 17/10/2014
 24043                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
 24044                              <1> 	;
 24045                              <1> 	; INPUT ->
 24046                              <1> 	;	EAX = PHYSICAL ADDRESS OF THE PAGE DIRECTORY (CHILD)
 24047                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
 24048                              <1> 	; OUTPUT ->
 24049                              <1> 	;	All of page tables in the page directory
 24050                              <1> 	;	and page dir's itself will be deallocated
 24051                              <1> 	;	except 'read only' duplicated pages (will be converted
 24052                              <1> 	;	to writable pages).
 24053                              <1> 	;
 24054                              <1> 	; Modified Registers -> EAX
 24055                              <1> 	;
 24056                              <1> 	;
 24057 000057CB 56                  <1> 	push	esi
 24058 000057CC 51                  <1> 	push	ecx
 24059 000057CD 50                  <1> 	push	eax
 24060 000057CE 89C6                <1> 	mov	esi, eax 
 24061 000057D0 31C9                <1> 	xor	ecx, ecx
 24062                              <1> 	; The 1st PDE points to Kernel Page Table 0 (the 1st 4MB),
 24063                              <1> 	; it must not be deallocated
 24064 000057D2 890E                <1> 	mov	[esi], ecx ; 0 ; clear PDE 0
 24065                              <1> dapd_0:
 24066 000057D4 AD                  <1> 	lodsd
 24067 000057D5 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
 24068 000057D7 7409                <1> 	jz	short dapd_1	
 24069 000057D9 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 24070 000057DD E812000000          <1> 	call	deallocate_page_table			
 24071                              <1> dapd_1:
 24072 000057E2 41                  <1> 	inc	ecx ; page directory entry index
 24073 000057E3 81F900040000        <1> 	cmp	ecx, PAGE_SIZE / 4 ; 1024
 24074 000057E9 72E9                <1> 	jb	short dapd_0
 24075                              <1> dapd_2:
 24076 000057EB 58                  <1> 	pop	eax
 24077 000057EC E872000000          <1> 	call	deallocate_page	; deallocate the page dir's itself
 24078 000057F1 59                  <1> 	pop	ecx
 24079 000057F2 5E                  <1> 	pop	esi
 24080 000057F3 C3                  <1> 	retn
 24081                              <1> 
 24082                              <1> deallocate_page_table:
 24083                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 24084                              <1> 	;	 (temporary modifications)
 24085                              <1> 	; 12/07/2016
 24086                              <1> 	; 19/09/2015
 24087                              <1> 	; 15/09/2015
 24088                              <1> 	; 05/08/2015
 24089                              <1> 	; 30/04/2015
 24090                              <1> 	; 28/04/2015
 24091                              <1> 	; 24/10/2014
 24092                              <1> 	; 23/10/2014
 24093                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
 24094                              <1> 	;
 24095                              <1> 	; INPUT ->
 24096                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE PAGE TABLE
 24097                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
 24098                              <1> 	;	(ECX = page directory entry index)
 24099                              <1> 	; OUTPUT ->
 24100                              <1> 	;	All of pages in the page table and page table's itself
 24101                              <1> 	;	will be deallocated except 'read only' duplicated pages
 24102                              <1> 	;	(will be converted to writable pages).
 24103                              <1> 	;
 24104                              <1> 	; Modified Registers -> EAX
 24105                              <1> 	;
 24106 000057F4 56                  <1> 	push	esi
 24107 000057F5 57                  <1> 	push	edi
 24108 000057F6 52                  <1> 	push	edx
 24109 000057F7 50                  <1> 	push	eax ; *
 24110 000057F8 89C6                <1> 	mov	esi, eax 
 24111 000057FA 31FF                <1> 	xor	edi, edi ; 0
 24112                              <1> dapt_0:
 24113 000057FC AD                  <1> 	lodsd
 24114 000057FD A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
 24115 000057FF 7455                <1> 	jz	short dapt_1
 24116                              <1> 	;
 24117 00005801 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
 24118                              <1> 				  ; (must be 1)
 24119 00005803 753F                <1> 	jnz	short dapt_3
 24120                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
 24121 00005805 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
 24122                              <1> 				   ; as child's page ?
 24123 00005809 7444                <1> 	jz	short dapt_4 ; Clear PTE but don't deallocate the page!
 24124                              <1> 	; check the parent's PTE value is read only & same page or not.. 
 24125                              <1> 	; ECX = page directory entry index (0-1023)
 24126 0000580B 53                  <1> 	push	ebx
 24127 0000580C 51                  <1> 	push	ecx
 24128 0000580D 66C1E102            <1> 	shl	cx, 2 ; *4 
 24129 00005811 01CB                <1> 	add	ebx, ecx ; PDE offset (for the parent)
 24130 00005813 8B0B                <1> 	mov	ecx, [ebx]
 24131 00005815 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
 24132 00005818 7428                <1> 	jz	short dapt_2	; parent process does not use this page
 24133 0000581A 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
 24134                              <1> 	; EDI = page table entry index (0-1023)
 24135 0000581F 89FA                <1> 	mov	edx, edi 
 24136 00005821 66C1E202            <1> 	shl	dx, 2 ; *4 
 24137 00005825 01CA                <1> 	add	edx, ecx ; PTE offset (for the parent)
 24138 00005827 8B1A                <1> 	mov	ebx, [edx]
 24139 00005829 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
 24140 0000582C 7414                <1> 	jz	short dapt_2	; parent process does not use this page
 24141 0000582E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
 24142 00005832 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
 24143 00005837 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
 24144 00005839 7507                <1> 	jne	short dapt_2	; not same page
 24145                              <1> 				; deallocate the child's page
 24146 0000583B 800A02              <1>         or      byte [edx], PTE_A_WRITE ; convert to writable page (parent)
 24147 0000583E 59                  <1> 	pop	ecx
 24148 0000583F 5B                  <1> 	pop	ebx
 24149 00005840 EB0D                <1> 	jmp	short dapt_4
 24150                              <1> 
 24151                              <1> ; 17/04/2021
 24152                              <1> ; ('dapt_1' is disabled as temporary)
 24153                              <1> ;
 24154                              <1> ;dapt_1:
 24155                              <1> ;	or	eax, eax	; swapped page ?
 24156                              <1> ;	jz	short dapt_5	; no
 24157                              <1> ;				; yes
 24158                              <1> ;	shr	eax, 1
 24159                              <1> ;	call	unlink_swap_block ; Deallocate swapped page block
 24160                              <1> ;				  ; on the swap disk (or in file)
 24161                              <1> ;	jmp	short dapt_5
 24162                              <1> dapt_2:
 24163 00005842 59                  <1> 	pop	ecx
 24164 00005843 5B                  <1> 	pop	ebx
 24165                              <1> dapt_3:	
 24166                              <1> 	; 12/07/2016
 24167 00005844 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
 24168 00005848 7505                <1> 	jnz	short dapt_4   ; AVL bit 1 = 1, do not deallocate this page!
 24169                              <1> 	;
 24170                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 24171 0000584A E814000000          <1> 	call	deallocate_page ; set the mem allocation bit of this page
 24172                              <1> dapt_4:
 24173 0000584F C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
 24174                              <1> dapt_1:	; 17/04/2021 (temporary)
 24175                              <1> dapt_5:
 24176 00005856 47                  <1> 	inc	edi ; page table entry index
 24177 00005857 81FF00040000        <1> 	cmp	edi, PAGE_SIZE / 4 ; 1024
 24178 0000585D 729D                <1> 	jb	short dapt_0
 24179                              <1> 	;
 24180 0000585F 58                  <1> 	pop	eax ; *
 24181 00005860 5A                  <1> 	pop	edx
 24182 00005861 5F                  <1> 	pop	edi	
 24183 00005862 5E                  <1> 	pop	esi
 24184                              <1> 	;
 24185                              <1> 	;call	deallocate_page	; deallocate the page table's itself
 24186                              <1> 	;retn
 24187                              <1> 
 24188                              <1> deallocate_page:
 24189                              <1> 	; 15/09/2015
 24190                              <1> 	; 28/04/2015
 24191                              <1> 	; 10/03/2015
 24192                              <1> 	; 17/10/2014
 24193                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
 24194                              <1> 	;
 24195                              <1> 	; INPUT -> 
 24196                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
 24197                              <1> 	; OUTPUT ->
 24198                              <1> 	;	[free_pages] is increased
 24199                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is SET)
 24200                              <1> 	;	CF = 1 if the page is already deallocated
 24201                              <1> 	; 	       (or not allocated) before.  
 24202                              <1> 	;
 24203                              <1> 	; Modified Registers -> EAX
 24204                              <1> 	;
 24205 00005863 53                  <1> 	push	ebx
 24206 00005864 52                  <1> 	push	edx
 24207                              <1> 	;
 24208 00005865 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; shift physical address to 
 24209                              <1> 				     ; 12 bits right
 24210                              <1> 				     ; to get page number
 24211 00005868 89C2                <1> 	mov	edx, eax
 24212                              <1> 	; 15/09/2015
 24213 0000586A C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
 24214                              <1> 				     ; (1 allocation bit = 1 page)
 24215                              <1> 				     ; (1 allocation bytes = 8 pages)
 24216 0000586D 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
 24217                              <1> 				     ; (to get 32 bit position)			
 24218                              <1> 	;
 24219 00005870 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address
 24220 00005875 01D3                <1> 	add	ebx, edx
 24221 00005877 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
 24222                              <1> 				     ; (allocation bit position)	 
 24223 0000587A 3B15[8C770100]      <1> 	cmp 	edx, [next_page]     ; is the new free page address lower
 24224                              <1> 				     ; than the address in 'next_page' ?
 24225                              <1> 				     ; (next/first free page value)		
 24226 00005880 7306                <1> 	jnb	short dap_1	     ; no	
 24227 00005882 8915[8C770100]      <1> 	mov	[next_page], edx     ; yes
 24228                              <1> dap_1:
 24229 00005888 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
 24230                              <1> 				     ; set relevant bit to 1.
 24231                              <1> 				     ; set CF to the previous bit value	
 24232                              <1> 	;cmc			     ; complement carry flag	
 24233                              <1> 	;jc	short dap_2	     ; do not increase free_pages count
 24234                              <1> 				     ; if the page is already deallocated
 24235                              <1> 				     ; before.	
 24236 0000588B FF05[88770100]      <1>         inc     dword [free_pages]
 24237                              <1> dap_2:
 24238 00005891 5A                  <1> 	pop	edx
 24239 00005892 5B                  <1> 	pop	ebx
 24240 00005893 C3                  <1> 	retn
 24241                              <1> 
 24242                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 24243                              <1> ;;                                                              ;;
 24244                              <1> ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
 24245                              <1> ;; Distributed under terms of the GNU General Public License    ;;
 24246                              <1> ;;                                                              ;;
 24247                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 24248                              <1> 
 24249                              <1> ;;$Revision: 5057 $
 24250                              <1> 
 24251                              <1> 
 24252                              <1> ;;align 4
 24253                              <1> ;;proc alloc_page
 24254                              <1> 
 24255                              <1> ;;        pushfd
 24256                              <1> ;;        cli
 24257                              <1> ;;        push    ebx
 24258                              <1> ;;;//-
 24259                              <1> ;;        cmp     [pg_data.pages_free], 1
 24260                              <1> ;;        jle     .out_of_memory
 24261                              <1> ;;;//-
 24262                              <1> ;;
 24263                              <1> ;;        mov     ebx, [page_start]
 24264                              <1> ;;        mov     ecx, [page_end]
 24265                              <1> ;;.l1:
 24266                              <1> ;;        bsf     eax, [ebx];
 24267                              <1> ;;        jnz     .found
 24268                              <1> ;;        add     ebx, 4
 24269                              <1> ;;        cmp     ebx, ecx
 24270                              <1> ;;        jb      .l1
 24271                              <1> ;;        pop     ebx
 24272                              <1> ;;        popfd
 24273                              <1> ;;        xor     eax, eax
 24274                              <1> ;;        ret
 24275                              <1> ;;.found:
 24276                              <1> ;;;//-
 24277                              <1> ;;        dec     [pg_data.pages_free]
 24278                              <1> ;;        jz      .out_of_memory
 24279                              <1> ;;;//-
 24280                              <1> ;;        btr     [ebx], eax
 24281                              <1> ;;        mov     [page_start], ebx
 24282                              <1> ;;        sub     ebx, sys_pgmap
 24283                              <1> ;;        lea     eax, [eax+ebx*8]
 24284                              <1> ;;        shl     eax, 12
 24285                              <1> ;;;//-       dec [pg_data.pages_free]
 24286                              <1> ;;        pop     ebx
 24287                              <1> ;;        popfd
 24288                              <1> ;;        ret
 24289                              <1> ;;;//-
 24290                              <1> ;;.out_of_memory:
 24291                              <1> ;;        mov     [pg_data.pages_free], 1
 24292                              <1> ;;        xor     eax, eax
 24293                              <1> ;;        pop     ebx
 24294                              <1> ;;        popfd
 24295                              <1> ;;        ret
 24296                              <1> ;;;//-
 24297                              <1> ;;endp
 24298                              <1> 
 24299                              <1> duplicate_page_dir:
 24300                              <1> 	; 21/09/2015
 24301                              <1> 	; 31/08/2015
 24302                              <1> 	; 20/07/2015
 24303                              <1> 	; 28/04/2015
 24304                              <1> 	; 27/04/2015
 24305                              <1> 	; 18/04/2015
 24306                              <1> 	; 12/04/2015
 24307                              <1> 	; 18/10/2014
 24308                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
 24309                              <1> 	;
 24310                              <1> 	; INPUT -> 
 24311                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
 24312                              <1> 	;		    page directory.
 24313                              <1> 	; OUTPUT ->
 24314                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
 24315                              <1> 	;	       page directory.
 24316                              <1> 	;	(New page directory with new page table entries.)
 24317                              <1> 	;	(New page tables with read only copies of the parent's
 24318                              <1> 	;	pages.)
 24319                              <1> 	;	EAX = 0 -> Error (CF = 1)
 24320                              <1> 	;
 24321                              <1> 	; Modified Registers -> none (except EAX)
 24322                              <1> 	;
 24323 00005894 E802FEFFFF          <1> 	call	allocate_page
 24324 00005899 723E                <1> 	jc	short dpd_err
 24325                              <1> 	;
 24326 0000589B 55                  <1> 	push	ebp ; 20/07/2015
 24327 0000589C 56                  <1> 	push	esi
 24328 0000589D 57                  <1> 	push	edi
 24329 0000589E 53                  <1> 	push	ebx
 24330 0000589F 51                  <1> 	push	ecx
 24331 000058A0 8B35[74010300]      <1> 	mov	esi, [u.pgdir]
 24332 000058A6 89C7                <1> 	mov	edi, eax
 24333 000058A8 50                  <1> 	push	eax ; save child's page directory address
 24334                              <1> 	; 31/08/2015
 24335                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
 24336                              <1> 	; (use same system space for all user page tables) 
 24337 000058A9 A5                  <1> 	movsd
 24338 000058AA BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
 24339 000058AF B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
 24340                              <1> dpd_0:	
 24341 000058B4 AD                  <1> 	lodsd
 24342                              <1> 	;or	eax, eax
 24343                              <1>         ;jnz     short dpd_1
 24344 000058B5 A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
 24345 000058B7 7508                <1> 	jnz	short dpd_1
 24346                              <1>  	; 20/07/2015 (virtual address at the end of the page table)	
 24347 000058B9 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
 24348 000058BF EB0F                <1> 	jmp	short dpd_2
 24349                              <1> dpd_1:	
 24350 000058C1 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
 24351 000058C5 89C3                <1> 	mov	ebx, eax
 24352                              <1> 	; EBX = Parent's page table address
 24353 000058C7 E81F000000          <1> 	call	duplicate_page_table
 24354 000058CC 720C                <1> 	jc	short dpd_p_err
 24355                              <1> 	; EAX = Child's page table address
 24356 000058CE 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
 24357                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
 24358                              <1> 			 ; (present, writable, user)
 24359                              <1> dpd_2:
 24360 000058D0 AB                  <1> 	stosd
 24361 000058D1 E2E1                <1> 	loop	dpd_0
 24362                              <1> 	;
 24363 000058D3 58                  <1> 	pop	eax  ; restore child's page directory address
 24364                              <1> dpd_3:
 24365 000058D4 59                  <1> 	pop	ecx
 24366 000058D5 5B                  <1> 	pop	ebx
 24367 000058D6 5F                  <1> 	pop	edi
 24368 000058D7 5E                  <1> 	pop	esi
 24369 000058D8 5D                  <1> 	pop	ebp ; 20/07/2015
 24370                              <1> dpd_err:
 24371 000058D9 C3                  <1> 	retn
 24372                              <1> dpd_p_err:
 24373                              <1> 	; release the allocated pages missing (recover free space)
 24374 000058DA 58                  <1> 	pop	eax  ; the new page directory address (physical)
 24375 000058DB 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
 24376 000058E1 E8E5FEFFFF          <1> 	call 	deallocate_page_dir
 24377 000058E6 29C0                <1> 	sub	eax, eax ; 0
 24378 000058E8 F9                  <1> 	stc
 24379 000058E9 EBE9                <1> 	jmp	short dpd_3	
 24380                              <1> 
 24381                              <1> duplicate_page_table:
 24382                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 24383                              <1> 	;	 (temporary modifications)
 24384                              <1> 	; 20/02/2017
 24385                              <1> 	; 21/09/2015
 24386                              <1> 	; 20/07/2015
 24387                              <1> 	; 05/05/2015
 24388                              <1> 	; 28/04/2015
 24389                              <1> 	; 27/04/2015
 24390                              <1> 	; 18/04/2015
 24391                              <1> 	; 18/10/2014
 24392                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
 24393                              <1> 	;
 24394                              <1> 	; INPUT -> 
 24395                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
 24396                              <1> 	;       20/02/2017		 
 24397                              <1> 	;	EBP = Linear address of the page (from 'duplicate_page_dir')
 24398                              <1> 	;	      (Linear address = CORE + user's virtual address) 	
 24399                              <1> 	; OUTPUT ->
 24400                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
 24401                              <1> 	;	      (with 'read only' attribute of page table entries)
 24402                              <1> 	;	20/02/2017
 24403                              <1> 	;	EBP = Next linear page address (for 'duplicate_page_dir')
 24404                              <1> 	;	
 24405                              <1> 	;	CF = 1 -> error 
 24406                              <1> 	;
 24407                              <1> 	; Modified Registers -> EBP (except EAX)
 24408                              <1> 	;
 24409 000058EB E8ABFDFFFF          <1> 	call	allocate_page
 24410 000058F0 7258                <1> 	jc	short dpt_err
 24411                              <1> 	;
 24412 000058F2 50                  <1> 	push	eax ; *
 24413 000058F3 56                  <1> 	push	esi
 24414 000058F4 57                  <1> 	push	edi
 24415 000058F5 52                  <1> 	push	edx
 24416 000058F6 51                  <1> 	push	ecx
 24417                              <1> 	;
 24418 000058F7 89DE                <1> 	mov	esi, ebx
 24419 000058F9 89C7                <1> 	mov	edi, eax
 24420 000058FB 89C2                <1> 	mov	edx, eax
 24421 000058FD 81C200100000        <1> 	add	edx, PAGE_SIZE 	
 24422                              <1> dpt_0:
 24423 00005903 AD                  <1> 	lodsd
 24424 00005904 21C0                <1> 	and	eax, eax
 24425 00005906 7432                <1> 	jz	short dpt_3
 24426 00005908 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
 24427                              <1> 	; 17/04/2021 (temporary)
 24428                              <1> 	;jnz	short dpt_1
 24429 0000590A 7439                <1> 	jz	short dpt_p_err
 24430                              <1> 
 24431                              <1> ; 17/04/2021
 24432                              <1> ; ('reload_page' procedure call is disabled as temporary)
 24433                              <1> ;
 24434                              <1> ;	; 20/07/2015
 24435                              <1> ;	; ebp = virtual (linear) address of the memory page
 24436                              <1> ;	call	reload_page ; 28/04/2015
 24437                              <1> ;	jc	short dpt_p_err
 24438                              <1> dpt_1:
 24439                              <1> 	; 21/09/2015
 24440 0000590C 89C1                <1> 	mov	ecx, eax
 24441 0000590E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
 24442 00005912 F6C102              <1> 	test	cl, PTE_A_WRITE ; writable page ?
 24443 00005915 751A                <1> 	jnz	short dpt_2
 24444                              <1> 	; Read only (parent) page
 24445                              <1> 	; 	- there is a third process which uses this page -
 24446                              <1> 	; Allocate a new page for the child process
 24447 00005917 E87FFDFFFF          <1> 	call	allocate_page
 24448 0000591C 7227                <1> 	jc	short dpt_p_err
 24449 0000591E 57                  <1> 	push	edi
 24450 0000591F 56                  <1> 	push	esi
 24451 00005920 89CE                <1> 	mov	esi, ecx
 24452 00005922 89C7                <1> 	mov	edi, eax
 24453 00005924 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
 24454 00005929 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
 24455 0000592B 5E                  <1> 	pop	esi
 24456 0000592C 5F                  <1> 	pop	edi
 24457                              <1> 	;
 24458                              <1> 
 24459                              <1> ; 17/04/2021
 24460                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)
 24461                              <1> ; 
 24462                              <1> ;	push	ebx
 24463                              <1> ;	push	eax
 24464                              <1> ;	; 20/07/2015
 24465                              <1> ;	mov	ebx, ebp
 24466                              <1> ;	; ebx = virtual (linear) address of the memory page
 24467                              <1> ;	call	add_to_swap_queue
 24468                              <1> ;	pop	eax
 24469                              <1> ;	pop	ebx
 24470                              <1> 
 24471                              <1> 	; 21/09/2015
 24472 0000592D 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
 24473                              <1> 		; user + writable + present page
 24474 0000592F EB09                <1> 	jmp	short dpt_3
 24475                              <1> dpt_2:
 24476                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
 24477 00005931 0C05                <1> 	or	al, PTE_A_USER+PTE_A_PRESENT 
 24478                              <1> 		    ; (read only page!)
 24479 00005933 8946FC              <1> 	mov	[esi-4], eax ; update parent's PTE
 24480 00005936 660D0002            <1> 	or      ax, PTE_DUPLICATED  ; (read only page & duplicated PTE!)
 24481                              <1> dpt_3:
 24482 0000593A AB                  <1> 	stosd  ; EDI points to child's PTE  	 
 24483                              <1> 	;
 24484 0000593B 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
 24485                              <1> 	;
 24486 00005941 39D7                <1> 	cmp	edi, edx
 24487 00005943 72BE                <1> 	jb	short dpt_0
 24488                              <1> dpt_p_err:
 24489 00005945 59                  <1> 	pop	ecx
 24490 00005946 5A                  <1> 	pop	edx
 24491 00005947 5F                  <1> 	pop	edi
 24492 00005948 5E                  <1> 	pop	esi
 24493 00005949 58                  <1> 	pop	eax ; *
 24494                              <1> dpt_err:
 24495 0000594A C3                  <1> 	retn
 24496                              <1> 
 24497                              <1> page_fault_handler:	; CPU EXCEPTION 0Eh (14) : Page Fault !
 24498                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 24499                              <1> 	;	 (temporary modifications)
 24500                              <1> 	; 21/09/2015
 24501                              <1> 	; 19/09/2015
 24502                              <1> 	; 17/09/2015
 24503                              <1> 	; 28/08/2015
 24504                              <1> 	; 20/07/2015
 24505                              <1> 	; 28/06/2015
 24506                              <1> 	; 03/05/2015
 24507                              <1> 	; 30/04/2015
 24508                              <1> 	; 18/04/2015
 24509                              <1> 	; 12/04/2015
 24510                              <1> 	; 30/10/2014
 24511                              <1> 	; 11/09/2014
 24512                              <1> 	; 10/09/2014 (Retro UNIX 386 v1 - beginning)
 24513                              <1> 	;
 24514                              <1> 	; Note: This is not an interrupt/exception handler.
 24515                              <1> 	;	This is a 'page fault remedy' subroutine 
 24516                              <1> 	;	which will be called by standard/uniform
 24517                              <1> 	;	exception handler.
 24518                              <1> 	;
 24519                              <1> 	; INPUT -> 
 24520                              <1> 	;	[error_code] = 32 bit ERROR CODE (lower 5 bits are valid)
 24521                              <1> 	;
 24522                              <1> 	;	cr2 = the virtual (linear) address 
 24523                              <1> 	;	      which has caused to page fault (19/09/2015)
 24524                              <1> 	;
 24525                              <1> 	; OUTPUT ->
 24526                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
 24527                              <1> 	;	EAX = 0 -> no error
 24528                              <1> 	;	EAX > 0 -> error code in EAX (also CF = 1)
 24529                              <1> 	;
 24530                              <1> 	; Modified Registers -> none (except EAX)
 24531                              <1> 	;	
 24532                              <1>         ;
 24533                              <1>         ; ERROR CODE:
 24534                              <1> 	;	 31  .....	4   3	2   1	0
 24535                              <1> 	;	+---+-- --+---+---+---+---+---+---+
 24536                              <1> 	;	|   Reserved  | I | R | U | W | P |
 24537                              <1> 	;	+---+-- --+---+---+---+---+---+---+
 24538                              <1> 	;
 24539                              <1> 	; P : PRESENT -	When set, the page fault was caused by 
 24540                              <1>     	;		a page-protection violation. When not set,
 24541                              <1> 	;		it was caused by a non-present page.
 24542                              <1> 	; W : WRITE   -	When set, the page fault was caused by
 24543                              <1> 	;		a page write. When not set, it was caused
 24544                              <1> 	;		by a page read.
 24545                              <1> 	; U : USER    -	When set, the page fault was caused 
 24546                              <1> 	;		while CPL = 3. 
 24547                              <1> 	;		This does not necessarily mean that
 24548                              <1> 	;		the page fault was a privilege violation.
 24549                              <1> 	; R : RESERVD -	When set, the page fault was caused by
 24550                              <1> 	;     WRITE	reading a 1 in a reserved field.
 24551                              <1> 	; I : INSTRUC -	When set, the page fault was caused by
 24552                              <1> 	;     FETCH	an instruction fetch
 24553                              <1> 	;
 24554                              <1> 	;; x86 (32 bit) VIRTUAL ADDRESS TRANSLATION
 24555                              <1> 	;  31               22                  12 11                    0
 24556                              <1> 	; +-------------------+-------------------+-----------------------+
 24557                              <1>        	; | PAGE DIR. ENTRY # | PAGE TAB. ENTRY # |        OFFSET         |
 24558                              <1>        	; +-------------------+-------------------+-----------------------+
 24559                              <1> 	;
 24560                              <1> 
 24561                              <1> 	;; CR3 REGISTER (Control Register 3)
 24562                              <1> 	;  31                                   12             5 4 3 2   0
 24563                              <1> 	; +---------------------------------------+-------------+---+-----+
 24564                              <1>       	; |                                       |  		|P|P|     |
 24565                              <1>       	; |   PAGE DIRECTORY TABLE BASE ADDRESS   |  reserved	|C|W|rsvrd|
 24566                              <1>       	; |                                       | 		|D|T|     |
 24567                              <1>    	; +---------------------------------------+-------------+---+-----+
 24568                              <1> 	;
 24569                              <1> 	;	PWT    - WRITE THROUGH
 24570                              <1> 	;	PCD    - CACHE DISABLE		
 24571                              <1> 	;
 24572                              <1> 	;
 24573                              <1> 	;; x86 PAGE DIRECTORY ENTRY (4 KByte Page)
 24574                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
 24575                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
 24576                              <1>       	; |                                       |     | | | | |P|P|U|R| |
 24577                              <1>       	; |     PAGE TABLE BASE ADDRESS 31..12    | AVL |G|0|D|A|C|W|/|/|P|
 24578                              <1>       	; |                                       |     | | | | |D|T|S|W| |
 24579                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
 24580                              <1> 	;
 24581                              <1>         ;       P      - PRESENT
 24582                              <1>         ;       R/W    - READ/WRITE
 24583                              <1>         ;       U/S    - USER/SUPERVISOR
 24584                              <1> 	;	PWT    - WRITE THROUGH
 24585                              <1> 	;	PCD    - CACHE DISABLE	
 24586                              <1> 	;	A      - ACCESSED	
 24587                              <1>         ;       D      - DIRTY (IGNORED)
 24588                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
 24589                              <1> 	;	G      - GLOBAL	(IGNORED) 
 24590                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
 24591                              <1> 	;
 24592                              <1> 	;
 24593                              <1> 	;; x86 PAGE TABLE ENTRY (4 KByte Page)
 24594                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
 24595                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
 24596                              <1>       	; |                                       |     | |P| | |P|P|U|R| |
 24597                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |G|A|D|A|C|W|/|/|P|
 24598                              <1>       	; |                                       |     | |T| | |D|T|S|W| |
 24599                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
 24600                              <1> 	;
 24601                              <1>         ;       P      - PRESENT
 24602                              <1>         ;       R/W    - READ/WRITE
 24603                              <1>         ;       U/S    - USER/SUPERVISOR
 24604                              <1> 	;	PWT    - WRITE THROUGH
 24605                              <1> 	;	PCD    - CACHE DISABLE	
 24606                              <1> 	;	A      - ACCESSED	
 24607                              <1>         ;       D      - DIRTY
 24608                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
 24609                              <1> 	;	G      - GLOBAL	 
 24610                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
 24611                              <1> 	;
 24612                              <1> 	;
 24613                              <1> 	;; 80386 PAGE TABLE ENTRY (4 KByte Page)
 24614                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
 24615                              <1> 	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
 24616                              <1>       	; |                                       |     | | | | | | |U|R| |
 24617                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |0|0|D|A|0|0|/|/|P|
 24618                              <1>       	; |                                       |     | | | | | | |S|W| |
 24619                              <1>       	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
 24620                              <1> 	;
 24621                              <1>         ;       P      - PRESENT
 24622                              <1>         ;       R/W    - READ/WRITE
 24623                              <1>         ;       U/S    - USER/SUPERVISOR
 24624                              <1>         ;       D      - DIRTY
 24625                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
 24626                              <1> 	;
 24627                              <1>         ;       NOTE: 0 INDICATES INTEL RESERVED. DO NOT DEFINE.
 24628                              <1> 	;
 24629                              <1> 	;
 24630                              <1> 	;; Invalid Page Table Entry
 24631                              <1> 	; 31                                                           1 0
 24632                              <1>       	; +-------------------------------------------------------------+-+
 24633                              <1>       	; |                                                             | |
 24634                              <1>       	; |                          AVAILABLE                          |0|
 24635                              <1>       	; |                                                             | |
 24636                              <1>       	; +-------------------------------------------------------------+-+
 24637                              <1> 	;
 24638                              <1> 
 24639 0000594B 53                  <1> 	push	ebx
 24640 0000594C 52                  <1> 	push	edx
 24641 0000594D 51                  <1> 	push	ecx
 24642                              <1> 	;
 24643                              <1> 	; 21/09/2015 (debugging)
 24644 0000594E FF05[88010300]      <1> 	inc	dword [u.pfcount] ; page fault count for running process
 24645 00005954 FF05[34030300]      <1> 	inc	dword [PF_Count] ; total page fault count	
 24646                              <1> 	; 28/06/2015
 24647                              <1> 	;mov	edx, [error_code] ; Lower 5 bits are valid
 24648 0000595A 8A15[2C030300]      <1> 	mov	dl, [error_code]
 24649                              <1> 	;
 24650 00005960 F6C201              <1> 	test	dl, 1	; page fault was caused by a non-present page
 24651                              <1> 			; sign
 24652 00005963 741A                <1> 	jz	short pfh_alloc_np
 24653                              <1> 	; 
 24654                              <1> 	; If it is not a 'write on read only page' type page fault
 24655                              <1> 	; major page fault error with minor reason must be returned without 
 24656                              <1> 	; fixing the problem. 'sys_exit with error' will be needed
 24657                              <1> 	; after return here!
 24658                              <1> 	; Page fault will be remedied, by copying page contents
 24659                              <1> 	; to newly allocated page with write permission;
 24660                              <1> 	; sys_fork -> sys_exec -> copy on write, demand paging method is 
 24661                              <1> 	; used for working with minimum possible memory usage. 
 24662                              <1> 	; sys_fork will duplicate page directory and tables of parent  
 24663                              <1> 	; process with 'read only' flag. If the child process attempts to
 24664                              <1> 	; write on these read only pages, page fault will be directed here
 24665                              <1> 	; for allocating a new page with same data/content. 
 24666                              <1> 	;
 24667                              <1> 	; IMPORTANT : Retro UNIX 386 v1 (and SINGLIX and TR-DOS)
 24668                              <1> 	; will not force to separate CODE and DATA space 
 24669                              <1> 	; in a process/program... 
 24670                              <1> 	; CODE segment/section may contain DATA!
 24671                              <1> 	; It is flat, smoth and simplest programming method already as in 
 24672                              <1> 	; Retro UNIX 8086 v1 and MS-DOS programs.
 24673                              <1> 	;	
 24674 00005965 F6C202              <1> 	test	dl, 2	; page fault was caused by a page write
 24675                              <1> 			; sign
 24676 00005968 0F8481000000        <1>         jz      pfh_p_err
 24677                              <1> 	; 31/08/2015
 24678 0000596E F6C204              <1> 	test	dl, 4	; page fault was caused while CPL = 3 (user mode)
 24679                              <1> 			; sign.  (U+W+P = 4+2+1 = 7)
 24680 00005971 747C                <1>         jz	pfh_pv_err
 24681                              <1> 	;
 24682                              <1> 	; make a new page and copy the parent's page content
 24683                              <1> 	; as the child's new page content
 24684                              <1> 	;
 24685 00005973 0F20D3              <1> 	mov	ebx, cr2 ; CR2 contains the linear address 
 24686                              <1> 			 ; which has caused to page fault
 24687 00005976 E87C000000          <1> 	call 	copy_page
 24688 0000597B 726B                <1>         jc      pfh_im_err ; insufficient memory
 24689                              <1> 	;
 24690 0000597D EB63                <1>         jmp     pfh_cpp_ok
 24691                              <1> 	;
 24692                              <1> pfh_alloc_np:
 24693 0000597F E817FDFFFF          <1> 	call	allocate_page	; (allocate a new page)
 24694 00005984 7262                <1>         jc      pfh_im_err	; 'insufficient memory' error
 24695                              <1> pfh_chk_cpl:
 24696                              <1> 	; EAX = Physical (base) address of the allocated (new) page
 24697                              <1> 		; (Lower 12 bits are ZERO, because 
 24698                              <1> 		;	the address is on a page boundary)
 24699 00005986 80E204              <1> 	and	dl, 4	; CPL = 3 ?
 24700 00005989 7505                <1> 	jnz	short pfh_um
 24701                              <1> 			; Page fault handler for kernel/system mode (CPL=0)		
 24702 0000598B 0F20DB              <1> 	mov	ebx, cr3 ; CR3 (Control Register 3) contains physical address
 24703                              <1> 			 ; of the current/active page directory
 24704                              <1> 			 ; (Always kernel/system mode page directory, here!)
 24705                              <1> 			 ; Note: Lower 12 bits are 0. (page boundary)
 24706 0000598E EB06                <1> 	jmp	short pfh_get_pde
 24707                              <1> 	;
 24708                              <1> pfh_um:			; Page fault handler for user/appl. mode (CPL=3)
 24709 00005990 8B1D[74010300]      <1>  	mov	ebx, [u.pgdir] ; Page directory of current/active process
 24710                              <1> 			; Physical address of the USER's page directory
 24711                              <1> 			; Note: Lower 12 bits are 0. (page boundary)
 24712                              <1> pfh_get_pde:
 24713 00005996 80CA03              <1> 	or	dl, 3	; USER + WRITE + PRESENT or SYSTEM + WRITE + PRESENT
 24714 00005999 0F20D1              <1> 	mov	ecx, cr2 ; CR2 contains the virtual address 
 24715                              <1> 			 ; which has been caused to page fault
 24716                              <1> 			 ;
 24717 0000599C C1E914              <1> 	shr	ecx, 20	 ; shift 20 bits right
 24718 0000599F 80E1FC              <1> 	and	cl, 0FCh ; mask lower 2 bits to get PDE offset		
 24719                              <1> 	;
 24720 000059A2 01CB                <1> 	add	ebx, ecx ; now, EBX points to the relevant page dir entry 
 24721 000059A4 8B0B                <1> 	mov	ecx, [ebx] ; physical (base) address of the page table 	
 24722 000059A6 F6C101              <1> 	test	cl, 1	 ; check bit 0 is set (1) or not (0).
 24723 000059A9 740B                <1> 	jz	short pfh_set_pde ; Page directory entry is not valid,
 24724                              <1> 			  	  ; set/validate page directory entry
 24725 000059AB 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
 24726 000059B0 89CB                <1> 	mov	ebx, ecx ; Physical address of the page table
 24727 000059B2 89C1                <1> 	mov	ecx, eax ; new page address (physical) 	
 24728 000059B4 EB16                <1> 	jmp	short pfh_get_pte
 24729                              <1> pfh_set_pde:
 24730                              <1> 	;; NOTE: Page directories and page tables never be swapped out!
 24731                              <1> 	;;	 (So, we know this PDE is empty or invalid)
 24732                              <1> 	;
 24733 000059B6 08D0                <1> 	or	al, dl	 ; lower 3 bits are used as U/S, R/W, P flags
 24734 000059B8 8903                <1> 	mov	[ebx], eax ; Let's put the new page directory entry here !
 24735 000059BA 30C0                <1> 	xor	al, al	 ; clear lower (3..8) bits
 24736 000059BC 89C3                <1> 	mov	ebx, eax
 24737 000059BE E8D8FCFFFF          <1> 	call	allocate_page	 ; (allocate a new page)
 24738 000059C3 7223                <1> 	jc	short pfh_im_err   ; 'insufficient memory' error
 24739                              <1> pfh_spde_1:
 24740                              <1> 	; EAX = Physical (base) address of the allocated (new) page
 24741 000059C5 89C1                <1> 	mov	ecx, eax
 24742 000059C7 E840FDFFFF          <1> 	call	clear_page ; Clear page content
 24743                              <1> pfh_get_pte:
 24744 000059CC 0F20D0              <1> 	mov	eax, cr2 ; virtual address
 24745                              <1> 			 ; which has been caused to page fault
 24746 000059CF 89C7                <1> 	mov	edi, eax ; 20/07/2015
 24747 000059D1 C1E80C              <1> 	shr	eax, 12	 ; shift 12 bit right to get 
 24748                              <1> 			 ; higher 20 bits of the page fault address 
 24749 000059D4 25FF030000          <1> 	and	eax, 3FFh ; mask PDE# bits, the result is PTE# (0 to 1023)
 24750 000059D9 C1E002              <1> 	shl	eax, 2	; shift 2 bits left to get PTE offset
 24751 000059DC 01C3                <1> 	add	ebx, eax ; now, EBX points to the relevant page table entry 
 24752                              <1> ; 17/04/2021 temporary
 24753                              <1> ;	mov	eax, [ebx] ; get previous value of pte
 24754                              <1> ;		; bit 0 of EAX is always 0 (otherwise we would not be here)
 24755                              <1> 
 24756                              <1> ; 17/04/2021
 24757                              <1> ; ('swap_in' procedure call has been disabled as temporary)
 24758                              <1> ;
 24759                              <1> ;	and	eax, eax
 24760                              <1> ;	jz	short pfh_gpte_1
 24761                              <1> ;	; 20/07/2015
 24762                              <1> ;	xchg	ebx, ecx ; new page address (physical)
 24763                              <1> ;	push	ebp ; 20/07/2015
 24764                              <1> ;	mov	ebp, cr2
 24765                              <1> ;		; ECX = physical address of the page table entry
 24766                              <1> ;		; EBX = Memory page address (physical!)
 24767                              <1> ;		; EAX = Swap disk (offset) address
 24768                              <1> ;		; EBP = virtual address (page fault address)
 24769                              <1> ;	call	swap_in
 24770                              <1> ;	pop	ebp
 24771                              <1> ;	jc      short pfh_err_retn
 24772                              <1> ;	xchg	ecx, ebx
 24773                              <1> ;		; EBX = physical address of the page table entry
 24774                              <1> ;		; ECX = new page
 24775                              <1> pfh_gpte_1:
 24776 000059DE 08D1                <1> 	or	cl, dl	; lower 3 bits are used as U/S, R/W, P flags
 24777 000059E0 890B                <1> 	mov	[ebx], ecx ; Let's put the new page table entry here !
 24778                              <1> pfh_cpp_ok:
 24779                              <1> ; 17/04/2021
 24780                              <1> ; ('add_to_swap_queue' procedure call has been disabled as temporary)
 24781                              <1> ;
 24782                              <1> ;	; 20/07/2015
 24783                              <1> ;	mov	ebx, cr2
 24784                              <1> ;	call 	add_to_swap_queue
 24785                              <1> 	;
 24786                              <1> 	; The new PTE (which contains the new page) will be added to 
 24787                              <1> 	; the swap queue, here. 
 24788                              <1> 	; (Later, if memory will become insufficient, 
 24789                              <1> 	; one page will be swapped out which is at the head of 
 24790                              <1> 	; the swap queue by using FIFO and access check methods.)
 24791                              <1> 	;
 24792 000059E2 31C0                <1> 	xor	eax, eax  ; 0
 24793                              <1> 	;
 24794                              <1> pfh_err_retn:
 24795 000059E4 59                  <1> 	pop	ecx
 24796 000059E5 5A                  <1> 	pop	edx
 24797 000059E6 5B                  <1> 	pop	ebx
 24798 000059E7 C3                  <1> 	retn 
 24799                              <1> 	
 24800                              <1> pfh_im_err:
 24801 000059E8 B8E4000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_IM ; Error code in AX
 24802                              <1> 			; Major (Primary) Error: Page Fault
 24803                              <1> 			; Minor (Secondary) Error: Insufficient Memory !
 24804 000059ED EBF5                <1> 	jmp	short pfh_err_retn
 24805                              <1> 
 24806                              <1> pfh_p_err: ; 09/03/2015
 24807                              <1> pfh_pv_err:
 24808                              <1> 	; Page fault was caused by a protection-violation
 24809 000059EF B8E6000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_PV ; Error code in AX
 24810                              <1> 			; Major (Primary) Error: Page Fault
 24811                              <1> 			; Minor (Secondary) Error: Protection violation !
 24812 000059F4 F9                  <1> 	stc
 24813 000059F5 EBED                <1> 	jmp	short pfh_err_retn
 24814                              <1> 
 24815                              <1> copy_page:
 24816                              <1> 	; 22/09/2015
 24817                              <1> 	; 21/09/2015
 24818                              <1> 	; 19/09/2015
 24819                              <1> 	; 07/09/2015
 24820                              <1> 	; 31/08/2015
 24821                              <1> 	; 20/07/2015
 24822                              <1> 	; 05/05/2015
 24823                              <1> 	; 03/05/2015
 24824                              <1> 	; 18/04/2015
 24825                              <1> 	; 12/04/2015
 24826                              <1> 	; 30/10/2014
 24827                              <1> 	; 18/10/2014 (Retro UNIX 386 v1 - beginning)
 24828                              <1> 	;
 24829                              <1> 	; INPUT -> 
 24830                              <1> 	;	EBX = Virtual (linear) address of source page
 24831                              <1> 	;	     (Page fault address)
 24832                              <1> 	; OUTPUT ->
 24833                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
 24834                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
 24835                              <1> 	;	EAX = 0 (CF = 1) 
 24836                              <1> 	;		if there is not a free page to be allocated
 24837                              <1> 	;	(page content of the source page will be copied
 24838                              <1> 	;	onto the target/new page) 	
 24839                              <1> 	;
 24840                              <1> 	; Modified Registers -> ecx, ebx (except EAX)
 24841                              <1> 	;	
 24842 000059F7 56                  <1> 	push	esi
 24843 000059F8 57                  <1> 	push	edi
 24844                              <1> 	;push	ebx
 24845                              <1> 	;push	ecx
 24846 000059F9 31F6                <1> 	xor 	esi, esi
 24847 000059FB C1EB0C              <1> 	shr	ebx, 12 ; shift 12 bits right to get PDE & PTE numbers
 24848 000059FE 89D9                <1> 	mov	ecx, ebx ; save page fault address (as 12 bit shifted)
 24849 00005A00 C1EB08              <1> 	shr	ebx, 8	 ; shift 8 bits right and then
 24850 00005A03 80E3FC              <1> 	and	bl, 0FCh ; mask lower 2 bits to get PDE offset	
 24851 00005A06 89DF                <1> 	mov 	edi, ebx ; save it for the parent of current process
 24852 00005A08 031D[74010300]      <1> 	add	ebx, [u.pgdir] ; EBX points to the relevant page dir entry 
 24853 00005A0E 8B03                <1> 	mov	eax, [ebx] ; physical (base) address of the page table
 24854 00005A10 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits 	
 24855 00005A14 89CB                <1> 	mov	ebx, ecx   ; (restore higher 20 bits of page fault address)
 24856 00005A16 81E3FF030000        <1> 	and	ebx, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
 24857 00005A1C 66C1E302            <1> 	shl	bx, 2	   ; shift 2 bits left to get PTE offset
 24858 00005A20 01C3                <1> 	add	ebx, eax   ; EBX points to the relevant page table entry 
 24859                              <1> 	; 07/09/2015
 24860 00005A22 66F7030002          <1>         test    word [ebx], PTE_DUPLICATED ; (Does current process share this
 24861                              <1> 				     ; read only page as a child process?)	
 24862 00005A27 7509                <1> 	jnz	short cpp_0 ; yes
 24863 00005A29 8B0B                <1> 	mov	ecx, [ebx] ; PTE value
 24864 00005A2B 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h  ; clear page attributes
 24865 00005A30 EB32                <1> 	jmp	short cpp_1
 24866                              <1> cpp_0:
 24867 00005A32 89FE                <1> 	mov	esi, edi
 24868 00005A34 0335[78010300]      <1> 	add	esi, [u.ppgdir] ; the parent's page directory entry
 24869 00005A3A 8B06                <1> 	mov	eax, [esi] ; physical (base) address of the page table
 24870 00005A3C 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
 24871 00005A40 89CE                <1> 	mov	esi, ecx   ; (restore higher 20 bits of page fault address)	
 24872 00005A42 81E6FF030000        <1> 	and	esi, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
 24873 00005A48 66C1E602            <1> 	shl	si, 2	   ; shift 2 bits left to get PTE offset
 24874 00005A4C 01C6                <1> 	add	esi, eax   ; EDX points to the relevant page table entry  	
 24875 00005A4E 8B0E                <1> 	mov	ecx, [esi] ; PTE value of the parent process
 24876                              <1> 	; 21/09/2015
 24877 00005A50 8B03                <1> 	mov	eax, [ebx] ; PTE value of the child process
 24878 00005A52 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear page attributes	
 24879                              <1> 	;
 24880 00005A56 F6C101              <1> 	test	cl, PTE_A_PRESENT ; is it a present/valid page ?
 24881 00005A59 7424                <1> 	jz	short cpp_3 ; the parent's page is not same page  	
 24882                              <1> 	;
 24883 00005A5B 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h ; clear page attributes
 24884 00005A60 39C8                <1> 	cmp	eax, ecx   ; Same page?	
 24885 00005A62 751B                <1> 	jne	short cpp_3 ; Parent page and child page are not same 
 24886                              <1> 			    ; Convert child's page to writable page
 24887                              <1> cpp_1:
 24888 00005A64 E832FCFFFF          <1> 	call	allocate_page
 24889 00005A69 721A                <1> 	jc	short cpp_4 ; 'insufficient memory' error
 24890 00005A6B 21F6                <1> 	and	esi, esi    ; check ESI is valid or not
 24891 00005A6D 7405                <1> 	jz	short cpp_2
 24892                              <1> 		; Convert read only page to writable page 
 24893                              <1> 		;(for the parent of the current process)
 24894                              <1> 	;and	word [esi], PTE_A_CLEAR ; 0F000h
 24895                              <1> 	; 22/09/2015
 24896 00005A6F 890E                <1> 	mov	[esi], ecx
 24897 00005A71 800E07              <1> 	or	byte [esi], PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER
 24898                              <1> 				 ; 1+2+4 = 7
 24899                              <1> cpp_2:
 24900 00005A74 89C7                <1> 	mov	edi, eax ; new page address of the child process
 24901                              <1> 	; 07/09/2015
 24902 00005A76 89CE                <1> 	mov	esi, ecx ; the page address of the parent process
 24903 00005A78 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
 24904 00005A7D F3A5                <1> 	rep	movsd ; 31/08/2015
 24905                              <1> cpp_3:		
 24906 00005A7F 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 1+2+4 = 7
 24907 00005A81 8903                <1> 	mov	[ebx], eax ; Update PTE
 24908 00005A83 28C0                <1> 	sub	al, al ; clear attributes
 24909                              <1> cpp_4:
 24910                              <1> 	;pop	ecx
 24911                              <1> 	;pop	ebx
 24912 00005A85 5F                  <1> 	pop	edi
 24913 00005A86 5E                  <1> 	pop	esi
 24914 00005A87 C3                  <1> 	retn
 24915                              <1> 
 24916                              <1> ;; 28/04/2015
 24917                              <1> ;; 24/10/2014
 24918                              <1> ;; 21/10/2014 (Retro UNIX 386 v1 - beginning)
 24919                              <1> ;; SWAP_PAGE_QUEUE (4096 bytes)
 24920                              <1> ;;
 24921                              <1> ;;   0000   0001   0002   0003   ....   1020   1021   1022   1023	
 24922                              <1> ;; +------+------+------+------+-    -+------+------+------+------+
 24923                              <1> ;; |  pg1 |  pg2 |  pg3 |  pg4 | .... |pg1021|pg1022|pg1023|pg1024|
 24924                              <1> ;; +------+------+------+------+-    -+------+------+------+------+    
 24925                              <1> ;;
 24926                              <1> ;; [swpq_last] = 0 to 4096 (step 4) -> the last position on the queue
 24927                              <1> ;;
 24928                              <1> ;; Method:
 24929                              <1> ;;	Swap page queue is a list of allocated pages with physical
 24930                              <1> ;;	addresses (system mode virtual adresses = physical addresses).
 24931                              <1> ;;	It is used for 'swap_in' and 'swap_out' procedures.
 24932                              <1> ;;	When a new page is being allocated, swap queue is updated
 24933                              <1> ;;	by 'swap_queue_shift' procedure, header of the queue (offset 0)
 24934                              <1> ;;	is checked for 'accessed' flag. If the 1st page on the queue
 24935                              <1> ;;	is 'accessed' or 'read only', it is dropped from the list;
 24936                              <1> ;;	other pages from the 2nd to the last (in [swpq_last]) shifted
 24937                              <1> ;; 	to head then the 2nd page becomes the 1st and '[swpq_last]' 
 24938                              <1> ;;	offset value becomes it's previous offset value - 4.
 24939                              <1> ;;	If the 1st page of the swap page queue is not 'accessed'	
 24940                              <1> ;;	the queue/list is not shifted.
 24941                              <1> ;;	After the queue/list shift, newly allocated page is added
 24942                              <1> ;;	to the tail of the queue at the [swpq_count*4] position.
 24943                              <1> ;;	But, if [swpq_count] > 1023, the newly allocated page
 24944                              <1> ;;	will not be added to the tail of swap page queue.  		 
 24945                              <1> ;;	
 24946                              <1> ;;	During 'swap_out' procedure, swap page queue is checked for
 24947                              <1> ;;	the first non-accessed, writable page in the list, 
 24948                              <1> ;;	from the head to the tail. The list is shifted to left 
 24949                              <1> ;;	(to the head) till a non-accessed page will be found in the list.
 24950                              <1> ;;	Then, this page	is swapped out (to disk) and then it is dropped
 24951                              <1> ;;	from the list by a final swap queue shift. [swpq_count] value
 24952                              <1> ;;	is changed. If all pages on the queue' are 'accessed', 
 24953                              <1> ;;	'insufficient memory' error will be returned ('swap_out' 
 24954                              <1> ;;	procedure will be failed)...
 24955                              <1> ;;
 24956                              <1> ;;	Note: If the 1st page of the queue is an 'accessed' page,
 24957                              <1> ;;	'accessed' flag of the page will be reset (0) and that page
 24958                              <1> ;;	(PTE) will be added to the tail of the queue after
 24959                              <1> ;;	the check, if [swpq_count] < 1023. If [swpq_count] = 1024
 24960                              <1> ;;	the queue will be rotated and the PTE in the head will be
 24961                              <1> ;;	added to the tail after resetting 'accessed' bit. 
 24962                              <1> ;;
 24963                              <1> ;;
 24964                              <1> ;;	
 24965                              <1> ;; SWAP DISK/FILE (with 4096 bytes swapped page blocks)
 24966                              <1> ;;
 24967                              <1> ;;  00000000  00000004  00000008  0000000C   ...   size-8    size-4
 24968                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+
 24969                              <1> ;; |descriptr| page(1) | page(2) | page(3) | ... |page(n-1)| page(n) |
 24970                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+    
 24971                              <1> ;;
 24972                              <1> ;; [swpd_next] = the first free block address in swapped page records
 24973                              <1> ;;    		 for next free block search by 'swap_out' procedure.
 24974                              <1> ;; [swpd_size] = swap disk/file size in sectors (512 bytes)
 24975                              <1> ;;		 NOTE: max. possible swap disk size is 1024 GB
 24976                              <1> ;; 		 (entire swap space must be accessed by using
 24977                              <1> ;;		 31 bit offset address) 
 24978                              <1> ;; [swpd_free] = free block (4096 bytes) count in swap disk/file space
 24979                              <1> ;; [swpd_start] = absolute/start address of the swap disk/file
 24980                              <1> ;;		  0 for file, or beginning sector of the swap partition
 24981                              <1> ;; [swp_drv] = logical drive description table addr. of swap disk/file
 24982                              <1> ;;
 24983                              <1> ;; 					
 24984                              <1> ;; Method:
 24985                              <1> ;;	When the memory (ram) becomes insufficient, page allocation
 24986                              <1> ;;	procedure swaps out a page from memory to the swap disk 
 24987                              <1> ;;	(partition) or swap file to get a new free page at the memory.
 24988                              <1> ;;	Swapping out is performed by using swap page queue.
 24989                              <1> ;;
 24990                              <1> ;; 	Allocation block size of swap disk/file is equal to page size
 24991                              <1> ;;	(4096 bytes). Swapping address (in sectors) is recorded
 24992                              <1> ;;	into relevant page file entry as 31 bit physical (logical)
 24993                              <1> ;;	offset address as 1 bit shifted to left for present flag (0).
 24994                              <1> ;;	Swapped page address is between 1 and swap disk/file size - 4.	  
 24995                              <1> ;;	Absolute physical (logical) address of the swapped page is 
 24996                              <1> ;;	calculated by adding offset value to the swap partition's 
 24997                              <1> ;;	start address. If the swap device (disk) is a virtual disk 
 24998                              <1> ;;	or it is a file, start address of the swap disk/volume is 0, 
 24999                              <1> ;;	and offset value is equal to absolute (physical or logical)
 25000                              <1> ;;	address/position. (It has not to be ZERO if the swap partition 
 25001                              <1> ;;	is in a partitioned virtual hard disk.) 
 25002                              <1> ;;
 25003                              <1> ;;	Note: Swap addresses are always specified/declared in sectors, 
 25004                              <1> ;;	not in bytes or	in blocks/zones/clusters (4096 bytes) as unit.
 25005                              <1> ;;
 25006                              <1> ;;	Swap disk/file allocation is mapped via 'Swap Allocation Table'
 25007                              <1> ;;	at memory as similar to 'Memory Allocation Table'.
 25008                              <1> ;;
 25009                              <1> ;;	Every bit of Swap Allocation Table repsesents one swap block
 25010                              <1> ;;	(equal to page size) respectively. Bit 0 of the S.A.T. byte 0
 25011                              <1> ;;	is reserved for swap disk/file block 0 as descriptor block
 25012                              <1> ;;	(also for compatibility with PTE). If bit value is ZERO,
 25013                              <1> ;;	it means relevant (respective) block is in use, and, 
 25014                              <1> ;;	of course, if bit value is 1, it means relevant (respective)
 25015                              <1> ;;      swap disk/file block is free.
 25016                              <1> ;;	For example: bit 1 of the byte 128 repsesents block 1025 
 25017                              <1> ;;	(128*8+1) or sector (offset) 8200 on the swap disk or
 25018                              <1> ;;	byte (offset/position) 4198400 in the swap file. 
 25019                              <1> ;;	4GB swap space is represented via 128KB Swap Allocation Table.
 25020                              <1> ;;	Initial layout of Swap Allocation Table is as follows:
 25021                              <1> ;;	------------------------------------------------------------
 25022                              <1> ;;	0111111111111111111111111 .... 11111111111111111111111111111
 25023                              <1> ;;	------------------------------------------------------------
 25024                              <1> ;;	(0 is reserved block, 1s represent free blocks respectively.)
 25025                              <1> ;;	(Note: Allocation cell/unit of the table is bit, not byte)
 25026                              <1> ;;
 25027                              <1> ;;	..............................................................
 25028                              <1> ;;
 25029                              <1> ;;	'swap_out' procedure checks 'free_swap_blocks' count at first,
 25030                              <1> ;;	then it searches Swap Allocation Table if free count is not
 25031                              <1> ;;	zero. From begining the [swpd_next] dword value, the first bit 
 25032                              <1> ;;	position with value of 1 on the table is converted to swap
 25033                              <1> ;;	disk/file offset address, in sectors (not 4096 bytes block).
 25034                              <1> ;;	'ldrv_write' procedure is called with ldrv (logical drive
 25035                              <1> ;;	number of physical swap disk or virtual swap disk)
 25036                              <1> ;;	number, sector offset (not absolute sector -LBA- number),
 25037                              <1> ;;	and sector count (8, 512*8 = 4096) and buffer adress
 25038                              <1> ;;	(memory page). That will be a direct disk write procedure.
 25039                              <1> ;;	(for preventing late memory allocation, significant waiting). 
 25040                              <1> ;;	If disk write procedure returns with error or free count of 
 25041                              <1> ;;	swap blocks is ZERO, 'swap_out' procedure will return with
 25042                              <1> ;;	'insufficient memory error' (cf=1). 
 25043                              <1> ;;
 25044                              <1> ;;	(Note: Even if free swap disk/file blocks was not zero,
 25045                              <1> ;;	any disk write error will not be fixed by 'swap_out' procedure,
 25046                              <1> ;;	in other words, 'swap_out' will not check the table for other
 25047                              <1> ;;	free blocks after a disk write error. It will return to 
 25048                              <1> ;;	the caller with error (CF=1) which means swapping is failed. 
 25049                              <1> ;;
 25050                              <1> ;;	After writing the page on to swap disk/file address/sector,
 25051                              <1> ;;	'swap_out' procesure returns with that swap (offset) sector
 25052                              <1> ;;	address (cf=0). 
 25053                              <1> ;;
 25054                              <1> ;;	..............................................................
 25055                              <1> ;;
 25056                              <1> ;;	'swap_in' procedure loads addressed (relevant) swap disk or
 25057                              <1> ;;	file sectors at specified memory page. Then page allocation
 25058                              <1> ;;	procedure updates relevant page table entry with 'present' 
 25059                              <1> ;;	attribute. If swap disk or file reading fails there is nothing
 25060                              <1> ;;	to do, except to terminate the process which is the owner of
 25061                              <1> ;;	the swapped page.
 25062                              <1> ;;
 25063                              <1> ;;	'swap_in' procedure sets the relevant/respective bit value
 25064                              <1> ;;	in the Swap Allocation Table (as free block). 'swap_in' also
 25065                              <1> ;;	updates [swpd_first] pointer if it is required.
 25066                              <1> ;;
 25067                              <1> ;;	..............................................................	 
 25068                              <1> ;;
 25069                              <1> ;;	Note: If [swap_enabled] value is ZERO, that means there is not
 25070                              <1> ;;	a swap disk or swap file in use... 'swap_in' and 'swap_out'
 25071                              <1> ;;	procedures ans 'swap page que' procedures will not be active...
 25072                              <1> ;;	'Insufficient memory' error will be returned by 'swap_out'
 25073                              <1> ;;	and 'general protection fault' will be returned by 'swap_in'
 25074                              <1> ;;	procedure, if it is called mistakenly (a wrong value in a PTE).		
 25075                              <1> ;;
 25076                              <1> 
 25077                              <1> ; 17/04/2021
 25078                              <1> ; ('swap_in' procedure call is disabled as temporary)
 25079                              <1> 
 25080                              <1> swap_in:
 25081                              <1> 	; 31/08/2015
 25082                              <1> 	; 20/07/2015
 25083                              <1> 	; 28/04/2015
 25084                              <1> 	; 18/04/2015
 25085                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
 25086                              <1> 	;
 25087                              <1> 	; INPUT -> 
 25088                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS OF THE MEMORY PAGE
 25089                              <1> 	;	EBP = VIRTUAL (LINEAR) ADDRESS (page fault address)
 25090                              <1> 	;	EAX = Offset Address for the swapped page on the
 25091                              <1> 	;	      swap disk or in the swap file.
 25092                              <1> 	;
 25093                              <1> 	; OUTPUT ->
 25094                              <1> 	;	EAX = 0 if loading at memory has been successful
 25095                              <1> 	;
 25096                              <1> 	;	CF = 1 -> swap disk reading error (disk/file not present
 25097                              <1> 	;		  or sector not present or drive not ready
 25098                              <1> 	;	     EAX = Error code
 25099                              <1> 	;	     [u.error] = EAX 
 25100                              <1> 	;		       = The last error code for the process
 25101                              <1> 	;		         (will be reset after returning to user)	  
 25102                              <1> 	;
 25103                              <1> 	; Modified Registers -> EAX
 25104                              <1> 	;
 25105                              <1> 
 25106                              <1> ;       cmp     dword [swp_drv], 0
 25107                              <1> ;	jna	short swpin_dnp_err
 25108                              <1> ;
 25109                              <1> ;	cmp	eax, [swpd_size]
 25110                              <1> ;	jnb	short swpin_snp_err
 25111                              <1> ;
 25112                              <1> ;	push	esi
 25113                              <1> ;	push	ebx
 25114                              <1> ;	push	ecx
 25115                              <1> ;	mov	esi, [swp_drv]	
 25116                              <1> ;	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
 25117                              <1> ;		; Note: Even if corresponding physical disk's sector 
 25118                              <1> ;		; size different than 512 bytes, logical disk sector
 25119                              <1> ;		; size is 512 bytes and disk reading procedure
 25120                              <1> ;		; will be performed for reading 4096 bytes
 25121                              <1> ;		; (2*2048, 8*512). 
 25122                              <1> ;	; ESI = Logical disk description table address
 25123                              <1> ;	; EBX = Memory page (buffer) address (physical!)
 25124                              <1> ;	; EAX = Sector adress (offset address, logical sector number)
 25125                              <1> ;	; ECX = Sector count ; 8 sectors
 25126                              <1> ;	push	eax
 25127                              <1> ;	call	logical_disk_read
 25128                              <1> ;	pop	eax
 25129                              <1> ;	jnc	short swpin_read_ok
 25130                              <1> ;	;
 25131                              <1> ;	mov	eax, SWP_DISK_READ_ERR ; drive not ready or read error
 25132                              <1> ;	mov	[u.error], eax
 25133                              <1> ;	jmp	short swpin_retn
 25134                              <1> ;	;
 25135                              <1> ;swpin_read_ok:
 25136                              <1> ;	; EAX = Offset address (logical sector number)
 25137                              <1> ;	call	unlink_swap_block  ; Deallocate swap block	
 25138                              <1> ;	;
 25139                              <1> ;	; EBX = Memory page (buffer) address (physical!)
 25140                              <1> ;	; 20/07/2015
 25141                              <1> ;	mov	ebx, ebp ; virtual address (page fault address)
 25142                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
 25143                              <1> ;	mov	bl, [u.uno] ; current process number
 25144                              <1> ;	; EBX = Virtual (Linear) address & process number combination
 25145                              <1> ;	call	swap_queue_shift
 25146                              <1> ;	; eax = 0 ; 10/06/2016 (if ebx input > 0, eax output = 0)
 25147                              <1> ;	;sub	eax, eax  ; 0 ; Error Code = 0  (no error)
 25148                              <1> ;	; zf = 1
 25149                              <1> ;swpin_retn:
 25150                              <1> ;	pop	ecx
 25151                              <1> ;	pop	ebx
 25152                              <1> ;	pop	esi
 25153                              <1> ;	retn
 25154                              <1> ;
 25155                              <1> ;swpin_dnp_err:
 25156                              <1> ;	mov	eax, SWP_DISK_NOT_PRESENT_ERR
 25157                              <1> ;swpin_err_retn:
 25158                              <1> ;	mov	[u.error], eax
 25159                              <1> ;	stc
 25160                              <1> ;	retn
 25161                              <1> ;
 25162                              <1> ;swpin_snp_err:
 25163                              <1> ;	mov	eax, SWP_SECTOR_NOT_PRESENT_ERR
 25164                              <1> ;	jmp	short swpin_err_retn
 25165                              <1> 
 25166                              <1> ; 17/04/2021
 25167                              <1> ; ('swap_out' procedure call is disabled as temporary)
 25168                              <1> 
 25169                              <1> swap_out:
 25170                              <1> 	; 10/06/2016
 25171                              <1> 	; 07/06/2016
 25172                              <1>         ; 23/05/2016
 25173                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
 25174                              <1> 	; 24/10/2014 - 31/08/2015 (Retro UNIX 386 v1)
 25175                              <1> 	;
 25176                              <1> 	; INPUT -> 
 25177                              <1> 	;	none
 25178                              <1> 	;
 25179                              <1> 	; OUTPUT ->
 25180                              <1> 	;	EAX = Physical page address (which is swapped out
 25181                              <1> 	;	      for allocating a new page)
 25182                              <1> 	;	CF = 1 -> swap disk writing error (disk/file not present
 25183                              <1> 	;		  or sector not present or drive not ready
 25184                              <1> 	;	     EAX = Error code
 25185                              <1> 	;	     [u.error] = EAX 
 25186                              <1> 	;		       = The last error code for the process
 25187                              <1> 	;		         (will be reset after returning to user)	  
 25188                              <1> 	;
 25189                              <1> 	; Modified Registers -> none (except EAX)
 25190                              <1> 	;
 25191                              <1> 
 25192                              <1> ;	cmp 	word [swpq_count], 1
 25193                              <1> ;       jc      swpout_im_err ; 'insufficient memory'
 25194                              <1> ;
 25195                              <1> ;       ;cmp    dword [swp_drv], 1
 25196                              <1> ;	;jc	short swpout_dnp_err ; 'swap disk/file not present'
 25197                              <1> ;
 25198                              <1> ;       cmp     dword [swpd_free], 1
 25199                              <1> ;       jc      swpout_nfspc_err ; 'no free space on swap disk'
 25200                              <1> ;
 25201                              <1> ;	push	ebx ; *
 25202                              <1> ;swpout_1:
 25203                              <1> ;	; 10/06/2016
 25204                              <1> ;	xor	ebx, ebx ; shift the queue and return a PTE value
 25205                              <1> ;	call	swap_queue_shift
 25206                              <1> ;	and	eax, eax	; 0 = empty queue (improper entries)
 25207                              <1> ;       jz      swpout_npts_err        ; There is not any proper PTE
 25208                              <1> ;				       ; pointer in the swap queue
 25209                              <1> ;	; EAX = PTE value of the page
 25210                              <1> ;	; EBX = PTE address of the page
 25211                              <1> ;	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
 25212                              <1> ;	;
 25213                              <1> ;	; 07/06/2016
 25214                              <1> ;	; 19/05/2016
 25215                              <1> ;	; check this page is in timer events or not
 25216                              <1> ;	
 25217                              <1> ;swpout_timer_page_0:
 25218                              <1> ;	push	edx ; **
 25219                              <1> ;
 25220                              <1> ;	; 07/06/2016
 25221                              <1> ;	cmp	byte [timer_events], 0 
 25222                              <1> ;	jna	short swpout_2
 25223                              <1> ;	;
 25224                              <1> ;	mov	dl, [timer_events]
 25225                              <1> ;
 25226                              <1> ;	push	ecx ; ***
 25227                              <1> ;	push	ebx ; ****
 25228                              <1> ;	mov	ebx, timer_set ; beginning address of timer event
 25229                              <1> ;			       ; structures 
 25230                              <1> ;swpout_timer_page_1:
 25231                              <1> ;	mov	cl, [ebx]
 25232                              <1> ;	or	cl, cl ; 0 = free, >0 = process number
 25233                              <1> ;	jz	short swpout_timer_page_3
 25234                              <1> ;	mov	ecx, [ebx+12] ; response (signal return) address
 25235                              <1> ;	and	cx, PTE_A_CLEAR ; clear offset part (right 12 bits)
 25236                              <1> ;				; of the response byte address, to
 25237                              <1> ;				; get beginning of the page address)
 25238                              <1> ;	cmp	eax, ecx
 25239                              <1> ;	jne	short swpout_timer_page_2 ; not same page
 25240                              <1> ;	
 25241                              <1> ;	; !same page!
 25242                              <1> ;	;
 25243                              <1> ;	; NOTE: // 19/05/2016 // - TRDOS 386 feature only ! -
 25244                              <1> ;	; This page will be used by the kernel to put timer event
 25245                              <1> ;	; response (signal return) byte at the requested address;
 25246                              <1> ;	; in order to prevent a possible wrong write (while
 25247                              <1> ;	; this page is swapped out) on physical memory,
 25248                              <1> ;	; we must protect this page against to be swapped out!
 25249                              <1> ;	;
 25250                              <1> ;	pop	ebx ; ****
 25251                              <1> ;	pop	ecx ; ***
 25252                              <1> ;	pop	edx ; **
 25253                              <1> ;	jmp	short swpout_1	; do not swap out this page !
 25254                              <1> ; 
 25255                              <1> ;swpout_timer_page_2:
 25256                              <1> ;	; 07/06/2016
 25257                              <1> ;	dec	dl
 25258                              <1> ;	jz	short swpout_timer_page_4
 25259                              <1> ;swpout_timer_page_3:
 25260                              <1> ;	;cmp	ebx, timer_set + 240 ; last timer event (15*16) 
 25261                              <1> ;	;jnb	short swpout_timer_page_4
 25262                              <1> ;	add	ebx, 16
 25263                              <1> ;	jmp	short swpout_timer_page_1	
 25264                              <1> ;
 25265                              <1> ;swpout_timer_page_4:
 25266                              <1> ;	pop	ebx ; ****
 25267                              <1> ;	pop	ecx ; ***
 25268                              <1> ;swpout_2:
 25269                              <1> ;	mov	edx, ebx	       ; Page table entry address	
 25270                              <1> ;	mov	ebx, eax	       ; Buffer (Page) Address				
 25271                              <1> ;	;
 25272                              <1> ;	call	link_swap_block
 25273                              <1> ;	jnc	short swpout_3	       ; It may not be needed here	
 25274                              <1> ;				       ; because [swpd_free] value
 25275                              <1> ;				       ; was checked at the beginging. 	
 25276                              <1> ;	pop	edx ; **
 25277                              <1> ;	pop	ebx ; *
 25278                              <1> ;	jmp	short swpout_nfspc_err 
 25279                              <1> ;swpout_3:
 25280                              <1> ;	test	eax, 80000000h ; test bit 31 (this may not be needed!)
 25281                              <1> ;	jnz	short swpout_nfspc_err  ; 10/06/2016 (bit 31 = 1 !)
 25282                              <1> ;	;	
 25283                              <1> ;	push	esi ; **
 25284                              <1> ;	push	ecx ; ***
 25285                              <1> ;	push	eax ; sector address ; (31 bit !, bit 31 = 0)
 25286                              <1> ;	mov	esi, [swp_drv]	
 25287                              <1> ;	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
 25288                              <1> ;		; Note: Even if corresponding physical disk's sector 
 25289                              <1> ;		; size different than 512 bytes, logical disk sector
 25290                              <1> ;		; size is 512 bytes and disk writing procedure
 25291                              <1> ;		; will be performed for writing 4096 bytes
 25292                              <1> ;		; (2*2048, 8*512). 
 25293                              <1> ;	; ESI = Logical disk description table address
 25294                              <1> ;	; EBX = Buffer (Page) address
 25295                              <1> ;	; EAX = Sector adress (offset address, logical sector number)
 25296                              <1> ;	; ECX = Sector count ; 8 sectors
 25297                              <1> ;	; edx = PTE address
 25298                              <1> ;	call	logical_disk_write
 25299                              <1> ;	; edx = PTE address
 25300                              <1> ;	pop	ecx ; sector address	
 25301                              <1> ;	jnc	short swpout_write_ok
 25302                              <1> ;	;
 25303                              <1> ;	;; call	unlink_swap_block ; this block must be left as 'in use'
 25304                              <1> ;swpout_dw_err:
 25305                              <1> ;	mov	eax, SWP_DISK_WRITE_ERR ; drive not ready or write error
 25306                              <1> ;	mov	[u.error], eax
 25307                              <1> ;	jmp	short swpout_retn
 25308                              <1> ;	;
 25309                              <1> ;swpout_write_ok:
 25310                              <1> ;	; EBX = Buffer (page) address
 25311                              <1> ;	; EDX = Page Table Entry address
 25312                              <1> ;	; ECX = Swap disk sector (file block) address (31 bit)
 25313                              <1> ;	shl 	ecx, 1  ; 31 bit sector address from bit 1 to bit 31 
 25314                              <1> ;	mov 	[edx], ecx 
 25315                              <1> ;		; bit 0 = 0 (swapped page)
 25316                              <1> ;	mov	eax, ebx
 25317                              <1> ;swpout_retn:
 25318                              <1> ;	pop	ecx ; ***
 25319                              <1> ;	pop	esi ; **
 25320                              <1> ;	pop	ebx ; *
 25321                              <1> ;	retn
 25322                              <1> ;
 25323                              <1> ;;swpout_dnp_err:
 25324                              <1> ;;	mov	eax, SWP_DISK_NOT_PRESENT_ERR ; disk not present
 25325                              <1> ;;	jmp	short swpout_err_retn
 25326                              <1> ;swpout_nfspc_err:
 25327                              <1> ;	mov	eax, SWP_NO_FREE_SPACE_ERR ; no free space
 25328                              <1> ;swpout_err_retn:
 25329                              <1> ;	mov	[u.error], eax
 25330                              <1> ;	;stc
 25331                              <1> ;	retn
 25332                              <1> ;swpout_npts_err:
 25333                              <1> ;	mov	eax, SWP_NO_PAGE_TO_SWAP_ERR
 25334                              <1> ;	pop	ebx
 25335                              <1> ;	jmp	short swpout_err_retn
 25336                              <1> ;swpout_im_err:
 25337                              <1> ;	mov	eax, ERR_MINOR_IM ; insufficient (out of) memory
 25338                              <1> ;	jmp	short swpout_err_retn
 25339                              <1> 
 25340                              <1> ; 17/04/2021
 25341                              <1> ; ('swap_queue_shift' procedure call is disabled as temporary)
 25342                              <1> 
 25343                              <1> swap_queue_shift:
 25344                              <1> 	; 26/03/2017
 25345                              <1> 	; 10/06/2016
 25346                              <1> 	; 09/06/2016 - TRDOS 386 (TRDOS v2.0)
 25347                              <1> 	; 23/10/2014 - 20/07/2015 (Retro UNIX 386 v1)
 25348                              <1> 	;
 25349                              <1> 	; INPUT ->
 25350                              <1> 	;	EBX = Virtual (linear) address (bit 12 to 31) 
 25351                              <1> 	;	      and process number combination (bit 0 to 11)
 25352                              <1> 	;	EBX = 0 -> shift/drop from the head (offset 0)
 25353                              <1> 	;	
 25354                              <1> 	; OUTPUT ->
 25355                              <1> 	;	If EBX input > 0 
 25356                              <1> 	;	   the queue will be shifted 4 bytes (dword),
 25357                              <1> 	; 	   from the tail to the head, up to entry offset
 25358                              <1> 	; 	   which points to EBX input value or nothing
 25359                              <1> 	;	   to do if EBX value is not found on the queue.
 25360                              <1> 	;	   (The entry -with EBX value- will be removed
 25361                              <1> 	;	   from the queue if it is found.)
 25362                              <1> 	;
 25363                              <1> 	;	   EAX = 0		
 25364                              <1> 	;
 25365                              <1> 	;	If EBX input = 0
 25366                              <1> 	;	   the queue will be shifted 4 bytes (dword),
 25367                              <1> 	; 	   from the tail to the head, if the PTE address
 25368                              <1> 	;	   which is pointed in head of the queue is marked
 25369                              <1> 	;	   as "accessed" or it is marked as "non present".
 25370                              <1> 	;	   (If "accessed" flag of the PTE -which is pointed
 25371                              <1> 	;	   in the head- is set -to 1-, it will be reset
 25372                              <1> 	;	   -to 0- and then, the queue will be rotated 
 25373                              <1> 	;	   -without dropping pointer of the PTE from 
 25374                              <1> 	;	   the queue- for 4 bytes on head to tail direction.
 25375                              <1> 	;	   Pointer in the head will be moved into the tail,
 25376                              <1> 	;	   other PTEs will be shifted on head direction.)
 25377                              <1> 	;
 25378                              <1> 	;	   Swap queue will be shifted up to the first
 25379                              <1> 	;	   'present' or 'non accessed' page will be found
 25380                              <1> 	;	   (as pointed) on the queue head (then it will be
 25381                              <1>         ;          removed/dropped from the queue).
 25382                              <1> 	;
 25383                              <1> 	;	   EAX (> 0) = PTE value of the page which is
 25384                              <1> 	;		 (it's pointer -virtual address-) dropped
 25385                              <1> 	;		 (removed) from swap queue.
 25386                              <1> 	;	   EBX = PTE address of the page (if EAX > 0)
 25387                              <1> 	;	         which is (it's pointer -virtual address-)
 25388                              <1> 	;		 dropped (removed) from swap queue.
 25389                              <1> 	;
 25390                              <1> 	;	   EAX = 0 -> empty swap queue ! 
 25391                              <1> 	;
 25392                              <1> 	; Modified Registers -> EAX, EBX
 25393                              <1> 	;
 25394                              <1> ;	movzx   eax, word [swpq_count]  ; Max. 1024
 25395                              <1> ;	and	ax, ax
 25396                              <1> ;	jz	short swpqs_retn
 25397                              <1> ;	push	edi
 25398                              <1> ;	push	esi
 25399                              <1> ;	push	ecx
 25400                              <1> ;	mov	esi, swap_queue
 25401                              <1> ;	mov	ecx, eax
 25402                              <1> ;	or	ebx, ebx
 25403                              <1> ;	jz	short swpqs_7
 25404                              <1> ;swpqs_1:
 25405                              <1> ;	lodsd
 25406                              <1> ;	cmp	eax, ebx
 25407                              <1> ;	je	short swpqs_2
 25408                              <1> ;	loop	swpqs_1
 25409                              <1> ;	; 10/06/2016
 25410                              <1> ;	sub	eax, eax 
 25411                              <1> ;	jmp	short swpqs_6
 25412                              <1> ;swpqs_2:
 25413                              <1> ;	mov	edi, esi
 25414                              <1> ;	sub 	edi, 4
 25415                              <1> ;swpqs_3:
 25416                              <1> ;	dec	word [swpq_count]
 25417                              <1> ;	jz	short swpqs_5
 25418                              <1> ;swpqs_4:
 25419                              <1> ;	dec 	ecx
 25420                              <1> ;	rep	movsd	; shift up (to the head)
 25421                              <1> ;swpqs_5:
 25422                              <1> ;	xor	eax, eax
 25423                              <1> ;	mov	[edi], eax
 25424                              <1> ;swpqs_6:
 25425                              <1> ;	pop	ecx
 25426                              <1> ;	pop	esi
 25427                              <1> ;	pop	edi
 25428                              <1> ;swpqs_retn:
 25429                              <1> ;	retn		
 25430                              <1> ;swpqs_7:
 25431                              <1> ;	mov	edi, esi ; head
 25432                              <1> ;	lodsd
 25433                              <1> ;	; 20/07/2015
 25434                              <1> ;	mov	ebx, eax
 25435                              <1> ;	and	ebx, ~PAGE_OFF ; ~0FFFh 
 25436                              <1> ;		      ; ebx = virtual address (at page boundary)	
 25437                              <1> ;	and	eax, PAGE_OFF ; 0FFFh
 25438                              <1> ;		      ; ax = process number (1 to 4095)
 25439                              <1> ;	cmp	al, [u.uno]
 25440                              <1> ;		; Max. 16 (nproc) processes for Retro UNIX 386 v1
 25441                              <1> ;	jne	short swpqs_8
 25442                              <1> ;	mov	eax, [u.pgdir]
 25443                              <1> ;	jmp	short swpqs_9
 25444                              <1> ;swpqs_8:
 25445                              <1> ;	; 09/06/2016
 25446                              <1> ;	cmp	byte [eax+p.stat-1], 0
 25447                              <1> ;	jna	short swpqs_3     ; free (or terminated) process
 25448                              <1> ;	cmp	byte [eax+p.stat-1], 2 ; waiting
 25449                              <1> ;	ja	short swpqs_3 	  ; zombie (3) or undefined ?	
 25450                              <1> ;
 25451                              <1> ;	;shl	ax, 2
 25452                              <1> ;	shl	al, 2
 25453                              <1> ;	mov 	eax, [eax+p.upage-4]
 25454                              <1> ;	or	eax, eax
 25455                              <1> ;	jz	short swpqs_3 ; invalid upage
 25456                              <1> ;	add	eax, u.pgdir - user
 25457                              <1> ;			 ; u.pgdir value for the process
 25458                              <1> ;			 ; is in [eax]
 25459                              <1> ;	mov	eax, [eax]
 25460                              <1> ;	and	eax, eax
 25461                              <1> ;	jz	short swpqs_3 ; invalid page directory
 25462                              <1> ;swpqs_9:
 25463                              <1> ;	push	edx
 25464                              <1> ;	; eax = page directory
 25465                              <1> ;	; ebx = virtual address
 25466                              <1> ;	call	get_pte
 25467                              <1> ;	mov	ebx, edx	; PTE address
 25468                              <1> ;	pop	edx
 25469                              <1> ;	; 10/06/2016
 25470                              <1> ;	jc	short swpqs_13 ; empty PDE
 25471                              <1> ;	; EAX = PTE value
 25472                              <1> ;	test	al, PTE_A_PRESENT ; bit 0 = 1
 25473                              <1> ;	jz	short swpqs_13  ; Drop non-present page
 25474                              <1> ;			        ; from the queue (head)
 25475                              <1> ;	test	al, PTE_A_WRITE	; bit 1 = 0 (read only)
 25476                              <1> ;	jz	short swpqs_13  ; Drop read only page
 25477                              <1> ;			        ; from the queue (head) 	
 25478                              <1> ;	;test	al, PTE_A_ACCESS ; bit 5 = 1 (Accessed)
 25479                              <1> ;	;jnz	short swpqs_11  ; present
 25480                              <1> ;			        ; accessed page
 25481                              <1> ;       btr     eax, PTE_A_ACCESS_BIT ; reset 'accessed' bit
 25482                              <1> ;	jc	short swpqs_11  ; accessed page
 25483                              <1> ;
 25484                              <1> ;	dec	ecx
 25485                              <1> ;	mov	[swpq_count], cx
 25486                              <1> ;       jz      short swpqs_10
 25487                              <1> ;		; esi = head + 4
 25488                              <1> ;		; edi = head
 25489                              <1> ;	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
 25490                              <1> ;swpqs_10:
 25491                              <1> ;	mov	[edi], ecx ; 0
 25492                              <1> ;	jmp	short swpqs_6 ; 26/03/2017
 25493                              <1> ;
 25494                              <1> ;swpqs_11:
 25495                              <1> ;	mov	[ebx], eax     ; save changed attribute
 25496                              <1> ;	; Rotation (head -> tail)
 25497                              <1> ;	dec	ecx     ; entry count -> last entry number		
 25498                              <1> ;	jz	short swpqs_10
 25499                              <1> ;		; esi = head + 4
 25500                              <1> ;		; edi = head
 25501                              <1> ;	mov	eax, [edi] ; 20/07/2015
 25502                              <1> ;	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
 25503                              <1> ;	mov	[edi], eax ; head -> tail ; [k] = [1]
 25504                              <1> ;
 25505                              <1> ;	mov	cx, [swpq_count]
 25506                              <1> ;
 25507                              <1> ;swpqs_12:
 25508                              <1> ;	mov	esi, swap_queue ; head
 25509                              <1> ;       jmp     swpqs_7
 25510                              <1> ;
 25511                              <1> ;swpqs_13:
 25512                              <1> ;	dec	ecx
 25513                              <1> ;	mov	[swpq_count], cx
 25514                              <1> ;       jz      swpqs_5
 25515                              <1> ;	jmp	short swpqs_12
 25516                              <1> 
 25517                              <1> ; 17/04/2021
 25518                              <1> ; ('add_to_swp_queue' procedure call is disabled as temporary)
 25519                              <1> 
 25520                              <1> add_to_swap_queue:
 25521                              <1> 	; 20/02/2017
 25522                              <1> 	; 20/07/2015
 25523                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
 25524                              <1> 	;
 25525                              <1> 	; Adds new page to swap queue
 25526                              <1> 	; (page directories and page tables must not be added
 25527                              <1> 	; to swap queue)	
 25528                              <1> 	;
 25529                              <1> 	; INPUT ->
 25530                              <1> 	;	EBX = Linear (Virtual) addr for current process
 25531                              <1> 	;	[u.uno]
 25532                              <1> 	;	20/02/2017
 25533                              <1> 	;	(Linear address = CORE + user's virtual address)
 25534                              <1> 	;
 25535                              <1> 	; OUTPUT ->
 25536                              <1> 	;	EAX = [swpq_count]
 25537                              <1> 	;	      (after the PTE has been added)
 25538                              <1> 	;	EAX = 0 -> Swap queue is full, (1024 entries)
 25539                              <1> 	;	      the PTE could not be added.
 25540                              <1> 	;
 25541                              <1> 	; Modified Registers -> EAX
 25542                              <1> 	;
 25543                              <1> ;	push	ebx
 25544                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
 25545                              <1> ;	mov	bl, [u.uno] ; current process number
 25546                              <1> ;	call	swap_queue_shift ; drop from the queue if
 25547                              <1> ;				 ; it is already on the queue
 25548                              <1> ;		; then add it to the tail of the queue
 25549                              <1> ;	movzx	eax, word [swpq_count]
 25550                              <1> ;	cmp	ax, 1024
 25551                              <1> ;	jb	short atsq_1
 25552                              <1> ;	sub	ax, ax
 25553                              <1> ;	pop	ebx
 25554                              <1> ;	retn
 25555                              <1> ;atsq_1:
 25556                              <1> ;	push	esi
 25557                              <1> ;	mov	esi, swap_queue
 25558                              <1> ;	and	ax, ax
 25559                              <1> ;	jz	short atsq_2
 25560                              <1> ;	shl	ax, 2	; convert to offset
 25561                              <1> ;	add	esi, eax
 25562                              <1> ;	shr	ax, 2
 25563                              <1> ;atsq_2:
 25564                              <1> ;	inc	ax
 25565                              <1> ;	mov	[esi], ebx ; Virtual address + [u.uno] combination
 25566                              <1> ;	mov	[swpq_count], ax
 25567                              <1> ;	pop	esi
 25568                              <1> ;	pop	ebx
 25569                              <1> ;	retn
 25570                              <1> 
 25571                              <1> ; 17/04/2021
 25572                              <1> ; ('unlink_swap_block' procedure call is disabled as temporary)
 25573                              <1> 
 25574                              <1> unlink_swap_block:
 25575                              <1> 	; 15/09/2015
 25576                              <1> 	; 30/04/2015
 25577                              <1> 	; 18/04/2015
 25578                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
 25579                              <1> 	;
 25580                              <1> 	; INPUT -> 
 25581                              <1> 	;	EAX = swap disk/file offset address
 25582                              <1> 	;	      (bit 1 to bit 31)
 25583                              <1> 	; OUTPUT ->
 25584                              <1> 	;	[swpd_free] is increased
 25585                              <1> 	;	(corresponding SWAP DISK ALLOC. TABLE bit is SET)
 25586                              <1> 	;
 25587                              <1> 	; Modified Registers -> EAX
 25588                              <1> 	;
 25589                              <1> ;	push	ebx
 25590                              <1> ;	push	edx
 25591                              <1> ;	;
 25592                              <1> ;	shr	eax, SECTOR_SHIFT+1  ;3+1 ; shift sector address to 
 25593                              <1> ;				     ; 3 bits right
 25594                              <1> ;				     ; to get swap block/page number
 25595                              <1> ;	mov	edx, eax
 25596                              <1> ;	; 15/09/2015
 25597                              <1> ;	shr	edx, 3		     ; to get offset to S.A.T.
 25598                              <1> ;				     ; (1 allocation bit = 1 page)
 25599                              <1> ;				     ; (1 allocation bytes = 8 pages)
 25600                              <1> ;	and	dl, 0FCh 	     ; clear lower 2 bits
 25601                              <1> ;				     ; (to get 32 bit position)			
 25602                              <1> ;	;
 25603                              <1> ;	mov	ebx, swap_alloc_table ; Swap Allocation Table address
 25604                              <1> ;	add	ebx, edx
 25605                              <1> ;	and	eax, 1Fh	     ; lower 5 bits only
 25606                              <1> ;				     ; (allocation bit position)	 
 25607                              <1> ;	cmp 	eax, [swpd_next]     ; is the new free block addr. lower
 25608                              <1> ;				     ; than the address in 'swpd_next' ?
 25609                              <1> ;				     ; (next/first free block value)		
 25610                              <1> ;	jnb	short uswpbl_1	     ; no	
 25611                              <1> ;	mov	[swpd_next], eax     ; yes	
 25612                              <1> ;uswpbl_1:
 25613                              <1> ;	bts	[ebx], eax	     ; unlink/release/deallocate block
 25614                              <1> ;				     ; set relevant bit to 1.
 25615                              <1> ;				     ; set CF to the previous bit value	
 25616                              <1> ;	cmc			     ; complement carry flag	
 25617                              <1> ;	jc	short uswpbl_2	     ; do not increase swfd_free count
 25618                              <1> ;				     ; if the block is already deallocated
 25619                              <1> ;				     ; before.	
 25620                              <1> ;       inc     dword [swpd_free]
 25621                              <1> ;uswpbl_2:
 25622                              <1> ;	pop	edx
 25623                              <1> ;	pop	ebx
 25624                              <1> ;	retn
 25625                              <1> 
 25626                              <1> ; 17/04/2021
 25627                              <1> ; ('ink_swap_block' procedure call is disabled as temporary)
 25628                              <1> 
 25629                              <1> link_swap_block:
 25630                              <1> 	; 01/07/2015
 25631                              <1> 	; 18/04/2015
 25632                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
 25633                              <1> 	;
 25634                              <1> 	; INPUT -> none
 25635                              <1> 	;
 25636                              <1> 	; OUTPUT ->
 25637                              <1> 	;	EAX = OFFSET ADDRESS OF THE ALLOCATED BLOCK (4096 bytes)
 25638                              <1> 	;	      in sectors (corresponding 
 25639                              <1> 	;	      SWAP DISK ALLOCATION TABLE bit is RESET)
 25640                              <1> 	;
 25641                              <1> 	;	CF = 1 and EAX = 0 
 25642                              <1> 	; 		   if there is not a free block to be allocated	
 25643                              <1> 	;
 25644                              <1> 	; Modified Registers -> none (except EAX)
 25645                              <1> 	;
 25646                              <1> 
 25647                              <1> ;	;mov	eax, [swpd_free]
 25648                              <1> ;	;and	eax, eax
 25649                              <1> ;	;jz	short out_of_swpspc
 25650                              <1> ;	;
 25651                              <1> ;	push	ebx
 25652                              <1> ;	push	ecx
 25653                              <1> ;	;
 25654                              <1> ;	mov	ebx, swap_alloc_table ; Swap Allocation Table offset
 25655                              <1> ;	mov	ecx, ebx
 25656                              <1> ;	add	ebx, [swpd_next] ; Free block searching starts from here
 25657                              <1> ;				 ; next_free_swap_block >> 5
 25658                              <1> ;	add	ecx, [swpd_last] ; Free block searching ends here
 25659                              <1> ;				 ; (total_swap_blocks - 1) >> 5
 25660                              <1> ;lswbl_scan:
 25661                              <1> ;	cmp	ebx, ecx
 25662                              <1> ;	ja	short lswbl_notfound
 25663                              <1> ;	;
 25664                              <1> ;	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
 25665                              <1> ;			   ; Clears ZF if a bit is found set (1) and 
 25666                              <1> ;			   ; loads the destination with an index to
 25667                              <1> ;			   ; first set bit. (0 -> 31) 
 25668                              <1> ;			   ; Sets ZF to 1 if no bits are found set.
 25669                              <1> ;	; 01/07/2015
 25670                              <1> ;	jnz	short lswbl_found ; ZF = 0 -> a free block has been found
 25671                              <1> ;			 ;
 25672                              <1> ;			 ; NOTE:  a Swap Disk Allocation Table bit 
 25673                              <1> ;			 ;	  with value of 1 means 
 25674                              <1> ;			 ;	  the corresponding page is free 
 25675                              <1> ;			 ;	  (Retro UNIX 386 v1 feaure only!)
 25676                              <1> ;	add	ebx, 4
 25677                              <1> ;			 ; We return back for searching next page block
 25678                              <1> ;			 ; NOTE: [swpd_free] is not ZERO; so, 
 25679                              <1> ;			 ;	 we always will find at least 1 free block here.
 25680                              <1> ;	jmp    	short lswbl_scan
 25681                              <1> ;	;
 25682                              <1> ;lswbl_notfound:	
 25683                              <1> ;	sub	ecx, swap_alloc_table
 25684                              <1> ;	mov	[swpd_next], ecx ; next/first free page = last page 
 25685                              <1> ;				 ; (unlink_swap_block procedure will change it)
 25686                              <1> ;	xor	eax, eax
 25687                              <1> ;	mov	[swpd_free], eax
 25688                              <1> ;	stc
 25689                              <1> ;lswbl_ok:
 25690                              <1> ;	pop	ecx
 25691                              <1> ;	pop	ebx
 25692                              <1> ;	retn
 25693                              <1> ;	;
 25694                              <1> ;;out_of_swpspc:
 25695                              <1> ;;	stc
 25696                              <1> ;;	retn
 25697                              <1> ;
 25698                              <1> ;lswbl_found:
 25699                              <1> ;	mov	ecx, ebx
 25700                              <1> ;	sub	ecx, swap_alloc_table
 25701                              <1> ;	mov	[swpd_next], ecx ; Set first free block searching start
 25702                              <1> ;				 ; address/offset (to the next)
 25703                              <1> ;       dec     dword [swpd_free] ; 1 block has been allocated (X = X-1) 
 25704                              <1> ;	;
 25705                              <1> ;	btr	[ebx], eax	 ; The destination bit indexed by the source value
 25706                              <1> ;				 ; is copied into the Carry Flag and then cleared
 25707                              <1> ;				 ; in the destination.
 25708                              <1> ;				 ;
 25709                              <1> ;				 ; Reset the bit which is corresponding to the 
 25710                              <1> ;				 ; (just) allocated block.
 25711                              <1> ;	shl	ecx, 5		 ; (block offset * 32) + block index
 25712                              <1> ;	add	eax, ecx	 ; = block number
 25713                              <1> ;	shl	eax, SECTOR_SHIFT ; 3, sector (offset) address of the block
 25714                              <1> ;				 ; 1 block =  8 sectors
 25715                              <1> ;	;
 25716                              <1> ;	; EAX = offset address of swap disk/file sector (beginning of the block)
 25717                              <1> ;	;
 25718                              <1> ;	; NOTE: The relevant page table entry will be updated
 25719                              <1> ;	;       according to this EAX value...
 25720                              <1> ;	;
 25721                              <1> ;	jmp	short lswbl_ok
 25722                              <1> 
 25723                              <1> ; 17/04/2021
 25724                              <1> ; ('logical_disk_read' procedure call is disabled as temporary)
 25725                              <1> 
 25726                              <1> logical_disk_read:
 25727                              <1> 	; 20/07/2015
 25728                              <1> 	; 09/03/2015 (temporary code here)
 25729                              <1> 	;
 25730                              <1> 	; INPUT ->
 25731                              <1> 	; 	ESI = Logical disk description table address
 25732                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
 25733                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
 25734                              <1> 	; 	ECX = Sector count
 25735                              <1> 	;
 25736                              <1> 	;
 25737                              <1> ;	retn
 25738                              <1> 
 25739                              <1> ; 17/04/2021
 25740                              <1> ; ('logical_disk_write' procedure call is disabled as temporary)
 25741                              <1> 
 25742                              <1> logical_disk_write:
 25743                              <1> 	; 20/07/2015
 25744                              <1> 	; 09/03/2015 (temporary code here)
 25745                              <1> 	;
 25746                              <1> 	; INPUT ->
 25747                              <1> 	; 	ESI = Logical disk description table address
 25748                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
 25749                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
 25750                              <1> 	; 	ECX = Sector count
 25751                              <1> 	;
 25752                              <1> ;	retn
 25753                              <1> 
 25754                              <1> get_physical_addr:
 25755                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 25756                              <1> 	;	(temporary modifications)
 25757                              <1> 	;
 25758                              <1> 	; 26/03/2017
 25759                              <1> 	; 20/02/2017
 25760                              <1> 	; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
 25761                              <1> 	; 18/10/2015
 25762                              <1> 	; 29/07/2015
 25763                              <1> 	; 20/07/2015
 25764                              <1> 	; 04/06/2015
 25765                              <1> 	; 20/05/2015
 25766                              <1> 	; 28/04/2015
 25767                              <1> 	; 18/04/2015
 25768                              <1> 	; Get physical address
 25769                              <1> 	;     (allocates a new page for user if it is not present)
 25770                              <1> 	;	
 25771                              <1> 	; (This subroutine is needed for mapping user's virtual 
 25772                              <1> 	; (buffer) address to physical address (of the buffer).)
 25773                              <1> 	; ('sys write', 'sys read' system calls...)
 25774                              <1> 	;
 25775                              <1> 	; INPUT ->
 25776                              <1> 	;	EBX = virtual address
 25777                              <1> 	;	u.pgdir = page directory (physical) address
 25778                              <1> 	;
 25779                              <1> 	; OUTPUT ->
 25780                              <1> 	;	EAX = physical address 
 25781                              <1> 	;	EBX = linear address	
 25782                              <1> 	;	EDX = physical address of the page frame
 25783                              <1> 	;	      (with attribute bits)
 25784                              <1> 	;	ECX = byte count within the page frame
 25785                              <1> 	;
 25786                              <1> 	; Modified Registers -> EAX, EBX, ECX, EDX
 25787                              <1> 	;
 25788 00005A88 81C300004000        <1> 	add	ebx, CORE ; 18/10/2015
 25789                              <1> get_physical_addr_x: ; 27/05/2016
 25790 00005A8E A1[74010300]        <1> 	mov	eax, [u.pgdir]
 25791 00005A93 E815FDFFFF          <1> 	call	get_pte
 25792                              <1> 		; EDX = Page table entry address (if CF=0)
 25793                              <1> 	        ;       Page directory entry address (if CF=1)
 25794                              <1> 		;       (Bit 0 value is 0 if PT is not present)
 25795                              <1> 		; EAX = Page table entry value (page address)
 25796                              <1> 		;	CF = 1 -> PDE not present or invalid ? 
 25797 00005A98 731C                <1> 	jnc	short gpa_1
 25798                              <1> 	;
 25799 00005A9A E8FCFBFFFF          <1> 	call	allocate_page
 25800 00005A9F 723F                <1> 	jc	short gpa_im_err  ; 'insufficient memory' error
 25801                              <1> gpa_0:
 25802 00005AA1 E866FCFFFF          <1> 	call 	clear_page
 25803                              <1> 	; EAX = Physical (base) address of the allocated (new) page
 25804 00005AA6 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
 25805                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
 25806                              <1> 			   ; (user, writable, present page)	
 25807 00005AA8 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
 25808 00005AAA A1[74010300]        <1> 	mov	eax, [u.pgdir]	
 25809 00005AAF E8F9FCFFFF          <1> 	call	get_pte
 25810 00005AB4 722A                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
 25811                              <1> gpa_1:
 25812                              <1> 	; EAX = PTE value, EDX = PTE address
 25813 00005AB6 A801                <1> 	test 	al, PTE_A_PRESENT
 25814 00005AB8 7516                <1> 	jnz	short gpa_3 ; 26/03/2017
 25815 00005ABA 09C0                <1> 	or	eax, eax
 25816 00005ABC 7446                <1> 	jz	short gpa_7  ; Allocate a new page
 25817                              <1> 
 25818                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
 25819                              <1> ; ('reload_page' procedure call is disabled as temporary)
 25820 00005ABE EB20                <1> 	jmp	short gpa_im_err  ; temporary !
 25821                              <1> 
 25822                              <1> 	; 20/07/2015
 25823                              <1> ;	push	ebp
 25824                              <1> ;	mov	ebp, ebx ; virtual (linear) address
 25825                              <1> ;	; reload swapped page
 25826                              <1> ;	call	reload_page ; 28/04/2015
 25827                              <1> ;	pop	ebp
 25828                              <1> ;	jc	short gpa_retn
 25829                              <1> gpa_2:
 25830                              <1> 	; 26/03/2017
 25831                              <1> 	; 20/02/2017
 25832                              <1> 	; If a page will contain a Signal Response Byte
 25833                              <1> 	; it must not be swapped out, because
 25834                              <1> 	; timer service or irq callback service
 25835                              <1> 	; will write a signal return/response byte 
 25836                              <1> 	; directly by using physical address of Signal
 25837                              <1> 	; Response Byte.(Even if process is not running,
 25838                              <1> 	; or it is running with swapped out pages.)
 25839                              <1> 	;
 25840                              <1> 	; 'no_page_swap' will be set by 'systimer' or
 25841                              <1> 	; 'syscalbac' sistem functions/calls. (*)
 25842                              <1> 	;
 25843 00005AC0 803D[16890100]00    <1> 	cmp	byte [no_page_swap], 0
 25844 00005AC7 761D                <1> 	jna	short gpa_4 ; this page can be swapped out
 25845                              <1> 	; this page must not be swapped out
 25846                              <1> 	; but 'no_page_swap' must be reset here
 25847                              <1> 	; immediately for other callers (*)
 25848                              <1> 	; (otherwise, swap queue would not be long enough) 
 25849 00005AC9 E844000000          <1> 	call	gpa_8 ; 26/03/2017
 25850 00005ACE EB16                <1> 	jmp	short gpa_5
 25851                              <1> gpa_3: 
 25852                              <1> 	; 26/03/2017
 25853 00005AD0 803D[16890100]00    <1> 	cmp	byte [no_page_swap], 0
 25854 00005AD7 7611                <1> 	jna	short gpa_6 ; this page can be swapped out
 25855 00005AD9 E834000000          <1> 	call	gpa_8
 25856 00005ADE EB0A                <1> 	jmp	short gpa_6
 25857                              <1> 
 25858                              <1> gpa_im_err:	
 25859 00005AE0 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
 25860                              <1> 				  ; Major error = 0 (No protection fault)	
 25861 00005AE5 C3                  <1> 	retn
 25862                              <1> gpa_4:
 25863                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
 25864                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)
 25865                              <1> 
 25866                              <1> 	; 20/07/2015
 25867                              <1> 	; 20/05/2015
 25868                              <1> 	; add this page to swap queue
 25869                              <1> ;	push	eax 
 25870                              <1> ;	; EBX = Linear (CORE+virtual) address ; 20/02/2017 
 25871                              <1> ;	call 	add_to_swap_queue
 25872                              <1> ;	pop	eax
 25873                              <1> gpa_5:
 25874                              <1> 		; PTE address in EDX
 25875                              <1> 		; virtual address in EBX
 25876                              <1> 	; EAX = memory page address
 25877 00005AE6 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_USER + PTE_A_WRITE
 25878                              <1> 				  ; present flag, bit 0 = 1
 25879                              <1> 				  ; user flag, bit 2 = 1	
 25880                              <1> 				  ; writable flag, bit 1 = 1
 25881 00005AE8 8902                <1> 	mov	[edx], eax  ; Update PTE value
 25882                              <1> gpa_6:
 25883                              <1> 	; 18/10/2015
 25884 00005AEA 89D9                <1> 	mov	ecx, ebx
 25885 00005AEC 81E1FF0F0000        <1> 	and	ecx, PAGE_OFF
 25886 00005AF2 89C2                <1> 	mov 	edx, eax
 25887 00005AF4 662500F0            <1> 	and	ax, PTE_A_CLEAR
 25888 00005AF8 01C8                <1> 	add	eax, ecx
 25889 00005AFA F7D9                <1> 	neg	ecx ; 1 -> -1 (0FFFFFFFFh), 4095 (0FFFh) -> -4095
 25890 00005AFC 81C100100000        <1> 	add	ecx, PAGE_SIZE
 25891 00005B02 F8                  <1> 	clc
 25892                              <1> gpa_retn:
 25893 00005B03 C3                  <1> 	retn
 25894                              <1> gpa_7:	
 25895 00005B04 E892FBFFFF          <1> 	call	allocate_page
 25896 00005B09 72D5                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
 25897 00005B0B E8FCFBFFFF          <1> 	call	clear_page
 25898 00005B10 EBAE                <1> 	jmp	short gpa_2
 25899                              <1> 
 25900                              <1> gpa_8: ; 26/03/2017
 25901 00005B12 C605[16890100]00    <1> 	mov	byte [no_page_swap], 0
 25902                              <1> 
 25903 00005B19 C3                  <1> 	retn	; 17/04/2021 (temporary)
 25904                              <1> 
 25905                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
 25906                              <1> ; ('swap_queue_shift' procedure call is disabled as temporary)
 25907                              <1> ;	
 25908                              <1> ;	push	ebx
 25909                              <1> ;	push	eax ; 26/03/2017
 25910                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
 25911                              <1> ;	mov	bl, [u.uno] ; current process number
 25912                              <1> ;	call	swap_queue_shift ; drop from the queue if
 25913                              <1> ;				 ; it is already on the queue
 25914                              <1> ;	pop	eax ; 26/03/2017
 25915                              <1> ;	pop	ebx
 25916                              <1> ;
 25917                              <1> ;	retn
 25918                              <1> 
 25919                              <1> ; 17/04/2021
 25920                              <1> ; ('reload_page' procedure call is disabled as temporary)
 25921                              <1> 
 25922                              <1> reload_page:
 25923                              <1> 	; 20/07/2015
 25924                              <1> 	; 28/04/2015 (Retro UNIX 386 v1 - beginning)
 25925                              <1> 	;
 25926                              <1> 	; Reload (Restore) swapped page at memory
 25927                              <1> 	;
 25928                              <1> 	; INPUT -> 
 25929                              <1> 	;	EBP = Virtual (linear) memory address
 25930                              <1> 	;	EAX = PTE value (swap disk sector address)
 25931                              <1> 	;	(Swap disk sector address = bit 1 to bit 31 of EAX)	
 25932                              <1> 	; OUTPUT ->
 25933                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF RELOADED PAGE
 25934                              <1> 	;
 25935                              <1> 	;	CF = 1 and EAX = error code
 25936                              <1> 	;
 25937                              <1> 	; Modified Registers -> none (except EAX)
 25938                              <1> 	;
 25939                              <1> ;	shr	eax, 1   ; Convert PTE value to swap disk address 
 25940                              <1> ;	push	ebx      ;
 25941                              <1> ;	mov	ebx, eax ; Swap disk (offset) address	
 25942                              <1> ;	call	allocate_page
 25943                              <1> ;	jc	short rlp_im_err
 25944                              <1> ;	xchg 	eax, ebx	
 25945                              <1> ;	; EBX = Physical memory (page) address
 25946                              <1> ;	; EAX = Swap disk (offset) address
 25947                              <1> ;	; EBP = Virtual (linear) memory address
 25948                              <1> ;	call	swap_in
 25949                              <1> ;	jc	short rlp_swp_err  ; (swap disk/file read error)
 25950                              <1> ;	mov	eax, ebx	
 25951                              <1> ;rlp_retn:
 25952                              <1> ;	pop	ebx
 25953                              <1> ;	retn
 25954                              <1> ;	
 25955                              <1> ;rlp_im_err:	
 25956                              <1> ;	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
 25957                              <1> ;				  ; Major error = 0 (No protection fault)	
 25958                              <1> ;	jmp	short rlp_retn
 25959                              <1> ;
 25960                              <1> ;rlp_swp_err:
 25961                              <1> ;	mov 	eax, SWP_DISK_READ_ERR ; Swap disk read error !
 25962                              <1> ;	jmp	short rlp_retn
 25963                              <1> 
 25964                              <1> copy_page_dir:
 25965                              <1> 	; 17/04/2021 (temporary modifications)
 25966                              <1> 	; 19/09/2015
 25967                              <1> 	; temporary - 07/09/2015
 25968                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
 25969                              <1> 	;
 25970                              <1> 	; INPUT -> 
 25971                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
 25972                              <1> 	;		    page directory.
 25973                              <1> 	; OUTPUT ->
 25974                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
 25975                              <1> 	;	       page directory.
 25976                              <1> 	;	(New page directory with new page table entries.)
 25977                              <1> 	;	(New page tables with read only copies of the parent's
 25978                              <1> 	;	pages.)
 25979                              <1> 	;	EAX = 0 -> Error (CF = 1)
 25980                              <1> 	;
 25981                              <1> 	; Modified Registers -> none (except EAX)
 25982                              <1> 	;
 25983 00005B1A E87CFBFFFF          <1> 	call	allocate_page
 25984 00005B1F 723E                <1> 	jc	short cpd_err
 25985                              <1> 	;
 25986 00005B21 55                  <1> 	push	ebp ; 20/07/2015
 25987 00005B22 56                  <1> 	push	esi
 25988 00005B23 57                  <1> 	push	edi
 25989 00005B24 53                  <1> 	push	ebx
 25990 00005B25 51                  <1> 	push	ecx
 25991 00005B26 8B35[74010300]      <1> 	mov	esi, [u.pgdir]
 25992 00005B2C 89C7                <1> 	mov	edi, eax
 25993 00005B2E 50                  <1> 	push	eax ; save child's page directory address
 25994                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
 25995                              <1> 	; (use same system space for all user page tables) 
 25996 00005B2F A5                  <1> 	movsd
 25997 00005B30 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
 25998 00005B35 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
 25999                              <1> cpd_0:	
 26000 00005B3A AD                  <1> 	lodsd
 26001                              <1> 	;or	eax, eax
 26002                              <1>         ;jnz     short cpd_1
 26003 00005B3B A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
 26004 00005B3D 7508                <1> 	jnz	short cpd_1
 26005                              <1>  	; (virtual address at the end of the page table)	
 26006 00005B3F 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
 26007 00005B45 EB0F                <1> 	jmp	short cpd_2
 26008                              <1> cpd_1:	
 26009 00005B47 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
 26010 00005B4B 89C3                <1> 	mov	ebx, eax
 26011                              <1> 	; EBX = Parent's page table address
 26012 00005B4D E81F000000          <1> 	call	copy_page_table
 26013 00005B52 720C                <1> 	jc	short cpd_p_err
 26014                              <1> 	; EAX = Child's page table address
 26015 00005B54 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
 26016                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
 26017                              <1> 			 ; (present, writable, user)
 26018                              <1> cpd_2:
 26019 00005B56 AB                  <1> 	stosd
 26020 00005B57 E2E1                <1> 	loop	cpd_0
 26021                              <1> 	;
 26022 00005B59 58                  <1> 	pop	eax  ; restore child's page directory address
 26023                              <1> cpd_3:
 26024 00005B5A 59                  <1> 	pop	ecx
 26025 00005B5B 5B                  <1> 	pop	ebx
 26026 00005B5C 5F                  <1> 	pop	edi
 26027 00005B5D 5E                  <1> 	pop	esi
 26028 00005B5E 5D                  <1> 	pop	ebp
 26029                              <1> cpd_err:
 26030 00005B5F C3                  <1> 	retn
 26031                              <1> cpd_p_err:
 26032                              <1> 	; release the allocated pages missing (recover free space)
 26033 00005B60 58                  <1> 	pop	eax  ; the new page directory address (physical)
 26034 00005B61 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
 26035 00005B67 E85FFCFFFF          <1> 	call 	deallocate_page_dir
 26036 00005B6C 29C0                <1> 	sub	eax, eax ; 0
 26037 00005B6E F9                  <1> 	stc
 26038 00005B6F EBE9                <1> 	jmp	short cpd_3	
 26039                              <1> 
 26040                              <1> copy_page_table:
 26041                              <1> 	; 17/04/2021 (temporary modifications)
 26042                              <1> 	; 19/09/2015
 26043                              <1> 	; temporary - 07/09/2015
 26044                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
 26045                              <1> 	;
 26046                              <1> 	; INPUT -> 
 26047                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
 26048                              <1> 	;	EBP = page table entry index (from 'copy_page_dir')
 26049                              <1> 	; OUTPUT ->
 26050                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
 26051                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
 26052                              <1> 	;	CF = 1 -> error 
 26053                              <1> 	;
 26054                              <1> 	; Modified Registers -> EBP (except EAX)
 26055                              <1> 	;
 26056 00005B71 E825FBFFFF          <1> 	call	allocate_page
 26057 00005B76 7244                <1> 	jc	short cpt_err
 26058                              <1> 	;
 26059 00005B78 50                  <1> 	push	eax ; *
 26060                              <1> 	;push 	ebx
 26061 00005B79 56                  <1> 	push	esi
 26062 00005B7A 57                  <1> 	push	edi
 26063 00005B7B 52                  <1> 	push	edx
 26064 00005B7C 51                  <1> 	push	ecx
 26065                              <1> 	;
 26066 00005B7D 89DE                <1> 	mov	esi, ebx
 26067 00005B7F 89C7                <1> 	mov	edi, eax
 26068 00005B81 89C2                <1> 	mov	edx, eax
 26069 00005B83 81C200100000        <1> 	add	edx, PAGE_SIZE 	
 26070                              <1> cpt_0:
 26071 00005B89 AD                  <1> 	lodsd
 26072 00005B8A A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 = 1
 26073                              <1> 	;jnz	short cpt_1 (*)
 26074                              <1> 	; 17/04/2021 (temporary (*)
 26075                              <1> 	;and	eax, eax (*)
 26076 00005B8C 741E                <1> 	jz	short cpt_2  ; 17/04/2021
 26077                              <1> 	
 26078                              <1> ; 17/04/2021
 26079                              <1> ; ('reload_page' procedure call is disabled as temporary)
 26080                              <1> ;
 26081                              <1> ;	; ebp = virtual (linear) address of the memory page
 26082                              <1> ;	call	reload_page ; 28/04/2015
 26083                              <1> ;	jc	short cpt_p_err
 26084                              <1> cpt_1:
 26085 00005B8E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
 26086 00005B92 89C1                <1> 	mov	ecx, eax
 26087                              <1> 	; Allocate a new page for the child process
 26088 00005B94 E802FBFFFF          <1> 	call	allocate_page
 26089 00005B99 721C                <1> 	jc	short cpt_p_err
 26090 00005B9B 57                  <1> 	push	edi
 26091 00005B9C 56                  <1> 	push	esi
 26092 00005B9D 89CE                <1> 	mov	esi, ecx
 26093 00005B9F 89C7                <1> 	mov	edi, eax
 26094 00005BA1 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
 26095 00005BA6 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
 26096 00005BA8 5E                  <1> 	pop	esi
 26097 00005BA9 5F                  <1> 	pop	edi
 26098                              <1> 	; 
 26099                              <1> 
 26100                              <1> ; 17/04/2021
 26101                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)	
 26102                              <1> ;
 26103                              <1> ;	push	ebx
 26104                              <1> ;	push	eax
 26105                              <1> ;	mov	ebx, ebp
 26106                              <1> ;	; ebx = virtual address of the memory page
 26107                              <1> ;	call	add_to_swap_queue
 26108                              <1> ;	pop	eax
 26109                              <1> ;	pop	ebx
 26110                              <1> 	;
 26111                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
 26112 00005BAA 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
 26113                              <1> cpt_2:
 26114 00005BAC AB                  <1> 	stosd  ; EDI points to child's PTE  	 
 26115                              <1> 	;
 26116 00005BAD 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
 26117                              <1> 	;
 26118 00005BB3 39D7                <1> 	cmp	edi, edx
 26119 00005BB5 72D2                <1> 	jb	short cpt_0
 26120                              <1> cpt_p_err:
 26121 00005BB7 59                  <1> 	pop	ecx
 26122 00005BB8 5A                  <1> 	pop	edx
 26123 00005BB9 5F                  <1> 	pop	edi
 26124 00005BBA 5E                  <1> 	pop	esi
 26125                              <1> 	;pop	ebx
 26126 00005BBB 58                  <1> 	pop	eax ; *
 26127                              <1> cpt_err:
 26128 00005BBC C3                  <1> 	retn
 26129                              <1> 
 26130                              <1> allocate_memory_block:
 26131                              <1> 	; 01/05/2017
 26132                              <1> 	; 28/04/2017
 26133                              <1> 	; 25/04/2017
 26134                              <1> 	; 01/04/2016, 02/04/2016, 03/04/2016
 26135                              <1> 	; 13/03/2016, 14/03/2016
 26136                              <1> 	; 12/03/2016 (TRDOS 386 = TRDOS v2.0)
 26137                              <1> 	; Allocating contiguous memory pages (in the kernel's memory space)
 26138                              <1> 	;
 26139                              <1> 	; INPUT -> 
 26140                              <1> 	;	EAX = Beginning address (physical)
 26141                              <1> 	;	EAX = 0 -> Allocate memory block from the first proper aperture	
 26142                              <1> 	;	ECX = Number of bytes to be allocated
 26143                              <1> 	;
 26144                              <1> 	; OUTPUT ->
 26145                              <1> 	; 	1) cf = 0 -> successful
 26146                              <1> 	;	EAX = Beginning (physical) address of the allocated memory block
 26147                              <1> 	;	ECX = Number of allocated bytes (rounded up to page borders) 
 26148                              <1> 	;	2) cf = 1 -> unsuccessful
 26149                              <1> 	;	 2.1) If EAX > 0 -> 
 26150                              <1> 	;	      (Number of requested pages is more than # of free pages
 26151                              <1> 	;	       but contiguous free pages -the aperture- is not enough!)	   	
 26152                              <1> 	;	      EAX = Beginning address of available aperture
 26153                              <1> 	;		    (one of all aperture with max. aperture size/length)		
 26154                              <1> 	;	      ECX = Size of available aperture (memory block) in bytes
 26155                              <1> 	;	 2.2) If EAX = 0 -> Out of memory error 
 26156                              <1> 	;	            (number of free pages is less than requested number)
 26157                              <1> 	;	      ECX = Total number of free bytes (free pages * 4096) 
 26158                              <1> 	;		    (It is not number of contiguous free bytes)	
 26159                              <1> 	;
 26160                              <1> 	; (Modified Registers -> EAX, ECX)
 26161                              <1> 	;
 26162                              <1> 	; PURPOSE: Loading a file at memory for copying or running etc.
 26163                              <1> 	; If this procedure returns with cf is set, ECX contains maximum
 26164                              <1> 	; available space and EAX contains the beginning address of it.
 26165                              <1> 	; If EAX has zero, ECX contains total number of free bytes.
 26166                              <1> 	; If requested block has been successfully allocated (by rounding up to
 26167                              <1> 	; the last page border), it must be deallocated later by using
 26168                              <1> 	; 'deallocate_memory_block' procedure.    
 26169                              <1> 
 26170 00005BBD 52                  <1> 	push	edx ; *
 26171 00005BBE BAFF0F0000          <1> 	mov	edx, PAGE_SIZE - 1   ; 4095
 26172 00005BC3 01D0                <1> 	add	eax, edx
 26173 00005BC5 01D1                <1> 	add	ecx, edx
 26174 00005BC7 C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
 26175                              <1> 
 26176                              <1> 	; ECX = number of contiguous pages to be allocated
 26177 00005BCA 8B15[88770100]      <1> 	mov	edx, [free_pages]
 26178                              <1> 	; 01/05/2017
 26179                              <1> 	;or	ecx, ecx
 26180                              <1> 	;jz	short amb3
 26181                              <1> 	; If ECX=0, set cf to 1 and return with max. available mem block size
 26182                              <1> 
 26183 00005BD0 39D1                <1> 	cmp	ecx, edx
 26184 00005BD2 7760                <1> 	ja	short amb_3
 26185                              <1> 
 26186 00005BD4 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; 12
 26187                              <1> 
 26188 00005BD7 89C2                <1> 	mov	edx, eax 	     ; page number
 26189 00005BD9 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
 26190                              <1> 				     ; (1 allocation bit = 1 page)
 26191                              <1> 				     ; (1 allocation bytes = 8 pages)
 26192 00005BDC 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
 26193                              <1> 				     ; (to get 32 bit position)	
 26194 00005BDF 53                  <1> 	push	ebx ; **
 26195                              <1> amb_0:
 26196 00005BE0 890D[38830100]      <1> 	mov	[mem_ipg_count], ecx ; initial (reset) value of page count
 26197 00005BE6 890D[3C830100]      <1> 	mov	[mem_pg_count], ecx
 26198 00005BEC 31C9                <1> 	xor	ecx, ecx ; 0
 26199 00005BEE 890D[40830100]      <1> 	mov	[mem_aperture], ecx ; 0
 26200 00005BF4 890D[44830100]      <1> 	mov	[mem_max_aperture], ecx ; 0
 26201                              <1> 	
 26202 00005BFA BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address.
 26203 00005BFF 3B15[8C770100]      <1> 	cmp	edx, [next_page]     ; Is the beginning page address lower
 26204                              <1> 				     ; than the address in 'next_page' ?
 26205                              <1> 				     ; (the first/next free page of user space)		
 26206 00005C05 7208                <1> 	jb	short amb_1
 26207 00005C07 3B15[90770100]      <1> 	cmp 	edx, [last_page]     ; is the beginning page address higher
 26208                              <1> 				     ; than the address in 'last_page' ?
 26209                              <1> 				     ; (end of the memory)		
 26210 00005C0D 7606                <1> 	jna	short amb_2	     ; no	
 26211                              <1> amb_1:
 26212 00005C0F 8B15[8C770100]      <1> 	mov	edx, [next_page]     ; M.A.T. offset (1 M.A.T. byte = 8 pages)
 26213                              <1> amb_2:
 26214 00005C15 01D3                <1> 	add	ebx, edx
 26215                              <1> 
 26216                              <1> 	; 28/04/2017
 26217                              <1> 	;xor	ecx, ecx
 26218 00005C17 0FBC0B              <1> 	bsf	ecx, [ebx]	     ; 0 to 31
 26219 00005C1A 89D0                <1> 	mov	eax, edx
 26220 00005C1C C1E003              <1> 	shl	eax, 3		     ; *8	
 26221 00005C1F 01C8                <1> 	add	eax, ecx	     ; beginning page number
 26222                              <1> 
 26223 00005C21 A3[48830100]        <1> 	mov	[mem_pg_pos], eax    ; beginning page no (for curr. mem. aperture)
 26224 00005C26 A3[4C830100]        <1>  	mov	[mem_max_pg_pos], eax ; beginning page no for max. mem. aperture
 26225                              <1> 
 26226 00005C2B 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only (0 to 31)
 26227                              <1> 				     ; (allocation bit position)	 
 26228 00005C2E 750E                <1> 	jnz	short amb_4	     ; 0
 26229 00005C30 B120                <1> 	mov	cl, 32
 26230 00005C32 EB4B                <1> 	jmp	short amb_10
 26231                              <1> 
 26232                              <1> amb_3:	; out_of_memory
 26233 00005C34 31C0                <1> 	xor	eax, eax ; 0
 26234 00005C36 89D1                <1> 	mov	ecx, edx ; free pages
 26235 00005C38 C1E10C              <1> 	shl	ecx, PAGE_SHIFT
 26236 00005C3B 5A                  <1> 	pop	edx ; *
 26237 00005C3C F9                  <1> 	stc
 26238 00005C3D C3                  <1> 	retn	
 26239                              <1> amb_4:
 26240 00005C3E 8B13                <1> 	mov	edx, [ebx]
 26241 00005C40 88C1                <1> 	mov	cl, al ; 1 to 31
 26242 00005C42 D3EA                <1> 	shr	edx, cl
 26243 00005C44 89D0                <1> 	mov	eax, edx
 26244                              <1> amb_5:
 26245 00005C46 D1E8                <1> 	shr	eax, 1 ; (***)
 26246 00005C48 7317                <1> 	jnc	short amb_7
 26247 00005C4A FF05[40830100]      <1> 	inc	dword [mem_aperture]
 26248 00005C50 FF0D[3C830100]      <1> 	dec	dword [mem_pg_count]
 26249 00005C56 7470                <1> 	jz	short amb_15
 26250                              <1> amb_6:
 26251                              <1> 	; 28/04/2017
 26252 00005C58 FEC1                <1> 	inc	cl
 26253 00005C5A 80F920              <1> 	cmp	cl, 32
 26254 00005C5D 730D                <1> 	jnb	short amb_9
 26255 00005C5F EBE5                <1> 	jmp	short amb_5
 26256                              <1> amb_7:
 26257 00005C61 50                  <1> 	push	eax ; (***) allocation bits (in shifted status)
 26258 00005C62 E81B010000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
 26259 00005C67 58                  <1> 	pop	eax ; (***)
 26260 00005C68 EBEE                <1> 	jmp	short amb_6
 26261                              <1> amb_8:
 26262                              <1> 	; 28/04/2017
 26263 00005C6A B120                <1> 	mov	cl, 32
 26264                              <1> amb_9:
 26265 00005C6C 89DA                <1> 	mov	edx, ebx
 26266 00005C6E 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL
 26267 00005C74 3B15[90770100]      <1> 	cmp	edx, [last_page]
 26268 00005C7A 7336                <1> 	jnb	short amb_14 ; contiguous pages not enough
 26269 00005C7C 83C304              <1> 	add	ebx, 4
 26270                              <1> amb_10:
 26271 00005C7F 8B03                <1> 	mov	eax, [ebx]
 26272 00005C81 21C0                <1> 	and 	eax, eax
 26273 00005C83 7408                <1>         jz      short amb_11 ; there is not a free page bit in this alloc dword
 26274 00005C85 40                  <1> 	inc	eax ; 0FFFFFFFFh -> 0
 26275 00005C86 740C                <1> 	jz	short amb_12 ; all of bits are set (32 free pages)
 26276 00005C88 48                  <1> 	dec	eax
 26277 00005C89 28C9                <1> 	sub	cl, cl ; 0
 26278 00005C8B EBB9                <1> 	jmp	short amb_5
 26279                              <1> amb_11:
 26280 00005C8D E8F0000000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
 26281 00005C92 EBD8                <1> 	jmp	short amb_9	
 26282                              <1> amb_12:
 26283 00005C94 390D[3C830100]      <1> 	cmp	[mem_pg_count], ecx ; 32
 26284 00005C9A 7306                <1> 	jnb	short amb_13
 26285 00005C9C 8B0D[3C830100]      <1> 	mov	ecx, [mem_pg_count]
 26286                              <1> amb_13:
 26287 00005CA2 010D[40830100]      <1> 	add	[mem_aperture], ecx
 26288 00005CA8 290D[3C830100]      <1> 	sub	[mem_pg_count], ecx
 26289 00005CAE 7618                <1> 	jna	short amb_15
 26290 00005CB0 EBBA                <1> 	jmp	short amb_9 ; 01/05/2017
 26291                              <1> amb_14:
 26292 00005CB2 E8CB000000          <1> 	call	amb_26 ; 28/04/2017
 26293 00005CB7 A1[4C830100]        <1> 	mov	eax, [mem_max_pg_pos] ; begin address of max. mem aperture	
 26294 00005CBC 8B0D[44830100]      <1> 	mov	ecx, [mem_max_aperture] ; max. (largest) memory aperture
 26295 00005CC2 F9                  <1> 	stc
 26296 00005CC3 E9AF000000          <1>         jmp     amb_25
 26297                              <1> 
 26298                              <1> amb_15: ; OK !
 26299 00005CC8 A1[48830100]        <1> 	mov	eax, [mem_pg_pos]    ; Beginning address as page number
 26300 00005CCD 8B0D[40830100]      <1> 	mov	ecx, [mem_aperture]  ; Free contiguous page count (>=1)
 26301                              <1> amb_16:
 26302                              <1> 	; allocate contiguous memory pages (via memory allocation table bits)
 26303 00005CD3 89C2                <1> 	mov	edx, eax
 26304                              <1> 	; 25/04/2017
 26305 00005CD5 C1EA03              <1> 	shr	edx, 3		 ; 8 pages in one allocation byte
 26306 00005CD8 80E2FC              <1> 	and	dl, 0FCh	 ; clear lower 2 bits
 26307                              <1> 				 ; (for dword/32bit positioning)	
 26308                              <1> 
 26309 00005CDB BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
 26310 00005CE0 01D3                <1> 	add	ebx, edx
 26311 00005CE2 83E01F              <1> 	and	eax, 1Fh ; 31
 26312                              <1> 	; 03/04/2016
 26313 00005CE5 BA20000000          <1> 	mov	edx, 32
 26314 00005CEA 28C2                <1> 	sub	dl, al
 26315 00005CEC 39CA                <1> 	cmp	edx, ecx	 ; ecx >= 1
 26316 00005CEE 7602                <1> 	jna	short amb_17
 26317 00005CF0 89CA                <1> 	mov	edx, ecx
 26318                              <1> amb_17:
 26319 00005CF2 29D1                <1> 	sub	ecx, edx
 26320 00005CF4 51                  <1> 	push	ecx ; ***
 26321 00005CF5 89D1                <1> 	mov	ecx, edx
 26322                              <1> amb_18:		
 26323 00005CF7 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
 26324                              <1> 				 ; is copied into the Carry Flag and then cleared
 26325                              <1> 				 ; in the destination.
 26326 00005CFA FF0D[88770100]      <1> 	dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
 26327 00005D00 49                  <1> 	dec	ecx
 26328 00005D01 7404                <1> 	jz	short amb_19
 26329 00005D03 FEC0                <1> 	inc	al
 26330 00005D05 EBF0                <1> 	jmp	short amb_18
 26331                              <1> amb_19:	
 26332 00005D07 59                  <1> 	pop	ecx ; ***
 26333 00005D08 21C9                <1> 	and	ecx, ecx ; 0 ?
 26334 00005D0A 741E                <1> 	jz	short amb_22	
 26335                              <1> 	; 01/04/2016
 26336 00005D0C B020                <1> 	mov	al, 32
 26337                              <1> amb_20:
 26338 00005D0E 83C304              <1> 	add	ebx, 4
 26339 00005D11 39C1                <1> 	cmp	ecx, eax ; 32
 26340 00005D13 7305                <1> 	jnb	short amb_21
 26341                              <1> 	; ECX < 32
 26342 00005D15 28C0                <1> 	sub	al, al ; 0
 26343 00005D17 50                  <1> 	push	eax ; 0 ***
 26344 00005D18 EBDD                <1> 	jmp	short amb_18
 26345                              <1> amb_21:
 26346 00005D1A 2905[88770100]      <1> 	sub	[free_pages], eax   ; [free_pages] = [free_pages] - 32
 26347 00005D20 C70300000000        <1> 	mov	dword [ebx], 0	    ; reset 32 bits
 26348 00005D26 29C1                <1> 	sub	ecx, eax ; 32
 26349 00005D28 75E4                <1> 	jnz	short amb_20
 26350                              <1> amb_22:
 26351 00005D2A A1[48830100]        <1> 	mov	eax, [mem_pg_pos]   ; Beginning address as page number
 26352 00005D2F 8B0D[40830100]      <1> 	mov	ecx, [mem_aperture] ; Free contiguous page count
 26353                              <1> 	; [next_page] update
 26354 00005D35 89C2                <1> 	mov	edx, eax
 26355                              <1> 	; 03/04/2016
 26356 00005D37 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
 26357                              <1> 				     ; (1 allocation bit = 1 page)
 26358                              <1> 				     ; (1 allocation bytes = 8 pages)
 26359 00005D3A 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
 26360                              <1> 				     ; (to get 32 bit position)	
 26361 00005D3D 3B15[8C770100]      <1> 	cmp	edx, [next_page] ; first free page pointer offset
 26362 00005D43 7732                <1> 	ja	short amb_25
 26363 00005D45 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
 26364 00005D4A 833C1300            <1> 	cmp	dword [ebx+edx], 0
 26365 00005D4E 7721                <1> 	ja	short amb_24
 26366 00005D50 89C2                <1> 	mov	edx, eax
 26367 00005D52 01CA                <1> 	add	edx, ecx
 26368 00005D54 C1EA03              <1> 	shr	edx, 3
 26369 00005D57 80E2FC              <1> 	and	dl, 0FCh
 26370                              <1> amb_23:
 26371 00005D5A 833C1300            <1> 	cmp	dword [ebx+edx], 0
 26372 00005D5E 7711                <1> 	ja	short amb_24
 26373 00005D60 83C204              <1> 	add	edx, 4
 26374 00005D63 3B15[90770100]      <1> 	cmp	edx, [last_page]    ; last page pointer offset
 26375 00005D69 76EF                <1> 	jna	short amb_23
 26376 00005D6B 8B15[94770100]      <1> 	mov	edx, [first_page]   ; (for) beginning of user's space
 26377                              <1> amb_24:
 26378 00005D71 8915[8C770100]      <1> 	mov	[next_page], edx
 26379                              <1> amb_25:
 26380 00005D77 9C                  <1> 	pushf
 26381 00005D78 C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
 26382 00005D7B C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
 26383 00005D7E 9D                  <1> 	popf
 26384 00005D7F 5B                  <1> 	pop	ebx ; **
 26385 00005D80 5A                  <1> 	pop	edx ; *
 26386 00005D81 C3                  <1> 	retn
 26387                              <1> 
 26388                              <1> amb_26:	; set maximum free memory aperture (free memory block size) 
 26389 00005D82 89DA                <1> 	mov	edx, ebx ; current address
 26390 00005D84 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL ; MAT beginning address
 26391                              <1> 	; 02/04/2016 
 26392 00005D8A C1E203              <1> 	shl	edx, 3 ; MAT byte offset * 8 = page number base
 26393 00005D8D 01CA                <1> 	add	edx, ecx ; current page number (ecx = 0 to 32)
 26394                              <1> 	;
 26395 00005D8F A1[40830100]        <1> 	mov	eax, [mem_aperture]
 26396 00005D94 21C0                <1> 	and	eax, eax
 26397 00005D96 7421                <1>         jz      short amb_27
 26398 00005D98 C705[40830100]0000- <1>         mov     dword [mem_aperture], 0
 26399 00005DA0 0000                <1>
 26400 00005DA2 3B05[44830100]      <1> 	cmp	eax, [mem_max_aperture]
 26401 00005DA8 760F                <1> 	jna	short amb_27
 26402 00005DAA A3[44830100]        <1> 	mov	[mem_max_aperture], eax
 26403                              <1> 	; 25/04/2017
 26404 00005DAF A1[48830100]        <1> 	mov	eax, [mem_pg_pos]
 26405                              <1> 	; EAX = Beginning page number of the max. aperture 
 26406 00005DB4 A3[4C830100]        <1> 	mov	[mem_max_pg_pos], eax
 26407                              <1> amb_27: 
 26408 00005DB9 8915[48830100]      <1> 	mov	[mem_pg_pos], edx ; current page
 26409                              <1> 
 26410 00005DBF A1[38830100]        <1> 	mov	eax, [mem_ipg_count] ; initial (reset) value of page count
 26411 00005DC4 A3[3C830100]        <1> 	mov	[mem_pg_count], eax
 26412                              <1> 
 26413 00005DC9 C3                  <1> 	retn
 26414                              <1> 
 26415                              <1> deallocate_memory_block:
 26416                              <1> 	; 03/04/2016
 26417                              <1> 	; 14/03/2016 (TRDOS 386 = TRDOS v2.0)
 26418                              <1> 	; Deallocating contiguous memory pages (in the kernel's memory space)
 26419                              <1> 	;
 26420                              <1> 	; INPUT -> 
 26421                              <1> 	;	EAX = Beginning address (physical)
 26422                              <1> 	;	ECX = Number of bytes to be deallocated
 26423                              <1> 	;
 26424                              <1> 	; OUTPUT ->
 26425                              <1> 	;	Memory Allocation Table bits will be updated
 26426                              <1> 	;	[free_pages] will be changed (increased)
 26427                              <1> 	;
 26428                              <1> 	; (Modified Registers -> EAX, ECX)
 26429                              <1> 	;
 26430                              <1> 	; PURPOSE: Unloading/Freeing a file -or an allocated memory block- 
 26431                              <1> 	; at memory after copying, running, saving, reading, writing etc.
 26432                              <1> 	;
 26433                              <1> 
 26434 00005DCA 52                  <1> 	push	edx ; *
 26435 00005DCB 53                  <1> 	push	ebx ; **
 26436                              <1> 
 26437 00005DCC C1E80C              <1> 	shr	eax, PAGE_SHIFT	     ; 12
 26438 00005DCF C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
 26439                              <1> 
 26440                              <1> 	; EAX = Beginning page number
 26441                              <1> 	; ECX = Number of contiguous pages to be deallocated
 26442                              <1> damb_0:
 26443                              <1> 	; deallocate contiguous memory pages (via memory allocation table bits)
 26444 00005DD2 89C2                <1> 	mov	edx, eax
 26445 00005DD4 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
 26446                              <1> 				     ; (1 allocation bit = 1 page)
 26447                              <1> 				     ; (1 allocation bytes = 8 pages)
 26448 00005DD7 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
 26449                              <1> 				     ; (to get 32 bit position)	
 26450 00005DDA 3B15[8C770100]      <1> 	cmp	edx, [next_page] ; next free page
 26451 00005DE0 7306                <1> 	jnb	short damb_1
 26452 00005DE2 8915[8C770100]      <1> 	mov	[next_page], edx
 26453                              <1> damb_1:
 26454 00005DE8 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
 26455 00005DED 01D3                <1> 	add	ebx, edx
 26456 00005DEF 83E01F              <1> 	and	eax, 1Fh ; 31
 26457                              <1> 
 26458                              <1> 	; 03/04/2016
 26459 00005DF2 BA20000000          <1> 	mov	edx, 32
 26460 00005DF7 28C2                <1> 	sub	dl, al
 26461 00005DF9 39CA                <1> 	cmp	edx, ecx
 26462 00005DFB 7602                <1> 	jna	short damb_2
 26463 00005DFD 89CA                <1> 	mov	edx, ecx
 26464                              <1> damb_2:
 26465 00005DFF 29D1                <1> 	sub	ecx, edx
 26466 00005E01 51                  <1> 	push	ecx ; ***
 26467 00005E02 89D1                <1> 	mov	ecx, edx
 26468                              <1> damb_3:		
 26469 00005E04 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
 26470                              <1> 				     ; set relevant bit to 1.
 26471                              <1> 				     ; set CF to the previous bit value	
 26472 00005E07 FF05[88770100]      <1> 	inc     dword [free_pages]   ; 1 page has been deallocated (X = X+1) 
 26473 00005E0D 49                  <1> 	dec	ecx
 26474 00005E0E 7404                <1> 	jz	short damb_4
 26475 00005E10 FEC0                <1> 	inc	al
 26476 00005E12 EBF0                <1> 	jmp	short damb_3
 26477                              <1> damb_4:	
 26478 00005E14 59                  <1> 	pop	ecx ; ***
 26479 00005E15 21C9                <1> 	and	ecx, ecx ; 0 ?
 26480 00005E17 741E                <1> 	jz	short damb_7
 26481                              <1> 	; 03/04/2016
 26482 00005E19 B020                <1> 	mov	al, 32
 26483                              <1> damb_5:
 26484 00005E1B 83C304              <1> 	add	ebx, 4
 26485 00005E1E 39C1                <1> 	cmp	ecx, eax ; 32
 26486 00005E20 7305                <1> 	jnb	short damb_6
 26487                              <1> 	; ECX < 32
 26488 00005E22 28C0                <1> 	sub	al, al ; 0
 26489 00005E24 50                  <1> 	push	eax ; 0 ***
 26490 00005E25 EBDD                <1> 	jmp	short damb_3
 26491                              <1> damb_6:
 26492 00005E27 0105[88770100]      <1> 	add	[free_pages], eax ; [free_pages] = [free_pages] + 32
 26493 00005E2D C703FFFFFFFF        <1> 	mov	dword [ebx], 0FFFFFFFFh ; set 32 bits
 26494 00005E33 29C1                <1> 	sub	ecx, eax ; 32
 26495 00005E35 75E4                <1> 	jnz	short damb_5
 26496                              <1> damb_7:
 26497 00005E37 5B                  <1> 	pop	ebx ; **
 26498 00005E38 5A                  <1> 	pop	edx ; *
 26499 00005E39 C3                  <1> 	retn
 26500                              <1> 
 26501                              <1> direct_memory_access:
 26502                              <1> 	; 17/04/2021 (temporary modifications)
 26503                              <1> 	; 22/07/2017
 26504                              <1> 	; 12/05/2017
 26505                              <1> 	; 16/07/2016
 26506                              <1> 	; 12/07/2016 (TRDOS 386 = TRDOS v2.0)
 26507                              <1> 	; This processure will be called to map
 26508                              <1> 	; user's (ring 3) page tables to access phsical
 26509                              <1> 	; (flat/linear) memory addresses, directly (without
 26510                              <1> 	;  kernel's data transfer functions).
 26511                              <1> 	; 
 26512                              <1> 	; Purpose: Video memory access and shared memory access.
 26513                              <1> 	;
 26514                              <1> 	; INPUT -> 
 26515                              <1> 	;	EAX = Beginning address (physical).
 26516                              <1> 	;	EBX = User's buffer address ; 12/05/2017
 26517                              <1> 	;	ECX = Number of contiguous pages to be mapped.
 26518                              <1> 	; OUTPUT ->
 26519                              <1> 	;	User's page directory and pages tables
 26520                              <1> 	;	will be updated.
 26521                              <1> 	;	
 26522                              <1> 	;	If an old page table entry has valid page address, 
 26523                              <1> 	;	that page will be deallocated just before PTE will
 26524                              <1> 	;	be changed for direct (1 to 1) memory page access.
 26525                              <1> 	;
 26526                              <1> 	;	If old PTE value points to a swapped page,
 26527                              <1>         ;       that page (block) will be unlinked on swap disk. 
 26528                              <1> 	;
 26529                              <1> 	;	Newly allocated pages (except page tables) will not
 26530                              <1> 	;	be applied to Memory Allocation Table.
 26531                              <1> 	;	AVL bit 1 (PTE bit 10) of page table entry will be
 26532                              <1> 	;	used to indicate shared (direct) memory page; then,
 26533                              <1> 	;	this page will not be deallocated later during
 26534                              <1> 	;	process termination. (Memory Allocation Table and
 26535                              <1> 	;	free memory count will not be affected.
 26536                              <1> 	;	(Except deallocating page table's itself.)
 26537                              <1> 	;	
 26538                              <1> 	;      CF = 1 -> error (EAX = error code)
 26539                              <1> 	;      CF = 0 -> success (EAX = beginning address)
 26540                              <1> 	;
 26541                              <1> 	;; (Modified Registers -> none)
 26542                              <1> 	; Modified registers: ebp, edx, ecx, ebx, esi, edi	
 26543                              <1> 	;
 26544                              <1> 
 26545                              <1> 	;push	ebp
 26546                              <1> 	;push	ebx
 26547                              <1> 	;push	ecx
 26548                              <1> 	;push	edx
 26549 00005E3A 662500F0            <1> 	and	ax, PTE_A_CLEAR ; clear page offset
 26550 00005E3E 50                  <1> 	push	eax
 26551                              <1> 	;and	ecx, ecx ; page count
 26552                              <1> 	;jz	dmem_acc_7  ; 'insufficient memory' error
 26553 00005E3F 89C5                <1> 	mov	ebp, eax
 26554 00005E41 81C300004000        <1> 	add	ebx, CORE ; 12/05/2017
 26555                              <1> dmem_acc_0: 
 26556 00005E47 891D[E48D0100]      <1> 	mov	[base_addr], ebx ; 12/05/2017
 26557 00005E4D A1[74010300]        <1> 	mov	eax, [u.pgdir] ; page dir address (physical)
 26558 00005E52 E856F9FFFF          <1> 	call	get_pte
 26559                              <1> 		; EDX = Page table entry address (if CF=0)
 26560                              <1> 	        ;       Page directory entry address (if CF=1)
 26561                              <1> 		;       (Bit 0 value is 0 if PT is not present)
 26562                              <1> 		; EAX = Page table entry value (page address)
 26563                              <1> 		;	CF = 1 -> PDE not present or invalid ? 	
 26564 00005E57 7321                <1> 	jnc	short dmem_acc_1
 26565                              <1> 	;
 26566 00005E59 E83DF8FFFF          <1> 	call	allocate_page
 26567                              <1> 	;jc	dmem_acc_7  ; 'insufficient memory' error
 26568                              <1> 	; 17/04/2021
 26569 00005E5E 7215                <1> 	jc	short _dmem_acc_7
 26570                              <1> 	;
 26571 00005E60 E8A7F8FFFF          <1> 	call 	clear_page
 26572                              <1> 	; EAX = Physical (base) address of the allocated (new) page
 26573 00005E65 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
 26574                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
 26575                              <1> 			   ; (user, writable, present page)	
 26576 00005E67 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
 26577 00005E69 A1[74010300]        <1> 	mov	eax, [u.pgdir]	
 26578 00005E6E E83AF9FFFF          <1> 	call	get_pte
 26579                              <1>         ;jc	dmem_acc_7 ; 'insufficient memory' error
 26580                              <1> 	; 17/04/2021
 26581 00005E73 7305                <1> 	jnc	short dmem_acc_1
 26582                              <1> _dmem_acc_7:
 26583 00005E75 E985000000          <1> 	jmp	dmem_acc_7
 26584                              <1> dmem_acc_1:
 26585                              <1> 	; EAX = PTE value, EDX = PTE address
 26586 00005E7A A801                <1> 	test 	al, PTE_A_PRESENT
 26587                              <1> 	;jnz	short dmem_acc_2   ; 17/04/2021 (*)
 26588                              <1> 	; 17/04/2021 (temporary)
 26589 00005E7C 745F                <1> 	jz	short short dmem_acc_6  ; ! temporary ! (*)	
 26590                              <1> 
 26591                              <1> ; 17/04/2021
 26592                              <1> ; (following code is disabled as temporary)
 26593                              <1> ;
 26594                              <1> ;	or	eax, eax
 26595                              <1> ;	jz	short dmem_acc_6   ; Change PTE
 26596                              <1> ;	shr	eax, 1		; swap disk block (8 sectors) address
 26597                              <1> ;	; unlink swap disk block
 26598                              <1> ;	call	unlink_swap_block
 26599                              <1> ;	jmp	short dmem_acc_6
 26600                              <1> 
 26601                              <1> dmem_acc_2:
 26602 00005E7E A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
 26603                              <1> 				  ; (must be 1)
 26604 00005E80 7550                <1> 	jnz	short dmem_acc_4
 26605                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
 26606 00005E82 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
 26607                              <1> 				   ; as child's page ?
 26608 00005E86 7455                <1> 	jz	short dmem_acc_5 ; Change PTE but don't deallocate the page!
 26609                              <1> 
 26610                              <1> 	;push	edi
 26611                              <1> 	;push	esi
 26612                              <1> 
 26613 00005E88 51                  <1> 	push	ecx
 26614                              <1> 	;push	ebx
 26615 00005E89 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; parent's page dir address (physical)
 26616                              <1> 	
 26617                              <1> 	; check the parent's PTE value is read only & same page or not.. 
 26618 00005E8F 89EF                <1> 	mov	edi, ebp
 26619 00005E91 C1EF16              <1> 	shr	edi, PAGE_D_SHIFT ; 22
 26620                              <1> 	; EDI = page directory entry index (0-1023)
 26621 00005E94 89EE                <1> 	mov	esi, ebp
 26622 00005E96 C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; 12	
 26623 00005E99 81E6FF030000        <1> 	and	esi, PTE_MASK
 26624                              <1> 	; ESI = page table entry index (0-1023)
 26625                              <1> 
 26626 00005E9F 66C1E702            <1> 	shl	di, 2 ; * 4
 26627 00005EA3 01FB                <1> 	add	ebx, edi ; PDE offset (for the parent)
 26628 00005EA5 8B0F                <1> 	mov	ecx, [edi]
 26629 00005EA7 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
 26630 00005EAA 7425                <1> 	jz	short dmem_acc_3	; parent process does not use this page
 26631 00005EAC 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
 26632 00005EB1 66C1E602            <1> 	shl	si, 2 ; *4 
 26633 00005EB5 01CE                <1> 	add	esi, ecx ; PTE offset (for the parent)
 26634 00005EB7 8B1E                <1> 	mov	ebx, [esi]
 26635 00005EB9 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
 26636 00005EBC 7413                <1> 	jz	short dmem_acc_3	; parent process does not use this page
 26637 00005EBE 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
 26638 00005EC2 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
 26639 00005EC7 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
 26640 00005EC9 7506                <1> 	jne	short dmem_acc_3	; not same page
 26641                              <1> 				; deallocate the child's page
 26642 00005ECB 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
 26643                              <1> 	;pop	ebx
 26644 00005ECE 59                  <1> 	pop	ecx
 26645 00005ECF EB0C                <1> 	jmp	short dmem_acc_5
 26646                              <1> dmem_acc_3:
 26647                              <1> 	;pop	ebx
 26648 00005ED1 59                  <1> 	pop	ecx
 26649                              <1> dmem_acc_4:	
 26650 00005ED2 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
 26651 00005ED6 7505                <1> 	jnz	short dmem_acc_5   ; AVL bit 1 = 1, do not deallocate this page!
 26652                              <1> 	;
 26653                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 26654 00005ED8 E886F9FFFF          <1> 	call	deallocate_page
 26655                              <1> dmem_acc_5:
 26656                              <1> 	;pop	esi
 26657                              <1> 	;pop	edi
 26658                              <1> dmem_acc_6:
 26659 00005EDD 89E8                <1> 	mov	eax, ebp ; physical page (offset=0) address
 26660                              <1> 	; EAX = memory page address
 26661                              <1> 	; EDX = PTE entry address (physical)
 26662 00005EDF 660D0704            <1> 	or	ax, PTE_A_PRESENT+PTE_A_USER+PTE_A_WRITE+PTE_SHARED
 26663                              <1> 			; present flag, bit 0 = 1
 26664                              <1> 			; user flag, bit 2 = 1	
 26665                              <1> 			; writable flag, bit 1 = 1
 26666                              <1> 			; direct memory access flag, bit 10 = 1
 26667                              <1> 			; (This page must not be deallocated!)
 26668 00005EE3 8902                <1> 	mov	[edx], eax  ; Update PTE value
 26669 00005EE5 49                  <1> 	dec	ecx ; remain count of contiguous pages
 26670 00005EE6 741E                <1> 	jz	short dmem_acc_8
 26671 00005EE8 81C500100000        <1> 	add	ebp, PAGE_SIZE ; next physical page address
 26672                              <1> 	; 22/07/2017
 26673                              <1> 	;mov	eax, ebp
 26674                              <1> 	; 12/05/2017
 26675 00005EEE 8B1D[E48D0100]      <1> 	mov	ebx, [base_addr] ; linear address (virtual+CORE)
 26676 00005EF4 81C300100000        <1> 	add	ebx, PAGE_SIZE	; next linear address
 26677 00005EFA E948FFFFFF          <1>         jmp     dmem_acc_0
 26678                              <1> dmem_acc_7:  ; ERROR ! 
 26679 00005EFF C7042404000000      <1> 	mov	dword [esp], ERR_MINOR_IM 
 26680                              <1> 		; Insufficient memory (minor) error!
 26681                              <1> 		; Major error = 0 (No protection fault)	
 26682                              <1> 	; cf = 1
 26683                              <1> dmem_acc_8:
 26684 00005F06 58                  <1> 	pop	eax
 26685                              <1> 	;pop	edx
 26686                              <1> 	;pop	ecx
 26687                              <1> 	;pop	ebx
 26688                              <1> 	;pop	ebp
 26689 00005F07 C3                  <1> 	retn
 26690                              <1> 
 26691                              <1> deallocate_user_pages:
 26692                              <1> 	; 20/05/2017
 26693                              <1> 	; 15/05/2017
 26694                              <1> 	; 20/02/2017
 26695                              <1> 	; 19/02/2017 (TRDOS 386 = TRDOS v2.0)
 26696                              <1> 	;
 26697                              <1> 	; Deallocate virtually contiguous user pages (memory block)
 26698                              <1> 	; (caller: 'sysdalloc' system call)
 26699                              <1> 	;
 26700                              <1> 	; INPUT ->
 26701                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
 26702                              <1> 	;	ECX = byte count
 26703                              <1> 	;	[u.pgdir] = user's page directory
 26704                              <1> 	;	[u.ppdir] = parent's page directory
 26705                              <1> 	;
 26706                              <1> 	; OUTPUT ->
 26707                              <1> 	;    If CF = 0 	
 26708                              <1> 	;	EAX = Deallocated memory bytes
 26709                              <1> 	;	  (Even if shared or read only pages will not be
 26710                              <1> 	;	   deallocated on M.A.T., this byte count will be
 26711                              <1> 	;	   returned as virtually deallocated bytes; in fact
 26712                              <1> 	;	   virtually deallocated user pages * 4096.) 
 26713                              <1> 	;	EBX = Virtual address (as rounded up)
 26714                              <1> 	;    If CF = 1    	
 26715                              <1> 	;	EAX = 0 (there is not any deallocated pages)
 26716                              <1> 	;
 26717                              <1> 	; Note: Empty page tables will not be deallocated!!!
 26718                              <1> 	;     (they will be deallocated at process termination stage)
 26719                              <1> 	;
 26720                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
 26721                              <1> 	;
 26722 00005F08 89DE                <1> 	mov	esi, ebx
 26723 00005F0A 89F7                <1> 	mov	edi, esi
 26724 00005F0C 01CF                <1> 	add	edi, ecx
 26725 00005F0E 81C6FF0F0000        <1> 	add	esi, PAGE_SIZE - 1  ; 4095 (round up)	
 26726 00005F14 C1EE0C              <1> 	shr	esi, PAGE_SHIFT
 26727 00005F17 C1EF0C              <1> 	shr	edi, PAGE_SHIFT
 26728 00005F1A 89F8                <1> 	mov	eax, edi ; end page
 26729 00005F1C 29F0                <1> 	sub	eax, esi ; end page - start page
 26730 00005F1E 0F86C8000000        <1> 	jna	da_u_pd_err  ; < 1
 26731 00005F24 89F3                <1> 	mov	ebx, esi
 26732 00005F26 C1E30C              <1> 	shl	ebx, PAGE_SHIFT ; virtual address (as rounded up)
 26733 00005F29 53                  <1> 	push	ebx ; *
 26734 00005F2A 89C1                <1> 	mov	ecx, eax ; page count
 26735 00005F2C C1E00C              <1> 	shl	eax, PAGE_SHIFT ; byte count as adjusted
 26736 00005F2F 50                  <1> 	push	eax ; **
 26737 00005F30 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
 26738 00005F36 81C600040000        <1>  	add	esi, CORE/PAGE_SIZE 
 26739 00005F3C 89F7                <1> 	mov	edi, esi
 26740 00005F3E 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry in the page table
 26741 00005F44 57                  <1> 	push	edi ; *** ; PTE index (of page directory)
 26742 00005F45 C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
 26743 00005F48 89F2                <1> 	mov	edx, esi 
 26744                              <1> 	; EDX = PDE index
 26745 00005F4A C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
 26746 00005F4D 01DE                <1> 	add	esi, ebx ; add page directory address
 26747                              <1> da_u_pd_1:
 26748 00005F4F AD                  <1> 	lodsd
 26749                              <1> 	;
 26750 00005F50 89F5                <1> 	mov	ebp, esi ; 20/02/2017
 26751                              <1> 	; EBP = next PDE address
 26752                              <1> 	;
 26753 00005F52 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
 26754 00005F54 0F8487000000        <1> 	jz	da_u_pd_3 ; 20/05/2017	
 26755 00005F5A 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 26756                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
 26757 00005F5E 8B3C24              <1> 	mov	edi, [esp] ; ***
 26758                              <1> 	; EDI = PTE index (of complete page directory)
 26759                              <1> 	;and	edi, PTE_MASK ; PTE entry in the page table
 26760 00005F61 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
 26761 00005F64 89FE                <1> 	mov	esi, edi ; PTE offset in page table (0-4092)
 26762 00005F66 01C6                <1> 	add	esi, eax ; now, esi points to requested PTE
 26763                              <1> da_u_pt_0:
 26764 00005F68 AD                  <1> 	lodsd
 26765 00005F69 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
 26766 00005F6B 7452                <1> 	jz	short da_u_pt_1
 26767                              <1> 	;
 26768 00005F6D A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
 26769                              <1> 				  ; (must be 1)
 26770 00005F6F 753C                <1> 	jnz	short da_u_pt_3
 26771                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
 26772 00005F71 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
 26773                              <1> 				   ; as child's page ?
 26774 00005F75 7441                <1> 	jz	short da_u_pt_4 ; Clear PTE but don't deallocate the page!
 26775                              <1> 	;
 26776                              <1> 	; check the parent's PTE value is read only & same page or not.. 
 26777                              <1> 	; EDX = page directory entry index (0-1023)
 26778 00005F77 52                  <1> 	push	edx ; ****
 26779                              <1> 	; EDI = page table entry offset (0-4092)
 26780 00005F78 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 26781 00005F7E 66C1E202            <1> 	shl	dx, 2 ; *4 
 26782 00005F82 01D3                <1> 	add	ebx, edx ; PDE address (for the parent)
 26783 00005F84 8B13                <1> 	mov	edx, [ebx] ; page table address
 26784 00005F86 F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
 26785 00005F89 7421                <1> 	jz	short da_u_pt_2	; parent process does not use this page
 26786 00005F8B 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
 26787                              <1> 	; EDI = page table entry offset (0-4092)
 26788 00005F90 01D7                <1> 	add	edi, edx	; PTE address (for the parent)
 26789 00005F92 8B1F                <1> 	mov	ebx, [edi]
 26790 00005F94 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
 26791 00005F97 7413                <1> 	jz	short da_u_pt_2	; parent process does not use this page
 26792 00005F99 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
 26793 00005F9D 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
 26794 00005FA2 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
 26795 00005FA4 7506                <1> 	jne	short da_u_pt_2	; not same page
 26796                              <1> 				; deallocate the child's page
 26797 00005FA6 800F02              <1>         or      byte [edi], PTE_A_WRITE ; convert to writable page (parent)
 26798 00005FA9 5A                  <1> 	pop	edx ; ****
 26799 00005FAA EB0C                <1> 	jmp	short da_u_pt_4
 26800                              <1> 
 26801                              <1> ; 17/04/2021
 26802                              <1> ; ('da_u_pt_1' is disabled as temporary)
 26803                              <1> 
 26804                              <1> ;da_u_pt_1:
 26805                              <1> ;	or	eax, eax	; swapped page ?
 26806                              <1> ;	jz	short da_u_pt_5	; no
 26807                              <1> ;				; yes
 26808                              <1> ;	shr	eax, 1
 26809                              <1> ;	call	unlink_swap_block ; Deallocate swapped page block
 26810                              <1> ;				  ; on the swap disk (or in file)
 26811                              <1> ;	jmp	short da_u_pt_5
 26812                              <1> da_u_pt_2:
 26813 00005FAC 5A                  <1> 	pop	edx ; ****
 26814                              <1> da_u_pt_3:
 26815 00005FAD 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
 26816 00005FB1 7505                <1> 	jnz	short da_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
 26817                              <1> 	;
 26818                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 26819 00005FB3 E8ABF8FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
 26820                              <1> da_u_pt_4:
 26821 00005FB8 C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
 26822                              <1> ; 17/04/2021 (temporary)
 26823                              <1> da_u_pt_1:
 26824                              <1> da_u_pt_5:
 26825                              <1> 	; 20/05/2017
 26826 00005FBF 58                  <1> 	pop	eax ; *** PTE index (of page directory)
 26827 00005FC0 49                  <1> 	dec	ecx ; remain page count
 26828 00005FC1 7426                <1> 	jz	short da_u_pd_4
 26829 00005FC3 40                  <1> 	inc	eax ; next PTE
 26830 00005FC4 6625FF03            <1> 	and	ax, PTE_MASK ; PTE entry index in the page table
 26831 00005FC8 50                  <1> 	push	eax ; *** (save again)
 26832                              <1> 	;mov	edi, eax
 26833                              <1> 	;and 	di, PTE_MASK
 26834                              <1> 	;cmp	edi, PAGE_SIZE / 4 ; 1024
 26835                              <1> 	;jnb	short da_u_pd_2
 26836 00005FC9 89C7                <1> 	mov	edi, eax
 26837 00005FCB C1E702              <1> 	shl	edi, 2 ; convert index to dword offset
 26838                              <1> 	;test	ax, PTE_MASK ; 3FFh
 26839 00005FCE 09C0                <1> 	or	eax, eax
 26840 00005FD0 7596                <1> 	jnz	short da_u_pt_0 ; 1-1023
 26841                              <1> da_u_pd_2:
 26842 00005FD2 42                  <1> 	inc	edx
 26843                              <1> 	; 20/05/2017
 26844 00005FD3 6681E2FF03          <1> 	and	dx, PTE_MASK  ; 3FFh
 26845 00005FD8 740F                <1> 	jz	short da_u_pd_4  ; 0 (1024)
 26846                              <1> 	;cmp	edx, 1024
 26847                              <1> 	;jnb	short da_u_pd_4
 26848 00005FDA 89EE                <1> 	mov	esi, ebp ; 20/02/2017
 26849 00005FDC E96EFFFFFF          <1> 	jmp	da_u_pd_1
 26850                              <1> da_u_pd_3:
 26851                              <1> 	; 15/05/2017 (empty page directory entry)
 26852 00005FE1 81E900040000        <1> 	sub	ecx, 1024
 26853 00005FE7 77E9                <1> 	ja	short da_u_pd_2 ; 20/05/2017
 26854                              <1> da_u_pd_4:
 26855 00005FE9 58                  <1> 	pop	eax ; **
 26856 00005FEA 5B                  <1> 	pop	ebx ; *
 26857 00005FEB C3                  <1> 	retn
 26858                              <1> 
 26859                              <1> da_u_pd_err:
 26860 00005FEC 31C0                <1> 	xor	eax, eax
 26861 00005FEE F9                  <1> 	stc	
 26862 00005FEF C3                  <1> 	retn
 26863                              <1> 
 26864                              <1> allocate_user_pages:
 26865                              <1> 	; 20/05/2017
 26866                              <1> 	; 01/05/2017, 02/05/2017, 15/05/2017
 26867                              <1> 	; 04/03/2017
 26868                              <1> 	; 20/02/2017 (TRDOS 386 = TRDOS v2.0)
 26869                              <1> 	;
 26870                              <1> 	; Allocate physically contiguous user pages (memory block)
 26871                              <1> 	; (caller: 'sysalloc' system call)
 26872                              <1> 	;
 26873                              <1> 	; Note: This procedure does not alloc a page's itself
 26874                              <1> 	;	(page bit) on Memory Allocation Table.
 26875                              <1> 	;	(allocate_memory_block is needed before this proc)
 26876                              <1> 	;
 26877                              <1> 	; INPUT ->
 26878                              <1> 	;	EAX = PHYSICAL ADDRESS (beginning address)
 26879                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
 26880                              <1> 	;	ECX = byte count (>=4096)
 26881                              <1> 	;	[u.pgdir] = user's page directory
 26882                              <1> 	;	
 26883                              <1> 	;	Note: All addresses are (must be) already adjusted
 26884                              <1> 	;	to page	borders, otherwise, lower 12bits of addresses
 26885                              <1> 	;	and byte count would be truncated.
 26886                              <1> 	;
 26887                              <1> 	; OUTPUT ->
 26888                              <1> 	;	none
 26889                              <1> 	;
 26890                              <1> 	;	CF = 1 -> insufficient memory error
 26891                              <1> 	;
 26892                              <1> 	; Note: All pages will be allocated in physical page order 
 26893                              <1> 	;	from the beginning page address. 
 26894                              <1> 	;	* A new page table will be added to the page dir
 26895                              <1> 	;	  when the requested PDE is invalid.
 26896                              <1> 	;	* Those pages will not be added to swap queue
 26897                              <1> 	;	  because main purpose of this allocation is to
 26898                              <1> 	;	  set a direct memory access (DMA controller) buffer.
 26899                              <1> 	;	 (Swapping out a page in a DMA buffer would be wrong!)
 26900                              <1> 	;	* Previous content of page tables (PTEs) would be
 26901                              <1> 	;	  (should be) deallocated before entering this
 26902                              <1> 	;	  procedure. So, new page table entries (PTEs)
 26903                              <1> 	;	  directly will be written without checking
 26904                              <1> 	;	  their previous content.	
 26905                              <1> 	;	* Only solution to increase free memory by removing
 26906                              <1> 	;	  that non-swappable memory block is to terminate
 26907                              <1> 	;	  the process or to wait until the process will 
 26908                              <1> 	;	  deallocate that memory block as itself. ('sysdalloc')
 26909                              <1> 	;	  (No problem, if the process does not grab all of
 26910                              <1> 	;	  -very big amount of- free memory by using
 26911                              <1> 	;	  'sysalloc' system call!?)
 26912                              <1> 	;	  (Even if the process has grabbed all of free memory, 
 26913                              <1> 	;	  no problem if the process is not running in 
 26914                              <1> 	;	  multitasking mode. No problem in multitasking
 26915                              <1> 	;	  mode if there is not another process which is running
 26916                              <1> 	;	  or waiting or sleeping for an event as it's pages
 26917                              <1> 	;	  are swapped-out. But a new process can not start to
 26918                              <1> 	;	  run if all of free memory has beeen allocated 
 26919                              <1> 	;	  by running processes. Deallocation -'sysdalloc'- 
 26920                              <1> 	;	  or terminate a running process is needed 
 26921                              <1> 	;	  in order to run a new process.) 
 26922                              <1> 	;
 26923                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
 26924                              <1> 	;
 26925                              <1> 
 26926                              <1> 	; 01/05/2017
 26927 00005FF0 662500F0            <1> 	and	ax, ~PAGE_OFF
 26928 00005FF4 6681E300F0          <1> 	and	bx, ~PAGE_OFF
 26929                              <1> 	; 02/05/2017 
 26930 00005FF9 BD00F0FFFF          <1> 	mov	ebp, 0FFFFF000h ; 4 Giga Bytes - 4096 Bytes (for Stack)
 26931 00005FFE C1E90C              <1> 	shr	ecx, PAGE_SHIFT ; page count
 26932 00006001 83F901              <1> 	cmp	ecx, 1
 26933 00006004 7251                <1> 	jb	short a_u_im_retn
 26934 00006006 89C2                <1> 	mov	edx, eax
 26935 00006008 01CA                <1> 	add	edx, ecx
 26936 0000600A 724B                <1> 	jc	short a_u_im_retn
 26937 0000600C 39D5                <1> 	cmp	ebp, edx
 26938 0000600E 7247                <1> 	jb	short a_u_im_retn
 26939 00006010 89DA                <1> 	mov	edx, ebx
 26940 00006012 81C200004000        <1> 	add	edx, CORE
 26941 00006018 723D                <1> 	jc	short a_u_im_retn	
 26942 0000601A 01CA                <1> 	add	edx, ecx
 26943 0000601C 7239                <1> 	jc	short a_u_im_retn
 26944 0000601E 39D5                <1> 	cmp	ebp, edx
 26945 00006020 7235                <1> 	jb	short a_u_im_retn
 26946                              <1> 	;
 26947 00006022 89C5                <1> 	mov	ebp, eax ; physical address
 26948 00006024 89DE                <1> 	mov	esi, ebx
 26949 00006026 81C600004000        <1> 	add	esi, CORE ; start of user's memory (4M) 
 26950 0000602C C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; higher 20 bits of the linear address
 26951                              <1> 	;shr	ecx, PAGE_SHIFT ; page count
 26952 0000602F 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
 26953 00006035 89F7                <1> 	mov	edi, esi
 26954 00006037 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry index in the page table
 26955 0000603D 57                  <1> 	push	edi  ; * ; PTE index (in page directory)
 26956 0000603E C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
 26957 00006041 89F2                <1> 	mov	edx, esi 
 26958                              <1> 	; EDX = PDE index
 26959 00006043 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
 26960 00006046 01DE                <1> 	add	esi, ebx ; add page directory address
 26961                              <1> a_u_pd_0:
 26962 00006048 AD                  <1> 	lodsd
 26963                              <1> 	;
 26964 00006049 89F3                <1> 	mov	ebx, esi ; next PDE address
 26965                              <1> 	;
 26966 0000604B A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
 26967 0000604D 7513                <1> 	jnz	short a_u_pd_2
 26968                              <1> 	;
 26969                              <1> 	; empty PDE (it does not point to valid page table address)
 26970 0000604F E847F6FFFF          <1> 	call	allocate_page  ; (allocate a new page table)
 26971 00006054 7302                <1> 	jnc	short a_u_pd_1 ; OK... now, we have a new page table.
 26972                              <1> 	; cf = 1
 26973                              <1> 	; There is not a free memory page to allocate a new page table !!!
 26974 00006056 5E                  <1> 	pop	esi ; *
 26975                              <1> a_u_im_retn:
 26976 00006057 C3                  <1> 	retn	; return to 'sysalloc' with 'insufficient memory' error
 26977                              <1> 	;
 26978                              <1> a_u_pd_1: ; clear the new page table content 
 26979                              <1> 	; EAX = Physical (base) address of the new page table
 26980 00006058 E8AFF6FFFF          <1> 	call	clear_page ; Clear page content
 26981                              <1> 	;
 26982 0000605D 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
 26983                              <1> 		 ; set bit 0, bit 1 and bit 2 to 1
 26984                              <1> 		 ; (present, writable, user)
 26985 0000605F 8946FC              <1> 	mov	[esi-4], eax
 26986                              <1> a_u_pd_2:
 26987 00006062 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 26988                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
 26989 00006066 8B3C24              <1> 	mov	edi, [esp] ; *
 26990                              <1> 	; EDI = PTE index (of page directory)
 26991                              <1> 	;and	edi, PTE_MASK ; PTE entry index in the page table	
 26992                              <1> 	; EBX = next PDE address
 26993 00006069 89FE                <1> 	mov	esi, edi ; PTE index in page table (0-1023)
 26994 0000606B C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
 26995 0000606E 01C7                <1> 	add	edi, eax ; now, edi points to requested PTE
 26996                              <1> a_u_pt_0:
 26997                              <1> 	; 02/05/2017
 26998 00006070 8B07                <1> 	mov	eax, [edi]
 26999                              <1> 	;
 27000 00006072 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
 27001 00006074 7445                <1> 	jz	short a_u_pt_1
 27002                              <1> 	;
 27003 00006076 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
 27004                              <1> 				  ; (must be 1)
 27005 00006078 7550                <1> 	jnz	short a_u_pt_3
 27006                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
 27007 0000607A 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
 27008                              <1> 				   ; as child's page ?
 27009 0000607E 7455                <1> 	jz	short a_u_pt_4	; Clear PTE but don't deallocate the page!
 27010                              <1> 	;
 27011                              <1> 	; check the parent's PTE value is read only & same page or not.. 
 27012                              <1> 	; EDX = page directory entry index (0-1023)
 27013 00006080 52                  <1> 	push	edx ; **
 27014 00006081 53                  <1> 	push	ebx ; ***
 27015                              <1> 	; ESI = page table entry index (0-1023)
 27016                              <1> 	;push	esi ; **** ; 20/05/2017
 27017 00006082 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 27018 00006088 66C1E202            <1> 	shl	dx, 2 ; *4 
 27019 0000608C 01D3                <1> 	add	ebx, edx ; PTE address,0 (for the parent)
 27020 0000608E 8B13                <1> 	mov	edx, [ebx] ; page table address
 27021 00006090 F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
 27022 00006093 7433                <1> 	jz	short a_u_pt_2	; parent process does not use this page
 27023 00006095 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
 27024 0000609A 66C1E602            <1> 	shl	si, 2 ; *4
 27025                              <1> 	; ESI = page table entry offset (0-4092)
 27026 0000609E 01D6                <1> 	add	esi, edx	; PTE address (for the parent)
 27027 000060A0 8B1E                <1> 	mov	ebx, [esi]
 27028 000060A2 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
 27029 000060A5 7421                <1> 	jz	short a_u_pt_2	; parent process does not use this page
 27030 000060A7 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
 27031 000060AB 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
 27032 000060B0 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
 27033 000060B2 7514                <1> 	jne	short a_u_pt_2	; not same page
 27034                              <1> 				; deallocate the child's page
 27035 000060B4 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
 27036                              <1> 	;pop	esi ; **** ; 20/05/2017
 27037 000060B7 5B                  <1> 	pop	ebx ; ***
 27038 000060B8 5A                  <1> 	pop	edx ; **
 27039 000060B9 EB1A                <1> 	jmp	short a_u_pt_4
 27040                              <1> a_u_pt_1:
 27041 000060BB 09C0                <1> 	or	eax, eax	; swapped page ?
 27042 000060BD 7416                <1> 	jz	short a_u_pt_4	; no
 27043                              <1> 				; yes
 27044 000060BF D1E8                <1> 	shr	eax, 1
 27045 000060C1 E8C2F9FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
 27046                              <1> 				  ; on the swap disk (or in file)
 27047 000060C6 EB0D                <1> 	jmp	short a_u_pt_4
 27048                              <1> a_u_pt_2:
 27049                              <1> 	;pop	esi ; **** ; 20/05/2017
 27050 000060C8 5B                  <1> 	pop	ebx ; ***
 27051 000060C9 5A                  <1> 	pop	edx ; **
 27052                              <1> a_u_pt_3:
 27053 000060CA 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
 27054 000060CE 7505                <1> 	jnz	short a_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
 27055                              <1> 	;
 27056                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
 27057 000060D0 E88EF7FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
 27058                              <1> 	;
 27059                              <1> a_u_pt_4:
 27060 000060D5 89E8                <1> 	mov	eax, ebp ; physical address
 27061 000060D7 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 04/03/2017
 27062 000060D9 AB                  <1> 	stosd
 27063 000060DA 5E                  <1> 	pop	esi ; * ; 20/05/2017
 27064 000060DB 49                  <1> 	dec	ecx ; remain page count
 27065 000060DC 7417                <1> 	jz	short a_u_pd_5
 27066 000060DE 81C500100000        <1> 	add	ebp, PAGE_SIZE
 27067 000060E4 46                  <1> 	inc	esi ; next PTE (index)
 27068                              <1> 	; 20/05/2017
 27069                              <1> 	;cmp	esi, PAGE_SIZE/4 ; 1024
 27070                              <1> 	;jb	short a_u_pt_0
 27071 000060E5 6681E6FF03          <1> 	and	si, PTE_MASK ; 3FFh (0 to 1023)
 27072 000060EA 56                  <1> 	push	esi ; *
 27073 000060EB 7583                <1> 	jnz	short a_u_pt_0 ; > 0 (<1024)
 27074                              <1> a_u_pd_3:
 27075 000060ED 42                  <1> 	inc	edx
 27076                              <1> ;	cmp	edx, 1024
 27077                              <1> ;	jnb	short a_u_pd_4 ; 02/05/2017 (error!, ecx > 0)
 27078 000060EE 89DE                <1> 	mov	esi, ebx ; the next PDE address
 27079 000060F0 E953FFFFFF          <1> 	jmp	a_u_pd_0
 27080                              <1> a_u_pd_4:
 27081                              <1> 	; 02/05/2017
 27082                              <1> ;	stc
 27083                              <1> a_u_pd_5:
 27084                              <1> 	; 20/05/2017
 27085                              <1> 	;pop	edi ; *
 27086 000060F5 C3                  <1> 	retn
 27087                              <1> 
 27088                              <1> allocate_lfb_pages_for_kernel:
 27089                              <1> 	; 15/12/2020
 27090                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
 27091                              <1> 	; Set kernel page tables for linear frame buffer 
 27092                              <1> 	; (this procedure will be called by kernel only)
 27093                              <1> 	;
 27094                              <1> 	; Input:
 27095                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
 27096                              <1>  	;	[LFB_SIZE] = linear frame buffer size in bytes
 27097                              <1> 	; Output:
 27098                              <1> 	;	none
 27099                              <1> 	;	cf = 1 -> error
 27100                              <1> 	;
 27101                              <1> 	; Modified registers: eax, ecx, edx, edi
 27102                              <1> 
 27103 000060F6 8B3D[E00F0300]      <1> 	mov	edi, [LFB_ADDR]
 27104 000060FC 8B15[E40F0300]      <1> 	mov	edx, [LFB_SIZE]
 27105                              <1> 
 27106 00006102 C1EF16              <1> 	shr	edi, 22	; convert address to page number
 27107                              <1> 			; and then convert it to PDE entry offset
 27108                              <1> 			; (1 PDE is for 4MB, 22 bit shift)
 27109                              <1> 
 27110 00006105 66C1E702            <1> 	shl	di, 2	; * 4 for offset 
 27111                              <1> 
 27112                              <1> 	;add	edx, 4095
 27113 00006109 C1EA0C              <1> 	shr	edx, 12	; convert LFB size to LFB page count
 27114                              <1> 	
 27115 0000610C 89D1                <1> 	mov	ecx, edx ; * ; LFB page count
 27116                              <1> 
 27117 0000610E 81C1FF030000        <1> 	add	ecx, 1023 ; page count + 1023
 27118 00006114 C1E90A              <1> 	shr	ecx, 10 ; convert to page directory entry count	
 27119                              <1> 			; (page table count)
 27120 00006117 51                  <1> 	push	ecx ; **
 27121 00006118 C1E10C              <1> 	shl	ecx, 12 ; convert to byte count
 27122                              <1> 
 27123 0000611B 31C0                <1> 	xor	eax, eax ; first available pages
 27124                              <1> 	
 27125                              <1> 	; allocate contiguous memory block for these kernel pages
 27126                              <1> 	
 27127 0000611D E89BFAFFFF          <1> 	call	allocate_memory_block
 27128                              <1> 	; eax = start address of (contiguous) memory block
 27129 00006122 59                  <1> 	pop	ecx ; ** ; PDE count
 27130 00006123 7301                <1> 	jnc	short a_lfb_k_1
 27131                              <1> 	; error (cf=1)
 27132 00006125 C3                  <1> 	retn
 27133                              <1> a_lfb_k_1:
 27134                              <1> 	; Allocate (new) page tables in kernel's page directory
 27135 00006126 51                  <1> 	push	ecx ; PDE (page table) count
 27136 00006127 50                  <1> 	push	eax ; start address of contiguous memory pages
 27137                              <1> 		    ; (at page boundary)	
 27138                              <1> 	; edi = 1st page directory entry offset
 27139 00006128 033D[80770100]      <1> 	add	edi, [k_page_dir] ; Kernel's Page Dir Address
 27140                              <1> a_lfb_k_2:
 27141 0000612E 660D0304            <1> 	or	ax, PDE_A_PRESENT + PDE_A_WRITE + PDE_EXTERNAL
 27142                              <1> 				; supervisor + read&write + present 	
 27143                              <1> 				; + external memory block (LFB)
 27144 00006132 AB                  <1> 	stosd
 27145 00006133 0500100000          <1> 	add	eax, 4096
 27146 00006138 E2F4                <1> 	loop	a_lfb_k_2
 27147                              <1> 	
 27148 0000613A 5F                  <1> 	pop	edi ; start addr of contiguous memory pages
 27149 0000613B 59                  <1> 	pop	ecx ; page table (PDE) count
 27150                              <1> 
 27151                              <1> 	; Allocate pages in (new) kernel page tables
 27152                              <1> 	
 27153                              <1> 	; (Note: page tables are contiguous in pyhsical memory)
 27154 0000613C C1E10A              <1> 	shl	ecx, 10 ; * 1024, convert to (total) PTE count 
 27155                              <1> 	
 27156 0000613F A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR]
 27157                              <1> 	; edx = LFB page count
 27158                              <1> 	;and	ax, ~4095  ; lw of LFB address is 0
 27159                              <1> a_lfb_k_3:	
 27160 00006144 660D0304            <1> 	or	ax, PTE_A_PRESENT + PTE_A_WRITE + PTE_EXTERNAL
 27161                              <1> 				; supervisor + read&write + present 	
 27162                              <1> 				; + external memory block (LFB)
 27163 00006148 AB                  <1> 	stosd
 27164 00006149 4A                  <1> 	dec	edx
 27165 0000614A 7408                <1> 	jz	short a_lfb_k_4 ; LFB size has been completed (!?)
 27166 0000614C 0500100000          <1> 	add	eax, 4096	
 27167 00006151 E2F1                <1> 	loop	a_lfb_k_3
 27168                              <1> 
 27169 00006153 C3                  <1> 	retn
 27170                              <1> 	
 27171                              <1> a_lfb_k_4:
 27172                              <1> 	; clear PTEs for empty/free pages 
 27173                              <1> 	; 	(if there are after LFB !?)
 27174 00006154 31C0                <1> 	xor	eax, eax ; clear page table entry (empty)
 27175 00006156 F3AB                <1> 	rep	stosd
 27176 00006158 C3                  <1> 	retn
 27177                              <1> 
 27178                              <1> ;deallocate_lfb_pages_for_kernel:
 27179                              <1> 	; 15/12/2020
 27180                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
 27181                              <1> 	; Reset/Release kernel page tables
 27182                              <1> 	;	 which are used for linear frame buffer 
 27183                              <1> 	; (this procedure will be called by kernel only)
 27184                              <1> 	;
 27185                              <1> 	; Input:
 27186                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
 27187                              <1>  	;	[FFB_SIZE] = linear frame buffer size in bytes
 27188                              <1> 	; Output:
 27189                              <1> 	;	none
 27190                              <1> 	;
 27191                              <1> 	; Modified registers: eax, ecx, edi
 27192                              <1> 
 27193                              <1> 	;mov	edi, [LFB_ADDR]
 27194                              <1> 	;mov	ecx, [LFB_SIZE]
 27195                              <1> 	;
 27196                              <1> 	;shr	edi, 22	; convert address to page number
 27197                              <1> 	;		; and then convert it to PDE entry offset
 27198                              <1> 	;		; (1 PDE is for 4MB, 22 bit shift)
 27199                              <1> 	;
 27200                              <1> 	;shl	di, 2	; * 4 for offset 
 27201                              <1> 	;
 27202                              <1> 	;;add	ecx, 4095
 27203                              <1> 	;shr	ecx, 12	; convert LFB size to page count  
 27204                              <1> 	;
 27205                              <1> 	;add	ecx, 1023 ; page count + 1023
 27206                              <1> 	;shr	ecx, 10 ; convert to page directory entry count	
 27207                              <1> 	;		; (page table count)
 27208                              <1> 	;push	ecx ; *
 27209                              <1> 	;shl	ecx, 12 ; convert to byte count
 27210                              <1> 	;
 27211                              <1> 	;xor	eax, eax ; first available pages
 27212                              <1> 	;
 27213                              <1> 	;; deallocate contiguous memory block for kernel pages
 27214                              <1> 	;
 27215                              <1> 	;call	deallocate_memory_block
 27216                              <1> 	;
 27217                              <1> 	;pop	ecx ; * ; PDE count
 27218                              <1> 	;
 27219                              <1> 	;; Release/Free PDEs (page tables) in kernel's page dir
 27220                              <1> 	;; edi = 1st page directory entry offset
 27221                              <1> 	;add	edi, [k_page_dir] ; Kernel's Page Dir Address
 27222                              <1> 	;sub	eax, eax ; clear (also invalidate)
 27223                              <1> 	;rep	stosd
 27224                              <1> 	;
 27225                              <1> 	;retn
 27226                              <1> 
 27227                              <1> ; /// End Of MEMORY MANAGEMENT FUNCTIONS ///
 27228                              <1> 
 27229                              <1> ;; Data:
 27230                              <1> 
 27231                              <1> ; 09/03/2015
 27232                              <1> ;swpq_count: dw 0 ; count of pages on the swap que
 27233                              <1> ;swp_drv:    dd 0 ; logical drive description table address of the swap drive/disk
 27234                              <1> ;swpd_size:  dd 0 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
 27235                              <1> ;swpd_free:  dd 0 ; free page blocks (4096 bytes) on swap disk/drive (logical)
 27236                              <1> ;swpd_next:  dd 0 ; next free page block
 27237                              <1> ;swpd_last:  dd 0 ; last swap page block
 27238                                  %include 'timer.s'   ; 17/01/2015
 27239                              <1> ; ****************************************************************************
 27240                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - timer.s
 27241                              <1> ; ----------------------------------------------------------------------------
 27242                              <1> ; Last Update: 08/08/2022  (Previous: 18/04/2021)
 27243                              <1> ; ----------------------------------------------------------------------------
 27244                              <1> ; Beginning: 17/01/2016
 27245                              <1> ; ----------------------------------------------------------------------------
 27246                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 27247                              <1> ; ----------------------------------------------------------------------------
 27248                              <1> ; Turkish Rational DOS
 27249                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 27250                              <1> ;
 27251                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 27252                              <1> ;
 27253                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
 27254                              <1> ; ****************************************************************************
 27255                              <1> 
 27256                              <1> ; TRDOS 386  (TRDOS v2.0) Kernel - TIMER & REAL TIME CLOCK (BIOS) FUNCTIONS
 27257                              <1> 
 27258                              <1> ; IBM PC-AT BIOS Source Code ('BIOS2.ASM')
 27259                              <1> ; TITLE BIOS2 ---- 06/10/85 BIOS INTERRUPT ROUTINES
 27260                              <1> 
 27261                              <1> ;-------------------------------------------------------------------------------
 27262                              <1> ;
 27263                              <1> ; ///////// TIMER (& REAL TIME CLOCK) FUNCTIONS ///////////////
 27264                              <1> 
 27265                              <1> int1Ah:
 27266                              <1> 	; 29/01/2016
 27267                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
 27268 00006159 9C                  <1> 	pushfd
 27269 0000615A 0E                  <1> 	push 	cs
 27270 0000615B E801000000          <1> 	call 	TIME_OF_DAY_1
 27271 00006160 C3                  <1> 	retn
 27272                              <1> 
 27273                              <1> ;-------------------------------------------------------------------------------
 27274                              <1> 
 27275                              <1> ;--- INT 1A H -- (TIME OF DAY) --------------------------------------------------
 27276                              <1> ;       THIS BIOS ROUTINE ALLOWS THE CLOCKS TO BE SET OR READ			:
 27277                              <1> ;										:
 27278                              <1> ; PARAMETERS:									:
 27279                              <1> ;     (AH) = 00H  READ THE CURRENT SETTING AND RETURN WITH,			:
 27280                              <1> ;                      (CX) = HIGH PORTION OF COUNT				:
 27281                              <1> ;                      (DX) = LOW PORTION OF COUNT				:
 27282                              <1> ;                      (AL) = 0 TIMER HAS NOT PASSED 24 HOURS SINCE LAST READ	:
 27283                              <1> ;                             1 IF ON ANOTHER DAY. (RESET TO ZERO AFTER READ)	:
 27284                              <1> ;										:
 27285                              <1> ;     (AH) = 01H  SET THE CURRENT CLOCK USING,					:
 27286                              <1> ;		     (CX) = HIGH PORTION OF COUNT				:
 27287                              <1> ;		     (DX) = LOW PORTION OF COUNT.				:
 27288                              <1> ;										:
 27289                              <1> ;             NOTE: COUNTS OCCUR AT THE RATE OF 1193180/65536 COUNTS/SECOND	:
 27290                              <1> ;                   (OR ABOUT 18.2 PER SECOND -- SEE EQUATES)			:
 27291                              <1> ;										:
 27292                              <1> ;     (AH) = 02H  READ THE REAL TIME CLOCK AND RETURN WITH,			:
 27293                              <1> ;                      (CH) = HOURS IN BCD (00-23)				:
 27294                              <1> ;                      (CL) = MINUTES IN BCD (00-59)				:
 27295                              <1> ;                      (DH) = SECONDS IN BCD (00-59)				:
 27296                              <1> ;                      (DL) = DAYLIGHT SAVINGS ENABLE (00-01)			:
 27297                              <1> ;										:
 27298                              <1> ;     (AH) = 03H  SET THE REAL TIME CLOCK USING,				:
 27299                              <1> ;                     (CH) = HOURS IN BCD (00-23)				:
 27300                              <1> ;                     (CL) = MINUTES IN BCD (00-59)				:
 27301                              <1> ;                     (DH) = SECONDS IN BCD (00-59)				:
 27302                              <1> ;                     (DL) = 01 IF DAYLIGHT SAVINGS ENABLE OPTION, ELSE 00.	:
 27303                              <1> ;										:
 27304                              <1> ;             NOTE: (DL) = 00 IF DAYLIGHT SAVINGS TIME ENABLE IS NOT ENABLED.	:
 27305                              <1> ;                   (DL) = 01 ENABLES TWO SPECIAL UPDATES THE LAST SUNDAY IN	:
 27306                              <1> ;	            APRIL   (1:59:59 --> 3:00:00 AM) AND THE LAST SUNDAY IN	:
 27307                              <1> ;                   OCTOBER (1:59:59 --> 1:00:00 AM) THE FIRST TIME.		:
 27308                              <1> ;										:
 27309                              <1> ;     (AH) = 04H  READ THE DATE FROM THE REAL TIME CLOCK AND RETURN WITH,	:
 27310                              <1> ;                      (CH) = CENTURY IN BCD (19 OR 20)				:
 27311                              <1> ;                      (CL) = YEAR IN BCD (00-99)				:
 27312                              <1> ;                      (DH) = MONTH IN BCD (01-12)				:
 27313                              <1> ;                      (DL) = DAY IN BCD (01-31).				:
 27314                              <1> ;										:
 27315                              <1> ;     (AH) = 05H  SET THE DATE INTO THE REAL TIME CLOCK USING,			:
 27316                              <1> ;                     (CH) = CENTURY IN BCD (19 OR 20)				:
 27317                              <1> ;                     (CL) = YEAR IN BCD (00-99)				:
 27318                              <1> ;                     (DH) = MONTH IN BCD (01-12)				:
 27319                              <1> ;                     (DL) = DAY IN BCD (01-31).				:
 27320                              <1> ;										:
 27321                              <1> ;     (AH) = 06H  SET THE ALARM TO INTERRUPT AT SPECIFIED TIME,			:
 27322                              <1> ;                     (CH) = HOURS IN BCD (00-23 (OR FFH))			:
 27323                              <1> ;                     (CL) = MINUTES IN BCD (00-59 (OR FFH))			:
 27324                              <1> ;                     (DH) = SECONDS IN BCD (00-59 (OR FFH))			:
 27325                              <1> ;										:
 27326                              <1> ;     (AH) = 07H  RESET THE ALARM INTERRUPT FUNCTION.				:
 27327                              <1> ;										:
 27328                              <1> ; NOTES: FOR ALL RETURNS CY= 0 FOR SUCCESSFUL OPERATION.			:
 27329                              <1> ;        FOR (AH)= 2, 4, 6 - CARRY FLAG SET IF REAL TIME CLOCK NOT OPERATING.	:
 27330                              <1> ;        FOR (AH)= 6 - CARRY FLAG SET IF ALARM ALREADY ENABLED. 		:
 27331                              <1> ;        FOR THE ALARM FUNCTION (AH = 6) THE USER MUST SUPPLY A ROUTINE AND	:
 27332                              <1> ;         INTERCEPT THE CORRECT ADDRESS IN THE VECTOR TABLE FOR INTERRUPT 4AH.	:
 27333                              <1> ;         USE 0FFH FOR ANY "DO NOT CARE" POSITION FOR INTERVAL INTERRUPTS.	:
 27334                              <1> ;        INTERRUPTS ARE DISABLED DURING DATA MODIFICATION. 			:
 27335                              <1> ;        AH & AL ARE RETURNED MODIFIED AND NOT DEFINED EXCEPT WHERE INDICATED.	:
 27336                              <1> ;--------------------------------------------------------------------------------
 27337                              <1> 
 27338                              <1> ; 29/07/2022
 27339                              <1> ; 15/01/2017
 27340                              <1> ; 14/01/2017
 27341                              <1> ; 07/01/2017
 27342                              <1> ; 02/01/2017
 27343                              <1> ; 29/05/2016
 27344                              <1> ; 29/01/2016
 27345                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
 27346                              <1> 
 27347                              <1> ; 29/05/2016
 27348                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 27349                              <1> int35h:  ; Date/Time functions
 27350                              <1> 
 27351                              <1> TIME_OF_DAY_1:
 27352                              <1> 	; 07/08/5022
 27353                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 27354                              <1> 	;sti				; INTERRUPTS BACK ON
 27355                              <1> 	; 29/05/2016
 27356 00006161 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
 27357                              <1> 	;
 27358 00006166 80FC08              <1> 	cmp	ah, (RTC_TBE-RTC_TB)/4	; CHECK IF COMMAND IN VALID RANGE (0-7)
 27359 00006169 F5                  <1> 	cmc				; COMPLEMENT CARRY FOR ERROR EXIT
 27360                              <1> 	; (*) jc short TIME_9		; EXIT WITH CARRY = 1 IF NOT VALID
 27361 0000616A 721A                <1> 	jc	short _TIME_9 ; 29/05/2016
 27362                              <1> 
 27363 0000616C 1E                  <1> 	push	ds
 27364 0000616D 56                  <1> 	push	esi
 27365 0000616E 66BE1000            <1> 	mov	si, KDATA		; kernel data segment
 27366 00006172 8EDE                <1> 	mov	ds, si
 27367                              <1> 
 27368                              <1> 	;;15/01/2017
 27369                              <1> 	; 14/01/2017
 27370                              <1> 	; 02/01/2017
 27371                              <1> 	;;mov	byte [intflg], 35h	; date & time interrupt 
 27372                              <1> 	;sti
 27373                              <1> 	;
 27374 00006174 C0E402              <1> 	shl	ah, 2			; convert function to dword offset
 27375 00006177 0FB6F4              <1> 	movzx	esi, ah			; PLACE INTO ADDRESSING REGISTER
 27376                              <1> 	;cli				; NO INTERRUPTS DURING TIME FUNCTIONS
 27377 0000617A FF96[8C610000]      <1> 	call	[esi+RTC_TB]		; VECTOR TO FUNCTION REQUESTED WITH CY=0
 27378                              <1> 					; RETURN WITH CARRY FLAG SET FOR RESULT
 27379                              <1> 	;sti				; INTERRUPTS BACK ON
 27380 00006180 B400                <1> 	mov	ah, 0			; CLEAR (AH) TO ZERO
 27381 00006182 5E                  <1> 	pop	esi			; RECOVER USERS REGISTER
 27382 00006183 1F                  <1> 	pop	ds			; RECOVER USERS SEGMENT SELECTOR
 27383                              <1> 
 27384                              <1> 	;;15/01/2017
 27385                              <1> 	; 02/01/2017
 27386                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
 27387                              <1> 
 27388                              <1> ;TIME_9:
 27389                              <1> 					; RETURN WITH CY= 0 IF NO ERROR
 27390                              <1> 	; (*) 29/05/2016
 27391                              <1> 	; (*) retf 4 ; skip eflags on stack
 27392 00006184 7305                <1> 	jnc	short _TIME_10
 27393                              <1> _TIME_9:
 27394                              <1> 	; 29/05/2016 -set carry flag on stack-
 27395                              <1> 	; [esp] = EIP
 27396                              <1> 	; [esp+4] = CS
 27397                              <1> 	; [esp+8] = E-FLAGS
 27398 00006186 804C240801          <1> 	or	byte [esp+8], 1	 ; set carry bit of eflags register
 27399                              <1> 	; [esp+12] = ESP (user)
 27400                              <1> 	; [esp+16] = SS (User)
 27401                              <1> _TIME_10:
 27402 0000618B CF                  <1> 	iretd
 27403                              <1> 	
 27404                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
 27405                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
 27406                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
 27407                              <1> 	; // RETF instruction:
 27408                              <1> 	;
 27409                              <1> 	; IF OperandMode=32 THEN
 27410                              <1>  	;    Load CS:EIP from stack;
 27411                              <1>  	;    Set CS RPL to CPL;
 27412                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
 27413                              <1>  	;    Load SS:eSP from stack;
 27414                              <1>  	; ELSE (* OperandMode=16 *)
 27415                              <1>  	;    Load CS:IP from stack;
 27416                              <1>  	;    Set CS RPL to CPL;
 27417                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
 27418                              <1> 	;    Load SS:eSP from stack;
 27419                              <1>  	; FI;
 27420                              <1> 	;
 27421                              <1> 	; //					
 27422                              <1> 					; ROUTINE VECTOR TABLE (AH)=
 27423                              <1> RTC_TB:
 27424 0000618C [AC610000]          <1> 	dd	RTC_00			; 0 = READ CURRENT CLOCK COUNT
 27425 00006190 [BF610000]          <1> 	dd	RTC_10			; 1 = SET CLOCK COUNT
 27426 00006194 [CD610000]          <1> 	dd	RTC_20			; 2 = READ THE REAL TIME CLOCK TIME
 27427 00006198 [FB610000]          <1> 	dd	RTC_30			; 3 = SET REAL TIME CLOCK TIME
 27428 0000619C [38620000]          <1> 	dd	RTC_40			; 4 = READ THE REAL TIME CLOCK DATE
 27429 000061A0 [5E620000]          <1> 	dd	RTC_50			; 5 = SET REAL TIME CLOCK DATE
 27430 000061A4 [BD620000]          <1> 	dd	RTC_60			; 6 = SET THE REAL TIME CLOCK ALARM
 27431 000061A8 [0F630000]          <1> 	dd	RTC_70			; 7 = RESET ALARM
 27432                              <1> 
 27433                              <1> RTC_TBE	equ	$
 27434                              <1> 
 27435                              <1> RTC_00:				; READ TIME COUNT
 27436 000061AC A0[04780100]        <1> 	mov	al, [TIMER_OFL]		; GET THE OVERFLOW FLAG
 27437 000061B1 C605[04780100]00    <1> 	mov	byte [TIMER_OFL], 0	; AND THEN RESET THE OVERFLOW FLAG
 27438 000061B8 8B0D[00780100]      <1>         mov     ecx, [TIMER_LH]         ; GET COUNT OF TIME
 27439 000061BE C3                  <1> 	retn
 27440                              <1> 
 27441                              <1> RTC_10:				; SET TIME COUNT
 27442 000061BF 890D[00780100]      <1>         mov     [TIMER_LH], ecx         ; SET TIME COUNT
 27443 000061C5 C605[04780100]00    <1> 	mov	byte [TIMER_OFL], 0	; RESET OVERFLOW FLAG
 27444 000061CC C3                  <1> 	retn				; RETURN WITH NO CARRY
 27445                              <1> 
 27446                              <1> RTC_20:				; GET RTC TIME
 27447 000061CD E8C7010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
 27448 000061D2 7226                <1> 	jc	short RTC_29		; EXIT IF ERROR (CY= 1)
 27449                              <1> 
 27450 000061D4 B000                <1> 	mov	al, CMOS_SECONDS	; SET ADDRESS OF SECONDS
 27451 000061D6 E8F4010000          <1> 	call	CMOS_READ		; GET SECONDS
 27452 000061DB 88C6                <1> 	mov	dh, al			; SAVE
 27453 000061DD B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 27454 000061DF E8EB010000          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
 27455 000061E4 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
 27456 000061E6 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
 27457 000061E8 B002                <1> 	mov	al, CMOS_MINUTES	; SET ADDRESS OF MINUTES
 27458 000061EA E8E0010000          <1> 	call	CMOS_READ		; GET MINUTES
 27459 000061EF 88C1                <1> 	mov	cl, al			; SAVE
 27460 000061F1 B004                <1>         mov     al, CMOS_HOURS          ; SET ADDRESS OF HOURS
 27461                              <1> RTC_41:		; 29/07/2022
 27462 000061F3 E8D7010000          <1> 	call	CMOS_READ		; GET HOURS
 27463 000061F8 88C5                <1> 	mov	ch, al			; SAVE
 27464                              <1> 	; 29/07/2022
 27465                              <1> 	;clc				; SET CY= 0
 27466                              <1> RTC_29:
 27467 000061FA C3                  <1> 	retn				; RETURN WITH RESULT IN CARRY FLAG
 27468                              <1> 
 27469                              <1> RTC_30:				; SET RTC TIME
 27470 000061FB E899010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
 27471 00006200 7305                <1> 	jnc	short RTC_35		; GO AROUND IF CLOCK OPERATING
 27472 00006202 E8AD010000          <1> 	call	RTC_STA			; ELSE TRY INITIALIZING CLOCK
 27473                              <1> RTC_35:
 27474 00006207 88F4                <1> 	mov	ah, dh			; GET TIME BYTE - SECONDS
 27475 00006209 B000                <1> 	mov	al, CMOS_SECONDS	; ADDRESS SECONDS
 27476 0000620B E894000000          <1> 	call	CMOS_WRITE		; UPDATE SECONDS
 27477 00006210 88CC                <1> 	mov	ah, cl			; GET TIME BYTE - MINUTES
 27478 00006212 B002                <1> 	mov	al, CMOS_MINUTES	; ADDRESS MINUTES
 27479 00006214 E88B000000          <1> 	call	CMOS_WRITE		; UPDATE MINUTES
 27480 00006219 88EC                <1> 	mov	ah, ch			; GET TIME BYTE - HOURS
 27481 0000621B B004                <1> 	mov	al, CMOS_HOURS		; ADDRESS HOURS
 27482 0000621D E882000000          <1> 	call	CMOS_WRITE		; UPDATE ADDRESS
 27483                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 27484                              <1> 	;mov	ah, al
 27485 00006222 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
 27486 00006226 E8A4010000          <1> 	call	CMOS_READ		; READ CURRENT TIME
 27487 0000622B 2462                <1> 	and	al, 01100010b		; MASK FOR VALID BIT POSITIONS
 27488 0000622D 0C02                <1> 	or	al, 00000010b		; TURN ON 24 HOUR MODE
 27489 0000622F 80E201              <1> 	and	dl, 00000001b		; USE ONLY THE DSE BIT
 27490 00006232 08D0                <1> 	or	al, dl			; GET DAY LIGHT SAVINGS TIME BIT (OSE)
 27491 00006234 86E0                <1> 	xchg	ah, al			; PLACE IN WORK REGISTER AND GET ADDRESS
 27492                              <1> 	;call	CMOS_WRITE		; SET NEW ALARM SITS
 27493                              <1> 	;clc				; SET CY= 0
 27494                              <1> 	;retn				; RETURN WITH CY= 0
 27495                              <1> 	; 29/07/2022
 27496 00006236 EB6C                <1> 	jmp	short CMOS_WRITE
 27497                              <1> 
 27498                              <1> RTC_40:				; GET RTC DATE
 27499 00006238 E85C010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
 27500                              <1> 	;jc	short RTC_49		; EXIT IF ERROR (CY= 1)
 27501                              <1> 	; 07/08/2022
 27502 0000623D 72BB                <1> 	jc	short RTC_29
 27503                              <1> 
 27504 0000623F B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH
 27505 00006241 E889010000          <1> 	call	CMOS_READ		; READ DAY OF MONTH
 27506 00006246 88C2                <1> 	mov	dl, al			; SAVE
 27507 00006248 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH
 27508 0000624A E880010000          <1> 	call	CMOS_READ		; READ MONTH
 27509 0000624F 88C6                <1> 	mov	dh, al			; SAVE
 27510 00006251 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR
 27511 00006253 E877010000          <1> 	call	CMOS_READ		; READ YEAR
 27512 00006258 88C1                <1> 	mov	cl, al			; SAVE
 27513 0000625A B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY LOCATION
 27514                              <1> ; 29/07/2022
 27515                              <1> ;	call	CMOS_READ		; GET CENTURY BYTE
 27516                              <1> ;	mov	ch, al			; SAVE
 27517                              <1> ;	; 29/07/2022
 27518                              <1> ;	;clc				; SET CY=0
 27519                              <1> ;RTC_49:
 27520                              <1> ;	retn				; RETURN WITH RESULTS IN CARRY FLAG
 27521                              <1> 
 27522                              <1> 	; 29/07/2022
 27523 0000625C EB95                <1> 	jmp	short RTC_41
 27524                              <1> 
 27525                              <1> 
 27526                              <1> RTC_50:				; SET RTC DATE
 27527 0000625E E836010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
 27528 00006263 7305                <1> 	jnc	short RTC_55		; GO AROUND IF NO ERROR
 27529 00006265 E84A010000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
 27530                              <1> RTC_55:
 27531 0000626A 66B80600            <1> 	mov	ax, CMOS_DAY_WEEK	; ADDRESS OF DAY OF WEEK BYTE
 27532 0000626E E831000000          <1> 	call	CMOS_WRITE		; LOAD ZEROS TO DAY OF WEEK
 27533 00006273 88D4                <1> 	mov	ah, dl			; GET DAY OF MONTH BYTE
 27534 00006275 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH BYTE
 27535 00006277 E828000000          <1> 	call	CMOS_WRITE		; WRITE OF DAY OF MONTH REGISTER
 27536 0000627C 88F4                <1> 	mov	ah, dh			; GET MONTH
 27537 0000627E B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH BYTE
 27538 00006280 E81F000000          <1> 	call	CMOS_WRITE		; WRITE MONTH REGISTER
 27539 00006285 88CC                <1> 	mov	ah, cl			; GET YEAR BYTE
 27540 00006287 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR REGISTER
 27541 00006289 E816000000          <1> 	call	CMOS_WRITE		; WRITE YEAR REGISTER
 27542 0000628E 88EC                <1> 	mov	ah, ch			; GET CENTURY BYTE
 27543 00006290 B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY BYTE
 27544 00006292 E80D000000          <1> 	call	CMOS_WRITE		; WRITE CENTURY LOCATION
 27545                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 27546                              <1> 	;mov	ah, al
 27547 00006297 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
 27548 0000629B E82F010000          <1> 	call	CMOS_READ		; READ CURRENT SETTINGS
 27549 000062A0 247F                <1> 	and	al, 07Fh		; CLEAR 'SET BIT'
 27550 000062A2 86E0                <1> 	xchg	ah, al			; MOVE TO WORK REGISTER
 27551                              <1> 	;call	CMOS_WRITE		; AND START CLOCK UPDATING
 27552                              <1> 	;clc				; SET CY= 0
 27553                              <1> 	;retn				; RETURN CY=0
 27554                              <1> 	; 29/07/2022
 27555                              <1> 	;jmp	short CMOS_WRITE
 27556                              <1> 
 27557                              <1> ;-------------------------------------------------------------------------------
 27558                              <1> 
 27559                              <1> ; 08/08/2022
 27560                              <1> ; 29/07/2022 (TRDOS 386 v2.0.5)
 27561                              <1> ; 18/04/2021 (TRDOS 386 v2.0.4)
 27562                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
 27563                              <1> 
 27564                              <1> ;--- CMOS_WRITE ----------------------------------------------------------------
 27565                              <1> ;	WRITE BYTE TO CMOS SYSTEM CLOCK CONFIGURATION TABLE		       :
 27566                              <1> ;									       :
 27567                              <1> ; INPUT: (AL)=	CMOS TABLE ADDRESS TO BE WRITTEN TO			       :
 27568                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
 27569                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO WRITE		       :
 27570                              <1> ;	 (AH)=	NEW VALUE TO BE PLACED IN THE ADDRESSED TABLE LOCATION	       :
 27571                              <1> ;									       :
 27572                              <1> ; OUTPUT:	VALUE IN (AH) PLACED IN LOCATION (AL) WITH NMI LEFT DISABLED   :
 27573                              <1> ;		IF BIT 7 OF (AL) IS ON, DURING THE CMOS UPDATE BOTH NMI AND    :
 27574                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
 27575                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
 27576                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
 27577                              <1> ;		ONLY THE CMOS LOCATION AND THE NMI STATE IS CHANGED.	       :
 27578                              <1> ;-------------------------------------------------------------------------------
 27579                              <1> 
 27580                              <1> 	; 08/08/2022
 27581                              <1> CMOS_WRITE:				; WRITE (AH) TO LOCATION (AL)
 27582                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 27583                              <1> 	;pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
 27584                              <1> 	;;push	ax			; SAVE WORK REGISTER VALUES
 27585                              <1> 	; 18/04/2021
 27586                              <1> 	;push	eax
 27587 000062A4 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
 27588 000062A6 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
 27589 000062A7 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
 27590 000062A9 FA                  <1> 	cli				; DISABLE INTERRUPTS
 27591 000062AA E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
 27592 000062AC 88E0                <1> 	mov	al, ah			; GET THE DATA BYTE TO WRITE
 27593 000062AE E671                <1> 	out	CMOS_DATA, al		; PLACE IN REQUESTED CMOS LOCATION
 27594 000062B0 B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2	; GET ADDRESS OF DEFAULT LOCATION
 27595                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
 27596 000062B2 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
 27597 000062B4 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
 27598                              <1> 	;nop				; I/O DELAY
 27599                              <1> 	; 29/07/2022
 27600 000062B6 E6EB                <1> 	out	0EBh, al ; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
 27601 000062B8 E471                <1> 	in	al, CMOS_DATA		; OPEN STANDBY LATCH
 27602                              <1> 	;;pop	ax			; RESTORE WORK REGISTERS
 27603                              <1> 	; 18/04/2021
 27604                              <1> 	;pop	eax
 27605                              <1> 	;popf
 27606                              <1> 	; 29/07/2022
 27607                              <1> 	;clc
 27608                              <1> 	; 08/08/2022
 27609 000062BA 30C0                <1> 	xor	al, al
 27610 000062BC C3                  <1> 	retn
 27611                              <1> 
 27612                              <1> ;-------------------------------------------------------------------------------
 27613                              <1> 
 27614                              <1> RTC_60:				; SET RTC ALARM
 27615 000062BD B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM
 27616 000062BF E80B010000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
 27617 000062C4 A820                <1> 	test	al, 20h			; CHECK FOR ALARM ALREADY ENABLED
 27618 000062C6 F9                  <1> 	stc				; SET CARRY IN CASE OF ERROR
 27619 000062C7 7541                <1> 	jnz	short RTC_69		; ERROR EXIT IF ALARM SET
 27620 000062C9 E8CB000000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
 27621 000062CE 7305                <1> 	jnc	short RTC_65		; SKIP INITIALIZATION IF NO ERROR
 27622 000062D0 E8DF000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
 27623                              <1> RTC_65:	
 27624 000062D5 88F4                <1> 	mov	ah, dh			; GET SECONDS BYTE
 27625 000062D7 B001                <1> 	mov	al, CMOS_SEC_ALARM	; ADDRESS THE SECONDS ALARM REGISTER
 27626 000062D9 E8C6FFFFFF          <1> 	call	CMOS_WRITE		; INSERT SECONDS
 27627 000062DE 88CC                <1> 	mov	ah, cl			; GET MINUTES PARAMETER
 27628 000062E0 B003                <1> 	mov	al, CMOS_MIN_ALARM	; ADDRESS MINUTES ALARM REGISTER
 27629 000062E2 E8BDFFFFFF          <1> 	call	CMOS_WRITE		; INSERT MINUTES
 27630 000062E7 88EC                <1> 	mov	ah, ch			; GET HOURS PARAMETER
 27631 000062E9 B005                <1> 	mov	al, CMOS_HR_ALARM	; ADDRESS HOUR ALARM REGISTER
 27632 000062EB E8B4FFFFFF          <1> 	call	CMOS_WRITE		; INSERT HOURS
 27633 000062F0 E4A1                <1> 	in	al, INTB01		; READ SECOND INTERRUPT MASK REGISTER
 27634 000062F2 24FE                <1> 	and	al, 0FEh		; ENABLE ALARM TIMER BIT (CY= 0)
 27635 000062F4 E6A1                <1> 	out	INTB01, al		; WRITE UPDATED MASK
 27636                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 27637                              <1> 	;mov	ah, al
 27638 000062F6 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
 27639 000062FA E8D0000000          <1> 	call	CMOS_READ		; READ CURRENT ALARM REGISTER
 27640 000062FF 247F                <1> 	and	al, 07Fh		; ENSURE SET BIT TURNED OFF
 27641 00006301 0C20                <1> 	or	al, 20h			; TURN ON ALARM ENABLE
 27642 00006303 86E0                <1> 	xchg	ah, al			; MOVE MASK TO OUTPUT REGISTER
 27643 00006305 E89AFFFFFF          <1> 	call	CMOS_WRITE		; WRITE NEW ALARM MASK
 27644                              <1> 	; 29/07/2022
 27645                              <1> 	;clc				; SET CY= 0
 27646                              <1> RTC_69:
 27647 0000630A 66B80000            <1> 	mov	ax, 0			; CLEAR AX REGISTER
 27648 0000630E C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAC
 27649                              <1> 
 27650                              <1> RTC_70:				; RESET ALARM
 27651                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 27652                              <1> 	;mov	ah, al
 27653 0000630F 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257	; ADDRESS ALARM REGISTER (TO BOTH AH,AL)
 27654 00006313 E8B7000000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
 27655 00006318 2457                <1> 	and	al, 57h			; TURN OFF ALARM ENABLE
 27656 0000631A 86E0                <1> 	xchg	ah, al			; SAVE DATA AND RECOVER ADDRESS
 27657                              <1> 	;call	CMOS_WRITE		; RESTORE NEW VALUE
 27658                              <1> 	;clc				; SET CY= 0
 27659                              <1> 	;retn				; RETURN WITH NO CARRY
 27660                              <1> 	; 29/07/2022
 27661 0000631C EB86                <1> 	jmp	short CMOS_WRITE
 27662                              <1> 
 27663                              <1> ;-------------------------------------------------------------------------------
 27664                              <1> 
 27665                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
 27666                              <1> 
 27667                              <1> ;--- HARDWARE INT 70 H -- ( IRQ LEVEL 8) ----------------------------------------
 27668                              <1> ; ALARM INTERRUPT HANDLER (RTC)							:
 27669                              <1> ;       THIS ROUTINE HANDLES THE PERIODIC AND ALARM INTERRUPTS FROM THE CMOS	:
 27670                              <1> ;       TIMER. INPUT FREQUENCY IS 1.024 KHZ OR APPROXIMATELY 1024 INTERRUPTS	:
 27671                              <1> ;       EVERY SECOND FOR THE PERIODIC INTERRUPT. FOR THE ALARM FUNCTION,	:
 27672                              <1> ;       THE INTERRUPT WILL OCCUR AT THE DESIGNATED TIME.			:
 27673                              <1> ;										:
 27674                              <1> ;       INTERRUPTS ARE ENABLED WHEN THE EVENT OR ALARM FUNCTION IS ACTIVATED.	:
 27675                              <1> ;       FOR THE EVENT INTERRUPT, THE HANDLER WILL DECREMENT THE WAIT COUNTER	:
 27676                              <1> ;       AND WHEN IT EXPIRES WILL SET THE DESIGNATED LOCATION TO 80H. FOR	:
 27677                              <1> ;       THE ALARM INTERRUPT. THE USER MUST PROVIDE A ROUTINE TO INTERCEPT	:
 27678                              <1> ;       THE CORRECT ADDRESS FROM THE VECTOR TABLE INVOKED BY INTERRUPT 4AH	:
 27679                              <1> ;       PRIOR TO SETTING THE REAL TIME CLOCK ALARM (INT 1AH, AH= 06H).		:
 27680                              <1> ;--------------------------------------------------------------------------------
 27681                              <1> 
 27682                              <1> RTC_A_INT: ; 07/01/2017
 27683                              <1> ;RTC_INT:				; ALARM INTERRUPT
 27684 0000631E 1E                  <1> 	push	ds			; LEAVE INTERRUPTS DISABLED
 27685 0000631F 50                  <1> 	push	eax			; SAVE REGISTERS
 27686 00006320 57                  <1> 	push	edi
 27687                              <1> RTC_I_1:				; CHECK FOR SECOND INTERRUPT
 27688 00006321 66B88C8B            <1> 	mov	ax, 256*(CMOS_REG_B+NMI)+CMOS_REG_C+NMI ; ALARM AND STATUS
 27689 00006325 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM FLAG MASK ADDRESS
 27690 00006327 90                  <1> 	nop				; I/O DELAY
 27691 00006328 EB00                <1> 	jmp	short $+2
 27692 0000632A E471                <1> 	in	al, CMOS_DATA		; READ AND RESET INTERRUPT REQUEST FLAGS
 27693 0000632C A860                <1> 	test	al, 01100000b		; CHECK FOR EITHER INTERRUPT PENDING
 27694 0000632E 745B                <1> 	jz	short	RTC_I_9		; EXIT IF NOT A VALID RTC INTERRUPT
 27695                              <1> 
 27696 00006330 86E0                <1> 	xchg	ah, al			; SAVE FLAGS AND GET ENABLE ADDRESS
 27697 00006332 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM ENABLE MASK ADDRESS
 27698 00006334 90                  <1> 	nop				; I/O DELAY
 27699 00006335 EB00                <1> 	jmp	short $+2	
 27700 00006337 E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ALARM ENABLE MASK
 27701 00006339 20E0                <1> 	and	al, ah			; ALLOW ONLY SOURCES THAT ARE ENABLED
 27702 0000633B A840                <1> 	test	al, 01000000b		; CHECK FOR PERIODIC INTERRUPT
 27703 0000633D 7439                <1> 	jz	short RTC_I_5		; SKIP IF NOT A PERIODIC INTERRUPT
 27704                              <1> 
 27705                              <1> ;-----	DECREMENT WAIT COUNT BY INTERRUPT INTERVAL
 27706                              <1> 
 27707 0000633F 66BF1000            <1> 	mov	di, KDATA		; kernel data segment
 27708 00006343 8EDF                <1> 	mov	ds, di
 27709                              <1> 	
 27710 00006345 812D[F8770100]D003- <1> 	sub	dword [RTC_LH], 976	; DECREMENT COUNT BY 1/1024
 27711 0000634D 0000                <1>
 27712 0000634F 7327                <1> 	jnc	short RTC_I_5		; SKIP TILL 32 BIT WORD LESS THAN ZERO
 27713                              <1> 
 27714                              <1> ;-----	TURN OFF PERIODIC INTERRUPT ENABLE
 27715                              <1> 
 27716                              <1> 	;push	ax			; SAVE INTERRUPT FLAG MASK
 27717                              <1> 	; 18/04/2021
 27718 00006351 50                  <1> 	push	eax
 27719 00006352 66B88B8B            <1> 	mov	ax, 257*(CMOS_REG_B+NMI) ; INTERRUPT ENABLE REGISTER
 27720 00006356 E670                <1> 	out	CMOS_PORT, al		; WRITE ADDRESS TO CMOS CLOCK
 27721 00006358 90                  <1> 	nop				; I/O DELAY
 27722 00006359 EB00                <1> 	jmp	short $+2
 27723 0000635B E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ENABLES
 27724 0000635D 24BF                <1> 	and	al, 0BFh		; TURN OFF PIE
 27725 0000635F 86C4                <1> 	xchg	al, ah			; GET CMOS ADDRESS AND SAVE VALUE
 27726 00006361 E670                <1> 	out	CMOS_PORT, al		; ADDRESS REGISTER B
 27727 00006363 86C4                <1> 	xchg	al, ah			; GET NEW INTERRUPT ENABLE MASK
 27728 00006365 E671                <1> 	out	CMOS_DATA, al		; SET MASK IN INTERRUPT ENABLE REGISTER
 27729 00006367 C605[FC770100]00    <1> 	mov	byte [RTC_WAIT_FLAG], 0	; SET FUNCTION ACTIVE FLAG OFF
 27730 0000636E 8B3D[FD770100]      <1> 	mov	edi, [USER_FLAG]	; SET UP (DS:DI) TO POINT TO USER FLAG
 27731 00006374 C60780              <1> 	mov	byte [edi], 80h		; TURN ON USERS FLAG
 27732                              <1> 	;pop	ax			; GET INTERRUPT SOURCE BACK
 27733                              <1> 	; 18/04/2021
 27734 00006377 58                  <1> 	pop	eax
 27735                              <1> RTC_I_5:
 27736 00006378 A820                <1> 	test	al, 00100000b		; TEST FOR ALARM INTERRUPT
 27737 0000637A 740D                <1> 	jz	short RTC_I_7		; SKIP USER INTERRUPT CALL IF NOT ALARM
 27738                              <1> 
 27739 0000637C B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
 27740 0000637E E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
 27741 00006380 FB                  <1> 	sti				; INTERRUPTS BACK ON NOW
 27742 00006381 52                  <1> 	push	edx
 27743 00006382 E895BB0000          <1> 	call	INT4Ah			; TRANSFER TO USER ROUTINE
 27744 00006387 5A                  <1> 	pop	edx
 27745 00006388 FA                  <1> 	cli				; BLOCK INTERRUPT FOR RETRY
 27746                              <1> RTC_I_7:				; RESTART ROUTINE TO HANDLE DELAYED
 27747 00006389 EB96                <1> 	jmp	short RTC_I_1		;  ENTRY AND SECOND EVENT BEFORE DONE
 27748                              <1> 
 27749                              <1> RTC_I_9:				; EXIT - NO PENDING INTERRUPTS
 27750 0000638B B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
 27751 0000638D E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
 27752 0000638F B020                <1> 	mov	al, EOI			; END OF INTERRUPT MASK TO 8259 - 2
 27753 00006391 E6A0                <1> 	out	INTB00, al		; TO 8259 - 2
 27754 00006393 E620                <1> 	out	INTA00,	al		; TO 8259 - 1
 27755 00006395 5F                  <1> 	pop	edi			; RESTORE REGISTERS
 27756 00006396 58                  <1> 	pop	eax
 27757 00006397 1F                  <1> 	pop	ds
 27758 00006398 CF                  <1> 	iretd				; END OF INTERRUPT
 27759                              <1> 
 27760                              <1> ;-------------------------------------------------------------------------------
 27761                              <1> 
 27762                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
 27763                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
 27764                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (bios2.asm)
 27765                              <1> UPD_IPR:				; WAIT TILL UPDATE NOT IN PROGRESS
 27766 00006399 51                  <1> 	push	ecx
 27767                              <1> 
 27768                              <1> 	; 29/05/2016
 27769 0000639A B968110000          <1> 	mov	ecx, ((1984+244)*4)/2	; AWARD BIOS 1999, ATIME.ASM		
 27770                              <1> 					; 'WAITCPU_CK_UD_STAT'
 27771                              <1> 					; (244Us + 1984Us)
 27772                              <1> 					; (assume each read takes
 27773                              <1> 					;  2 microseconds).
 27774                              <1> 	;mov	ecx, 65535		
 27775                              <1> 		;mov cx, 800		; SET TIMEOUT LOOP COUNT (= 800)	
 27776                              <1> UPD_10:
 27777 0000639F B00A                <1> 	mov	al, CMOS_REG_A		; ADDRESS STATUS REGISTER A
 27778 000063A1 FA                  <1> 	cli				; NO TIMER INTERRUPTS DURING UPDATES
 27779 000063A2 E828000000          <1> 	call	CMOS_READ		; READ UPDATE IN PROCESS FLAG
 27780 000063A7 A880                <1> 	test	al, 80h			; IF UIP BIT IS ON ( CANNOT READ TIME )
 27781 000063A9 7406                <1> 	jz	short UPD_90		; EXIT WITH CY= 0 IF CAN READ CLOCK NOW
 27782 000063AB FB                  <1> 	sti				; ALLOW INTERRUPTS WHILE WAITING
 27783 000063AC E2F1                <1> 	loop	UPD_10			; LOOP TILL READY OR TIMEOUT
 27784 000063AE 31C0                <1> 	xor	eax, eax ; xor ax, ax	; CLEAR RESULTS IF ERROR
 27785 000063B0 F9                  <1> 	stc				; SET CARRY FOR ERROR
 27786                              <1> UPD_90:
 27787 000063B1 59                  <1> 	pop	ecx			; RESTORE CALLERS REGISTER
 27788 000063B2 FA                  <1> 	cli				; INTERRUPTS OFF DURING SET
 27789 000063B3 C3                  <1> 	retn				; RETURN WITH CY FLAG SET
 27790                              <1> 
 27791                              <1> 	; 18/04/2021
 27792                              <1> RTC_STA:			; INITIALIZE REAL TIME CLOCK
 27793                              <1> 	;mov	al, CMOS_REG_A		; ADDRESS REGISTER A AND LOAD DATA MASK		
 27794                              <1> 	;mov	ah, 26h
 27795 000063B4 66B80A26            <1> 	mov	ax, (26h*100h)+CMOS_REG_A
 27796 000063B8 E8E7FEFFFF          <1> 	call	CMOS_WRITE		; INITIALIZE STATUS REGISTER A
 27797                              <1> 	;mov	al, CMOS_REG_B		; SET "SET BIT" FOR CLOCK INITIALIZATION	
 27798                              <1> 	;mov	ah, 82h
 27799 000063BD 66B80B82            <1> 	mov	ax, (82h*100h)+CMOS_REG_B
 27800 000063C1 E8DEFEFFFF          <1> 	call	CMOS_WRITE		; AND 24 HOUR MODE TO REGISTER B
 27801 000063C6 B00C                <1> 	mov	al, CMOS_REG_C		; ADDRESS REGISTER C
 27802 000063C8 E802000000          <1> 	call	CMOS_READ		; READ REGISTER C TO INITIALIZE
 27803 000063CD B00D                <1> 	mov	al, CMOS_REG_D		; ADDRESS REGISTER D
 27804                              <1> 	; 18/04/2021
 27805                              <1> 	;call	CMOS_READ		; READ REGISTER D TO INITIALIZE
 27806                              <1> 	;retn
 27807                              <1> 	;jmp	short CMOS_READ ; 18/04/2021
 27808                              <1> 
 27809                              <1> ;-------------------------------------------------------------------------------
 27810                              <1> 
 27811                              <1> 	; 29/07/2022 - TRDOS 386 v2.0.5
 27812                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
 27813                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 
 27814                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
 27815                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (test4.asm)
 27816                              <1> 
 27817                              <1> ;--- CMOS_READ -----------------------------------------------------------------
 27818                              <1> ;		READ BYTE FROM CMOS_SYSTEM CLOCK CONFIGURATION TABLE	       :
 27819                              <1> ;									       :
 27820                              <1> ; INPUT: (AL)=	CMOS_TABLE ADDRESS TO BE READ				       :
 27821                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
 27822                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO READ		       :
 27823                              <1> ;									       :
 27824                              <1> ; OUTPUT: (AL)	VALUE AT LOCATION (AL) MOVED INTO (AL). IF BIT 7 OF (AL) WAS   :
 27825                              <1> ;		ON THEN NMI LEFT DISABLED, DURING THE CMOS READ BOTH NMI AND   :
 27826                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
 27827                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
 27828                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
 27829                              <1> ;		ONLY THE (AL) REGISTER AND THE NMI STATE IS CHANGED.	       :
 27830                              <1> ;-------------------------------------------------------------------------------
 27831                              <1> 
 27832                              <1> CMOS_READ:
 27833                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 27834                              <1> 	;pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
 27835 000063CF D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
 27836 000063D1 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
 27837 000063D2 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
 27838 000063D4 FA                  <1> 	cli				; DISABLE INTERRUPTS
 27839 000063D5 E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
 27840                              <1> 	; 29/05/2016
 27841                              <1> 	;nop				; I/O DELAY
 27842 000063D7 E6EB                <1> 	out	0EBh, al ; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
 27843                              <1> 	;
 27844 000063D9 E471                <1> 	in	al, CMOS_DATA		; READ THE REQUESTED CMOS LOCATION
 27845                              <1> 	;push	ax	; SAVE (AH) REGISTER VALUE AND CMOS BYTE
 27846                              <1> 	; 18/04/2021
 27847 000063DB 50                  <1> 	push	eax
 27848                              <1> 	; 15/03/2015 ; IBM PC/XT Model 286 BIOS source code 
 27849                              <1> 		     ; ----- 10/06/85 (test4.asm)
 27850 000063DC B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2 	; GET ADDRESS OF DEFAULT LOCATION
 27851                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
 27852 000063DE D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
 27853 000063E0 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
 27854                              <1> 	;pop	ax			; RESTORE (AH) AND (AL), CMOS BYTE
 27855                              <1> 	; 18/04/2021
 27856 000063E2 58                  <1> 	pop	eax
 27857                              <1> 	; 29/07/2022
 27858                              <1> 	;popf
 27859 000063E3 F8                  <1> 	clc	; 29/07/2022	
 27860 000063E4 C3                  <1> 	retn				; RETURN WITH FLAGS RESTORED
 27861                              <1> 
 27862                              <1> ;-------------------------------------------------------------------------------
 27863                              <1> 
 27864                              <1> ; /// End Of TIMER FUNCTIONS ///
 27865                                  
 27866 000063E5 90<rept>                Align 16
 27867                                  
 27868                                  gdt:	; Global Descriptor Table
 27869                                  	; 02/12/2020
 27870                                  	; (30/07/2015, conforming cs)
 27871                                  	; (26/03/2015)
 27872                                  	; (24/03/2015, tss)
 27873                                  	; (19/03/2015)
 27874                                  	; (29/12/2013)
 27875                                  	;
 27876 000063F0 0000000000000000        	dw 0, 0, 0, 0		; NULL descriptor
 27877                                  gdt_kcode:
 27878                                  	; 18/08/2014
 27879                                  			; 8h kernel code segment, base = 00000000h		
 27880                                  	;dw 0FFFFh, 0, 9E00h, 00CFh	; KCODE  ; 30/12/2016	 
 27881 000063F8 FFFF0000009ACF00        	dw 0FFFFh, 0, 9A00h, 00CFh	; KCODE
 27882                                  gdt_kdata:
 27883                                  			; 10h kernel data segment, base = 00000000h	
 27884 00006400 FFFF00000092CF00        	dw 0FFFFh, 0, 9200h, 00CFh	; KDATA
 27885                                  gdt_ucode:
 27886                                  			; 1Bh user code segment, base address = 400000h ; CORE
 27887                                  	;dw 0FBFFh, 0, 0FE40h, 00CFh	; UCODE  ; 30/12/2016	
 27888 00006408 FFFB000040FACF00        	dw 0FBFFh, 0, 0FA40h, 00CFh	; UCODE
 27889                                  gdt_udata: 
 27890                                  			; 23h user data segment, base address = 400000h ; CORE
 27891 00006410 FFFB000040F2CF00        	dw 0FBFFh, 0, 0F240h, 00CFh	; UDATA
 27892                                  gdt_tss:
 27893                                  			; Task State Segment
 27894 00006418 6700                    	dw 0067h ; Limit = 103 ; (104-1, tss size = 104 byte, 
 27895                                  			       ;  no IO permission in ring 3)
 27896                                  gdt_tss0:
 27897 0000641A 0000                    	dw 0  ; TSS base address, bits 0-15 
 27898                                  gdt_tss1:
 27899 0000641C 00                      	db 0  ; TSS base address, bits 16-23 
 27900                                  	      		; 49h	
 27901 0000641D E9                      	db 11101001b ; 0E9h => P=1/DPL=11/0/1/0/B/1 --> B = Task is busy (1)
 27902 0000641E 00                      	db 0 ; G/0/0/AVL/LIMIT=0000 ; (Limit bits 16-19 = 0000) (G=0, 1 byte)
 27903                                  gdt_tss2:
 27904 0000641F 00                      	db 0  ; TSS base address, bits 24-31 
 27905                                  
 27906                                  	; 30/11/2020
 27907                                  	; 29/11/2020 - TRDOS v2.0.3
 27908                                  	; VESA VBE3 VIDE BIOS 32 BIT PMI SEGMENTS (16 bit segments)
 27909                                  			; 30h ; VBE3CS
 27910                                  _vbe3_CS:  ; vesa vbe3 bios uses this as code seg (same addr with _vbe3_DS)
 27911                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/C/R/A = 9Ah, 16 bit
 27912 00006420 FFFF0000009A0000        	dw 0FFFFh, 0, 9A00h, 0 ; Note: base addr will be initialized
 27913                                  			; 38h ; VBE3BDS
 27914                                  _vbe3_BDS: ; vesa vbe3 bios uses this as equivalent of rombios data segment
 27915                                  	; limit = 1536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
 27916 00006428 FF05000000920000        	dw 05FFh, 0, 9200h, 0 ; Note: base addr will be initialized	
 27917                                  			; 40h ; VBE3A000 
 27918                                  _A0000Sel: ; VGA default video memory address
 27919                                  	; limit = 65536, base addr = 0A0000h, 16 bit
 27920 00006430 FFFF00000A920000        	dw 0FFFFh, 0, 920Ah, 0
 27921                                  			; 48h ; VBE3B000 
 27922                                  _B0000Sel: ; MDA (monochrome) video memory address
 27923                                  	; limit = 65536, base addr = 0B0000h, 16 bit
 27924 00006438 FFFF00000B920000        	dw 0FFFFh, 0, 920Bh, 0
 27925                                  			; 50h ; VBE3B800 
 27926                                  _B8000Sel: ; CGA video memory address
 27927                                  	; limit = 32768, base addr = 0B8000h, 16 bit
 27928 00006440 FF7F00800B920000        	dw 07FFFh, 8000h, 920Bh, 0
 27929                                  			; 58h ; VBE3DS 
 27930                                  _vbe3_DS: ; vesa vbe3 bios uses this as data seg (CodeSegSel in PMInfoBlock)
 27931                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
 27932 00006448 FFFF000000920000        	dw 0FFFFh, 0, 9200h, 0 ; Note: base addr will be initialized
 27933                                  			; 60h ; VBE3SS   
 27934                                  _vbe3_SS: ; kernel's stack segment but 16 bit version (same stack addr)
 27935                                  	; limit = 1024, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
 27936 00006450 FF03000000920000        	dw 03FFh, 0, 9200h, 0 ; Note: base addr will be initialized
 27937                                  			; 68h ; VBE3ES 	
 27938                                  _vbe3_ES: ; extra 16 bit segment points to buffers in kernel's mem space
 27939                                  	; limit = 2048, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
 27940 00006458 FF07000000920000        	dw 07FFh, 0, 9200h,0 ; Note: base addr will be initialized
 27941                                  			; 70h ; KODE16	
 27942                                  _16bit_CS: ; 16 bit code segment points to kernel's far return addr
 27943                                  	; limit = 16M, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
 27944 00006460 FFFF0000009AFF00        	dw 0FFFFh, 0, 9A00h, 00FFh ; Note: base addr will be initialized
 27945                                  
 27946                                  gdt_end:
 27947                                  	;; 9Eh = 1001 1110b (GDT byte 5) P=1/DPL=00/1/TYPE=1110, 
 27948                                  					;; Type= 1 (code)/C=1/R=1/A=0
 27949                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
 27950                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
 27951                                  
 27952                                  	;; 9Ah = 1001 1010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
 27953                                  					;; Type= 1 (code)/C=0/R=1/A=0
 27954                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
 27955                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
 27956                                  
 27957                                  	;; 92h = 1001 0010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
 27958                                  					;; Type= 0 (data)/E=0/W=1/A=0
 27959                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
 27960                                  		; 0= Data E= Expansion direction (1= down, 0= up)
 27961                                  		; W= Writeable, A= Accessed
 27962                                  
 27963                                  	;; FEh = 1111 1110b (GDT byte 5) P=1/DPL=11/1/TYPE=1110, 
 27964                                  					;; Type= 1 (code)/C=1/R=1/A=0
 27965                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
 27966                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
 27967                                  	
 27968                                  	;; FAh = 1111 1010b (GDT byte 5) P=1/DPL=11/1/TYPE=1010, 
 27969                                  					;; Type= 1 (code)/C=0/R=1/A=0
 27970                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
 27971                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
 27972                                  
 27973                                  	;; F2h = 1111 0010b (GDT byte 5) P=1/DPL=11/1/TYPE=0010, 
 27974                                  					;; Type= 0 (data)/E=0/W=1/A=0
 27975                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
 27976                                  		; 0= Data E= Expansion direction (1= down, 0= up)
 27977                                  	
 27978                                  	;; CFh = 1100 1111b (GDT byte 6) G=1/B=1/0/AVL=0, Limit=1111b (3)
 27979                                  
 27980                                  		;; Limit = FFFFFh (=> FFFFFh+1= 100000h) // bits 0-15, 48-51 //
 27981                                  		;	 = 100000h * 1000h (G=1) = 4GB
 27982                                  		;; Limit = FFBFFh (=> FFBFFh+1= FFC00h) // bits 0-15, 48-51 //
 27983                                  		;	 = FFC00h * 1000h (G=1) = 4GB - 4MB
 27984                                  		; G= Granularity (1= 4KB), B= Big (32 bit), 
 27985                                  		; AVL= Available to programmers	
 27986                                  
 27987                                  gdtd:
 27988 00006468 7700                            dw gdt_end - gdt - 1    ; Limit (size)
 27989 0000646A [F0630000]                      dd gdt			; Address of the GDT
 27990                                  
 27991                                  	; 20/08/2014
 27992                                  idtd:
 27993 0000646E 7F02                            dw idt_end - idt - 1    ; Limit (size)
 27994 00006470 [98740100]                      dd idt			; Address of the IDT
 27995                                  
 27996                                  ; 20/02/2017
 27997                                  ;;; 11/03/2015
 27998                                  %include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
 27999                              <1> ; ****************************************************************************
 28000                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskdata.s
 28001                              <1> ; ----------------------------------------------------------------------------
 28002                              <1> ; Last Update: 06/08/2022 (Previous: 24/01/2016)
 28003                              <1> ; ----------------------------------------------------------------------------
 28004                              <1> ; Beginning: 24/01/2016
 28005                              <1> ; ----------------------------------------------------------------------------
 28006                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 28007                              <1> ; ----------------------------------------------------------------------------
 28008                              <1> ; Turkish Rational DOS
 28009                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 28010                              <1> ;
 28011                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 28012                              <1> ; diskdata.inc (11/03/2015)
 28013                              <1> ;
 28014                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
 28015                              <1> ; ****************************************************************************
 28016                              <1> 
 28017                              <1> ; Retro UNIX 386 v1 Kernel - DISKDATA.INC
 28018                              <1> ; Last Modification: 11/03/2015
 28019                              <1> ;	(Initialized Disk Parameters Data section for 'DISKIO.INC') 
 28020                              <1> ;
 28021                              <1> 
 28022                              <1> ;----------------------------------------
 28023                              <1> ;	80286 INTERRUPT LOCATIONS	:
 28024                              <1> ;	REFERENCED BY POST & BIOS	:
 28025                              <1> ;----------------------------------------
 28026                              <1> 
 28027 00006474 [D7640000]          <1> DISK_POINTER:	dd	MD_TBL6		; Pointer to Diskette Parameter Table
 28028                              <1> 
 28029                              <1> ; IBM PC-XT Model 286 source code ORGS.ASM (06/10/85) - 14/12/2014
 28030                              <1> ;----------------------------------------------------------------
 28031                              <1> ; DISK_BASE							:
 28032                              <1> ;	THIS IS THE SET OF PARAMETERS REQUIRED FOR		:
 28033                              <1> ;	DISKETTE OPERATION. THEY ARE POINTED AT BY THE		:
 28034                              <1> ;	DATA VARIABLE @DISK_POINTER. TO MODIFY THE PARAMETERS,	:
 28035                              <1> ;	BUILD ANOTHER PARAMETER BLOCK AND POINT AT IT		:
 28036                              <1> ;----------------------------------------------------------------
 28037                              <1> 
 28038                              <1> ;DISK_BASE:	
 28039                              <1> ;	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28040                              <1> ;	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28041                              <1> ;	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28042                              <1> ;	DB	2		; 512 BYTES/SECTOR
 28043                              <1> ;	;DB	15		; EOT (LAST SECTOR ON TRACK)
 28044                              <1> ;	db	18		; (EOT for 1.44MB diskette)
 28045                              <1> ;	DB	01BH		; GAP LENGTH
 28046                              <1> ;	DB	0FFH		; DTL
 28047                              <1> ;	;DB	054H		; GAP LENGTH FOR FORMAT
 28048                              <1> ;	db	06ch		; (for 1.44MB dsikette)
 28049                              <1> ;	DB	0F6H		; FILL BYTE FOR FORMAT
 28050                              <1> ;	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28051                              <1> ;	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28052                              <1> 
 28053                              <1> ;----------------------------------------
 28054                              <1> ;	ROM BIOS DATA AREAS		:
 28055                              <1> ;----------------------------------------
 28056                              <1> 
 28057                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
 28058                              <1> 
 28059                              <1> ;@EQUIP_FLAG	DW	?		; INSTALLED HARDWARE FLAGS
 28060                              <1> 
 28061                              <1> ;----------------------------------------
 28062                              <1> ;	DISKETTE DATA AREAS		:
 28063                              <1> ;----------------------------------------
 28064                              <1> 
 28065                              <1> ;@SEEK_STATUS	DB	?		; DRIVE RECALIBRATION STATUS
 28066                              <1> ;					; BIT 3-0 = DRIVE 3-0 RECALIBRATION
 28067                              <1> ;					; BEFORE NEXT SEEK IF BIT IS = 0
 28068                              <1> ;@MOTOR_STATUS	DB	?		; MOTOR STATUS
 28069                              <1> ;					; BIT 3-0 = DRIVE 3-0 CURRENTLY RUNNING
 28070                              <1> ;					; BIT 7 = CURRENT OPERATION IS A WRITE
 28071                              <1> ;@MOTOR_COUNT	DB	?		; TIME OUT COUNTER FOR MOTOR(S) TURN OFF
 28072                              <1> ;@DSKETTE_STATUS DB	?		; RETURN CODE STATUS BYTE
 28073                              <1> ;					; CMD_BLOCK  IN STACK FOR DISK OPERATION
 28074                              <1> ;@NEC_STATUS	DB	7 DUP(?)	; STATUS BYTES FROM DISKETTE OPERATION
 28075                              <1> 
 28076                              <1> ;----------------------------------------
 28077                              <1> ;	POST AND BIOS WORK DATA AREA	:
 28078                              <1> ;----------------------------------------
 28079                              <1> 
 28080                              <1> ;@INTR_FLAG	DB	?		; FLAG INDICATING AN INTERRUPT HAPPENED
 28081                              <1> 
 28082                              <1> ;----------------------------------------
 28083                              <1> ;	TIMER DATA AREA 		:
 28084                              <1> ;----------------------------------------
 28085                              <1> 
 28086                              <1> ; 17/12/2014  (IRQ 0 - INT 08H)
 28087                              <1> ;TIMER_LOW	equ	46Ch		; Timer ticks (counter)  @ 40h:006Ch
 28088                              <1> ;TIMER_HIGH	equ	46Eh		; (18.2 timer ticks per second)
 28089                              <1> ;TIMER_OFL	equ	470h		; Timer - 24 hours flag  @ 40h:0070h
 28090                              <1> 
 28091                              <1> ;----------------------------------------
 28092                              <1> ;	ADDITIONAL MEDIA DATA		:
 28093                              <1> ;----------------------------------------
 28094                              <1> 
 28095                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
 28096                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
 28097                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
 28098                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
 28099                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
 28100                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
 28101                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
 28102                              <1> 
 28103                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
 28104                              <1> 
 28105                              <1> ;--------------------------------------------------------
 28106                              <1> ;	DRIVE TYPE TABLE				:
 28107                              <1> ;--------------------------------------------------------
 28108                              <1> 		; 16/02/2015 (unix386.s, 32 bit modifications)
 28109                              <1> DR_TYPE:
 28110 00006478 01                  <1> 		DB	01		; DRIVE TYPE, MEDIA TABLE
 28111                              <1>                 ;DW	MD_TBL1
 28112 00006479 [96640000]          <1> 		dd	MD_TBL1
 28113 0000647D 82                  <1> 		DB	02+BIT7ON
 28114                              <1> 		;DW	MD_TBL2
 28115 0000647E [A3640000]          <1>                 dd      MD_TBL2
 28116 00006482 02                  <1> DR_DEFAULT:	DB	02
 28117                              <1>                 ;DW	MD_TBL3
 28118 00006483 [B0640000]          <1> 		dd      MD_TBL3
 28119 00006487 03                  <1> 		DB	03
 28120                              <1>                 ;DW	MD_TBL4
 28121 00006488 [BD640000]          <1> 		dd      MD_TBL4
 28122 0000648C 84                  <1> 		DB	04+BIT7ON
 28123                              <1>                 ;DW	MD_TBL5
 28124 0000648D [CA640000]          <1> 		dd      MD_TBL5
 28125 00006491 04                  <1> 		DB	04
 28126                              <1>                 ;DW	MD_TBL6
 28127 00006492 [D7640000]          <1> 		dd      MD_TBL6
 28128                              <1> DR_TYPE_E       equ $                   ; END OF TABLE
 28129                              <1> ;DR_CNT		EQU	(DR_TYPE_E-DR_TYPE)/3
 28130                              <1> DR_CNT		equ	(DR_TYPE_E-DR_TYPE)/5
 28131                              <1> ;--------------------------------------------------------
 28132                              <1> ;	MEDIA/DRIVE PARAMETER TABLES			:
 28133                              <1> ;--------------------------------------------------------
 28134                              <1> ;--------------------------------------------------------
 28135                              <1> ;	360 KB MEDIA IN 360 KB DRIVE			:
 28136                              <1> ;--------------------------------------------------------
 28137                              <1> MD_TBL1:        
 28138 00006496 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28139 00006497 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28140 00006498 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28141 00006499 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28142 0000649A 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
 28143 0000649B 2A                  <1> 	DB	02AH		; GAP LENGTH
 28144 0000649C FF                  <1> 	DB	0FFH		; DTL
 28145 0000649D 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
 28146 0000649E F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28147 0000649F 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28148 000064A0 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28149 000064A1 27                  <1> 	DB	39		; MAX. TRACK NUMBER
 28150 000064A2 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
 28151                              <1> ;--------------------------------------------------------
 28152                              <1> ;	360 KB MEDIA IN 1.2 MB DRIVE			:
 28153                              <1> ;--------------------------------------------------------
 28154                              <1> MD_TBL2:        
 28155 000064A3 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28156 000064A4 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28157 000064A5 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28158 000064A6 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28159 000064A7 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
 28160 000064A8 2A                  <1> 	DB	02AH		; GAP LENGTH
 28161 000064A9 FF                  <1> 	DB	0FFH		; DTL
 28162 000064AA 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
 28163 000064AB F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28164 000064AC 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28165 000064AD 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28166 000064AE 27                  <1> 	DB	39		; MAX. TRACK NUMBER
 28167 000064AF 40                  <1> 	DB	RATE_300	; DATA TRANSFER RATE
 28168                              <1> ;--------------------------------------------------------
 28169                              <1> ;	1.2 MB MEDIA IN 1.2 MB DRIVE			:
 28170                              <1> ;--------------------------------------------------------
 28171                              <1> MD_TBL3:
 28172 000064B0 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28173 000064B1 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28174 000064B2 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28175 000064B3 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28176 000064B4 0F                  <1> 	DB	15		; EOT (LAST SECTOR ON TRACK)
 28177 000064B5 1B                  <1> 	DB	01BH		; GAP LENGTH
 28178 000064B6 FF                  <1> 	DB	0FFH		; DTL
 28179 000064B7 54                  <1> 	DB	054H		; GAP LENGTH FOR FORMAT
 28180 000064B8 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28181 000064B9 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28182 000064BA 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28183 000064BB 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
 28184 000064BC 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
 28185                              <1> ;--------------------------------------------------------
 28186                              <1> ;	720 KB MEDIA IN 720 KB DRIVE			:
 28187                              <1> ;--------------------------------------------------------
 28188                              <1> MD_TBL4:
 28189 000064BD DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28190 000064BE 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28191 000064BF 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28192 000064C0 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28193 000064C1 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
 28194 000064C2 2A                  <1> 	DB	02AH		; GAP LENGTH
 28195 000064C3 FF                  <1> 	DB	0FFH		; DTL
 28196 000064C4 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
 28197 000064C5 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28198 000064C6 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28199 000064C7 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28200 000064C8 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
 28201 000064C9 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
 28202                              <1> ;--------------------------------------------------------
 28203                              <1> ;	720 KB MEDIA IN 1.44 MB DRIVE			:
 28204                              <1> ;--------------------------------------------------------
 28205                              <1> MD_TBL5:
 28206 000064CA DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28207 000064CB 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28208 000064CC 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28209 000064CD 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28210 000064CE 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
 28211 000064CF 2A                  <1> 	DB	02AH		; GAP LENGTH
 28212 000064D0 FF                  <1> 	DB	0FFH		; DTL
 28213 000064D1 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
 28214 000064D2 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28215 000064D3 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28216 000064D4 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28217 000064D5 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
 28218 000064D6 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
 28219                              <1> ;--------------------------------------------------------
 28220                              <1> ;	1.44 MB MEDIA IN 1.44 MB DRIVE			:
 28221                              <1> ;--------------------------------------------------------
 28222                              <1> MD_TBL6:
 28223 000064D7 AF                  <1> 	DB	10101111B	; SRT=A, HD UNLOAD=0F - 1ST SPECIFY BYTE
 28224 000064D8 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
 28225 000064D9 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
 28226 000064DA 02                  <1> 	DB	2		; 512 BYTES/SECTOR
 28227 000064DB 12                  <1> 	DB	18		; EOT (LAST SECTOR ON TRACK)
 28228 000064DC 1B                  <1> 	DB	01BH		; GAP LENGTH
 28229 000064DD FF                  <1> 	DB	0FFH		; DTL
 28230 000064DE 6C                  <1> 	DB	06CH		; GAP LENGTH FOR FORMAT
 28231 000064DF F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
 28232 000064E0 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
 28233 000064E1 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
 28234 000064E2 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
 28235 000064E3 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
 28236                              <1> 
 28237                              <1> 
 28238                              <1> ; << diskette.inc >>
 28239                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 28240                              <1> ;
 28241                              <1> ;----------------------------------------
 28242                              <1> ;	ROM BIOS DATA AREAS		:
 28243                              <1> ;----------------------------------------
 28244                              <1> 
 28245                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
 28246                              <1> 
 28247                              <1> ;----------------------------------------
 28248                              <1> ;	FIXED DISK DATA AREAS		:
 28249                              <1> ;----------------------------------------
 28250                              <1> 
 28251                              <1> ;DISK_STATUS1:	DB	0		; FIXED DISK STATUS
 28252                              <1> ;HF_NUM:	DB	0		; COUNT OF FIXED DISK DRIVES
 28253                              <1> ;CONTROL_BYTE:	DB	0		; HEAD CONTROL BYTE
 28254                              <1> ;@PORT_OFF	DB	?		; RESERVED (PORT OFFSET)
 28255                              <1> 
 28256                              <1> ;----------------------------------------
 28257                              <1> ;	ADDITIONAL MEDIA DATA		:
 28258                              <1> ;----------------------------------------
 28259                              <1> 
 28260                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
 28261                              <1> ;HF_STATUS	DB	0		; STATUS REGISTER
 28262                              <1> ;HF_ERROR	DB	0		; ERROR REGISTER
 28263                              <1> ;HF_INT_FLAG	DB	0		; FIXED DISK INTERRUPT FLAG
 28264                              <1> ;HF_CNTRL	DB	0		; COMBO FIXED DISK/DISKETTE CARD BIT 0=1
 28265                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
 28266                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
 28267                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
 28268                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
 28269                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
 28270                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
 28271                              <1> 
 28272                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
 28273                              <1> ;
 28274                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 28275                              <1> 
 28276                              <1> ERR_TBL:
 28277 000064E4 E0                  <1> 	db	NO_ERR
 28278 000064E5 024001BB            <1> 	db	BAD_ADDR_MARK,BAD_SEEK,BAD_CMD,UNDEF_ERR
 28279 000064E9 04BB100A            <1> 	db	RECORD_NOT_FND,UNDEF_ERR,BAD_ECC,BAD_SECTOR
 28280                              <1> 
 28281                              <1> ; 06/08/2022
 28282                              <1> ; 17/12/2014 (mov ax, [cfd])
 28283                              <1> ; 11/12/2014
 28284                              <1> ;cfd:		db	0		; current floppy drive (for GET_PARM)
 28285                              <1> ; 17/12/2014				; instead of 'DISK_POINTER'
 28286                              <1> ;pfd:		db	1		; previous floppy drive (for GET_PARM)
 28287                              <1> 					; (initial value of 'pfd 
 28288                              <1> 					; must be different then 'cfd' value
 28289                              <1> 					; to force updating/initializing
 28290                              <1> 					; current drive parameters) 
 28291                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 28292                              <1> ; 11/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
 28293 000064ED FF                  <1> pfd:		db	0FFh
 28294                              <1> 
 28295                              <1> align 2
 28296                              <1> 
 28297 000064EE F001                <1> HF_PORT:	dw 	1F0h  ; Default = 1F0h
 28298                              <1> 			      ; (170h)
 28299 000064F0 F603                <1> HF_REG_PORT:	dw	3F6h  ; HF_PORT + 206h
 28300                              <1> 
 28301                              <1> ; 05/01/2015 
 28302 000064F2 00                  <1> hf_m_s:         db      0     ; (0 = Master, 1 = Slave)
 28303                              <1> 
 28304                              <1> ; *****************************************************************************
 28305                                  
 28306 000064F3 90                      Align 2
 28307                                  
 28308                                  ; 04/11/2014 (Retro UNIX 386 v1)
 28309 000064F4 0000                    mem_1m_1k:   dw 0  ; Number of contiguous KB between
 28310                                  		   ; 1 and 16 MB, max. 3C00h = 15 MB.
 28311 000064F6 0000                    mem_16m_64k: dw 0  ; Number of contiguous 64 KB blocks
 28312                                  		   ; between 16 MB and 4 GB.
 28313                                  
 28314                                  ; 12/11/2014 (Retro UNIX 386 v1)
 28315 000064F8 00                      boot_drv:    db 0  ; boot drive number (physical)
 28316                                  ; 24/11/2014
 28317 000064F9 00                      drv:	     db 0 
 28318 000064FA 00                      last_drv:    db 0  ; last hdd
 28319 000064FB 00                      hdc:         db 0  ; number of hard disk drives
 28320                                  		   ; (present/detected)
 28321                                  
 28322                                  ; 24/11/2014 (Retro UNIX 386 v1)
 28323                                  ; Physical drive type & flags
 28324 000064FC 00                      fd0_type:    db 0  ; floppy drive type
 28325 000064FD 00                      fd1_type:    db 0  ; 4 = 1.44 Mb, 80 track, 3.5" (18 spt)
 28326                                  		   ; 6 = 2.88 Mb, 80 track, 3.5" (36 spt)
 28327                                  		   ; 3 = 720 Kb, 80 track, 3.5" (9 spt)
 28328                                  		   ; 2 = 1.2 Mb, 80 track, 5.25" (15 spt)
 28329                                  		   ; 1 = 360 Kb, 40 track, 5.25" (9 spt)		
 28330 000064FE 00                      hd0_type:    db 0  ; EDD status for hd0 (bit 7 = present flag)
 28331 000064FF 00                      hd1_type:    db 0  ; EDD status for hd1 (bit 7 = present flag)
 28332 00006500 00                      hd2_type:    db 0  ; EDD status for hd2 (bit 7 = present flag)
 28333 00006501 00                      hd3_type:    db 0  ; EDD status for hd3 (bit 7 = present flag)
 28334                                  		   ; bit 0 = Fixed disk access subset supported
 28335                                  		   ; bit 1 = Drive locking and ejecting
 28336                                  		   ; bit 2 = Enhanced disk drive support
 28337                                  		   ; bit 3 = Reserved (64 bit EDD support)
 28338                                  		   ; (If bit 0 is '1' Retro UNIX 386 v1
 28339                                  		   ; will interpret it as 'LBA ready'!)
 28340                                  
 28341                                  ; 08/08/2022
 28342                                  ; (drv.cylinders, drv.spt, drv.spt will not be used now on)
 28343                                  ; ('diskio.inc')
 28344                                  ; ((spt and heads and cylinder counts will be taken from DPT))
 28345                                  
 28346                                  ; 11/03/2015 - 10/07/2015
 28347                                  ;drv.cylinders: dw 0,0,0,0,0,0,0
 28348                                  ;drv.heads:     dw 0,0,0,0,0,0,0
 28349                                  ;drv.spt:       dw 0,0,0,0,0,0,0
 28350                                  ; 12/07/2022 - 11/03/2015
 28351 00006502 000000000000000000-     drv.size:      dd 0,0,0,0,0,0,0
 28352 0000650B 000000000000000000-
 28353 00006514 000000000000000000-
 28354 0000651D 00                 
 28355 0000651E 00000000000000          drv.status:    db 0,0,0,0,0,0,0
 28356 00006525 00000000000000          drv.error:     db 0,0,0,0,0,0,0
 28357                                  ;
 28358                                  
 28359                                  Align 2
 28360                                  
 28361                                  ;;; 11/03/2015
 28362                                  %include 'kybdata.s'	; KEYBOARD (BIOS) DATA
 28363                              <1> ; ****************************************************************************
 28364                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - kybdata.s
 28365                              <1> ; ----------------------------------------------------------------------------
 28366                              <1> ; Last Update: 24/07/2022 (Previous: 17/01/2016)
 28367                              <1> ; ----------------------------------------------------------------------------
 28368                              <1> ; Beginning: 17/01/2016
 28369                              <1> ; ----------------------------------------------------------------------------
 28370                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 28371                              <1> ; ----------------------------------------------------------------------------
 28372                              <1> ; Turkish Rational DOS
 28373                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 28374                              <1> ;
 28375                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 28376                              <1> ; kybdata.inc (11/03/2015)
 28377                              <1> ;
 28378                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
 28379                              <1> ; ****************************************************************************
 28380                              <1> 
 28381                              <1> ; Retro UNIX 386 v1 Kernel - KYBDATA.INC
 28382                              <1> ; Last Modification: 11/03/2015
 28383                              <1> ;		 (Data Section for 'KEYBOARD.INC')	
 28384                              <1> ;
 28385                              <1> ; ///////// KEYBOARD DATA ///////////////
 28386                              <1> 
 28387                              <1> ; 24/07/2022 - TRDOS 386 Kernel v2.0.5
 28388                              <1> ; 05/12/2014
 28389                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-) 
 28390                              <1> ; 03/06/86  KEYBOARD BIOS
 28391                              <1> 
 28392                              <1> ;---------------------------------------------------------------------------------
 28393                              <1> ;	KEY IDENTIFICATION SCAN TABLES
 28394                              <1> ;---------------------------------------------------------------------------------
 28395                              <1> 
 28396                              <1> ;-----	TABLES FOR ALT CASE ------------
 28397                              <1> ;-----	ALT-INPUT-TABLE 
 28398 0000652C 524F50514B          <1> K30:	db	82,79,80,81,75
 28399 00006531 4C4D474849          <1> 	db	76,77,71,72,73		; 10 NUMBER ON KEYPAD
 28400                              <1> ;-----	SUPER-SHIFT-TABLE 
 28401 00006536 101112131415        <1> 	db	16,17,18,19,20,21	; A-Z TYPEWRITER CHARS
 28402 0000653C 161718191E1F        <1> 	db	22,23,24,25,30,31
 28403 00006542 202122232425        <1> 	db	32,33,34,35,36,37
 28404 00006548 262C2D2E2F30        <1> 	db	38,44,45,46,47,48
 28405 0000654E 3132                <1> 	db	49,50
 28406                              <1> 
 28407                              <1> ;-----	TABLE OF SHIFT KEYS AND MASK VALUES
 28408                              <1> ;-----	KEY_TABLE 
 28409 00006550 52                  <1> _K6:    db      INS_KEY                 ; INSERT KEY
 28410 00006551 3A4546381D          <1> 	db	CAPS_KEY,NUM_KEY,SCROLL_KEY,ALT_KEY,CTL_KEY
 28411 00006556 2A36                <1>         db      LEFT_KEY,RIGHT_KEY
 28412                              <1> _K6L    equ     $-_K6
 28413                              <1> 
 28414                              <1> ;-----	MASK_TABLE
 28415 00006558 80                  <1> _K7:    db      INS_SHIFT               ; INSERT MODE SHIFT
 28416 00006559 4020100804          <1> 	db	CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT,ALT_SHIFT,CTL_SHIFT
 28417 0000655E 0201                <1> 	db	LEFT_SHIFT,RIGHT_SHIFT
 28418                              <1> 
 28419                              <1> ;-----	TABLES FOR CTRL CASE		;---- CHARACTERS ------
 28420 00006560 1BFF00FFFFFF        <1> _K8:	db	27,-1,0,-1,-1,-1	; Esc, 1, 2, 3, 4, 5
 28421 00006566 1EFFFFFFFF1F        <1> 	db 	30,-1,-1,-1,-1,31	; 6, 7, 8, 9, 0, -
 28422                              <1> 	;db	-1,127,-1,17,23,5	; =, Bksp, Tab, Q, W, E
 28423 0000656C FF7F94111705        <1> 	db	-1,127,148,17,23,5 ; 24/07/2022
 28424 00006572 12141915090F        <1> 	db	18,20,25,21,9,15	; R, T, Y, U, I, O
 28425 00006578 101B1D0AFF01        <1> 	db	16,27,29,10,-1,1	; P, [, ], Enter, Ctrl, A
 28426 0000657E 13040607080A        <1> 	db	19,4,6,7,8,10		; S, D, F, G, H, J
 28427 00006584 0B0CFFFFFFFF        <1> 	db	11,12,-1,-1,-1,-1	; K, L, :, ', `, LShift
 28428 0000658A 1C1A18031602        <1> 	db	28,26,24,3,22,2		; Bkslash, Z, X, C, V, B
 28429 00006590 0E0DFFFFFFFF        <1> 	db	14,13,-1,-1,-1,-1	; N, M, ,, ., /, RShift
 28430 00006596 96FF20FF            <1> 	db	150,-1,' ',-1		; *, ALT, Spc, CL
 28431                              <1> 	;				;----- FUNCTIONS ------		
 28432 0000659A 5E5F60616263        <1> 	db 	94,95,96,97,98,99	; F1 - F6
 28433 000065A0 64656667FFFF        <1> 	db	100,101,102,103,-1,-1	; F7 - F10, NL, SL
 28434 000065A6 778D848E738F        <1> 	db	119,141,132,142,115,143	; Home, Up, PgUp, -, Left, Pad5
 28435 000065AC 749075917692        <1> 	db 	116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
 28436 000065B2 93FFFFFF898A        <1> 	db	147,-1,-1,-1,137,138	; Del, SysReq, Undef, WT, F11, F12
 28437                              <1> 
 28438                              <1> ;-----	TABLES FOR LOWER CASE ----------
 28439 000065B8 1B3132333435363738- <1> K10:	db 	27,'1234567890-=',8,9
 28440 000065C1 39302D3D0809        <1>
 28441 000065C7 71776572747975696F- <1> 	db 	'qwertyuiop[]',13,-1,'asdfghjkl;',39
 28442 000065D0 705B5D0DFF61736466- <1>
 28443 000065D9 67686A6B6C3B27      <1>
 28444 000065E0 60FF5C7A786376626E- <1> 	db	96,-1,92,'zxcvbnm,./',-1,'*',-1,' ',-1
 28445 000065E9 6D2C2E2FFF2AFF20FF  <1>
 28446                              <1> ;-----	LC TABLE SCAN
 28447 000065F2 3B3C3D3E3F          <1> 	db	59,60,61,62,63		; BASE STATE OF F1 - F10
 28448 000065F7 4041424344          <1> 	db	64,65,66,67,68
 28449 000065FC FFFF                <1> 	db	-1,-1			; NL, SL
 28450                              <1> 
 28451                              <1> ;-----	KEYPAD TABLE
 28452 000065FE 474849FF4BFF        <1> K15:	db	71,72,73,-1,75,-1	; BASE STATE OF KEYPAD KEYS
 28453 00006604 4DFF4F50515253      <1> 	db	77,-1,79,80,81,82,83
 28454 0000660B FFFF5C8586          <1> 	db	-1,-1,92,133,134	; SysRq, Undef, WT, F11, F12
 28455                              <1> 
 28456                              <1> ;-----	TABLES FOR UPPER CASE ----------
 28457 00006610 1B21402324255E262A- <1> K11:	db 	27,'!@#$%',94,'&*()_+',8,0
 28458 00006619 28295F2B0800        <1>
 28459 0000661F 51574552545955494F- <1> 	db 	'QWERTYUIOP{}',13,-1,'ASDFGHJKL:"'
 28460 00006628 507B7D0DFF41534446- <1>
 28461 00006631 47484A4B4C3A22      <1>
 28462 00006638 7EFF7C5A584356424E- <1> 	db	126,-1,'|ZXCVBNM<>?',-1,'*',-1,' ',-1
 28463 00006641 4D3C3E3FFF2AFF20FF  <1>
 28464                              <1> ;-----	UC TABLE SCAN
 28465 0000664A 5455565758          <1> K12:	db	84,85,86,87,88		; SHIFTED STATE OF F1 - F10
 28466 0000664F 595A5B5C5D          <1> 	db	89,90,91,92,93
 28467 00006654 FFFF                <1> 	db	-1,-1			; NL, SL
 28468                              <1> 
 28469                              <1> ;-----	NUM STATE TABLE
 28470 00006656 3738392D3435362B31- <1> K14:	db 	'789-456+1230.'		; NUMLOCK STATE OF KEYPAD KEYS
 28471 0000665F 3233302E            <1>
 28472                              <1> 	;
 28473 00006663 FFFF7C8788          <1> 	db	-1,-1,124,135,136	; SysRq, Undef, WT, F11, F12
 28474                              <1> 
 28475                              <1> ; 26/08/2014
 28476                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (03/03/2014)
 28477                              <1> ; Derived from IBM "pc-at" 
 28478                              <1> ; rombios source code (06/10/1985)
 28479                              <1> ; 'dseg.inc'
 28480                              <1> 
 28481                              <1> ;---------------------------------------;
 28482                              <1> ;	SYSTEM DATA AREA		;
 28483                              <1> ;----------------------------------------
 28484 00006668 00                  <1> BIOS_BREAK	db	0		; BIT 7=1 IF BREAK KEY HAS BEEN PRESSED
 28485                              <1> 
 28486                              <1> ;----------------------------------------
 28487                              <1> ;	KEYBOARD DATA AREAS		;
 28488                              <1> ;----------------------------------------
 28489                              <1> 
 28490 00006669 00                  <1> KB_FLAG		db	0		; KEYBOARD SHIFT STATE AND STATUS FLAGS
 28491 0000666A 00                  <1> KB_FLAG_1	db	0		; SECOND BYTE OF KEYBOARD STATUS
 28492 0000666B 00                  <1> KB_FLAG_2	db	0		; KEYBOARD LED FLAGS
 28493 0000666C 00                  <1> KB_FLAG_3	db	0		; KEYBOARD MODE STATE AND TYPE FLAGS
 28494 0000666D 00                  <1> ALT_INPUT	db	0		; STORAGE FOR ALTERNATE KEY PAD ENTRY
 28495 0000666E [7E660000]          <1> BUFFER_START	dd	KB_BUFFER 	; OFFSET OF KEYBOARD BUFFER START
 28496 00006672 [9E660000]          <1> BUFFER_END	dd	KB_BUFFER + 32	; OFFSET OF END OF BUFFER
 28497 00006676 [7E660000]          <1> BUFFER_HEAD	dd	KB_BUFFER 	; POINTER TO HEAD OF KEYBOARD BUFFER
 28498 0000667A [7E660000]          <1> BUFFER_TAIL	dd	KB_BUFFER 	; POINTER TO TAIL OF KEYBOARD BUFFER
 28499                              <1> ; ------	HEAD = TAIL INDICATES THAT THE BUFFER IS EMPTY
 28500 0000667E 0000<rept>          <1> KB_BUFFER	times	16 dw 0		; ROOM FOR 16 SCAN CODE ENTRIES
 28501                              <1> 
 28502                              <1> ; /// End Of KEYBOARD DATA ///
 28503                                  %include 'vidata.s'	; VIDEO (BIOS) DATA
 28504                              <1> ; ****************************************************************************
 28505                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vidata.s
 28506                              <1> ; ----------------------------------------------------------------------------
 28507                              <1> ; Last Update: 24/11/2020
 28508                              <1> ; ----------------------------------------------------------------------------
 28509                              <1> ; Beginning: 16/01/2016
 28510                              <1> ; ----------------------------------------------------------------------------
 28511                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 28512                              <1> ; ----------------------------------------------------------------------------
 28513                              <1> ; Turkish Rational DOS
 28514                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 28515                              <1> ;
 28516                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 28517                              <1> ; vidata.inc (11/03/2015)
 28518                              <1> ;
 28519                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
 28520                              <1> ; ****************************************************************************
 28521                              <1> 
 28522                              <1> ; Retro UNIX 386 v1 Kernel - VIDATA.S
 28523                              <1> ; Last Modification: 11/03/2015
 28524                              <1> ;		    (Data section for 'VIDEO.INC')	
 28525                              <1> ;
 28526                              <1> ; ///////// VIDEO DATA ///////////////
 28527                              <1> 
 28528                              <1> ;----------------------------------------
 28529                              <1> ;	VIDEO DISPLAY DATA AREA		;
 28530                              <1> ;----------------------------------------
 28531 0000669E 03                  <1> CRT_MODE:	db	3	; CURRENT DISPLAY MODE (TYPE)
 28532 0000669F 29                  <1> CRT_MODE_SET:	db	29h	; CURRENT SETTING OF THE 3X8 REGISTER
 28533                              <1> 				; (29h default setting for video mode 3)
 28534                              <1> 				; Mode Select register Bits
 28535                              <1> 				;   BIT 0 - 80x25 (1), 40x25 (0)
 28536                              <1> 				;   BIT 1 - ALPHA (0), 320x200 GRAPHICS (1)
 28537                              <1> 				;   BIT 2 - COLOR (0), BW (1)
 28538                              <1> 				;   BIT 3 - Video Sig. ENABLE (1), DISABLE (0)
 28539                              <1> 				;   BIT 4 - 640x200 B&W Graphics Mode (1)
 28540                              <1> 				;   BIT 5 - ALPHA mode BLINKING (1)
 28541                              <1> 				;   BIT 6, 7 - Not Used
 28542                              <1> 
 28543                              <1> ; Mode 0 - 2Ch = 101100b	; 40x25 text, 16 gray colors
 28544                              <1> ; Mode 1 - 28h = 101000b	; 40x25 text, 16 fore colors, 8 back colors
 28545                              <1> ; Mode 2 - 2Dh = 101101b	; 80x25 text, 16 gray colors	
 28546                              <1> ; Mode 3 - 29h = 101001b	; 80x25 text, 16 fore color, 8 back color
 28547                              <1> ; Mode 4 - 2Ah = 101010b	; 320x200 graphics, 4 colors
 28548                              <1> ; Mode 5 - 2Eh = 101110b	; 320x200 graphics, 4 gray colors
 28549                              <1> ; Mode 6 - 1Eh = 011110b	; 640x200 graphics, 2 colors
 28550                              <1> ; Mode 7 - 29h = 101001b	; 80x25 text, black & white colors
 28551                              <1> ; Mode & 37h = Video signal OFF
 28552                              <1> 
 28553                              <1> ; 24/06/2016
 28554 000066A0 50                  <1> CRT_COLS:	db	80	; Number of columns
 28555                              <1> 
 28556                              <1> ; 01/07/2016
 28557 000066A1 00                  <1> CRT_PALETTE:	db 	0	; Current palette setting
 28558                              <1> 
 28559                              <1> ; 03/07/2016
 28560 000066A2 10                  <1> CHAR_HEIGHT:	db	16	; Default character height
 28561 000066A3 60                  <1> VGA_VIDEO_CTL:	db	60h	; ROM BIOS DATA AREA Offset 87h
 28562 000066A4 F9                  <1> VGA_SWITCHES:	db 	0F9h	; Feature Bit Switches (the basic screen)
 28563 000066A5 51                  <1> VGA_MODESET_CTL: db	051h	; Basic mode set options (VGA video flags)
 28564                              <1> 				; ROM BIOS DATA AREA Offset 89h
 28565                              <1> 				; Bit 7, 4 : Mode
 28566                              <1> 				;	  01 : 400-line mode
 28567                              <1> 				; Bit 6	: Display switch enabled = 1			
 28568                              <1> 				; Bit 5	: Reserved = 0
 28569                              <1> 				; Bit 3	: Default palette loading 
 28570                              <1> 				;	  disabled = 0
 28571                              <1> 				; Bit 2 : Color monitor = 0
 28572                              <1> 				; Bit 1 = Gray scale summing 
 28573                              <1> 				;	  disabled = 0
 28574                              <1> 				; Bit 0 = VGA active = 1
 28575 000066A6 19                  <1> VGA_ROWS:	db	25
 28576                              <1> 
 28577                              <1> ; 16/01/2016
 28578                              <1> chr_attrib:  ; Character color/attributes for video pages (0 to 7)
 28579 000066A7 0707070707070707    <1> 	db	07h, 07h, 07h, 07h, 07h, 07h, 07h, 07h
 28580                              <1> ; 30/01/2016
 28581                              <1> vmode:
 28582 000066AF 0303030303030303    <1> 	db	3,3,3,3,3,3,3,3 ; video modes for pseudo screens 
 28583                              <1> 
 28584                              <1> CURSOR_MODE: ; cursor start (ch) = 14, cursor end (cl) = 15
 28585 000066B7 0F0E                <1> 	db	15, 14 ; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
 28586                              <1> 
 28587                              <1> ;align 4
 28588                              <1> ;VGA_BASE: ; 26/07/2016
 28589                              <1> ;	dd	 0B8000h  ; (Mode < 0Dh) or 0A0000h (mode >= 0Dh)
 28590                              <1> 
 28591 000066B9 90                  <1> align 2
 28592                              <1> 
 28593                              <1> vga_modes:
 28594                              <1> 	; 25/07/2016
 28595                              <1> 	; 09/07/2016
 28596                              <1> 	; 03/07/2016
 28597                              <1> 	; valid (implemented) video modes (>7, extension to IBM PC CGA modes)
 28598 000066BA 0302010007040506    <1> 	db 	03h, 02h, 01h, 00h, 07h, 04h, 05h, 06h
 28599                              <1> vga_g_modes: ; 31/07/2016
 28600 000066C2 13F0126A0D0E1011    <1> 	db	13h, 0F0h, 12h, 6Ah, 0Dh, 0Eh, 10h, 11h
 28601                              <1> vga_mode_count equ $ - vga_modes
 28602                              <1> vga_g_mode_count equ $ - vga_g_modes
 28603                              <1> 
 28604                              <1> vga_mode_tbl_ptr:
 28605                              <1> 	; 25/07/2016
 28606 000066CA [2A670000]          <1> 	dd	vga_mode_03h
 28607 000066CE [2A670000]          <1> 	dd	vga_mode_03h ; mode 02h -> mode 03h 
 28608 000066D2 [6A670000]          <1> 	dd	vga_mode_01h
 28609 000066D6 [6A670000]          <1> 	dd	vga_mode_01h ; mode 00h -> mode 01h
 28610                              <1> 	;dd	vga_mode_07h
 28611 000066DA [2A670000]          <1> 	dd	vga_mode_03h ; mode 07h -> mode 03h
 28612 000066DE [AA670000]          <1> 	dd	vga_mode_04h
 28613 000066E2 [AA670000]          <1> 	dd	vga_mode_04h ; mode 05h -> mode 04h	
 28614 000066E6 [EA670000]          <1> 	dd	vga_mode_06h
 28615 000066EA [2A680000]          <1> 	dd	vga_mode_13h
 28616 000066EE [6A680000]          <1> 	dd	vga_mode_F0h
 28617 000066F2 [AA680000]          <1> 	dd	vga_mode_12h
 28618 000066F6 [EA680000]          <1> 	dd	vga_mode_6Ah
 28619 000066FA [2A690000]          <1> 	dd	vga_mode_0Dh
 28620 000066FE [6A690000]          <1> 	dd	vga_mode_0Eh
 28621 00006702 [AA690000]          <1> 	dd	vga_mode_10h
 28622 00006706 [EA690000]          <1> 	dd	vga_mode_11h	
 28623                              <1> 
 28624                              <1> vga_memmodel: 
 28625                              <1> 	; 25/07/2016
 28626                              <1> 	; 07/07/2016
 28627                              <1> 	CTEXT	equ 0
 28628                              <1> 	;MTEXT	equ 1
 28629                              <1> 	MTEXT	equ 0 ; mode 07h -> mode 03h
 28630                              <1> 	CGA	equ 2
 28631                              <1> 	LINEAR8 equ 5
 28632                              <1> 	PLANAR4	equ 4
 28633                              <1> 	PLANAR1	equ 3
 28634 0000670A 0000000000020202    <1> 	db	CTEXT, CTEXT, CTEXT, CTEXT, MTEXT, CGA, CGA, CGA
 28635                              <1> vga_g_memmodel: ; 31/07/2016
 28636 00006712 0504040404040403    <1> 	db	LINEAR8, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR1
 28637                              <1> ;vga_pixbits:
 28638                              <1> ;	; 25/07/2016
 28639                              <1> ;	; 08/07/2016
 28640                              <1> ;	db 	4, 4, 4, 4, 4, 2, 2, 1, 8, 4, 4, 4, 4, 4, 4, 1
 28641                              <1> vga_dac_s:
 28642 0000671A 020202020001010103- <1> 	db	2, 2, 2, 2, 0, 1, 1, 1, 3, 3, 2, 2, 1, 1, 2, 2  
 28643 00006723 03020201010202      <1>
 28644                              <1> 						; (vgatables.h, VGAMODES, dac) 
 28645                              <1> 						; 17/11/2020
 28646                              <1> vga_params:
 28647                              <1> 	; 23/11/2020
 28648                              <1> 	; 16/11/2020
 28649                              <1> 	; 09/11/2020, 10/11/2020, 11/11/2020 (TRDOS 386 v2.0.3)
 28650                              <1> 	; 25/07/2016 
 28651                              <1> 	; 19/07/2016
 28652                              <1> 	; 03/07/2016
 28653                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
 28654                              <1> 	; vgabios-0.7a (2011)
 28655                              <1> 	; by the LGPL VGABios Developers Team (2001-2008)
 28656                              <1> 	; 'vgatables.h'
 28657                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
 28658                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
 28659                              <1> 
 28660                              <1> 	; 09/11/2020
 28661                              <1> 	; Block Structure of Video Parameter Table
 28662                              <1> 	;
 28663                              <1> 	; Offset	# Bytes		Contents
 28664                              <1> 	;
 28665                              <1> 	;  0		1		# columns
 28666                              <1> 	;  1		1  		# rows - 1 
 28667                              <1> 	;  2		1		Pixels/character
 28668                              <1> 	;  3-4		2		Page length		
 28669                              <1> 	;  5-8		4		Sequencer Registers
 28670                              <1> 	;  9		1		Miscellaneous Register	
 28671                              <1> 	;  10-34	25		CRTC Registers
 28672                              <1> 	;  35-54	20		Attribute Registers
 28673                              <1> 	;  55-63	9		Graphics Controller Registers
 28674                              <1> 	;
 28675                              <1> 	; Ref: Programmer's Guide to EGA, VGA, and Super VGA cards
 28676                              <1> 	; (Richard F. Ferraro, 1994)  
 28677                              <1> 
 28678                              <1> 	;
 28679                              <1> vga_mode_03h:  ; mode 03h, 80*25 text, CGA colors
 28680                              <1> 	; 11/11/2020
 28681 0000672A 5018100010          <1>  	db	80, 24, 16, 00h, 10h ; tw, th-1, ch, slength (5)
 28682 0000672F 00030002            <1>  	db	00h, 03h, 00h, 02h ; sequ regs (4)
 28683 00006733 67                  <1>  	db	67h	; misc reg (1)
 28684 00006734 5F4F50825581BF1F    <1>  	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
 28685                              <1>  	; 09/11/2020
 28686                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
 28687 0000673C 004F                <1> 	db	00h, 4Fh
 28688                              <1> vga_p_cm_pos equ $ - vga_mode_03h
 28689 0000673E 0D0E00000000        <1> 	db	0Dh, 0Eh, 00h, 00h, 00h, 00h
 28690 00006744 9C8E8F281F96B9A3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 1Fh, 96h, 0B9h, 0A3h
 28691 0000674C FF                  <1> 	db	0FFh	; crtc_regs (25)
 28692 0000674D 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
 28693 00006755 38393A3B3C3D3E3F    <1>  	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
 28694                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
 28695 0000675D 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
 28696 00006761 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs (9)
 28697                              <1> 	; 09/11/2020
 28698                              <1> 	;db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 00h, 0FFh ; grdc regs (9)
 28699                              <1> vga_mode_01h:	; mode 01h, 40*25 text, CGA colors
 28700 0000676A 2818100008          <1> 	db	40, 24, 16, 00h, 08h ; tw, th-1, ch, slength
 28701 0000676F 08030002            <1> 	db	08h, 03h, 00h, 02h  ; sequ regs
 28702 00006773 67                  <1> 	db	67h	; misc reg
 28703 00006774 2D2728902BA0BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 0A0h, 0BFh, 1Fh
 28704 0000677C 004F0D0E00000000    <1> 	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
 28705 00006784 9C8E8F141F96B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 1Fh, 96h, 0B9h, 0A3h
 28706 0000678C FF                  <1> 	db	0FFh	; crtc_regs
 28707 0000678D 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
 28708 00006795 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
 28709                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
 28710 0000679D 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
 28711 000067A1 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs
 28712                              <1> ;vga_mode_07h:	; mode 07h, 80*25 text, mono color
 28713                              <1> ;	db	80, 24, 16, 00h, 10h  ; tw, th-1, ch, slength
 28714                              <1> ;	db	00h, 03h, 00h, 02h ; sequ regs
 28715                              <1> ;	db	66h	; misc reg
 28716                              <1> ;	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
 28717                              <1> ;	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
 28718                              <1> ;	db	9Ch, 8Eh, 8Fh, 28h, 0Fh, 96h, 0B9h, 0A3h
 28719                              <1> ;	db	0FFh	; crtc regs
 28720                              <1> ;	db	00h, 08h, 08h, 08h, 08h, 08h, 08h, 08h
 28721                              <1> ;	db	10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
 28722                              <1> ;	db	0Eh, 00h, 0Fh, 08h  ; actl regs
 28723                              <1> ;	db	00h, 00h, 00h, 00h, 00h, 10h, 0Ah, 0Fh, 0FFh ; grdc regs
 28724                              <1> vga_mode_04h:	; 320*200 graphics, 4 colors, CGA
 28725                              <1> 	; 11/11/2020
 28726 000067AA 2818080040          <1> 	db	40, 24, 8, 00h, 40h ; tw, th-1, ch, slength
 28727 000067AF 09030002            <1> 	db	09h, 03h, 00h, 02h ; sequ regs
 28728 000067B3 63                  <1> 	db	63h	; misc reg
 28729 000067B4 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
 28730 000067BC 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
 28731 000067C4 9C8E8F140096B9A2    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0A2h
 28732 000067CC FF                  <1> 	db	0FFh	; crtc_regs
 28733 000067CD 0013151702040607    <1> 	db	00h, 13h, 15h, 17h, 02h, 04h, 06h, 07h
 28734 000067D5 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
 28735 000067DD 01000300            <1> 	db	01h, 00h, 03h, 00h ; actl regs
 28736 000067E1 0000000000300F0FFF  <1> 	db 	00h, 00h, 00h, 00h, 00h, 30h, 0Fh, 0Fh, 0FFh ; grdc regs
 28737                              <1> vga_mode_06h:	; 640*200 graphics, 2 colors, CGA
 28738                              <1> 	; 11/11/2020
 28739 000067EA 5018080040          <1> 	db	80, 24, 8, 00h, 40h   ;	tw, th-1, ch, slength
 28740 000067EF 01010006            <1> 	db	01h, 01h, 00h, 06h ; sequ regs
 28741 000067F3 63                  <1> 	db	63h	; misc reg
 28742 000067F4 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
 28743 000067FC 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
 28744 00006804 9C8E8F280096B9C2    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0C2h
 28745 0000680C FF                  <1> 	db	0FFh	; crtc regs
 28746 0000680D 0017171717171717    <1> 	db	00h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
 28747 00006815 1717171717171717    <1> 	db	17h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
 28748 0000681D 01000100            <1> 	db	01h, 00h, 01, 00h  ; actl regs
 28749 00006821 0000000000000D0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 0Fh, 0FFh ; grdc regs
 28750                              <1> vga_mode_13h:  ; mode 13h, 300*200, 256 colors, linear
 28751                              <1> 	; 11/11/2020
 28752                              <1> 	;db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength (5)
 28753                              <1> 	; 23/11/2020 - 10/11/2020
 28754 0000682A 28180800FA          <1> 	db 	40, 24, 8, 00h, 0FAh ; tw, th-1, ch, slength (5)
 28755 0000682F 010F000E            <1> 	db	01h, 0Fh, 00h, 0Eh ; sequ regs (4)
 28756 00006833 63                  <1> 	db	63h	; misc reg (1)
 28757 00006834 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh 
 28758 0000683C 0041000000000000    <1> 	db 	00h, 041h, 00h, 00h, 00h, 00h, 00h, 00h
 28759 00006844 9C8E8F284096B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h
 28760 0000684C FF                  <1> 	db	0FFh	; crtc regs (25)
 28761 0000684D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
 28762 00006855 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
 28763 0000685D 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs (20)
 28764                              <1> 	; 10/11/2020
 28765                              <1>  	;db	41h, 01h, 0Fh, 13h  ; actl regs (20) 
 28766 00006861 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs (9)
 28767                              <1> vga_mode_setl equ $ - vga_mode_13h  ; = 64
 28768                              <1> vga_mode_F0h:  ; mode X ; 320*240, 256 colors, planar
 28769 0000686A 2818080000          <1> 	db 	40, 24, 8, 00h, 00h ; tw, th-1, ch, slength
 28770 0000686F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28771 00006873 E3                  <1> 	db	0E3h	; misc reg
 28772 00006874 5F4F508254800D3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Dh, 3Eh 
 28773 0000687C 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
 28774 00006884 EAACDF2800E706E3    <1> 	db	0EAh, 0ACh, 0DFh, 28h, 00h, 0E7h, 06h, 0E3h
 28775 0000688C FF                  <1> 	db	0FFh	; crtc regs (25)
 28776 0000688D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
 28777 00006895 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
 28778 0000689D 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs
 28779 000068A1 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs
 28780                              <1> vga_mode_12h:  ; mode 12h, 640*480, 16 colors, planar
 28781                              <1> 	; 11/11/2020
 28782                              <1>  	;db 	80, 29, 16, 0, 0 ; tw, th-1, ch, slength
 28783                              <1> 	; 09/11/2020
 28784 000068AA 501D1000A0          <1>  	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
 28785 000068AF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28786 000068B3 E3                  <1> 	db 	0E3h	; misc reg
 28787 000068B4 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
 28788                              <1> 	; 09/11/2020
 28789                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 53h, 9Fh, 0Bh, 3Eh
 28790 000068BC 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
 28791 000068C4 EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
 28792                              <1> 	; 09/11/2020
 28793                              <1>  	;db	0E9h, 8Bh, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
 28794 000068CC FF                  <1> 	db	0FFh	; crtc regs
 28795 000068CD 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
 28796 000068D5 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
 28797 000068DD 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28798 000068E1 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28799                              <1> vga_mode_6Ah:  ; mode 6Ah, 800*600, 16 colors, planar
 28800                              <1> 	; 11/11/2020
 28801 000068EA 6424100000          <1>  	db 	100, 36, 16, 00h, 00h ; tw, th-1, ch, slength
 28802 000068EF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28803 000068F3 E3                  <1> 	db 	0E3h	; misc reg
 28804 000068F4 7F6363836B1B72F0    <1> 	db	7Fh, 63h, 63h, 83h, 6Bh, 1Bh, 72h, 0F0h
 28805 000068FC 0060000000000000    <1> 	db	00h, 60h, 00h, 00h, 00h, 00h, 00h, 00h
 28806 00006904 598D5732005773E3    <1>  	db	59h, 8Dh, 57h, 32h, 00h, 57h, 73h, 0E3h
 28807 0000690C FF                  <1> 	db	0FFh	; crtc regs
 28808 0000690D 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
 28809 00006915 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
 28810 0000691D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28811 00006921 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28812                              <1> vga_mode_0Dh:  ; mode 0Dh, 320*200, 16 colors, planar
 28813 0000692A 2818080020          <1>  	db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength
 28814 0000692F 090F0006            <1> 	db	09h, 0Fh, 00h, 06h ; sequ regs
 28815 00006933 63                  <1> 	db 	63h	; misc reg
 28816 00006934 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
 28817 0000693C 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
 28818 00006944 9C8E8F140096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0E3h
 28819 0000694C FF                  <1> 	db	0FFh	; crtc regs
 28820 0000694D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
 28821 00006955 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
 28822 0000695D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28823 00006961 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28824                              <1> vga_mode_0Eh:  ; mode 0Eh, 640*200, 16 colors, planar
 28825 0000696A 5018080040          <1>  	db 	80, 24, 8, 00h, 40h ; tw, th-1, ch, slength
 28826 0000696F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28827 00006973 63                  <1> 	db 	63h	; misc reg
 28828 00006974 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
 28829 0000697C 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
 28830 00006984 9C8E8F280096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0E3h
 28831 0000698C FF                  <1> 	db	0FFh	; crtc regs
 28832 0000698D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
 28833 00006995 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
 28834 0000699D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28835 000069A1 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28836                              <1> vga_mode_10h: ; mode 10h, 640*350, 16 colors, planar
 28837 000069AA 50180E0080          <1>  	db 	80, 24, 14, 00h, 80h ; tw, th-1, ch, slength
 28838 000069AF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28839 000069B3 A3                  <1> 	db 	0A3h	; misc reg
 28840 000069B4 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
 28841 000069BC 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
 28842 000069C4 83855D280F63BAE3    <1>  	db	83h, 85h, 5Dh, 28h, 0Fh, 63h, 0BAh, 0E3h
 28843 000069CC FF                  <1> 	db	0FFh	; crtc regs
 28844 000069CD 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
 28845 000069D5 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
 28846 000069DD 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28847 000069E1 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28848                              <1> vga_mode_11h: ; mode 11h, 640*480, mono color, planar
 28849                              <1>  	; 11/11/2020
 28850 000069EA 501D1000A0          <1> 	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
 28851 000069EF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
 28852 000069F3 E3                  <1> 	db 	0E3h	; misc reg
 28853 000069F4 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
 28854 000069FC 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
 28855 00006A04 EA8CDF2800E704C3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0C3h ; 11/11/2020
 28856 00006A0C FF                  <1> 	db	0FFh	; crtc regs
 28857 00006A0D 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
 28858 00006A15 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
 28859 00006A1D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
 28860 00006A21 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
 28861                              <1> end_of_vga_params:
 28862                              <1> 
 28863                              <1> ; /// End Of VIDEO DATA ///
 28864                              <1> 
 28865                              <1> ; 23/11/2020
 28866                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
 28867                              <1> ;	for TRDOS 386 v2 kernel (video bios)  
 28868                              <1> 
 28869                              <1> ; vbetables.h by Volker Rupper (02/01/2020)
 28870                              <1> 
 28871                              <1> b_vbe_modes:
 28872                              <1> 	;/* standard VESA modes */	
 28873 00006A2A 0001800290010800    <1> 	dw 100h,  640, 400,  8
 28874 00006A32 01018002E0010800    <1> 	dw 101h,  640, 480,  8
 28875 00006A3A 0301200358020800    <1> 	dw 103h,  800, 600,  8
 28876 00006A42 0501000400030800    <1> 	dw 105h, 1024, 768,  8
 28877 00006A4A 0E014001C8001000    <1> 	dw 10Eh,  320, 200, 16
 28878 00006A52 0F014001C8001800    <1> 	dw 10Fh,  320, 200, 24
 28879 00006A5A 11018002E0011000    <1> 	dw 111h,  640, 480, 16
 28880 00006A62 12018002E0011800    <1> 	dw 112h,  640, 480, 24
 28881 00006A6A 1401200358021000    <1> 	dw 114h,  800, 600, 16
 28882 00006A72 1501200358021800    <1> 	dw 115h,  800, 600, 24
 28883 00006A7A 1701000400031000    <1> 	dw 117h, 1024, 768, 16
 28884 00006A82 1801000400031800    <1> 	dw 118h, 1024, 768, 24
 28885                              <1> 
 28886                              <1> ;/* BOCHS/PLEX86 'own' mode numbers */
 28887 00006A8A 40014001C8002000    <1> 	dw 140h,  320,  200, 32
 28888 00006A92 4101800290012000    <1> 	dw 141h,  640,  400, 32
 28889 00006A9A 42018002E0012000    <1> 	dw 142h,  640,  480, 32
 28890 00006AA2 4301200358022000    <1> 	dw 143h,  800,  600, 32
 28891 00006AAA 4401000400032000    <1> 	dw 144h, 1024,  768, 32
 28892 00006AB2 46014001C8000800    <1> 	dw 146h,  320,  200,  8
 28893 00006ABA 8D010005D0021000    <1> 	dw 18Dh, 1280,  720, 16
 28894 00006AC2 8E010005D0021800    <1> 	dw 18Eh, 1280,  720, 24
 28895 00006ACA 8F010005D0022000    <1> 	dw 18Fh, 1280,  720, 32
 28896 00006AD2 9001800738041000    <1> 	dw 190h, 1920, 1080, 16
 28897 00006ADA 9101800738041800    <1> 	dw 191h, 1920, 1080, 24
 28898 00006AE2 9201800738042000    <1> 	dw 192h, 1920, 1080, 32
 28899                              <1> 
 28900                              <1> end_of_b_vbe_modes:
 28901                              <1> 
 28902                              <1> MA1 equ VBE_MODE_ATTRIBUTE_SUPPORTED
 28903                              <1> MA2 equ VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE
 28904                              <1> MA3 equ VBE_MODE_ATTRIBUTE_COLOR_MODE
 28905                              <1> MA4 equ VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE
 28906                              <1> MA5 equ	VBE_MODE_ATTRIBUTE_GRAPHICS_MODE
 28907                              <1> 
 28908                              <1> MODE_ATTRIBUTES equ MA1|MA2|MA3|MA4|MA5
 28909                              <1> 
 28910                              <1> WA1 equ VBE_WINDOW_ATTRIBUTE_RELOCATABLE
 28911                              <1> WA2 equ	VBE_WINDOW_ATTRIBUTE_READABLE
 28912                              <1> WA3 equ VBE_WINDOW_ATTRIBUTE_WRITEABLE
 28913                              <1> 
 28914                              <1> WINA_ATTRIBUTES equ WA1|WA2|WA3
 28915                              <1> 
 28916                              <1> ; 24/11/2020
 28917                              <1> 
 28918                              <1> %if 0
 28919                              <1> 
 28920                              <1> MODE_INFO_LIST: 
 28921                              <1> 
 28922                              <1> ; 24/11/2020
 28923                              <1> ; '%if 0' disables 24 mode info tables here, until %endif 
 28924                              <1> ; ('set_mode_info_list' will set only 1 list for selected mode)
 28925                              <1> ; (Purpose: To save about 1 KB kernel size by removing fixed data)
 28926                              <1> 
 28927                              <1> 			dw	0100h ; 640x400x8 
 28928                              <1> ModeAttributes1: 	dw	MODE_ATTRIBUTES
 28929                              <1> WinAAttributes1: 	db	WINA_ATTRIBUTES
 28930                              <1> WinBAttributes1: 	db	0
 28931                              <1> WinGranularity1: 	dw	VBE_DISPI_BANK_SIZE_KB
 28932                              <1> WinSize1: 		dw	VBE_DISPI_BANK_SIZE_KB
 28933                              <1> WinASegment1:		dw	VGAMEM_GRAPH
 28934                              <1> WinBSegment1:		dw	0000h
 28935                              <1> WinFuncPtr1:		dd	0
 28936                              <1> BytesPerScanLine1: 	dw	640
 28937                              <1> XResolution1:		dw	640
 28938                              <1> YResolution1:		dw	400
 28939                              <1> XCharSize1:		db	8
 28940                              <1> YCharSize1:		db	16
 28941                              <1> NumberOfPlanes1: 	db	1
 28942                              <1> BitsPerPixel1:		db	8
 28943                              <1> NumberOfBanks1:		db	4
 28944                              <1> MemoryModel1:		db	VBE_MEMORYMODEL_PACKED_PIXEL
 28945                              <1> BankSize1:		db	0
 28946                              <1> NumberOfImagePages1: 	db	64
 28947                              <1> Reserved_page1:		db	0
 28948                              <1> RedMaskSize1:		db	0
 28949                              <1> RedFieldPosition1: 	db	0
 28950                              <1> GreenMaskSize1:		db	0
 28951                              <1> GreenFieldPosition1: 	db	0
 28952                              <1> BlueMaskSize1:		db	0
 28953                              <1> BlueFieldPosition1: 	db	0
 28954                              <1> RsvdMaskSize1: 		db	0
 28955                              <1> RsvdFieldPosition1: 	db	0
 28956                              <1> DirectColorModeInfo1: 	db	0
 28957                              <1> PhysBasePtr1:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 28958                              <1> OffScreenMemOffset1: 	dd	0
 28959                              <1> OffScreenMemSize1: 	dw	0
 28960                              <1> LinBytesPerScanLine1: 	dw	640
 28961                              <1> BnkNumberOfPages1: 	db	0
 28962                              <1> LinNumberOfPages1: 	db	0
 28963                              <1> LinRedMaskSize1:	db	0
 28964                              <1> LinRedFieldPosition1: 	db	0
 28965                              <1> LinGreenMaskSize1: 	db	0
 28966                              <1> LinGreenFieldPosition1: db	0
 28967                              <1> LinBlueMaskSize1: 	db	0
 28968                              <1> LinBlueFieldPosition1: 	db	0
 28969                              <1> LinRsvdMaskSize1: 	db	0
 28970                              <1> LinRsvdFieldPosition1: 	db	0
 28971                              <1> MaxPixelClock1:		dd	0
 28972                              <1> 
 28973                              <1> 			dw	0101h ; 640x480x8
 28974                              <1> ModeAttributes2: 	dw	MODE_ATTRIBUTES
 28975                              <1> WinAAttributes2: 	db	WINA_ATTRIBUTES
 28976                              <1> WinBAttributes2: 	db	0
 28977                              <1> WinGranularity2: 	dw	VBE_DISPI_BANK_SIZE_KB
 28978                              <1> WinSize2: 		dw	VBE_DISPI_BANK_SIZE_KB
 28979                              <1> WinASegment2:		dw	VGAMEM_GRAPH
 28980                              <1> WinBSegment2:		dw	0000h
 28981                              <1> WinFuncPtr2:		dd	0
 28982                              <1> BytesPerScanLine2:	dw	640
 28983                              <1> XResolution2:		dw	640
 28984                              <1> YResolution2:		dw	480
 28985                              <1> XCharSize2:		db	8
 28986                              <1> YCharSize2:		db	16
 28987                              <1> NumberOfPlanes2:	db	1
 28988                              <1> BitsPerPixel2:		db	8
 28989                              <1> NumberOfBanks2:		db	5
 28990                              <1> MemoryModel2:		db	VBE_MEMORYMODEL_PACKED_PIXEL
 28991                              <1> BankSize2:		db	0
 28992                              <1> NumberOfImagePages2:	db	53
 28993                              <1> Reserved_page2:		db	0
 28994                              <1> RedMaskSize2:		db	0
 28995                              <1> RedFieldPosition2:	db	0
 28996                              <1> GreenMaskSize2:		db	0
 28997                              <1> GreenFieldPosition2:	db	0
 28998                              <1> BlueMaskSize2:		db	0
 28999                              <1> BlueFieldPosition2:	db	0
 29000                              <1> RsvdMaskSize2:		db	0
 29001                              <1> RsvdFieldPosition2:	db	0
 29002                              <1> DirectColorModeInfo2:	db	0
 29003                              <1> PhysBasePtr2:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29004                              <1> OffScreenMemOffset2:	dd	0
 29005                              <1> OffScreenMemSize2:	dw	0
 29006                              <1> LinBytesPerScanLine2:	dw	640
 29007                              <1> BnkNumberOfPages2: 	db	0
 29008                              <1> LinNumberOfPages2: 	db	0
 29009                              <1> LinRedMaskSize2:	db	0
 29010                              <1> LinRedFieldPosition2: 	db	0
 29011                              <1> LinGreenMaskSize2: 	db	0
 29012                              <1> LinGreenFieldPosition2: db	0
 29013                              <1> LinBlueMaskSize2: 	db	0
 29014                              <1> LinBlueFieldPosition2: 	db	0
 29015                              <1> LinRsvdMaskSize2: 	db	0
 29016                              <1> LinRsvdFieldPosition2: 	db	0
 29017                              <1> MaxPixelClock2:		dd	0
 29018                              <1> 			
 29019                              <1> 			dw	0103h ; 800x600x8
 29020                              <1> ModeAttributes3: 	dw	MODE_ATTRIBUTES
 29021                              <1> WinAAttributes3: 	db	WINA_ATTRIBUTES
 29022                              <1> WinBAttributes3: 	db	0
 29023                              <1> WinGranularity3: 	dw	VBE_DISPI_BANK_SIZE_KB
 29024                              <1> WinSize3: 		dw	VBE_DISPI_BANK_SIZE_KB
 29025                              <1> WinASegment3:		dw	VGAMEM_GRAPH
 29026                              <1> WinBSegment3:		dw	0000h
 29027                              <1> WinFuncPtr3:		dd	0
 29028                              <1> BytesPerScanLine3:	dw	800
 29029                              <1> XResolution3:		dw	800
 29030                              <1> YResolution3:		dw	600
 29031                              <1> XCharSize3:		db	8
 29032                              <1> YCharSize3:		db	16
 29033                              <1> NumberOfPlanes3:	db	1
 29034                              <1> BitsPerPixel3:		db	8
 29035                              <1> NumberOfBanks3:		db	8
 29036                              <1> MemoryModel3:		db	VBE_MEMORYMODEL_PACKED_PIXEL
 29037                              <1> BankSize3:		db	0
 29038                              <1> NumberOfImagePages3:	db	33
 29039                              <1> Reserved_page3:		db	0
 29040                              <1> RedMaskSize3:		db	0
 29041                              <1> RedFieldPosition3:	db	0
 29042                              <1> GreenMaskSize3:		db	0
 29043                              <1> GreenFieldPosition3:	db	0
 29044                              <1> BlueMaskSize3:		db	0
 29045                              <1> BlueFieldPosition3:	db	0
 29046                              <1> RsvdMaskSize3:		db	0
 29047                              <1> RsvdFieldPosition3:	db	0
 29048                              <1> DirectColorModeInfo3:	db	0
 29049                              <1> PhysBasePtr3:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29050                              <1> OffScreenMemOffset3:	dd	0
 29051                              <1> OffScreenMemSize3:	dw	0
 29052                              <1> LinBytesPerScanLine3:	dw	800
 29053                              <1> BnkNumberOfPages3: 	db	0
 29054                              <1> LinNumberOfPages3: 	db	0
 29055                              <1> LinRedMaskSize3:	db	0
 29056                              <1> LinRedFieldPosition3: 	db	0
 29057                              <1> LinGreenMaskSize3: 	db	0
 29058                              <1> LinGreenFieldPosition: 	db	0
 29059                              <1> LinBlueMaskSize: 	db	0
 29060                              <1> LinBlueFieldPosition: 	db	0
 29061                              <1> LinRsvdMaskSize: 	db	0
 29062                              <1> LinRsvdFieldPosition: 	db	0
 29063                              <1> MaxPixelClock:		dd	0
 29064                              <1> 			
 29065                              <1> 			dw	0105h ; 1024x768x8
 29066                              <1> ModeAttributes4: 	dw	MODE_ATTRIBUTES
 29067                              <1> WinAAttributes4: 	db	WINA_ATTRIBUTES
 29068                              <1> WinBAttributes4: 	db	0
 29069                              <1> WinGranularity4: 	dw	VBE_DISPI_BANK_SIZE_KB
 29070                              <1> WinSize4: 		dw	VBE_DISPI_BANK_SIZE_KB
 29071                              <1> WinASegment4:		dw	VGAMEM_GRAPH
 29072                              <1> WinBSegment4:		dw	0000h
 29073                              <1> WinFuncPtr4:		dd	0
 29074                              <1> BytesPerScanLine4:	dw	1024
 29075                              <1> XResolution4:		dw	1024
 29076                              <1> YResolution4:		dw	768
 29077                              <1> XCharSize4:		db	8
 29078                              <1> YCharSize4:		db	16
 29079                              <1> NumberOfPlanes4:	db	1
 29080                              <1> BitsPerPixel4:		db	8
 29081                              <1> NumberOfBanks4:		db	12
 29082                              <1> MemoryModel4:		db	VBE_MEMORYMODEL_PACKED_PIXEL
 29083                              <1> BankSize4:		db	0
 29084                              <1> NumberOfImagePages4:	db	20
 29085                              <1> Reserved_page4:		db	0
 29086                              <1> RedMaskSize4:		db	0
 29087                              <1> RedFieldPosition4:	db	0
 29088                              <1> GreenMaskSize4:		db	0
 29089                              <1> GreenFieldPosition4:	db	0
 29090                              <1> BlueMaskSize4:		db	0
 29091                              <1> BlueFieldPosition4:	db	0
 29092                              <1> RsvdMaskSize4:		db	0
 29093                              <1> RsvdFieldPosition4:	db	0
 29094                              <1> DirectColorModeInfo4:	db	0
 29095                              <1> PhysBasePtr4:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29096                              <1> OffScreenMemOffset4:	dd	0
 29097                              <1> OffScreenMemSize4:	dw	0
 29098                              <1> LinBytesPerScanLine4:	dw	1024
 29099                              <1> BnkNumberOfPages4: 	db	0
 29100                              <1> LinNumberOfPages4: 	db	0
 29101                              <1> LinRedMaskSize4:	db	0
 29102                              <1> LinRedFieldPosition4: 	db	0
 29103                              <1> LinGreenMaskSize4: 	db	0
 29104                              <1> LinGreenFieldPosition4: db	0
 29105                              <1> LinBlueMaskSize4: 	db	0
 29106                              <1> LinBlueFieldPosition4: 	db	0
 29107                              <1> LinRsvdMaskSize4: 	db	0
 29108                              <1> LinRsvdFieldPosition4: 	db	0
 29109                              <1> MaxPixelClock4:		dd	0
 29110                              <1> 
 29111                              <1> 			dw	010Eh ; 320x200x16
 29112                              <1> ModeAttributes5: 	dw	MODE_ATTRIBUTES
 29113                              <1> WinAAttributes5: 	db	WINA_ATTRIBUTES
 29114                              <1> WinBAttributes5: 	db	0
 29115                              <1> WinGranularity5: 	dw	VBE_DISPI_BANK_SIZE_KB
 29116                              <1> WinSize5: 		dw	VBE_DISPI_BANK_SIZE_KB
 29117                              <1> WinASegment5:		dw	VGAMEM_GRAPH
 29118                              <1> WinBSegment5:		dw	0000h
 29119                              <1> WinFuncPtr5:		dd	0
 29120                              <1> BytesPerScanLine5:	dw	640
 29121                              <1> XResolution5:		dw	320
 29122                              <1> YResolution5:		dw	200
 29123                              <1> XCharSize5:		db	8
 29124                              <1> YCharSize5:		db	16
 29125                              <1> NumberOfPlanes5:	db	1
 29126                              <1> BitsPerPixel5:		db	16
 29127                              <1> NumberOfBanks5:		db	2
 29128                              <1> MemoryModel5:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29129                              <1> BankSize5:		db	0
 29130                              <1> NumberOfImagePages5:	db	130
 29131                              <1> Reserved_page5:		db	0
 29132                              <1> RedMaskSize5:		db	5
 29133                              <1> RedFieldPosition5:	db	11
 29134                              <1> GreenMaskSize5:		db	6
 29135                              <1> GreenFieldPosition5:	db	5
 29136                              <1> BlueMaskSize5:		db	5
 29137                              <1> BlueFieldPosition5:	db	0
 29138                              <1> RsvdMaskSize5:		db	0
 29139                              <1> RsvdFieldPosition5:	db	0
 29140                              <1> DirectColorModeInfo5:	db	0
 29141                              <1> PhysBasePtr5:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29142                              <1> OffScreenMemOffset5:	dd	0
 29143                              <1> OffScreenMemSize5:	dw	0
 29144                              <1> LinBytesPerScanLine5:	dw	640
 29145                              <1> BnkNumberOfPages5: 	db	0
 29146                              <1> LinNumberOfPages5: 	db	0
 29147                              <1> LinRedMaskSize5:	db	5
 29148                              <1> LinRedFieldPosition5:	db	11
 29149                              <1> LinGreenMaskSize5:	db	6
 29150                              <1> LinGreenFieldPosition5:	db	5
 29151                              <1> LinBlueMaskSize5:	db	5
 29152                              <1> LinBlueFieldPosition5:	db	0
 29153                              <1> LinRsvdMaskSize5:	db	0
 29154                              <1> LinRsvdFieldPosition5:	db	0
 29155                              <1> MaxPixelClock5:		dd	0
 29156                              <1> 	
 29157                              <1> 			dw	010Fh ; 320x200x24
 29158                              <1> ModeAttributes6: 	dw	MODE_ATTRIBUTES
 29159                              <1> WinAAttributes6: 	db	WINA_ATTRIBUTES
 29160                              <1> WinBAttributes6: 	db	0
 29161                              <1> WinGranularity6: 	dw	VBE_DISPI_BANK_SIZE_KB
 29162                              <1> WinSize6: 		dw	VBE_DISPI_BANK_SIZE_KB
 29163                              <1> WinASegment6:		dw	VGAMEM_GRAPH
 29164                              <1> WinBSegment6:		dw	0000h
 29165                              <1> WinFuncPtr6:		dd	0
 29166                              <1> BytesPerScanLine6:	dw	960
 29167                              <1> XResolution6:		dw	320
 29168                              <1> YResolution6:		dw	200
 29169                              <1> XCharSize6:		db	8
 29170                              <1> YCharSize6:		db	16
 29171                              <1> NumberOfPlanes6:	db	1
 29172                              <1> BitsPerPixel6:		db	24
 29173                              <1> NumberOfBanks6:		db	3
 29174                              <1> MemoryModel6:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29175                              <1> BankSize6:		db	0
 29176                              <1> NumberOfImagePages6:	db	86
 29177                              <1> Reserved_page6:		db	0
 29178                              <1> RedMaskSize6:		db	8
 29179                              <1> RedFieldPosition6:	db	16
 29180                              <1> GreenMaskSize6:		db	8
 29181                              <1> GreenFieldPosition6:	db	8
 29182                              <1> BlueMaskSize6:		db	8
 29183                              <1> BlueFieldPosition6:	db	0
 29184                              <1> RsvdMaskSize6:		db	0
 29185                              <1> RsvdFieldPosition6:	db	0
 29186                              <1> DirectColorModeInfo6:	db	0
 29187                              <1> PhysBasePtr6:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29188                              <1> OffScreenMemOffset6:	dd	0
 29189                              <1> OffScreenMemSize6:	dw	0
 29190                              <1> LinBytesPerScanLine6:	dw	960
 29191                              <1> BnkNumberOfPages6: 	db	0
 29192                              <1> LinNumberOfPages6: 	db	0
 29193                              <1> LinRedMaskSize6:	db	8
 29194                              <1> LinRedFieldPosition6:	db	16
 29195                              <1> LinGreenMaskSize6:	db	8
 29196                              <1> LinGreenFieldPosition6:	db	8
 29197                              <1> LinBlueMaskSize6:	db	8
 29198                              <1> LinBlueFieldPosition6:	db	0
 29199                              <1> LinRsvdMaskSize6:	db	0
 29200                              <1> LinRsvdFieldPosition6:	db	0
 29201                              <1> MaxPixelClock6:		dd	0
 29202                              <1> 	
 29203                              <1> 			dw	0111h ; 640x480x16
 29204                              <1> ModeAttributes7: 	dw	MODE_ATTRIBUTES
 29205                              <1> WinAAttributes7: 	db	WINA_ATTRIBUTES
 29206                              <1> WinBAttributes7: 	db	0
 29207                              <1> WinGranularity7: 	dw	VBE_DISPI_BANK_SIZE_KB
 29208                              <1> WinSize7: 		dw	VBE_DISPI_BANK_SIZE_KB
 29209                              <1> WinASegment7:		dw	VGAMEM_GRAPH
 29210                              <1> WinBSegment7:		dw	0000h
 29211                              <1> WinFuncPtr7:		dd	0
 29212                              <1> BytesPerScanLine7:	dw	1280
 29213                              <1> XResolution7:		dw	640
 29214                              <1> YResolution7:		dw	480
 29215                              <1> XCharSize7:		db	8
 29216                              <1> YCharSize7:		db	16
 29217                              <1> NumberOfPlanes7:	db	1
 29218                              <1> BitsPerPixel7:		db	16
 29219                              <1> NumberOfBanks7:		db	10
 29220                              <1> MemoryModel7:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29221                              <1> BankSize7:		db	0
 29222                              <1> NumberOfImagePages7:	db	26
 29223                              <1> Reserved_page7:		db	0
 29224                              <1> RedMaskSize7:		db	5
 29225                              <1> RedFieldPosition7:	db	11
 29226                              <1> GreenMaskSize7:		db	6
 29227                              <1> GreenFieldPosition7:	db	5
 29228                              <1> BlueMaskSize7:		db	5
 29229                              <1> BlueFieldPosition7:	db	0
 29230                              <1> RsvdMaskSize7:		db	0
 29231                              <1> RsvdFieldPosition7:	db	0
 29232                              <1> DirectColorModeInfo7:	db	0
 29233                              <1> PhysBasePtr7:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
 29234                              <1> OffScreenMemOffset7:	dd	0
 29235                              <1> OffScreenMemSize7:	dw	0
 29236                              <1> LinBytesPerScanLine7:	dw	1280
 29237                              <1> BnkNumberOfPages7: 	db	0
 29238                              <1> LinNumberOfPages7: 	db	0
 29239                              <1> LinRedMaskSize7:	db	5
 29240                              <1> LinRedFieldPosition7:	db	11
 29241                              <1> LinGreenMaskSize7:	db	6
 29242                              <1> LinGreenFieldPosition7:	db	5
 29243                              <1> LinBlueMaskSize7:	db	5
 29244                              <1> LinBlueFieldPosition7:	db	0
 29245                              <1> LinRsvdMaskSize7:	db	0
 29246                              <1> LinRsvdFieldPosition7:	db	0
 29247                              <1> MaxPixelClock7:		dd	0
 29248                              <1> 
 29249                              <1> 			dw	0112h ; 640x480x24
 29250                              <1> ModeAttributes8: 	dw	MODE_ATTRIBUTES
 29251                              <1> WinAAttributes8: 	db	WINA_ATTRIBUTES
 29252                              <1> WinBAttributes8: 	db	0
 29253                              <1> WinGranularity8: 	dw	VBE_DISPI_BANK_SIZE_KB
 29254                              <1> WinSize8: 		dw	VBE_DISPI_BANK_SIZE_KB
 29255                              <1> WinASegment8:		dw	VGAMEM_GRAPH
 29256                              <1> WinBSegment8:		dw	0000h
 29257                              <1> WinFuncPtr8:		dd	0
 29258                              <1> BytesPerScanLine8:	dw	1920
 29259                              <1> XResolution8:		dw	640
 29260                              <1> YResolution8:		dw	480
 29261                              <1> XCharSize8:		db	8
 29262                              <1> YCharSize8:		db	16
 29263                              <1> NumberOfPlanes8:	db	1
 29264                              <1> BitsPerPixel8:		db	24
 29265                              <1> NumberOfBanks8:		db	15
 29266                              <1> MemoryModel8:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29267                              <1> BankSize8:		db	0
 29268                              <1> NumberOfImagePages8:	db	17
 29269                              <1> Reserved_page8:		db	0
 29270                              <1> RedMaskSize8:		db	8
 29271                              <1> RedFieldPosition8:	db	16
 29272                              <1> GreenMaskSize8:		db	8
 29273                              <1> GreenFieldPosition8:	db	8
 29274                              <1> BlueMaskSize8:		db	8
 29275                              <1> BlueFieldPosition8:	db	0
 29276                              <1> RsvdMaskSize8:		db	0
 29277                              <1> RsvdFieldPosition8:	db	0
 29278                              <1> DirectColorModeInfo8:	db	0
 29279                              <1> PhysBasePtr8:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29280                              <1> OffScreenMemOffset8:	dd	0
 29281                              <1> OffScreenMemSize8:	dw	0
 29282                              <1> LinBytesPerScanLine8:	dw	1920
 29283                              <1> BnkNumberOfPages8: 	db	0
 29284                              <1> LinNumberOfPages8: 	db	0
 29285                              <1> LinRedMaskSize8:	db	8
 29286                              <1> LinRedFieldPosition8:	db	16
 29287                              <1> LinGreenMaskSize8:	db	8
 29288                              <1> LinGreenFieldPosition8:	db	8
 29289                              <1> LinBlueMaskSize8:	db	8
 29290                              <1> LinBlueFieldPosition8:	db	0
 29291                              <1> LinRsvdMaskSize8:	db	0
 29292                              <1> LinRsvdFieldPosition8:	db	0
 29293                              <1> MaxPixelClock8:		dd	0
 29294                              <1> 
 29295                              <1> 			dw	0114h ; 800x600x16
 29296                              <1> ModeAttributes9: 	dw	MODE_ATTRIBUTES
 29297                              <1> WinAAttributes9: 	db	WINA_ATTRIBUTES
 29298                              <1> WinBAttributes9: 	db	0
 29299                              <1> WinGranularity9: 	dw	VBE_DISPI_BANK_SIZE_KB
 29300                              <1> WinSize9: 		dw	VBE_DISPI_BANK_SIZE_KB
 29301                              <1> WinASegment9:		dw	VGAMEM_GRAPH
 29302                              <1> WinBSegment9:		dw	0000h
 29303                              <1> WinFuncPtr9:		dd	0
 29304                              <1> BytesPerScanLine9:	dw	1600
 29305                              <1> XResolution9:		dw	800
 29306                              <1> YResolution9:		dw	600
 29307                              <1> XCharSize9:		db	8
 29308                              <1> YCharSize9:		db	16
 29309                              <1> NumberOfPlanes9:	db	1
 29310                              <1> BitsPerPixel9:		db	16
 29311                              <1> NumberOfBanks9:		db	15
 29312                              <1> MemoryModel9:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29313                              <1> BankSize9:		db	0
 29314                              <1> NumberOfImagePages9:	db	16
 29315                              <1> Reserved_page9:		db	0
 29316                              <1> RedMaskSize9:		db	5
 29317                              <1> RedFieldPosition9:	db	11
 29318                              <1> GreenMaskSize9:		db	6
 29319                              <1> GreenFieldPosition9:	db	5
 29320                              <1> BlueMaskSize9:		db	5
 29321                              <1> BlueFieldPosition9:	db	0
 29322                              <1> RsvdMaskSize9:		db	0
 29323                              <1> RsvdFieldPosition9:	db	0
 29324                              <1> DirectColorModeInfo9:	db	0
 29325                              <1> PhysBasePtr9:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29326                              <1> OffScreenMemOffset9:	dd	0
 29327                              <1> OffScreenMemSize9:	dw	0
 29328                              <1> LinBytesPerScanLine9:	dw	1600
 29329                              <1> BnkNumberOfPages9: 	db	0
 29330                              <1> LinNumberOfPages9: 	db	0
 29331                              <1> LinRedMaskSize9:	db	5
 29332                              <1> LinRedFieldPosition9:	db	11
 29333                              <1> LinGreenMaskSize9:	db	6
 29334                              <1> LinGreenFieldPosition9:	db	5
 29335                              <1> LinBlueMaskSize9:	db	5
 29336                              <1> LinBlueFieldPosition9:	db	0
 29337                              <1> LinRsvdMaskSize9:	db	0
 29338                              <1> LinRsvdFieldPosition9:	db	0
 29339                              <1> MaxPixelClock9:		dd	0
 29340                              <1> 	
 29341                              <1> 			dw	0115h ; 800x600x24
 29342                              <1> ModeAttributes10: 	dw	MODE_ATTRIBUTES
 29343                              <1> WinAAttributes10: 	db	WINA_ATTRIBUTES
 29344                              <1> WinBAttributes10: 	db	0
 29345                              <1> WinGranularity10: 	dw	VBE_DISPI_BANK_SIZE_KB
 29346                              <1> WinSize10: 		dw	VBE_DISPI_BANK_SIZE_KB
 29347                              <1> WinASegment10:		dw	VGAMEM_GRAPH
 29348                              <1> WinBSegment10:		dw	0000h
 29349                              <1> WinFuncPtr10:		dd	0
 29350                              <1> BytesPerScanLine10:	dw	2400
 29351                              <1> XResolution10:		dw	800
 29352                              <1> YResolution10:		dw	600
 29353                              <1> XCharSize10:		db	8
 29354                              <1> YCharSize10:		db	16
 29355                              <1> NumberOfPlanes10:	db	1
 29356                              <1> BitsPerPixel10:		db	24
 29357                              <1> NumberOfBanks10:	db	22
 29358                              <1> MemoryModel10:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29359                              <1> BankSize10:		db	0
 29360                              <1> NumberOfImagePages10:	db	10
 29361                              <1> Reserved_page10:	db	0
 29362                              <1> RedMaskSize10:		db	8
 29363                              <1> RedFieldPosition10:	db	16
 29364                              <1> GreenMaskSize10:	db	8
 29365                              <1> GreenFieldPosition10:	db	8
 29366                              <1> BlueMaskSize10:		db	8
 29367                              <1> BlueFieldPosition10:	db	0
 29368                              <1> RsvdMaskSize10:		db	0
 29369                              <1> RsvdFieldPosition10:	db	0
 29370                              <1> DirectColorModeInfo10:	db	0
 29371                              <1> PhysBasePtr10:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29372                              <1> OffScreenMemOffset10:	dd	0
 29373                              <1> OffScreenMemSize10:	dw	0
 29374                              <1> LinBytesPerScanLine10:	dw	2400
 29375                              <1> BnkNumberOfPages10: 	db	0
 29376                              <1> LinNumberOfPages10: 	db	0
 29377                              <1> LinRedMaskSize10:	db	8
 29378                              <1> LinRedFieldPosition10:	db	16
 29379                              <1> LinGreenMaskSize10:	db	8
 29380                              <1> LinGreenFieldPosition10:db	8
 29381                              <1> LinBlueMaskSize10:	db	8
 29382                              <1> LinBlueFieldPosition10:	db	0
 29383                              <1> LinRsvdMaskSize10:	db	0
 29384                              <1> LinRsvdFieldPosition10:	db	0
 29385                              <1> MaxPixelClock10:	dd	0
 29386                              <1> 
 29387                              <1> 			dw	0117h ; 1024x768x16
 29388                              <1> ModeAttributes11: 	dw	MODE_ATTRIBUTES
 29389                              <1> WinAAttributes11: 	db	WINA_ATTRIBUTES
 29390                              <1> WinBAttributes11: 	db	0
 29391                              <1> WinGranularity11: 	dw	VBE_DISPI_BANK_SIZE_KB
 29392                              <1> WinSize11: 		dw	VBE_DISPI_BANK_SIZE_KB
 29393                              <1> WinASegment11:		dw	VGAMEM_GRAPH
 29394                              <1> WinBSegment11:		dw	0000h
 29395                              <1> WinFuncPtr11:		dd	0
 29396                              <1> BytesPerScanLine11:	dw	2048
 29397                              <1> XResolution11:		dw	1024
 29398                              <1> YResolution11:		dw	768
 29399                              <1> XCharSize11:		db	8
 29400                              <1> YCharSize11:		db	16
 29401                              <1> NumberOfPlanes11:	db	1
 29402                              <1> BitsPerPixel11:		db	16
 29403                              <1> NumberOfBanks11:	db	24
 29404                              <1> MemoryModel11:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29405                              <1> BankSize11:		db	0
 29406                              <1> NumberOfImagePages11:	db	9
 29407                              <1> Reserved_page11:	db	0
 29408                              <1> RedMaskSize11:		db	5
 29409                              <1> RedFieldPosition11:	db	11
 29410                              <1> GreenMaskSize11:	db	6
 29411                              <1> GreenFieldPosition11:	db	5
 29412                              <1> BlueMaskSize11:		db	5
 29413                              <1> BlueFieldPosition11:	db	0
 29414                              <1> RsvdMaskSize11:		db	0
 29415                              <1> RsvdFieldPosition11:	db	0
 29416                              <1> DirectColorModeInfo11:	db	0
 29417                              <1> PhysBasePtr11:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
 29418                              <1> OffScreenMemOffset11:	dd	0
 29419                              <1> OffScreenMemSize11:	dw	0
 29420                              <1> LinBytesPerScanLine11:	dw	2048
 29421                              <1> BnkNumberOfPages11: 	db	0
 29422                              <1> LinNumberOfPages11: 	db	0
 29423                              <1> LinRedMaskSize11:	db	5
 29424                              <1> LinRedFieldPosition11:	db	11
 29425                              <1> LinGreenMaskSize11:	db	6
 29426                              <1> LinGreenFieldPosition11:db	5
 29427                              <1> LinBlueMaskSize11:	db	5
 29428                              <1> LinBlueFieldPosition11:	db	0
 29429                              <1> LinRsvdMaskSize11:	db	0
 29430                              <1> LinRsvdFieldPosition11:	db	0
 29431                              <1> MaxPixelClock11:	dd	0
 29432                              <1> 
 29433                              <1> 			dw	0118h ; 1024x768x24
 29434                              <1> ModeAttributes12: 	dw	MODE_ATTRIBUTES
 29435                              <1> WinAAttributes12: 	db	WINA_ATTRIBUTES
 29436                              <1> WinBAttributes12: 	db	0
 29437                              <1> WinGranularity12: 	dw	VBE_DISPI_BANK_SIZE_KB
 29438                              <1> WinSize12: 		dw	VBE_DISPI_BANK_SIZE_KB
 29439                              <1> WinASegment12:		dw	VGAMEM_GRAPH
 29440                              <1> WinBSegment12:		dw	0000h
 29441                              <1> WinFuncPtr12:		dd	0
 29442                              <1> BytesPerScanLine12:	dw	3072
 29443                              <1> XResolution12:		dw	1024
 29444                              <1> YResolution12:		dw	768
 29445                              <1> XCharSize12:		db	8
 29446                              <1> YCharSize12:		db	16
 29447                              <1> NumberOfPlanes12:	db	1
 29448                              <1> BitsPerPixel12:		db	24
 29449                              <1> NumberOfBanks12:	db	36
 29450                              <1> MemoryModel12:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29451                              <1> BankSize12:		db	0
 29452                              <1> NumberOfImagePages12:	db	6
 29453                              <1> Reserved_page12:	db	0
 29454                              <1> RedMaskSize12:		db	8
 29455                              <1> RedFieldPosition12:	db	16
 29456                              <1> GreenMaskSize12:	db	8
 29457                              <1> GreenFieldPosition12:	db	8
 29458                              <1> BlueMaskSize12:		db	8
 29459                              <1> BlueFieldPosition12:	db	0
 29460                              <1> RsvdMaskSize12:		db	0
 29461                              <1> RsvdFieldPosition12:	db	0
 29462                              <1> DirectColorModeInfo12:	db	0
 29463                              <1> PhysBasePtr12:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29464                              <1> OffScreenMemOffset12:	dd	0
 29465                              <1> OffScreenMemSize12:	dw	0
 29466                              <1> LinBytesPerScanLine12:	dw	3072
 29467                              <1> BnkNumberOfPages12: 	db	0
 29468                              <1> LinNumberOfPages12: 	db	0
 29469                              <1> LinRedMaskSize12:	db	8
 29470                              <1> LinRedFieldPosition12:	db	16
 29471                              <1> LinGreenMaskSize12:	db	8
 29472                              <1> LinGreenFieldPosition12:db	8
 29473                              <1> LinBlueMaskSize12:	db	8
 29474                              <1> LinBlueFieldPosition12:	db	0
 29475                              <1> LinRsvdMaskSize12:	db	0
 29476                              <1> LinRsvdFieldPosition12:	db	0
 29477                              <1> MaxPixelClock12:	dd	0
 29478                              <1> 
 29479                              <1> 			dw	0140h ; 320x200x32
 29480                              <1> ModeAttributes13: 	dw	MODE_ATTRIBUTES
 29481                              <1> WinAAttributes13: 	db	WINA_ATTRIBUTES
 29482                              <1> WinBAttributes13: 	db	0
 29483                              <1> WinGranularity13: 	dw	VBE_DISPI_BANK_SIZE_KB
 29484                              <1> WinSize13: 		dw	VBE_DISPI_BANK_SIZE_KB
 29485                              <1> WinASegment13:		dw	VGAMEM_GRAPH
 29486                              <1> WinBSegment13:		dw	0000h
 29487                              <1> WinFuncPtr13:		dd	0
 29488                              <1> BytesPerScanLine13:	dw	1280
 29489                              <1> XResolution13:		dw	320
 29490                              <1> YResolution13:		dw	200
 29491                              <1> XCharSize13:		db	8
 29492                              <1> YCharSize13:		db	16
 29493                              <1> NumberOfPlanes13:	db	1
 29494                              <1> BitsPerPixel13:		db	32
 29495                              <1> NumberOfBanks13:	db	4
 29496                              <1> MemoryModel13:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29497                              <1> BankSize13:		db	0
 29498                              <1> NumberOfImagePages13:	db	64
 29499                              <1> Reserved_page13:	db	0
 29500                              <1> RedMaskSize13:		db	8
 29501                              <1> RedFieldPosition13:	db	16
 29502                              <1> GreenMaskSize13:	db	8
 29503                              <1> GreenFieldPosition13:	db	8
 29504                              <1> BlueMaskSize13:		db	8
 29505                              <1> BlueFieldPosition13:	db	0
 29506                              <1> RsvdMaskSize13:		db	8
 29507                              <1> RsvdFieldPosition13:	db	24
 29508                              <1> DirectColorModeInfo13:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 29509                              <1> PhysBasePtr13:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29510                              <1> OffScreenMemOffset13:	dd	0
 29511                              <1> OffScreenMemSize13:	dw	0
 29512                              <1> LinBytesPerScanLine13:	dw	1280
 29513                              <1> BnkNumberOfPages13: 	db	0
 29514                              <1> LinNumberOfPages13: 	db	0
 29515                              <1> LinRedMaskSize13:	db	8
 29516                              <1> LinRedFieldPosition13:	db	16
 29517                              <1> LinGreenMaskSize13:	db	8
 29518                              <1> LinGreenFieldPosition13:db	8
 29519                              <1> LinBlueMaskSize13:	db	8
 29520                              <1> LinBlueFieldPosition13:	db	0
 29521                              <1> LinRsvdMaskSize13:	db	8
 29522                              <1> LinRsvdFieldPosition13:	db	24
 29523                              <1> MaxPixelClock13:	dd	0
 29524                              <1> 
 29525                              <1> 			dw	0141h ; 640x400x32
 29526                              <1> ModeAttributes14: 	dw	MODE_ATTRIBUTES
 29527                              <1> WinAAttributes14: 	db	WINA_ATTRIBUTES
 29528                              <1> WinBAttributes14: 	db	0
 29529                              <1> WinGranularity14: 	dw	VBE_DISPI_BANK_SIZE_KB
 29530                              <1> WinSize14: 		dw	VBE_DISPI_BANK_SIZE_KB
 29531                              <1> WinASegment14:		dw	VGAMEM_GRAPH
 29532                              <1> WinBSegment14:		dw	0000h
 29533                              <1> WinFuncPtr14:		dd	0
 29534                              <1> BytesPerScanLine14:	dw	2560
 29535                              <1> XResolution14:		dw	640
 29536                              <1> YResolution14:		dw	400
 29537                              <1> XCharSize14:		db	8
 29538                              <1> YCharSize14:		db	16
 29539                              <1> NumberOfPlanes14:	db	1
 29540                              <1> BitsPerPixel14:		db	32
 29541                              <1> NumberOfBanks14:	db	16
 29542                              <1> MemoryModel14:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29543                              <1> BankSize14:		db	0
 29544                              <1> NumberOfImagePages14:	db	15
 29545                              <1> Reserved_page14:	db	0
 29546                              <1> RedMaskSize14:		db	8
 29547                              <1> RedFieldPosition14:	db	16
 29548                              <1> GreenMaskSize14:	db	8
 29549                              <1> GreenFieldPosition14:	db	8
 29550                              <1> BlueMaskSize14:		db	8
 29551                              <1> BlueFieldPosition14:	db	0
 29552                              <1> RsvdMaskSize14:		db	8
 29553                              <1> RsvdFieldPosition14:	db	24
 29554                              <1> DirectColorModeInfo14:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 29555                              <1> PhysBasePtr14:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29556                              <1> OffScreenMemOffset14:	dd  	0
 29557                              <1> OffScreenMemSize14:	dw	0
 29558                              <1> LinBytesPerScanLine14:	dw	2560
 29559                              <1> BnkNumberOfPages14: 	db	0
 29560                              <1> LinNumberOfPages14: 	db	0
 29561                              <1> LinRedMaskSize14:	db	8
 29562                              <1> LinRedFieldPosition14:	db	16
 29563                              <1> LinGreenMaskSize14:	db	8
 29564                              <1> LinGreenFieldPosition14:db	8
 29565                              <1> LinBlueMaskSize14:	db	8
 29566                              <1> LinBlueFieldPosition14:	db	0
 29567                              <1> LinRsvdMaskSize14:	db	8
 29568                              <1> LinRsvdFieldPosition14:	db	24
 29569                              <1> MaxPixelClock14:	dd	0
 29570                              <1> 
 29571                              <1> 			dw	0142 ; 640x480x32
 29572                              <1> ModeAttributes15: 	dw	MODE_ATTRIBUTES
 29573                              <1> WinAAttributes15: 	db	WINA_ATTRIBUTES
 29574                              <1> WinBAttributes15: 	db	0
 29575                              <1> WinGranularity15: 	dw	VBE_DISPI_BANK_SIZE_KB
 29576                              <1> WinSize15: 		dw	VBE_DISPI_BANK_SIZE_KB
 29577                              <1> WinASegment15:		dw	VGAMEM_GRAPH
 29578                              <1> WinBSegment15:		dw	0000h
 29579                              <1> WinFuncPtr15:		dd	0
 29580                              <1> BytesPerScanLine15:	dw	2560
 29581                              <1> XResolution15:		dw	640
 29582                              <1> YResolution15:		dw	480
 29583                              <1> XCharSize15:		db	8
 29584                              <1> YCharSize15:		db	16
 29585                              <1> NumberOfPlanes15:	db	1
 29586                              <1> BitsPerPixel15:		db	32
 29587                              <1> NumberOfBanks15:	db	19
 29588                              <1> MemoryModel15:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29589                              <1> BankSize15:		db	0
 29590                              <1> NumberOfImagePages15:	db	12
 29591                              <1> Reserved_page15:	db	0
 29592                              <1> RedMaskSize15:		db	8
 29593                              <1> RedFieldPosition15:	db	16
 29594                              <1> GreenMaskSize15:	db	8
 29595                              <1> GreenFieldPosition15:	db	8
 29596                              <1> BlueMaskSize15:		db	8
 29597                              <1> BlueFieldPosition15:	db	0
 29598                              <1> RsvdMaskSize15:		db	8
 29599                              <1> RsvdFieldPosition15:	db	24
 29600                              <1> DirectColorModeInfo15:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
 29601                              <1> PhysBasePtr15:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
 29602                              <1> OffScreenMemOffset15:	dd	0
 29603                              <1> OffScreenMemSize15:	dw	0
 29604                              <1> LinBytesPerScanLine15:	dw	2560
 29605                              <1> BnkNumberOfPages15: 	db	0
 29606                              <1> LinNumberOfPages15: 	db	0
 29607                              <1> LinRedMaskSize15:	db	8
 29608                              <1> LinRedFieldPosition15:	db	16
 29609                              <1> LinGreenMaskSize15:	db	8
 29610                              <1> LinGreenFieldPosition15:db	8
 29611                              <1> LinBlueMaskSize15:	db	8
 29612                              <1> LinBlueFieldPosition15:	db	0
 29613                              <1> LinRsvdMaskSize15:	db	8
 29614                              <1> LinRsvdFieldPosition15:	db	24
 29615                              <1> MaxPixelClock15:	dd	0
 29616                              <1> 
 29617                              <1> 			dw	0143h ; 800x600x32
 29618                              <1> ModeAttributes16: 	dw	MODE_ATTRIBUTES
 29619                              <1> WinAAttributes16: 	db	WINA_ATTRIBUTES
 29620                              <1> WinBAttributes16: 	db	0
 29621                              <1> WinGranularity16: 	dw	VBE_DISPI_BANK_SIZE_KB
 29622                              <1> WinSize16: 		dw	VBE_DISPI_BANK_SIZE_KB
 29623                              <1> WinASegment16:		dw	VGAMEM_GRAPH
 29624                              <1> WinBSegment16:		dw	0000h
 29625                              <1> WinFuncPtr16:		dd	0
 29626                              <1> BytesPerScanLine16:	dw	3200
 29627                              <1> XResolution16:		dw	800
 29628                              <1> YResolution16:		dw	600
 29629                              <1> XCharSize16:		db	8
 29630                              <1> YCharSize16:		db	16
 29631                              <1> NumberOfPlanes16:	db	1
 29632                              <1> BitsPerPixel16:		db	32
 29633                              <1> NumberOfBanks16:	db	30
 29634                              <1> MemoryModel16:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29635                              <1> BankSize16:		db	0
 29636                              <1> NumberOfImagePages16:	db	7
 29637                              <1> Reserved_page16:	db	0
 29638                              <1> RedMaskSize16:		db	8
 29639                              <1> RedFieldPosition16:	db	16
 29640                              <1> GreenMaskSize16:	db	8
 29641                              <1> GreenFieldPosition16:	db	8
 29642                              <1> BlueMaskSize16:		db	8
 29643                              <1> BlueFieldPosition16:	db	0
 29644                              <1> RsvdMaskSize16:		db	8
 29645                              <1> RsvdFieldPosition16:	db	24
 29646                              <1> DirectColorModeInfo16:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
 29647                              <1> PhysBasePtr16:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
 29648                              <1> OffScreenMemOffset16:	dd	0
 29649                              <1> OffScreenMemSize16:	dw	0
 29650                              <1> LinBytesPerScanLine16:	dw	3200
 29651                              <1> BnkNumberOfPages16: 	db	0
 29652                              <1> LinNumberOfPages16: 	db	0
 29653                              <1> LinRedMaskSize16:	db	8
 29654                              <1> LinRedFieldPosition16:	db	16
 29655                              <1> LinGreenMaskSize16:	db	8
 29656                              <1> LinGreenFieldPosition16:db	8
 29657                              <1> LinBlueMaskSize16:	db	8
 29658                              <1> LinBlueFieldPosition16:	db	0
 29659                              <1> LinRsvdMaskSize16:	db	8
 29660                              <1> LinRsvdFieldPosition16:	db	24
 29661                              <1> MaxPixelClock16:	dd	0
 29662                              <1> 	
 29663                              <1> 			dw	0144h ; 1024x768x32
 29664                              <1> ModeAttributes17: 	dw	MODE_ATTRIBUTES
 29665                              <1> WinAAttributes17: 	db	WINA_ATTRIBUTES
 29666                              <1> WinBAttributes17: 	db	0
 29667                              <1> WinGranularity17: 	dw	VBE_DISPI_BANK_SIZE_KB
 29668                              <1> WinSize17: 		dw	VBE_DISPI_BANK_SIZE_KB
 29669                              <1> WinASegment17:		dw	VGAMEM_GRAPH
 29670                              <1> WinBSegment17:		dw	0000h
 29671                              <1> WinFuncPtr17:		dd	0
 29672                              <1> BytesPerScanLine17:	dw	4096
 29673                              <1> XResolution17:		dw	1024
 29674                              <1> YResolution17:		dw	768
 29675                              <1> XCharSize17:		db	8
 29676                              <1> YCharSize17:		db	16
 29677                              <1> NumberOfPlanes17:	db	1
 29678                              <1> BitsPerPixel17:		db	32
 29679                              <1> NumberOfBanks17:	db	48
 29680                              <1> MemoryModel17:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29681                              <1> BankSize17:		db	0
 29682                              <1> NumberOfImagePages17:	db	4
 29683                              <1> Reserved_page17:	db	0
 29684                              <1> RedMaskSize17:		db	8
 29685                              <1> RedFieldPosition17:	db	16
 29686                              <1> GreenMaskSize17:	db	8
 29687                              <1> GreenFieldPosition17:	db	8
 29688                              <1> BlueMaskSize17:		db	8
 29689                              <1> BlueFieldPosition17:	db	0
 29690                              <1> RsvdMaskSize17:		db	8
 29691                              <1> RsvdFieldPosition17:	db	24
 29692                              <1> DirectColorModeInfo17:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 29693                              <1> PhysBasePtr17:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29694                              <1> OffScreenMemOffset17:	dd	0
 29695                              <1> OffScreenMemSize17:	dw	0
 29696                              <1> LinBytesPerScanLine17:	dw	4096
 29697                              <1> BnkNumberOfPages17: 	db	0
 29698                              <1> LinNumberOfPages17: 	db	0
 29699                              <1> LinRedMaskSize17:	db	8
 29700                              <1> LinRedFieldPosition17:	db	16
 29701                              <1> LinGreenMaskSize17:	db	8
 29702                              <1> LinGreenFieldPosition17:db	8
 29703                              <1> LinBlueMaskSize17:	db	8
 29704                              <1> LinBlueFieldPosition17:	db	0
 29705                              <1> LinRsvdMaskSize17:	db	8
 29706                              <1> LinRsvdFieldPosition17:	db	24
 29707                              <1> MaxPixelClock17:	dd	0
 29708                              <1> 	
 29709                              <1> 			dw	0146h ; 320x200x8
 29710                              <1> ModeAttributes18: 	dw	MODE_ATTRIBUTES
 29711                              <1> WinAAttributes18: 	db	WINA_ATTRIBUTES
 29712                              <1> WinBAttributes18: 	db	0
 29713                              <1> WinGranularity18: 	dw	VBE_DISPI_BANK_SIZE_KB
 29714                              <1> WinSize18: 		dw	VBE_DISPI_BANK_SIZE_KB
 29715                              <1> WinASegment18:		dw	VGAMEM_GRAPH
 29716                              <1> WinBSegment18:		dw	0000h
 29717                              <1> WinFuncPtr18:		dd	0
 29718                              <1> BytesPerScanLine18:	dw	320
 29719                              <1> XResolution18:		dw	320
 29720                              <1> YResolution18:		dw	200
 29721                              <1> XCharSize18:		db	8
 29722                              <1> YCharSize18:		db	16
 29723                              <1> NumberOfPlanes18:	db	1
 29724                              <1> BitsPerPixel18:		db	8
 29725                              <1> NumberOfBanks18:	db	1
 29726                              <1> MemoryModel18:		db	VBE_MEMORYMODEL_PACKED_PIXEL
 29727                              <1> BankSize18:		db	0
 29728                              <1> NumberOfImagePages18:	db	255 ; 261 in vbetables.h (03/01/2020) !
 29729                              <1> Reserved_page18:	db	0
 29730                              <1> RedMaskSize18:		db	0
 29731                              <1> RedFieldPosition18:	db	0
 29732                              <1> GreenMaskSize18:	db	0
 29733                              <1> GreenFieldPosition18:	db	0
 29734                              <1> BlueMaskSize18:		db	0
 29735                              <1> BlueFieldPosition18:	db	0
 29736                              <1> RsvdMaskSize18:		db	0
 29737                              <1> RsvdFieldPosition18:	db	0
 29738                              <1> DirectColorModeInfo18:	db	0
 29739                              <1> PhysBasePtr18:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29740                              <1> OffScreenMemOffset18:	dd	0
 29741                              <1> OffScreenMemSize18:	dw	0
 29742                              <1> LinBytesPerScanLine18:	dw	320
 29743                              <1> BnkNumberOfPages18: 	db	0
 29744                              <1> LinNumberOfPages18: 	db	0
 29745                              <1> LinRedMaskSize18:	db	0
 29746                              <1> LinRedFieldPosition18: 	db	0
 29747                              <1> LinGreenMaskSize18: 	db	0
 29748                              <1> LinGreenFieldPosition18:db	0
 29749                              <1> LinBlueMaskSize18: 	db	0
 29750                              <1> LinBlueFieldPosition18: db	0
 29751                              <1> LinRsvdMaskSize18: 	db	0
 29752                              <1> LinRsvdFieldPosition18: db	0
 29753                              <1> MaxPixelClock18:	dd	0
 29754                              <1> 
 29755                              <1> 			dw	018Dh ; 1280x720x16
 29756                              <1> ModeAttributes19: 	dw	MODE_ATTRIBUTES
 29757                              <1> WinAAttributes19: 	db	WINA_ATTRIBUTES
 29758                              <1> WinBAttributes19: 	db	0
 29759                              <1> WinGranularity19: 	dw	VBE_DISPI_BANK_SIZE_KB
 29760                              <1> WinSize19: 		dw	VBE_DISPI_BANK_SIZE_KB
 29761                              <1> WinASegment19:		dw	VGAMEM_GRAPH
 29762                              <1> WinBSegment19:		dw	0000h
 29763                              <1> WinFuncPtr19:		dd	0
 29764                              <1> BytesPerScanLine19:	dw	2560
 29765                              <1> XResolution19:		dw	1280
 29766                              <1> YResolution19:		dw	720
 29767                              <1> XCharSize19:		db	8
 29768                              <1> YCharSize19:		db	16
 29769                              <1> NumberOfPlanes19:	db	1
 29770                              <1> BitsPerPixel19:		db	16
 29771                              <1> NumberOfBanks19:	db	29
 29772                              <1> MemoryModel19:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29773                              <1> BankSize19:		db	0
 29774                              <1> NumberOfImagePages19:	db	8
 29775                              <1> Reserved_page19:	db	0
 29776                              <1> RedMaskSize19:		db	5
 29777                              <1> RedFieldPosition19:	db	11
 29778                              <1> GreenMaskSize19:	db	6
 29779                              <1> GreenFieldPosition19:	db	5
 29780                              <1> BlueMaskSize19:		db	5
 29781                              <1> BlueFieldPosition19:	db	0
 29782                              <1> RsvdMaskSize19:		db	0
 29783                              <1> RsvdFieldPosition19:	db	0
 29784                              <1> DirectColorModeInfo19:	db	0
 29785                              <1> PhysBasePtr19:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29786                              <1> OffScreenMemOffset19:	dd	0
 29787                              <1> OffScreenMemSize19:	dw	0
 29788                              <1> LinBytesPerScanLine19:	dw	2560
 29789                              <1> BnkNumberOfPages19: 	db	0
 29790                              <1> LinNumberOfPages19: 	db	0
 29791                              <1> LinRedMaskSize19:	db	5
 29792                              <1> LinRedFieldPosition19:	db	11
 29793                              <1> LinGreenMaskSize19:	db	6
 29794                              <1> LinGreenFieldPosition19:db	5
 29795                              <1> LinBlueMaskSize19:	db	5
 29796                              <1> LinBlueFieldPosition19:	db	0
 29797                              <1> LinRsvdMaskSize19:	db	0
 29798                              <1> LinRsvdFieldPosition19:	db	0
 29799                              <1> MaxPixelClock19:	dd	0
 29800                              <1> 
 29801                              <1> 			dw	018Eh ; 1280x720x24
 29802                              <1> ModeAttributes20: 	dw	MODE_ATTRIBUTES
 29803                              <1> WinAAttributes20: 	db	WINA_ATTRIBUTES
 29804                              <1> WinBAttributes20: 	db	0
 29805                              <1> WinGranularity20: 	dw	VBE_DISPI_BANK_SIZE_KB
 29806                              <1> WinSize20: 		dw	VBE_DISPI_BANK_SIZE_KB
 29807                              <1> WinASegment20:		dw	VGAMEM_GRAPH
 29808                              <1> WinBSegment20:		dw	0000h
 29809                              <1> WinFuncPtr20:		dd	0
 29810                              <1> BytesPerScanLine20:	dw	3840
 29811                              <1> XResolution20:		dw	1280
 29812                              <1> YResolution20:		dw	720
 29813                              <1> XCharSize20:		db	8
 29814                              <1> YCharSize20:		db	16
 29815                              <1> NumberOfPlanes20:	db	1
 29816                              <1> BitsPerPixel20:		db	24
 29817                              <1> NumberOfBanks20:	db	43
 29818                              <1> MemoryModel20:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29819                              <1> BankSize20:		db	0
 29820                              <1> NumberOfImagePages20:	db	5
 29821                              <1> Reserved_page20:	db	0
 29822                              <1> RedMaskSize20:		db	8
 29823                              <1> RedFieldPosition20:	db	16
 29824                              <1> GreenMaskSize20:	db	8
 29825                              <1> GreenFieldPosition20:	db	8
 29826                              <1> BlueMaskSize20:		db	8
 29827                              <1> BlueFieldPosition20:	db	0
 29828                              <1> RsvdMaskSize20:		db	0
 29829                              <1> RsvdFieldPosition20:	db	0
 29830                              <1> DirectColorModeInfo20:	db	0
 29831                              <1> PhysBasePtr20:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29832                              <1> OffScreenMemOffset20:	dd	0
 29833                              <1> OffScreenMemSize20:	dw	0
 29834                              <1> LinBytesPerScanLine20:	dw	3840
 29835                              <1> BnkNumberOfPages20: 	db	0
 29836                              <1> LinNumberOfPages20: 	db	0
 29837                              <1> LinRedMaskSize20:	db	8
 29838                              <1> LinRedFieldPosition20:	db	16
 29839                              <1> LinGreenMaskSize20:	db	8
 29840                              <1> LinGreenFieldPosition20:db	8
 29841                              <1> LinBlueMaskSize20:	db	8
 29842                              <1> LinBlueFieldPosition20:	db	0
 29843                              <1> LinRsvdMaskSize20:	db	0
 29844                              <1> LinRsvdFieldPosition20:	db	0
 29845                              <1> MaxPixelClock20:	dd	0
 29846                              <1> 	
 29847                              <1> 			dw	018Fh ; 1280x720x32
 29848                              <1> ModeAttributes21: 	dw	MODE_ATTRIBUTES
 29849                              <1> WinAAttributes21: 	db	WINA_ATTRIBUTES
 29850                              <1> WinBAttributes21: 	db	0
 29851                              <1> WinGranularity21: 	dw	VBE_DISPI_BANK_SIZE_KB
 29852                              <1> WinSize21: 		dw	VBE_DISPI_BANK_SIZE_KB
 29853                              <1> WinASegment21:		dw	VGAMEM_GRAPH
 29854                              <1> WinBSegment21:		dw	0000h
 29855                              <1> WinFuncPtr21:		dd	0
 29856                              <1> BytesPerScanLine21:	dw	5120
 29857                              <1> XResolution21:		dw	1280
 29858                              <1> YResolution21:		dw	720
 29859                              <1> XCharSize21:		db	8
 29860                              <1> YCharSize21:		db	16
 29861                              <1> NumberOfPlanes21:	db	1
 29862                              <1> BitsPerPixel21:		db	32
 29863                              <1> NumberOfBanks21:	db	57
 29864                              <1> MemoryModel21:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29865                              <1> BankSize21:		db	0
 29866                              <1> NumberOfImagePages21:	db	3
 29867                              <1> Reserved_page21:	db	0
 29868                              <1> RedMaskSize21:		db	8
 29869                              <1> RedFieldPosition21:	db	16
 29870                              <1> GreenMaskSize21:	db	8
 29871                              <1> GreenFieldPosition21:	db	8
 29872                              <1> BlueMaskSize21:		db	8
 29873                              <1> BlueFieldPosition21:	db	0
 29874                              <1> RsvdMaskSize21:		db	8
 29875                              <1> RsvdFieldPosition21:	db	24
 29876                              <1> DirectColorModeInfo21:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 29877                              <1> PhysBasePtr21:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29878                              <1> OffScreenMemOffset21:	dd	0
 29879                              <1> OffScreenMemSize21:	dw	0
 29880                              <1> LinBytesPerScanLine21:	dw	5120
 29881                              <1> BnkNumberOfPages21: 	db	0
 29882                              <1> LinNumberOfPages21: 	db	0
 29883                              <1> LinRedMaskSize21:	db	8
 29884                              <1> LinRedFieldPosition21:	db	16
 29885                              <1> LinGreenMaskSize21:	db	8
 29886                              <1> LinGreenFieldPosition21:db	8
 29887                              <1> LinBlueMaskSize21:	db	8
 29888                              <1> LinBlueFieldPosition21:	db	0
 29889                              <1> LinRsvdMaskSize21:	db	8
 29890                              <1> LinRsvdFieldPosition21:	db	24
 29891                              <1> MaxPixelClock21:	dd	0
 29892                              <1> 			
 29893                              <1> 			dw	0190h ; 1920x1080x16
 29894                              <1> ModeAttributes22: 	dw	MODE_ATTRIBUTES
 29895                              <1> WinAAttributes22: 	db	WINA_ATTRIBUTES
 29896                              <1> WinBAttributes22: 	db	0
 29897                              <1> WinGranularity22: 	dw	VBE_DISPI_BANK_SIZE_KB
 29898                              <1> WinSize22: 		dw	VBE_DISPI_BANK_SIZE_KB
 29899                              <1> WinASegment22:		dw	VGAMEM_GRAPH
 29900                              <1> WinBSegment22:		dw	0000h
 29901                              <1> WinFuncPtr22:		dd	0
 29902                              <1> BytesPerScanLine22:	dw	3840
 29903                              <1> XResolution22:		dw	1920
 29904                              <1> YResolution22:		dw	1080
 29905                              <1> XCharSize22:		db	8
 29906                              <1> YCharSize22:		db	16
 29907                              <1> NumberOfPlanes22:	db	1
 29908                              <1> BitsPerPixel22:		db	16
 29909                              <1> NumberOfBanks22:	db	64
 29910                              <1> MemoryModel22:		db	VBE_MEMORYMODEL_DIRECT_COLOR,
 29911                              <1> BankSize22:		db	0
 29912                              <1> NumberOfImagePages22:	db	3
 29913                              <1> Reserved_page22:	db	0
 29914                              <1> RedMaskSize22:		db	5
 29915                              <1> RedFieldPosition22:	db	11
 29916                              <1> GreenMaskSize22:	db	6
 29917                              <1> GreenFieldPosition22:	db	5
 29918                              <1> BlueMaskSize22:		db	5
 29919                              <1> BlueFieldPosition22:	db	0
 29920                              <1> RsvdMaskSize22:		db	0
 29921                              <1> RsvdFieldPosition22:	db	0
 29922                              <1> DirectColorModeInfo22:	db	0
 29923                              <1> PhysBasePtr22:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29924                              <1> OffScreenMemOffset22:	dd	0
 29925                              <1> OffScreenMemSize22:	dw	0
 29926                              <1> LinBytesPerScanLine22:	dw	3840
 29927                              <1> BnkNumberOfPages22: 	db	0
 29928                              <1> LinNumberOfPages22: 	db	0
 29929                              <1> LinRedMaskSize22:	db	5
 29930                              <1> LinRedFieldPosition22:	db	11
 29931                              <1> LinGreenMaskSize22:	db	6
 29932                              <1> LinGreenFieldPosition22:db	5
 29933                              <1> LinBlueMaskSize22:	db	5
 29934                              <1> LinBlueFieldPosition22:	db	0
 29935                              <1> LinRsvdMaskSize22:	db	0
 29936                              <1> LinRsvdFieldPosition22:	db	0
 29937                              <1> MaxPixelClock22:	dd	0
 29938                              <1> 			
 29939                              <1> 			dw	0191h ; 1920x1080x24
 29940                              <1> ModeAttributes23: 	dw	MODE_ATTRIBUTES
 29941                              <1> WinAAttributes23: 	db	WINA_ATTRIBUTES
 29942                              <1> WinBAttributes23: 	db	0
 29943                              <1> WinGranularity23: 	dw	VBE_DISPI_BANK_SIZE_KB
 29944                              <1> WinSize23: 		dw	VBE_DISPI_BANK_SIZE_KB
 29945                              <1> WinASegment23:		dw	VGAMEM_GRAPH
 29946                              <1> WinBSegment23:		dw	0000h
 29947                              <1> WinFuncPtr23:		dd	0
 29948                              <1> BytesPerScanLine23:	dw	5760
 29949                              <1> XResolution23:		dw	1920
 29950                              <1> YResolution23:		dw	1080
 29951                              <1> XCharSize23:		db	8
 29952                              <1> YCharSize23:		db	16
 29953                              <1> NumberOfPlanes23:	db	1
 29954                              <1> BitsPerPixel23:		db	24
 29955                              <1> NumberOfBanks23:	db	95
 29956                              <1> MemoryModel23:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 29957                              <1> BankSize23:		db	0
 29958                              <1> NumberOfImagePages23:	db	1
 29959                              <1> Reserved_page23:	db	0
 29960                              <1> RedMaskSize23:		db	8
 29961                              <1> RedFieldPosition23:	db	16
 29962                              <1> GreenMaskSize23:	db	8
 29963                              <1> GreenFieldPosition23:	db	8
 29964                              <1> BlueMaskSize23:		db	8
 29965                              <1> BlueFieldPosition23:	db	0
 29966                              <1> RsvdMaskSize23:		db	0
 29967                              <1> RsvdFieldPosition23:	db	0
 29968                              <1> DirectColorModeInfo23:	db	0
 29969                              <1> PhysBasePtr23:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 29970                              <1> OffScreenMemOffset23:	dd	0
 29971                              <1> OffScreenMemSize23:	dw	0
 29972                              <1> LinBytesPerScanLine23:	dw	5760
 29973                              <1> BnkNumberOfPages23: 	db	0
 29974                              <1> LinNumberOfPages23: 	db	0
 29975                              <1> LinRedMaskSize23:	db	8
 29976                              <1> LinRedFieldPosition23:	db	16
 29977                              <1> LinGreenMaskSize23:	db	8
 29978                              <1> LinGreenFieldPosition23:db	8
 29979                              <1> LinBlueMaskSize23:	db	8
 29980                              <1> LinBlueFieldPosition23:	db	0
 29981                              <1> LinRsvdMaskSize23:	db	0
 29982                              <1> LinRsvdFieldPosition23:	db	0
 29983                              <1> MaxPixelClock23:	dd	0
 29984                              <1> 
 29985                              <1> 			dw	0192h ; 1920x1080x32
 29986                              <1> ModeAttributes24: 	dw	MODE_ATTRIBUTES
 29987                              <1> WinAAttributes24: 	db	WINA_ATTRIBUTES
 29988                              <1> WinBAttributes24: 	db	0
 29989                              <1> WinGranularity24: 	dw	VBE_DISPI_BANK_SIZE_KB
 29990                              <1> WinSize24: 		dw	VBE_DISPI_BANK_SIZE_KB
 29991                              <1> WinASegment24:		dw	VGAMEM_GRAPH
 29992                              <1> WinBSegment24:		dw	0000h
 29993                              <1> WinFuncPtr24:		dd	0
 29994                              <1> BytesPerScanLine24:	dw	7680
 29995                              <1> XResolution24:		dw	1920
 29996                              <1> YResolution24:		dw	1080
 29997                              <1> XCharSize24:		db	8
 29998                              <1> YCharSize24:		db	16
 29999                              <1> NumberOfPlanes24:	db	1
 30000                              <1> BitsPerPixel24:		db	32
 30001                              <1> NumberOfBanks24:	db	127
 30002                              <1> MemoryModel24:		db	VBE_MEMORYMODEL_DIRECT_COLOR
 30003                              <1> BankSize24:		db	0
 30004                              <1> NumberOfImagePages24:	db	1
 30005                              <1> Reserved_page24:	db	0
 30006                              <1> RedMaskSize24:		db	8
 30007                              <1> RedFieldPosition24:	db	16
 30008                              <1> GreenMaskSize24:	db	8
 30009                              <1> GreenFieldPosition24:	db	8
 30010                              <1> BlueMaskSize24:		db	8
 30011                              <1> BlueFieldPosition24:	db	0
 30012                              <1> RsvdMaskSize24:		db	8
 30013                              <1> RsvdFieldPosition24:	db	24
 30014                              <1> DirectColorModeInfo24:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 30015                              <1> PhysBasePtr24:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
 30016                              <1> OffScreenMemOffset24:	dd	0
 30017                              <1> OffScreenMemSize24:	dw	0
 30018                              <1> LinBytesPerScanLine24:	dw 	7680
 30019                              <1> BnkNumberOfPages24: 	db	0
 30020                              <1> LinNumberOfPages24: 	db	0
 30021                              <1> LinRedMaskSize24:	db	8
 30022                              <1> LinRedFieldPosition24:	db	16
 30023                              <1> LinGreenMaskSize24:	db	8
 30024                              <1> LinGreenFieldPosition24:db	8
 30025                              <1> LinBlueMaskSize24:	db	8
 30026                              <1> LinBlueFieldPosition24:	db	0
 30027                              <1> LinRsvdMaskSize24:	db	8
 30028                              <1> LinRsvdFieldPosition24:	db	24
 30029                              <1> MaxPixelClock24:	dd	0
 30030                              <1> 
 30031                              <1> VBE_VESA_MODE_END_OF_LIST: dw	0
 30032                              <1> 
 30033                              <1> %endif
 30034                              <1> 
 30035                              <1> ; 24/11/2020
 30036                              <1> 
 30037                              <1> direct_color_fields:
 30038                              <1> 	; 24/11/2020
 30039                              <1> 
 30040                              <1> ; (vbetables-gen.c)
 30041                              <1> ; // Direct Color fields 
 30042                              <1> ; (required for direct/6 and YUV/7 memory models)
 30043                              <1> ; switch(pm->depth) {
 30044                              <1>     
 30045                              <1> ;case 8:
 30046 00006AEA 00                  <1> r_size_8:  db 0
 30047 00006AEB 00                  <1> r_pos_8:   db 0
 30048 00006AEC 00                  <1> g_size_8:  db 0
 30049 00006AED 00                  <1> g_pos_8:   db 0
 30050 00006AEE 00                  <1> b_size_8:  db 0
 30051 00006AEF 00                  <1> b_pos_8:   db 0
 30052 00006AF0 00                  <1> a_size_8:  db 0
 30053 00006AF1 00                  <1> a_pos_8:   db 0
 30054                              <1> 
 30055                              <1> ;case 16:
 30056 00006AF2 05                  <1> r_size_16:  db 5
 30057 00006AF3 0B                  <1> r_pos_16:   db 11
 30058 00006AF4 06                  <1> g_size_16:  db 6
 30059 00006AF5 05                  <1> g_pos_16:   db 5
 30060 00006AF6 05                  <1> b_size_16:  db 5
 30061 00006AF7 00                  <1> b_pos_16:   db 0
 30062 00006AF8 00                  <1> a_size_16:  db 0
 30063 00006AF9 00                  <1> a_pos_16:   db 0
 30064                              <1> 
 30065                              <1> ;case 24:
 30066 00006AFA 08                  <1> r_size_24:  db 8
 30067 00006AFB 10                  <1> r_pos_24:   db 16
 30068 00006AFC 08                  <1> g_size_24:  db 8
 30069 00006AFD 08                  <1> g_pos_24:   db 8
 30070 00006AFE 08                  <1> b_size_24:  db 8
 30071 00006AFF 00                  <1> b_pos_24:   db 0
 30072 00006B00 00                  <1> a_size_24:  db 0
 30073 00006B01 00                  <1> a_pos_24:   db 0
 30074                              <1> 
 30075                              <1> ;case 32:
 30076 00006B02 08                  <1> r_size_32:  db 8
 30077 00006B03 10                  <1> r_pos_32:   db 16
 30078 00006B04 08                  <1> g_size_32:  db 8
 30079 00006B05 08                  <1> g_pos_32:   db 8
 30080 00006B06 08                  <1> b_size_32:  db 8
 30081 00006B07 00                  <1> b_pos_32:   db 0
 30082 00006B08 08                  <1> a_size_32:  db 8
 30083 00006B09 18                  <1> a_pos_32:   db 24
 30084                                  ;%include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
 30085                                  ;;;
 30086                                  
 30087                                  Align 2
 30088                                  
 30089                                  %include 'sysdefs.s' ; 24/01/2015
 30090                              <1> ; ****************************************************************************
 30091                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - SYSTEM DEFINITIONS : sysdefs.s
 30092                              <1> ; ----------------------------------------------------------------------------
 30093                              <1> ; Last Update: 23/07/2022  (Previous: 31/12/2017)
 30094                              <1> ; ----------------------------------------------------------------------------
 30095                              <1> ; Beginning: 24/01/2016
 30096                              <1> ; ----------------------------------------------------------------------------
 30097                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
 30098                              <1> ; ----------------------------------------------------------------------------
 30099                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 30100                              <1> ; sysdefs.inc (14/11/2015)
 30101                              <1> ; ****************************************************************************
 30102                              <1> 
 30103                              <1> ; Retro UNIX 386 v1 Kernel - SYSDEFS.INC
 30104                              <1> ; Last Modification: 14/11/2015
 30105                              <1> ;
 30106                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
 30107                              <1> ; (Modified from 
 30108                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
 30109                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
 30110                              <1> ; 	UNIX.ASM (MASM 6.11) --> SYSDEFS.INC (NASM 2.11)
 30111                              <1> ; ----------------------------------------------------------------------------
 30112                              <1> ;
 30113                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
 30114                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
 30115                              <1> ; <Bell Laboratories (17/3/1972)>
 30116                              <1> ; <Preliminary Release of UNIX Implementation Document>
 30117                              <1> ;
 30118                              <1> ; ****************************************************************************
 30119                              <1> 
 30120                              <1> nproc 	equ	16  ; number of processes
 30121                              <1> ;nfiles equ	50
 30122                              <1> ntty	equ     8   ; 8+1 -> 8 (10/05/2013)
 30123                              <1> nbuf	equ	4   ; 6 ;; 21/08/2015 - 'namei' buffer problem when nbuf > 4 	
 30124                              <1> 		; NOTE: If fd0 super block buffer addres is beyond of the 1st
 30125                              <1> 		; 32K, DMA r/w routine or someting else causes a jump to 
 30126                              <1> 		; kernel panic routine (in 'alloc' routine, in u5.s)
 30127                              <1> 		; because of invalid buffer content (r/w error). 
 30128                              <1> 		; When all buffers are set before the end of the 1st 32k,
 30129                              <1> 		; there is no problem!? (14/11/2015) 
 30130                              <1> 
 30131                              <1> ;csgmnt	equ	2000h	; 26/05/2013 (segment of process 1)
 30132                              <1> ;core	equ 	0  	    ; 19/04/2013	
 30133                              <1> ;ecore	equ	32768 - 64  ; 04/06/2013 (24/05/2013)
 30134                              <1> 	; (if total size of argument list and arguments is 128 bytes)
 30135                              <1> 	; maximum executable file size = 32768-(64+40+128-6) = 32530 bytes
 30136                              <1> 	; maximum stack size = 40 bytes (+6 bytes for 'IRET' at 32570)	
 30137                              <1> 	; initial value of user's stack pointer = 32768-64-128-2 = 32574
 30138                              <1> 	; 	(sp=32768-args_space-2 at the beginning of execution)
 30139                              <1> 	; argument list offset = 32768-64-128 = 32576 (if it is 128 bytes)
 30140                              <1> 	; 'u' structure offset (for the '/core' dump file) = 32704
 30141                              <1> 	; '/core' dump file size = 32768 bytes
 30142                              <1>  
 30143                              <1> ; 08/03/2014 
 30144                              <1> ;sdsegmnt equ	6C0h  ; 256*16 bytes (swap data segment size for 16 processes)		 	 
 30145                              <1> ; 19/04/2013 Retro UNIX 8086 v1 feaure only !
 30146                              <1> ;;sdsegmnt equ 	740h  ; swap data segment (for user structures and registers)
 30147                              <1> 
 30148                              <1> ; 30/08/2013
 30149                              <1> time_count equ 4 ; 10 --> 4 01/02/2014
 30150                              <1> 
 30151                              <1> ; 05/02/2014
 30152                              <1> ; process status
 30153                              <1> ;SFREE 	equ 0
 30154                              <1> ;SRUN	equ 1
 30155                              <1> ;SWAIT	equ 2
 30156                              <1> ;SZOMB	equ 3
 30157                              <1> ;SSLEEP	equ 4 ; Retro UNIX 8086 V1 extension (for sleep and wakeup)
 30158                              <1> 
 30159                              <1> ; 09/03/2015
 30160                              <1> userdata equ 80000h ; user structure data address for current user ; temporary
 30161                              <1> swap_queue equ 90000h - 2000h ; swap queue address ; temporary
 30162                              <1> swap_alloc_table equ 0D0000h  ;  swap allocation table address ; temporary
 30163                              <1> 
 30164                              <1> ; 17/09/2015
 30165                              <1> ESPACE equ 48 ; [u.usp] (at 'sysent') - [u.sp] value for error return
 30166                              <1> 
 30167                              <1> ; 31/12/2017
 30168                              <1> ; 19/02/2017
 30169                              <1> ; 15/10/2016
 30170                              <1> ; 20/05/2016
 30171                              <1> ; 19/05/2016
 30172                              <1> ; 18/05/2016
 30173                              <1> ; 29/04/2016 
 30174                              <1> ; TRDOS 386 (TRDOS v2.0) system calls - temporary List 
 30175                              <1> ; 14/07/2013 - 21/09/2015 (Retro UNIX 8086 & 386 system calls) 
 30176                              <1> _ver 	equ 0 ; Get TRDOS version (v2.0)
 30177                              <1> _exit 	equ 1
 30178                              <1> _fork 	equ 2
 30179                              <1> _read 	equ 3
 30180                              <1> _write	equ 4
 30181                              <1> _open	equ 5
 30182                              <1> _close 	equ 6
 30183                              <1> _wait 	equ 7
 30184                              <1> _creat 	equ 8
 30185                              <1> _rename	equ 9  ; TRDOS 386, Rename File (31/12/2017)	
 30186                              <1> _delete	equ 10 ; TRDOS 386, Delete File (29/12/2017)
 30187                              <1> _exec	equ 11
 30188                              <1> _chdir	equ 12
 30189                              <1> _time 	equ 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
 30190                              <1> _mkdir 	equ 14
 30191                              <1> _chmod	equ 15 ; TRDOS 386, Change Attributes (30/12/2017) 
 30192                              <1> _rmdir	equ 16 ; TRDOS 386, Remove Directory (29/12/2017)
 30193                              <1> _break	equ 17
 30194                              <1> _drive	equ 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
 30195                              <1> _seek	equ 19
 30196                              <1> _tell 	equ 20
 30197                              <1> _mem	equ 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
 30198                              <1> _prompt	equ 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
 30199                              <1> _path	equ 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
 30200                              <1> _env	equ 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
 30201                              <1> _stime	equ 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
 30202                              <1> _quit	equ 26	
 30203                              <1> _intr	equ 27
 30204                              <1> _dir	equ 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
 30205                              <1> _emt 	equ 29
 30206                              <1> _ldrvt 	equ 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
 30207                              <1> _video  equ 31 ; TRDOS 386 Video Functions (16/05/2016)
 30208                              <1> _audio	equ 32 ; TRDOS 386 Video Functions (16/05/2016)
 30209                              <1> _timer	equ 33 ; TRDOS 386 Timer Functions (18/05/2016)
 30210                              <1> _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
 30211                              <1> _msg	equ 35 ; Retro UNIX 386 v1 feature only !
 30212                              <1> _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
 30213                              <1> _fpsave equ 37 ; TRDOS 386 FPU state option (28/02/2017)
 30214                              <1> _pri 	equ 38 ; change priority - TRDOS 386 (20/05/2016)
 30215                              <1> _rele	equ 39 ; TRDOS 386 (19/05/2016)
 30216                              <1> _fff	equ 40 ; Find First File - TRDOS 386 (15/10/2016)
 30217                              <1> _fnf	equ 41 ; Find Next File - TRDOS 386 (15/10/2016)
 30218                              <1> _alloc	equ 42 ; Allocate memory - TRDOS 386 (19/02/2017)
 30219                              <1> 	       ; TRDOS 386 (19/02/2017) DMA buff fuctions		
 30220                              <1> _dalloc equ 43 ; Deallocate mem - TRDOS 386 (19/02/2017)
 30221                              <1> _calbac equ 44 ; Set IRQ callback - TRDOS 386 (20/02/2017)  				
 30222                              <1> _dma	equ 45 ; DMA service - TRDOS 386 (20/08/2017)  
 30223                              <1> 
 30224                              <1> %macro sys 1-4
 30225                              <1>     ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
 30226                              <1>     ; 03/09/2015	
 30227                              <1>     ; 13/04/2015
 30228                              <1>     ; Retro UNIX 386 v1 system call.		
 30229                              <1>     %if %0 >= 2   
 30230                              <1>         mov ebx, %2
 30231                              <1>         %if %0 >= 3    
 30232                              <1>             mov ecx, %3
 30233                              <1>             %if %0 = 4
 30234                              <1>                mov edx, %4   
 30235                              <1>             %endif
 30236                              <1>         %endif
 30237                              <1>     %endif
 30238                              <1>     mov eax, %1
 30239                              <1>     ;int 30h
 30240                              <1>     int 40h ; TRDOS 386 (TRDOS v2.0)		   
 30241                              <1> %endmacro
 30242                              <1> 
 30243                              <1> ; TRDOS 386 system calls, interrupt number
 30244                              <1> ; 25/12/2016
 30245                              <1> SYSCALL_INT_NUM   equ '40' ; '40h'
 30246                              <1> 
 30247                              <1> ; 13/05/2015 - ERROR CODES
 30248                              <1> ERR_FILE_NOT_OPEN  equ 10 ; 'file not open !' error
 30249                              <1> ERR_FILE_ACCESS    equ 11 ; 'permission denied !' error
 30250                              <1> ; 14/05/2015
 30251                              <1> ERR_DIR_ACCESS     equ 11 ; 'permission denied !' error
 30252                              <1> ERR_FILE_NOT_FOUND equ 12 ; 'file not found !' error
 30253                              <1> ERR_TOO_MANY_FILES equ 13 ; 'too many open files !' error
 30254                              <1> ERR_DIR_EXISTS     equ 14 ; 'directory already exists !' error 	
 30255                              <1> ; 16/05/2015		
 30256                              <1> ERR_DRV_NOT_RDY    equ 15 ; 'drive not ready !' error
 30257                              <1> ; 18/05/2015
 30258                              <1> ERR_DEV_NOT_RDY    equ 15 ; 'device not ready !' error
 30259                              <1> ERR_DEV_ACCESS     equ 11 ; 'permission denied !' error 
 30260                              <1> ERR_DEV_NOT_OPEN   equ 10 ; 'device not open !' error	
 30261                              <1> ; 07/06/2015
 30262                              <1> ERR_FILE_EOF	   equ 16 ; 'end of file !' error
 30263                              <1> ERR_DEV_VOL_SIZE   equ 16 ; 'out of volume !' error
 30264                              <1> ; 09/06/2015
 30265                              <1> ERR_DRV_READ	   equ 17 ; 'disk read error !'
 30266                              <1> ERR_DRV_WRITE	   equ 18 ; 'disk write error !'
 30267                              <1> ; 16/06/2015
 30268                              <1> ERR_NOT_DIR	   equ 19 ; 'not a (valid) directory !' error
 30269                              <1> ERR_FILE_SIZE	   equ 20 ; 'file size error !'	
 30270                              <1> ; 22/06/2015
 30271                              <1> ERR_NOT_SUPERUSER  equ 11 ; 'permission denied !' error
 30272                              <1> ERR_NOT_OWNER      equ 11 ; 'permission denied !' error
 30273                              <1> ERR_NOT_FILE       equ 11 ; 'permission denied !' error	
 30274                              <1> ; 23/06/2015
 30275                              <1> ERR_FILE_EXISTS    equ 14 ; 'file already exists !' error
 30276                              <1> ERR_DRV_NOT_SAME   equ 21 ; 'not same drive !' error
 30277                              <1> ERR_DIR_NOT_FOUND  equ 12 ; 'directory not found !' error
 30278                              <1> ERR_NOT_EXECUTABLE equ 22 ; 'not executable file !' error
 30279                              <1> ; 27/06/2015
 30280                              <1> ERR_INV_PARAMETER  equ 23 ; 'invalid parameter !' error
 30281                              <1> ERR_INV_DEV_NAME   equ 24 ; 'invalid device name !' error
 30282                              <1> ; 29/06/2015
 30283                              <1> ERR_TIME_OUT	   equ 25 ; 'time out !' error			
 30284                              <1> ERR_DEV_NOT_RESP   equ 25 ; 'device not responding !' error
 30285                              <1> ; 10/10/2016
 30286                              <1> ERR_INV_FILE_NAME  equ 26 ; 'invalid file name !' error
 30287                              <1> ERR_INV_FLAGS	   equ 23 ; 'invalid flags !' error
 30288                              <1> ; For code compatibility with previous version of TRDOS (2011)
 30289                              <1> ; (Temporary error codes for current TRDOS 386 -2016- version) 
 30290                              <1> ERR_NO_MORE_FILES  equ 12 ; 'no more files !' error
 30291                              <1> ERR_PATH_NOT_FOUND equ  3 ; 'path not found !' error 
 30292                              <1> 			  ; 'dir not found !' ; TRDOS 8086
 30293                              <1> ERR_NOT_FOUND:	   equ  2 ; 'file not found !' ; TRDOS 8086
 30294                              <1> ERR_DISK_SPACE	   equ 39 ; 'out of volume !' TRDOS 8086
 30295                              <1> 			  ; 'insufficient disk space !' ; 27h
 30296                              <1> ERR_DISK_WRITE	   equ 30 ; 'disk write protected !' ; 16/10/2016
 30297                              <1> ERR_ACCESS_DENIED  equ  5 ; 'access denied !' ; TRDOS 8086 	
 30298                              <1> ; 28/02/2017
 30299                              <1> ERR_PERM_DENIED	   equ 11 ; 'permission denied !' error  	
 30300                              <1> ; 18/05/2016
 30301                              <1> ERR_MISC	   equ 27 ; miscellaneous/other errors
 30302                              <1> ; 15/10/2016
 30303                              <1> ; TRDOS 8086 -> TRDOS 386 (0Bh -> 28)
 30304                              <1> ERR_INV_FORMAT	   equ 28 ; 'invalid format !' error
 30305                              <1> ; TRDOS 8086 -> TRDOS 386 (0Dh -> 29)
 30306                              <1> ERR_INV_DATA	   equ 29 ; 'invalid data !' error
 30307                              <1> ; TRDOS 8086 -> TRDOS 386 (0Eh -> 20)
 30308                              <1> ERR_ZERO_LENGTH	   equ 20  ; 'zero length !' error 	
 30309                              <1> ; TRDOS 8086 -> TRDOS 386 (15h -> 17, 1Dh -> 18, 1Eh -> 17) 	
 30310                              <1> ERR_DRV_NR_READ	   equ 17 ; 'drive not ready or read error !'
 30311                              <1> ERR_DRV_NR_WRITE   equ 18 ; 'drive not ready or write error !'		
 30312                              <1> ; 15/10/2016
 30313                              <1> ERR_INV_PATH_NAME  equ 19 ; 'bad path name !' error
 30314                              <1> ERR_BAD_CMD_ARG	   equ  1 ; 'bad command argument !' ; TRDOS 8086
 30315                              <1> ERR_INV_FNUMBER	   equ  1 ; 'invalid function number !' ; TRDOS 8086
 30316                              <1> ERR_BIG_FILE	   equ  8 ; 'big file & out of memory ! ; TRDOS 8086 	
 30317                              <1> ERR_BIG_DATA	   equ  8 ; 'big data & out of memory ! ; TRDOS 8086
 30318                              <1> ERR_CLUSTER	   equ 35 ; 'cluster not available !' ; TRDOS 8086
 30319                              <1> ERR_OUT_OF_MEMORY  equ  4 ; 'out of memory !'
 30320                              <1> 			  ; 'insufficient memory !'
 30321                              <1> ERR_P_VIOLATION	   equ	6 ; 'protection violation !'
 30322                              <1> ERR_PAGE_FAULT	   equ 224 ;'page fault !' ;0E0h						 
 30323                              <1> ERR_SWP_DISK_READ  	   equ 40
 30324                              <1> ERR_SWP_DISK_NOT_PRESENT   equ 41
 30325                              <1> ERR_SWP_SECTOR_NOT_PRESENT equ 42
 30326                              <1> ERR_SWP_NO_FREE_SPACE      equ 43
 30327                              <1> ERR_SWP_DISK_WRITE         equ 44
 30328                              <1> ERR_SWP_NO_PAGE_TO_SWAP    equ 45
 30329                              <1> ; 10/04/2017
 30330                              <1> ERR_BUFFER	   equ 46  ; 'buffer error !'
 30331                              <1> ; 28/08/2017 (20/08/2017)
 30332                              <1> ERR_DMA		   equ -1  ; DMA buffer (allocation/misc.) error!
 30333                              <1> 
 30334                              <1> ; 26/08/2015
 30335                              <1> ; 24/07/2015
 30336                              <1> ; 24/06/2015
 30337                              <1> MAX_ARG_LEN	   equ 256 ; max. length of sys exec arguments
 30338                              <1> ; 01/07/2015
 30339                              <1> MAX_MSG_LEN	   equ 255 ; max. msg length for 'sysmsg'
 30340                              <1> ;	
 30341                              <1> ; 06/10/2016
 30342                              <1> ;OPENFILES	   equ 10  ; max. number of open files (system)
 30343                              <1> ; 23/07/2022
 30344                              <1> OPENFILES	   equ 32  ; max. number of open files (system)
 30345                              <1> ; 07/10/2016
 30346                              <1> ;NUMOFDEVICES	   equ 20  ; max. num of available devices (sys)
 30347                              <1> 			 		
 30348                                  %include 'trdosk0.s' ; 04/01/2016 
 30349                              <1> ; ****************************************************************************
 30350                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DEFINITIONS : trdosk0.s
 30351                              <1> ; ----------------------------------------------------------------------------
 30352                              <1> ; Last Update: 29/02/2016
 30353                              <1> ; ----------------------------------------------------------------------------
 30354                              <1> ; Beginning: 04/01/2016
 30355                              <1> ; ----------------------------------------------------------------------------
 30356                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
 30357                              <1> ; ----------------------------------------------------------------------------
 30358                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 30359                              <1> ; TRDOS2.ASM (09/11/2011)
 30360                              <1> ; ****************************************************************************
 30361                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
 30362                              <1> ;
 30363                              <1> ; Masterboot / Partition Table at Beginning+1BEh
 30364                              <1> ptBootable       equ 0
 30365                              <1> ptBeginHead      equ 1
 30366                              <1> ptBeginSector    equ 2
 30367                              <1> ptBeginCylinder  equ 3
 30368                              <1> ptFileSystemID   equ 4
 30369                              <1> ptEndHead        equ 5
 30370                              <1> ptEndSector      equ 6
 30371                              <1> ptEndCylinder    equ 7
 30372                              <1> ptStartSector    equ 8
 30373                              <1> ptSectors        equ 12
 30374                              <1> 
 30375                              <1> ; Boot Sector Parameters at 7C00h
 30376                              <1> DataArea1     equ -4
 30377                              <1> DataArea2     equ -2
 30378                              <1> BootStart     equ 0h
 30379                              <1> OemName       equ 03h
 30380                              <1> BytesPerSec   equ 0Bh
 30381                              <1> SecPerClust   equ 0Dh
 30382                              <1> ResSectors    equ 0Eh
 30383                              <1> FATs          equ 10h
 30384                              <1> RootDirEnts   equ 11h
 30385                              <1> Sectors       equ 13h
 30386                              <1> Media         equ 15h
 30387                              <1> FATSecs       equ 16h
 30388                              <1> SecPerTrack   equ 18h
 30389                              <1> Heads         equ 1Ah 
 30390                              <1> Hidden1       equ 1Ch
 30391                              <1> Hidden2       equ 1Eh
 30392                              <1> HugeSec1      equ 20h
 30393                              <1> HugeSec2      equ 22h
 30394                              <1> DriveNumber   equ 24h
 30395                              <1> Reserved1     equ 25h
 30396                              <1> bootsignature equ 26h                 
 30397                              <1> VolumeID      equ 27h
 30398                              <1> VolumeLabel   equ 2Bh
 30399                              <1> FileSysType   equ 36h          
 30400                              <1> Reserved2     equ 3Eh                           ; Starting cluster of P2000
 30401                              <1> 
 30402                              <1> ; FAT32 BPB Structure
 30403                              <1> FAT32_FAT_Size equ 36
 30404                              <1> FAT32_RootFClust equ 44
 30405                              <1> FAT32_FSInfoSec equ 48
 30406                              <1> FAT32_DrvNum equ 64
 30407                              <1> FAT32_BootSig equ 66
 30408                              <1> FAT32_VolID equ 67
 30409                              <1> FAT32_VolLab equ 71
 30410                              <1> FAT32_FilSysType equ 82
 30411                              <1> 
 30412                              <1> ; BIOS Disk Parameters
 30413                              <1> DPDiskNumber  equ 0h
 30414                              <1> DPDType       equ 1h
 30415                              <1> DPReturn      equ 2h
 30416                              <1> DPHeads       equ 3h
 30417                              <1> DPCylinders   equ 4h
 30418                              <1> DPSecPerTrack equ 6h
 30419                              <1> DPDisks       equ 7h
 30420                              <1> DPTableOff    equ 8h
 30421                              <1> DPTableSeg    equ 0Ah
 30422                              <1> DPNumOfSecs   equ 0Ch
 30423                              <1> 
 30424                              <1> ; BIOS INT 13h Extensions (LBA extensions)
 30425                              <1> ; Just After DP Data (DPDiskNumber+)
 30426                              <1> DAP_PacketSize equ 10h  ; If extensions present, this byte will be >=10h
 30427                              <1> DAP_Reserved1 equ 11h   ; Reserved Byte 
 30428                              <1> DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127
 30429                              <1> DAP_Reserved2 equ 13h   ; Reserved Byte
 30430                              <1> DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET
 30431                              <1> DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1
 30432                              <1>                         ; C1= Selected Cylinder Number
 30433                              <1>                         ; H0= Number Of Heads (Maximum Head Number + 1)
 30434                              <1>                         ; H1= Selected Head Number
 30435                              <1>                         ; S0= Maximum Sector Number
 30436                              <1>                         ; S1= Selected Sector Number
 30437                              <1>                         ; QUAD WORD
 30438                              <1> ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh
 30439                              <1>                              ; QUAD WORD (Also, value in 0h must be 18h) 
 30440                              <1>                              ; TR-DOS will not use 64 bit Flat Address
 30441                              <1> 
 30442                              <1> ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters"
 30443                              <1> ; Just After DP Data (DPDiskNumber+)
 30444                              <1> GetDParams_48h equ 20h ; Word. Data Length, must be 26 (1Ah) for short data.
 30445                              <1> GDP_48h_InfoFlag equ 22h ; Word
 30446                              <1> ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid.
 30447                              <1> GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders.
 30448                              <1> GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads.
 30449                              <1> GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track.
 30450                              <1> GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors.
 30451                              <1> GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector.
 30452                              <1> 
 30453                              <1> ; TR-DOS Standalone Program Extensions to the DiskParams Block
 30454                              <1> ; Just After DP Data (DPDiskNumber+)
 30455                              <1> TRDP_CurrentSector equ 3Ah  ; DX:AX (LBA)
 30456                              <1> TRDP_SectorCount equ 3Eh    ; CX (or Counter)
 30457                              <1> 
 30458                              <1> 
 30459                              <1> ; DOS Logical Disks
 30460                              <1> LD_Name equ 0
 30461                              <1> LD_DiskType equ 1
 30462                              <1> LD_PhyDrvNo equ 2
 30463                              <1> LD_FATType equ 3
 30464                              <1> LD_FSType equ 4
 30465                              <1> LD_LBAYes equ 5
 30466                              <1> LD_BPB equ 6
 30467                              <1> LD_FATBegin equ 96
 30468                              <1> LD_ROOTBegin equ 100
 30469                              <1> LD_DATABegin equ 104
 30470                              <1> LD_StartSector equ 108
 30471                              <1> LD_TotalSectors equ 112
 30472                              <1> LD_FreeSectors equ 116
 30473                              <1> LD_Clusters equ 120
 30474                              <1> LD_PartitionEntry equ 124
 30475                              <1> LD_DParamEntry equ 125
 30476                              <1> LD_MediaChanged equ 126
 30477                              <1> LD_CDirLevel equ 127
 30478                              <1> LD_CurrentDirectory equ 128
 30479                              <1> 
 30480                              <1> ; Singlix FS Extensions to DOS Logical Disks
 30481                              <1> ; 03/01/2010 (LD_BPB compatibility for CHS r/w)
 30482                              <1> 
 30483                              <1> LD_FS_Name equ 0
 30484                              <1> LD_FS_DiskType equ 1
 30485                              <1> LD_FS_PhyDrvNo equ 2
 30486                              <1> LD_FS_FATType equ 3
 30487                              <1> LD_FS_FSType equ 4
 30488                              <1> LD_FS_LBAYes equ 5
 30489                              <1> LD_FS_BPB equ 6
 30490                              <1> LD_FS_MediaAttrib equ 6
 30491                              <1> LD_FS_VersionMajor equ 7
 30492                              <1> LD_FS_RootDirD equ 8
 30493                              <1> LD_FS_MATLocation equ 12
 30494                              <1> LD_FS_Reserved1 equ 16 ;1 reserved byte
 30495                              <1> LD_FS_BytesPerSec equ 17 ; LD_BPB + 0Bh
 30496                              <1> LD_FS_Reserved2 equ 19 ;2 reserved byte
 30497                              <1> LD_FS_DATLocation equ 20
 30498                              <1> LD_FS_DATSectors equ 24
 30499                              <1> LD_FS_Reserved3 equ 28 ;3 reserved word
 30500                              <1> LD_FS_SecPerTrack equ 30 ; LD_BPB + 18h
 30501                              <1> LD_FS_NumHeads equ 32    ; LD_BPB + 1Ah
 30502                              <1> LD_FS_UnDelDirD equ 34
 30503                              <1> LD_FS_Reserved4 equ 38 ;4 reserved word
 30504                              <1> LD_FS_VolumeSerial equ 40
 30505                              <1> LD_FS_VolumeName equ 44
 30506                              <1> LD_FS_BeginSector equ 108
 30507                              <1> LD_FS_VolumeSize equ 112
 30508                              <1> LD_FS_FreeSectors equ 116
 30509                              <1> LD_FS_FirstFreeSector equ 120
 30510                              <1> LD_FS_PartitionEntry equ 124
 30511                              <1> LD_FS_DParamEntry equ 125
 30512                              <1> LD_FS_MediaChanged equ 126
 30513                              <1> LD_FS_CDirLevel equ 127
 30514                              <1> LD_FS_CDIR_Converted equ 128
 30515                              <1> 
 30516                              <1> ; Valid FAT Types
 30517                              <1> FS_FAT12 equ 1
 30518                              <1> FS_FAT16_CHS equ 2
 30519                              <1> FS_FAT32_CHS equ 3
 30520                              <1> FS_FAT16_LBA equ 4
 30521                              <1> FS_FAT32_LBA equ 5
 30522                              <1> 
 30523                              <1> ; Cursor Location
 30524                              <1> CCCpointer equ  0450h   ; BIOS data, current cursor column
 30525                              <1> ; FAT Clusters EOC sign
 30526                              <1> FAT12EOC equ 0FFFh
 30527                              <1> FAT16EOC equ 0FFFFh
 30528                              <1> ;FAT32EOC equ 0FFFFFFFh ; It is not direct usable for 8086 code
 30529                              <1> ; BAD Cluster
 30530                              <1> FAT12BADC equ 0FF7h
 30531                              <1> FAT16BADC equ 0FFF7h
 30532                              <1> ;FAT32BADC equ 0FFFFFF7h ; It is not direct usable for 8086 code
 30533                              <1> ; MS-DOS FAT16 FS (Maximum Possible) Last Cluster Number= 0FFF6h 
 30534                              <1> 
 30535                              <1> ; TRFS
 30536                              <1> 
 30537                              <1> bs_FS_JmpBoot equ 0 ; jmp short bsBootCode
 30538                              <1>                 ; db 0EBh, db 3Fh, db 90h
 30539                              <1> bs_FS_Identifier equ 3  ; db 'FS', db 0
 30540                              <1> bs_FS_BytesPerSec equ 6 ; dw 512
 30541                              <1> bs_FS_MediaAttrib equ 8 ; db 3
 30542                              <1> bs_FS_PartitionID equ 9 ; db 0A1h
 30543                              <1> bs_FS_VersionMaj equ 10 ; db 01h
 30544                              <1> bs_FS_VersionMin equ 11 ; db 0
 30545                              <1> bs_FS_BeginSector equ 12   ; dd 0 
 30546                              <1> bs_FS_VolumeSize equ 16 ; dd 2880
 30547                              <1> bs_FS_StartupFD equ 20 ; dd 0
 30548                              <1> bs_FS_MATLocation equ 24 ; dd 1
 30549                              <1> bs_FS_RootDirD equ 28 ; dd 8
 30550                              <1> bs_FS_SystemConfFD equ 32 ; dd 0
 30551                              <1> bs_FS_SwapFD equ 36 ; dd 0
 30552                              <1> bs_FS_UnDelDirD equ 40 ; dd 0
 30553                              <1> bs_FS_DriveNumber equ 44 ; db 0
 30554                              <1> bs_FS_LBA_Ready equ 45 ; db 0
 30555                              <1> bs_FS_MagicWord equ 46 
 30556                              <1> bs_FS_SecPerTrack equ 46 ; db 0A1h
 30557                              <1> bs_FS_Heads equ 47 ; db 01h 
 30558                              <1> bs_FS_OperationSys equ 48 ; db "TR-SINGLIX v1.0b"
 30559                              <1> bs_FS_Terminator equ 64 ; db 0
 30560                              <1> bs_FS_BootCode equ 65 
 30561                              <1> 
 30562                              <1> FS_MAT_DATLocation equ 12
 30563                              <1> FS_MAT_DATScount equ 16
 30564                              <1> FS_MAT_FreeSectors equ 20
 30565                              <1> FS_MAT_FirstFreeSector equ 24
 30566                              <1> FS_RDT_VolumeSerialNo equ 28
 30567                              <1> FS_RDT_VolumeName equ 64
 30568                              <1> 
 30569                              <1> ; FAT12 + FAT16 + FAT32
 30570                              <1> BS_JmpBoot equ 0
 30571                              <1> BS_OEMName equ 3
 30572                              <1> BPB_BytsPerSec equ 11
 30573                              <1> BPB_SecPerClust equ 13
 30574                              <1> BPB_RsvdSecCnt equ 14
 30575                              <1> BPB_NumFATs equ 16
 30576                              <1> BPB_RootEntCnt equ 17
 30577                              <1> BPB_TotalSec16 equ 19
 30578                              <1> BPB_Media equ 21
 30579                              <1> BPB_FATSz16 equ 22
 30580                              <1> BPB_SecPerTrk equ 24
 30581                              <1> BPB_NumHeads equ 26
 30582                              <1> BPB_HiddSec equ 28
 30583                              <1> BPB_TotalSec32 equ 32
 30584                              <1> 
 30585                              <1> ; FAT12 and FAT16 only
 30586                              <1> BS_DrvNum equ 36
 30587                              <1> BS_Reserved1 equ 37
 30588                              <1> BS_BootSig equ 38
 30589                              <1> BS_VolID equ 39
 30590                              <1> BS_VolLab equ 43
 30591                              <1> BS_FilSysType equ 54 ; 8 bytes
 30592                              <1> BS_BootCode equ 62
 30593                              <1> 
 30594                              <1> ; FAT32 only
 30595                              <1> BPB_FATSz32 equ 36 ; FAT32, 4 bytes
 30596                              <1> BPB_ExtFlags equ 40 ; FAT32, 2 bytes
 30597                              <1> BPB_FSVer equ 42 ; FAT32, 2 bytes
 30598                              <1> BPB_RootClus equ 44 ; FAT32, 4 bytes
 30599                              <1> BPB_FSInfo equ 48 ; FAT 32, 2 bytes 
 30600                              <1> BPB_BkBootSec equ 50 ; FAT32, 2 bytes
 30601                              <1> BPB_Reserved equ 52 ; FAT32, 12 bytes
 30602                              <1> BS_FAT32_DrvNum equ 64 ; FAT32, 1 byte
 30603                              <1> BS_FAT32_Reserved1 equ 65 ; FAT32, 1 byte
 30604                              <1> BS_FAT32_BootSig equ 66 ; FAT32, 1 byte
 30605                              <1> BS_FAT32_VolID equ 67 ; FAT32, 4 bytes
 30606                              <1> BS_FAT32_VolLab equ 71 ; FAT32, 11 bytes
 30607                              <1> BS_FAT32_FilSysType equ 82 ; FAT32, 8 bytes
 30608                              <1> BS_FAT32_BootCode equ 90
 30609                              <1> 
 30610                              <1> ; 29/02/2016
 30611                              <1> ;(FAT32 Free Cluster Count & First Free Cluster values)
 30612                              <1> ;[BPB_Reserved] = Free Cluster Count (offset 52)
 30613                              <1> ;[BPB_Reserved+4] = First Free Cluster (offset 56)
 30614                              <1> 
 30615                              <1> BS_Validation equ 510
 30616                              <1> 
 30617                              <1> ; 15/02/2016
 30618                              <1> ; FILE.ASM - 09/10/2011
 30619                              <1> ; Directory Entry Structure
 30620                              <1> ; 29/10/2009 (According to Microsoft FAT32 File System Specification)
 30621                              <1> DirEntry_Name equ 0
 30622                              <1> DirEntry_Attr equ 11
 30623                              <1> DirEntry_NTRes equ 12
 30624                              <1> DirEntry_CrtTimeTenth equ 13
 30625                              <1> DirEntry_CrtTime equ 14
 30626                              <1> DirEntry_CrtDate equ 16
 30627                              <1> DirEntry_LastAccDate equ 18
 30628                              <1> DirEntry_FstClusHI equ 20
 30629                              <1> DirEntry_WrtTime equ 22
 30630                              <1> DirEntry_WrtDate equ 24
 30631                              <1> DirEntry_FstClusLO equ 26
 30632                              <1> DirEntry_FileSize equ 28
 30633                                  %include 'trdosk1.s' ; 04/01/2016 
 30634                              <1> ; ****************************************************************************
 30635                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - SYS INIT : trdosk1.s
 30636                              <1> ; ----------------------------------------------------------------------------
 30637                              <1> ; Last Update: 25/07/2022 (Previous: 18/04/2021)
 30638                              <1> ; ----------------------------------------------------------------------------
 30639                              <1> ; Beginning: 04/01/2016
 30640                              <1> ; ----------------------------------------------------------------------------
 30641                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 30642                              <1> ; ----------------------------------------------------------------------------
 30643                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 30644                              <1> ; TRDOS2.ASM (09/11/2011)
 30645                              <1> ; ****************************************************************************
 30646                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
 30647                              <1> ;
 30648                              <1> 
 30649                              <1> sys_init:
 30650                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.4) 
 30651                              <1> 	; 20/01/2018  (v2.0.1)
 30652                              <1> 	; 23/01/2017  (v2.0.0)
 30653                              <1> 	; 07/05/2016
 30654                              <1> 	; 02/05/2016
 30655                              <1> 	; 24/04/2016
 30656                              <1> 	; 14/04/2016
 30657                              <1> 	; 13/04/2016
 30658                              <1> 	; 30/03/2016
 30659                              <1> 	; 24/01/2016
 30660                              <1> 	; 06/01/2016
 30661                              <1> 	; 04/01/2016 (TRDOS 386 v2.0 - Beginning)
 30662                              <1> 
 30663                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
 30664 00006B0A B036                <1> 	mov	al, 00110110b ; 36h
 30665 00006B0C E643                <1>  	out	43h, al
 30666 00006B0E 31C0                <1> 	xor	eax, eax  ; sub	al, al ; 0
 30667 00006B10 E640                <1> 	out	40h, al ; LB
 30668 00006B12 E640                <1> 	out	40h, al ; HB
 30669                              <1>  	; 
 30670                              <1> 	; 30/03/2016
 30671                              <1> 	; Clear Logical DOS Disk Description Tables Area
 30672                              <1> 	;xor	eax, eax
 30673 00006B14 BF00010900          <1> 	mov	edi, Logical_DOSDisks
 30674 00006B19 B980060000          <1> 	mov	ecx, 6656/4 ; 26*256 = 6656 bytes
 30675 00006B1E F3AB                <1> 	rep	stosd ; 1664 times 4 bytes
 30676                              <1> 
 30677 00006B20 B83F3A2F00          <1> 	mov	eax, '?:/'
 30678 00006B25 A3[43780100]        <1> 	mov	[Current_Dir_Drv], eax
 30679                              <1> 
 30680                              <1> 	; Logical DRV INIT (only for hard disks)
 30681 00006B2A E8F1030000          <1> 	call 	ldrv_init  ; trdosk2.s
 30682                              <1> 	
 30683                              <1> 	; When floppy_drv_init call is disabled
 30684                              <1> 	; media changed sign is needed
 30685                              <1> 	; for proper drive initialization
 30686                              <1>         
 30687 00006B2F BE00010900          <1> 	mov 	esi, Logical_DOSDisks
 30688 00006B34 B001                <1> 	mov 	al, 1 ; Initialization sign (invalid_fd_parameter)
 30689 00006B36 83C67E              <1> 	add 	esi, LD_MediaChanged ; Media Change Status = 1 (init needed)
 30690 00006B39 8806                <1> 	mov 	[esi], al ; A:
 30691 00006B3B 81C600010000        <1> 	add 	esi, 100h 
 30692 00006B41 8806                <1> 	mov 	[esi], al ; B: 
 30693                              <1>            
 30694                              <1> _current_drive_bootdisk:
 30695 00006B43 8A15[F8640000]      <1> 	mov 	dl, [boot_drv] ; physical drive number
 30696 00006B49 80FAFF              <1> 	cmp 	dl, 0FFh
 30697 00006B4C 740A                <1> 	je 	short _last_dos_diskno_check
 30698                              <1> _boot_drive_check:
 30699 00006B4E 80FA80              <1> 	cmp 	dl, 80h
 30700 00006B51 7218                <1> 	jb 	short _current_drive_a
 30701 00006B53 80EA7E              <1> 	sub 	dl, 7Eh ; C = 2 , D = 3
 30702 00006B56 EB13                <1> 	jmp 	short _current_drive_a 
 30703                              <1> 
 30704                              <1> _last_dos_diskno_check:
 30705 00006B58 8A15[67300100]      <1> 	mov 	dl, [Last_DOS_DiskNo]
 30706 00006B5E 80FA02              <1> 	cmp 	dl, 2
 30707 00006B61 7706                <1> 	ja 	short _current_drive_c
 30708 00006B63 7406                <1> 	je 	short _current_drive_a
 30709 00006B65 30D2                <1> 	xor 	dl, dl ; A:
 30710 00006B67 EB02                <1> 	jmp 	short _current_drive_a
 30711                              <1> 
 30712                              <1> _current_drive_c:
 30713 00006B69 B202                <1> 	mov 	dl, 2 ; C:
 30714                              <1> 
 30715                              <1> _current_drive_a:
 30716 00006B6B 8815[F9640000]      <1> 	mov	[drv], dl
 30717 00006B71 BE[69300100]        <1>         mov     esi, msg_CRLF_temp
 30718 00006B76 E8AF000000          <1> 	call 	print_msg
 30719                              <1> 
 30720 00006B7B 8A15[F9640000]      <1> 	mov	dl, [drv]
 30721                              <1> _default_drive_c:
 30722 00006B81 E8DD0B0000          <1> 	call 	change_current_drive
 30723 00006B86 731C                <1> 	jnc 	short _start_mainprog
 30724                              <1> 
 30725                              <1> _drv_not_ready_error: 
 30726 00006B88 BE[2C330100]        <1> 	mov 	esi, msgl_drv_not_ready
 30727 00006B8D E898000000          <1> 	call 	print_msg
 30728                              <1>         ;jmp	_end_of_mainprog
 30729                              <1> 
 30730                              <1> 	; 20/01/2018
 30731 00006B92 B202                <1> 	mov	dl, 2
 30732 00006B94 3815[F9640000]      <1> 	cmp	[drv], dl
 30733 00006B9A 736C                <1> 	jnb	short _end_of_mainprog
 30734 00006B9C 8815[F9640000]      <1> 	mov	[drv], dl
 30735 00006BA2 EBDD                <1> 	jmp	short _default_drive_c
 30736                              <1> 
 30737                              <1> _start_mainprog:
 30738                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 30739                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.4 - Beginning) 
 30740                              <1> 	; 07/01/2017
 30741                              <1> 	; 07/05/2016
 30742                              <1> 	; 02/05/2016
 30743                              <1> 	; 24/04/2016 (TRDOS 386 v2)
 30744                              <1> 	; Retro UNIX 386 v1, 'sys_init' (u0.s)
 30745                              <1> 	; 23/06/2015
 30746                              <1> 
 30747                              <1> 	; 02/05/2016
 30748                              <1> 	; 24/04/2016
 30749                              <1> 	;mov	ax, 1
 30750                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
 30751 00006BA4 31C0                <1> 	xor	eax, eax
 30752 00006BA6 FEC0                <1> 	inc	al  ; eax = 1
 30753 00006BA8 A2[6D010300]        <1> 	mov	[u.uno], al
 30754 00006BAD 66A3[04010300]      <1> 	mov	[mpid], ax
 30755 00006BB3 66A3[00000300]      <1> 	mov	[p.pid], ax
 30756 00006BB9 A2[60000300]        <1> 	mov	[p.stat], al
 30757 00006BBE C605[64010300]04    <1> 	mov	byte [u.quant], time_count  ; 07/01/2017
 30758                              <1> 	;
 30759 00006BC5 A1[80770100]        <1> 	mov	eax, [k_page_dir]
 30760 00006BCA A3[74010300]        <1> 	mov	[u.pgdir], eax ; reset
 30761                              <1> 	;
 30762 00006BCF E8C7EAFFFF          <1> 	call	allocate_page
 30763                              <1> 	;jc	panic
 30764                              <1> 	; 25/07/2022
 30765 00006BD4 7305                <1> 	jnc	short _start_mainprog_1
 30766 00006BD6 E9AE000000          <1> 	jmp	panic
 30767                              <1> 
 30768                              <1> _start_mainprog_1:
 30769 00006BDB A3[70010300]        <1> 	mov	[u.upage], eax ; user structure page	
 30770 00006BE0 A3[70000300]        <1> 	mov	[p.upage], eax
 30771 00006BE5 E822EBFFFF          <1> 	call	clear_page
 30772                              <1> 	;
 30773                              <1> 	; 24/08/2015
 30774 00006BEA FE0D[10010300]      <1> 	dec 	byte [sysflg] ; FFh = ready for system call
 30775                              <1> 			      ; 0 = executing a system call
 30776                              <1> 	; 13/04/2016
 30777                              <1> 	; Clear Environment Variables Page/Area
 30778 00006BF0 BF00300900          <1> 	mov	edi, Env_Page ; 93000h
 30779 00006BF5 B980000000          <1> 	mov	ecx, Env_Page_Size / 4	; 512/4  (4096/4)				 	  		 	  
 30780 00006BFA 31C0                <1> 	xor	eax, eax
 30781 00006BFC F3AB                <1> 	rep	stosd
 30782                              <1> 
 30783                              <1> 	; 14/04/2016
 30784 00006BFE E811330000          <1>  	call	mainprog_startup_configuration
 30785                              <1> 
 30786 00006C03 E8980C0000          <1>         call    dos_prompt
 30787                              <1>               
 30788                              <1> _end_of_mainprog:
 30789 00006C08 BE[69300100]        <1>         mov     esi, msg_CRLF_temp
 30790 00006C0D E818000000          <1> 	call 	print_msg
 30791 00006C12 BE[6F300100]        <1> 	mov 	esi, mainprog_Version
 30792 00006C17 E80E000000          <1> 	call 	print_msg
 30793                              <1> 	; 24/01/2016
 30794 00006C1C 28E4                <1> 	sub	ah, ah
 30795 00006C1E E8ABA2FFFF          <1> 	call	int16h ; call getch
 30796 00006C23 E939A7FFFF          <1> 	jmp	cpu_reset
 30797                              <1> 
 30798 00006C28 EBFE                <1> infinitiveloop: jmp short infinitiveloop
 30799                              <1> 
 30800                              <1> print_msg:
 30801                              <1> 	; 13/05/2016
 30802                              <1> 	; 04/01/2016
 30803                              <1> 	; 01/07/2015
 30804                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
 30805                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
 30806                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
 30807                              <1> 	;
 30808 00006C2A 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
 30809                              <1> 	;mov	bl, 07h ; Black background, light gray forecolor
 30810                              <1> 
 30811 00006C30 AC                  <1> 	lodsb
 30812                              <1> pmsg1:
 30813 00006C31 56                  <1> 	push 	esi
 30814                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
 30815 00006C32 B307                <1> 	mov	bl, 07h ; Black background, light gray forecolor
 30816 00006C34 E8E5B5FFFF          <1> 	call 	_write_tty
 30817 00006C39 5E                  <1> 	pop	esi
 30818 00006C3A AC                  <1> 	lodsb
 30819 00006C3B 20C0                <1> 	and 	al, al
 30820 00006C3D 75F2                <1> 	jnz 	short pmsg1
 30821 00006C3F C3                  <1> 	retn
 30822                              <1> 
 30823                              <1> clear_screen:
 30824                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 30825                              <1> 	; 06/12/2020 
 30826                              <1> 	; 03/12/2020 (TRDOS 386 v2.0.3)
 30827                              <1> 	; 13/05/2016
 30828                              <1> 	; 30/01/2016
 30829                              <1> 	; 24/01/2016
 30830                              <1> 	; 04/01/2016
 30831 00006C40 0FB61D[AE770100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE] ; video page number (0 to 7)
 30832                              <1> 	; 25/07/2022
 30833                              <1> 	;sub	al, al
 30834                              <1> 	; al = 0
 30835 00006C47 8AA3[AF660000]      <1> 	mov 	ah, [ebx+vmode] ; default = 03h (80x25 text)
 30836 00006C4D 80FC04              <1> 	cmp	ah, 4
 30837 00006C50 7205                <1> 	jb	short cls1
 30838 00006C52 80FC07              <1> 	cmp	ah, 7
 30839 00006C55 752B                <1> 	jne	short vga_clear
 30840                              <1> cls1:
 30841                              <1> 	;mov	bh, bl
 30842                              <1> 	;mov	bl, 7
 30843 00006C57 3A25[9E660000]      <1> 	cmp	ah, [CRT_MODE] ; current video mode ? 
 30844 00006C5D 740D                <1> 	je	short cls2 ; yes (current video mode = 3)
 30845                              <1> 	;;call	set_mode_3 ; set video mode to 3 (& clear screen)
 30846                              <1> 	;;retn
 30847                              <1> 	; 06/12/2020
 30848                              <1> 	;cmp	byte [pmi32], 0
 30849                              <1> 	; 25/07/2022
 30850 00006C5F 383D[D00F0300]      <1> 	cmp	[pmi32], bh ; 0
 30851 00006C65 771B                <1> 	ja	short vga_clear 	
 30852 00006C67 E9BCB5FFFF          <1> 	jmp	set_mode_3
 30853                              <1> cls2:
 30854 00006C6C 88DF                <1> 	mov	bh, bl ; video page (0 to 7)
 30855 00006C6E B307                <1> 	mov	bl, 07h ; attribute to be used on blanked line
 30856                              <1> 	; 25/07/2022
 30857                              <1> 	;sub 	al, al ; 0 = entire window
 30858                              <1> 	;xor 	cx, cx
 30859                              <1> 	; 25/07/2022
 30860                              <1> 	; al = 0
 30861 00006C70 31C9                <1> 	xor	ecx, ecx
 30862 00006C72 66BA4F18            <1> 	mov 	dx, 184Fh
 30863 00006C76 E8F5B2FFFF          <1> 	call	_scroll_up ; 24/01/2016
 30864                              <1> 	;
 30865                              <1> 	;mov	bh, [ACTIVE_PAGE] ; video page number (0 to 7)
 30866                              <1> 	;xor 	dx, dx
 30867                              <1> 	; 25/07/2022
 30868 00006C7B 31D2                <1> 	xor	edx, edx
 30869                              <1> 	;call	_set_cpos ; 24/01/2016 
 30870                              <1> 	;;retn
 30871                              <1> 	; 03/12/2020
 30872 00006C7D E934B6FFFF          <1> 	jmp	_set_cpos ; returns to the caller of this proc
 30873                              <1> ;cls3:
 30874                              <1> ;	retn
 30875                              <1> 
 30876                              <1> 	; 06/12/2020
 30877                              <1> vga_clear:
 30878                              <1> 	; 03/12/2020
 30879                              <1> 	; set mode by using _int10h
 30880                              <1> 	; (also clears screen)
 30881                              <1> 	;mov	al, ah
 30882                              <1> 	;sub	ah, ah  ; set current video mode
 30883                              <1> 	; 25/07/2022
 30884 00006C82 86E0                <1> 	xchg	ah, al
 30885                              <1> 	; ah = 0
 30886                              <1> 	; al = video mode
 30887                              <1> 	;call	_int10h ; simulates int 10h in TRDOS 386 kernel
 30888                              <1> 	;jmp	short cls3
 30889 00006C84 E94DAAFFFF          <1> 	jmp	_int10h ; returns to the caller of this proc
 30890                              <1> 
 30891                              <1> panic:
 30892                              <1> 	; 13/05/2016 (TRDOS 386 = TRDOS v2)
 30893                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
 30894                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
 30895 00006C89 BE[373B0100]        <1> 	mov 	esi, panic_msg
 30896 00006C8E E897FFFFFF          <1> 	call 	print_msg
 30897                              <1> key_to_reboot:
 30898                              <1>         ; 24/01/2016
 30899 00006C93 28E4                <1>         sub     ah, ah
 30900 00006C95 E834A2FFFF          <1>         call    int16h	; call getch
 30901                              <1>         ; wait for a character from the current tty
 30902                              <1> 	;
 30903 00006C9A B00A                <1> 	mov	al, 0Ah
 30904 00006C9C 8A3D[AE770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
 30905 00006CA2 B307                <1> 	mov	bl, 07h ; Black background, 
 30906                              <1> 			; light gray forecolor
 30907 00006CA4 E875B5FFFF          <1> 	call 	_write_tty
 30908 00006CA9 E9B3A6FFFF          <1> 	jmp	cpu_reset 
 30909                              <1> 
 30910                              <1> ctrlbrk:
 30911                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 30912                              <1> 	; 12/11/2015
 30913                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
 30914                              <1> 	; 06/12/2013 (Retro UNIX 8086 v1)
 30915                              <1> 	;
 30916                              <1> 	; INT 1Bh (control+break) handler		
 30917                              <1> 	;
 30918                              <1>       	; Retro Unix 8086 v1 feature only!
 30919                              <1>       	;
 30920                              <1> 	
 30921                              <1> 	; 25/07/2022
 30922 00006CAE 52                  <1> 	push	edx
 30923 00006CAF 31D2                <1> 	xor	edx, edx
 30924                              <1> 	;cmp 	word [u.intr], 0
 30925 00006CB1 663915[68010300]    <1> 	cmp	[u.intr], dx ; 0
 30926 00006CB8 763D                <1> 	jna 	short cbrk4
 30927                              <1> cbrk0:
 30928                              <1> 	; 12/11/2015
 30929                              <1> 	; 06/12/2013
 30930                              <1> 	;cmp 	word [u.quit], 0
 30931 00006CBA 663915[6A010300]    <1> 	cmp	[u.quit], dx ; 0 ; 25/07/2022
 30932 00006CC1 7434                <1> 	jz	short cbrk4
 30933                              <1> 	
 30934                              <1> 	; 20/09/2013	
 30935                              <1> 	;push 	ax
 30936 00006CC3 50                  <1> 	push	eax ; 25/07/2022
 30937 00006CC4 A0[AE770100]        <1> 	mov	al, [ptty]
 30938                              <1> 	
 30939                              <1> 	; 12/11/2015
 30940                              <1> 	;
 30941                              <1> 	; ctrl+break (EOT, CTRL+D) from serial port
 30942                              <1> 	; or ctrl+break from console (pseudo) tty
 30943                              <1> 	; (!redirection!)
 30944                              <1> 	
 30945 00006CC9 3C08                <1> 	cmp	al, 8 ; serial port tty nums > 7
 30946 00006CCB 720E                <1>         jb      short cbrk1 ; console (pseudo) tty
 30947                              <1> 		
 30948                              <1> 	; Serial port interrupt handler sets [ptty]
 30949                              <1> 	; to the port's tty number (as temporary).
 30950                              <1> 	;
 30951                              <1> 	; If active process is using a stdin or 
 30952                              <1> 	; stdout redirection (by the shell),
 30953                              <1>         ; console tty keyboard must be available
 30954                              <1> 	; to terminate running process,
 30955                              <1> 	; in order to prevent a deadlock. 
 30956                              <1> 
 30957                              <1> 	; 25/07/2022
 30958                              <1> 	;push	edx
 30959                              <1> 	;movzx	edx, byte [u.uno]
 30960 00006CCD 8A15[6D010300]      <1> 	mov	dl, [u.uno]
 30961 00006CD3 3A82[3F000300]      <1> 	cmp     al, [edx+p.ttyc-1] ; console tty (rw)
 30962                              <1> 	;pop	edx
 30963 00006CD9 7412                <1> 	je	short cbrk2
 30964                              <1> cbrk1:
 30965 00006CDB FEC0                <1> 	inc 	al  ; [u.ttyp] : 1 based tty number
 30966                              <1> 	; 06/12/2013
 30967 00006CDD 3A05[50010300]      <1> 	cmp	al, [u.ttyp]   ; recent open tty (r)
 30968 00006CE3 7408                <1> 	je	short cbrk2	
 30969 00006CE5 3A05[51010300]      <1>         cmp     al, [u.ttyp+1] ; recent open tty (w)
 30970 00006CEB 7509                <1> 	jne	short cbrk3	
 30971                              <1> cbrk2:
 30972                              <1> 	;; 06/12/2013
 30973                              <1> 	;mov	ax, [u.quit]
 30974                              <1> 	;and	ax, ax
 30975                              <1> 	;jz	short cbrk3
 30976                              <1> 	
 30977                              <1> 	;xor	ax, ax ; 0
 30978                              <1> 	;dec	ax
 30979                              <1> 	; 0FFFFh = 'ctrl+brk' keystroke
 30980                              <1> 	; 25/07/2022
 30981 00006CED 31C0                <1> 	xor	eax, eax ; 0
 30982 00006CEF 48                  <1> 	dec	eax ; -1 ; 0FFFFFFFFh
 30983 00006CF0 66A3[6A010300]      <1> 	mov	[u.quit], ax
 30984                              <1> cbrk3:
 30985                              <1> 	;pop	ax
 30986 00006CF6 58                  <1> 	pop	eax ; 25/07/2022
 30987                              <1> cbrk4:
 30988                              <1> 	; 25/07/2022
 30989 00006CF7 5A                  <1> 	pop	edx
 30990 00006CF8 C3                  <1> 	retn
 30991                              <1> 
 30992                              <1> ; 31/12/2017
 30993                              <1> ; TRDOS 386 - 30/12/2017
 30994                              <1> %define get_rtc_date RTC_40
 30995                              <1> %define get_rtc_time RTC_20
 30996                              <1> %define	set_rtc_date RTC_50
 30997                              <1> %define set_rtc_time RTC_30	
 30998                              <1> get_rtc_date_time:
 30999                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (01/09/2014)
 31000                              <1> ;epoch:
 31001                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.3)
 31002                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
 31003                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
 31004                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1 - UNIX.ASM)
 31005                              <1> 	; 'epoch' procedure prototype: 
 31006                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
 31007                              <1> 	; 14/11/2012
 31008                              <1> 	; unixboot.asm (boot file configuration)
 31009                              <1> 	; version of "epoch" procedure in "unixproc.asm"
 31010                              <1> 	; 21/7/2012
 31011                              <1> 	; 15/7/2012
 31012                              <1> 	; 14/7/2012		
 31013                              <1> 	; Erdogan Tan - RETRO UNIX v0.1
 31014                              <1> 	; compute current date and time as UNIX Epoch/Time
 31015                              <1> 	; UNIX Epoch: seconds since 1/1/1970 00:00:00
 31016                              <1> 	;
 31017                              <1>         ;  ((Modified registers: EAX, EDX, ECX, EBX))  
 31018                              <1> 	;
 31019                              <1> 
 31020                              <1> 	; 18/04/2021
 31021                              <1> 	; INPUT:
 31022                              <1> 	;	none (real time clock)
 31023                              <1> 	; OUTPUT:
 31024                              <1> 	;	eax = unix epoch time value
 31025                              <1> 	;	    (seconds since 1/1/1970 00:00:00)
 31026                              <1> 
 31027 00006CF9 E8CFF4FFFF          <1> 	call 	get_rtc_time		; Return Current Time
 31028                              <1>         ;xchg 	ch, cl ; 18/04/2021
 31029 00006CFE 66890D[4A740100]    <1>         mov 	[hour], cx    ; BCD, cl = minute, ch = hour
 31030                              <1>         ;xchg 	dh, dl ; 18/04/2021
 31031                              <1> 	;mov 	[second], dx  ; BCD, dh = second, dl = dse
 31032                              <1> 	; 18/04/2021
 31033 00006D05 8835[4E740100]      <1> 	mov	[second], dh  ; second
 31034                              <1> 	;
 31035 00006D0B E828F5FFFF          <1>         call 	get_rtc_date		; Return Current Date
 31036                              <1>         ;xchg 	ch, cl ; 18/04/2021
 31037 00006D10 66890D[44740100]    <1>         mov 	[year], cx    ; BCD, cl = year, ch = century
 31038                              <1>         ;xchg 	dh, dl ; 18/04/2021
 31039 00006D17 668915[46740100]    <1>         mov 	[month], dx   ; BCD, dl = day, dh = month
 31040                              <1> 	;
 31041                              <1> 	;mov 	al, [hour]    ; Hour
 31042                              <1>         ; 18/04/2021
 31043 00006D1E A0[4B740100]        <1> 	mov	al, [hour+1]  ; Hour
 31044                              <1> 	   	; AL <-- BCD number
 31045 00006D23 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31046                              <1> 					; AH = AL / 10h
 31047                              <1> 					; AL = AL MOD 10h
 31048 00006D25 D50A                <1>         aad 	; AX= AH*10+AL
 31049                              <1> 	;mov 	[hour], al
 31050                              <1> 	;mov 	al, [hour+1]  ; Minute
 31051 00006D27 8605[4A740100]      <1> 	xchg	al, [hour]    ; [hour] = hour, al = minute
 31052                              <1> 	   	; AL <-- BCD number
 31053 00006D2D D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31054                              <1> 					; AH = AL / 10h
 31055                              <1> 					; AL = AL MOD 10h
 31056 00006D2F D50A                <1>         aad 	; AX= AH*10+AL
 31057 00006D31 A2[4C740100]        <1> 	mov 	[minute], al
 31058 00006D36 A0[4E740100]        <1> 	mov 	al, [second]  ; Second
 31059                              <1> 	   	; AL <-- BCD number
 31060 00006D3B D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31061                              <1> 					; AH = AL / 10h
 31062                              <1> 					; AL = AL MOD 10h
 31063 00006D3D D50A                <1>         aad 	; AX= AH*10+AL
 31064 00006D3F A2[4E740100]        <1> 	mov 	[second], al
 31065 00006D44 66A1[44740100]      <1> 	mov 	ax, [year]    ; Year (century)
 31066                              <1> 	; 18/04/2021
 31067                              <1> 	;push 	eax ; puhs ax
 31068                              <1> 	;mov	al, ah ; century ; 18/04/2021
 31069                              <1> 	   	; AL <-- BCD number
 31070 00006D4A D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31071                              <1> 					; AH = AL / 10h
 31072                              <1> 					; AL = AL MOD 10h
 31073 00006D4C D50A                <1>         aad 	; AX= AH*10+AL
 31074                              <1> 	;mov 	ah, 100
 31075                              <1> 	;mul 	ah
 31076                              <1> 	;mov 	[year], ax
 31077                              <1> 	; 18/04/2021
 31078                              <1> 	; ax = al = year (0 to 99)
 31079 00006D4E 668705[44740100]    <1> 	xchg	ax, [year]    ; [year+1] = century -> ah
 31080                              <1> 	;pop	eax ; pop ax
 31081 00006D55 88E0                <1> 	mov	al, ah  ; century
 31082                              <1> 	   	; AL <-- BCD number
 31083 00006D57 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31084                              <1> 					; AH = AL / 10h
 31085                              <1> 					; AL = AL MOD 10h
 31086 00006D59 D50A                <1>         aad 	; AX= AH*10+AL
 31087                              <1> 	; 18/04/2021
 31088 00006D5B B464                <1> 	mov	ah, 100	      ; 100*(century byte of year)
 31089 00006D5D F6E4                <1> 	mul	ah
 31090                              <1> 	;
 31091 00006D5F 660105[44740100]    <1> 	add 	[year], ax
 31092                              <1> 	;mov 	al, [month]   ; Month
 31093                              <1> 	; 18/04/2021
 31094 00006D66 A0[47740100]        <1> 	mov	al, [month+1] ; Month
 31095                              <1> 	   	; AL <-- BCD number
 31096 00006D6B D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31097                              <1> 					; AH = AL / 10h
 31098                              <1> 					; AL = AL MOD 10h
 31099 00006D6D D50A                <1>         aad 	; AX= AH*10+AL
 31100                              <1> 	;mov 	[month], al	
 31101                              <1>         ;mov	al, [month+1] ; Day
 31102                              <1> 	; 18/04/2021
 31103 00006D6F 8605[46740100]      <1> 	xchg	al, [month]   ; [month] = month, al = day
 31104                              <1> 	   	; AL <-- BCD number
 31105 00006D75 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
 31106                              <1> 					; AH = AL / 10h
 31107                              <1> 					; AL = AL MOD 10h
 31108 00006D77 D50A                <1>         aad 	; AX= AH*10+AL
 31109 00006D79 A2[48740100]        <1>         mov     [day], al
 31110                              <1> 	
 31111 00006D7E C3                  <1> 	retn	; 30/12/2017
 31112                              <1> 
 31113                              <1> epoch:
 31114 00006D7F E875FFFFFF          <1> 	call	get_rtc_date_time ; TRDOS 386 - 30/12/2017
 31115                              <1> 
 31116                              <1> convert_to_epoch:
 31117                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 31118                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0)
 31119                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit modification)
 31120                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1)
 31121                              <1> 	;
 31122                              <1> 	; ((Modified registers: EAX, EDX, EBX)) 
 31123                              <1> 	;
 31124                              <1> 	; Derived from DALLAS Semiconductor
 31125                              <1> 	; Application Note 31 (DS1602/DS1603)
 31126                              <1> 	; 6 May 1998
 31127 00006D84 29C0                <1> 	sub 	eax, eax
 31128 00006D86 66A1[44740100]      <1> 	mov 	ax, [year]
 31129 00006D8C 662DB207            <1> 	sub 	ax, 1970
 31130 00006D90 BA6D010000          <1> 	mov 	edx, 365
 31131 00006D95 F7E2                <1> 	mul 	edx
 31132 00006D97 31DB                <1> 	xor 	ebx, ebx
 31133 00006D99 8A1D[46740100]      <1> 	mov 	bl, [month]
 31134 00006D9F FECB                <1> 	dec 	bl
 31135 00006DA1 D0E3                <1> 	shl 	bl, 1
 31136                              <1> 	;sub	edx, edx
 31137 00006DA3 668B93[50740100]    <1> 	mov 	dx, [EBX+DMonth]
 31138 00006DAA 8A1D[48740100]      <1>         mov     bl, [day]
 31139 00006DB0 FECB                <1> 	dec 	bl
 31140 00006DB2 01D0                <1> 	add 	eax, edx
 31141 00006DB4 01D8                <1> 	add 	eax, ebx
 31142                              <1> 			; EAX = days since 1/1/1970
 31143 00006DB6 668B15[44740100]    <1> 	mov 	dx, [year]
 31144 00006DBD 6681EAB107          <1> 	sub 	dx, 1969
 31145                              <1> 	;shr 	dx, 1
 31146                              <1> 	;shr 	dx, 1
 31147                              <1> 	; 25/07/2022
 31148 00006DC2 C1EA02              <1> 	shr	edx, 2		
 31149                              <1> 		; (year-1969)/4
 31150 00006DC5 01D0                <1> 	add 	eax, edx
 31151                              <1> 			; + leap days since 1/1/1970
 31152 00006DC7 803D[46740100]02    <1> 	cmp 	byte [month], 2	; if past february
 31153 00006DCE 760E                <1> 	jna 	short cte1
 31154 00006DD0 668B15[44740100]    <1> 	mov 	dx, [year]
 31155 00006DD7 6683E203            <1> 	and 	dx, 3 ; year mod 4
 31156 00006DDB 7501                <1> 	jnz 	short cte1		
 31157                              <1> 			; and if leap year
 31158                              <1> 	;add 	eax, 1 	; add this year's leap day (february 29)
 31159                              <1> 	; 25/07/2022
 31160 00006DDD 40                  <1> 	inc	eax
 31161                              <1> cte1: 			; compute seconds since 1/1/1970
 31162 00006DDE BA18000000          <1> 	mov 	edx, 24
 31163 00006DE3 F7E2                <1> 	mul	edx
 31164 00006DE5 8A15[4A740100]      <1> 	mov 	dl, [hour]
 31165 00006DEB 01D0                <1> 	add 	eax, edx
 31166                              <1> 		; EAX = hours since 1/1/1970 00:00:00
 31167                              <1> 	;mov	ebx, 60
 31168 00006DED B33C                <1> 	mov	bl, 60
 31169 00006DEF F7E3                <1> 	mul	ebx
 31170 00006DF1 8A15[4C740100]      <1> 	mov 	dl, [minute]
 31171 00006DF7 01D0                <1> 	add 	eax, edx
 31172                              <1> 		; EAX = minutes since 1/1/1970 00:00:00
 31173                              <1> 	;mov 	ebx, 60
 31174 00006DF9 F7E3                <1> 	mul	ebx
 31175 00006DFB 8A15[4E740100]      <1> 	mov 	dl, [second]
 31176 00006E01 01D0                <1> 	add 	eax, edx
 31177                              <1>  		; EAX -> seconds since 1/1/1970 00:00:00
 31178 00006E03 C3                  <1> 	retn
 31179                              <1> 
 31180                              <1> ;set_date_time:
 31181                              <1> convert_from_epoch:
 31182                              <1> 	; 25/07/2022 (v2.0.5)
 31183                              <1> 	; 18/04/2021 (v2.0.4)
 31184                              <1> 	; 31/12/2017 (v2.0.0)
 31185                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
 31186                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
 31187                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
 31188                              <1> 	; 'convert_from_epoch' procedure prototype: 
 31189                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
 31190                              <1> 	;
 31191                              <1> 	; ((Modified registers: EAX, EDX, ECX, EBX))	
 31192                              <1> 	;
 31193                              <1> 	; Derived from DALLAS Semiconductor
 31194                              <1> 	; Application Note 31 (DS1602/DS1603)
 31195                              <1> 	; 6 May 1998
 31196                              <1> 	;
 31197                              <1> 	; INPUT:
 31198                              <1> 	; EAX = Unix (Epoch) Time
 31199                              <1> 	;
 31200 00006E04 31D2                <1> 	xor 	edx, edx
 31201                              <1> 	;mov 	ecx, 60
 31202                              <1> 	; 25/07/2022
 31203 00006E06 29C9                <1> 	sub	ecx, ecx
 31204 00006E08 B13C                <1> 	mov	cl, 60
 31205 00006E0A F7F1                <1> 	div	ecx
 31206                              <1> 	;mov 	[imin], eax   ; whole minutes
 31207                              <1> 			  ; since 1/1/1970
 31208 00006E0C 668915[4E740100]    <1> 	mov 	[second], dx  ; leftover seconds
 31209 00006E13 29D2                <1> 	sub 	edx, edx
 31210 00006E15 F7F1                <1> 	div	ecx
 31211                              <1> 	;mov 	[ihrs], eax   ; whole hours
 31212                              <1> 	;		      ; since 1/1/1970
 31213 00006E17 668915[4C740100]    <1> 	mov 	[minute], dx  ; leftover minutes
 31214 00006E1E 31D2                <1> 	xor	edx, edx
 31215                              <1> 	;mov 	cx, 24
 31216 00006E20 B118                <1> 	mov 	cl, 24
 31217 00006E22 F7F1                <1> 	div	ecx
 31218                              <1> 	;mov 	[iday], ax   ; whole days
 31219                              <1> 			     ; since 1/1/1970
 31220 00006E24 668915[4A740100]    <1> 	mov 	[hour], dx   ; leftover hours
 31221 00006E2B 05DB020000          <1> 	add 	eax, 365+366 ; whole day since
 31222                              <1> 			     ; 1/1/1968 	
 31223                              <1> 	;mov 	[iday], ax
 31224 00006E30 50                  <1> 	push 	eax
 31225 00006E31 29D2                <1> 	sub	edx, edx
 31226                              <1> 	;mov 	ecx, (4*365)+1 ; 4 years = 1461 days
 31227                              <1> 	; 25/07/2022
 31228 00006E33 66B9B505            <1> 	mov	cx, (4*365)+1
 31229 00006E37 F7F1                <1> 	div	ecx
 31230 00006E39 59                  <1> 	pop 	ecx
 31231                              <1> 	;mov 	[lday], ax   ; count of quadyrs (4 years)
 31232                              <1> 	;push 	dx
 31233                              <1> 	; 18/04/2021
 31234 00006E3A 52                  <1> 	push	edx
 31235                              <1> 	;mov 	[qday], dx   ; days since quadyr began
 31236 00006E3B 6683FA3C            <1> 	cmp 	dx, 31+29    ; if past feb 29 then
 31237 00006E3F F5                  <1> 	cmc		     ; add this quadyr's leap day
 31238 00006E40 83D000              <1> 	adc 	eax, 0	     ; to # of qadyrs (leap days)
 31239                              <1> 	;mov 	[lday], ax   ; since 1968			  
 31240                              <1> 	;mov 	cx, [iday]
 31241 00006E43 91                  <1> 	xchg 	ecx, eax     ; ECX = lday, EAX = iday		  
 31242 00006E44 29C8                <1> 	sub 	eax, ecx     ; iday - lday
 31243                              <1> 	;mov 	ecx, 365
 31244                              <1> 	; 25/07/2022
 31245 00006E46 66B96D01            <1> 	mov	cx, 365
 31246 00006E4A 31D2                <1> 	xor	edx, edx
 31247                              <1> 	; EAX = iday-lday, EDX = 0
 31248 00006E4C F7F1                <1> 	div	ecx
 31249                              <1> 	;mov 	[iyrs], ax   ; whole years since 1968
 31250                              <1> 	;jday = iday - (iyrs*365) - lday
 31251                              <1> 	;mov	[jday], dx   ; days since 1/1 of current year
 31252                              <1> 	;add	eax, 1968
 31253 00006E4E 6605B007            <1> 	add 	ax, 1968     ; compute year
 31254 00006E52 66A3[44740100]      <1> 	mov 	[year], ax
 31255                              <1> 	;mov 	cx, dx
 31256                              <1> 	; 25/07/2022
 31257 00006E58 89D1                <1> 	mov	ecx, edx
 31258                              <1> 	;;mov 	dx, [qday]
 31259                              <1> 	;pop 	dx
 31260                              <1> 	; 18/04/2021
 31261 00006E5A 5A                  <1> 	pop	edx
 31262 00006E5B 6681FA6D01          <1> 	cmp 	dx, 365	     ; if qday <= 365 and qday >= 60	
 31263 00006E60 7708                <1> 	ja 	short cfe1   ; jday = jday +1
 31264 00006E62 6683FA3C            <1> 	cmp 	dx, 60       ; if past 2/29 and leap year then
 31265 00006E66 F5                  <1>         cmc		     ; add a leap day to the # of whole
 31266                              <1> 	;adc 	cx, 0        ; days since 1/1 of current year
 31267                              <1> 	; 25/07/2022
 31268 00006E67 83D100              <1> 	adc	ecx, 0
 31269                              <1> cfe1:			
 31270                              <1> 	;mov 	[jday], cx
 31271                              <1> 	;mov 	bx, 12       ; estimate month
 31272                              <1> 	; 18/04/2021
 31273 00006E6A 29DB                <1> 	sub	ebx, ebx
 31274 00006E6C B30C                <1> 	mov	bl, 12
 31275 00006E6E 66BA6E01            <1> 	mov 	dx, 366      ; mday, max. days since 1/1 is 365
 31276 00006E72 6683E003            <1> 	and 	ax, 11b      ; year mod 4 (and dx, 3) 
 31277                              <1> cfe2:	; Month calculation  ; 0 to 11  (11 to 0)	
 31278                              <1> 	;cmp 	cx, dx       ; mday = # of days passed from 1/1
 31279                              <1> 	; 25/07/2022
 31280 00006E76 39D1                <1> 	cmp	ecx, edx 
 31281 00006E78 731B                <1> 	jnb 	short cfe3
 31282                              <1> 	;dec 	bx           ; month = month - 1
 31283                              <1> 	;shl 	bx, 1
 31284                              <1> 	; 18/04/2021
 31285 00006E7A FECB                <1> 	dec	bl
 31286 00006E7C D0E3                <1> 	shl	bl, 1 
 31287 00006E7E 668B93[50740100]    <1> 	mov 	dx, [EBX+DMonth] ; # elapsed days at 1st of month
 31288                              <1> 	; 18/04/2021
 31289                              <1> 	;shr 	bx, 1        ; bx = month - 1 (0 to 11)
 31290 00006E85 D0EB                <1> 	shr	bl, 1
 31291                              <1> 	;cmp	bx, 1        ; if month > 2 and year mod 4  = 0	
 31292 00006E87 80FB01              <1> 	cmp	bl, 1
 31293 00006E8A 76EA                <1> 	jna 	short cfe2   ; then mday = mday + 1
 31294 00006E8C 76E8                <1> 	jna 	short cfe2   ; then mday = mday + 1
 31295 00006E8E 08C0                <1> 	or 	al, al       ; if past 2/29 and leap year then
 31296 00006E90 75E4                <1> 	jnz 	short cfe2   ; add leap day (to mday)
 31297                              <1> 	;inc 	dx           ; mday = mday + 1
 31298                              <1> 	; 25/07/2022
 31299 00006E92 42                  <1> 	inc	edx
 31300 00006E93 EBE1                <1> 	jmp 	short cfe2
 31301                              <1> cfe3:
 31302                              <1> 	;inc 	bx	     ; -> bx = month, 1 to 12
 31303                              <1> 	; 18/04/2021
 31304 00006E95 FEC3                <1> 	inc	bl
 31305 00006E97 66891D[46740100]    <1> 	mov 	[month], bx
 31306                              <1> 	;sub 	cx, dx	     ; day = jday - mday + 1	
 31307                              <1> 	; 25/07/2022
 31308 00006E9E 29D1                <1> 	sub	ecx, edx
 31309                              <1> 	;inc 	cx 			  
 31310                              <1> 	; 18/04/2021
 31311 00006EA0 FEC1                <1> 	inc	cl
 31312                              <1> 	;mov 	[day], cx
 31313 00006EA2 880D[48740100]      <1> 	mov	[day], cl	
 31314                              <1> 
 31315                              <1> 	; eax, ebx, ecx, edx is changed at return
 31316                              <1> 	; output ->
 31317                              <1> 	; [year], [month], [day], [hour], [minute], [second]
 31318                              <1> 
 31319 00006EA8 C3                  <1> 	retn	; 31/12/2017 (TRDOS 386)
 31320                              <1> 
 31321                              <1> set_rtc_date_time:
 31322                              <1> 	; 31/12/2017 (v2.0.0)
 31323                              <1> 	; 30/12/2017 (TRDOS 386)
 31324                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
 31325                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
 31326 00006EA9 E80F000000          <1> 	call	set_date_bcd
 31327                              <1> 	; Set real-time clock date
 31328 00006EAE E8ABF3FFFF          <1> 	call	set_rtc_date ; RTC_50
 31329                              <1> 	; Set real-time clock time
 31330 00006EB3 E832000000          <1> 	call	set_time_bcd
 31331 00006EB8 E93EF3FFFF          <1> 	jmp	set_rtc_time ; RTC_30	
 31332                              <1> 
 31333                              <1> ; 31/12/2017
 31334                              <1> set_date_bcd:
 31335 00006EBD A0[45740100]        <1>         mov     al, [year+1]
 31336 00006EC2 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31337 00006EC4 D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
 31338                              <1> 			     ; AL = AH * 10h + AL
 31339 00006EC6 88C5                <1> 	mov 	ch, al ; century (BCD)
 31340 00006EC8 A0[44740100]        <1> 	mov 	al, [year]
 31341 00006ECD D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31342 00006ECF D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
 31343                              <1> 			     ; AL = AH * 10h + AL
 31344 00006ED1 88C1                <1> 	mov 	cl, al ; year (BCD)
 31345 00006ED3 A0[46740100]        <1>         mov 	al, [month]
 31346 00006ED8 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31347 00006EDA D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
 31348                              <1> 			     ; AL = AH * 10h + AL
 31349 00006EDC 88C6                <1> 	mov 	dh, al ; month (BCD)
 31350 00006EDE A0[48740100]        <1> 	mov 	al, [day]
 31351 00006EE3 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31352 00006EE5 D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
 31353                              <1> 			     ; AL = AH * 10h + AL
 31354                              <1> 	; 18/04/2021
 31355 00006EE7 88C2                <1> 	mov 	dl, al ; day (BCD)
 31356 00006EE9 C3                  <1> 	retn	; 30/12/2017
 31357                              <1> 
 31358                              <1> ; 31/12/2017
 31359                              <1> set_time_bcd:
 31360                              <1>         ; Read real-time clock time 
 31361                              <1> 	; (get day light saving time bit status)
 31362 00006EEA FA                  <1>  	cli
 31363 00006EEB E8A9F4FFFF          <1> 	call	UPD_IPR 		; CHECK FOR UPDATE IN PROCESS
 31364                              <1> 	; cf = 1 -> al = 0
 31365 00006EF0 7207                <1>         jc      short stime1
 31366 00006EF2 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
 31367 00006EF4 E8D6F4FFFF          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
 31368                              <1> stime1:
 31369 00006EF9 FB                  <1> 	sti
 31370 00006EFA 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
 31371 00006EFC 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
 31372                              <1> 	; DL = 1 or 0 (day light saving time)
 31373                              <1> 	;	
 31374 00006EFE A0[4A740100]        <1> 	mov 	al, [hour]
 31375 00006F03 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31376 00006F05 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
 31377                              <1> 			     ; AL = AH * 10h + AL
 31378 00006F07 88C5                <1> 	mov 	ch, al ; hour (BCD)
 31379 00006F09 A0[4C740100]        <1>         mov     al, [minute]
 31380 00006F0E D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31381 00006F10 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
 31382                              <1> 			     ; AL = AH * 10h + AL
 31383 00006F12 88C1                <1> 	mov 	cl, al       ; minute (BCD)
 31384 00006F14 A0[4E740100]        <1>         mov     al, [second]
 31385 00006F19 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
 31386 00006F1B D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
 31387                              <1> 			     ; AL = AH * 10h + AL
 31388 00006F1D 88C6                <1> 	mov 	dh, al	     ; second (BCD)
 31389 00006F1F C3                  <1> 	retn	; 30/12/2017
 31390                                  %include 'trdosk2.s' ; 04/01/2016
 31391                              <1> ; ****************************************************************************
 31392                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - DRV INIT : trdosk2.s
 31393                              <1> ; ----------------------------------------------------------------------------
 31394                              <1> ; Last Update: 30/07/2022 (Previous: 30/08/2020)
 31395                              <1> ; ----------------------------------------------------------------------------
 31396                              <1> ; Beginning: 04/01/2016
 31397                              <1> ; ----------------------------------------------------------------------------
 31398                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
 31399                              <1> ; ----------------------------------------------------------------------------
 31400                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 31401                              <1> ; TRDOS2.ASM (09/11/2011)
 31402                              <1> ; ****************************************************************************
 31403                              <1> ; DRV_INIT.ASM (c) 2009-2011 Erdogan TAN  [26/09/2009] Last Update: 07/08/2011
 31404                              <1> ;
 31405                              <1> 
 31406                              <1> ldrv_init: ; Logical Drive Initialization
 31407                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 31408                              <1> 	; 30/08/2020
 31409                              <1> 	; 25/08/2020
 31410                              <1> 	; 11/08/2020 - 13/08/2020
 31411                              <1> 	; 17/07/2020 - 20/07/2020
 31412                              <1> 	; 14/07/2020 - 15/07/2020
 31413                              <1> 	; 30/01/2018
 31414                              <1> 	; 27/12/2017
 31415                              <1> 	; 12/02/2016
 31416                              <1> 	; 06/01/2016
 31417                              <1> 	;  	('diskinit.inc', 'diskio.inc' integration)
 31418                              <1> 	; 04/01/2016 (TRDOS 386 = TRDOS v2.0)
 31419                              <1> 	; 07/08/2011
 31420                              <1> 	; 20/09/2009
 31421                              <1> 	; 2005
 31422                              <1> 
 31423                              <1> 	; 15/07/2020
 31424                              <1> 	;movzx	ecx, byte [HF_NUM] ; number of fixed disks
 31425                              <1> 	;cmp	cl, 1
 31426                              <1> 	;jnb	short load_hd_partition_tables
 31427                              <1> 
 31428 00006F20 A0[18780100]        <1> 	mov	al, [HF_NUM] ; number of fixed disks
 31429 00006F25 20C0                <1> 	and 	al, al
 31430 00006F27 7501                <1> 	jnz	short load_hd_partition_tables
 31431                              <1> 
 31432                              <1> 	; no any hard disks
 31433 00006F29 C3                  <1> 	retn			
 31434                              <1> 
 31435                              <1> load_hd_partition_tables:
 31436                              <1> 	;mov	esi, [HDPM_TBL_VEC] ; primary master disk FDPT
 31437                              <1> 	; 15/07/2020
 31438 00006F2A BE[1C780100]        <1> 	mov	esi, HDPM_TBL_VEC
 31439 00006F2F BF[427C0100]        <1> 	mov 	edi, PTable_hd0
 31440 00006F34 B280                <1> 	mov 	dl, 80h
 31441                              <1> 	; 15/07/2020
 31442 00006F36 A2[FB640000]        <1> 	mov	[hdc], al
 31443                              <1> 	;xor	ecx, ecx ; 0
 31444                              <1> load_next_hd_partition_table:
 31445                              <1> 	; 20/07/2020
 31446 00006F3B 31C9                <1> 	xor	ecx, ecx ; 0
 31447                              <1> 	;push	ecx
 31448 00006F3D 57                  <1> 	push	edi ; *
 31449                              <1> 	;push	esi ; FDPT (+ DPTE) address
 31450                              <1> 	; 15/07/2020
 31451 00006F3E AD                  <1> 	lodsd
 31452 00006F3F 56                  <1> 	push	esi ; ** ; next FDPT (+ DPTE) address ptr
 31453                              <1> 	
 31454                              <1> 	;mov	al, [esi+20] ; DPTE offset 4
 31455                              <1> 	;and	al, 40h ;  LBA bit (bit 6)
 31456                              <1> 	;;shr	al, 6
 31457                              <1> 	;mov 	[HD_LBA_yes], al
 31458                              <1> 	
 31459                              <1> 	; 15/07/2020
 31460 00006F40 8A4814              <1> 	mov	cl, [eax+20]
 31461 00006F43 80E140              <1> 	and	cl, 40h
 31462 00006F46 880D[467D0100]      <1> 	mov	[HD_LBA_yes], cl
 31463                              <1> 	
 31464 00006F4C E83F040000          <1> 	call	load_masterboot
 31465                              <1> 	;jc	short pass_pt_this_hard_disk
 31466                              <1> 	; 13/08/2020
 31467                              <1> 	;jc	pass_pt_this_hard_disk
 31468                              <1> 	; 25/07/2022
 31469 00006F51 7305                <1> 	jnc	short load_mbr_ok
 31470 00006F53 E98A000000          <1> 	jmp	pass_pt_this_hard_disk
 31471                              <1> 
 31472                              <1> load_mbr_ok:
 31473 00006F58 BB[007C0100]        <1> 	mov	ebx, PartitionTable
 31474 00006F5D 89DE                <1> 	mov	esi, ebx
 31475                              <1> 	;mov	ecx, 16
 31476 00006F5F B110                <1> 	mov	cl, 16
 31477 00006F61 F3A5                <1> 	rep 	movsd
 31478 00006F63 89DE                <1> 	mov 	esi, ebx 
 31479                              <1> 	;mov 	byte [hdc], 4 ; 4 - partition index
 31480                              <1> 	; 15/07/2020
 31481 00006F65 C605[477D0100]04    <1> 	mov	byte [PP_Counter], 4
 31482                              <1> loc_validate_hdp_partition:
 31483                              <1> 	;cmp 	byte [esi+ptFileSystemID], 0
 31484                              <1> 	;jna	short loc_validate_next_hdp_partition2
 31485                              <1> 	; 13/08/2020
 31486 00006F6C 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
 31487 00006F6F 20C0                <1> 	and	al, al
 31488 00006F71 7457                <1> 	jz	short loc_validate_next_hdp_partition2
 31489                              <1> 
 31490 00006F73 56                  <1> 	push	esi ; *** ; Masterboot partition table offset
 31491 00006F74 52                  <1> 	push	edx ; **** ; dl = Physical drive number
 31492                              <1> 
 31493                              <1> 	; 13/08/2020
 31494 00006F75 3C05                <1> 	cmp	al, 05h  ; Extended partition CHS
 31495 00006F77 7404                <1>  	je	short loc_set_ep_counter
 31496 00006F79 3C0F                <1> 	cmp	al, 0Fh  ; Extended partition LBA
 31497 00006F7B 7511                <1>  	jne	short loc_validate_next_hdp_partition0
 31498                              <1> 	
 31499                              <1> 	;;inc	byte [PP_Counter]
 31500                              <1> 	; 15/07/2020
 31501                              <1> 	;inc 	byte [EP_Counter] ; disk has valid partition(s)
 31502                              <1> 
 31503                              <1> loc_set_ep_counter:
 31504                              <1> 	; 13/08/2020
 31505 00006F7D 803D[487D0100]80    <1> 	cmp	byte [EP_Counter], 80h
 31506 00006F84 7342                <1> 	jnb	short loc_validate_next_hdp_partition1
 31507                              <1> 
 31508 00006F86 8815[487D0100]      <1> 	mov	byte [EP_Counter], dl ; disk drv has extd. part.
 31509                              <1> 
 31510 00006F8C EB3A                <1> 	jmp	short loc_validate_next_hdp_partition1
 31511                              <1> 
 31512                              <1> loc_validate_next_hdp_partition0:
 31513 00006F8E 31FF                <1> 	xor	edi, edi ; 0  
 31514                              <1> 	; Input -> ESI = PartitionTable offset
 31515                              <1> 	; DL = Hard disk drive number 
 31516                              <1> 	; EDI = 0 -> Primary Partition
 31517                              <1> 	; EDI > 0 -> Extended Partition's Start Sector   
 31518 00006F90 E887010000          <1> 	call 	validate_hd_fat_partition
 31519 00006F95 730E                <1> 	jnc 	short loc_set_valid_hdp_partition_entry
 31520                              <1> 
 31521                              <1> 	;pop	edx
 31522                              <1> 	;push	edx
 31523 00006F97 8B1424              <1> 	mov	edx, [esp]  ; ****
 31524 00006F9A 8B742404            <1> 	mov	esi, [esp+4] ; *** ; 30/01/2018
 31525 00006F9E E8CC020000          <1> 	call	validate_hd_fs_partition
 31526 00006FA3 7223                <1> 	jc	short loc_validate_next_hdp_partition1
 31527                              <1> loc_set_valid_hdp_partition_entry:
 31528 00006FA5 8A0D[67300100]      <1> 	mov 	cl, [Last_DOS_DiskNo] 
 31529 00006FAB 80C141              <1> 	add 	cl, 'A'
 31530                              <1> 	; ESI = Logical dos drive description table address
 31531 00006FAE 880E                <1> 	mov	[esi+LD_Name], cl
 31532                              <1> 	; 15/07/2020
 31533 00006FB0 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo] ; Physical drive number
 31534                              <1> 	;mov	al, [esp] ; ****
 31535 00006FB3 2C7F                <1> 	sub	al, 7Fh
 31536                              <1> 		; AL = 1 to 4	
 31537 00006FB5 C0E002              <1> 	shl	al, 2 ; AL = 4 to 16
 31538                              <1> 
 31539 00006FB8 8A15[477D0100]      <1> 	mov	dl, [PP_Counter]
 31540                              <1> 
 31541                              <1> 	;sub	al, [PP_Counter]
 31542 00006FBE 28D0                <1> 	sub	al, dl ; [PP_Counter] ; 4 - partition index
 31543                              <1> 
 31544                              <1> 	; AL = Partition entry/index, 0 based
 31545                              <1> 	;  0 -> hd 0, Partition Table offset = 0
 31546                              <1> 	; 15 -> hd 3, Partition Table offset = 3
 31547                              <1> 
 31548                              <1> 	;mov	[esi+LD_PartitionEntry], al 
 31549                              <1> 	
 31550                              <1> 	; 15/07/2020
 31551 00006FC0 B404                <1> 	mov	ah, 4
 31552                              <1> 	;sub	ah, [PP_Counter]
 31553 00006FC2 28D4                <1> 	sub	ah, dl
 31554                              <1> 
 31555                              <1> 	; AH = Primary partition index, 0 to 3 ; pt entry
 31556                              <1> 	;		(4 to 7 for logical disk partitions)
 31557                              <1> 
 31558                              <1> 	;mov 	[esi+LD_DParamEntry], ah 
 31559 00006FC4 6689467C            <1> 	mov 	[esi+LD_PartitionEntry], ax
 31560                              <1> 
 31561                              <1> loc_validate_next_hdp_partition1:
 31562 00006FC8 5A                  <1> 	pop 	edx ; **** ; dl = Physical drive number 
 31563 00006FC9 5E                  <1> 	pop	esi ; *** ; Masterboot partition table offset
 31564                              <1> 
 31565                              <1> loc_validate_next_hdp_partition2:
 31566                              <1> 	; ESI = PartitionTable offset
 31567                              <1> 	; DL = Hard/Fixed disk drive number
 31568                              <1> 	
 31569                              <1> 	;dec	byte [hdc] ; 4 - partition index
 31570                              <1> 	;jz	short pass_pt_this_hard_disk
 31571                              <1> 	; 15/07/2020
 31572 00006FCA FE0D[477D0100]      <1> 	dec	byte [PP_Counter] ; 4 - partition index
 31573 00006FD0 7410                <1> 	jz	short pass_pt_this_hard_disk
 31574                              <1> 	
 31575 00006FD2 83C610              <1> 	add	esi, 16 ; 10h
 31576 00006FD5 EB95                <1> 	jmp	short loc_validate_hdp_partition
 31577                              <1> 
 31578                              <1> loc_not_any_extd_partitions:
 31579                              <1> 	; 15/07/2020
 31580 00006FD7 C3                  <1> 	retn	
 31581                              <1> 
 31582                              <1> loc_next_hd_partition_table:
 31583 00006FD8 FEC2                <1> 	inc	dl
 31584                              <1> 	; 15/07/2020
 31585                              <1> 	;add	esi, 32 ; next FDPT address
 31586 00006FDA 83C740              <1> 	add	edi, 64 ; next partition table destination
 31587 00006FDD E959FFFFFF          <1>         jmp     load_next_hd_partition_table
 31588                              <1> 
 31589                              <1> pass_pt_this_hard_disk:
 31590                              <1> 	;pop	esi ; FDPT (+ DPTE) address
 31591                              <1> 	; 15/07/2020
 31592 00006FE2 5E                  <1> 	pop	esi ; ** ; next FDPT (+ DPTE) address ptr
 31593 00006FE3 5F                  <1> 	pop	edi ; * ; Ptable_hd?
 31594                              <1> 	;pop	ecx
 31595                              <1> 	;loop	loc_next_hd_partition_table
 31596 00006FE4 FE0D[FB640000]      <1> 	dec	byte [hdc]
 31597 00006FEA 75EC                <1> 	jnz	short loc_next_hd_partition_table
 31598                              <1> 
 31599                              <1> 	;cmp	byte [PP_Counter], 1
 31600                              <1> 	;jnb	short load_extended_dos_partitions
 31601                              <1> 	;; Empty partition table
 31602                              <1> 	;retn
 31603                              <1> 
 31604                              <1> 	; 11/08/2020
 31605                              <1> 	; 17/07/2020
 31606                              <1> check_extended_partitions:
 31607                              <1> 	; 15/07/2020
 31608                              <1> 	;cmp	byte [EP_Counter], 0
 31609                              <1> 	;jna	short loc_not_any_extd_partitions
 31610                              <1> 	; 13/08/2020
 31611 00006FEC A0[487D0100]        <1> 	mov	al, [EP_Counter] ; 1st disk drv has extd partition
 31612 00006FF1 08C0                <1> 	or	al, al ; 0 ?
 31613 00006FF3 74E2                <1> 	jz	short loc_not_any_extd_partitions
 31614                              <1> 
 31615                              <1> load_extended_dos_partitions:
 31616                              <1> 	;mov	byte [hdc], 80h
 31617                              <1> 	; 13/08/2020
 31618 00006FF5 A2[FB640000]        <1> 	mov	byte [hdc], al ; 1st disk drv has extd partition
 31619                              <1> 	; 25/08/2020
 31620 00006FFA 2C80                <1> 	sub	al, 80h
 31621 00006FFC 740E                <1> 	jz	short loc_set_ext_ptable_hd0
 31622 00006FFE C0E006              <1> 	shl	al, 6 ; * 64
 31623 00007001 0FB6F0              <1> 	movzx	esi, al
 31624 00007004 81C6[427C0100]      <1> 	add	esi, PTable_hd0
 31625 0000700A EB05                <1> 	jmp 	short next_hd_extd_partition
 31626                              <1> 
 31627                              <1> 	; 25/08/2020
 31628                              <1> loc_set_ext_ptable_hd0:
 31629 0000700C BE[427C0100]        <1> 	mov	esi, PTable_hd0
 31630                              <1> 
 31631                              <1> next_hd_extd_partition:
 31632                              <1> 	; 17/07/2020
 31633                              <1> 	;mov 	byte [EP_Counter], 0 ; Reset for each physical disk
 31634                              <1> 	; 13/08/2020
 31635                              <1> 	;mov	byte [LD_Counter], 0 ; Reset logical drive index
 31636 00007011 66C705[487D0100]00- <1> 	mov 	word [EP_Counter], 0 ; Reset EP index and LD index	
 31637 00007019 00                  <1>
 31638                              <1> 
 31639 0000701A 56                  <1> 	push	esi ; **** ; PTable_hd? offset
 31640                              <1> 	
 31641 0000701B C605[477D0100]04    <1> 	mov 	byte [PP_Counter], 4 
 31642                              <1> 				; set for each extd partition table
 31643                              <1> 	;;mov	ecx, 4
 31644                              <1> 	;mov	cl, 4
 31645 00007022 8A15[FB640000]      <1> 	mov	dl, [hdc]
 31646                              <1> hd_check_fs_id_05h:
 31647 00007028 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
 31648 0000702B 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
 31649 0000702D 7411                <1> 	je	short loc_set_ep_start_sector ; yes
 31650                              <1> hd_check_fs_id_0Fh:
 31651 0000702F 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
 31652 00007031 740D                <1> 	je	short loc_set_ep_start_sector ; yes
 31653                              <1> 
 31654                              <1> continue_to_check_ep:
 31655                              <1> 	;add	esi, 16
 31656                              <1> 	;loop	hd_check_fs_id_05h
 31657                              <1> 	; 15/07/2020
 31658                              <1> 	;dec	cl
 31659                              <1> 	;jz	short continue_check_ep_next_disk
 31660 00007033 FE0D[477D0100]      <1> 	dec	byte [PP_Counter] ; 4 --> 0
 31661 00007039 742D                <1> 	jz	short continue_check_ep_next_disk
 31662 0000703B 83C610              <1> 	add	esi, 16
 31663 0000703E EBE8                <1> 	jmp	short hd_check_fs_id_05h
 31664                              <1> 
 31665                              <1> loc_set_ep_start_sector:
 31666                              <1> 	; dl = [hdc] ; Drive number
 31667                              <1> 	; 15/07/2020
 31668 00007040 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
 31669                              <1> 	; 30/08/2020
 31670 00007043 890D[4A7D0100]      <1> 	mov	[MBR_EP_StartSector], ecx 
 31671                              <1> 	; 20/07/2020
 31672                              <1> loc_validate_hde_partition_next:
 31673 00007049 890D[4E7D0100]      <1> 	mov	[EP_StartSector], ecx ; Extended partition's start sector
 31674 0000704F BB[427A0100]        <1>         mov	ebx, MasterBootBuff
 31675 00007054 803D[467D0100]01    <1> 	cmp	byte [HD_LBA_yes], 1 ; LBA ready = Yes
 31676 0000705B 7227                <1> 	jb	short loc_hd_load_ep_05h ; cf = 1 ; 20/07/2020 
 31677                              <1> 	; 11/08/2020
 31678                              <1> 	; (BugFix for extended partition type 05h beyond CHS limit)
 31679                              <1> 	; (Infact if extended partition starts at the beyond of CHS limit,
 31680                              <1> 	;  it's partition ID must be 0Fh but they/somebodies had used 05h.)
 31681                              <1> 	;cmp	al, 05h
 31682                              <1> 	;je	short loc_hd_load_ep_05h
 31683                              <1> loc_hd_load_ep_0Fh:
 31684                              <1> 	; 04/01/2016
 31685                              <1> 	;push	ecx
 31686                              <1> 	; 15/07/2020
 31687                              <1> 	;mov	ecx, [esi+ptStartSector] ; sector number
 31688                              <1> 	;mov	ebx, MasterBootBuff ; buffer address
 31689                              <1> 	; LBA read/write (with private LBA function) 
 31690                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
 31691                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
 31692                              <1> 	;mov	ah, 1Bh ; LBA read
 31693                              <1> 	;mov	al, 1 ; sector count
 31694 0000705D 66B8011B            <1> 	mov	ax, 1B01h
 31695 00007061 E8D7DEFFFF          <1> 	call	int13h
 31696                              <1> 	;pop	ecx
 31697                              <1> 	;jnc	short loc_hd_move_ep_table
 31698                              <1> 	; 15/07/2020
 31699 00007066 732E                <1> 	jnc	short loc_validate_hde_partition
 31700                              <1> 
 31701                              <1> continue_check_ep_next_disk:
 31702                              <1> 	; 15/07/2020
 31703                              <1> 	;pop	edi ; PTable_ep?
 31704 00007068 5E                  <1> 	pop	esi ; **** ; PTable_hd?
 31705 00007069 A0[18780100]        <1> 	mov	al, [HF_NUM] ; number of hard disks
 31706 0000706E 047F                <1> 	add	al, 7Fh
 31707 00007070 3805[FB640000]      <1> 	cmp	[hdc], al
 31708 00007076 730B                <1> 	jnb	short loc_validating_hd_partitions_ok
 31709 00007078 83C640              <1> 	add	esi, 64
 31710                              <1> 	; 15/07/2020
 31711                              <1> 	;add	edi, 64
 31712 0000707B FE05[FB640000]      <1> 	inc	byte [hdc]
 31713 00007081 EB8E                <1> 	jmp	short next_hd_extd_partition
 31714                              <1> 
 31715                              <1> loc_validating_hd_partitions_ok:
 31716                              <1> 	; 15/07/2020
 31717                              <1> 	;mov	al, [Last_DOS_DiskNo]
 31718                              <1> loc_drv_init_retn:
 31719 00007083 C3                  <1> 	retn
 31720                              <1> 	
 31721                              <1> loc_hd_load_ep_05h:
 31722                              <1> 	; 20/07/2020 ('diskio.s', int13h, cf = 1 -> bugfix)
 31723                              <1> 	;clc    ; (Bug: int13h would not clear carry flag bit, 
 31724                              <1> 	;	; even if there would not be an error)
 31725                              <1> 	;	; ((Fix: now, int13h procedure clears carry flag
 31726                              <1> 	;	;  at the entrance of it.. 20/07/2020))
 31727                              <1> 	; 15/07/2020
 31728                              <1> 	;push	ecx 
 31729 00007084 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
 31730 00007087 668B4E02            <1>         mov     cx, [esi+ptBeginSector]
 31731 0000708B 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
 31732                              <1> 	;mov	ebx, MasterBootBuff
 31733 0000708F E8A9DEFFFF          <1> 	call	int13h ; 20/07/2020
 31734                              <1> 		       ; 'diskio.s' modification, 'clc'
 31735                              <1> 	;pop	ecx  
 31736 00007094 72D2                <1> 	jc	short continue_check_ep_next_disk
 31737                              <1> 	; 15/07/2020
 31738                              <1> 	;jmp	short loc_validate_hde_partition
 31739                              <1> 
 31740                              <1> 	; 15/07/2020
 31741                              <1> ;loc_hd_move_ep_table:
 31742                              <1> 	;;pop	edi
 31743                              <1> 	;;push	edi  ; PTable_ep?
 31744                              <1> 	;mov	edi, [esp]        
 31745                              <1>         ;mov	esi, PartitionTable ; Extended
 31746                              <1> 	;mov	ebx, esi
 31747                              <1> 	;;mov	ecx, 16
 31748                              <1> 	;mov	cl, 16
 31749                              <1>        	;rep	movsd
 31750                              <1> 	;mov	esi, ebx 
 31751                              <1> ;loc_set_hde_sub_partition_count:
 31752                              <1> 	;mov	byte [PP_Counter], 4
 31753                              <1> 	;mov	byte [EP_Counter], 0
 31754                              <1> 
 31755                              <1> loc_validate_hde_partition:
 31756                              <1> 	; 13/08/2020
 31757                              <1> 	; 15/07/2020
 31758                              <1> 	;mov	byte [PP_Counter], 4
 31759 00007096 BE[007C0100]        <1> 	mov	esi, PartitionTable ; (in MasterBootBuff)
 31760                              <1> 	; 13/08/2020
 31761                              <1> 	;jmp	short get_minidisk_partition_entry
 31762                              <1> 
 31763                              <1> ;get_minidisk_partition_entry:
 31764                              <1> ;	; 20/07/2020
 31765                              <1> ;	cmp	byte [esi+ptFileSystemID], 0
 31766                              <1> ;	ja	short loc_validate_minidisk_partition
 31767                              <1> ;	; 13/08/2020
 31768                              <1> ;	jmp	short continue_check_ep_next_disk
 31769                              <1> 
 31770                              <1> ;	; 11/08/2020
 31771                              <1> ;get_minidisk_partition_entry_next:
 31772                              <1> ;	; 13/08/2020
 31773                              <1> ;	;dec 	byte [PP_Counter]
 31774                              <1> ;	;jz	short continue_check_ep_next_disk
 31775                              <1> ;	; 20/07/2020
 31776                              <1> ;;get_minidisk_partition_entry_next:
 31777                              <1> ;	; 13/08/2020
 31778                              <1> ;	cmp	esi, PartitionTable+64 
 31779                              <1> ;	jnb	short continue_check_ep_next_disk
 31780                              <1> ;	
 31781                              <1> ;	add 	esi, 16 ; 10h
 31782                              <1> ;	;jmp	short get_minidisk_partition_entry
 31783                              <1> 
 31784                              <1> 	; 13/08/2020
 31785                              <1> get_minidisk_partition_entry:
 31786                              <1> 	; 20/07/2020
 31787 0000709B 807E0400            <1> 	cmp	byte [esi+ptFileSystemID], 0
 31788 0000709F 76C7                <1> 	jna	short continue_check_ep_next_disk ; 13/08/2020
 31789                              <1> 
 31790                              <1> loc_validate_minidisk_partition:
 31791                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 31792                              <1> 	; 13/08/2020
 31793                              <1> 	; 20/07/2020
 31794                              <1> 	;push	esi ; *** ; Extended partition table offset
 31795                              <1> 
 31796                              <1> 	; 13/08/2020
 31797 000070A1 FE05[487D0100]      <1> 	inc	byte [EP_Counter] ; current (sub partition) index 
 31798                              <1> 				  ; in current extended partition
 31799                              <1> 
 31800 000070A7 BF[4E7D0100]        <1> 	mov	edi, EP_StartSector
 31801                              <1> 
 31802                              <1> 	; Input -> ESI = PartitionTable offset
 31803                              <1> 	; DL = Hard disk drive number   
 31804                              <1> 	; EDI = Extended partition start sector pointer
 31805 000070AC E86B000000          <1> 	call	validate_hd_fat_partition
 31806                              <1> 	;pop	ecx ; *
 31807 000070B1 7308                <1> 	jnc	short loc_set_valid_hde_partition_entry
 31808                              <1> 			 ; jump down to deep !!!
 31809                              <1> 
 31810                              <1> 	;pop	esi ; *** ; Extended partition table offset
 31811                              <1> 	; 13/08/2020
 31812                              <1> 	;mov	esi, PartitionTable
 31813                              <1> 
 31814                              <1> 	; 11/08/2020
 31815                              <1> 	; ESI = Extended partition table offset
 31816 000070B3 8A15[FB640000]      <1> 	mov	dl, [hdc]
 31817                              <1> 
 31818                              <1> 	;; DL = Hard disk drive number
 31819                              <1> 	;dec	byte [PP_Counter]
 31820                              <1> 	;jz	short continue_check_ep_next_disk
 31821                              <1> 	;add 	esi, 16 ; 10h
 31822                              <1> 	;mov	dl, [hdc]
 31823                              <1> 	;jmp	short get_minidisk_partition_entry
 31824                              <1> 
 31825                              <1> 	; 11/08/2020
 31826                              <1> 	;jmp	short get_minidisk_partition_entry_next
 31827                              <1> 
 31828                              <1> 	; 23/08/2020
 31829 000070B9 EB3E                <1> 	jmp	short validate_next_minidisk_partition_ok
 31830                              <1> 
 31831                              <1> 	; 17/07/2020
 31832                              <1> 	;; jumping down to deep levels !!!
 31833                              <1> 	; ((That is a pitty microsoft preferred ep table chain
 31834                              <1> 	; instead of a single table as mbr partition table!?))
 31835                              <1> 
 31836                              <1> loc_set_valid_hde_partition_entry:
 31837                              <1> 	; 15/07/2020
 31838 000070BB A0[FB640000]        <1> 	mov	al, [hdc] ; Hard disk drive number (>=80h)
 31839 000070C0 88C2                <1> 	mov	dl, al ; mov dl, [hdc]
 31840 000070C2 2C7F                <1> 	sub	al, 7Fh
 31841                              <1> 		    ; 1 to 4	
 31842 000070C4 C0E002              <1> 	shl	al, 2 ; 4 to 16
 31843 000070C7 2A05[477D0100]      <1> 	sub	al, [PP_Counter] ; al - (4 - partition index)
 31844                              <1> 			; (disk number * 4) + partition index
 31845                              <1> 	
 31846                              <1> 	; AL = Partition entry/index, 0 based
 31847                              <1>         ;  0 -> hd 0, Partition Table offset = 0
 31848                              <1>         ; 15 -> hd 3, Partition Table offset = 3
 31849                              <1> 
 31850                              <1> 	;mov	ah, 4 ; Logical dos partition (>= 4)
 31851                              <1> 	;add	ah, [EP_Counter]
 31852                              <1> 		; Logical disk partition index = 4 to 7
 31853                              <1> 		; (Primary disk partition index = 0 to 3)
 31854                              <1> 
 31855                              <1> 	; 13/08/2020
 31856 000070CD 8A25[497D0100]      <1> 	mov	ah, [LD_Counter] ; Logical drive index number
 31857                              <1> 				; (in current extended partition)
 31858 000070D3 80C404              <1> 	add	ah, 4 ; 4 to 7
 31859                              <1> 	
 31860                              <1> 	; 15/07/2020
 31861                              <1> 	; CX -> AX
 31862                              <1> 	;; 06/01/2016 (TRDOS v2.0)
 31863                              <1> 	;; BUGFIX *
 31864                              <1> 	;;mov	[esi+LD_PartitionEntry], cl 
 31865                              <1> 	;;mov	[esi+LD_DParamEntry], ch 
 31866                              <1> 	;mov	[esi+LD_PartitionEntry], cx 
 31867 000070D6 6689467C            <1> 	mov	[esi+LD_PartitionEntry], ax 	
 31868                              <1> 
 31869 000070DA 8A0D[67300100]      <1> 	mov	cl, [Last_DOS_DiskNo] 
 31870 000070E0 80C141              <1> 	add	cl, 'A'
 31871 000070E3 880E                <1> 	mov	[esi+LD_Name], cl
 31872                              <1> 
 31873                              <1> 	; 17/07/2020
 31874                              <1> 	;cmp	cl, 'Z'
 31875                              <1> 	;jb	short logical_drive_count_ok_for_next
 31876                              <1> 	;pop	esi ; ***
 31877                              <1> 	;pop	esi ; ****
 31878                              <1> 	;retn
 31879                              <1> 
 31880                              <1> ;logical_drive_count_ok_for_next:
 31881                              <1> 
 31882                              <1> 	;; 15/07/2020
 31883                              <1> 	;inc	byte [EP_Counter]
 31884                              <1> 	; 13/08/2020
 31885 000070E5 FE05[497D0100]      <1> 	inc	byte [LD_Counter]	
 31886                              <1> 
 31887                              <1> 	;mov	dl, [hdc]
 31888                              <1> 
 31889                              <1> 	; 17/07/2020
 31890                              <1> 	;; Now, 
 31891                              <1> 	;; we are swimming in deep of an extended partition !!!
 31892                              <1> 	; (! sub or chained extended partition tables !)
 31893                              <1> 	; ((Logical dos partitions in extended partition were called
 31894                              <1> 	;  as 'mini disk partition' in msdos 6.0 source code.))
 31895                              <1> 
 31896                              <1> validate_next_minidisk_partition:
 31897                              <1> 	; 13/08/2020
 31898                              <1> 	;pop	esi ; *** ; Extended partition table offset
 31899                              <1> 
 31900                              <1> 	; 17/07/2020
 31901                              <1> 	;cmp	byte [EP_Counter], 4
 31902                              <1> 	; 13/08/2020
 31903 000070EB 803D[497D0100]04    <1> 	cmp	byte [LD_Counter], 4 ; maximum 4 logical disks
 31904                              <1> 				     ; per extended partition
 31905                              <1> 	;jnb	continue_check_ep_next_disk
 31906                              <1> 	; 25/07/2022
 31907 000070F2 7205                <1> 	jb	short validate_next_minidisk_partition_ok
 31908 000070F4 E96FFFFFFF          <1> 	jmp	continue_check_ep_next_disk	
 31909                              <1> 
 31910                              <1> validate_next_minidisk_partition_ok:
 31911                              <1> 	; 13/08/2020
 31912                              <1> 	;dec	byte [PP_Counter] ; 4 --> 0
 31913                              <1> 	;jz	continue_check_ep_next_disk
 31914                              <1> 	
 31915                              <1> 	;cmp	esi, PartitionTable+64 
 31916                              <1> 	;jnb	continue_check_ep_next_disk
 31917                              <1> 
 31918                              <1> 	;add	esi, 16
 31919                              <1> 	; 13/08/2020
 31920 000070F9 BE[107C0100]        <1> 	mov	esi, PartitionTable+16
 31921                              <1> 
 31922                              <1> 	; 20/07/2020
 31923 000070FE 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
 31924                              <1> 
 31925                              <1> 	; 20/07/2020
 31926 00007101 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
 31927 00007103 7409                <1> 	je	short loc_minidisk_next_ep_lba_chs ; 17/07/2020
 31928 00007105 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
 31929                              <1> 	;jne	continue_check_ep_next_disk ; AL must be 0 here
 31930                              <1> 					; (when it is not 05h or 0Fh)
 31931                              <1> 					; If AL is not ZERO -> EP Bug!
 31932                              <1> 					; (!Microsoft DOS convention!)
 31933                              <1> 	; 25/07/2022
 31934 00007107 7405                <1> 	je	short loc_minidisk_next_ep_lba_chs
 31935 00007109 E95AFFFFFF          <1> 	jmp	continue_check_ep_next_disk	
 31936                              <1> 
 31937                              <1> loc_minidisk_next_ep_lba_chs:
 31938                              <1> 	; 17/07/2020
 31939 0000710E 8B4E08              <1> 	mov	ecx, [esi+ptStartSector] ; relative start sector number
 31940                              <1> 	;add	ecx, [EP_StartSector]
 31941                              <1> 	; 30/08/2020	
 31942 00007111 030D[4A7D0100]      <1> 	add	ecx, [MBR_EP_StartSector] 
 31943                              <1> 	; 20/07/2020
 31944 00007117 E92DFFFFFF          <1> 	jmp	loc_validate_hde_partition_next
 31945                              <1> 
 31946                              <1> validate_hd_fat_partition:
 31947                              <1> 	; 17/07/2020
 31948                              <1> 	; 15/07/2020
 31949                              <1> 	;	(optimization)
 31950                              <1> 	; 14/07/2020
 31951                              <1> 	;	(fat16 -big- partition search bugfix)
 31952                              <1> 	; 27/12/2017
 31953                              <1> 	; 12/02/2016
 31954                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
 31955                              <1> 	; 07/08/2011
 31956                              <1> 	; 23/07/2011
 31957                              <1> 	; Input
 31958                              <1> 	;   DL = Hard/Fixed Disk Drive Number
 31959                              <1> 	;   ESI = PartitionTable offset
 31960                              <1> 	;   EDI = Extend. Part. Start Sector Pointer
 31961                              <1> 	;   EDI = 0 -> Primary Partition 
 31962                              <1> 	;   byte [Last_DOS_DiskNo]
 31963                              <1>  	; Output
 31964                              <1> 	;  cf=0 -> Validated
 31965                              <1> 	;   ESI = Logical dos drv desc. table
 31966                              <1> 	;   EBX = FAT boot sector buffer
 31967                              <1> 	;   byte [Last_DOS_DiskNo]
 31968                              <1> 	;  cf=1 -> Not a valid FAT partition
 31969                              <1> 	; EAX, EDX, ECX, EDI -> changed 
 31970                              <1> 	
 31971                              <1> 	;mov 	esi, PartitionTable
 31972 0000711C 8A6604              <1> 	mov 	ah, [esi+ptFileSystemID]
 31973 0000711F B002                <1> 	mov	al, 2 ; 27/12/2017
 31974 00007121 80FC06              <1> 	cmp 	ah, 06h ; FAT16 CHS partition (>=32MB)
 31975                              <1> 	; 12/02/2016
 31976                              <1> 	;;jb	short loc_not_a_valid_fat_partition2
 31977                              <1>  	;jnb	short vhdp_FAT16_32
 31978                              <1> 	; 14/07/2020 (BugFix)
 31979 00007124 7711                <1> 	ja	short vhdp_FAT16_32
 31980 00007126 7425                <1> 	je	short loc_set_valid_hd_partition_params
 31981                              <1> 
 31982                              <1> vhdp_FAT12_16:
 31983                              <1> 	; 27/12/2017
 31984 00007128 FEC8                <1> 	dec	al ; mov al, 1
 31985 0000712A 38C4                <1> 	cmp	ah, al ; 1 ; FAT12 partition
 31986 0000712C 741F                <1> 	je	short loc_set_valid_hd_partition_params
 31987                              <1> 	;
 31988 0000712E FEC0                <1> 	inc	al ; mov al, 2
 31989 00007130 80FC04              <1> 	cmp	ah, 04h ; FAT16 CHS partition (< 32MB)
 31990 00007133 7418                <1> 	je	short loc_set_valid_hd_partition_params
 31991                              <1> 	
 31992                              <1> 	; 15/07/2020
 31993                              <1> 	; (ah = 05h, 02h or 03h)
 31994                              <1> loc_not_a_valid_fat_partition1:
 31995 00007135 F9                  <1> 	stc
 31996                              <1> 	; cf=1
 31997 00007136 C3                  <1> 	retn
 31998                              <1> 
 31999                              <1> vhdp_FAT16_32:
 32000                              <1> 	; 15/07/2020
 32001                              <1> 	;mov	al, 3
 32002 00007137 FEC0                <1> 	inc	al
 32003 00007139 80FC0C              <1> 	cmp	ah, 0Ch ; FAT32 LBA partition
 32004 0000713C 740F                <1> 	je	short loc_set_valid_hd_partition_params
 32005 0000713E 7706                <1> 	ja	short vhdp_check_FAT16_lba
 32006                              <1> 
 32007                              <1> vhdp_check_FAT32_chs:
 32008 00007140 80FC0B              <1> 	cmp	ah, 0Bh ; FAT32 CHS partition 
 32009 00007143 7408                <1> 	je	short loc_set_valid_hd_partition_params
 32010                              <1> 	;jne	short loc_not_a_valid_fat_partition1
 32011                              <1> 
 32012                              <1> 	;stc
 32013                              <1> loc_not_a_valid_fat_partition2:
 32014 00007145 C3                  <1> 	retn
 32015                              <1> 
 32016                              <1> vhdp_check_FAT16_lba:
 32017 00007146 80FC0E              <1> 	cmp	ah, 0Eh ; FAT16 LBA partition
 32018 00007149 75EA                <1> 	jne	short loc_not_a_valid_fat_partition1
 32019                              <1> 
 32020                              <1> 	;mov	al, 2
 32021 0000714B FEC8                <1> 	dec	al
 32022                              <1> 
 32023                              <1> loc_set_valid_hd_partition_params:
 32024                              <1> 	; 30/07/2022
 32025                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32026                              <1> 	; 15/07/2020
 32027                              <1> 	;inc 	byte [Last_DOS_DiskNo] ; > 1
 32028                              <1> 	;
 32029 0000714D 31DB                <1> 	xor	ebx, ebx
 32030 0000714F 8A3D[67300100]      <1> 	mov	bh, [Last_DOS_DiskNo] ; * 256	
 32031 00007155 FEC7                <1> 	inc	bh ; 15/07/2020
 32032 00007157 81C300010900        <1> 	add	ebx, Logical_DOSDisks
 32033                              <1> 	;
 32034 0000715D C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
 32035 00007161 885302              <1> 	mov	byte [ebx+LD_PhyDrvNo], dl
 32036                              <1> 	;mov	byte [ebx+LD_FATType], al ; 2 or 3
 32037                              <1> 	;mov	byte [ebx+LD_FSType], ah ; 06h, 0Eh, 0Bh, 0Ch
 32038 00007164 66894303            <1> 	mov	word [ebx+LD_FATType], ax
 32039                              <1> 	;
 32040 00007168 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
 32041 0000716B 09FF                <1> 	or	edi, edi 
 32042 0000716D 7402                <1> 	jz	short pass_hd_FAT_ep_start_sector_adding
 32043                              <1> loc_add_hd_FAT_ep_start_sector:
 32044                              <1> 	; 17/07/2020
 32045 0000716F 030F                <1> 	add	ecx, [edi]
 32046                              <1> pass_hd_FAT_ep_start_sector_adding:
 32047 00007171 894B6C              <1> 	mov	[ebx+LD_StartSector], ecx
 32048                              <1> loc_hd_FAT_logical_drv_init:
 32049 00007174 89DD                <1> 	mov	ebp, ebx
 32050                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
 32051 00007176 A0[467D0100]        <1> 	mov	al, [HD_LBA_yes] ; 07/01/2016
 32052 0000717B 884305              <1> 	mov	[ebx+LD_LBAYes], al
 32053 0000717E BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
 32054 00007183 08C0                <1> 	or	al, al
 32055 00007185 740C                <1> 	jz	short loc_hd_FAT_drv_init_load_bs_chs
 32056                              <1> loc_hd_FAT_drv_init_load_bs_lba:
 32057                              <1> 	; DL = Physical drive number
 32058                              <1>    	;mov	ecx, [esi+ptStartSector] ; sector number
 32059                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
 32060                              <1> 	; LBA read/write (with private LBA function) 
 32061                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
 32062                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
 32063 00007187 B41B                <1> 	mov	ah, 1Bh ; LBA read
 32064 00007189 B001                <1> 	mov	al, 1 ; sector count
 32065 0000718B E8ADDDFFFF          <1> 	call	int13h
 32066 00007190 7313                <1> 	jnc	short loc_hd_drv_FAT_boot_validation
 32067                              <1> loc_not_a_valid_fat_partition3:
 32068 00007192 C3                  <1> 	retn
 32069                              <1> loc_hd_FAT_drv_init_load_bs_chs:
 32070 00007193 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
 32071 00007196 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
 32072 0000719A 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
 32073                              <1> 	;mov	ebx, DOSBootSectorBuff
 32074 0000719E E89ADDFFFF          <1> 	call	int13h
 32075 000071A3 72ED                <1> 	jc	short loc_not_a_valid_fat_partition3
 32076                              <1> loc_hd_drv_FAT_boot_validation:
 32077                              <1> 	;mov	esi, DOSBootSectorBuff
 32078 000071A5 89DE                <1> 	mov	esi, ebx
 32079 000071A7 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
 32080 000071B0 7514                <1> 	jne	short loc_not_a_valid_fat_partition4
 32081 000071B2 807E15F8            <1> 	cmp	byte [esi+BPB_Media], 0F8h
 32082 000071B6 750E                <1> 	jne	short loc_not_a_valid_fat_partition4
 32083                              <1> 
 32084                              <1> 	; 25/07/2022
 32085 000071B8 31C9                <1> 	xor	ecx, ecx
 32086                              <1> 
 32087                              <1> 	; 27/12/2017
 32088 000071BA 807D0303            <1> 	cmp	byte [ebp+LD_FATType], 3
 32089 000071BE 7508                <1> 	jne	short loc_hd_FAT16_BPB
 32090                              <1> 
 32091                              <1> loc_hd_drv_FAT32_boot_validation:
 32092 000071C0 807E4229            <1> 	cmp	byte [esi+BS_FAT32_BootSig], 29h
 32093 000071C4 7413                <1> 	je	short loc_hd_FAT32_BPB
 32094                              <1> 
 32095                              <1> loc_not_a_valid_fat_partition4:
 32096 000071C6 F9                  <1> 	stc
 32097 000071C7 C3                  <1> 	retn
 32098                              <1> 
 32099                              <1> loc_hd_FAT16_BPB:
 32100 000071C8 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
 32101 000071CC 75F8                <1> 	jne	short loc_not_a_valid_fat_partition4
 32102                              <1> 
 32103 000071CE 66837E1600          <1> 	cmp	word [esi+BPB_FATSz16], 0
 32104 000071D3 7604                <1> 	jna	short loc_hd_big_FAT16_BPB
 32105                              <1> 	;mov	ecx, 32
 32106                              <1> 	; 25/07/2022
 32107 000071D5 B120                <1> 	mov	cl, 32
 32108                              <1> 	; ecx = 32
 32109 000071D7 EB02                <1> 	jmp	short loc_hd_move_FAT_BPB
 32110                              <1> 
 32111                              <1> loc_hd_FAT32_BPB:
 32112                              <1> 	;cmp	word [esi+BPB_FATSz16], 0
 32113                              <1> 	;ja	short loc_not_a_valid_fat_partition4
 32114                              <1> loc_hd_big_FAT16_BPB:
 32115                              <1> 	;mov	ecx, 45
 32116                              <1> 	; 25/07/2022
 32117 000071D9 B12D                <1> 	mov	cl, 45
 32118                              <1> 	; ecx = 45
 32119                              <1> loc_hd_move_FAT_BPB:
 32120 000071DB 89EF                <1> 	mov 	edi, ebp
 32121                              <1> 	;mov	esi, ebx ; Boot sector
 32122 000071DD 57                  <1> 	push	edi
 32123 000071DE 83C706              <1> 	add	edi, LD_BPB
 32124 000071E1 F366A5              <1> 	rep	movsw 
 32125 000071E4 5E                  <1> 	pop	esi
 32126 000071E5 0FB74614            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RsvdSecCnt]
 32127 000071E9 03466C              <1> 	add	eax, [esi+LD_StartSector]
 32128 000071EC 894660              <1> 	mov	[esi+LD_FATBegin], eax
 32129 000071EF 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
 32130 000071F3 7223                <1> 	jb	short loc_set_FAT16_RootDirLoc
 32131                              <1> loc_set_FAT32_RootDirLoc:
 32132 000071F5 8B462A              <1> 	mov	eax, [esi+LD_BPB+BPB_FATSz32]
 32133 000071F8 0FB65E16            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_NumFATs]
 32134 000071FC F7E3                <1> 	mul	ebx
 32135 000071FE 034660              <1> 	add	eax, [esi+LD_FATBegin]
 32136                              <1> loc_set_FAT32_data_begin:
 32137 00007201 894668              <1> 	mov	[esi+LD_DATABegin], eax
 32138 00007204 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
 32139                              <1> 	; If Root Directory Cluster <> 2 then
 32140                              <1> 	; change the beginning sector value 
 32141                              <1> 	; of the root dir by adding sector offset.
 32142 00007207 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
 32143                              <1> 	;sub	eax, 2
 32144                              <1> 	; 30/07/2022
 32145 0000720A 48                  <1> 	dec	eax ; 2 -> 1
 32146 0000720B 48                  <1> 	dec	eax ; 1 -> 0
 32147 0000720C 7433                <1> 	jz	short short loc_set_32bit_FAT_total_sectors  
 32148                              <1> 	;movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
 32149 0000720E 8A5E13              <1> 	mov	bl, [esi+LD_BPB+BPB_SecPerClust] 
 32150 00007211 F7E3                <1> 	mul	ebx
 32151 00007213 014664              <1> 	add	[esi+LD_ROOTBegin], eax
 32152 00007216 EB29                <1> 	jmp	short loc_set_32bit_FAT_total_sectors
 32153                              <1> 	;
 32154                              <1> loc_set_FAT16_RootDirLoc:
 32155 00007218 0FB64616            <1> 	movzx	eax, byte [esi+LD_BPB+BPB_NumFATs]
 32156 0000721C 0FB7561C            <1> 	movzx	edx, word [esi+LD_BPB+BPB_FATSz16]
 32157 00007220 F7E2                <1> 	mul	edx
 32158 00007222 034660              <1> 	add	eax, [esi+LD_FATBegin]  
 32159 00007225 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
 32160                              <1> loc_set_FAT16_data_begin:
 32161 00007228 894668              <1> 	mov	[esi+LD_DATABegin], eax 
 32162                              <1> 	;mov	eax, 20h  ; Size of a directory entry
 32163                              <1> 	;;movzx	edx, word [esi+LD_BPB+BPB_RootEntCnt]
 32164                              <1>         ;mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
 32165                              <1>         ;mul	edx
 32166                              <1> 	;;mov	ecx, 511
 32167                              <1> 	;mov	cx, 511
 32168                              <1> 	;add	eax, ecx
 32169                              <1> 	;inc	ecx ; 512
 32170                              <1> 	;div	ecx
 32171                              <1> 	; 14/07/2020
 32172 0000722B 0FB74617            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RootEntCnt]
 32173 0000722F 6683C00F            <1> 	add	ax, 15
 32174                              <1> 	;shr	ax, 4 ; / 16 ; (16 entries per sector)
 32175                              <1> 	; 25/07/2022
 32176 00007233 C1E804              <1> 	shr	eax, 4
 32177 00007236 014668              <1> 	add	[esi+LD_DATABegin], eax
 32178                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
 32179 00007239 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
 32180                              <1> 	;test	ax, ax
 32181                              <1> 	; 25/07/2022
 32182 0000723D 85C0                <1> 	test	eax, eax
 32183                              <1> 	;jz	short loc_set_32bit_FAT_total_sectors
 32184                              <1> ;loc_set_16bit_FAT_total_sectors:
 32185                              <1> 	;mov	[esi+LD_TotalSectors], eax
 32186                              <1> 	;jmp	short loc_set_hd_FAT_cluster_count
 32187                              <1> 	; 14/07/2020
 32188 0000723F 7503                <1> 	jnz	short loc_set_hd_FAT_cluster_count
 32189                              <1> loc_set_32bit_FAT_total_sectors:
 32190 00007241 8B4626              <1> 	mov	eax, [esi+LD_BPB+BPB_TotalSec32]
 32191                              <1> 	;mov	[esi+LD_TotalSectors], eax
 32192                              <1> loc_set_hd_FAT_cluster_count:
 32193 00007244 894670              <1> 	mov	[esi+LD_TotalSectors], eax ; 14/07/2020
 32194 00007247 8B5668              <1> 	mov	edx, [esi+LD_DATABegin]
 32195 0000724A 2B566C              <1> 	sub	edx, [esi+LD_StartSector]
 32196 0000724D 29D0                <1> 	sub	eax, edx
 32197 0000724F 31D2                <1> 	xor	edx, edx ; 0
 32198 00007251 0FB64E13            <1>         movzx   ecx, byte [esi+LD_BPB+BPB_SecPerClust]
 32199 00007255 F7F1                <1>         div	ecx 
 32200 00007257 894678              <1> 	mov	[esi+LD_Clusters], eax
 32201                              <1> 	; Maximum Valid Cluster Number= EAX +1
 32202                              <1> 	; with 2 reserved clusters= EAX +2
 32203                              <1> loc_set_hd_FAT_fs_free_sectors:
 32204                              <1> 	;mov	dword [esi+LD_FreeSectors], 0
 32205 0000725A E852010000          <1> 	call	get_free_FAT_sectors
 32206 0000725F 720D                <1> 	jc	short loc_validate_hd_FAT_partition_retn
 32207 00007261 894674              <1> 	mov	[esi+LD_FreeSectors], eax
 32208 00007264 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6  ; Volume Name Reset
 32209                              <1> 
 32210                              <1> 	; 15/07/2020
 32211 00007268 FE05[67300100]      <1> 	inc 	byte [Last_DOS_DiskNo] ; > 1
 32212                              <1> 
 32213                              <1> 	;mov	cl, [Last_DOS_DiskNo] 
 32214                              <1> 	;add	cl, 'A'
 32215                              <1> 	;mov	[esi+LD_FS_Name], cl
 32216                              <1> 
 32217                              <1> loc_validate_hd_FAT_partition_retn:         
 32218 0000726E C3                  <1> 	retn
 32219                              <1> 
 32220                              <1> validate_hd_fs_partition:
 32221                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32222                              <1> 	; 03/02/2018
 32223                              <1> 	; 09/12/2017
 32224                              <1> 	; 13/02/2016
 32225                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32226                              <1> 	; 29/01/2011
 32227                              <1> 	; 23/07/2011
 32228                              <1> 	; Input
 32229                              <1> 	;   DL = Hard/Fixed Disk Drive Number
 32230                              <1> 	;   ESI = PartitionTable offset
 32231                              <1> 	;   byte [Last_DOS_DiskNo]
 32232                              <1> 	; Output
 32233                              <1> 	;  cf=0 -> Validated
 32234                              <1> 	;   ESI = Logical dos drv desc. table
 32235                              <1> 	;   EBX = Singlix FS boot sector buffer
 32236                              <1> 	;   byte [Last_DOS_DiskNo]
 32237                              <1> 	;  cf=1 -> Not a valid 'Singlix FS' partition
 32238                              <1> 	; EAX, EDX, ECX, EDI -> changed 
 32239                              <1> 
 32240                              <1> 	;mov	esi, PartitionTable
 32241 0000726F 8A6604              <1> 	mov	ah, [esi+ptFileSystemID]
 32242 00007272 80FCA1              <1> 	cmp	ah, 0A1h ; SINGLIX FS1 (trfs1) partition
 32243 00007275 7549                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
 32244                              <1> loc_set_valid_hd_fs_partition_params:
 32245 00007277 FE05[67300100]      <1> 	inc	byte [Last_DOS_DiskNo] ; > 1
 32246 0000727D 30C0                <1> 	xor	al, al ; mov al, 0
 32247                              <1> 	;mov	[drv], dl
 32248 0000727F 29DB                <1> 	sub	ebx, ebx ; 0
 32249 00007281 8A3D[67300100]      <1> 	mov	bh, [Last_DOS_DiskNo] 
 32250 00007287 81C300010900        <1> 	add	ebx, Logical_DOSDisks
 32251 0000728D C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
 32252 00007291 885302              <1> 	mov	[ebx+LD_PhyDrvNo], dl
 32253                              <1> 	;mov	[ebx+LD_FATType], al ; 0
 32254                              <1> 	;mov	[ebx+LD_FSType], ah
 32255 00007294 66894303            <1> 	mov	[ebx+LD_FATType], ax
 32256                              <1> 	;mov	eax, [esi+ptStartSector]
 32257                              <1> 	;mov	[ebx+LD_StartSector], eax
 32258                              <1> loc_hd_fs_logical_drv_init:
 32259 00007298 89DD                <1> 	mov	ebp, ebx ; 10/01/2016
 32260                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
 32261 0000729A A0[467D0100]        <1> 	mov	al, [HD_LBA_yes] ; 10/01/2016
 32262 0000729F 884305              <1> 	mov	[ebx+LD_LBAYes], al
 32263 000072A2 89DE                <1> 	mov	esi, ebx
 32264 000072A4 BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
 32265 000072A9 08C0                <1> 	or	al, al
 32266 000072AB 7515                <1> 	jnz	short loc_hd_fs_drv_init_load_bs_lba
 32267                              <1> loc_hd_fs_drv_init_load_bs_chs:
 32268 000072AD 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
 32269 000072B0 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
 32270 000072B4 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
 32271                              <1> 	;mov	ebx, DOSBootSectorBuff
 32272 000072B8 E880DCFFFF          <1> 	call	int13h
 32273 000072BD 7311                <1> 	jnc	short loc_hd_drv_fs_boot_validation
 32274                              <1> loc_validate_hd_fs_partition_err_retn:
 32275 000072BF C3                  <1> 	retn
 32276                              <1> loc_validate_hd_fs_partition_stc_retn:
 32277 000072C0 F9                  <1> 	stc
 32278 000072C1 C3                  <1> 	retn
 32279                              <1> loc_hd_fs_drv_init_load_bs_lba:
 32280                              <1> 	; DL = Physical drive number
 32281                              <1> 	;mov	esi, ebx
 32282 000072C2 8B4E08              <1>    	mov	ecx, [esi+ptStartSector] ; sector number
 32283                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
 32284                              <1> 	; LBA read/write (with private LBA function) 
 32285                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
 32286                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
 32287 000072C5 B41B                <1> 	mov	ah, 1Bh ; LBA read
 32288 000072C7 B001                <1> 	mov	al, 1 ; sector count
 32289 000072C9 E86FDCFFFF          <1> 	call	int13h
 32290 000072CE 72EF                <1> 	jc	short loc_validate_hd_fs_partition_err_retn
 32291                              <1> loc_hd_drv_fs_boot_validation:
 32292                              <1> 	;mov	esi, DOSBootSectorBuff
 32293 000072D0 89DE                <1> 	mov	esi, ebx ; Boot sector buffer
 32294 000072D2 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
 32295 000072DB 75E3                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
 32296                              <1>         ;
 32297                              <1> 	;Singlix FS Extensions to TR-DOS (7/6/2009) 
 32298 000072DD 66817E034653        <1> 	cmp	word [esi+bs_FS_Identifier], 'FS' ; 03/02/2018
 32299 000072E3 75DB                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
 32300                              <1>         ;'A1h' check is not necessary
 32301                              <1> 	;  if 'FS' check is passed as OK/Yes.
 32302 000072E5 807E09A1            <1> 	cmp	byte [esi+bs_FS_PartitionID], 0A1h
 32303 000072E9 75D5                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
 32304                              <1> 	;
 32305 000072EB 89EF                <1> 	mov	edi, ebp ; 10/01/2016
 32306                              <1> 	;
 32307 000072ED 8A462D              <1> 	mov	al, byte [esi+bs_FS_LBA_Ready]
 32308 000072F0 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
 32309                              <1> 	;
 32310                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
 32311 000072F3 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
 32312 000072F6 884706              <1> 	mov	byte [edi+LD_FS_MediaAttrib], al
 32313                              <1> 	;
 32314 000072F9 8A460A              <1> 	mov	al, [esi+bs_FS_VersionMaj]
 32315 000072FC 884707              <1> 	mov	[edi+LD_FS_VersionMajor], al
 32316                              <1> 	;
 32317 000072FF 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
 32318 00007303 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
 32319 00007307 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
 32320 0000730A 30E4                <1> 	xor	ah, ah ; 09/12/2017
 32321 0000730C 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
 32322 00007310 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
 32323 00007313 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
 32324                              <1> 	;
 32325 00007317 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
 32326 0000731A 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
 32327 0000731D 8B5618              <1> 	mov	edx, [esi+bs_FS_MATLocation]
 32328 00007320 89570C              <1> 	mov	[edi+LD_FS_MATLocation], edx
 32329 00007323 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
 32330 00007326 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
 32331 00007329 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
 32332 0000732C 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
 32333 0000732F 8B4710              <1> 	mov	eax, [edi+bs_FS_VolumeSize]
 32334 00007332 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
 32335                              <1> 	;
 32336 00007335 89D0                <1> 	mov	eax, edx ; [edi+LD_FS_MATLocation]
 32337 00007337 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
 32338 0000733A 89FE                <1> 	mov	esi, edi
 32339                              <1> mread_hd_fs_MAT_sector:
 32340                              <1>         ;mov	ebx, DOSBootSectorBuff
 32341                              <1> 	;mov	ecx, 1
 32342                              <1> 	; 25/07/2022
 32343 0000733C 29C9                <1> 	sub	ecx, ecx
 32344 0000733E FEC1                <1> 	inc	cl
 32345                              <1> 	; ecx = 1	
 32346 00007340 E8E4A90000          <1> 	call	disk_read
 32347 00007345 7248                <1> 	jc	short loc_validate_hd_fs_partition_retn
 32348                              <1> 	; EDI will not be changed
 32349 00007347 89DE                <1> 	mov	esi, ebx
 32350                              <1> use_hdfs_mat_sector_params:
 32351 00007349 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
 32352 0000734C 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
 32353 0000734F 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
 32354 00007352 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
 32355 00007355 8B4614              <1> 	mov	eax, [esi+FS_MAT_FreeSectors]
 32356 00007358 894774              <1>         mov     [edi+LD_FS_FreeSectors], eax
 32357 0000735B 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
 32358 0000735E 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
 32359 00007361 8B4708              <1> 	mov	eax, [edi+LD_FS_RootDirD]
 32360 00007364 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
 32361 00007367 89FE                <1> 	mov	esi, edi   
 32362                              <1> read_hd_fs_RDT_sector:
 32363 00007369 BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff
 32364                              <1> 	;mov	ecx, 1
 32365 0000736E B101                <1> 	mov	cl, 1
 32366 00007370 E8B4A90000          <1> 	call	disk_read
 32367 00007375 7218                <1> 	jc	short loc_validate_hd_fs_partition_retn
 32368                              <1> 	; EDI will not be changed
 32369 00007377 89DE                <1> 	mov	esi, ebx
 32370                              <1> use_hdfs_RDT_sector_params:
 32371 00007379 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
 32372 0000737C 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
 32373 0000737F 57                  <1> 	push	edi
 32374                              <1> 	;mov	ecx, 16
 32375 00007380 B110                <1> 	mov	cl, 16
 32376 00007382 83C640              <1> 	add	esi, FS_RDT_VolumeName
 32377 00007385 83C72C              <1> 	add	edi, LD_FS_VolumeName
 32378 00007388 F3A5                <1> 	rep	movsd ; 64 bytes
 32379 0000738A 5E                  <1> 	pop	esi
 32380                              <1> 		; Volume Name Reset
 32381 0000738B C6467E06            <1>         mov     byte [esi+LD_FS_MediaChanged], 6
 32382                              <1> 	;
 32383                              <1>         ;mov	cl, [Last_DOS_DiskNo] 
 32384                              <1> 	;add	cl, 'A'
 32385                              <1> 	;mov	[esi+LD_FS_Name], cl
 32386                              <1> 
 32387                              <1> loc_validate_hd_fs_partition_retn:
 32388 0000738F C3                  <1> 	retn
 32389                              <1> 
 32390                              <1> load_masterboot:
 32391                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32392                              <1> 	; 14/07/2020 (Reset function has been removed)
 32393                              <1> 	;
 32394                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32395                              <1> 	; 2005 - 2011
 32396                              <1> 	; input -> DL = drive number
 32397                              <1> ;	mov	ah, 0Dh ; Alternate disk reset
 32398                              <1> ;	call	int13h
 32399                              <1> ;	jnc	short pass_reset_error
 32400                              <1> ;harddisk_error:
 32401                              <1> ;  	retn
 32402                              <1> ;pass_reset_error:
 32403 00007390 BB[427A0100]        <1> 	mov	ebx, MasterBootBuff
 32404                              <1> 	;mov	ax, 0201h
 32405                              <1> 	;mov	cx, 1
 32406                              <1> 	; 25/07/2022
 32407                              <1> 	;xor	ecx, ecx
 32408                              <1> 	;inc	cl
 32409 00007395 B101                <1> 	mov	cl, 1
 32410                              <1> 	; ecx = 1
 32411 00007397 89C8                <1> 	mov	eax, ecx ; ch = cylinder = 0
 32412 00007399 B402                <1> 	mov	ah, 2  ; chs read
 32413                              <1> 	; eax = 0201h
 32414 0000739B 30F6                <1> 	xor	dh, dh ; head = 0
 32415 0000739D E89BDBFFFF          <1> 	call	int13h
 32416 000073A2 720C                <1> 	jc	short harddisk_error
 32417                              <1> 	;
 32418 000073A4 66813D[407C0100]55- <1> 	cmp	word [MBIDCode], 0AA55h
 32419 000073AC AA                  <1>
 32420 000073AD 7401                <1> 	je	short load_masterboot_ok
 32421 000073AF F9                  <1> 	stc
 32422                              <1> harddisk_error:
 32423                              <1> load_masterboot_ok:
 32424 000073B0 C3                  <1> 	retn
 32425                              <1> 
 32426                              <1> get_free_FAT_sectors:
 32427                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32428                              <1> 	; 21/12/2017
 32429                              <1> 	; 29/02/2016
 32430                              <1> 	; 13/02/2016
 32431                              <1> 	; 04/02/2016
 32432                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
 32433                              <1> 	; 11/07/2010
 32434                              <1> 	; 21/06/2009
 32435                              <1> 	; INPUT: ESI = Logical DOS Drive Description Table address
 32436                              <1> 	; OUTPUT: STC => Error
 32437                              <1>         ;	cf = 0 and EAX = Free FAT sectors
 32438                              <1> 	; Also, related parameters and FAT buffer will be reset and updated
 32439                              <1> 
 32440 000073B1 31C0                <1> 	xor	eax, eax
 32441                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Reset
 32442                              <1> 	
 32443 000073B3 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
 32444 000073B7 7653                <1> 	jna	short loc_gfc_get_fat_free_clusters
 32445                              <1> 
 32446                              <1> 	; 29/02/2016
 32447 000073B9 48                  <1> 	dec	eax ; 0FFFFFFFFh
 32448 000073BA 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count (reset)
 32449 000073BD 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster (reset)
 32450 000073C0 40                  <1> 	inc	eax ; 0
 32451                              <1> 	;
 32452 000073C1 668B4636            <1> 	mov	ax, [esi+LD_BPB+BPB_FSInfo]
 32453 000073C5 03466C              <1> 	add	eax, [esi+LD_StartSector]
 32454                              <1> 
 32455 000073C8 BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff
 32456                              <1> 	;mov	ecx, 1
 32457                              <1> 	; 25/07/2022
 32458 000073CD 31C9                <1> 	xor	ecx, ecx
 32459 000073CF FEC1                <1> 	inc	cl
 32460                              <1> 	; ecx = 1
 32461 000073D1 E853A90000          <1>  	call	disk_read
 32462 000073D6 7301                <1> 	jnc	short loc_gfc_check_fsinfo_signs
 32463                              <1> retn_gfc_get_fsinfo_sec:
 32464 000073D8 C3                  <1> 	retn
 32465                              <1> 
 32466                              <1> loc_gfc_check_fsinfo_signs:
 32467 000073D9 BB[527D0100]        <1> 	mov 	ebx, DOSBootSectorBuff ; 13/02/2016
 32468 000073DE 813B52526141        <1>         cmp     dword [ebx], 41615252h
 32469 000073E4 7524                <1> 	jne	short retn_gfc_get_fsinfo_stc
 32470                              <1> 	;add	ebx, 484
 32471                              <1> 	;cmp	dword [ebx], 61417272h
 32472 000073E6 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
 32473 000073EF 61                  <1>
 32474 000073F0 7518                <1> 	jne	short retn_gfc_get_fsinfo_stc
 32475                              <1> 	;add	ebx, 4
 32476                              <1> 	;mov	eax, [ebx]
 32477 000073F2 8B83E8010000        <1> 	mov	eax, [ebx+488]
 32478                              <1> 	; 29/02/2016
 32479 000073F8 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
 32480 000073FB 8B93EC010000        <1> 	mov	edx,  [ebx+492] 
 32481 00007401 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster
 32482                              <1> 	; 21/12/2017
 32483 00007404 89C3                <1> 	mov	ebx, eax ; (initial value = 0FFFFFFFFh)
 32484 00007406 43                  <1> 	inc	ebx ; 0FFFFFFFFh -> 0  
 32485 00007407 7513                <1> 	jnz	short short retn_from_get_free_fat32_clusters
 32486 00007409 C3                  <1> 	retn
 32487                              <1> 
 32488                              <1> retn_gfc_get_fsinfo_stc:
 32489 0000740A F9                  <1> 	stc
 32490 0000740B C3                  <1> 	retn
 32491                              <1> 
 32492                              <1> loc_gfc_get_fat_free_clusters:
 32493                              <1> 	;mov	eax, 2
 32494 0000740C B002                <1> 	mov	al, 2
 32495                              <1> 	;mov	[FAT_CurrentCluster], eax
 32496                              <1> loc_gfc_loop_get_next_cluster:
 32497 0000740E E8774D0000          <1> 	call	get_next_cluster
 32498 00007413 730E                <1> 	jnc	short loc_gfc_free_fat_clusters_cont
 32499 00007415 21C0                <1> 	and	eax, eax
 32500 00007417 7411                <1> 	jz	short loc_gfc_pass_inc_free_cluster_count
 32501                              <1>  
 32502                              <1> retn_from_get_free_fat_clusters:
 32503 00007419 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors] ; Free clusters !
 32504                              <1> retn_from_get_free_fat32_clusters:
 32505 0000741C 0FB65E13            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
 32506 00007420 F7E3                <1>       	mul	ebx
 32507                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Free sectors
 32508                              <1> retn_get_free_sectors_calc:
 32509 00007422 C3                  <1> 	retn
 32510                              <1> 
 32511                              <1> loc_gfc_free_fat_clusters_cont:
 32512 00007423 09C0                <1> 	or	eax, eax
 32513 00007425 7503                <1> 	jnz	short loc_gfc_pass_inc_free_cluster_count
 32514 00007427 FF4674              <1> 	inc	dword [esi+LD_FreeSectors] ; Free clusters !
 32515                              <1>    
 32516                              <1> loc_gfc_pass_inc_free_cluster_count:
 32517                              <1> 	;mov	eax, [FAT_CurrentCluster]
 32518 0000742A 89C8                <1> 	mov	eax, ecx ; [FAT_CurrentCluster]
 32519 0000742C 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
 32520 0000742F 77E8                <1> 	ja	short retn_from_get_free_fat_clusters
 32521 00007431 40                  <1> 	inc	eax
 32522                              <1> 	;mov	[FAT_CurrentCluster], eax
 32523 00007432 EBDA                <1> 	jmp	short loc_gfc_loop_get_next_cluster
 32524                              <1> 
 32525                              <1> floppy_drv_init:
 32526                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32527                              <1> 	; 09/12/2017
 32528                              <1> 	; 06/07/2016
 32529                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32530                              <1> 	; 24/07/2011
 32531                              <1> 	; 04/07/2009
 32532                              <1> 	; INPUT ->
 32533                              <1> 	;	DL = Drive number (0,1)
 32534                              <1> 	; OUTPUT ->
 32535                              <1> 	;	BL = drive name
 32536                              <1> 	;	BH = drive number
 32537                              <1> 	;	ESI = Logical DOS drv description table
 32538                              <1> 	;	EAX = Volume serial number
 32539                              <1>  
 32540 00007434 BE[FC640000]        <1> 	mov	esi, fd0_type ; 10/01/2016
 32541 00007439 BF00010900          <1> 	mov	edi, Logical_DOSDisks
 32542 0000743E 08D2                <1> 	or	dl, dl
 32543 00007440 7407                <1> 	jz	short loc_drv_init_fd0_fd1
 32544 00007442 81C700010000        <1> 	add	edi, 100h
 32545 00007448 46                  <1> 	inc	esi ; fd1_type ; 10/01/2016
 32546                              <1> loc_drv_init_fd0_fd1:
 32547 00007449 C6477E00            <1> 	mov	byte [edi+LD_MediaChanged], 0
 32548 0000744D 803E01              <1> 	cmp	byte [esi], 1 ; type (>0 if it is existing) 
 32549                              <1> 		; 4 = 1.44 MB, 80 track, 3 1/2"
 32550 00007450 7221                <1> 	jb	short read_fd_boot_sector_retn
 32551 00007452 885702              <1> 	mov	[edi+LD_PhyDrvNo], dl
 32552                              <1> read_fd_boot_sector:
 32553 00007455 30F6                <1> 	xor	dh, dh
 32554 00007457 B904000000          <1> 	mov	ecx, 4 ; Retry Count
 32555                              <1> read_fd_boot_sector_again:
 32556 0000745C 51                  <1> 	push 	ecx
 32557                              <1> 	;mov	cx, 1
 32558 0000745D B101                <1> 	mov	cl, 1
 32559 0000745F 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
 32560 00007463 BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff
 32561 00007468 E8D0DAFFFF          <1> 	call	int13h
 32562 0000746D 59                  <1> 	pop	ecx
 32563 0000746E 7304                <1> 	jnc	short use_fd_boot_sector_params
 32564 00007470 E2EA                <1> 	loop	read_fd_boot_sector_again
 32565                              <1> 
 32566                              <1> read_fd_boot_sector_stc_retn:
 32567 00007472 F9                  <1> 	stc
 32568                              <1> read_fd_boot_sector_retn:
 32569 00007473 C3                  <1> 	retn
 32570                              <1> 
 32571                              <1> use_fd_boot_sector_params:
 32572                              <1> 	;mov	esi, DOSBootSectorBuff
 32573 00007474 89DE                <1> 	mov	esi, ebx
 32574 00007476 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
 32575 0000747F 75F1                <1> 	jne	short read_fd_boot_sector_stc_retn
 32576 00007481 66817E035346        <1>         cmp     word [esi+bs_FS_Identifier], 'SF'
 32577                              <1> 	;jne	use_fd_fatfs_boot_sector_params
 32578                              <1> 	; 25/07/2022
 32579 00007487 7405                <1> 	je	short use_fdfs_boot_sector_params
 32580 00007489 E9A1000000          <1> 	jmp	use_fd_fatfs_boot_sector_params	
 32581                              <1> use_fdfs_boot_sector_params:
 32582 0000748E 8A462D              <1> 	mov	al, [esi+bs_FS_LBA_Ready]
 32583 00007491 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
 32584                              <1> 	;
 32585                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
 32586 00007494 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
 32587 00007497 884706              <1> 	mov	[edi+LD_FS_MediaAttrib], al
 32588                              <1> 	;
 32589 0000749A 8A460A              <1>         mov	al, [esi+bs_FS_VersionMaj]
 32590 0000749D 884707              <1> 	mov	byte [edi+LD_FS_VersionMajor], al
 32591 000074A0 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
 32592 000074A4 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
 32593 000074A8 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
 32594 000074AB 28E4                <1> 	sub	ah, ah ; 09/12/2017
 32595 000074AD 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
 32596 000074B1 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
 32597 000074B4 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
 32598                              <1> 	;
 32599 000074B8 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
 32600 000074BB 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
 32601 000074BE 8B4618              <1> 	mov	eax, [esi+bs_FS_MATLocation]
 32602 000074C1 89470C              <1> 	mov	[edi+LD_FS_MATLocation], eax
 32603 000074C4 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
 32604 000074C7 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
 32605 000074CA 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
 32606 000074CD 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
 32607 000074D0 8B4610              <1> 	mov	eax, [esi+bs_FS_VolumeSize]
 32608 000074D3 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
 32609                              <1> 	;		
 32610 000074D6 89FE                <1> 	mov	esi, edi
 32611 000074D8 8B460C              <1>  	mov	eax, [esi+LD_FS_MATLocation]
 32612                              <1> 	;add	eax, [edi+LD_FS_BeginSector]
 32613                              <1> read_fd_MAT_sector_again:
 32614                              <1> 	;mov	ebx, DOSBootSectorBuff
 32615                              <1> 	;mov	ecx, 1
 32616 000074DB B101                <1> 	mov	cl, 1
 32617 000074DD E84DA80000          <1> 	call	chs_read
 32618 000074E2 89DE                <1> 	mov	esi, ebx
 32619                              <1> 	;jnc	short use_fdfs_mat_sector_params
 32620                              <1> 	;jmp	short read_fd_boot_sector_retn
 32621                              <1> 	;retn
 32622                              <1> 	; 25/07/2022
 32623 000074E4 7248                <1> 	jc	short read_fd_RDT_sector_retn
 32624                              <1> use_fdfs_mat_sector_params:
 32625 000074E6 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
 32626 000074E9 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
 32627 000074EC 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
 32628 000074EF 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
 32629 000074F2 8B4714              <1> 	mov	eax, [edi+FS_MAT_FreeSectors]
 32630 000074F5 894774              <1> 	mov	[edi+LD_FS_FreeSectors], eax
 32631 000074F8 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
 32632 000074FB 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
 32633                              <1> 	;
 32634 000074FE 89FE                <1> 	mov	esi, edi
 32635 00007500 8B4608              <1>  	mov	eax, [esi+LD_FS_RootDirD]
 32636                              <1> read_fd_RDT_sector_again:
 32637                              <1> 	;mov	ebx, DOSBootSectorBuff
 32638                              <1> 	;mov	cx, 1
 32639 00007503 B101                <1> 	mov	cl, 1
 32640 00007505 E825A80000          <1> 	call	chs_read
 32641 0000750A 89DE                <1> 	mov	esi, ebx
 32642 0000750C 7220                <1> 	jc	short read_fd_RDT_sector_retn
 32643                              <1> use_fdfs_RDT_sector_params:
 32644 0000750E 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
 32645 00007511 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
 32646 00007514 57                  <1> 	push	edi
 32647                              <1> 	;mov	ecx, 16
 32648 00007515 B110                <1> 	mov	cl, 16	
 32649 00007517 83C640              <1> 	add	esi, FS_RDT_VolumeName
 32650 0000751A 83C72C              <1> 	add	edi, LD_FS_VolumeName
 32651 0000751D F3A5                <1> 	rep	movsd ; 64 bytes
 32652 0000751F 5E                  <1> 	pop	esi
 32653 00007520 C6460300            <1> 	mov	byte [esi+LD_FATType], 0
 32654 00007524 C64604A1            <1> 	mov	byte [esi+LD_FSType], 0A1h  
 32655 00007528 E9A2000000          <1>         jmp     loc_cont_use_fd_boot_sector_params
 32656                              <1> 
 32657                              <1> read_fd_RDT_sector_stc_retn:
 32658 0000752D F9                  <1> 	stc
 32659                              <1> read_fd_RDT_sector_retn:
 32660 0000752E C3                  <1> 	retn
 32661                              <1> 
 32662                              <1> use_fd_fatfs_boot_sector_params:
 32663 0000752F 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
 32664 00007533 75F8                <1> 	jne	short read_fd_RDT_sector_stc_retn
 32665 00007535 807E15F0            <1> 	cmp	byte [esi+BPB_Media], 0F0h
 32666 00007539 72F3                <1> 	jb	short read_fd_RDT_sector_retn
 32667 0000753B 57                  <1> 	push	edi
 32668 0000753C 83C706              <1> 	add	edi, LD_BPB
 32669                              <1> 	;mov	ecx, 16
 32670 0000753F B110                <1> 	mov	cl, 16
 32671 00007541 F3A5                <1> 	rep	movsd ; 64 bytes 
 32672 00007543 5E                  <1> 	pop	esi
 32673 00007544 31C0                <1> 	xor	eax, eax
 32674 00007546 89466C              <1> 	mov	[esi+LD_StartSector], eax ; 0
 32675 00007549 668B461C            <1> 	mov	ax, [esi+LD_BPB+BPB_FATSz16]
 32676 0000754D 8A4E16              <1> 	mov	cl, [esi+LD_BPB+BPB_NumFATs] 
 32677 00007550 F7E1                <1>   	mul	ecx
 32678                              <1> 	; edx = 0 !
 32679 00007552 668B5614            <1> 	mov	dx, [esi+LD_BPB+BPB_RsvdSecCnt]
 32680 00007556 66895660            <1> 	mov	[esi+LD_FATBegin], dx
 32681                              <1> 	; 25/07/2022
 32682 0000755A 01D0                <1> 	add	eax, edx
 32683                              <1> 	;add	ax, dx
 32684 0000755C 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
 32685 0000755F 894668              <1> 	mov	[esi+LD_DATABegin], eax 
 32686 00007562 668B5617            <1> 	mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
 32687                              <1> 	;;shl	edx, 5 ; * 32 (Size of a directory entry)
 32688                              <1> 	;shl	dx, 5
 32689                              <1> 	;;add	edx, 511
 32690                              <1> 	;add	dx, 511
 32691                              <1> 	;;shr	edx, 9 ; edx = ((edx*32)+511) / 512
 32692                              <1> 	;shr	dx, 9
 32693 00007566 6683C20F            <1> 	add	dx, 15 ; 06/07/2016 (+(512/32)-1)
 32694                              <1> 	;shr	dx, 4 ; / 16 (==16 entries per sector)
 32695                              <1> 	; 25/07/2022
 32696 0000756A C1EA04              <1> 	shr	edx, 4
 32697 0000756D 015668              <1> 	add 	[esi+LD_DATABegin], edx ; + rd sectors
 32698                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
 32699 00007570 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
 32700 00007574 894670              <1> 	mov	[esi+LD_TotalSectors], eax
 32701 00007577 2B4668              <1> 	sub	eax, [esi+LD_DATABegin]
 32702                              <1>   	;movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust]
 32703 0000757A 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]  
 32704 0000757D 80F901              <1> 	cmp	cl, 1
 32705 00007580 7604                <1> 	jna	short save_fd_fatfs_cluster_count
 32706                              <1> 	; 25/07/2022
 32707 00007582 29D2                <1> 	sub	edx, edx
 32708                              <1> 	;sub	dx, dx ; 0
 32709                              <1> 	;sub	dl, dl ; 06/07/2016
 32710 00007584 F7F1                <1> 	div	ecx
 32711                              <1> save_fd_fatfs_cluster_count:
 32712 00007586 894678              <1> 	mov	[esi+LD_Clusters], eax
 32713                              <1> 
 32714                              <1>       ; Maximum Valid Cluster Number = EAX +1
 32715                              <1>       ; with 2 reserved clusters= EAX +2
 32716                              <1>  
 32717                              <1> reset_FAT_buffer_decriptors:
 32718 00007589 29C0                <1> 	sub	eax, eax ; 0  
 32719 0000758B A2[567F0100]        <1> 	mov	[FAT_BuffValidData], al ; 0
 32720 00007590 A2[577F0100]        <1> 	mov	[FAT_BuffDrvName], al ; 0
 32721 00007595 A3[5A7F0100]        <1> 	mov	[FAT_BuffSector], eax ; 0
 32722                              <1> 
 32723                              <1> read_fd_FAT_sectors:
 32724 0000759A BB001C0900          <1>   	mov	ebx, FAT_Buffer
 32725 0000759F 668B4614            <1> 	mov	ax, [esi+LD_BPB+BPB_RsvdSecCnt]
 32726                              <1> 	;mov	ecx, 3
 32727 000075A3 B103                <1> 	mov	cl, 3 ; 3 sectors
 32728 000075A5 E885A70000          <1> 	call	chs_read
 32729 000075AA 7240                <1> 	jc	short read_fd_FAT_sectors_retn
 32730                              <1> use_fd_FAT_sectors:
 32731 000075AC 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo]
 32732 000075AF 0441                <1> 	add	al, 'A' 
 32733 000075B1 A2[577F0100]        <1> 	mov	[FAT_BuffDrvName], al 
 32734 000075B6 C605[567F0100]01    <1>  	mov	byte [FAT_BuffValidData], 1
 32735 000075BD E82B000000          <1> 	call	fd_init_calculate_free_clusters
 32736 000075C2 7228                <1> 	jc	short read_fd_FAT_sectors_retn
 32737                              <1>   
 32738                              <1> loc_use_fd_boot_sector_params_FAT:
 32739 000075C4 C6460301            <1> 	mov	byte [esi+LD_FATType], 1 ; FAT 12
 32740 000075C8 C6460401            <1> 	mov	byte [esi+LD_FSType], 1
 32741 000075CC 8B462D              <1>         mov     eax, [esi+LD_BPB+VolumeID]
 32742                              <1> loc_cont_use_fd_boot_sector_params:
 32743 000075CF 8A7E02              <1> 	mov	bh, [esi+LD_PhyDrvNo]
 32744 000075D2 887E7D              <1> 	mov	[esi+LD_DParamEntry], bh
 32745 000075D5 88FB                <1> 	mov	bl, bh
 32746 000075D7 80C341              <1> 	add	bl, 'A'
 32747 000075DA 881E                <1> 	mov	byte [esi+LD_Name], bl
 32748 000075DC C6460101            <1> 	mov	byte [esi+LD_DiskType], 1
 32749 000075E0 C6460500            <1> 	mov	byte [esi+LD_LBAYes], 0
 32750 000075E4 C6467C00            <1> 	mov	byte [esi+LD_PartitionEntry], 0
 32751 000075E8 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6 ; Volume Name Reset
 32752                              <1> 
 32753                              <1> read_fd_FAT_sectors_retn:
 32754 000075EC C3                  <1> 	retn   
 32755                              <1> 
 32756                              <1> fd_init_calculate_free_clusters:
 32757                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32758                              <1> 	; 09/12/2017
 32759                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32760                              <1> 	; 04/07/2009
 32761                              <1> 	; INPUT ->
 32762                              <1> 	;     ESI = Logical DOS drive description table address
 32763                              <1> 	; OUTPUT ->
 32764                              <1> 	;    [ESI+LD_FreeSectors] will be set
 32765                              <1> 	
 32766 000075ED 29C0                <1> 	sub	eax, eax
 32767 000075EF 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; 0
 32768 000075F2 B002                <1> 	mov	al, 2 ; eax = 2
 32769                              <1> 
 32770                              <1> fd_init_loop_get_next_cluster:
 32771 000075F4 E828000000          <1> 	call	fd_init_get_next_cluster
 32772 000075F9 7225                <1> 	jc	short fd_init_calculate_free_clusters_retn
 32773                              <1> 
 32774                              <1> fd_init_free_fat_clusters:
 32775                              <1> 	;cmp 	eax, 0
 32776                              <1> 	;ja	short fd_init_pass_inc_free_cluster_count
 32777                              <1> 	;and	eax, eax
 32778                              <1> 	;jnz	short fd_init_pass_inc_free_cluster_count
 32779                              <1> 	;and	ax, ax
 32780 000075FB 21C0                <1> 	and	eax, eax ; 25/07/2022
 32781 000075FD 7503                <1> 	jnz	short fd_init_pass_inc_free_cluster_count
 32782                              <1> 	; 25/07/2022
 32783 000075FF FF4674              <1> 	inc	dword [esi+LD_FreeSectors]
 32784                              <1>         ;inc	word [esi+LD_FreeSectors]
 32785                              <1>     
 32786                              <1> fd_init_pass_inc_free_cluster_count:
 32787                              <1>   	; 25/07/2022
 32788 00007602 A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 32789                              <1> 	;mov	ax, [FAT_CurrentCluster]
 32790 00007607 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
 32791                              <1> 	;cmp	ax, [esi+LD_Clusters]
 32792 0000760A 7703                <1> 	ja	short short retn_from_fd_init_calculate_free_clusters
 32793 0000760C 40                  <1> 	inc	eax
 32794                              <1> 	;inc	ax
 32795 0000760D EBE5                <1> 	jmp	short fd_init_loop_get_next_cluster
 32796                              <1> 
 32797                              <1> retn_from_fd_init_calculate_free_clusters:
 32798                              <1> 	; 25/07/2022
 32799                              <1> 	;xor	eax, eax
 32800 0000760F 30E4                <1> 	xor	ah, ah
 32801 00007611 8A4613              <1>   	mov	al, [esi+LD_BPB+BPB_SecPerClust]
 32802 00007614 3C01                <1>   	cmp	al, 1
 32803 00007616 7608                <1> 	jna	short fd_init_calculate_free_clusters_retn
 32804                              <1> 	;;movzx	eax, al
 32805                              <1> 	;xor	ah, ah ; 09/12/2017
 32806                              <1> 	; 25/07/2022
 32807 00007618 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
 32808                              <1> 	;mov	cx, [esi+LD_FreeSectors] ; Count of free clusters
 32809 0000761B F7E1                <1>   	mul	ecx
 32810                              <1> 	;mul	cx
 32811 0000761D 894674              <1> 	mov	[esi+LD_FreeSectors], eax
 32812                              <1> 	;mov	[esi+LD_FreeSectors], ax
 32813                              <1> fd_init_calculate_free_clusters_retn:
 32814 00007620 C3                  <1> 	retn
 32815                              <1> 
 32816                              <1> fd_init_get_next_cluster:
 32817                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32818                              <1> 	; 04/02/2016
 32819                              <1> 	; 02/02/2016
 32820                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32821                              <1> 	; 04/07/2009
 32822                              <1> 	; INPUT ->
 32823                              <1> 	;    EAX = Current cluster
 32824                              <1> 	;    ESI = Logical DOS drive description table address
 32825                              <1> 	;    EDX = 0
 32826                              <1> 	; OUTPUT ->
 32827                              <1> 	;    EAX = Next cluster
 32828                              <1> 
 32829 00007621 A3[527F0100]        <1> 	mov	[FAT_CurrentCluster], eax
 32830                              <1> fd_init_get_next_cluster_readnext:
 32831 00007626 29D2                <1> 	sub	edx, edx ; 0
 32832 00007628 BB00040000          <1>   	mov	ebx, 1024 ; 400h
 32833 0000762D F7F3                <1>   	div	ebx
 32834                              <1>   	; EAX = Count of 3 FAT sectors
 32835                              <1>   	; EDX = Buffer entry index
 32836 0000762F 89C1                <1> 	mov	ecx, eax
 32837                              <1> 	;mov	eax, 3
 32838 00007631 B003                <1> 	mov	al, 3
 32839 00007633 F7E2                <1> 	mul	edx ; Multiply by 3
 32840                              <1> 	;shr	ax, 1 ; Divide by 2
 32841                              <1> 	; 25/07/2022
 32842 00007635 D1E8                <1> 	shr	eax, 1
 32843 00007637 89C3                <1> 	mov	ebx, eax ; Buffer byte offset
 32844 00007639 81C3001C0900        <1> 	add	ebx, FAT_Buffer
 32845 0000763F 89C8                <1> 	mov	eax, ecx
 32846                              <1> 	;mov	edx, 3
 32847 00007641 66BA0300            <1> 	mov	dx, 3
 32848 00007645 F7E2                <1> 	mul	edx 
 32849                              <1>   	; EAX = FAT Beginning Sector
 32850                              <1> 	; EDX = 0
 32851 00007647 8A0E                <1> 	mov	cl, [esi+LD_Name]
 32852                              <1> 	;cmp	byte [FAT_BuffValidData], 0
 32853                              <1> 	;jna	short fd_init_load_FAT_sectors0
 32854 00007649 3A0D[577F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
 32855 0000764F 751D                <1> 	jne	short fd_init_load_FAT_sectors0
 32856 00007651 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 32857 00007657 751B                <1> 	jne	short fd_init_load_FAT_sectors1
 32858                              <1> 	; 25/07/2022
 32859 00007659 A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 32860                              <1> 	;mov	al, [FAT_CurrentCluster]
 32861 0000765E D1E8                <1> 	shr	eax, 1
 32862                              <1> 	;shr	al, 1
 32863 00007660 668B03              <1> 	mov	ax, [ebx]
 32864 00007663 7305                <1>   	jnc	short fd_init_gnc_even
 32865                              <1> 	;shr	ax, 4
 32866                              <1> 	; 25/04/2022
 32867 00007665 C1E804              <1> 	shr	eax, 4
 32868                              <1> fd_init_gnc_clc_retn:
 32869 00007668 F8                  <1> 	clc
 32870 00007669 C3                  <1> 	retn
 32871                              <1> 
 32872                              <1> fd_init_gnc_even:
 32873 0000766A 80E40F              <1> 	and	ah, 0Fh
 32874 0000766D C3                  <1> 	retn
 32875                              <1> 
 32876                              <1> fd_init_load_FAT_sectors0:
 32877 0000766E 880D[577F0100]      <1> 	mov 	[FAT_BuffDrvName], cl
 32878                              <1> fd_init_load_FAT_sectors1:
 32879 00007674 C605[567F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
 32880 0000767B A3[5A7F0100]        <1> 	mov	[FAT_BuffSector], eax
 32881 00007680 034660              <1> 	add	eax, [esi+LD_FATBegin]
 32882 00007683 BB001C0900          <1>  	mov	ebx, FAT_Buffer
 32883                              <1> 	;movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
 32884 00007688 668B4E1C            <1> 	mov	cx, [esi+LD_BPB+BPB_FATSz16]
 32885                              <1> 	;sub	cx, [FAT_BuffSector]
 32886                              <1>         ; 25/07/2022
 32887 0000768C 2B0D[5A7F0100]      <1> 	sub	ecx, [FAT_BuffSector] 
 32888                              <1> 	;sub	edx, edx
 32889 00007692 B203                <1> 	mov	dl, 3
 32890                              <1> 	; edx = 3 
 32891                              <1> 	;;cmp	ecx, 3
 32892                              <1> 	;cmp	cx, 3
 32893 00007694 39D1                <1> 	cmp	ecx, edx ; 3
 32894 00007696 7602                <1> 	jna	short fdinit_pass_fix_sector_count_3
 32895                              <1> 	;;mov	ecx, 3
 32896                              <1> 	;mov	ecx, 3
 32897 00007698 89D1                <1> 	mov	ecx, edx ; 3
 32898                              <1> fdinit_pass_fix_sector_count_3:  
 32899 0000769A E890A60000          <1> 	call	chs_read
 32900 0000769F 730D                <1> 	jnc	short fd_init_FAT_sectors_no_load_error
 32901 000076A1 C605[567F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
 32902                              <1> 		; Drv not ready or read Error !
 32903 000076A8 B80F000000          <1> 	mov	eax, ERR_DRV_NOT_RDY ; 15
 32904                              <1> 	;xor	edx, edx
 32905 000076AD C3                  <1> 	retn
 32906                              <1> 
 32907                              <1> fd_init_FAT_sectors_no_load_error:
 32908 000076AE C605[567F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
 32909 000076B5 A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 32910 000076BA E967FFFFFF          <1>         jmp     fd_init_get_next_cluster_readnext
 32911                              <1> 
 32912                              <1> get_FAT_volume_name:
 32913                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 32914                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 32915                              <1> 	; 12/09/2009
 32916                              <1> 	; INPUT ->
 32917                              <1> 	;	BH = Logical DOS drive number (0,1,2,3,4 ...)
 32918                              <1> 	;       BL = 0
 32919                              <1> 	; OUTPUT ->
 32920                              <1> 	;	CF = 0 -> ESI = Volume name address
 32921                              <1> 	; 	CF = 1 -> Root volume name not found
 32922                              <1> 
 32923                              <1> 	;mov 	ah, 0FFh
 32924                              <1> 	;mov 	al, [Last_Dos_DiskNo]
 32925                              <1> 	;cmp 	al, bh
 32926                              <1> 	;jb     short loc_gfvn_dir_load_err
 32927                              <1> 
 32928 000076BF 89DE                <1> 	mov	esi, ebx
 32929 000076C1 81E600FF0000        <1> 	and	esi, 0FF00h ; esi = bh
 32930 000076C7 81C600010900        <1> 	add	esi, Logical_DOSDisks
 32931 000076CD 8A06                <1> 	mov     al, [esi+LD_Name]
 32932 000076CF 8A6603              <1> 	mov     ah, [esi+LD_FATType]
 32933 000076D2 80FC01              <1> 	cmp     ah, 1
 32934 000076D5 7210                <1> 	jb    	short loc_gfvn_dir_load_err
 32935 000076D7 3C41                <1> 	cmp 	al, 'A'
 32936 000076D9 720C                <1> 	jb      short loc_gfvn_dir_load_err
 32937 000076DB 80FC02              <1> 	cmp 	ah, 2 
 32938 000076DE 7708                <1> 	ja      short get_FAT32_root_cluster
 32939                              <1> 	
 32940 000076E0 E8E34B0000          <1> 	call    load_FAT_root_directory
 32941 000076E5 730B                <1> 	jnc     short loc_get_volume_name
 32942                              <1> 
 32943                              <1> loc_gfvn_dir_load_err:
 32944 000076E7 C3                  <1> 	retn
 32945                              <1> 
 32946                              <1> get_FAT32_root_cluster:
 32947 000076E8 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
 32948 000076EB E8564C0000          <1> 	call    load_FAT_sub_directory
 32949 000076F0 7222                <1> 	jc	short loc_get_volume_name_retn
 32950                              <1> 
 32951                              <1> loc_get_volume_name:
 32952 000076F2 BE00000800          <1>         mov     esi, Directory_Buffer
 32953                              <1> 	;xor	cx, cx ; 0
 32954                              <1> 	; 25/07/2022
 32955 000076F7 31C9                <1> 	xor	ecx, ecx ; 0
 32956                              <1> check_root_volume_name:
 32957 000076F9 8A06                <1> 	mov	al, [esi]
 32958 000076FB 08C0                <1> 	or      al, al
 32959 000076FD 7415                <1> 	jz      short loc_get_volume_name_retn
 32960 000076FF 807E0B08            <1> 	cmp     byte [esi+0Bh], 08h
 32961 00007703 740F                <1> 	je      short loc_get_volume_name_retn
 32962 00007705 663B0D[6C7F0100]    <1> 	cmp     cx, [DirBuff_LastEntry]
 32963 0000770C 7307                <1> 	jnb     short pass_check_root_volume_name
 32964                              <1> 	;inc	cx
 32965                              <1> 	; 25/07/2022
 32966 0000770E 41                  <1> 	inc	ecx
 32967 0000770F 83C620              <1> 	add     esi, 32
 32968 00007712 EBE5                <1> 	jmp     short check_root_volume_name
 32969                              <1> 
 32970                              <1> loc_get_volume_name_retn:
 32971 00007714 C3                  <1> 	retn
 32972                              <1>     
 32973                              <1> pass_check_root_volume_name:
 32974 00007715 803D[687F0100]03    <1> 	cmp	byte [DirBuff_FATType], 3
 32975 0000771C 7230                <1> 	jb	short loc_get_volume_name_retn_xor
 32976                              <1> 
 32977 0000771E BB001C0900          <1> 	mov	ebx, FAT_Buffer
 32978 00007723 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 32979 00007728 31C0                <1> 	xor	eax, eax
 32980 0000772A 8A25[677F0100]      <1> 	mov	ah, [DirBuff_DRV]
 32981 00007730 80EC41              <1> 	sub	ah, 'A' 
 32982 00007733 01C6                <1> 	add	esi, eax
 32983 00007735 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 32984 0000773A E84B4A0000          <1> 	call	get_next_cluster
 32985 0000773F 7305                <1> 	jnc 	short loc_gfvn_load_FAT32_dir_cluster
 32986                              <1>   	
 32987 00007741 83F801              <1> 	cmp     eax, 1
 32988 00007744 F5                  <1> 	cmc
 32989 00007745 C3                  <1> 	retn
 32990                              <1>   
 32991                              <1> loc_gfvn_load_FAT32_dir_cluster:
 32992 00007746 E8FB4B0000          <1> 	call	load_FAT_sub_directory
 32993 0000774B 73A5                <1> 	jnc	short loc_get_volume_name
 32994 0000774D C3                  <1> 	retn
 32995                              <1> 
 32996                              <1> loc_get_volume_name_retn_xor:
 32997 0000774E 31C0                <1> 	xor 	eax, eax
 32998 00007750 C3                  <1> 	retn
 32999                              <1> 
 33000                              <1> get_media_change_status:
 33001                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
 33002                              <1> 	; 09/09/2009
 33003                              <1> 	; INPUT:
 33004                              <1> 	;     DL = Drive number (physical)
 33005                              <1> 	; OUTPUT: clc & AH = 6 media changed
 33006                              <1> 	;     clc & AH = 0 media not changed         
 33007                              <1> 	;     stc -> Drive not ready or an error 
 33008                              <1>   
 33009 00007751 B416                <1> 	mov	ah, 16h
 33010 00007753 E8E5D7FFFF          <1>   	call	int13h
 33011 00007758 80FC06              <1> 	cmp	ah, 06h
 33012 0000775B 7405                <1> 	je	short loc_gmc_status_retn
 33013 0000775D 08E4                <1> 	or	ah, ah
 33014 0000775F 7401                <1> 	jz	short loc_gmc_status_retn
 33015                              <1> loc_gmc_status_stc_retn:    
 33016 00007761 F9                  <1> 	stc
 33017                              <1> loc_gmc_status_retn:
 33018 00007762 C3                  <1> 	retn
 33019                                  %include 'trdosk3.s' ; 06/01/2016
 33020                              <1> ; ****************************************************************************
 33021                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - MAIN PROGRAM : trdosk3.s
 33022                              <1> ; ----------------------------------------------------------------------------
 33023                              <1> ; Last Update: 07/08/2022  (Previous: 31/12/2017)
 33024                              <1> ; ----------------------------------------------------------------------------
 33025                              <1> ; Beginning: 06/01/2016
 33026                              <1> ; ----------------------------------------------------------------------------
 33027                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 33028                              <1> ; ----------------------------------------------------------------------------
 33029                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 33030                              <1> ; MAINPROG.ASM (09/11/2011)
 33031                              <1> ; ****************************************************************************
 33032                              <1> ; MAINPROG.ASM [ TRDOS KERNEL - COMMAND EXECUTER SECTION - MAIN PROGRAM ]
 33033                              <1> ; (c) 2004-2011  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/11/2011
 33034                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ] Last Update: 09/11/2011
 33035                              <1> ; DIR.ASM [ DIRECTORY FUNCTIONS ] Last Update: 09/10/2011
 33036                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
 33037                              <1> 
 33038                              <1> change_current_drive:
 33039                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33040                              <1> 	; 16/10/2016
 33041                              <1> 	; 02/02/2016
 33042                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
 33043                              <1> 	; 18/08/2011
 33044                              <1> 	; 09/09/2009
 33045                              <1> 	; INPUT:
 33046                              <1> 	;   DL = Logical DOS Drive Number
 33047                              <1> 	; OUTPUT:
 33048                              <1> 	;  cf=1 -> Not successful
 33049                              <1> 	;   EAX = Error code
 33050                              <1> 	;  cf=0 ->
 33051                              <1> 	;   EAX = 0 (successful)
 33052                              <1> 
 33053 00007763 31DB                <1> 	xor	ebx, ebx
 33054 00007765 88D7                <1> 	mov	bh, dl
 33055                              <1> 
 33056                              <1> 	;cmp	dl, 1
 33057                              <1> 	;jna	short loc_ccdrv_initial_media_change_check
 33058                              <1> 	;cmp	bh, [Last_Dos_DiskNo]
 33059                              <1> 	;ja	short loc_ccdrv_drive_not_ready_err
 33060                              <1> 
 33061                              <1> loc_ccdrv_initial_media_change_check:
 33062 00007767 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 33063 0000776C 01DE                <1> 	add	esi, ebx
 33064                              <1> loc_ccdrv_dos_drive_name_check:
 33065 0000776E 80FA02              <1> 	cmp	dl, 2
 33066 00007771 720E                <1> 	jb	short loc_ccdrv_dos_drive_name_check_ok
 33067                              <1> 
 33068 00007773 8A06                <1> 	mov	al, [esi+LD_Name]
 33069 00007775 2C41                <1> 	sub	al, 'A'
 33070 00007777 38D0                <1> 	cmp	al, dl
 33071 00007779 7406                <1> 	je	short loc_ccdrv_dos_drive_name_check_ok
 33072                              <1> 
 33073                              <1> loc_ccdrv_drive_not_ready_err:
 33074                              <1> 	; 16/10/2016 (15h -> 15)
 33075                              <1> 	;mov	eax, 15 ; Drive not ready
 33076                              <1> 	; 26/07/2022
 33077 0000777B 29C0                <1> 	sub	eax, eax
 33078 0000777D B00F                <1> 	mov	al, 15
 33079                              <1> loc_change_current_drive_stc_retn:
 33080 0000777F F9                  <1> 	stc
 33081 00007780 C3                  <1> 	retn  
 33082                              <1> 
 33083                              <1> loc_ccdrv_dos_drive_name_check_ok:
 33084 00007781 8A667E              <1> 	mov	ah, [esi+LD_MediaChanged]
 33085 00007784 80FC06              <1> 	cmp	ah, 6  ; VOLUME NAME CHECK/MOVE SIGN
 33086 00007787 7455                <1> 	je	short loc_ccdrv_get_FAT_volume_name_0
 33087                              <1> 
 33088 00007789 80FA01              <1> 	cmp	dl, 1
 33089 0000778C 777D                <1> 	ja	short loc_gmcs_init_drv_hd
 33090                              <1> 
 33091                              <1> loc_gmcs_init_drv_fd:
 33092 0000778E 08E4                <1> 	or	ah, ah 
 33093                              <1> 	; AH = 1 is initialization sign (invalid_fd_parameter)
 33094 00007790 7517                <1> 	jnz	short loc_ccdrv_call_fd_init
 33095                              <1> 
 33096 00007792 E8BAFFFFFF          <1> 	call	get_media_change_status
 33097 00007797 72E2                <1> 	jc	short loc_ccdrv_drive_not_ready_err
 33098                              <1> 
 33099 00007799 20E4                <1> 	and	ah, ah
 33100 0000779B 7476                <1> 	jz	short loc_change_current_drv3
 33101                              <1> 
 33102 0000779D 80F406              <1> 	xor	ah, 6
 33103 000077A0 75D9                <1> 	jnz	short loc_ccdrv_drive_not_ready_err
 33104                              <1> 
 33105                              <1> loc_ccdrv_call_fd_init_check_vol_id:
 33106 000077A2 E86D090000          <1> 	call	get_volume_serial_number
 33107 000077A7 730D                <1> 	jnc	short loc_ccdrv_check_vol_serial
 33108                              <1> 
 33109                              <1> loc_ccdrv_call_fd_init:
 33110 000077A9 E886FCFFFF          <1> 	call	floppy_drv_init
 33111 000077AE 731A                <1> 	jnc	short loc_reset_drv_fd_current_dir
 33112                              <1> 
 33113                              <1> loc_ccdrv_fdinit_fail_retn:
 33114                              <1> 	; 16/10/2016
 33115 000077B0 B80F000000          <1> 	mov	eax, 15 ; Drive not ready
 33116 000077B5 C3                  <1> 	retn
 33117                              <1> 
 33118                              <1> loc_ccdrv_check_vol_serial:
 33119 000077B6 A3[38780100]        <1> 	mov	[Current_VolSerial], eax
 33120                              <1> 	;mov	dl, bh
 33121 000077BB E874FCFFFF          <1> 	call	floppy_drv_init
 33122 000077C0 72EE                <1> 	jc	short loc_ccdrv_fdinit_fail_retn
 33123                              <1> 
 33124 000077C2 3B05[38780100]      <1> 	cmp	eax, [Current_VolSerial]
 33125 000077C8 7445                <1> 	je	short loc_change_current_drv2
 33126                              <1> 
 33127                              <1> loc_reset_drv_fd_current_dir:
 33128 000077CA 31C0                <1> 	xor	eax, eax              
 33129 000077CC 88467F              <1>         mov	[esi+LD_CDirLevel], al
 33130 000077CF 89F7                <1> 	mov	edi, esi
 33131 000077D1 81C780000000        <1> 	add	edi, LD_CurrentDirectory
 33132 000077D7 B920000000          <1> 	mov	ecx, 32
 33133 000077DC F3AB                <1> 	rep	stosd   
 33134                              <1>  
 33135                              <1> loc_ccdrv_get_FAT_volume_name_0:
 33136 000077DE 8A4603              <1> 	mov	al, [esi+LD_FATType]
 33137 000077E1 08C0                <1> 	or	al, al
 33138 000077E3 742A                <1> 	jz	short loc_change_current_drv2
 33139                              <1> 
 33140 000077E5 56                  <1> 	push	esi 
 33141 000077E6 3C02                <1> 	cmp	al, 2
 33142 000077E8 7705                <1> 	ja	short loc_ccdrv_get_FAT32_vol_name
 33143                              <1>              
 33144                              <1> loc_ccdrv_get_FAT2_16_vol_name:
 33145 000077EA 83C631              <1> 	add	esi, LD_BPB + VolumeLabel
 33146 000077ED EB03                <1> 	jmp	short loc_ccdrv_get_FAT_volume_name_1
 33147                              <1> 
 33148                              <1> loc_ccdrv_get_FAT32_vol_name:
 33149 000077EF 83C64D              <1> 	add	esi, LD_BPB + FAT32_VolLab
 33150                              <1> loc_ccdrv_get_FAT_volume_name_1:
 33151 000077F2 53                  <1> 	push	ebx
 33152 000077F3 56                  <1> 	push	esi
 33153 000077F4 E8C6FEFFFF          <1> 	call	get_FAT_volume_name
 33154 000077F9 5F                  <1> 	pop	edi
 33155 000077FA 5B                  <1> 	pop	ebx
 33156                              <1> 	; BL = 0
 33157 000077FB 720B                <1> 	jc	short loc_change_current_drv1
 33158 000077FD 20C0                <1> 	and	al, al
 33159 000077FF 7407                <1> 	jz	short loc_change_current_drv1
 33160                              <1> 
 33161                              <1> loc_ccdrv_move_FAT_volume_name:
 33162 00007801 B90B000000          <1> 	mov	ecx, 11
 33163 00007806 F3A4                <1> 	rep	movsb
 33164                              <1> 
 33165                              <1> loc_change_current_drv1:
 33166 00007808 5E                  <1> 	pop	esi
 33167 00007809 EB04                <1> 	jmp	short loc_change_current_drv2
 33168                              <1> 
 33169                              <1> loc_gmcs_init_drv_hd:
 33170 0000780B 08E4                <1> 	or	ah, ah
 33171 0000780D 7404                <1> 	jz	short loc_change_current_drv3
 33172                              <1> 	; BL = 0, BH = Logical DOS drive number
 33173                              <1> loc_change_current_drv2:
 33174 0000780F C6467E00            <1> 	mov	byte [esi+LD_MediaChanged], 0
 33175                              <1> loc_change_current_drv3:
 33176 00007813 883D[42780100]      <1> 	mov	[Current_Drv], bh
 33177                              <1> 
 33178                              <1> 	;call	restore_current_directory
 33179                              <1> 	;retn
 33180                              <1> 
 33181                              <1> restore_current_directory:
 33182                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33183                              <1> 	; 11/02/2016
 33184                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
 33185                              <1> 	; 25/01/2010
 33186                              <1> 	; 12/10/2009
 33187                              <1> 	;
 33188                              <1> 	; INPUT:
 33189                              <1> 	;   ESI = Logical DOS Drive Description Table
 33190                              <1> 	;
 33191                              <1> 	; OUTPUT:
 33192                              <1> 	;   ESI = Logical DOS Drive Description Table
 33193                              <1> 	;   EDI = offset Current_Dir_Drv 
 33194                              <1> 
 33195 00007819 8A4603              <1> 	mov	al, [esi+LD_FATType]
 33196 0000781C A2[41780100]        <1> 	mov	[Current_FATType], al
 33197                              <1> 
 33198 00007821 8A26                <1> 	mov	ah, [esi+LD_Name] 
 33199 00007823 8825[43780100]      <1> 	mov	[Current_Dir_Drv], ah
 33200                              <1> 
 33201 00007829 20C0                <1> 	and	al, al
 33202 0000782B 741D                <1> 	jz	short loc_restore_FS_current_directory
 33203                              <1> 
 33204                              <1> loc_restore_FAT_current_directory:
 33205 0000782D 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
 33206 00007830 8825[40780100]      <1> 	mov	[Current_Dir_Level], ah
 33207 00007836 08E4                <1> 	or	ah, ah
 33208 00007838 7415                <1>         jz	short loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster
 33209                              <1> 
 33210 0000783A 0FB6D4              <1> 	movzx	edx, ah
 33211 0000783D C0E204              <1> 	shl	dl, 4 ; * 16
 33212 00007840 01F2                <1>         add	edx, esi
 33213 00007842 8B828C000000        <1> 	mov	eax, [edx+LD_CurrentDirectory+12]
 33214 00007848 EB29                <1> 	jmp	short loc_ccdrv_reset_cdir_FAT_fcluster
 33215                              <1> 
 33216                              <1> loc_restore_FS_current_directory:
 33217                              <1> 	;call	load_current_FS_directory
 33218                              <1> 	;retn
 33219                              <1> 	; 26/07/2022
 33220 0000784A E9314B0000          <1> 	jmp	load_current_FS_directory
 33221                              <1> 
 33222                              <1> loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster:
 33223 0000784F 3C03                <1> 	cmp	al, 3
 33224 00007851 7205                <1> 	jb	short loc_ccdrv_reset_cdir_FAT_12_16_fcluster
 33225                              <1> loc_ccdrv_reset_cdir_FAT32_fcluster:
 33226 00007853 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
 33227 00007856 EB02                <1> 	jmp	short loc_ccdrv_check_rootdir_sign
 33228                              <1> loc_ccdrv_reset_cdir_FAT_12_16_fcluster:   
 33229                              <1> 	;xor	al, al  ; xor eax, eax
 33230                              <1> 	; 26/07/2022
 33231 00007858 31C0                <1> 	xor	eax, eax
 33232                              <1> 	;xor	edx, edx
 33233                              <1> loc_ccdrv_check_rootdir_sign:
 33234 0000785A 80BE8000000000      <1> 	cmp	byte [esi+LD_CurrentDirectory], 0
 33235 00007861 7510                <1> 	jne	short loc_ccdrv_reset_cdir_FAT_fcluster
 33236                              <1> loc_ccdrv_set_rootdir_FAT_fcluster:
 33237 00007863 89868C000000        <1>         mov     [esi+LD_CurrentDirectory+12], eax
 33238 00007869 C78680000000524F4F- <1> 	mov	dword [esi+LD_CurrentDirectory], 'ROOT'
 33239 00007872 54                  <1>
 33240                              <1> 
 33241                              <1> loc_ccdrv_reset_cdir_FAT_fcluster:
 33242 00007873 A3[3C780100]        <1> 	mov	[Current_Dir_FCluster], eax
 33243                              <1> 
 33244 00007878 BF[A07F0100]        <1> 	mov	edi, PATH_Array
 33245 0000787D 89F2                <1> 	mov	edx, esi
 33246 0000787F 81C680000000        <1> 	add	esi, LD_CurrentDirectory
 33247 00007885 B920000000          <1> 	mov	ecx, 32
 33248 0000788A F3A5                <1> 	rep	movsd
 33249                              <1> 
 33250 0000788C E87E2B0000          <1> 	call	change_prompt_dir_string
 33251                              <1> 	
 33252 00007891 89D6                <1> 	mov	esi, edx
 33253                              <1> 	
 33254 00007893 29C0                <1>         sub	eax, eax
 33255                              <1>        ;sub	edx, edx
 33256 00007895 BF[43780100]        <1> 	mov	edi, Current_Dir_Drv
 33257                              <1> 
 33258 0000789A A2[68300100]        <1> 	mov	[Restore_CDIR], al ; 0
 33259 0000789F C3                  <1> 	retn
 33260                              <1> 
 33261                              <1> dos_prompt:
 33262                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33263                              <1> 	; 06/05/2016
 33264                              <1> 	; 30/01/2016
 33265                              <1> 	; 29/01/2016
 33266                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
 33267                              <1> 	; 15/09/2011
 33268                              <1> 	; 13/09/2009
 33269                              <1> 	; 2004-2005
 33270                              <1> 
 33271                              <1> 	; 06/05/2016
 33272 000078A0 C705[FC830100]-     <1> 	mov	dword [mainprog_return_addr], return_from_cmd_interpreter
 33273 000078A6 [52790000]          <1>
 33274                              <1> 
 33275                              <1> loc_TRDOS_prompt:
 33276 000078AA BF[42790100]        <1> 	mov	edi, TextBuffer
 33277 000078AF C6075B              <1> 	mov	byte [edi], "["
 33278 000078B2 47                  <1> 	inc	edi
 33279 000078B3 BE[C3300100]        <1> 	mov	esi, TRDOSPromptLabel
 33280                              <1> get_next_prompt_label_char:
 33281 000078B8 803E20              <1> 	cmp	byte [esi], 20h
 33282 000078BB 7203                <1> 	jb	short pass_prompt_label
 33283 000078BD A4                  <1> 	movsb
 33284 000078BE EBF8                <1> 	jmp	short get_next_prompt_label_char
 33285                              <1> pass_prompt_label:
 33286 000078C0 C6075D              <1> 	mov	byte [edi], "]"
 33287 000078C3 47                  <1> 	inc	edi
 33288 000078C4 C60720              <1> 	mov	byte [edi], 20h
 33289 000078C7 47                  <1> 	inc	edi
 33290 000078C8 BE[43780100]        <1> 	mov	esi, Current_Dir_Drv
 33291 000078CD 66A5                <1> 	movsw
 33292 000078CF A4                  <1> 	movsb 
 33293                              <1> loc_prompt_current_directory:
 33294 000078D0 803E20              <1> 	cmp	byte [esi], 20h
 33295 000078D3 7203                <1> 	jb	short pass_prompt_current_directory
 33296 000078D5 A4                  <1> 	movsb
 33297 000078D6 EBF8                <1> 	jmp	short loc_prompt_current_directory  
 33298                              <1> pass_prompt_current_directory:
 33299 000078D8 C6073E              <1> 	mov	byte [edi], '>'
 33300 000078DB 47                  <1> 	inc	edi
 33301 000078DC C60700              <1> 	mov	byte [edi], 0  
 33302 000078DF BE[42790100]        <1> 	mov	esi, TextBuffer
 33303 000078E4 E841F3FFFF          <1> 	call	print_msg
 33304                              <1>         
 33305                              <1> 	;sub	bh, bh ; video page = 0
 33306                              <1> 	;call	get_cpos ; get cursor position
 33307 000078E9 668B15[9E770100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
 33308 000078F0 8815[A2780100]      <1> 	mov	[CursorColumn], dl
 33309                              <1> 
 33310                              <1> 	; 30/01/2016 (to show cursor on the row, again)
 33311                              <1> 	; (Initial color attributes of video page 0 is 0)
 33312                              <1> 	; (see: 'StartPMP' in trdos386.s)
 33313                              <1> 	; 
 33314                              <1> 	;mov	edi, 0B8000h ; start of video page 0
 33315                              <1> 	;movzx	ecx, dl ; column	 
 33316                              <1> 	;mov	al, 80
 33317                              <1> 	;mul	dh
 33318                              <1> 	;add	ax, cx
 33319                              <1> 	;shl	ax, 1 ; character + attribute
 33320                              <1> 	;add	di, ax ; (2*80*row) + (2*column)
 33321                              <1> 	;neg	cl
 33322                              <1> 	;add	cl, 80
 33323                              <1> 	;mov	ax, 700h ;  ah = 7 (color attribute)
 33324                              <1> 	;rep	stosw	
 33325                              <1> 
 33326                              <1> loc_rw_char:
 33327 000078F6 E8AB000000          <1> 	call	rw_char
 33328                              <1> loc_move_command:
 33329 000078FB BE[F2780100]        <1> 	mov	esi, CommandBuffer
 33330 00007900 89F7                <1> 	mov	edi, esi
 33331 00007902 31C9                <1> 	xor	ecx, ecx
 33332                              <1> first_command_char:
 33333 00007904 AC                  <1> 	lodsb
 33334 00007905 3C20                <1> 	cmp	al, 20h
 33335 00007907 770C                <1> 	ja	short pass_space_control
 33336 00007909 723F                <1> 	jb	short loc_move_cmd_arguments_ok
 33337 0000790B 81FE[41790100]      <1> 	cmp	esi, CommandBuffer + 79
 33338 00007911 72F1                <1> 	jb	short first_command_char
 33339 00007913 EB35                <1> 	jmp	short loc_move_cmd_arguments_ok
 33340                              <1> 
 33341                              <1> 	; 26/07/2022
 33342                              <1> pass_space_control:
 33343 00007915 3C61                <1> 	cmp	al, 61h
 33344 00007917 7206                <1> 	jb	short pass_capitalize
 33345 00007919 3C7A                <1> 	cmp	al, 7Ah
 33346 0000791B 7702                <1> 	ja	short pass_capitalize
 33347 0000791D 24DF                <1> 	and	al, 0DFh
 33348                              <1> pass_capitalize:
 33349 0000791F AA                  <1> 	stosb   
 33350 00007920 FEC1                <1> 	inc     cl
 33351 00007922 81FE[41790100]      <1> 	cmp     esi, CommandBuffer + 79
 33352                              <1> 	;jb	short next_command_char
 33353                              <1> 	; 26/07/2022
 33354 00007928 7320                <1> 	jnb	short loc_move_cmd_arguments_ok
 33355                              <1> 
 33356                              <1> next_command_char:
 33357 0000792A AC                  <1> 	lodsb
 33358 0000792B 3C20                <1> 	cmp	al, 20h
 33359 0000792D 77E6                <1> 	ja	short pass_space_control
 33360 0000792F 7219                <1> 	jb	short loc_move_cmd_arguments_ok
 33361                              <1> 
 33362                              <1> loc_1st_cmd_arg: ; 30/01/2016
 33363 00007931 AC                  <1> 	lodsb
 33364 00007932 3C20                <1> 	cmp	al, 20h
 33365 00007934 74FB                <1> 	je	short loc_1st_cmd_arg
 33366 00007936 7212                <1> 	jb	short loc_move_cmd_arguments_ok
 33367                              <1> 	
 33368 00007938 C60700              <1>         mov     byte [edi], 0
 33369 0000793B 47                  <1> 	inc	edi
 33370                              <1> 
 33371                              <1> loc_move_cmd_arguments:
 33372 0000793C AA                  <1> 	stosb
 33373 0000793D 81FE[41790100]      <1> 	cmp	esi, CommandBuffer + 79
 33374 00007943 7305                <1> 	jnb	short loc_move_cmd_arguments_ok
 33375 00007945 AC                  <1>         lodsb
 33376 00007946 3C20                <1> 	cmp	al, 20h
 33377 00007948 73F2                <1> 	jnb	short loc_move_cmd_arguments
 33378                              <1> 	; 26/07/2022
 33379                              <1> 	;jmp	short loc_move_cmd_arguments_ok
 33380                              <1> 
 33381                              <1> ; 26/07/2022
 33382                              <1> ;pass_space_control:
 33383                              <1> ;	cmp	al, 61h
 33384                              <1> ;	jb	short pass_capitalize
 33385                              <1> ;	cmp	al, 7Ah
 33386                              <1> ;	ja	short pass_capitalize
 33387                              <1> ;	and	al, 0DFh
 33388                              <1> ;pass_capitalize:
 33389                              <1> ;	stosb   
 33390                              <1> ;	inc     cl
 33391                              <1> ;	cmp     esi, CommandBuffer + 79
 33392                              <1> ;	jb      short next_command_char 
 33393                              <1> 
 33394                              <1> loc_move_cmd_arguments_ok:
 33395 0000794A C60700              <1>         mov     byte [edi], 0
 33396                              <1> 
 33397                              <1> call_command_interpreter:
 33398 0000794D E8FD070000          <1> 	call    command_interpreter
 33399                              <1> 
 33400                              <1> return_from_cmd_interpreter:
 33401 00007952 B950000000          <1>         mov	ecx, 80
 33402                              <1> 	;mov	cx, 80
 33403 00007957 BF[F2780100]        <1> 	mov	edi, CommandBuffer
 33404 0000795C 30C0                <1> 	xor	al, al
 33405 0000795E F3AA                <1> 	rep	stosb
 33406                              <1> 	;cmp	byte [Program_Exit], 0
 33407                              <1> 	;ja	short loc_terminate_trdos
 33408                              <1>         
 33409                              <1> 	; 16/01/2016
 33410 00007960 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80*25 color
 33411 00007967 7419                <1> 	je	short pass_set_txt_mode
 33412                              <1> 
 33413 00007969 E85CA1FFFF          <1> 	call	set_txt_mode ; set vide mode to 03h
 33414                              <1> 	; 07/01/2017
 33415 0000796E 30C0                <1> 	xor	al, al
 33416                              <1> 
 33417                              <1> loc_check_active_page:
 33418                              <1> 	;xor	al, al
 33419 00007970 3805[AE770100]      <1> 	cmp	[ACTIVE_PAGE], al ; 0
 33420                              <1>         ;je	loc_TRDOS_prompt
 33421                              <1> 	; 26/07/2022
 33422 00007976 7405                <1> 	je	short loc_prompt_again
 33423                              <1> 
 33424                              <1> 	; AL = 0 = video page 0
 33425 00007978 E875A5FFFF          <1> 	call	set_active_page
 33426                              <1> loc_prompt_again: ; 26/07/2022		
 33427 0000797D E928FFFFFF          <1>         jmp     loc_TRDOS_prompt ; infinitive loop
 33428                              <1> 
 33429                              <1> pass_set_txt_mode: 
 33430 00007982 BE[0F3B0100]        <1> 	mov	esi, nextline
 33431 00007987 E89EF2FFFF          <1> 	call	print_msg
 33432 0000798C EBE2                <1> 	jmp     short loc_check_active_page
 33433                              <1> 
 33434                              <1> ;rw_char:
 33435                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33436                              <1> loc_arrow:    
 33437 0000798E 80FC4B              <1> 	cmp	ah, 4Bh
 33438 00007991 7426                <1> 	je	short loc_back
 33439 00007993 80FC53              <1> 	cmp	ah, 53h
 33440 00007996 7421                <1> 	je      short loc_back
 33441 00007998 80FC4D              <1> 	cmp	ah, 4Dh
 33442 0000799B 7509                <1> 	jne	short readnextchar
 33443 0000799D 80FA4F              <1> 	cmp	dl, 79
 33444 000079A0 7304                <1> 	jnb	short readnextchar
 33445 000079A2 FEC2                <1> 	inc	dl
 33446 000079A4 EB1D                <1> 	jmp	short set_cursor_pos
 33447                              <1> 
 33448                              <1> rw_char: 
 33449                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33450                              <1> 	; 13/05/2016
 33451                              <1> 	; 30/01/2016
 33452                              <1> 	; 29/01/2016
 33453                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
 33454                              <1> 	; 2004-2005
 33455                              <1> 	
 33456                              <1> 	; DH = cursor row, DL = cursor column
 33457                              <1> 	; BH = 0 = video page number (active page)
 33458                              <1> 
 33459                              <1> 	;xor	bh, bh ; 0 = video page 0
 33460                              <1> 
 33461                              <1> readnextchar:
 33462 000079A6 30E4                <1> 	xor     ah, ah
 33463 000079A8 E82195FFFF          <1> 	call	int16h
 33464 000079AD 20C0                <1> 	and	al, al
 33465 000079AF 74DD                <1> 	jz	short loc_arrow    
 33466 000079B1 3CE0                <1> 	cmp	al, 0E0h          
 33467 000079B3 74D9                <1> 	je	short loc_arrow
 33468 000079B5 3C08                <1> 	cmp	al, 08h             
 33469 000079B7 752A                <1> 	jne	short char_return
 33470                              <1> loc_back:
 33471 000079B9 3A15[A2780100]      <1> 	cmp	dl, [CursorColumn]
 33472 000079BF 76E5                <1> 	jna     short readnextchar
 33473                              <1> prev_column:
 33474 000079C1 FECA                <1> 	dec	dl
 33475                              <1> set_cursor_pos:
 33476                              <1> 	;push	dx
 33477 000079C3 52                  <1> 	push	edx ; 29/12/2017
 33478                              <1> 	;xor	bh, bh ; 0 = video page 0
 33479                              <1> 	; DH = Row, DL = Column
 33480 000079C4 E8EDA8FFFF          <1> 	call	_set_cpos ; 17/01/2016
 33481 000079C9 5A                  <1>         pop	edx ; 29/12/2017
 33482                              <1> 	;pop	dx
 33483                              <1> 	;movzx	ebx, dl
 33484 000079CA 88D3                <1> 	mov	bl, dl
 33485 000079CC 2A1D[A2780100]      <1> 	sub	bl, [CursorColumn] 
 33486 000079D2 B020                <1> 	mov	al, 20h
 33487 000079D4 8883[F2780100]      <1> 	mov	[CommandBuffer+ebx], al
 33488                              <1> 	;sub	bh, bh ; video page 0
 33489                              <1> 	;mov	cx, 1
 33490 000079DA B307                <1> 	mov	bl, 7 ; color attribute
 33491                              <1> 	; bh = 0 ; 26/07/2022
 33492 000079DC E8BCA7FFFF          <1> 	call	_write_c_current ; 17/01/2016
 33493                              <1> 	;mov	dx, [CURSOR_POSN]
 33494 000079E1 EBC3                <1> 	jmp	short readnextchar
 33495                              <1> 
 33496                              <1> 	; 26/07/2022
 33497                              <1> ;loc_arrow:    
 33498                              <1> ;	cmp	ah, 4Bh
 33499                              <1> ;	je	short loc_back
 33500                              <1> ;	cmp	ah, 53h
 33501                              <1> ;	je      short loc_back
 33502                              <1> ;	cmp	ah, 4Dh
 33503                              <1> ;	jne	short readnextchar
 33504                              <1> ;	cmp	dl, 79
 33505                              <1> ;	jnb	short readnextchar
 33506                              <1> ;	inc	dl
 33507                              <1> ;	jmp	short set_cursor_pos
 33508                              <1> 
 33509                              <1> char_return:
 33510 000079E3 0FB6DA              <1> 	movzx	ebx, dl
 33511 000079E6 2A1D[A2780100]      <1> 	sub	bl, [CursorColumn] 
 33512 000079EC 3C20                <1> 	cmp	al, 20h
 33513 000079EE 721D                <1> 	jb	short loc_escape
 33514 000079F0 8883[F2780100]      <1> 	mov	[CommandBuffer+ebx], al
 33515 000079F6 80FA4F              <1> 	cmp	dl, 79
 33516 000079F9 73AB                <1> 	jnb	short readnextchar
 33517 000079FB 66BB0700            <1> 	mov	bx, 7 ; color attribute
 33518 000079FF E81AA8FFFF          <1> 	call	_write_tty
 33519 00007A04 668B15[9E770100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
 33520 00007A0B EB99                <1>         jmp	short readnextchar ; 26/07/2022
 33521                              <1> 
 33522                              <1> loc_escape:
 33523 00007A0D 3C1B                <1> 	cmp	al, 1Bh
 33524 00007A0F 7414                <1> 	je	short rw_char_retn
 33525                              <1> 	;
 33526 00007A11 3C0D                <1> 	cmp	al, 0Dh ; CR
 33527 00007A13 7591                <1>         jne	short readnextchar ; 26/07/2022
 33528                              <1> 
 33529                              <1> 	; 13/05/2016
 33530 00007A15 66BB0700            <1> 	mov	bx, 7 ; attribute/color (bl)
 33531                              <1> 		      ; video page 0 (bh=0)	
 33532 00007A19 E800A8FFFF          <1> 	call	_write_tty
 33533                              <1> 	;mov	bx, 7  ; attribute/color
 33534                              <1> 		      ; video page 0 (bh=0)
 33535 00007A1E B00A                <1> 	mov	al, 0Ah ; LF
 33536 00007A20 E8F9A7FFFF          <1> 	call	_write_tty
 33537                              <1> rw_char_retn:
 33538 00007A25 C3                  <1> 	retn
 33539                              <1> 
 33540                              <1> show_date:
 33541                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33542                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 33543                              <1>         ; 2004-2005
 33544                              <1> 
 33545                              <1> 	;mov	ah, 04h
 33546                              <1> 	;call	int1Ah
 33547 00007A26 E80DE8FFFF          <1> 	call	RTC_40	; GET RTC DATE
 33548                              <1> 
 33549 00007A2B 88D0                <1> 	mov	al, dl
 33550 00007A2D E88F94FFFF          <1>   	call	bcd_to_ascii
 33551 00007A32 66A3[AF310100]      <1> 	mov	[Day], ax
 33552                              <1> 
 33553 00007A38 88F0                <1> 	mov	al, dh
 33554 00007A3A E88294FFFF          <1>   	call	bcd_to_ascii
 33555 00007A3F 66A3[B2310100]      <1> 	mov	[Month], ax
 33556                              <1> 
 33557 00007A45 88E8                <1> 	mov	al, ch
 33558 00007A47 E87594FFFF          <1>   	call	bcd_to_ascii
 33559 00007A4C 66A3[B5310100]      <1> 	mov	[Century], ax
 33560                              <1> 
 33561 00007A52 88C8                <1> 	mov	al, cl
 33562 00007A54 E86894FFFF          <1>   	call	bcd_to_ascii
 33563 00007A59 66A3[B7310100]      <1> 	mov	[Year], ax
 33564                              <1> 
 33565 00007A5F BE[9F310100]        <1> 	mov	esi, Msg_Show_Date
 33566                              <1> 	;call	print_msg
 33567                              <1> 	;retn
 33568                              <1> 	; 26/07/2022
 33569 00007A64 E9C1F1FFFF          <1> 	jmp	print_msg
 33570                              <1> 
 33571                              <1> set_date:
 33572                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33573                              <1> 	; 13/05/2016
 33574                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 33575                              <1>         ; 2004-2005
 33576                              <1> 
 33577 00007A69 BE[83310100]        <1> 	mov	esi, Msg_Enter_Date
 33578 00007A6E E8B7F1FFFF          <1> 	call	print_msg
 33579                              <1> 
 33580                              <1> loc_enter_day_1:
 33581 00007A73 30E4                <1> 	xor     ah, ah
 33582 00007A75 E85494FFFF          <1> 	call	int16h
 33583                              <1> 	; AL = ASCII Code of the Character
 33584 00007A7A 3C0D                <1> 	cmp	al, 13
 33585                              <1> 	;je	loc_set_date_retn
 33586                              <1> 	; 26/07/2022
 33587 00007A7C 7404                <1> 	je	short set_date_0
 33588 00007A7E 3C1B                <1> 	cmp	al, 27
 33589                              <1> 	;je	loc_set_date_retn
 33590                              <1> 	; 26/07/2022
 33591 00007A80 7511                <1> 	jne	short set_date_1
 33592                              <1> 
 33593                              <1> set_date_0:
 33594                              <1> ;loc_set_date_retn:
 33595 00007A82 BE[0F3B0100]        <1> 	mov	esi, nextline
 33596                              <1> 	;call	print_msg
 33597                              <1> 	;retn
 33598                              <1> 	; 26/07/2022
 33599 00007A87 E99EF1FFFF          <1> 	jmp	print_msg
 33600                              <1> 
 33601                              <1> 	; 26/07/2022
 33602                              <1> loc_set_date_stc_0:
 33603                              <1> 	;xor	bh, bh ; video page 0
 33604 00007A8C E877A8FFFF          <1> 	call	beeper ; BEEP !
 33605 00007A91 EBE0                <1> 	jmp	short loc_enter_day_1
 33606                              <1> 
 33607                              <1> 	; 26/07/2022
 33608                              <1> set_date_1:
 33609 00007A93 A2[AF310100]        <1> 	mov	[Day], al
 33610 00007A98 3C30                <1> 	cmp	al, '0'
 33611 00007A9A 72F0                <1> 	jb	short loc_set_date_stc_0
 33612 00007A9C 3C33                <1> 	cmp	al, '3'
 33613 00007A9E 77EC                <1> 	ja	short loc_set_date_stc_0
 33614                              <1> 	; 13/05/2016
 33615                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33616                              <1> 		      ; video page 0 (bh)	
 33617 00007AA0 B307                <1> 	mov	bl, 7
 33618 00007AA2 E877A7FFFF          <1> 	call	_write_tty
 33619                              <1> loc_enter_day_2:
 33620 00007AA7 30E4                <1> 	xor     ah, ah
 33621 00007AA9 E82094FFFF          <1> 	call	int16h
 33622                              <1> 	; AL = ASCII Code of the Character
 33623 00007AAE 3C1B                <1> 	cmp	al, 27
 33624                              <1>         ;je	loc_set_date_retn
 33625                              <1> 	; 26/07/2022
 33626 00007AB0 74D0                <1> 	je	short set_date_0
 33627 00007AB2 A2[B0310100]        <1> 	mov	[Day+1], al
 33628 00007AB7 3C30                <1> 	cmp	al, '0'
 33629 00007AB9 7211                <1>         jb      short loc_set_date_stc_1
 33630 00007ABB 3C39                <1> 	cmp	al, '9'
 33631 00007ABD 770D                <1>         ja      short loc_set_date_stc_1
 33632 00007ABF 803D[AF310100]33    <1> 	cmp	byte [Day], '3'
 33633 00007AC6 7219                <1> 	jb	short pass_set_day_31
 33634 00007AC8 3C31                <1> 	cmp	al, '1'
 33635                              <1>         ;ja	loc_set_date_stc_1
 33636                              <1> 	; 26/07/2022
 33637 00007ACA 7615                <1> 	jna	short pass_set_day_31
 33638                              <1> 
 33639                              <1> 	; 26/07/2022
 33640                              <1> loc_set_date_stc_1:
 33641 00007ACC E8E4010000          <1> 	call	check_for_backspace
 33642 00007AD1 7407                <1> 	je	short loc_set_date_bs_1
 33643                              <1> 	;xor	bh, bh ; video page 0
 33644 00007AD3 E830A8FFFF          <1> 	call	beeper ; BEEP !
 33645 00007AD8 EBCD                <1> 	jmp	short loc_enter_day_2
 33646                              <1> loc_set_date_bs_1:
 33647 00007ADA E8C4010000          <1> 	call	write_backspace
 33648 00007ADF EB92                <1> 	jmp     short loc_enter_day_1
 33649                              <1> 
 33650                              <1> pass_set_day_31:
 33651                              <1> 	; 13/05/2016
 33652                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33653                              <1> 		      ; video page 0 (bh)	
 33654 00007AE1 B307                <1> 	mov	bl, 7
 33655 00007AE3 E836A7FFFF          <1> 	call	_write_tty
 33656                              <1> loc_enter_separator_1:
 33657 00007AE8 28E4                <1> 	sub     ah, ah ; 0
 33658 00007AEA E8DF93FFFF          <1> 	call	int16h
 33659                              <1> 	; AL = ASCII Code of the Character
 33660 00007AEF 3C1B                <1> 	cmp	al, 27
 33661                              <1>         ;je	loc_set_date_retn
 33662                              <1> 	; 26/07/2022
 33663 00007AF1 748F                <1> 	je	short set_date_0
 33664 00007AF3 3C2D                <1> 	cmp	al, '-'
 33665 00007AF5 7443                <1> 	je	short pass_set_date_separator_1
 33666 00007AF7 3C2F                <1> 	cmp	al, '/'
 33667                              <1> 	;jne	loc_set_date_stc_2
 33668                              <1> 	; 26/07/2022
 33669 00007AF9 743F                <1> 	je	short pass_set_date_separator_1
 33670                              <1> 
 33671                              <1> 	; 26/07/2022
 33672                              <1> loc_set_date_stc_2:
 33673 00007AFB E8B5010000          <1> 	call	check_for_backspace
 33674 00007B00 7407                <1> 	je	short loc_set_date_bs_2
 33675                              <1> 	;xor	bh, bh ; video page 0
 33676 00007B02 E801A8FFFF          <1> 	call	beeper ; BEEP !
 33677 00007B07 EBDF                <1> 	jmp	short loc_enter_separator_1
 33678                              <1> loc_set_date_bs_2:
 33679 00007B09 E895010000          <1> 	call	write_backspace
 33680 00007B0E EB97                <1> 	jmp	short loc_enter_day_2
 33681                              <1> 
 33682                              <1> 	; 26/07/2022
 33683                              <1> loc_set_date_stc_3:
 33684 00007B10 E8A0010000          <1> 	call	check_for_backspace
 33685 00007B15 7407                <1> 	je	short loc_set_date_bs_3
 33686                              <1> 	;xor	bh, bh ; video page 0
 33687 00007B17 E8ECA7FFFF          <1> 	call	beeper ; BEEP !
 33688 00007B1C EB23                <1> 	jmp	short loc_enter_month_1
 33689                              <1> loc_set_date_bs_3:
 33690 00007B1E E880010000          <1> 	call	write_backspace
 33691 00007B23 EBC3                <1> 	jmp	short loc_enter_separator_1
 33692                              <1> 
 33693                              <1> 	; 26/07/2022
 33694                              <1> loc_set_date_stc_4:
 33695 00007B25 E88B010000          <1> 	call	check_for_backspace
 33696 00007B2A 7407                <1> 	je	short loc_set_date_bs_4
 33697                              <1> 	;xor	bh, bh ; video page 0
 33698 00007B2C E8D7A7FFFF          <1> 	call	beeper ; BEEP !
 33699 00007B31 EB2D                <1> 	jmp	short loc_enter_month_2
 33700                              <1> loc_set_date_bs_4:
 33701 00007B33 E86B010000          <1> 	call	write_backspace
 33702 00007B38 EB07                <1> 	jmp	short loc_enter_month_1
 33703                              <1> 	
 33704                              <1> pass_set_date_separator_1:
 33705                              <1> 	; 13/05/2016
 33706                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33707                              <1> 		      ; video page 0 (bh)
 33708 00007B3A B307                <1> 	mov	bl, 7	
 33709 00007B3C E8DDA6FFFF          <1> 	call	_write_tty
 33710                              <1> loc_enter_month_1:
 33711 00007B41 30E4                <1> 	xor     ah, ah ; 0
 33712 00007B43 E88693FFFF          <1> 	call	int16h
 33713                              <1> 	; AL = ASCII Code of the Character
 33714 00007B48 3C1B                <1> 	cmp	al, 27
 33715                              <1>         ;je	loc_set_date_retn
 33716                              <1> 	; 26/07/2022
 33717                              <1> 	;je	short loc_set_date_ok
 33718                              <1> 	; 07/08/2022
 33719 00007B4A 741F                <1> 	je	short jmp_loc_set_date_ok
 33720 00007B4C A2[B2310100]        <1> 	mov	[Month], al
 33721 00007B51 3C30                <1> 	cmp	al, '0'
 33722 00007B53 72BB                <1>         jb      short loc_set_date_stc_3
 33723 00007B55 3C31                <1> 	cmp	al, '1'
 33724 00007B57 77B7                <1>         ja	short loc_set_date_stc_3
 33725                              <1> 	; 13/05/2016
 33726                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33727                              <1> 		      ; video page 0 (bh)	
 33728 00007B59 B307                <1> 	mov	bl, 7
 33729 00007B5B E8BEA6FFFF          <1> 	call	_write_tty
 33730                              <1> loc_enter_month_2:
 33731 00007B60 30E4                <1> 	xor     ah, ah
 33732 00007B62 E86793FFFF          <1> 	call	int16h
 33733                              <1> 	; AL = ASCII Code of the Character
 33734 00007B67 3C1B                <1> 	cmp	al, 27
 33735                              <1>         ;;je	loc_set_date_retn
 33736                              <1> 	; 26/07/2022
 33737                              <1> 	;je	short loc_set_date_ok
 33738                              <1> 	; 07/08/2022
 33739 00007B69 7505                <1> 	jne	short loc_enter_month_3
 33740                              <1> jmp_loc_set_date_ok:	
 33741 00007B6B E996000000          <1> 	jmp	loc_set_date_ok 
 33742                              <1> loc_enter_month_3:
 33743 00007B70 A2[B3310100]        <1> 	mov	[Month+1], al
 33744 00007B75 3C30                <1> 	cmp	al, '0'
 33745 00007B77 72AC                <1>         jb	short loc_set_date_stc_4
 33746 00007B79 3C39                <1> 	cmp	al, '9'
 33747 00007B7B 77A8                <1>         ja	short loc_set_date_stc_4
 33748 00007B7D 803D[B2310100]31    <1> 	cmp	byte [Month], '1'
 33749 00007B84 7204                <1> 	jb	short pass_set_month_12
 33750 00007B86 3C32                <1> 	cmp	al, '2'
 33751 00007B88 779B                <1>         ja	short loc_set_date_stc_4
 33752                              <1> pass_set_month_12:
 33753                              <1> 	; 13/05/2016
 33754                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33755                              <1> 		      ; video page 0 (bh)
 33756 00007B8A B307                <1> 	mov	bl, 7	
 33757 00007B8C E88DA6FFFF          <1> 	call	_write_tty
 33758                              <1> loc_enter_separator_2:
 33759 00007B91 28E4                <1> 	sub     ah, ah
 33760 00007B93 E83693FFFF          <1> 	call	int16h
 33761                              <1> 	; AL = ASCII Code of the Character
 33762 00007B98 3C1B                <1> 	cmp	al, 27
 33763                              <1>         ;je	loc_set_date_retn
 33764                              <1> 	; 26/07/2022
 33765 00007B9A 746A                <1> 	je	short loc_set_date_ok
 33766 00007B9C 3C2D                <1> 	cmp	al, '-'
 33767 00007B9E 7404                <1> 	je	short pass_set_date_separator_2
 33768 00007BA0 3C2F                <1> 	cmp	al, '/'
 33769 00007BA2 756C                <1>         jne	short loc_set_date_stc_5
 33770                              <1> pass_set_date_separator_2:
 33771                              <1> 	; 13/05/2016
 33772                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33773                              <1> 		      ; video page 0 (bh)	
 33774 00007BA4 B307                <1> 	mov	bl, 7
 33775 00007BA6 E873A6FFFF          <1> 	call	_write_tty
 33776                              <1> loc_enter_year_1:
 33777 00007BAB 30E4                <1> 	xor    ah, ah
 33778 00007BAD E81C93FFFF          <1> 	call	int16h
 33779                              <1> 	; AL = ASCII Code of the Character
 33780 00007BB2 3C1B                <1> 	cmp	al, 27
 33781                              <1>         ;je	loc_set_date_retn
 33782                              <1> 	; 26/07/2022
 33783 00007BB4 7450                <1> 	je	short loc_set_date_ok
 33784 00007BB6 A2[B7310100]        <1> 	mov	[Year], al
 33785 00007BBB 3C30                <1> 	cmp	al, '0'
 33786 00007BBD 726C                <1>         jb	short loc_set_date_stc_6
 33787 00007BBF 3C39                <1> 	cmp	al, '9'
 33788 00007BC1 7768                <1>         ja	short loc_set_date_stc_6
 33789                              <1> 	; 13/05/2016
 33790                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33791                              <1> 		      ; video page 0 (bh)
 33792 00007BC3 B307                <1> 	mov	bl, 7	
 33793 00007BC5 E854A6FFFF          <1> 	call	_write_tty
 33794                              <1> loc_enter_year_2:
 33795 00007BCA 30E4                <1> 	xor	ah, ah
 33796 00007BCC E8FD92FFFF          <1> 	call	int16h
 33797                              <1> 	; AL = ASCII Code of the Character
 33798 00007BD1 3C1B                <1> 	cmp	al, 27
 33799                              <1> 	;je	short loc_set_date_retn
 33800                              <1> 	; 26/07/2022
 33801 00007BD3 7431                <1> 	je	short loc_set_date_ok
 33802 00007BD5 A2[B8310100]        <1> 	mov	byte [Year+1], al
 33803 00007BDA 3C30                <1> 	cmp	al, '0'
 33804 00007BDC 7268                <1>         jb 	short loc_set_date_stc_7
 33805 00007BDE 3C39                <1> 	cmp	al, '9'
 33806 00007BE0 7764                <1>         ja	short loc_set_date_stc_7
 33807                              <1> 	; 13/05/2016
 33808                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 33809                              <1> 		      ; video page 0 (bh)
 33810 00007BE2 B307                <1> 	mov	bl, 7	
 33811 00007BE4 E835A6FFFF          <1> 	call	_write_tty
 33812                              <1> loc_set_date_get_lchar_again:
 33813 00007BE9 28E4                <1> 	sub	ah, ah ; 0
 33814 00007BEB E8DE92FFFF          <1> 	call	int16h
 33815                              <1> 	; AL = ASCII Code of the Character
 33816 00007BF0 3C0D                <1> 	cmp	al, 13 ; ENTER key
 33817 00007BF2 746D                <1> 	je	short loc_set_date_progress
 33818 00007BF4 3C1B                <1> 	cmp	al, 27 ; ESC key
 33819                              <1> 	;je	short loc_set_date_retn
 33820                              <1> 	; 26/07/2022
 33821 00007BF6 740E                <1> 	je	short loc_set_date_ok
 33822                              <1> 	;
 33823 00007BF8 E8B8000000          <1> 	call	check_for_backspace
 33824 00007BFD 75EA                <1> 	jne	short loc_set_date_get_lchar_again
 33825                              <1> 
 33826                              <1> loc_set_date_bs_8:
 33827 00007BFF E89F000000          <1> 	call	write_backspace
 33828 00007C04 EBC4                <1> 	jmp	short loc_enter_year_2
 33829                              <1> 
 33830                              <1> loc_set_date_ok:
 33831                              <1> ;loc_set_date_retn:
 33832 00007C06 BE[0F3B0100]        <1> 	mov	esi, nextline
 33833                              <1> 	;call	print_msg
 33834                              <1> 	;retn
 33835                              <1> 	; 26/07/2022
 33836 00007C0B E91AF0FFFF          <1> 	jmp	print_msg
 33837                              <1> 
 33838                              <1> 	; 26/07/2022
 33839                              <1> ;loc_set_date_stc_0:
 33840                              <1> ;	;xor	bh, bh ; video page 0
 33841                              <1> ;	call	beeper ; BEEP !
 33842                              <1> ;	jmp	loc_enter_day_1
 33843                              <1> ;loc_set_date_stc_1:
 33844                              <1> ;	call	check_for_backspace
 33845                              <1> ;	je	short loc_set_date_bs_1
 33846                              <1> ;	;xor	bh, bh ; video page 0
 33847                              <1> ;	call	beeper ; BEEP !
 33848                              <1> ;	jmp	loc_enter_day_2
 33849                              <1> ;loc_set_date_bs_1:
 33850                              <1> ;	call	write_backspace
 33851                              <1> ;	jmp     loc_enter_day_1
 33852                              <1> ;loc_set_date_stc_2:
 33853                              <1> ;	call	check_for_backspace
 33854                              <1> ;	je	short loc_set_date_bs_2
 33855                              <1> ;	;xor	bh, bh ; video page 0
 33856                              <1> ;	call	beeper ; BEEP !
 33857                              <1> ;	jmp	loc_enter_separator_1
 33858                              <1> ;loc_set_date_bs_2:
 33859                              <1> ;	call	write_backspace
 33860                              <1> ;	jmp	loc_enter_day_2
 33861                              <1> ;loc_set_date_stc_3:
 33862                              <1> ;	call	check_for_backspace
 33863                              <1> ;	je	short loc_set_date_bs_3
 33864                              <1> ;	;xor	bh, bh ; video page 0
 33865                              <1> ;	call	beeper ; BEEP !
 33866                              <1> ;	jmp	loc_enter_month_1
 33867                              <1> ;loc_set_date_bs_3:
 33868                              <1> ;	call	write_backspace
 33869                              <1> ;	jmp	loc_enter_separator_1
 33870                              <1> ;loc_set_date_stc_4:
 33871                              <1> ;	call	check_for_backspace
 33872                              <1> ;	je	short loc_set_date_bs_4
 33873                              <1> ;	;xor	bh, bh ; video page 0
 33874                              <1> ;	call	beeper ; BEEP !
 33875                              <1> ;	jmp	loc_enter_month_2
 33876                              <1> ;loc_set_date_bs_4:
 33877                              <1> ;	call	write_backspace
 33878                              <1> ;	jmp	loc_enter_month_1
 33879                              <1> 
 33880                              <1> 	; 26/07/2022
 33881                              <1> loc_set_date_stc_5:
 33882 00007C10 E8A0000000          <1> 	call	check_for_backspace
 33883 00007C15 740A                <1> 	je	short loc_set_date_bs_5
 33884                              <1> 	;xor	bh, bh ; video page 0
 33885 00007C17 E8ECA6FFFF          <1> 	call	beeper ; BEEP !
 33886 00007C1C E970FFFFFF          <1> 	jmp	loc_enter_separator_2
 33887                              <1> loc_set_date_bs_5:
 33888 00007C21 E87D000000          <1> 	call	write_backspace
 33889 00007C26 E935FFFFFF          <1> 	jmp	loc_enter_month_2
 33890                              <1> loc_set_date_stc_6:
 33891 00007C2B E885000000          <1> 	call	check_for_backspace
 33892 00007C30 740A                <1>         je      short loc_set_date_bs_6
 33893                              <1> 	;xor	bh, bh ; video page 0
 33894 00007C32 E8D1A6FFFF          <1> 	call	beeper ; BEEP !
 33895 00007C37 E96FFFFFFF          <1> 	jmp	loc_enter_year_1
 33896                              <1> loc_set_date_bs_6:
 33897 00007C3C E862000000          <1> 	call	write_backspace
 33898 00007C41 E94BFFFFFF          <1> 	jmp	loc_enter_separator_2
 33899                              <1> loc_set_date_stc_7:
 33900 00007C46 E86A000000          <1> 	call	check_for_backspace
 33901 00007C4B 740A                <1> 	je	short loc_set_date_bs_7
 33902                              <1> 	;xor	bh, bh ; video page 0
 33903 00007C4D E8B6A6FFFF          <1> 	call	beeper ; BEEP !
 33904 00007C52 E973FFFFFF          <1> 	jmp	loc_enter_year_2
 33905                              <1> loc_set_date_bs_7:
 33906 00007C57 E847000000          <1> 	call	write_backspace
 33907 00007C5C E94AFFFFFF          <1> 	jmp	loc_enter_year_1
 33908                              <1> 
 33909                              <1> loc_set_date_progress:
 33910                              <1> 	; Get Current Date
 33911                              <1> 	;mov	ah, 04h
 33912                              <1> 	;call	int1Ah
 33913 00007C61 E8D2E5FFFF          <1> 	call	RTC_40	; GET RTC DATE
 33914                              <1> 	; CH = century (in BCD)
 33915                              <1> 
 33916 00007C66 66A1[B7310100]      <1> 	mov	ax, [Year]
 33917 00007C6C 662D3030            <1> 	sub	ax, '00'
 33918 00007C70 C0E004              <1> 	shl	al, 4 ; * 16
 33919 00007C73 88C1                <1> 	mov	cl, al
 33920 00007C75 00E1                <1> 	add	cl, ah
 33921 00007C77 66A1[B2310100]      <1> 	mov	ax, [Month]
 33922 00007C7D 662D3030            <1> 	sub	ax, '00'
 33923 00007C81 C0E004              <1> 	shl	al, 4 ; * 16
 33924 00007C84 88C6                <1> 	mov	dh, al
 33925 00007C86 00E6                <1> 	add	dh, ah
 33926 00007C88 66A1[AF310100]      <1> 	mov	ax, [Day]
 33927 00007C8E 662D3030            <1> 	sub	ax, '00'
 33928 00007C92 C0E004              <1> 	shl	al, 4 ; * 16
 33929 00007C95 88C2                <1> 	mov	dl, al
 33930 00007C97 00E2                <1> 	add	dl, ah
 33931                              <1> 
 33932                              <1> 	;mov	ah, 05h
 33933                              <1> 	;call	int1Ah
 33934 00007C99 E8C0E5FFFF          <1> 	call	RTC_50	; SET RTC DATE
 33935                              <1> 
 33936                              <1> ;loc_set_date_retn:
 33937                              <1> ;	mov	esi, nextline
 33938                              <1> ;	;call	print_msg
 33939                              <1> ;	;retn
 33940                              <1> ;	; 26/07/2022
 33941                              <1> ;	jmp	print_msg
 33942                              <1> 
 33943                              <1> 	; 26/07/2022
 33944 00007C9E E963FFFFFF          <1> 	jmp	loc_set_date_ok 
 33945                              <1> 
 33946                              <1> write_backspace:
 33947                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 33948 00007CA3 B008                <1> 	mov	al, 08h ; BACKSPACE
 33949                              <1> 	; 13/05/2016
 33950 00007CA5 66BB0700            <1> 	mov	bx, 7 ; bl = attribute/color
 33951                              <1> 		      ; bh = video page = 0	
 33952 00007CA9 E870A5FFFF          <1> 	call	_write_tty
 33953 00007CAE B020                <1> 	mov	al, 20h ; BLANK/SPACE char 
 33954                              <1> 	;mov	bx, 7 ; attribute/color
 33955                              <1> 	;call	_write_c_current
 33956                              <1> 	;retn
 33957 00007CB0 E9E8A4FFFF          <1> 	jmp	_write_c_current
 33958                              <1> 
 33959                              <1> check_for_backspace:
 33960                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 33961 00007CB5 663D080E            <1> 	cmp	ax, 0E08h
 33962 00007CB9 7410                <1> 	je	short cfbs_retn
 33963 00007CBB 663DE04B            <1> 	cmp	ax, 4BE0h
 33964 00007CBF 740A                <1> 	je	short cfbs_retn
 33965 00007CC1 663D004B            <1> 	cmp	ax, 4B00h
 33966 00007CC5 7404                <1> 	je	short cfbs_retn
 33967 00007CC7 663DE053            <1> 	cmp	ax, 53E0h
 33968                              <1> cfbs_retn:
 33969 00007CCB C3                  <1> 	retn
 33970                              <1> 
 33971                              <1> show_time:
 33972                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 33973                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 33974                              <1>         ; 2004-2005
 33975                              <1> 
 33976                              <1> 	;mov	ah, 02h
 33977                              <1> 	;call	int1Ah
 33978 00007CCC E8FCE4FFFF          <1> 	call	RTC_20	; GET RTC TIME
 33979                              <1> 	
 33980 00007CD1 88E8                <1> 	mov	al, ch
 33981 00007CD3 E8E991FFFF          <1> 	call	bcd_to_ascii
 33982 00007CD8 66A3[DD310100]      <1> 	mov	[Hour], ax
 33983                              <1> 
 33984 00007CDE 88C8                <1> 	mov	al, cl
 33985 00007CE0 E8DC91FFFF          <1> 	call	bcd_to_ascii
 33986 00007CE5 66A3[E0310100]      <1> 	mov	[Minute], ax
 33987                              <1> 
 33988 00007CEB 88F0                <1> 	mov	al, dh
 33989 00007CED E8CF91FFFF          <1> 	call	bcd_to_ascii
 33990 00007CF2 66A3[E3310100]      <1> 	mov	[Second], ax
 33991                              <1> 
 33992 00007CF8 BE[CD310100]        <1> 	mov	esi, Msg_Show_Time
 33993                              <1> 	;call	print_msg
 33994                              <1> 	;retn
 33995                              <1> 	; 26/07/2022
 33996 00007CFD E928EFFFFF          <1> 	jmp	print_msg
 33997                              <1> 
 33998                              <1> set_time:
 33999                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 34000                              <1> 	; 13/05/2016
 34001                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 34002                              <1>         ; 2004-2005
 34003                              <1> 
 34004 00007D02 BE[BC310100]        <1> 	mov 	esi, Msg_Enter_Time
 34005 00007D07 E81EEFFFFF          <1> 	call	print_msg
 34006                              <1> 
 34007                              <1> loc_enter_hour_1:
 34008 00007D0C 30E4                <1> 	xor     ah, ah
 34009 00007D0E E8BB91FFFF          <1> 	call	int16h
 34010                              <1> 	; AL = ASCII Code of the Character
 34011 00007D13 3C0D                <1> 	cmp	al, 13 ; ENTER key
 34012 00007D15 742D                <1>         je	short loc_set_time_retn
 34013 00007D17 3C1B                <1> 	cmp	al, 27 ; ESC key
 34014 00007D19 7429                <1>         je	short loc_set_time_retn
 34015                              <1> set_time_0:
 34016 00007D1B A2[DD310100]        <1> 	mov	[Hour], al
 34017 00007D20 3C30                <1> 	cmp	al, '0'
 34018 00007D22 7204                <1>         jb	short loc_set_time_stc_0
 34019 00007D24 3C32                <1> 	cmp	al, '2'
 34020                              <1>  	;ja	loc_set_time_stc_0
 34021                              <1> 	; 26/07/2022
 34022 00007D26 7626                <1> 	jna	short set_time_1
 34023                              <1> 
 34024                              <1> 	; 26/07/2022
 34025                              <1> loc_set_time_stc_0:
 34026                              <1> 	;xor	bh, bh ; video page 0
 34027 00007D28 E8DBA5FFFF          <1> 	call	beeper ; BEEP !
 34028 00007D2D EBDD                <1> 	jmp	short loc_enter_hour_1
 34029                              <1> 
 34030                              <1> loc_set_time_stc_1:
 34031 00007D2F E881FFFFFF          <1> 	call	check_for_backspace
 34032 00007D34 7407                <1> 	je	short loc_set_time_bs_1
 34033                              <1> 	;xor	bh, bh ; video page 0
 34034 00007D36 E8CDA5FFFF          <1> 	call	beeper ; BEEP !
 34035 00007D3B EB18                <1> 	jmp	short loc_enter_hour_2
 34036                              <1> loc_set_time_bs_1:
 34037 00007D3D E861FFFFFF          <1> 	call	write_backspace
 34038 00007D42 EBC8                <1> 	jmp	short loc_enter_hour_1
 34039                              <1> 
 34040                              <1> 	; 26/07/2022
 34041                              <1> loc_set_time_retn:
 34042 00007D44 BE[0F3B0100]        <1> 	mov 	esi, nextline
 34043                              <1> 	;call	print_msg
 34044                              <1> 	;retn
 34045 00007D49 E9DCEEFFFF          <1> 	jmp	print_msg
 34046                              <1> 
 34047                              <1> set_time_1:
 34048                              <1> 	; 13/05/2016
 34049                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34050                              <1> 		      ; video page 0 (bh)
 34051 00007D4E B307                <1> 	mov	bl, 7	
 34052 00007D50 E8C9A4FFFF          <1> 	call	_write_tty
 34053                              <1> loc_enter_hour_2:
 34054 00007D55 30E4                <1> 	xor     ah, ah
 34055 00007D57 E87291FFFF          <1> 	call	int16h
 34056                              <1> 	; AL = ASCII Code of the Character
 34057 00007D5C 3C1B                <1> 	cmp	al, 27
 34058 00007D5E 74E4                <1> 	je	short loc_set_time_retn
 34059 00007D60 A2[DE310100]        <1> 	mov	[Hour+1], al
 34060 00007D65 3C30                <1> 	cmp	al, '0'
 34061 00007D67 72C6                <1> 	jb	short loc_set_time_stc_1
 34062 00007D69 3C39                <1> 	cmp	al, '9'
 34063 00007D6B 77C2                <1> 	ja	short loc_set_time_stc_1
 34064 00007D6D 803D[DD310100]32    <1>         cmp     byte [Hour], '2'
 34065 00007D74 7204                <1> 	jb	short pass_set_time_24
 34066 00007D76 3C34                <1> 	cmp	al, '4'
 34067 00007D78 77B5                <1> 	ja	short loc_set_time_stc_1
 34068                              <1> pass_set_time_24:
 34069                              <1> 	; 13/05/2016
 34070                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34071                              <1> 		      ; video page 0 (bh)
 34072 00007D7A B307                <1> 	mov	bl, 7	
 34073 00007D7C E89DA4FFFF          <1> 	call	_write_tty
 34074                              <1> loc_enter_time_separator_1:
 34075 00007D81 28E4                <1> 	sub    ah, ah ; 0
 34076 00007D83 E84691FFFF          <1> 	call	int16h
 34077                              <1> 	; AL = ASCII Code of the Character
 34078 00007D88 3C1B                <1> 	cmp	al, 27
 34079 00007D8A 74B8                <1> 	je	short loc_set_time_retn
 34080 00007D8C 3C3A                <1> 	cmp	al, ':'
 34081                              <1> 	;jne	loc_set_time_stc_2
 34082                              <1> 	; 26/07/2022
 34083 00007D8E 7415                <1> 	je	short set_time_2
 34084                              <1> 	
 34085                              <1> 	; 26/07/2022
 34086                              <1> loc_set_time_stc_2:
 34087 00007D90 E820FFFFFF          <1> 	call	check_for_backspace
 34088 00007D95 7407                <1> 	je	short loc_set_time_bs_2
 34089                              <1> 	;xor	bh, bh ; video page 0
 34090 00007D97 E86CA5FFFF          <1> 	call	beeper ; BEEP !
 34091 00007D9C EBE3                <1> 	jmp	short loc_enter_time_separator_1
 34092                              <1> loc_set_time_bs_2:
 34093 00007D9E E800FFFFFF          <1> 	call	write_backspace
 34094 00007DA3 EBB0                <1> 	jmp	short loc_enter_hour_2
 34095                              <1> 
 34096                              <1> set_time_2:
 34097                              <1> 	; 13/05/2016
 34098                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34099                              <1> 		      ; video page 0 (bh)
 34100 00007DA5 B307                <1> 	mov	bl, 7	
 34101 00007DA7 E872A4FFFF          <1> 	call	_write_tty
 34102                              <1> loc_enter_minute_1:
 34103 00007DAC 30E4                <1> 	xor     ah, ah
 34104 00007DAE E81B91FFFF          <1> 	call	int16h
 34105                              <1> 	; AL = ASCII Code of the Character
 34106 00007DB3 3C1B                <1> 	cmp	al, 27
 34107 00007DB5 748D                <1> 	je	short loc_set_time_retn
 34108 00007DB7 A2[E0310100]        <1> 	mov	[Minute], al
 34109 00007DBC 3C30                <1> 	cmp	al, '0'
 34110 00007DBE 7204                <1> 	jb	short loc_set_time_stc_3
 34111 00007DC0 3C35                <1> 	cmp	al, '5'
 34112                              <1> 	;ja	loc_set_time_stc_3
 34113                              <1> 	; 26/07/2022
 34114 00007DC2 7615                <1> 	jna	short set_time_3
 34115                              <1> 
 34116                              <1> 	; 26/07/2022
 34117                              <1> loc_set_time_stc_3:
 34118 00007DC4 E8ECFEFFFF          <1> 	call	check_for_backspace
 34119 00007DC9 7407                <1> 	je	short loc_set_time_bs_3
 34120                              <1> 	;xor	bh, bh ; video page 0
 34121 00007DCB E838A5FFFF          <1> 	call	beeper ; BEEP !6
 34122 00007DD0 EBDA                <1> 	jmp	short loc_enter_minute_1
 34123                              <1> loc_set_time_bs_3:
 34124 00007DD2 E8CCFEFFFF          <1> 	call	write_backspace
 34125 00007DD7 EBA8                <1> 	jmp	short loc_enter_time_separator_1
 34126                              <1> 
 34127                              <1> set_time_3:
 34128                              <1> 	; 13/05/2016
 34129                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34130                              <1> 		      ; video page 0 (bh)
 34131 00007DD9 B307                <1> 	mov	bl, 7	
 34132 00007DDB E83EA4FFFF          <1> 	call	_write_tty
 34133                              <1> loc_enter_minute_2:
 34134 00007DE0 30E4                <1> 	xor     ah, ah
 34135 00007DE2 E8E790FFFF          <1> 	call	int16h
 34136                              <1> 	; AL = ASCII Code of the Character
 34137 00007DE7 3C1B                <1> 	cmp	al, 27
 34138                              <1> 	;je	short loc_set_time_retn
 34139                              <1> 	; 07/08/2022
 34140 00007DE9 7505                <1> 	jne	short loc_enter_minute_3
 34141 00007DEB E954FFFFFF          <1> 	jmp	loc_set_time_retn
 34142                              <1> loc_enter_minute_3:	
 34143 00007DF0 A2[E1310100]        <1> 	mov	[Minute+1], al
 34144 00007DF5 3C30                <1> 	cmp	al, '0'
 34145 00007DF7 7204                <1> 	jb	short loc_set_time_stc_4
 34146 00007DF9 3C39                <1> 	cmp	al, '9'
 34147                              <1> 	;ja	loc_set_time_stc_4
 34148                              <1> 	; 26/07/2022
 34149 00007DFB 7615                <1> 	jna	short set_time_4
 34150                              <1> 
 34151                              <1> 	; 26/07/2022
 34152                              <1> loc_set_time_stc_4:
 34153 00007DFD E8B3FEFFFF          <1> 	call	check_for_backspace
 34154 00007E02 7407                <1> 	je	short loc_set_time_bs_4
 34155                              <1> 	;xor	bh, bh ; video page 0
 34156 00007E04 E8FFA4FFFF          <1> 	call	beeper ; BEEP !
 34157 00007E09 EBD5                <1> 	jmp	short loc_enter_minute_2
 34158                              <1> loc_set_time_bs_4:
 34159 00007E0B E893FEFFFF          <1> 	call	write_backspace
 34160 00007E10 EB9A                <1> 	jmp	short loc_enter_minute_1
 34161                              <1> 
 34162                              <1> set_time_4:
 34163                              <1> 	; 13/05/2016
 34164                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34165                              <1> 		      ; video page 0 (bh)
 34166 00007E12 B307                <1> 	mov	bl, 7	
 34167 00007E14 E805A4FFFF          <1> 	call	_write_tty
 34168                              <1> loc_enter_time_separator_2:
 34169 00007E19 66C705[E3310100]30- <1> 	mov	word [Second], 3030h
 34170 00007E21 30                  <1>
 34171 00007E22 28E4                <1> 	sub     ah, ah
 34172 00007E24 E8A590FFFF          <1> 	call	int16h
 34173                              <1> 	; AL = ASCII Code of the Character
 34174 00007E29 3C0D                <1> 	cmp	al, 13
 34175                              <1>         ;je	short loc_set_time_progress
 34176                              <1> 	; 07/08/2022
 34177 00007E2B 7505                <1> 	jne	short loc_enter_time_separator_3
 34178                              <1> jmp_loc_set_time_progress:
 34179 00007E2D E9D4000000          <1> 	jmp	loc_set_time_progress
 34180                              <1> loc_enter_time_separator_3:
 34181 00007E32 3C1B                <1> 	cmp	al, 27
 34182                              <1> 	;;je	loc_set_time_retn
 34183                              <1> 	; 26/07/2022
 34184                              <1> 	;je	short loc_set_time_ok
 34185                              <1> 	; 07/08/2022
 34186 00007E34 7505                <1> 	jne	short loc_enter_time_separator_4
 34187 00007E36 E982000000          <1> 	jmp	loc_set_time_ok
 34188                              <1> loc_enter_time_separator_4:
 34189 00007E3B 3C3A                <1> 	cmp	al, ':'
 34190 00007E3D 7563                <1>         jne	short loc_set_time_stc_5
 34191                              <1> 
 34192                              <1> 	; 13/05/2016
 34193                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34194                              <1> 		      ; video page 0 (bh)
 34195 00007E3F B307                <1> 	mov	bl, 7	
 34196 00007E41 E8D8A3FFFF          <1> 	call	_write_tty
 34197                              <1> loc_enter_second_1:
 34198 00007E46 30E4                <1> 	xor     ah, ah
 34199 00007E48 E88190FFFF          <1> 	call	int16h
 34200                              <1> 	; AL = ASCII Code of the Character
 34201 00007E4D 3C0D                <1> 	cmp	al, 13
 34202                              <1> 	;je	short loc_set_time_progress
 34203                              <1> 	; 07/08/2022
 34204 00007E4F 74DC                <1> 	je	short jmp_loc_set_time_progress
 34205 00007E51 3C1B                <1> 	cmp	al, 27
 34206                              <1> 	;;je	loc_set_time_retn
 34207                              <1> 	; 26/07/2022
 34208                              <1> 	;je	short loc_set_time_ok
 34209                              <1> 	; 07/08/2022
 34210 00007E53 7502                <1> 	jne	short loc_enter_second_2
 34211 00007E55 EB66                <1> 	jmp	loc_set_time_ok
 34212                              <1> loc_enter_second_2:
 34213 00007E57 A2[E3310100]        <1> 	mov	[Second], al
 34214 00007E5C 3C30                <1> 	cmp	al, '0'
 34215 00007E5E 7267                <1> 	jb	short loc_set_time_stc_6
 34216 00007E60 3C35                <1> 	cmp	al, '5'
 34217 00007E62 7763                <1> 	ja	short loc_set_time_stc_6
 34218                              <1> 	; 13/05/2016
 34219                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34220                              <1> 		      ; video page 0 (bh)
 34221 00007E64 B307                <1> 	mov	bl, 7	
 34222 00007E66 E8B3A3FFFF          <1> 	call	_write_tty
 34223                              <1> loc_enter_second_3:
 34224 00007E6B 30E4                <1> 	xor     ah, ah
 34225 00007E6D E85C90FFFF          <1> 	call	int16h
 34226                              <1> 	; AL = ASCII Code of the Character
 34227 00007E72 3C1B                <1> 	cmp	al, 27
 34228                              <1> 	;je	short loc_set_time_retn
 34229                              <1> 	; 26/07/2022
 34230 00007E74 7447                <1> 	je	short loc_set_time_ok
 34231 00007E76 3C30                <1> 	cmp	al, '0'
 34232 00007E78 7271                <1>         jb	short loc_set_time_stc_7
 34233 00007E7A 3C39                <1> 	cmp	al, '9'
 34234 00007E7C 776D                <1>         ja	short loc_set_time_stc_7
 34235                              <1> 	; 13/05/2016
 34236                              <1> 	;mov	bx, 7 ; attribute/color (bl)
 34237                              <1> 		      ; video page 0 (bh)
 34238 00007E7E B307                <1> 	mov	bl, 7	
 34239 00007E80 E899A3FFFF          <1> 	call	_write_tty
 34240                              <1> loc_set_time_get_lchar_again:
 34241 00007E85 28E4                <1> 	sub	ah, ah ; 0
 34242 00007E87 E84290FFFF          <1> 	call	int16h
 34243                              <1> 	; AL = ASCII Code of the Character
 34244 00007E8C 3C0D                <1> 	cmp	al, 13
 34245 00007E8E 7476                <1> 	je	short loc_set_time_progress
 34246 00007E90 3C1B                <1> 	cmp	al, 27
 34247                              <1> 	;je	short loc_set_time_retn
 34248                              <1> 	; 07/08/2022
 34249 00007E92 7429                <1> 	je	short loc_set_time_ok
 34250                              <1> 	;
 34251 00007E94 E81CFEFFFF          <1> 	call	check_for_backspace
 34252 00007E99 75EA                <1> 	jne	short loc_set_time_get_lchar_again
 34253                              <1> 
 34254                              <1> loc_set_time_bs_8:
 34255 00007E9B E803FEFFFF          <1> 	call	write_backspace
 34256 00007EA0 EBC9                <1> 	jmp	short loc_enter_second_3
 34257                              <1> 
 34258                              <1> ;	; 26/07/2022
 34259                              <1> ;loc_set_time_retn:
 34260                              <1> ;	mov 	esi, nextline
 34261                              <1> ;	;call	print_msg
 34262                              <1> ;	;retn
 34263                              <1> ;	jmp	print_msg
 34264                              <1> 
 34265                              <1> 	; 26/07/2022
 34266                              <1> ;loc_set_time_stc_0:
 34267                              <1> ;	;xor	bh, bh ; video page 0
 34268                              <1> ;	call	beeper ; BEEP !
 34269                              <1> ;	jmp	loc_enter_hour_1
 34270                              <1> ;loc_set_time_stc_1:
 34271                              <1> ;	call	check_for_backspace
 34272                              <1> ;	je	short loc_set_time_bs_1
 34273                              <1> ;	;xor	bh, bh ; video page 0
 34274                              <1> ;	call	beeper ; BEEP !
 34275                              <1> ;	jmp	loc_enter_hour_2
 34276                              <1> ;loc_set_time_bs_1:
 34277                              <1> ;	call	write_backspace
 34278                              <1> ;	jmp	loc_enter_hour_1
 34279                              <1> ;loc_set_time_stc_2:
 34280                              <1> ;	call	check_for_backspace
 34281                              <1> ;	je	short loc_set_time_bs_2
 34282                              <1> ;	;xor	bh, bh ; video page 0
 34283                              <1> ;	call	beeper ; BEEP !
 34284                              <1> ;	jmp	loc_enter_time_separator_1
 34285                              <1> ;loc_set_time_bs_2:
 34286                              <1> ;	call	write_backspace
 34287                              <1> ;	jmp	loc_enter_hour_2
 34288                              <1> ;loc_set_time_stc_3:
 34289                              <1> ;	call	check_for_backspace
 34290                              <1> ;	je	short loc_set_time_bs_3
 34291                              <1> ;	;xor	bh, bh ; video page 0
 34292                              <1> ;	call	beeper ; BEEP !6
 34293                              <1> ;	jmp	loc_enter_minute_1
 34294                              <1> ;loc_set_time_bs_3:
 34295                              <1> ;	call	write_backspace
 34296                              <1> ;	jmp	loc_enter_time_separator_1
 34297                              <1> ;loc_set_time_stc_4:
 34298                              <1> ;	call	check_for_backspace
 34299                              <1> ;	je	short loc_set_time_bs_4
 34300                              <1> ;	;xor	bh, bh ; video page 0
 34301                              <1> ;	call	beeper ; BEEP !
 34302                              <1> ;	jmp	loc_enter_minute_2
 34303                              <1> ;loc_set_time_bs_4:
 34304                              <1> ;	call	write_backspace
 34305                              <1> ;	jmp	loc_enter_minute_1
 34306                              <1> 
 34307                              <1> 	; 26/07/2022
 34308                              <1> loc_set_time_stc_5:
 34309 00007EA2 E80EFEFFFF          <1> 	call	check_for_backspace
 34310 00007EA7 740A                <1> 	je	short loc_set_time_bs_5
 34311                              <1> 	;xor	bh, bh ; video page 0
 34312 00007EA9 E85AA4FFFF          <1> 	call	beeper ; BEEP !
 34313 00007EAE E966FFFFFF          <1> 	jmp	loc_enter_time_separator_2
 34314                              <1> loc_set_time_bs_5:
 34315 00007EB3 E8EBFDFFFF          <1> 	call	write_backspace
 34316 00007EB8 E923FFFFFF          <1> 	jmp	loc_enter_minute_2
 34317                              <1> 
 34318                              <1> 	; 26/07/2022
 34319                              <1> loc_set_time_ok:
 34320 00007EBD BE[0F3B0100]        <1> 	mov 	esi, nextline
 34321                              <1> 	;call	print_msg
 34322                              <1> 	;retn
 34323 00007EC2 E963EDFFFF          <1> 	jmp	print_msg
 34324                              <1> 
 34325                              <1> 	; 07/08/2022
 34326                              <1> loc_set_time_stc_6:
 34327 00007EC7 E8E9FDFFFF          <1> 	call	check_for_backspace
 34328 00007ECC 7413                <1> 	je	short loc_set_time_bs_6
 34329                              <1> 	;xor	bh, bh ; video page 0
 34330 00007ECE E835A4FFFF          <1> 	call	beeper ; BEEP !
 34331 00007ED3 66C705[E3310100]30- <1> 	mov	word [Second], 3030h
 34332 00007EDB 30                  <1>
 34333 00007EDC E965FFFFFF          <1> 	jmp	loc_enter_second_1
 34334                              <1> loc_set_time_bs_6:
 34335 00007EE1 E8BDFDFFFF          <1> 	call	write_backspace
 34336 00007EE6 E92EFFFFFF          <1> 	jmp	loc_enter_time_separator_2
 34337                              <1> loc_set_time_stc_7:
 34338 00007EEB E8C5FDFFFF          <1> 	call	check_for_backspace
 34339 00007EF0 740A                <1> 	je	short loc_set_time_bs_7
 34340                              <1> 	;xor	bh, bh ; video page 0
 34341 00007EF2 E811A4FFFF          <1> 	call	beeper ; BEEP !
 34342 00007EF7 E96FFFFFFF          <1> 	jmp	loc_enter_second_3
 34343                              <1> loc_set_time_bs_7:
 34344 00007EFC E8A2FDFFFF          <1> 	call	write_backspace
 34345 00007F01 E940FFFFFF          <1> 	jmp	loc_enter_second_1
 34346                              <1> 
 34347                              <1> loc_set_time_progress:
 34348                              <1> 	; Get Current Time
 34349                              <1> 	;mov 	ah, 02h
 34350                              <1> 	;call	int1Ah
 34351 00007F06 E8C2E2FFFF          <1> 	call	RTC_20	; GET RTC TIME
 34352                              <1> 	;DL = Daylight Savings Enable option (0-1)	
 34353                              <1> 
 34354 00007F0B 66A1[DD310100]      <1> 	mov	ax, [Hour]
 34355 00007F11 662D3030            <1> 	sub	ax, '00'
 34356 00007F15 C0E004              <1> 	shl	al, 4 ; * 16
 34357 00007F18 88C5                <1> 	mov	ch, al
 34358 00007F1A 00E5                <1> 	add	ch, ah
 34359 00007F1C 66A1[E0310100]      <1> 	mov	ax, [Minute]
 34360 00007F22 662D3030            <1> 	sub	ax, '00'
 34361 00007F26 C0E004              <1> 	shl	al, 4 ; * 16
 34362 00007F29 88C1                <1> 	mov	cl, al
 34363 00007F2B 00E1                <1> 	add	cl, ah
 34364 00007F2D 66A1[E3310100]      <1> 	mov	ax, [Second]
 34365 00007F33 662D3030            <1> 	sub	ax, '00'
 34366 00007F37 C0E004              <1> 	shl	al, 4 ; * 16
 34367 00007F3A 88C6                <1> 	mov	dh, al
 34368 00007F3C 00E6                <1> 	add	dh, ah
 34369                              <1> 	
 34370                              <1> 	;mov	ah, 03h
 34371                              <1> 	;call	int1Ah
 34372 00007F3E E8B8E2FFFF          <1> 	call	RTC_30	; SET RTC TIME
 34373                              <1> 
 34374                              <1> 	; 26/07/2022
 34375 00007F43 E975FFFFFF          <1> 	jmp	loc_set_time_ok
 34376                              <1> 
 34377                              <1> print_volume_info:
 34378                              <1> 	; 01/03/2016
 34379                              <1> 	; 08/02/2016
 34380                              <1> 	; 06/02/2016
 34381                              <1> 	; 04/02/2016
 34382                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
 34383                              <1> 	; 25/10/2009
 34384                              <1> 	;
 34385                              <1> 	; "Volume Serial No: "
 34386                              <1>  	;
 34387                              <1> 	; INPUT  : AL = DOS Drive Number
 34388                              <1> 	; OUTPUT : AH = FS Type
 34389                              <1> 	;          AL = DOS Drive Name
 34390                              <1> 	; CF = 0 -> OK
 34391                              <1> 	; CF = 1 -> Drive not ready 
 34392                              <1> 
 34393 00007F48 88C4                <1> 	mov	ah, al
 34394 00007F4A 28C0                <1> 	sub	al, al
 34395 00007F4C 0FB7F0              <1> 	movzx	esi, ax	
 34396 00007F4F 81C600010900        <1> 	add	esi, Logical_DOSDisks
 34397 00007F55 8A06                <1> 	mov	al, [esi]
 34398 00007F57 3C41                <1> 	cmp	al, 'A'  
 34399 00007F59 7304                <1> 	jnb	short loc_pvi_set_vol_name
 34400 00007F5B 8A6604              <1> 	mov	ah, [esi+LD_FSType]
 34401 00007F5E C3                  <1> 	retn
 34402                              <1> 
 34403                              <1> loc_pvi_set_vol_name:
 34404 00007F5F A2[17320100]        <1> 	mov	[Vol_Drv_Name], al
 34405 00007F64 56                  <1> 	push	esi
 34406 00007F65 E858010000          <1> 	call	move_volume_name_and_serial_no ;;;
 34407 00007F6A 7302                <1> 	jnc	short loc_pvi_mvn_ok
 34408 00007F6C 5E                  <1> 	pop	esi
 34409 00007F6D C3                  <1> 	retn
 34410                              <1> 
 34411                              <1> loc_pvi_mvn_ok:
 34412 00007F6E 8B3424              <1> 	mov	esi, [esp]
 34413 00007F71 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
 34414 00007F75 7509                <1> 	jne	short loc_pvi_fat_vol_size
 34415 00007F77 8B4670              <1> 	mov	eax, [esi+LD_FS_VolumeSize]
 34416 00007F7A 0FB75E11            <1> 	movzx	ebx, word [esi+LD_FS_BytesPerSec]
 34417 00007F7E EB07                <1> 	jmp	short loc_vol_size_mul32
 34418                              <1> loc_pvi_fat_vol_size:
 34419 00007F80 8B4670              <1> 	mov	eax, [esi+LD_TotalSectors]
 34420 00007F83 0FB75E11            <1> 	movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
 34421                              <1> loc_vol_size_mul32:
 34422 00007F87 F7E3                <1> 	mul	ebx
 34423 00007F89 09D2                <1> 	or	edx, edx
 34424 00007F8B 7507                <1> 	jnz	short loc_vol_size_in_kbytes
 34425                              <1> loc_vol_size_in_bytes:
 34426 00007F8D B9[F5310100]        <1> 	mov	ecx, VolSize_Bytes
 34427 00007F92 EB0D                <1> 	jmp	short loc_write_vol_size_str
 34428                              <1> loc_vol_size_in_kbytes:
 34429 00007F94 66BB0004            <1> 	mov	bx, 1024
 34430 00007F98 F7F3                <1> 	div	ebx
 34431 00007F9A B9[E8310100]        <1> 	mov 	ecx, VolSize_KiloBytes
 34432 00007F9F 31D2                <1> 	xor	edx, edx ; 0
 34433                              <1> loc_write_vol_size_str:
 34434 00007FA1 890D[787F0100]      <1> 	mov	[VolSize_Unit1], ecx
 34435                              <1> 	; 
 34436 00007FA7 BF[8E7F0100]        <1> 	mov	edi, Vol_Tot_Sec_Str_End
 34437                              <1>         ;mov	byte [edi], 0
 34438 00007FAC B90A000000          <1> 	mov	ecx, 10
 34439                              <1> loc_write_vol_size_chr:
 34440 00007FB1 F7F1                <1> 	div	ecx
 34441 00007FB3 80C230              <1> 	add	dl, '0'
 34442 00007FB6 4F                  <1> 	dec	edi	
 34443 00007FB7 8817                <1> 	mov	[edi], dl
 34444 00007FB9 85C0                <1> 	test	eax, eax
 34445 00007FBB 7404                <1> 	jz	short loc_write_vol_size_str_ok
 34446 00007FBD 28D2                <1> 	sub	dl, dl ; 0
 34447 00007FBF EBF0                <1> 	jmp	short loc_write_vol_size_chr
 34448                              <1> 
 34449                              <1> loc_write_vol_size_str_ok:
 34450 00007FC1 893D[807F0100]      <1> 	mov	[Vol_Tot_Sec_Str_Start], edi
 34451                              <1> 	;
 34452 00007FC7 BF[00320100]        <1> 	mov	edi, Vol_FS_Name
 34453 00007FCC 8A4E03              <1> 	mov	cl, [esi+LD_FATType]
 34454 00007FCF 20C9                <1> 	and	cl, cl ; 0 ?
 34455 00007FD1 7515                <1> 	jnz	short loc_write_vol_FAT_str_1
 34456 00007FD3 66C7075452          <1> 	mov	word [edi], 'TR'
 34457 00007FD8 C7470420465331      <1> 	mov	dword [edi+4], ' FS1'
 34458                              <1> 	;movzx	ebx, word [esi+LD_FS_BytesPerSec]
 34459 00007FDF 668B5E11            <1> 	mov	bx, [esi+LD_FS_BytesPerSec]
 34460 00007FE3 8B4674              <1> 	mov	eax, [esi+LD_FS_FreeSectors]
 34461 00007FE6 EB36                <1> 	jmp	short loc_vol_freespace_mul32
 34462                              <1> 
 34463                              <1> loc_write_vol_FAT_str_1:
 34464 00007FE8 66B83332            <1> 	mov	ax, '32' ; FAT32
 34465 00007FEC 80F902              <1> 	cmp	cl, 2 ; [esi+LD_FATType]
 34466 00007FEF 7708                <1> 	ja	short loc_write_vol_FAT_str_2
 34467 00007FF1 66B83132            <1> 	mov	ax, '12' ; FAT12
 34468 00007FF5 7202                <1> 	jb	short loc_write_vol_FAT_str_2
 34469 00007FF7 B436                <1> 	mov	ah, '6'  ; FAT16
 34470                              <1> loc_write_vol_FAT_str_2:
 34471 00007FF9 C70746415420        <1> 	mov	dword [edi], 'FAT '
 34472 00007FFF 66894704            <1> 	mov	word [edi+4], ax
 34473                              <1> 	;
 34474                              <1> 	;movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
 34475 00008003 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec]
 34476 00008007 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
 34477                              <1> 
 34478                              <1> loc_vol_freespace_recalc0:
 34479                              <1> 	; 01/03/2016
 34480 0000800A 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
 34481 0000800D 720F                <1> 	jb	short loc_vol_freespace_mul32
 34482                              <1> 	;inc	eax ; 0
 34483 0000800F 20C9                <1> 	and	cl, cl ; byte [esi+LD_FATType]
 34484 00008011 740B                <1> 	jz	short loc_vol_freespace_mul32 	
 34485 00008013 53                  <1> 	push	ebx
 34486 00008014 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free sectors
 34487 00008018 E870470000          <1> 	call	calculate_fat_freespace
 34488 0000801D 5B                  <1> 	pop	ebx
 34489                              <1> 
 34490                              <1> loc_vol_freespace_mul32:
 34491 0000801E F7E3                <1> 	mul	ebx
 34492 00008020 09D2                <1> 	or	edx, edx
 34493 00008022 7507                <1> 	jnz	short loc_vol_fspace_in_kbytes
 34494                              <1> loc_vol_fspace_in_bytes:
 34495 00008024 B9[F5310100]        <1> 	mov	ecx, VolSize_Bytes
 34496 00008029 EB0D                <1> 	jmp	short loc_write_vol_fspace_str
 34497                              <1> loc_vol_fspace_in_kbytes:
 34498 0000802B 66BB0004            <1> 	mov	bx, 1024
 34499 0000802F F7F3                <1> 	div	ebx
 34500 00008031 B9[E8310100]        <1> 	mov 	ecx, VolSize_KiloBytes
 34501 00008036 31D2                <1> 	xor	edx, edx ; 0
 34502                              <1> loc_write_vol_fspace_str:
 34503 00008038 890D[7C7F0100]      <1> 	mov	[VolSize_Unit2], ecx
 34504                              <1> 	;	
 34505 0000803E BF[9E7F0100]        <1> 	mov	edi, Vol_Free_Sectors_Str_End
 34506                              <1>         ;mov	byte [edi], 0
 34507 00008043 B90A000000          <1> 	mov	ecx, 10
 34508                              <1> loc_write_vol_fspace_chr:
 34509 00008048 F7F1                <1> 	div	ecx
 34510 0000804A 80C230              <1> 	add	dl, '0'
 34511 0000804D 4F                  <1> 	dec	edi	
 34512 0000804E 8817                <1> 	mov	[edi], dl
 34513 00008050 85C0                <1> 	test	eax, eax
 34514 00008052 7404                <1> 	jz	short loc_write_vol_fspace_str_ok
 34515 00008054 28D2                <1> 	sub	dl, dl ; 0
 34516 00008056 EBF0                <1> 	jmp	short loc_write_vol_fspace_chr
 34517                              <1> 
 34518                              <1> loc_write_vol_fspace_str_ok:
 34519 00008058 893D[907F0100]      <1> 	mov	[Vol_Free_Sectors_Str_Start], edi
 34520                              <1> 	;
 34521 0000805E BE[FE310100]        <1> 	mov	esi, Volume_in_drive
 34522 00008063 E8C2EBFFFF          <1> 	call	print_msg
 34523 00008068 BE[3E320100]        <1> 	mov	esi, Vol_Name
 34524 0000806D E8B8EBFFFF          <1> 	call	print_msg
 34525 00008072 BE[0F3B0100]        <1> 	mov	esi, nextline
 34526 00008077 E8AEEBFFFF          <1> 	call	print_msg
 34527                              <1> 	;
 34528 0000807C BE[9F320100]        <1> 	mov	esi, Vol_Total_Sector_Header
 34529 00008081 E8A4EBFFFF          <1> 	call	print_msg
 34530 00008086 8B35[807F0100]      <1> 	mov	esi, [Vol_Tot_Sec_Str_Start]
 34531 0000808C E899EBFFFF          <1> 	call	print_msg
 34532 00008091 8B35[787F0100]      <1> 	mov	esi, [VolSize_Unit1]
 34533 00008097 E88EEBFFFF          <1> 	call	print_msg
 34534                              <1> 	;
 34535 0000809C BE[B0320100]        <1> 	mov	esi, Vol_Free_Sectors_Header
 34536 000080A1 E884EBFFFF          <1> 	call	print_msg
 34537 000080A6 8B35[907F0100]      <1> 	mov	esi, [Vol_Free_Sectors_Str_Start]
 34538 000080AC E879EBFFFF          <1> 	call	print_msg
 34539 000080B1 8B35[7C7F0100]      <1> 	mov	esi, [VolSize_Unit2]
 34540 000080B7 E86EEBFFFF          <1> 	call	print_msg
 34541                              <1> 	;
 34542 000080BC 5E                  <1> 	pop	esi
 34543                              <1> 	
 34544                              <1> 	;mov	ah, [esi+LD_FSType]
 34545                              <1> 	;mov	al, [esi+LD_FATType]
 34546 000080BD 668B4603            <1> 	mov	ax, [esi+LD_FATType]
 34547                              <1> 
 34548 000080C1 C3                  <1> 	retn
 34549                              <1> 
 34550                              <1> move_volume_name_and_serial_no:
 34551                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 34552                              <1> 	; 08/02/2016  (TRDOS 386 = TRDOS v2.0)
 34553                              <1> 	; this routine will be called by
 34554                              <1> 	; "print_volume_info" and "print_directory"
 34555                              <1> 	; INPUT ->
 34556                              <1> 	;	ESI = Logical DOS drv descripton table address
 34557                              <1> 	; OUTPUT ->
 34558                              <1> 	;	*Volume name will be moved to text area
 34559                              <1> 	;	*Volume serial number will be converted to
 34560                              <1> 	;	 text and will be moved to text area
 34561                              <1> 	;   cf = 1 -> invalid/unknown dos drive
 34562                              <1> 	;   cf = 0 -> ecx = 0
 34563                              <1> 	;
 34564                              <1> 	; (eax, edx, ecx, esi, edi will be changed)
 34565                              <1> 
 34566                              <1> 	; 26/07/2022
 34567 000080C2 31C9                <1> 	xor	ecx, ecx
 34568                              <1> 
 34569 000080C4 BF[3E320100]        <1> 	mov 	edi, Vol_Name
 34570                              <1> 
 34571                              <1> 	;mov	ah, [esi+LD_FSType]
 34572                              <1> 	;mov	al, [esi+LD_FATType]
 34573 000080C9 668B4603            <1> 	mov	ax, [esi+LD_FATType]
 34574 000080CD 80FCA1              <1> 	cmp	ah, 0A1h
 34575 000080D0 7418                <1> 	je	short mvn_2
 34576 000080D2 08E4                <1> 	or	ah, ah
 34577 000080D4 7404                <1> 	jz	short mvn_0
 34578 000080D6 08C0                <1> 	or	al, al
 34579 000080D8 7504                <1> 	jnz	short mvn_1
 34580                              <1> mvn_0:
 34581 000080DA 8A06                <1> 	mov	al, [esi]
 34582 000080DC F9                  <1> 	stc
 34583 000080DD C3                  <1> 	retn
 34584                              <1> mvn_1:
 34585 000080DE 3C02                <1> 	cmp	al, 2
 34586 000080E0 7714                <1> 	ja	short mvn_3 
 34587                              <1> 	;or	al, al
 34588                              <1> 	;jz	short mvn_2
 34589 000080E2 8B462D              <1> 	mov	eax, [esi+LD_BPB+VolumeID]
 34590 000080E5 83C631              <1> 	add	esi, LD_BPB+VolumeLabel
 34591 000080E8 EB12                <1> 	jmp	short mvn_4
 34592                              <1> mvn_2:
 34593 000080EA 8B4628              <1> 	mov	eax, [esi+LD_FS_VolumeSerial]
 34594 000080ED 83C62C              <1> 	add	esi, LD_FS_VolumeName
 34595                              <1> 	;mov	ecx, 16
 34596                              <1> 	; 26/07/2022
 34597 000080F0 B110                <1> 	mov	cl, 16
 34598 000080F2 F3A5                <1> 	rep	movsd
 34599 000080F4 EB0D                <1> 	jmp	short mvn_5
 34600                              <1> mvn_3:
 34601 000080F6 8B4649              <1> 	mov	eax, [esi+LD_BPB+FAT32_VolID]
 34602 000080F9 83C64D              <1> 	add	esi, LD_BPB+FAT32_VolLab
 34603                              <1> mvn_4:
 34604                              <1> 	;mov	ecx, 11
 34605                              <1> 	; 26/07/2022
 34606 000080FC B10B                <1> 	mov	cl, 11
 34607 000080FE F3A4                <1> 	rep	movsb
 34608 00008100 C60700              <1> 	mov	byte [edi], 0
 34609                              <1> mvn_5:
 34610                              <1> 	;mov	[Current_VolSerial], eax  
 34611 00008103 E831C0FFFF          <1> 	call	dwordtohex
 34612 00008108 8915[93320100]      <1> 	mov	[Vol_Serial1], edx
 34613 0000810E A3[98320100]        <1> 	mov	[Vol_Serial2], eax
 34614                              <1> 	; ecx = 0
 34615 00008113 C3                  <1> 	retn
 34616                              <1> 
 34617                              <1> get_volume_serial_number:
 34618                              <1> 	; 19/01/2016 (TRDOS 386 = TRDOS v2.0)
 34619                              <1> 	; 08/08/2010
 34620                              <1> 	;
 34621                              <1> 	; INPUT -> DL = Logical DOS Drive number
 34622                              <1> 	; OUTPUT -> EAX = Volume serial number
 34623                              <1> 	;          BL= FAT Type	    
 34624                              <1> 	;          BH = Logical DOS drv Number (DL input)
 34625                              <1> 	; cf = 1 -> Drive not ready
 34626                              <1> 
 34627 00008114 31DB                <1> 	xor	ebx, ebx
 34628 00008116 88D7                <1> 	mov	bh, dl
 34629 00008118 3815[67300100]      <1> 	cmp	[Last_DOS_DiskNo], dl
 34630 0000811E 7304                <1> 	jnb	short loc_gvsn_start
 34631                              <1> loc_gvsn_stc_retn:
 34632 00008120 31C0                <1> 	xor	eax, eax
 34633 00008122 F9                  <1> 	stc 
 34634 00008123 C3                  <1>         retn 
 34635                              <1> loc_gvsn_start:
 34636 00008124 56                  <1> 	push	esi
 34637 00008125 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 34638 0000812A 01DE                <1> 	add	esi, ebx
 34639 0000812C 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
 34640 0000812F 20DB                <1> 	and	bl, bl
 34641 00008131 740F                <1> 	jz	short loc_gvsn_fs
 34642 00008133 80FB02              <1> 	cmp	bl, 2
 34643 00008136 7705                <1> 	ja	short loc_gvsn_fat32
 34644                              <1> loc_gvsn_fat:
 34645 00008138 83C62D              <1> 	add	esi, LD_BPB + VolumeID
 34646 0000813B EB0E                <1> 	jmp	short loc_gvsn_return
 34647                              <1> loc_gvsn_fat32: 
 34648 0000813D 83C649              <1> 	add	esi, LD_BPB + FAT32_VolID
 34649 00008140 EB09                <1> 	jmp	short loc_gvsn_return 
 34650                              <1> loc_gvsn_fs:
 34651 00008142 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
 34652 00008146 75D8                <1> 	jne	short loc_gvsn_stc_retn 
 34653 00008148 83C628              <1> 	add	esi, LD_FS_VolumeSerial
 34654                              <1> loc_gvsn_return:
 34655 0000814B 8B06                <1> 	mov	eax, [esi]
 34656 0000814D 5E                  <1> 	pop	esi
 34657 0000814E C3                  <1> 	retn
 34658                              <1> 
 34659                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ]
 34660                              <1> ; 09/11/2011
 34661                              <1> ; 29/01/2005
 34662                              <1> 
 34663                              <1> command_interpreter:
 34664                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 34665                              <1> 	; 16/10/2016
 34666                              <1> 	; 12/10/2016
 34667                              <1> 	; 13/05/2016
 34668                              <1> 	; 07/05/2016
 34669                              <1> 	; 04/03/2016
 34670                              <1> 	; 04/02/2016
 34671                              <1> 	; 03/02/2016
 34672                              <1> 	; 30/01/2016
 34673                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS 2.0)
 34674                              <1> 	; 15/09/2011         
 34675                              <1> 	; 29/01/2005
 34676                              <1>         
 34677                              <1> 	; Input: ecx = command word length (CL)
 34678                              <1> 	;	 CommandBuffer = Command string offset
 34679                              <1>  
 34680 0000814F C605[30800100]00    <1> 	mov	byte [Program_Exit], 0
 34681                              <1> 
 34682                              <1> 	;cmp	cl, 4
 34683                              <1> 	;ja	c_6
 34684                              <1> 	;jb	c_2
 34685                              <1> 
 34686                              <1> 	; 26/07/2022
 34687 00008156 80F903              <1> 	cmp	cl, 3
 34688 00008159 777C                <1> 	ja	short c_4
 34689 0000815B 7405                <1> 	je	short c_3
 34690 0000815D E9D2010000          <1> 	jmp	c_2
 34691                              <1> c_3:
 34692                              <1> cmp_cmd_dir:
 34693 00008162 BF[CF300100]        <1> 	mov	edi, Cmd_Dir
 34694 00008167 E8D1030000          <1> 	call	cmp_cmd	
 34695                              <1> 	;jnc	print_directory_list
 34696                              <1> 	; 26/07/2022
 34697 0000816C 7205                <1> 	jc	short cmp_cmd_cls
 34698 0000816E E97D040000          <1> 	jmp	print_directory_list
 34699                              <1> 
 34700                              <1> cmp_cmd_cls:
 34701 00008173 B103                <1> 	mov	cl, 3
 34702 00008175 BF[0B310100]        <1> 	mov	edi, Cmd_Cls
 34703 0000817A E8BE030000          <1> 	call	cmp_cmd	
 34704                              <1>         ;jnc	clear_screen
 34705                              <1> 	; 26/07/2022
 34706 0000817F 7205                <1> 	jc	short cmp_cmd_ver
 34707 00008181 E9BAEAFFFF          <1> 	jmp	clear_screen
 34708                              <1> 
 34709                              <1> cmp_cmd_ver:
 34710 00008186 B103                <1> 	mov	cl, 3
 34711 00008188 BF[D9300100]        <1> 	mov	edi, Cmd_Ver
 34712 0000818D E8AB030000          <1> 	call	cmp_cmd	
 34713 00008192 720A                <1> 	jc	short cmp_cmd_mem
 34714                              <1> 
 34715 00008194 BE[6F300100]        <1> 	mov	esi, mainprog_Version
 34716                              <1> 	;call	print_msg
 34717 00008199 E98CEAFFFF          <1> 	jmp	print_msg
 34718                              <1> 	;retn
 34719                              <1> 
 34720                              <1> cmp_cmd_mem:
 34721 0000819E B103                <1> 	mov	cl, 3
 34722 000081A0 BF[41310100]        <1> 	mov	edi, Cmd_Mem
 34723 000081A5 E893030000          <1> 	call	cmp_cmd	
 34724                              <1> 	;jnc	memory_info
 34725                              <1> 	; 26/07/2022
 34726 000081AA 7205                <1> 	jc	short cmp_cmd_del
 34727 000081AC E9BABEFFFF          <1> 	jmp	memory_info
 34728                              <1> 
 34729                              <1> cmp_cmd_del:
 34730 000081B1 B103                <1> 	mov	cl, 3
 34731 000081B3 BF[14310100]        <1> 	mov	edi, Cmd_Del
 34732 000081B8 E880030000          <1> 	call	cmp_cmd	
 34733                              <1>         ;jnc	delete_file
 34734                              <1> 	; 26/07/2022
 34735 000081BD 7205                <1> 	jc	short cmp_cmd_set
 34736 000081BF E9C2100000          <1> 	jmp	delete_file
 34737                              <1> 
 34738                              <1> cmp_cmd_set:
 34739 000081C4 B103                <1> 	mov	cl, 3
 34740 000081C6 BF[07310100]        <1> 	mov	edi, Cmd_Set
 34741 000081CB E86D030000          <1> 	call	cmp_cmd	
 34742                              <1> 	;jnc	set_get_env
 34743                              <1> 	; 26/07/2022
 34744 000081D0 720F                <1> 	jc	short cmp_cmd_run
 34745 000081D2 E91D190000          <1> 	jmp	set_get_env
 34746                              <1> 
 34747                              <1> 	; 07/08/2022
 34748                              <1> c_4:
 34749                              <1> 	; 26/07/2022
 34750 000081D7 80F904              <1> 	cmp	cl, 4
 34751 000081DA 741D                <1> 	je	short cmp_cmd_4
 34752 000081DC E937020000          <1> 	jmp	c_6
 34753                              <1> 
 34754                              <1> cmp_cmd_run:
 34755 000081E1 B103                <1> 	mov	cl, 3
 34756 000081E3 BF[03310100]        <1> 	mov	edi, Cmd_Run
 34757 000081E8 E850030000          <1> 	call	cmp_cmd	
 34758                              <1> 	; 07/05/2016
 34759                              <1>         ;jc	cmp_cmd_external
 34760                              <1> 	; 26/07/2022
 34761 000081ED 7305                <1> 	jnc	short c3_run
 34762 000081EF E92C030000          <1> 	jmp	cmp_cmd_external
 34763                              <1> c3_run:
 34764 000081F4 E91C1F0000          <1> 	jmp	load_and_execute_file
 34765                              <1> 
 34766                              <1> cmp_cmd_4:
 34767                              <1> 	; 26/07/2022
 34768                              <1> cmp_cmd_exit:
 34769 000081F9 BF[DD300100]        <1> 	mov	edi, Cmd_Exit
 34770 000081FE E83A030000          <1> 	call	cmp_cmd	
 34771 00008203 7208                <1> 	jc	short cmp_cmd_date
 34772                              <1> 
 34773 00008205 C605[30800100]01    <1>         mov     byte [Program_Exit], 1
 34774 0000820C C3                  <1>         retn
 34775                              <1> 
 34776                              <1> cmp_cmd_date:
 34777 0000820D B104                <1> 	mov	cl, 4
 34778 0000820F BF[F9300100]        <1> 	mov	edi, Cmd_Date
 34779 00008214 E824030000          <1> 	call	cmp_cmd	
 34780 00008219 720A                <1>         jc	short cmp_cmd_time
 34781                              <1> 	
 34782 0000821B E806F8FFFF          <1> 	call	show_date
 34783                              <1> 	;call	set_date
 34784                              <1> 	;retn
 34785                              <1> 	; 26/07/2022
 34786 00008220 E944F8FFFF          <1> 	jmp	set_date
 34787                              <1> 
 34788                              <1> cmp_cmd_time:
 34789 00008225 B104                <1> 	mov	cl, 4
 34790 00008227 BF[FE300100]        <1> 	mov	edi, Cmd_Time
 34791 0000822C E80C030000          <1>    	call	cmp_cmd	
 34792 00008231 720A                <1> 	jc	short cmp_cmd_show
 34793                              <1> 
 34794 00008233 E894FAFFFF          <1> 	call	show_time
 34795                              <1> 	;call	set_time
 34796                              <1> 	;retn
 34797                              <1> 	; 26/07/2022
 34798 00008238 E9C5FAFFFF          <1> 	jmp	set_time
 34799                              <1> 
 34800                              <1> cmp_cmd_show:
 34801 0000823D B104                <1> 	mov	cl, 4
 34802 0000823F BF[0F310100]        <1> 	mov	edi, Cmd_Show
 34803 00008244 E8F4020000          <1>    	call	cmp_cmd	
 34804                              <1>         ;jnc	show_file
 34805                              <1> 	; 26/07/2022
 34806 00008249 7205                <1> 	jc	short cmp_cmd_echo
 34807 0000824B E946090000          <1> 	jmp	show_file
 34808                              <1> 
 34809                              <1> cmp_cmd_echo:
 34810 00008250 B104                <1> 	mov	cl, 4
 34811 00008252 BF[4B310100]        <1> 	mov	edi, Cmd_Echo
 34812 00008257 E8E1020000          <1>    	call	cmp_cmd	
 34813 0000825C 7224                <1> 	jc	short cmp_cmd_copy
 34814                              <1> 	
 34815                              <1> 	; 22/11/2017
 34816                              <1> 	; AL = 0
 34817 0000825E 803E20              <1> 	cmp	byte [esi], 20h
 34818 00008261 7215                <1> 	jb	short cmd_echo_nextline
 34819                              <1> 	; 14/04/2016
 34820 00008263 56                  <1> 	push	esi
 34821                              <1> cmd_echo_asciiz:
 34822                              <1> 	;inc	esi
 34823                              <1> 	;mov	al, [esi]
 34824                              <1> 	; 22/11/2017
 34825 00008264 AC                  <1> 	lodsb
 34826 00008265 3C20                <1> 	cmp	al, 20h
 34827 00008267 73FB                <1> 	jnb	short cmd_echo_asciiz
 34828 00008269 4E                  <1> 	dec	esi
 34829 0000826A C60600              <1> 	mov	byte [esi], 0
 34830 0000826D 5E                  <1> 	pop	esi
 34831 0000826E 89F7                <1> 	mov	edi, esi
 34832 00008270 E8B5E9FFFF          <1> 	call	print_msg
 34833 00008275 C60700              <1> 	mov	byte [edi], 0	
 34834                              <1> cmd_echo_nextline:
 34835 00008278 BE[7D3B0100]        <1> 	mov	esi, NextLine
 34836                              <1> 	;call	print_msg   
 34837                              <1> 	;retn
 34838 0000827D E9A8E9FFFF          <1> 	jmp	print_msg
 34839                              <1> 
 34840                              <1> cmp_cmd_copy:
 34841 00008282 B104                <1> 	mov	cl, 4
 34842 00008284 BF[32310100]        <1> 	mov	edi, Cmd_Copy
 34843 00008289 E8AF020000          <1>    	call	cmp_cmd	
 34844                              <1> 	;jnc	copy_file
 34845                              <1> 	; 26/07/2022
 34846 0000828E 7205                <1> 	jc	short cmp_cmd_move
 34847 00008290 E9AA160000          <1> 	jmp	copy_file
 34848                              <1> 
 34849                              <1> cmp_cmd_move:
 34850 00008295 B104                <1> 	mov	cl, 4
 34851 00008297 BF[37310100]        <1> 	mov	edi, Cmd_Move
 34852 0000829C E89C020000          <1>    	call	cmp_cmd	
 34853                              <1> 	;jnc	move_file
 34854                              <1> 	; 26/07/2022
 34855 000082A1 7205                <1> 	jc	short cmp_cmd_path
 34856 000082A3 E955150000          <1> 	jmp	move_file
 34857                              <1> 
 34858                              <1> cmp_cmd_path:
 34859 000082A8 B104                <1> 	mov	cl, 4
 34860 000082AA BF[3C310100]        <1> 	mov	edi, Cmd_Path
 34861 000082AF E889020000          <1>    	call	cmp_cmd	
 34862                              <1> 	;jnc	set_get_path
 34863                              <1> 	; 26/07/2022
 34864 000082B4 7205                <1> 	jc	short cmp_cmd_beep
 34865 000082B6 E9C1180000          <1> 	jmp	set_get_path
 34866                              <1> 
 34867                              <1> cmp_cmd_beep:
 34868 000082BB B104                <1> 	mov	cl, 4
 34869 000082BD BF[69310100]        <1> 	mov	edi, Cmd_Beep
 34870 000082C2 E876020000          <1>    	call	cmp_cmd	
 34871 000082C7 720B                <1> 	jc	short cmp_cmd_find
 34872                              <1> 	; 13/05/2016
 34873 000082C9 8A3D[AE770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
 34874 000082CF E934A0FFFF          <1> 	jmp	beeper
 34875                              <1> 
 34876                              <1> cmp_cmd_find:
 34877 000082D4 B104                <1> 	mov	cl, 4
 34878 000082D6 BF[46310100]        <1> 	mov	edi, Cmd_Find
 34879 000082DB E85D020000          <1>    	call	cmp_cmd	
 34880                              <1>         ;jc	cmp_cmd_external
 34881                              <1> 	; 26/07/2022
 34882 000082E0 7305                <1> 	jnc	short c4_find
 34883 000082E2 E939020000          <1> 	jmp	cmp_cmd_external
 34884                              <1> c4_find:
 34885                              <1> 	;call	find_and_list_files
 34886 000082E7 E91F210000          <1> 	jmp	find_and_list_files
 34887                              <1> 	;retn
 34888                              <1> 
 34889                              <1> c_1:
 34890 000082EC AD                  <1> 	lodsd
 34891                              <1> cmp_cmd_help:
 34892 000082ED 3C3F                <1> 	cmp	al, '?'
 34893 000082EF 751D                <1>         jne     short cmp_cmd_remark
 34894                              <1> 
 34895 000082F1 BE[CF300100]        <1> 	mov	esi, Command_List
 34896                              <1> cmd_help_next_w:
 34897 000082F6 E82FE9FFFF          <1> 	call	print_msg
 34898                              <1> 
 34899 000082FB 803E20              <1> 	cmp	byte [esi], 20h ; 0
 34900 000082FE 7233                <1> 	jb	short cmd_help_retn
 34901                              <1> 	
 34902 00008300 56                  <1> 	push	esi
 34903 00008301 BE[0F3B0100]        <1> 	mov	esi, nextline
 34904 00008306 E81FE9FFFF          <1> 	call	print_msg
 34905 0000830B 5E                  <1> 	pop	esi
 34906 0000830C EBE8                <1> 	jmp	short cmd_help_next_w	
 34907                              <1> 
 34908                              <1> cmp_cmd_remark:
 34909 0000830E 3C2A                <1> 	cmp	al, '*'
 34910                              <1> 	;jne	cmp_cmd_external
 34911                              <1> 	; 26/07/2022
 34912 00008310 7405                <1> 	je	short cmp_cmd_rem
 34913 00008312 E909020000          <1> 	jmp	cmp_cmd_external
 34914                              <1> cmp_cmd_rem:
 34915 00008317 46                  <1> 	inc	esi
 34916 00008318 BF[A4780100]        <1> 	mov	edi, Remark
 34917 0000831D 8A06                <1> 	mov	al, [esi]
 34918 0000831F 3C20                <1> 	cmp	al, 20h
 34919 00008321 7707                <1> 	ja	short cmd_remark_write
 34920 00008323 89FE                <1> 	mov	esi, edi ; Remark
 34921 00008325 E900E9FFFF          <1> 	jmp	print_msg
 34922                              <1> 
 34923                              <1> cmd_remark_write:
 34924 0000832A AA                  <1> 	stosb
 34925 0000832B AC                  <1> 	lodsb
 34926 0000832C 3C20                <1> 	cmp	al, 20h
 34927 0000832E 73FA                <1> 	jnb	short cmd_remark_write
 34928 00008330 C60700              <1> 	mov	byte [edi], 0
 34929                              <1> 
 34930                              <1> cmd_help_retn:
 34931                              <1> cmd_remark_retn:
 34932                              <1> cd_retn:
 34933 00008333 C3                  <1> 	retn
 34934                              <1> c_2:
 34935                              <1> 	; 26/07/2022
 34936 00008334 BE[F2780100]        <1> 	mov	esi, CommandBuffer
 34937 00008339 80F902              <1> 	cmp	cl, 2
 34938                              <1> 	;ja	c_3
 34939                              <1> 	;mov	esi, CommandBuffer
 34940 0000833C 72AE                <1> 	jb	short c_1
 34941                              <1> 	; 26/07/2022
 34942                              <1> 	;jne	short c_1
 34943                              <1> 
 34944                              <1> cmp_cmd_cd:
 34945 0000833E 66AD                <1> 	lodsw
 34946 00008340 663D4344            <1> 	cmp	ax, 'CD'
 34947 00008344 754E                <1> 	jne	short cmp_cmd_drive
 34948 00008346 46                  <1>         inc	esi
 34949                              <1> cd_0:
 34950 00008347 668B06              <1> 	mov	ax, [esi]	
 34951 0000834A 3C20                <1> 	cmp	al, 20h
 34952 0000834C 76E5                <1> 	jna	short cd_retn
 34953                              <1> 	; 10/02/2016
 34954 0000834E 80FC3A              <1> 	cmp	ah, ':'
 34955 00008351 7504                <1> 	jne	short cd_1
 34956 00008353 46                  <1> 	inc	esi
 34957 00008354 46                  <1> 	inc	esi
 34958 00008355 EB47                <1> 	jmp	short cd_2
 34959                              <1> 
 34960                              <1> cd_1:	; change current directory
 34961                              <1> 	; 29/11/2009
 34962                              <1> 	; AH = CDh	; to separate 'CD' command from others
 34963                              <1> 			; for restoring current directory
 34964                              <1> 			; 0CDh sign is for saving cdir into 
 34965                              <1> 			; DOS drv description table cdir area
 34966                              <1> 	
 34967 00008357 B4CD                <1> 	mov	ah, 0CDh ; mov byte [CD_COMMAND], 0CDh 
 34968                              <1> 
 34969 00008359 E88D210000          <1> 	call	change_current_directory
 34970                              <1> 	;jnc	change_prompt_dir_string
 34971                              <1> 	; 26/07/2022
 34972 0000835E 7205                <1> 	jc	short cd_error_messages
 34973 00008360 E9AA200000          <1> 	jmp	change_prompt_dir_string
 34974                              <1> 
 34975                              <1> cd_error_messages:
 34976 00008365 3C03                <1> 	cmp	al, 3
 34977 00008367 740C                <1> 	je	short cd_path_not_found
 34978                              <1> 	; 16/10/2016 (15h -> 15)
 34979 00008369 3C0F                <1> 	cmp	al, 15 ; drive not ready error 
 34980 0000836B 7453                <1> 	je	short cd_drive_not_ready
 34981 0000836D 3C11                <1> 	cmp	al, 17 ; read error
 34982 0000836F 744F                <1> 	je	short cd_drive_not_ready	
 34983 00008371 3C13                <1> 	cmp	al, 19 ; ; Bad directory/path name 
 34984 00008373 7460                <1> 	je	short cd_command_failed
 34985                              <1> 
 34986                              <1> cd_path_not_found:
 34987 00008375 50                  <1> 	push	eax ; 29/12/2017
 34988                              <1> 	;push	ax	
 34989 00008376 BE[72330100]        <1> 	mov	esi, Msg_Dir_Not_Found
 34990 0000837B E8AAE8FFFF          <1> 	call	print_msg
 34991                              <1> 	;pop	ax
 34992 00008380 58                  <1> 	pop	eax ; 29/12/2017
 34993 00008381 3A25[40780100]      <1> 	cmp	ah, [Current_Dir_Level]
 34994                              <1>         ;jnb	change_prompt_dir_string
 34995                              <1> 	; 26/07/2022
 34996 00008387 7306                <1> 	jnb	short cd_cpds
 34997 00008389 8825[40780100]      <1> 	mov	[Current_Dir_Level], ah
 34998                              <1> cd_cpds:
 34999 0000838F E97B200000          <1>         jmp     change_prompt_dir_string
 35000                              <1> 
 35001                              <1> cmp_cmd_drive: ; change current drive
 35002                              <1> 	; C:, D:, E: etc.
 35003 00008394 80FC3A              <1> 	cmp	ah, ':'
 35004                              <1> 	;jne	cmp_cmd_external
 35005                              <1> 	; 26/07/2022
 35006 00008397 7405                <1> 	je	short cd_2
 35007                              <1> cmd_ext:
 35008 00008399 E982010000          <1> 	jmp	cmp_cmd_external
 35009                              <1> 
 35010                              <1> cd_2:	; 'CD C:', 'CD D:' ...
 35011 0000839E 803E20              <1> 	cmp	byte [esi], 20h
 35012                              <1> 	;ja	loc_cmd_failed
 35013                              <1> 	; 26/07/2022
 35014 000083A1 7706                <1> 	ja	short cd_failed
 35015 000083A3 24DF                <1> 	and	al, 0DFh
 35016 000083A5 2C41                <1> 	sub	al, 'A'
 35017                              <1> 	;jc	loc_cmd_failed
 35018                              <1> 	; 26/07/2022
 35019 000083A7 7305                <1> 	jnc	short cd_3
 35020                              <1> cd_failed:
 35021 000083A9 E97C010000          <1> 	jmp	loc_cmd_failed
 35022                              <1> cd_3:
 35023 000083AE 3A05[67300100]      <1>         cmp     al, [Last_DOS_DiskNo]
 35024 000083B4 770A                <1>         ja	short cd_drive_not_ready
 35025                              <1> 	
 35026 000083B6 88C2                <1> 	mov	dl, al
 35027 000083B8 E8A6F3FFFF          <1> 	call 	change_current_drive
 35028 000083BD 7201                <1> 	jc	short cd_drive_not_ready	
 35029 000083BF C3                  <1> 	retn
 35030                              <1> 
 35031                              <1> cd_drive_not_ready:
 35032 000083C0 BE[2F330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
 35033 000083C5 E860E8FFFF          <1> 	call	print_msg
 35034                              <1> 
 35035                              <1> cd_fail_drive_restart:
 35036 000083CA 8A15[42780100]      <1> 	mov	dl, [Current_Drv]
 35037                              <1> 	;call 	change_current_drive
 35038 000083D0 E98EF3FFFF          <1>         jmp     change_current_drive
 35039                              <1> 	;retn
 35040                              <1> 
 35041                              <1> cd_command_failed:
 35042 000083D5 BE[10330100]        <1> 	mov	esi, Msg_Bad_Command
 35043 000083DA E84BE8FFFF          <1> 	call	print_msg
 35044 000083DF EBE9                <1> 	jmp	short cd_fail_drive_restart
 35045                              <1> 
 35046                              <1> c_5:
 35047                              <1> cmp_cmd_mkdir:
 35048 000083E1 BF[2C310100]        <1> 	mov	edi, Cmd_Mkdir
 35049 000083E6 E852010000          <1> 	call	cmp_cmd	
 35050                              <1> 	;jnc	make_directory
 35051                              <1> 	; 26/07/2022
 35052 000083EB 7205                <1> 	jc	short cmp_cmd_rmdir
 35053 000083ED E95C0A0000          <1> 	jmp	make_directory
 35054                              <1> 
 35055                              <1> cmp_cmd_rmdir:
 35056 000083F2 B105                <1> 	mov	cl, 5
 35057 000083F4 BF[26310100]        <1> 	mov	edi, Cmd_Rmdir
 35058 000083F9 E83F010000          <1> 	call	cmp_cmd	
 35059                              <1> 	;jnc	delete_directory
 35060                              <1> 	; 26/07/2022
 35061 000083FE 7205                <1> 	jc	short cmp_cmd_chdir
 35062 00008400 E9650B0000          <1> 	jmp	delete_directory
 35063                              <1> 
 35064                              <1> cmp_cmd_chdir:
 35065 00008405 B105                <1> 	mov	cl, 5
 35066 00008407 BF[63310100]        <1> 	mov	edi, Cmd_Chdir
 35067 0000840C E82C010000          <1> 	call	cmp_cmd	
 35068                              <1> 	;jc	cmp_cmd_external
 35069                              <1> 	; 26/07/2022
 35070 00008411 7286                <1> 	jc	short cmd_ext
 35071                              <1> 
 35072 00008413 E92FFFFFFF          <1> 	jmp	cd_0
 35073                              <1> 
 35074                              <1> c_6:
 35075 00008418 80F906              <1> 	cmp	cl, 6
 35076                              <1> 	;ja	c_8
 35077                              <1> 	; 26/07/2022
 35078 0000841B 72C4                <1> 	jb	short c_5
 35079 0000841D 7405                <1> 	je	short cmd_6
 35080 0000841F E9E4000000          <1> 	jmp	c_8
 35081                              <1> 
 35082                              <1> cmd_6:
 35083                              <1> cmp_cmd_prompt:
 35084 00008424 BF[E2300100]        <1> 	mov	edi, Cmd_Prompt
 35085 00008429 E80F010000          <1> 	call	cmp_cmd	
 35086 0000842E 722F                <1>         jc	short cmp_cmd_volume
 35087                              <1> get_prompt_name_fchar:
 35088 00008430 AC                  <1> 	lodsb
 35089 00008431 3C20                <1> 	cmp	al, 20h
 35090 00008433 74FB                <1> 	je	short get_prompt_name_fchar
 35091 00008435 7713                <1> 	ja	short loc_change_prompt_label
 35092                              <1> default_command_prompt: ; 31/12/2017 ('sysprompt')
 35093 00008437 BE[C3300100]        <1> 	mov	esi, TRDOSPromptLabel
 35094 0000843C C7065452444F        <1> 	mov	dword [esi], "TRDO"
 35095 00008442 66C746045300        <1>        	mov	word [esi+4], "S" 
 35096                              <1> loc_cmd_prompt_return:
 35097 00008448 C3                  <1> 	retn
 35098                              <1> 
 35099                              <1> set_command_prompt: ; 31/12/2017 ('sysprompt')
 35100 00008449 AC                  <1> 	lodsb
 35101                              <1> loc_change_prompt_label:
 35102                              <1> 	;mov	cx, 11
 35103                              <1> 	; 26/07/2022
 35104 0000844A 29C9                <1> 	sub	ecx, ecx
 35105 0000844C B10B                <1> 	mov	cl, 11
 35106 0000844E BF[C3300100]        <1> 	mov	edi, TRDOSPromptLabel
 35107                              <1> put_char_new_prompt_label:
 35108 00008453 AA                  <1> 	stosb
 35109 00008454 AC                  <1> 	lodsb
 35110 00008455 3C20                <1> 	cmp	al, 20h
 35111 00008457 7202                <1> 	jb	short pass_put_new_prompt_label
 35112 00008459 E2F8                <1> 	loop	put_char_new_prompt_label
 35113                              <1> pass_put_new_prompt_label:
 35114 0000845B C60700              <1> 	mov	byte [edi], 0
 35115 0000845E C3                  <1> 	retn
 35116                              <1> 
 35117                              <1> cmp_cmd_volume:
 35118 0000845F B106                <1> 	mov	cl, 6
 35119 00008461 BF[E9300100]        <1> 	mov	edi, Cmd_Volume
 35120 00008466 E8D2000000          <1> 	call	cmp_cmd	
 35121 0000846B 7259                <1>         jc	short cmp_cmd_attrib
 35122                              <1> 
 35123                              <1> cmd_vol1:
 35124 0000846D AC                  <1> 	lodsb
 35125 0000846E 3C20                <1> 	cmp	al, 20h
 35126 00008470 7707                <1> 	ja	short cmd_vol2
 35127 00008472 A0[42780100]        <1> 	mov	al, [Current_Drv]
 35128 00008477 EB41                <1> 	jmp	short cmd_vol4
 35129                              <1> cmd_vol2:
 35130 00008479 3C41                <1> 	cmp	al, 'A'
 35131                              <1> 	;jb	loc_cmd_failed
 35132                              <1> 	; 26/07/2022
 35133 0000847B 722D                <1> 	jb	short cmd_vol_failed_1
 35134 0000847D 3C7A                <1> 	cmp	al, 'z'
 35135                              <1> 	;ja	loc_cmd_failed
 35136                              <1> 	; 26/07/2022
 35137 0000847F 7731                <1> 	ja	short cmd_vol_failed_2
 35138 00008481 3C5A                <1> 	cmp	al, 'Z'
 35139 00008483 7606                <1> 	jna	short cmd_vol3
 35140 00008485 3C61                <1> 	cmp	al, 'a'
 35141                              <1>         ;jb	loc_cmd_failed
 35142                              <1> 	; 26/07/2022
 35143 00008487 722B                <1> 	jb	short cmd_vol_failed_3
 35144 00008489 24DF                <1> 	and	al, 0DFh
 35145                              <1> cmd_vol3:
 35146 0000848B 8A26                <1> 	mov	ah, [esi]
 35147 0000848D 80FC3A              <1> 	cmp	ah, ':'
 35148 00008490 0F8594000000        <1>         jne     loc_cmd_failed
 35149 00008496 2C41                <1> 	sub	al, 'A'
 35150 00008498 3A05[67300100]      <1>         cmp     al, [Last_DOS_DiskNo]
 35151 0000849E 761A                <1> 	jna	short cmd_vol4
 35152                              <1> 
 35153 000084A0 BE[2F330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
 35154 000084A5 E980E7FFFF          <1> 	jmp	print_msg
 35155                              <1> 
 35156                              <1> 	; 26/07/2022
 35157                              <1> 	; (numeric characters and underscore are allowed)
 35158                              <1> cmd_vol_failed_1:
 35159                              <1> 	; check for numeric characters
 35160 000084AA 3C30                <1> 	cmp	al, '0'
 35161 000084AC 7204                <1> 	jb	short cmd_vol_failed_2
 35162 000084AE 3C39                <1> 	cmp	al, '9'
 35163 000084B0 76D9                <1> 	jna	short cmd_vol3
 35164                              <1> cmd_vol_failed_2:		
 35165 000084B2 EB76                <1> 	jmp	loc_cmd_failed
 35166                              <1> cmd_vol_failed_3:
 35167 000084B4 3C5F                <1> 	cmp	al, '_' ; underline ?
 35168 000084B6 74D3                <1> 	je	short cmd_vol3 ; is ok..
 35169 000084B8 EBF8                <1> 	jmp	short cmd_vol_failed_2
 35170                              <1> 
 35171                              <1> cmd_vol4:
 35172 000084BA E889FAFFFF          <1> 	call	print_volume_info
 35173                              <1> 	;jc	cd_drive_not_ready
 35174                              <1> 	; 26/07/2022
 35175 000084BF 7339                <1> 	jnc	short cmd_vol5
 35176 000084C1 E9FAFEFFFF          <1> 	jmp	cd_drive_not_ready	
 35177                              <1> ;cmd_vol5:
 35178                              <1> ;	retn
 35179                              <1> 
 35180                              <1> cmp_cmd_attrib:
 35181 000084C6 B106                <1> 	mov	cl, 6
 35182 000084C8 BF[18310100]        <1> 	mov	edi, Cmd_Attrib
 35183 000084CD E86B000000          <1> 	call	cmp_cmd	
 35184                              <1> 	;jnc	set_file_attributes
 35185                              <1> 	; 26/07/2022
 35186 000084D2 7205                <1> 	jc	short cmp_cmd_rename
 35187 000084D4 E9B80E0000          <1> 	jmp	set_file_attributes
 35188                              <1> 
 35189                              <1> cmp_cmd_rename:
 35190 000084D9 B106                <1> 	mov	cl, 6
 35191 000084DB BF[1F310100]        <1> 	mov	edi, Cmd_Rename
 35192 000084E0 E858000000          <1> 	call	cmp_cmd	
 35193                              <1> 	;jnc	rename_file
 35194                              <1> 	; 26/07/2022
 35195 000084E5 7205                <1> 	jc	short cmp_cmd_device
 35196 000084E7 E9D6100000          <1> 	jmp	rename_file
 35197                              <1> 
 35198                              <1> cmp_cmd_device:
 35199 000084EC B106                <1> 	mov	cl, 6
 35200 000084EE BF[54310100]        <1> 	mov	edi, Cmd_Device
 35201 000084F3 E845000000          <1> 	call	cmp_cmd	
 35202 000084F8 7226                <1> 	jc	short cmp_cmd_external
 35203                              <1> 	; 26/07/2022
 35204                              <1> cmd_vol5:
 35205                              <1> cmd_dev:
 35206 000084FA C3                  <1> 	retn
 35207                              <1> 
 35208                              <1> c_7:
 35209                              <1> cmp_cmd_devlist:
 35210 000084FB BF[5B310100]        <1> 	mov	edi, Cmd_DevList
 35211 00008500 E838000000          <1> 	call	cmp_cmd	
 35212 00008505 7219                <1>         jc	short cmp_cmd_external
 35213                              <1> 
 35214                              <1> loc_cmd_return:
 35215 00008507 C3                  <1> 	retn
 35216                              <1> 
 35217                              <1> c_8:
 35218 00008508 80F908              <1>         cmp	cl, 8
 35219 0000850B 7713                <1> 	ja	short cmp_cmd_external
 35220 0000850D 72EC                <1> 	jb	short c_7
 35221                              <1> 
 35222                              <1> cmp_cmd_longname:
 35223 0000850F BF[F0300100]        <1> 	mov	edi, Cmd_LongName
 35224 00008514 E824000000          <1> 	call	cmp_cmd	
 35225                              <1> 	;jnc	get_and_print_longname
 35226                              <1> 	; 26/07/2022
 35227 00008519 7205                <1> 	jc	short cmp_cmd_external
 35228 0000851B E923060000          <1> 	jmp	get_and_print_longname
 35229                              <1> 
 35230                              <1> cmp_cmd_external:
 35231                              <1> 	; 07/05/2016
 35232                              <1> 	; 22/04/2016
 35233 00008520 BE[F2780100]        <1> 	mov	esi, CommandBuffer
 35234 00008525 E9EB1B0000          <1> 	jmp	loc_run_check_filename 
 35235                              <1> 
 35236                              <1> loc_cmd_failed:
 35237 0000852A 803D[F2780100]20    <1> 	cmp	byte [CommandBuffer], 20h
 35238 00008531 76D4                <1> 	jna	short loc_cmd_return
 35239 00008533 BE[10330100]        <1> 	mov	esi, Msg_Bad_Command
 35240                              <1> ;	call	print_msg
 35241                              <1> ;loc_cmd_return:
 35242                              <1> ;	retn
 35243 00008538 E9EDE6FFFF          <1> 	jmp	print_msg
 35244                              <1> 
 35245                              <1> cmp_cmd:
 35246                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 35247                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
 35248 0000853D BE[F2780100]        <1>         mov	esi, CommandBuffer
 35249                              <1>         ; edi = internal command word (ASCIIZ)
 35250                              <1> 	; ecx = command length (<=8)
 35251                              <1> cmp_cmd_1:
 35252 00008542 AC                  <1> 	lodsb
 35253 00008543 AE                  <1> 	scasb
 35254 00008544 750D                <1> 	jne	short cmp_cmd_3
 35255 00008546 E2FA                <1> 	loop	cmp_cmd_1
 35256 00008548 AC                  <1>  	lodsb
 35257 00008549 3C20                <1> 	cmp	al, 20h
 35258 0000854B 7703                <1> 	ja	short cmp_cmd_2
 35259 0000854D 30C0                <1> 	xor	al, al
 35260                              <1> 	; ZF = 1 -> internal command word matches
 35261 0000854F C3                  <1> 	retn
 35262                              <1> cmp_cmd_2:
 35263                              <1> 	; ZF = 0 (CF = 0) -> external command word 	
 35264 00008550 58                  <1> 	pop	eax ; no return to the caller from here 
 35265 00008551 EBCD                <1> 	jmp	short cmp_cmd_external  ; 26/07/2022	
 35266                              <1> cmp_cmd_3:
 35267 00008553 F9                  <1> 	stc
 35268                              <1> 	; CF = 1 -> internal command word does not match
 35269 00008554 C3                  <1> 	retn
 35270                              <1> 
 35271                              <1> loc_run_cmd_failed:
 35272                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
 35273                              <1> 	; 15/03/2016
 35274                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 35275                              <1> 	; 07/12/2009 (CMD_INTR.ASM)	
 35276                              <1> 	; 29/11/2009
 35277                              <1> 
 35278 00008555 E863000000          <1> 	call	restore_cdir_after_cmd_fail
 35279                              <1> 
 35280                              <1> loc_run_cmd_failed_cmp_al:
 35281                              <1> 	; End of Restore_CDIR code (29/11/2009)
 35282                              <1> 
 35283 0000855A 3C01                <1> 	cmp	al, 1 ; Bad command or file name
 35284 0000855C 74CC                <1> 	je	short loc_cmd_failed ; 26/07/2022
 35285                              <1> loc_run_dir_not_found:
 35286 0000855E 3C03                <1> 	cmp	al, 3
 35287 00008560 750A                <1> 	jne	short loc_run_file_notfound_msg
 35288                              <1> 	; Path not found (MS-DOS Error Code = 3)
 35289 00008562 BE[72330100]        <1> 	mov	esi, Msg_Dir_Not_Found
 35290 00008567 E9BEE6FFFF          <1> 	jmp	print_msg
 35291                              <1> 
 35292                              <1> loc_run_file_notfound_msg:
 35293 0000856C 3C02                <1> 	cmp	al, 2 ; File not found
 35294 0000856E 750A                <1> 	jne	short loc_run_file_drv_read_err
 35295                              <1> 
 35296                              <1> loc_print_file_notfound_msg: 
 35297 00008570 BE[89330100]        <1>         mov     esi, Msg_File_Not_Found
 35298                              <1> 	;call	proc_printmsg
 35299                              <1> 	;retn
 35300 00008575 E9B0E6FFFF          <1> 	jmp	print_msg
 35301                              <1> 
 35302                              <1> loc_run_file_drv_read_err:
 35303                              <1> 	; Err: 17 (Read fault)
 35304 0000857A 3C11                <1> 	cmp	al, 17 ; Drive not ready or read error
 35305 0000857C 7404                <1> 	je	short loc_run_file_print_drv_read_err
 35306                              <1> 	;
 35307 0000857E 3C0F                <1> 	cmp	al, 15 ; Drive not ready (or read error)
 35308 00008580 750A                <1> 	jne	short loc_run_file_toobig
 35309                              <1> 
 35310                              <1> loc_run_file_print_drv_read_err:
 35311 00008582 BE[2F330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
 35312 00008587 E99EE6FFFF          <1> 	jmp	print_msg
 35313                              <1> 
 35314                              <1> loc_run_file_toobig:
 35315 0000858C 3C08                <1> 	cmp	al, 8 ; Not enough free memory to load&run file
 35316 0000858E 750A                <1> 	jne	short loc_run_file_perm_denied
 35317 00008590 BE[D4330100]        <1> 	mov	esi, Msg_Insufficient_Memory
 35318 00008595 E990E6FFFF          <1> 	jmp	print_msg
 35319                              <1> 
 35320                              <1> loc_run_file_perm_denied:
 35321                              <1> 	; 29/12/2017
 35322 0000859A 3C0B                <1> 	cmp	al, ERR_PERM_DENIED ; 11 ; Permission denied
 35323 0000859C 750A                <1> 	jne	short loc_run_misc_error
 35324 0000859E BE[68350100]        <1> 	mov	esi, Msg_Permission_Denied
 35325 000085A3 E982E6FFFF          <1> 	jmp	print_msg	
 35326                              <1> 
 35327                              <1> 	; 15/03/2016
 35328                              <1> print_misc_error_msg:
 35329                              <1> loc_run_misc_error:
 35330                              <1> 	; AL = Error code
 35331 000085A8 E84CBBFFFF          <1> 	call	bytetohex
 35332 000085AD 66A3[08340100]      <1>         mov     [error_code_hex], ax
 35333                              <1> 	
 35334 000085B3 BE[EB330100]        <1> 	mov	esi, Msg_Error_Code 
 35335                              <1> 	;call	print_msg 
 35336                              <1> 	;retn
 35337 000085B8 E96DE6FFFF          <1> 	jmp	print_msg
 35338                              <1> 
 35339                              <1> restore_cdir_after_cmd_fail:
 35340                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 35341 000085BD 50                  <1> 	push	eax
 35342 000085BE 8A3D[9F7F0100]      <1> 	mov	bh, [RUN_CDRV] ; it is set at the beginning
 35343                              <1> 				; of the 'run' command.
 35344 000085C4 3A3D[42780100]      <1> 	cmp	bh, [Current_Drv]
 35345 000085CA 7409                <1> 	je	short loc_run_restore_cdir
 35346 000085CC 88FA                <1> 	mov	dl, bh
 35347 000085CE E890F1FFFF          <1> 	call	change_current_drive 
 35348 000085D3 EB19                <1> 	jmp	short loc_run_err_pass_restore_cdir
 35349                              <1> 
 35350                              <1> loc_run_restore_cdir:
 35351 000085D5 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 35352 000085DC 7610                <1> 	jna	short loc_run_err_pass_restore_cdir
 35353 000085DE 30DB                <1> 	xor	bl, bl
 35354 000085E0 0FB7F3              <1> 	movzx	esi, bx
 35355 000085E3 81C600010900        <1> 	add	esi, Logical_DOSDisks
 35356 000085E9 E82BF2FFFF          <1> 	call	restore_current_directory
 35357                              <1> 
 35358                              <1> loc_run_err_pass_restore_cdir:
 35359 000085EE 58                  <1> 	pop	eax
 35360 000085EF C3                  <1> 	retn
 35361                              <1> 
 35362                              <1> print_directory_list:
 35363                              <1> 	; 07/08/2022
 35364                              <1> 	; 27/07/2022 (TRDOS 386 Kernel v2.0.5)
 35365                              <1> 	; 10/02/2016
 35366                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
 35367                              <1> 	; 06/12/2009 ('cmp_cmd_dir')	
 35368                              <1> 	;
 35369 000085F0 66C705[E0800100]00- <1> 	mov	word [AttributesMask], 0800h ; ..except volume names..
 35370 000085F8 08                  <1>
 35371 000085F9 A0[42780100]        <1> 	mov	al, [Current_Drv]
 35372 000085FE A2[9F7F0100]        <1> 	mov	[RUN_CDRV], al
 35373                              <1> get_dfname_fchar:
 35374 00008603 AC                  <1> 	lodsb
 35375 00008604 3C20                <1> 	cmp	al, 20h
 35376 00008606 74FB                <1> 	je	short get_dfname_fchar
 35377 00008608 0F82E0000000        <1>         jb      loc_print_dir_call_all
 35378 0000860E 3C2D                <1> 	cmp	al, '-'
 35379 00008610 753C                <1> 	jne	short loc_print_dir_call_flt
 35380                              <1> get_next_attr_char:
 35381 00008612 AC                  <1> 	lodsb
 35382 00008613 3C20                <1> 	cmp	al, 20h
 35383 00008615 74FB                <1> 	je	short get_next_attr_char
 35384                              <1> 	;jb	loc_cmd_failed
 35385                              <1> 	; 27/07/2022
 35386 00008617 7305                <1> 	jnb	short pdl_1
 35387                              <1> pdl_0:
 35388 00008619 E90CFFFFFF          <1> 	jmp	loc_cmd_failed
 35389                              <1> pdl_1:
 35390 0000861E 24DF                <1> 	and	al, 0DFh
 35391 00008620 3C44                <1> 	cmp	al, 'D' ; directories only ?
 35392 00008622 750E                <1> 	jne	short pass_only_directories
 35393 00008624 AC                  <1> 	lodsb
 35394 00008625 3C20                <1> 	cmp	al, 20h
 35395                              <1> 	;ja	loc_cmd_failed
 35396                              <1> 	; 27/07/2022
 35397 00008627 77F0                <1> 	ja	short pdl_0
 35398 00008629 800D[E0800100]10    <1> 	or	byte [AttributesMask], 10h ; ..directory..
 35399 00008630 EB10                <1> 	jmp	short get_dfname_fchar_attr
 35400                              <1> pass_only_directories:
 35401 00008632 3C46                <1> 	cmp	al, 'F'	; files only ?
 35402 00008634 7530                <1> 	jne	short check_attr_s ; 27/07/2022
 35403 00008636 AC                  <1> 	lodsb
 35404 00008637 3C20                <1> 	cmp	al, 20h
 35405                              <1> 	;ja	loc_cmd_failed
 35406                              <1> 	; 27/07/2022
 35407 00008639 77DE                <1> 	ja	short pdl_0
 35408 0000863B 800D[E1800100]10    <1> 	or	byte [AttributesMask+1], 10h ; ..except directories..
 35409                              <1> get_dfname_fchar_attr:
 35410 00008642 AC                  <1> 	lodsb
 35411 00008643 3C20                <1> 	cmp	al, 20h
 35412 00008645 74FB                <1> 	je	short get_dfname_fchar_attr
 35413                              <1> 	;jb	short loc_print_dir_call_all
 35414                              <1> 	; 07/08/2022
 35415 00008647 7305                <1> 	jnb	short loc_print_dir_call_flt
 35416 00008649 E9A0000000          <1> 	jmp	loc_print_dir_call_all
 35417                              <1> loc_print_dir_call_flt:
 35418 0000864E 4E                  <1> 	dec	esi
 35419 0000864F BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 35420 00008654 E87E240000          <1> 	call	parse_path_name
 35421 00008659 7352                <1>  	jnc	short loc_print_dir_change_drv_1
 35422 0000865B 3C01                <1> 	cmp	al, 1
 35423                              <1> 	;ja	loc_run_cmd_failed
 35424                              <1> 	; 27/07/2022
 35425 0000865D 764E                <1> 	jna	short loc_print_dir_change_drv_1
 35426                              <1> pdl_2:
 35427 0000865F E9F1FEFFFF          <1> 	jmp	loc_run_cmd_failed
 35428                              <1> 
 35429                              <1> 	; 27/07/2022
 35430                              <1> check_attr_s_cap:
 35431 00008664 24DF                <1> 	and	al, 0DFh
 35432                              <1> check_attr_s:
 35433 00008666 3C53                <1> 	cmp	al, 'S'
 35434 00008668 7510                <1> 	jne	short pass_attr_s
 35435 0000866A 800D[E0800100]04    <1> 	or	byte [AttributesMask], 4 ; system
 35436 00008671 AC                  <1> 	lodsb
 35437 00008672 3C20                <1> 	cmp	al, 20h
 35438 00008674 74CC                <1> 	je	short get_dfname_fchar_attr
 35439 00008676 7276                <1> 	jb	short loc_print_dir_call_all
 35440 00008678 24DF                <1> 	and	al, 0DFh
 35441                              <1> pass_attr_s:
 35442 0000867A 3C48                <1> 	cmp	al, 'H'
 35443 0000867C 7510                <1> 	jne	short pass_attr_h
 35444 0000867E 800D[E0800100]02    <1> 	or	byte [AttributesMask], 2 ; hidden
 35445                              <1> pass_attr_shr:
 35446 00008685 AC                  <1> 	lodsb
 35447 00008686 3C20                <1> 	cmp	al, 20h
 35448 00008688 74B8                <1> 	je	short get_dfname_fchar_attr
 35449 0000868A 7262                <1> 	jb	short loc_print_dir_call_all
 35450 0000868C EBD6                <1> 	jmp	short check_attr_s_cap
 35451                              <1> pass_attr_h:
 35452 0000868E 3C52                <1> 	cmp	al, 'R'
 35453 00008690 7509                <1> 	jne	short pass_attr_r
 35454 00008692 800D[E0800100]01    <1> 	or	byte [AttributesMask], 1 ; read only
 35455 00008699 EBEA                <1> 	jmp	short pass_attr_shr
 35456                              <1> pass_attr_r:
 35457 0000869B 3C41                <1> 	cmp	al, 'A'
 35458                              <1> 	;jne	loc_cmd_failed
 35459                              <1> 	; 27/07/2022
 35460 0000869D 7405                <1> 	je	short pass_attr_a
 35461 0000869F E986FEFFFF          <1> 	jmp	loc_cmd_failed
 35462                              <1> pass_attr_a:
 35463 000086A4 800D[E0800100]20    <1> 	or	byte [AttributesMask], 20h ; archive
 35464 000086AB EBD8                <1> 	jmp	short pass_attr_shr
 35465                              <1> 
 35466                              <1> 	; 07/08/2022
 35467                              <1> loc_print_dir_change_drv_1:
 35468 000086AD 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 35469                              <1> loc_print_dir_change_drv_2:
 35470 000086B3 3A15[9F7F0100]      <1> 	cmp	dl, [RUN_CDRV]
 35471 000086B9 7407                <1> 	je	short loc_print_dir_change_directory 
 35472 000086BB E8A3F0FFFF          <1> 	call	change_current_drive
 35473                              <1>         ;jc	loc_run_cmd_failed
 35474                              <1> 	; 27/07/2022
 35475 000086C0 729D                <1> 	jc	short pdl_2
 35476                              <1> loc_print_dir_change_directory:
 35477 000086C2 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h ; 0 or 20h ?
 35478 000086C9 7619                <1> 	jna	short pass_print_dir_change_directory
 35479                              <1> 
 35480 000086CB FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 35481 000086D1 BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 35482 000086D6 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 35483 000086D8 E80E1E0000          <1> 	call	change_current_directory
 35484                              <1>         ;jc	loc_run_cmd_failed
 35485                              <1> 	; 27/07/2022
 35486 000086DD 7280                <1> 	jc	short pdl_2
 35487                              <1> 
 35488                              <1> loc_print_dir_change_prompt_dir_string:
 35489 000086DF E82B1D0000          <1> 	call	change_prompt_dir_string
 35490                              <1> 
 35491                              <1> pass_print_dir_change_directory:
 35492 000086E4 BE[24810100]        <1> 	mov	esi, FindFile_Name
 35493 000086E9 803E20              <1> 	cmp	byte [esi], 20h ; ; 0 or 20h ?
 35494 000086EC 7706                <1> 	ja	short loc_print_dir_call
 35495                              <1> 
 35496                              <1> loc_print_dir_call_all:
 35497 000086EE C7062A2E2A00        <1> 	mov	dword [esi], '*.*'
 35498                              <1> loc_print_dir_call:
 35499 000086F4 E82D000000          <1> 	call	print_directory
 35500                              <1> 
 35501 000086F9 8A15[9F7F0100]      <1> 	mov	dl, [RUN_CDRV]  ; it is set at the beginning
 35502 000086FF 3A15[42780100]      <1> 	cmp	dl, [Current_Drv]
 35503 00008705 7405                <1> 	je	short loc_print_dir_call_restore_cdir_retn
 35504                              <1> 	;call	change_current_drive
 35505                              <1> 	;retn
 35506                              <1> 	; 27/07/2022
 35507 00008707 E957F0FFFF          <1> 	jmp	change_current_drive	
 35508                              <1> 
 35509                              <1> loc_print_dir_call_restore_cdir_retn:
 35510 0000870C 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 35511 00008713 7610                <1> 	jna	short pass_print_dir_call_restore_cdir_retn
 35512                              <1> 
 35513 00008715 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 35514 0000871A 31C0                <1> 	xor	eax, eax
 35515 0000871C 88D4                <1> 	mov	ah, dl
 35516 0000871E 01C6                <1> 	add	esi, eax
 35517                              <1> 
 35518                              <1> 	;call	restore_current_directory
 35519                              <1> 	; 27/07/2022
 35520 00008720 E9F4F0FFFF          <1> 	jmp	restore_current_directory
 35521                              <1> 
 35522                              <1> pass_print_dir_call_restore_cdir_retn:
 35523 00008725 C3                  <1> 	retn
 35524                              <1> 
 35525                              <1> print_directory:
 35526                              <1> 	; 27/07/2022 (TRDOS 386 Kernel v2.0.5)
 35527                              <1> 	; 13/05/2016
 35528                              <1> 	; 11/02/2016
 35529                              <1> 	; 10/02/2016
 35530                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
 35531                              <1> 	; 30/10/2010 ('proc_print_directory')	
 35532                              <1> 	; 19/09/2009
 35533                              <1> 	; 2005 
 35534                              <1> 	; INPUT ->
 35535                              <1> 	;	ESI = Asciiz File/Dir Name Address
 35536                              <1> 
 35537 00008726 56                  <1> 	push	esi
 35538                              <1> 
 35539 00008727 29C0                <1> 	sub	eax, eax
 35540                              <1> 
 35541 00008729 66A3[6C810100]      <1> 	mov	[Dir_Count], ax ; 0
 35542 0000872F 66A3[6A810100]      <1> 	mov 	[File_Count], ax ; 0
 35543 00008735 A3[6E810100]        <1> 	mov 	[Total_FSize], eax ; 0
 35544                              <1> 
 35545 0000873A E801E5FFFF          <1> 	call    clear_screen
 35546                              <1> 	
 35547 0000873F 31C9                <1> 	xor	ecx, ecx	
 35548 00008741 8A2D[42780100]      <1> 	mov     ch, [Current_Drv] ; DirBuff_Drv - 'A'
 35549 00008747 A0[43780100]        <1> 	mov     al, [Current_Dir_Drv] 
 35550 0000874C A2[2D320100]        <1> 	mov     [Dir_Drive_Name], al
 35551 00008751 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 35552 00008756 01CE                <1> 	add	esi, ecx
 35553                              <1> 
 35554 00008758 E865F9FFFF          <1> 	call	move_volume_name_and_serial_no
 35555 0000875D 730C                <1> 	jnc	short print_dir_strlen_check
 35556                              <1> 
 35557 0000875F 5E                  <1> 	pop	esi
 35558 00008760 8A3D[AE770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
 35559                              <1> 	;call	beeper
 35560                              <1> 	;retn
 35561 00008766 E99D9BFFFF          <1> 	jmp	beeper  ; beep ! and return
 35562                              <1> 
 35563                              <1> print_dir_strlen_check:
 35564 0000876B BE[45780100]        <1> 	mov	esi, Current_Dir_Root
 35565 00008770 BF[CA320100]        <1> 	mov	edi, Dir_Str_Root
 35566                              <1> 	
 35567                              <1> 	;xor	ecx, ecx
 35568 00008775 8A0D[A1780100]      <1>         mov     cl, [Current_Dir_StrLen]
 35569 0000877B FEC1                <1> 	inc	cl
 35570 0000877D 80F940              <1> 	cmp	cl, 64
 35571 00008780 760D                <1> 	jna	short pass_print_dir_strlen_shorting
 35572 00008782 46                  <1> 	inc	esi
 35573 00008783 01CE                <1> 	add	esi, ecx
 35574 00008785 83EE40              <1> 	sub	esi, 64 
 35575 00008788 47                  <1> 	inc	edi
 35576 00008789 B82E2E2E20          <1> 	mov	eax, '... ' 
 35577 0000878E AB                  <1> 	stosd
 35578                              <1>  
 35579                              <1> pass_print_dir_strlen_shorting:
 35580 0000878F F3A4                <1> 	rep	movsb
 35581                              <1> 
 35582 00008791 BE[20320100]        <1> 	mov	esi, Dir_Drive_Str
 35583 00008796 E88FE4FFFF          <1> 	call	print_msg
 35584                              <1> 
 35585 0000879B BE[7F320100]        <1> 	mov	esi, Vol_Serial_Header
 35586 000087A0 E885E4FFFF          <1> 	call	print_msg
 35587                              <1> 
 35588 000087A5 BE[BF320100]        <1> 	mov	esi, Dir_Str_Header
 35589 000087AA E87BE4FFFF          <1> 	call	print_msg
 35590                              <1> 	
 35591 000087AF BE[0D3B0100]        <1> 	mov	esi, next2line
 35592 000087B4 E871E4FFFF          <1> 	call	print_msg
 35593                              <1> 
 35594                              <1> loc_print_dir_first_file:
 35595 000087B9 C605[81810100]10    <1> 	mov	byte [PrintDir_RowCounter], 16
 35596 000087C0 66A1[E0800100]      <1> 	mov	ax, [AttributesMask]
 35597 000087C6 5E                  <1> 	pop	esi
 35598                              <1> 
 35599 000087C7 E845020000          <1> 	call	find_first_file
 35600                              <1> 	;jc	loc_dir_ok
 35601                              <1> 	; 27/07/2022
 35602 000087CC 7305                <1> 	jnc	short loc_dfname_use_this
 35603 000087CE E97B010000          <1> 	jmp	loc_dir_ok
 35604                              <1> 	 
 35605                              <1> loc_dfname_use_this:
 35606                              <1> 	; bl =	File Attributes (bh = Long Name Entry Length)
 35607 000087D3 F6C310              <1> 	test	bl, 10h  ; Is it a directory?
 35608 000087D6 741B                <1> 	jz	short loc_not_dir
 35609                              <1> 
 35610 000087D8 66FF05[6C810100]    <1> 	inc	word [Dir_Count]
 35611 000087DF 89F2                <1> 	mov	edx, esi 	; FindFile_DirEntry address
 35612 000087E1 BE[0E340100]        <1>  	mov	esi, Type_Dir	; '<DIR>     '
 35613 000087E6 BF[25340100]        <1> 	mov	edi, Dir_Or_FileSize
 35614                              <1> 	; move 10 bytes
 35615 000087EB A5                  <1> 	movsd
 35616 000087EC A5                  <1> 	movsd
 35617 000087ED 66A5                <1> 	movsw	    	
 35618 000087EF 89D6                <1> 	mov	esi, edx
 35619 000087F1 EB36                <1> 	jmp     short loc_dir_attribute
 35620                              <1> 
 35621                              <1> loc_not_dir:
 35622 000087F3 66FF05[6A810100]    <1> 	inc	word [File_Count]
 35623 000087FA 0105[6E810100]      <1> 	add	[Total_FSize], eax
 35624                              <1> 
 35625 00008800 B90A000000          <1> 	mov	ecx, 10  ; 32 bit divisor
 35626 00008805 89CF                <1> 	mov	edi, ecx
 35627 00008807 81C7[25340100]      <1> 	add	edi, Dir_Or_FileSize
 35628                              <1> loc_dir_rdivide:
 35629 0000880D 29D2                <1> 	sub	edx, edx
 35630 0000880F F7F1                <1> 	div	ecx 	 ; remainder in dl (< 10)
 35631 00008811 80C230              <1> 	add     dl, '0'	 ; to make visible (ascii)
 35632 00008814 4F                  <1> 	dec	edi
 35633 00008815 8817                <1> 	mov     [edi], dl
 35634 00008817 21C0                <1> 	and	eax, eax
 35635 00008819 75F2                <1> 	jnz	short loc_dir_rdivide
 35636                              <1> 
 35637                              <1> loc_dir_fill_space:
 35638 0000881B 81FF[25340100]      <1> 	cmp     edi, Dir_Or_FileSize
 35639 00008821 7606                <1> 	jna     short loc_dir_attribute
 35640 00008823 4F                  <1> 	dec     edi
 35641 00008824 C60720              <1> 	mov     byte [edi], 20h
 35642 00008827 EBF2                <1> 	jmp     short loc_dir_fill_space
 35643                              <1> 
 35644                              <1> loc_dir_attribute:
 35645 00008829 C705[30340100]2020- <1> 	mov	dword [File_Attribute], 20202020h
 35646 00008831 2020                <1>
 35647                              <1> 
 35648 00008833 80FB20              <1> 	cmp	bl, 20h  ; Is it an archive file?
 35649 00008836 7207                <1> 	jb	short loc_dir_pass_arch
 35650 00008838 C605[33340100]41    <1> 	mov	byte [File_Attribute+3], 'A'
 35651                              <1> 
 35652                              <1> loc_dir_pass_arch:
 35653 0000883F 80E307              <1> 	and	bl, 7
 35654 00008842 7428                <1> 	jz	short loc_dir_file_name
 35655 00008844 88DF                <1> 	mov	bh, bl
 35656 00008846 80E303              <1> 	and	bl, 3
 35657 00008849 38DF                <1> 	cmp	bh, bl
 35658 0000884B 7607                <1> 	jna	short loc_dir_pass_s
 35659 0000884D C605[30340100]53    <1> 	mov	byte [File_Attribute], 'S'
 35660                              <1> 
 35661                              <1> loc_dir_pass_s:
 35662 00008854 80E302              <1> 	and     bl,2
 35663 00008857 7407                <1> 	jz      short loc_dir_pass_h
 35664 00008859 C605[31340100]48    <1> 	mov     byte [File_Attribute+1], 'H'
 35665                              <1> loc_dir_pass_h:
 35666 00008860 80E701              <1> 	and     bh,1
 35667 00008863 7407                <1> 	jz      short loc_dir_file_name
 35668 00008865 C605[32340100]52    <1> 	mov     byte [File_Attribute+2], 'R'
 35669                              <1> loc_dir_file_name:
 35670                              <1> 	;mov	bx, [esi+18h] ; Date
 35671                              <1> 	;mov	dx, [esi+16h] ; Time
 35672 0000886C 8B5E16              <1> 	mov	ebx, [esi+16h]
 35673 0000886F 89F1                <1> 	mov	ecx, esi ; FindFile_DirEntry address
 35674 00008871 BF[18340100]        <1> 	mov     edi, File_Name
 35675                              <1> 	; move 8 bytes
 35676 00008876 A5                  <1> 	movsd
 35677 00008877 A5                  <1> 	movsd
 35678 00008878 C60720              <1> 	mov	byte [edi], 20h
 35679 0000887B 47                  <1> 	inc	edi
 35680                              <1> 	; move 3 bytes
 35681 0000887C 66A5                <1> 	movsw
 35682 0000887E A4                  <1> 	movsb
 35683 0000887F 89CE                <1> 	mov	esi, ecx
 35684                              <1> 
 35685                              <1> Dir_Time_start:
 35686                              <1> 	;mov	ax, dx		; Time
 35687 00008881 6689D8              <1> 	mov	ax, bx
 35688 00008884 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
 35689 00008888 6683E03F            <1> 	and	ax, 0000111111b	; Minute Mask
 35690 0000888C D40A                <1> 	aam			; Q([AL]/10)->AH
 35691                              <1> 				; R([AL]/10)->AL
 35692                              <1> 				; [AL]+[AH]= Minute as BCD
 35693 0000888E 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
 35694 00008892 86E0                <1> 	xchg	ah, al
 35695 00008894 66A3[43340100]      <1> 	mov	[File_Minute], ax
 35696                              <1> 
 35697                              <1> 	;mov	al, dh
 35698 0000889A 88F8                <1> 	mov	al, bh
 35699 0000889C C0E803              <1> 	shr	al, 3		; shift right 3 times
 35700 0000889F D40A                <1> 	aam			; [AL]+[AH]= Hours as BCD
 35701 000088A1 660D3030            <1> 	or	ax, '00'
 35702 000088A5 86E0                <1> 	xchg	ah, al
 35703 000088A7 66A3[40340100]      <1> 	mov     [File_Hour], ax
 35704                              <1> 
 35705 000088AD C1EB10              <1> 	shr	ebx, 16		; BX = Date
 35706                              <1> 	
 35707                              <1> Dir_Date_start:
 35708                              <1> 	;mov	ax, bx		; Date
 35709                              <1> 	; 27/07/2022
 35710 000088B0 89D8                <1> 	mov	eax, ebx
 35711 000088B2 6683E01F            <1> 	and	ax, 00011111b	; Day Mask
 35712 000088B6 D40A                <1> 	aam			; Q([AL]/10)->AH
 35713                              <1> 				; R([AL]/10)->AL
 35714                              <1> 				; [AL]+[AH]= Day as BCD
 35715 000088B8 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
 35716 000088BC 86C4                <1> 	xchg	al, ah
 35717                              <1> 
 35718 000088BE 66A3[35340100]      <1> 	mov	[File_Day], ax
 35719                              <1> 
 35720                              <1> 	;mov	ax, bx
 35721                              <1> 	; 27/07/2022
 35722 000088C4 89D8                <1> 	mov	eax, ebx
 35723                              <1> 	;shr	ax, 5		; shift right 5 times
 35724 000088C6 C1E805              <1> 	shr	eax, 5
 35725 000088C9 6683E00F            <1> 	and	ax, 00001111b	; Month Mask
 35726 000088CD D40A                <1> 	aam
 35727 000088CF 660D3030            <1> 	or	ax, '00'
 35728 000088D3 86E0                <1> 	xchg	ah, al
 35729 000088D5 66A3[38340100]      <1> 	mov	[File_Month], ax
 35730                              <1> 
 35731                              <1> 	;mov	ax, bx
 35732                              <1> 	; 27/07/2022
 35733 000088DB 89D8                <1> 	mov	eax, ebx
 35734                              <1> 	;shr	ax, 9
 35735 000088DD C1E809              <1> 	shr	eax, 9
 35736 000088E0 6683E07F            <1> 	and	ax, 01111111b	; Result = Year - 1980
 35737 000088E4 6605BC07            <1> 	add	ax, 1980
 35738                              <1> 
 35739 000088E8 B10A                <1> 	mov	cl, 10
 35740 000088EA F6F1                <1> 	div	cl		; Q -> AL, R -> AH 
 35741 000088EC 80CC30              <1> 	or	ah, '0'
 35742 000088EF 8825[3E340100]      <1> 	mov	[File_Year+3], ah
 35743 000088F5 D40A                <1> 	aam
 35744 000088F7 86E0                <1> 	xchg	ah, al
 35745 000088F9 80CC30              <1> 	or	ah, '0'	  ; Convert to ASCII
 35746 000088FC 8825[3D340100]      <1> 	mov	[File_Year+2], ah
 35747 00008902 D40A                <1> 	aam
 35748 00008904 86C4                <1> 	xchg	al, ah
 35749 00008906 660D3030            <1> 	or	ax, '00'
 35750 0000890A 66A3[3B340100]      <1> 	mov	[File_Year], ax
 35751                              <1> 
 35752                              <1> loc_show_line:
 35753 00008910 56                  <1> 	push	esi
 35754 00008911 BE[18340100]        <1> 	mov     esi, File_Name
 35755 00008916 E80FE3FFFF          <1> 	call	print_msg
 35756 0000891B BE[0F3B0100]        <1> 	mov	esi, nextline
 35757 00008920 E805E3FFFF          <1> 	call	print_msg
 35758 00008925 5E                  <1> 	pop	esi
 35759                              <1> 
 35760 00008926 FE0D[81810100]      <1> 	dec	byte [PrintDir_RowCounter]
 35761 0000892C 740C                <1> 	jz	short pause_dir_scroll ; 27/07/2022
 35762                              <1> 
 35763                              <1> loc_next_entry:
 35764 0000892E E88B010000          <1> 	call	find_next_file
 35765                              <1> 	;jnc	loc_dfname_use_this
 35766                              <1> 	; 27/07/2022
 35767 00008933 7219                <1> 	jc	short loc_dir_ok
 35768 00008935 E999FEFFFF          <1> 	jmp	loc_dfname_use_this
 35769                              <1> 
 35770                              <1> 	; 27/07/2022
 35771                              <1> pause_dir_scroll:
 35772 0000893A 28E4                <1> 	sub	ah, ah           
 35773 0000893C E88D85FFFF          <1> 	call	int16h
 35774 00008941 3C1B                <1> 	cmp	al, 1Bh
 35775 00008943 7409                <1> 	je	short loc_dir_ok
 35776 00008945 C605[81810100]10    <1> 	mov	byte [PrintDir_RowCounter], 16 ; Reset counter
 35777 0000894C EBE0                <1>         jmp     short loc_next_entry
 35778                              <1> 
 35779                              <1> loc_dir_ok:
 35780 0000894E B90A000000          <1> 	mov     ecx, 10
 35781                              <1> 	;mov	ax, [Dir_Count]
 35782                              <1> 	; 27/07/2022
 35783 00008953 0FB705[6C810100]    <1> 	movzx	eax, word [Dir_Count]
 35784 0000895A BF[59340100]        <1> 	mov	edi, Decimal_Dir_Count
 35785                              <1> 	;cmp	ax, cx ; 10
 35786                              <1> 	; 27/07/2022
 35787 0000895F 39C8                <1> 	cmp	eax, ecx
 35788 00008961 7216                <1> 	jb	short pass_ddc
 35789 00008963 47                  <1> 	inc	edi
 35790 00008964 6683F864            <1> 	cmp	ax, 100
 35791 00008968 720F                <1> 	jb	short pass_ddc
 35792 0000896A 47                  <1> 	inc	edi
 35793 0000896B 663DE803            <1> 	cmp	ax, 1000
 35794 0000896F 7208                <1> 	jb	short pass_ddc
 35795 00008971 47                  <1> 	inc	edi
 35796 00008972 663D1027            <1> 	cmp	ax, 10000
 35797 00008976 7201                <1> 	jb	short pass_ddc
 35798 00008978 47                  <1> 	inc	edi
 35799                              <1> pass_ddc:
 35800 00008979 886F01              <1> 	mov     [edi+1], ch ; 0
 35801                              <1> loc_ddc_rediv:
 35802 0000897C 31D2                <1> 	xor     edx, edx
 35803                              <1> 	;div	cx  ; 10
 35804                              <1> 	; 27/07/2022
 35805 0000897E F7F1                <1> 	div	ecx
 35806 00008980 80C230              <1> 	add     dl, '0'
 35807 00008983 8817                <1> 	mov     [edi], dl
 35808 00008985 4F                  <1> 	dec     edi
 35809                              <1> 	;or	ax, ax
 35810                              <1> 	; 27/07/2022
 35811 00008986 09C0                <1> 	or	eax, eax
 35812 00008988 75F2                <1> 	jnz	short loc_ddc_rediv
 35813                              <1> 
 35814 0000898A 66A1[6A810100]      <1> 	mov     ax, [File_Count]
 35815 00008990 BF[48340100]        <1> 	mov     edi, Decimal_File_Count
 35816                              <1> 	;cmp	ax, cx ; 10
 35817                              <1> 	; 27/07/2022
 35818 00008995 39C8                <1> 	cmp	eax, ecx ; 10
 35819 00008997 7216                <1> 	jb      short pass_dfc
 35820 00008999 47                  <1> 	inc     edi
 35821 0000899A 6683F864            <1> 	cmp     ax, 100
 35822 0000899E 720F                <1> 	jb      short pass_dfc
 35823 000089A0 47                  <1> 	inc     edi
 35824 000089A1 663DE803            <1> 	cmp     ax, 1000
 35825 000089A5 7208                <1> 	jb      short pass_dfc
 35826 000089A7 47                  <1> 	inc     edi
 35827 000089A8 663D1027            <1> 	cmp     ax, 10000
 35828 000089AC 7201                <1> 	jb      short pass_dfc
 35829 000089AE 47                  <1> 	inc     edi
 35830                              <1> pass_dfc:
 35831                              <1> 	;mov    cx, 10
 35832 000089AF 886F01              <1> 	mov     [edi+1], ch ; 00
 35833                              <1> loc_dfc_rediv:
 35834                              <1> 	;;xor	dx, dx
 35835                              <1> 	;xor	dl, dl
 35836                              <1> 	;div	cx
 35837                              <1> 	; 27/07/022
 35838 000089B2 31D2                <1> 	xor	edx, edx
 35839 000089B4 F7F1                <1> 	div	ecx
 35840 000089B6 80C230              <1> 	add	dl, '0'
 35841 000089B9 8817                <1> 	mov	[edi], dl
 35842 000089BB 4F                  <1> 	dec	edi
 35843                              <1> 	;or	ax, ax
 35844                              <1> 	; 27/07/2022
 35845 000089BC 09C0                <1> 	or	eax, eax
 35846 000089BE 75F2                <1> 	jnz	short loc_dfc_rediv
 35847                              <1> 
 35848 000089C0 BF[80810100]        <1> 	mov     edi, TFS_Dec_End
 35849                              <1>         ;mov    byte [edi], 0
 35850 000089C5 A1[6E810100]        <1> 	mov     eax, [Total_FSize]
 35851                              <1> 	;mov    ecx, 10
 35852                              <1> rediv_tfs_hex:
 35853 000089CA 29D2                <1> 	sub	edx, edx ; 27/07/2022
 35854                              <1> 	;sub	dl, dl
 35855 000089CC F7F1                <1> 	div	ecx
 35856 000089CE 80C230              <1> 	add	dl, '0'
 35857 000089D1 4F                  <1> 	dec     edi
 35858 000089D2 8817                <1> 	mov     [edi], dl
 35859 000089D4 21C0                <1> 	and	eax, eax
 35860 000089D6 75F2                <1> 	jnz	short rediv_tfs_hex
 35861                              <1> 	
 35862 000089D8 893D[72810100]      <1> 	mov	[TFS_Dec_Begin], edi
 35863 000089DE BE[46340100]        <1> 	mov	esi, Decimal_File_Count_Header
 35864 000089E3 E842E2FFFF          <1> 	call	print_msg
 35865 000089E8 BE[4E340100]        <1> 	mov	esi, str_files
 35866 000089ED E838E2FFFF          <1> 	call	print_msg
 35867 000089F2 BE[5F340100]        <1> 	mov	esi, str_dirs
 35868 000089F7 E82EE2FFFF          <1> 	call	print_msg
 35869 000089FC 8B35[72810100]      <1> 	mov	esi, [TFS_Dec_Begin]
 35870 00008A02 E823E2FFFF          <1> 	call	print_msg
 35871 00008A07 BE[70340100]        <1> 	mov	esi, str_bytes
 35872                              <1> 	;call	print_msg
 35873                              <1> 	;retn
 35874                              <1> 	; 27/07/2022
 35875 00008A0C E919E2FFFF          <1> 	jmp	print_msg
 35876                              <1> 
 35877                              <1> find_first_file:
 35878                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 35879                              <1> 	; 11/02/2016
 35880                              <1> 	; 10/02/2016
 35881                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
 35882                              <1> 	; 09/10/2011
 35883                              <1> 	; 17/09/2009
 35884                              <1> 	; 2005
 35885                              <1> 	; INPUT ->
 35886                              <1> 	;	ESI = ASCIIZ File/Dir Name Address (in Current Directory)
 35887                              <1> 	;	AL = Attributes AND mask (The AND result must be equal to AL)
 35888                              <1> 	;	      bit 0 = Read Only
 35889                              <1> 	;	      bir 1 = Hidden
 35890                              <1> 	;	      bit 2 = System
 35891                              <1> 	;	      bit 3 = Volume Label
 35892                              <1> 	;	      bit 4 = Directory
 35893                              <1> 	;	      bit 5 = Archive
 35894                              <1> 	;	      bit 6 = Reserved, must be 0
 35895                              <1> 	;	      bit 7 = Reserved, must be 0
 35896                              <1> 	;       AH = Attributes Negative AND mask (The AND result must be ZERO)
 35897                              <1> 	;
 35898                              <1> 	; OUTPUT ->
 35899                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
 35900                              <1> 	;	CF = 0 ->
 35901                              <1> 	;	     ESI = Directory Entry (FindFile_DirEntry) Location
 35902                              <1> 	;	     EDI = Directory Buffer Directory Entry Location
 35903                              <1> 	;	     EAX = File Size
 35904                              <1> 	;	      BL = Attributes of The File/Directory
 35905                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
 35906                              <1> 	;             DX > 0 : Ambiguous filename chars are used
 35907                              <1> 	;
 35908                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
 35909                              <1> 
 35910 00008A11 66A3[32810100]      <1> 	mov	[FindFile_AttributesMask], ax
 35911 00008A17 BF[34810100]        <1> 	mov	edi, FindFile_DirEntry ; TR-DOS Fullfilename formatted buffer
 35912 00008A1C 31C0                <1> 	xor	eax, eax
 35913                              <1> 	;mov	ecx, 11
 35914                              <1> 	; 28/07/2022
 35915 00008A1E 31C9                <1> 	xor	ecx, ecx
 35916 00008A20 B10B                <1> 	mov	cl, 11
 35917 00008A22 F3AB                <1> 	rep	stosd	; 44 bytes
 35918                              <1> 	;stosw		; +2 bytes 
 35919                              <1> 	    
 35920 00008A24 BF[24810100]        <1> 	mov	edi, FindFile_Name ; FFF structure, offset 66
 35921 00008A29 39FE                <1> 	cmp	esi, edi
 35922 00008A2B 7408                <1> 	je	short loc_fff_mfn_ok
 35923 00008A2D 89FA                <1> 	mov	edx, edi 
 35924                              <1> 	; move 13 bytes
 35925 00008A2F A5                  <1> 	movsd
 35926 00008A30 A5                  <1> 	movsd
 35927 00008A31 A5                  <1> 	movsd
 35928 00008A32 AA                  <1> 	stosb
 35929 00008A33 89D6                <1> 	mov	esi, edx
 35930                              <1> loc_fff_mfn_ok:
 35931 00008A35 BF[D3800100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
 35932 00008A3A E8CE1F0000          <1> 	call	convert_file_name
 35933 00008A3F 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
 35934                              <1> 
 35935 00008A41 66A1[32810100]      <1> 	mov	ax, [FindFile_AttributesMask]
 35936                              <1> 	;xor	ecx, ecx
 35937 00008A47 30C9                <1> 	xor	cl, cl  
 35938 00008A49 E8F01C0000          <1> 	call	locate_current_dir_file
 35939 00008A4E 726D                <1> 	jc	short loc_fff_retn
 35940                              <1> 	; EDI = Directory Entry
 35941                              <1> 	; EBX = Directory Buffer Entry Index/Number
 35942                              <1> 
 35943                              <1> loc_fff_fnf_ln_check:
 35944 00008A50 30ED                <1> 	xor	ch, ch 
 35945 00008A52 80F60F              <1> 	xor	dh, 0Fh
 35946 00008A55 7408                <1> 	jz	short loc_fff_longname_yes
 35947 00008A57 882D[31810100]      <1> 	mov	[FindFile_LongNameYes], ch ; 0
 35948 00008A5D EB0C                <1> 	jmp	short loc_fff_longname_no
 35949                              <1> 
 35950                              <1> loc_fff_longname_yes:
 35951                              <1> 	;inc	byte [FindFile_LongNameYes]
 35952 00008A5F 8A0D[3E800100]      <1> 	mov	cl, [LFN_EntryLength]  
 35953 00008A65 880D[31810100]      <1> 	mov	[FindFile_LongNameEntryLength], cl ; FindFile_LongNameYes
 35954                              <1> 
 35955                              <1> loc_fff_longname_no:
 35956                              <1> 	;mov	bx, [DirBuff_CurrentEntry]
 35957 00008A6B 66891D[5C810100]    <1> 	mov	[FindFile_DirEntryNumber], bx
 35958                              <1> 	;mov	dx, ax ; Ambiguous Filename chars used sign > 0
 35959                              <1> 	; 28/07/2022
 35960 00008A72 89C2                <1> 	mov	edx, eax
 35961                              <1> 
 35962 00008A74 A0[42780100]        <1> 	mov	al, [Current_Drv]
 35963 00008A79 A2[E2800100]        <1> 	mov	[FindFile_Drv], al 
 35964                              <1> 
 35965 00008A7E A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 35966 00008A83 A3[54810100]        <1> 	mov	[FindFile_DirFirstCluster], eax
 35967                              <1> 
 35968 00008A88 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 35969 00008A8D A3[58810100]        <1> 	mov	[FindFile_DirCluster], eax
 35970                              <1> 
 35971 00008A92 66FF05[5E810100]    <1> 	inc	word [FindFile_MatchCounter]
 35972                              <1> 
 35973 00008A99 89FB                <1> 	mov	ebx, edi
 35974 00008A9B 89FE                <1> 	mov	esi, edi
 35975 00008A9D BF[34810100]        <1> 	mov	edi, FindFile_DirEntry
 35976 00008AA2 89F8                <1> 	mov	eax, edi
 35977 00008AA4 B108                <1> 	mov	cl, 8
 35978 00008AA6 F3A5                <1> 	rep	movsd
 35979 00008AA8 89C6                <1> 	mov	esi, eax
 35980 00008AAA 89DF                <1> 	mov	edi, ebx
 35981                              <1> 
 35982 00008AAC A1[50810100]        <1> 	mov	eax, [FindFile_DirEntry+28] ; File Size
 35983                              <1> 
 35984 00008AB1 8A1D[3F810100]      <1> 	mov	bl, [FindFile_DirEntry+11] ; File Attributes 
 35985 00008AB7 8A3D[31810100]      <1> 	mov	bh, [FindFile_LongNameYes]
 35986                              <1> 
 35987                              <1> 	;mov	cx, [DirBuff_EntryCounter]
 35988                              <1> 	;mov	[FindFile_DirEntryNumber], cx
 35989                              <1> 	;mov	cx, [FindFile_DirEntryNumber]
 35990                              <1> 	; ecx = 0
 35991                              <1> 
 35992                              <1> loc_fff_retn:
 35993 00008ABD C3                  <1> 	retn
 35994                              <1> 
 35995                              <1> find_next_file:
 35996                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 35997                              <1> 	; 15/10/2016
 35998                              <1> 	; 10/02/2016
 35999                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
 36000                              <1> 	; 06/02/2011
 36001                              <1> 	; 17/09/2009
 36002                              <1> 	; 2005
 36003                              <1> 	; INPUT ->
 36004                              <1> 	;	NONE, Find First File Parameters
 36005                              <1> 	; OUTPUT ->
 36006                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
 36007                              <1> 	;	CF = 0 -> 
 36008                              <1> 	;	    ESI = Directory Entry (FindFile_DirEntry) Location
 36009                              <1> 	;	    EDI = Directory Buffer Directory Entry Location
 36010                              <1> 	;	    EAX = File Size
 36011                              <1> 	;	      BL = Attributes of The File/Directory
 36012                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
 36013                              <1> 	;             DX > 0 : Ambiguous filename chars are used 
 36014                              <1> 	;
 36015                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
 36016                              <1> 
 36017 00008ABE 66833D[5E810100]00  <1> 	cmp	word [FindFile_MatchCounter], 0
 36018 00008AC6 7707                <1> 	ja	short loc_start_search_next_file
 36019                              <1> 
 36020                              <1> loc_fnf_stc_retn:
 36021 00008AC8 F9                  <1> 	stc
 36022                              <1> loc_fnf_ax12h_retn:
 36023 00008AC9 B80C000000          <1> 	mov	eax, 12 ; No More files
 36024                              <1> ;loc_fnf_retn:
 36025 00008ACE C3                  <1> 	retn
 36026                              <1> 
 36027                              <1> loc_start_search_next_file:
 36028 00008ACF 668B1D[5C810100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
 36029                              <1> 	;inc	bx
 36030                              <1> 	; 28/07/2022
 36031 00008AD6 43                  <1> 	inc	ebx
 36032 00008AD7 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 36033 00008ADE 7719                <1> 	ja	short loc_cont_search_next_file
 36034                              <1> 
 36035                              <1> loc_fnf_search:
 36036 00008AE0 BE[D3800100]        <1> 	mov	esi, Dir_Entry_Name
 36037 00008AE5 66A1[32810100]      <1> 	mov	ax, [FindFile_AttributesMask]
 36038                              <1> 	;xor	cx, cx
 36039                              <1> 	; 28/07/2022
 36040 00008AEB 31C9                <1> 	xor	ecx, ecx
 36041 00008AED E84A1D0000          <1> 	call	find_directory_entry
 36042                              <1> 	;jnc	loc_fff_fnf_ln_check
 36043                              <1> 	; 28/07/2022
 36044 00008AF2 7205                <1> 	jc	short loc_cont_search_next_file
 36045 00008AF4 E957FFFFFF          <1> 	jmp	loc_fff_fnf_ln_check
 36046                              <1> 
 36047                              <1> loc_cont_search_next_file:
 36048 00008AF9 31DB                <1> 	xor	ebx, ebx
 36049 00008AFB 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 36050 00008B01 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 36051 00008B06 01DE                <1> 	add	esi, ebx
 36052                              <1> 
 36053 00008B08 803D[40780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
 36054 00008B0F 7608                <1> 	jna	short loc_fnf_check_FAT_type
 36055 00008B11 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
 36056 00008B15 72B2                <1> 	jb	short loc_fnf_ax12h_retn
 36057 00008B17 EB06                <1> 	jmp	short loc_fnf_check_next_cluster
 36058                              <1>  
 36059                              <1> loc_fnf_check_FAT_type:
 36060 00008B19 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
 36061 00008B1D 72AA                <1> 	jb	short loc_fnf_ax12h_retn
 36062                              <1> 
 36063                              <1> loc_fnf_check_next_cluster:
 36064 00008B1F A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 36065 00008B24 E861360000          <1> 	call	get_next_cluster
 36066 00008B29 7306                <1> 	jnc	short loc_fnf_load_next_dir_cluster
 36067 00008B2B 09C0                <1> 	or	eax, eax
 36068 00008B2D 7499                <1> 	jz	short loc_fnf_stc_retn
 36069                              <1> 	;mov	eax, 17 ;Drive not ready or read error
 36070 00008B2F F5                  <1>  	cmc	;stc
 36071                              <1> loc_fnf_retn:
 36072 00008B30 C3                  <1> 	retn
 36073                              <1> 
 36074                              <1> loc_fnf_load_next_dir_cluster:
 36075 00008B31 E810380000          <1> 	call	load_FAT_sub_directory
 36076 00008B36 72F8                <1> 	jc	short loc_fnf_retn
 36077                              <1> 	;xor	bx, bx
 36078                              <1> 	; 28/07/2022
 36079 00008B38 31DB                <1> 	xor	ebx, ebx
 36080 00008B3A 66891D[5C810100]    <1> 	mov	[FindFile_DirEntryNumber], bx
 36081 00008B41 EB9D                <1> 	jmp	short loc_fnf_search
 36082                              <1> 
 36083                              <1> get_and_print_longname:
 36084                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36085                              <1> 	; 16/10/2016
 36086                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
 36087                              <1> 	; 24/01/2010
 36088                              <1> 	; 17/10/2009 (CMD_INTR.ASM, 'cmp_cmd_longname')
 36089                              <1> get_longname_fchar:
 36090 00008B43 803E20              <1> 	cmp	byte [esi], 20h
 36091 00008B46 7701                <1> 	ja	short loc_find_longname
 36092                              <1> 	;jb	short loc_longname_retn
 36093                              <1> 	;inc	esi
 36094                              <1> 	;je	short get_longname_fchar
 36095                              <1> ;loc_longname_retn:
 36096 00008B48 C3                  <1> 	retn
 36097                              <1> loc_find_longname:
 36098 00008B49 E82C200000          <1> 	call	find_longname
 36099 00008B4E 731D                <1> 	jnc	short loc_print_longname
 36100                              <1> 	
 36101 00008B50 08C0                <1> 	or	al, al
 36102 00008B52 7412                <1> 	jz	short loc_longname_not_found
 36103                              <1> 	  
 36104                              <1> 	; 16/10/2016 (15h -> 15, 17)
 36105 00008B54 3C0F                <1> 	cmp	al, 15
 36106                              <1> 	;je	cd_drive_not_ready ; drive not ready
 36107                              <1> 	; 28/07/2022
 36108 00008B56 7505                <1> 	jne	short loc_fln_err2
 36109                              <1> loc_fln_err1:
 36110 00008B58 E963F8FFFF          <1> 	jmp	cd_drive_not_ready	
 36111                              <1> loc_fln_err2:
 36112                              <1> 				   ; or
 36113 00008B5D 3C11                <1> 	cmp	al, 17		   ; read error	
 36114                              <1> 	;je	cd_drive_not_ready
 36115                              <1> 	; 28/07/2022
 36116                              <1> 	;je	short loc_fln_err1 
 36117                              <1> 
 36118                              <1> loc_ln_file_dir_not_found:
 36119 00008B5F BE[9B330100]        <1> 	mov	esi, Msg_File_Directory_Not_Found
 36120                              <1> 	;;call	print_msg
 36121                              <1>         ;;retn
 36122                              <1> 	;jmp	print_msg
 36123                              <1> 	; 28/07/2022
 36124 00008B64 EB2B                <1> 	jmp	short loc_lfn_err3
 36125                              <1> 
 36126                              <1> loc_longname_not_found:
 36127 00008B66 BE[BA330100]        <1>         mov     esi, Msg_LongName_Not_Found
 36128                              <1> 	;;call	print_msg
 36129                              <1>         ;;retn
 36130                              <1> 	;jmp	print_msg
 36131                              <1> 	; 28/07/2022
 36132 00008B6B EB24                <1> 	jmp	short loc_lfn_err3
 36133                              <1> 
 36134                              <1> loc_print_longname:
 36135                              <1> 	;mov	esi, LongFileName
 36136 00008B6D BF[42790100]        <1> 	mov	edi, TextBuffer
 36137 00008B72 57                  <1> 	push	edi 
 36138 00008B73 3C00                <1> 	cmp	al, 0
 36139 00008B75 7708                <1> 	ja	short loc_print_longname_1
 36140                              <1> loc_print_FS_longname: ; Singlix FS (64 byte ASCIIZ file name)
 36141 00008B77 AC                  <1> 	lodsb
 36142 00008B78 AA                  <1> 	stosb  
 36143 00008B79 08C0                <1> 	or	al, al
 36144 00008B7B 75FA                <1> 	jnz	short loc_print_FS_longname
 36145 00008B7D EB07                <1> 	jmp	short loc_print_longname_2
 36146                              <1> 	;
 36147                              <1> loc_print_longname_1: ; MS Windows long name (UNICODE chars)
 36148 00008B7F 66AD                <1> 	lodsw
 36149 00008B81 AA                  <1> 	stosb  
 36150 00008B82 08C0                <1> 	or	al, al
 36151 00008B84 75F9                <1> 	jnz	short loc_print_longname_1
 36152                              <1> 	;
 36153                              <1> loc_print_longname_2:	
 36154 00008B86 5E                  <1> 	pop	esi
 36155 00008B87 E89EE0FFFF          <1> 	call	print_msg
 36156 00008B8C BE[0F3B0100]        <1>   	mov	esi, nextline
 36157                              <1> loc_lfn_err3:
 36158                              <1> 	;call	print_msg
 36159                              <1> 	;retn
 36160 00008B91 E994E0FFFF          <1> 	jmp	print_msg	
 36161                              <1> 
 36162                              <1> show_file:
 36163                              <1> 	; 07/08/2022
 36164                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36165                              <1> 	; 18/02/2016
 36166                              <1> 	; 17/02/2016
 36167                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 36168                              <1> 	; 13/09/2011 (CMD_INTR.ASM, 'cmp_cmd_show')
 36169                              <1> 	; 08/11/2009
 36170                              <1> 
 36171                              <1> loc_show_parse_path_name:
 36172 00008B96 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 36173 00008B9B E8371F0000          <1> 	call	parse_path_name
 36174                              <1> 	;jc	loc_cmd_failed
 36175                              <1> 	; 28/07/2022
 36176 00008BA0 7305                <1> 	jnc	short loc_show_check_filename_exists
 36177                              <1> show_file_err1:
 36178 00008BA2 E983F9FFFF          <1> 	jmp	loc_cmd_failed
 36179                              <1> 
 36180                              <1> loc_show_check_filename_exists:
 36181 00008BA7 BE[24810100]        <1> 	mov	esi, FindFile_Name
 36182 00008BAC 803E20              <1> 	cmp	byte [esi], 20h
 36183                              <1> 	;jna	loc_cmd_failed
 36184                              <1> 	; 28/07/2022
 36185 00008BAF 76F1                <1> 	jna	short show_file_err1
 36186                              <1> 
 36187                              <1> 	; 15/02/2016 (invalid file name check)
 36188 00008BB1 E800020000          <1> 	call	check_filename 	
 36189 00008BB6 730A                <1> 	jnc	short loc_show_change_drv
 36190                              <1> 
 36191 00008BB8 BE[86340100]        <1> 	mov	esi, Msg_invalid_name_chars
 36192 00008BBD E968E0FFFF          <1> 	jmp	print_msg
 36193                              <1>    
 36194                              <1> loc_show_change_drv:
 36195 00008BC2 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 36196 00008BC8 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 36197 00008BCE 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 36198 00008BD4 38F2                <1> 	cmp	dl, dh
 36199 00008BD6 740C                <1> 	je	short loc_show_change_directory
 36200 00008BD8 E886EBFFFF          <1> 	call	change_current_drive
 36201                              <1> 	;;jc	loc_file_rw_cmd_failed
 36202                              <1> 	;jc	loc_run_cmd_failed
 36203                              <1> 	; 28/07/2022
 36204 00008BDD 7305                <1> 	jnc	short loc_show_change_directory
 36205                              <1> show_file_err2:
 36206 00008BDF E971F9FFFF          <1> 	jmp	loc_run_cmd_failed
 36207                              <1> 
 36208                              <1> loc_show_change_directory:
 36209 00008BE4 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 36210 00008BEB 7614                <1> 	jna	short loc_findload_showfile
 36211                              <1> 
 36212 00008BED FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 36213 00008BF3 BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 36214 00008BF8 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 36215 00008BFA E8EC180000          <1> 	call	change_current_directory
 36216                              <1> 	;;jc	loc_file_rw_cmd_failed
 36217                              <1> 	;jc	loc_run_cmd_failed
 36218                              <1> 	; 28/07/2022
 36219 00008BFF 72DE                <1> 	jc	short show_file_err2
 36220                              <1> 
 36221                              <1> ;loc_show_change_prompt_dir_string:
 36222                              <1> 	;call	change_prompt_dir_string
 36223                              <1> 
 36224                              <1> loc_findload_showfile:
 36225                              <1> 	; 15/02/2016
 36226 00008C01 BE[24810100]        <1> 	mov	esi, FindFile_Name
 36227 00008C06 BF[D3800100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
 36228 00008C0B E8FD1D0000          <1> 	call	convert_file_name
 36229 00008C10 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
 36230                              <1> 
 36231 00008C12 28C0                <1> 	sub	al, al	; Attrib AND mask = 0
 36232                              <1> 	; Directory attribute : 10h
 36233                              <1> 	; Volume name attribute: 8h
 36234 00008C14 B418                <1> 	mov	ah, 00011000b ; 18h (Attrib NAND, AND --> zero mask)
 36235                              <1> 	;
 36236                              <1> 	;xor	cx, cx  
 36237                              <1> 	; 28/07/2022
 36238 00008C16 31C9                <1> 	xor	ecx, ecx
 36239 00008C18 E8211B0000          <1> 	call	locate_current_dir_file
 36240                              <1> 	;;jc	loc_file_rw_cmd_failed
 36241                              <1> 	;jc	loc_run_cmd_failed
 36242                              <1> 	; 28/07/2022
 36243 00008C1D 72C0                <1> 	jc	short show_file_err2
 36244                              <1> 
 36245                              <1> loc_show_load_file:
 36246                              <1> 	; EDI = Directory Entry
 36247 00008C1F 668B4714            <1> 	mov	ax, [edi+DirEntry_FstClusHI] ; First Cluster High Word
 36248 00008C23 C1E010              <1> 	shl	eax, 16
 36249 00008C26 668B471A            <1> 	mov	ax, [edi+DirEntry_FstClusLO] ; First Cluster Low Word
 36250 00008C2A A3[8C810100]        <1> 	mov	[Show_Cluster], eax
 36251 00008C2F 8B471C              <1> 	mov	eax, [edi+DirEntry_FileSize] ; File Size
 36252 00008C32 21C0                <1> 	and	eax, eax ; Empty file !
 36253                              <1> 	;jz	end_of_show_file
 36254                              <1> 	; 28/07/2022
 36255 00008C34 7505                <1> 	jnz	short loc_show_load_file_set_size
 36256 00008C36 E904010000          <1> 	jmp	end_of_show_file 
 36257                              <1> 
 36258                              <1> loc_show_load_file_set_size: ; 28/07/2022
 36259 00008C3B A3[90810100]        <1> 	mov	[Show_FileSize], eax
 36260 00008C40 31C0                <1> 	xor	eax, eax
 36261 00008C42 A3[94810100]        <1> 	mov	[Show_FilePointer], eax ; 0
 36262 00008C47 66A3[98810100]      <1> 	mov	[Show_ClusterPointer], ax ; 0
 36263 00008C4D 29DB                <1> 	sub	ebx, ebx
 36264 00008C4F 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 36265 00008C55 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 36266 00008C5A 01DE                <1> 	add	esi, ebx
 36267 00008C5C 8935[88810100]      <1> 	mov	[Show_LDDDT], esi ; Logical DOS Drv Description Table addr
 36268                              <1> 
 36269 00008C62 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0	
 36270 00008C66 7713                <1> 	ja	short loc_show_calculate_cluster_size
 36271                              <1> 	; Singlix FS
 36272                              <1> 	; First Cluster Number is FDT number (in compatibility buffer)
 36273 00008C68 8B15[8C810100]      <1> 	mov	edx, [Show_Cluster] ; Compatibility dir. buffer value (FDT)	
 36274 00008C6E 8915[84810100]      <1> 	mov	[Show_FDT], edx
 36275 00008C74 31C0                <1> 	xor	eax, eax
 36276 00008C76 A3[8C810100]        <1> 	mov	[Show_Cluster], eax ; Sector index  = 0
 36277                              <1> 				    ; (next time it will be 1)			
 36278                              <1> loc_show_calculate_cluster_size:
 36279 00008C7B 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec] ; FAT 12-16-32 (512)
 36280                              <1> 	; BX = 512 = [esi+LD_FS_BytesPerSec] ; Singlix FS	
 36281 00008C7F 8A4613              <1> 	mov	al, [esi+LD_BPB+BPB_SecPerClust] ; FAT 12-16-32 (<= 128)
 36282                              <1> 	; AL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
 36283 00008C82 F7E3                <1> 	mul	ebx	
 36284                              <1> 
 36285                              <1> 	;cmp	eax, 65536 ; non-compatible (very big) cluster size
 36286                              <1> 	;ja	short end_of_show_file	
 36287 00008C84 66A3[9A810100]      <1> 	mov	[Show_ClusterSize], ax
 36288                              <1> 
 36289                              <1> loc_start_show_file:
 36290 00008C8A BE[0F3B0100]        <1> 	mov	esi, nextline
 36291 00008C8F E896DFFFFF          <1> 	call	print_msg
 36292                              <1> 
 36293 00008C94 A1[8C810100]        <1> 	mov	eax, [Show_Cluster]
 36294 00008C99 C605[9C810100]17    <1> 	mov	byte [Show_RowCount], 23
 36295                              <1> 
 36296                              <1> 	; 17/02/2016
 36297 00008CA0 8B35[88810100]      <1> 	mov	esi, [Show_LDDDT]
 36298                              <1> 
 36299                              <1> 	; 07/08/2022
 36300                              <1> loc_show_next_cluster:
 36301                              <1> 	; 15/02/2016
 36302 00008CA6 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
 36303                              <1> 	; ESI = Logical DOS drv description table address
 36304 00008CAB E8D1360000          <1> 	call	read_cluster
 36305                              <1> 	;;jc	loc_file_rw_cmd_failed
 36306                              <1> 	;jc	loc_run_cmd_failed
 36307                              <1> 	; 07/08/2022
 36308 00008CB0 7305                <1> 	jnc	short loc_show_nc_rc_ok
 36309 00008CB2 E99EF8FFFF          <1> 	jmp	loc_run_cmd_failed
 36310                              <1> loc_show_nc_rc_ok:
 36311 00008CB7 31DB                <1> 	xor 	ebx, ebx
 36312                              <1> loc_show_next_byte:
 36313 00008CB9 803D[9C810100]00    <1> 	cmp	byte [Show_RowCount], 0
 36314 00008CC0 7512                <1> 	jne	short pass_show_wait_for_key
 36315 00008CC2 30E4                <1> 	xor	ah, ah
 36316 00008CC4 E80582FFFF          <1> 	call	int16h
 36317 00008CC9 3C1B                <1> 	cmp	al, 1Bh
 36318                              <1> 	;jne	short pass_exit_show
 36319                              <1> 	; 28/07/2022
 36320 00008CCB 7472                <1> 	je	short end_of_show_file
 36321                              <1> 
 36322                              <1> ;end_of_show_file:
 36323                              <1> ;pass_show_file:
 36324                              <1> ;	mov	esi, nextline
 36325                              <1> ;	call	print_msg
 36326                              <1> ;	jmp	loc_file_rw_restore_retn
 36327                              <1> 
 36328                              <1> pass_exit_show:
 36329 00008CCD C605[9C810100]14    <1> 	mov	byte [Show_RowCount], 20
 36330                              <1> pass_show_wait_for_key:
 36331 00008CD4 81C300000700        <1> 	add	ebx, Cluster_Buffer
 36332 00008CDA 8A03                <1> 	mov	al, [ebx]
 36333 00008CDC 3C0D                <1> 	cmp	al, 0Dh
 36334                              <1>  	;jne	loc_show_check_tab_space
 36335                              <1> 	; 28/07/2022
 36336 00008CDE 740B                <1> 	je	short loc_show_dec_row_count
 36337 00008CE0 E991000000          <1> 	jmp	loc_show_check_tab_space
 36338                              <1> 
 36339                              <1> 	; 07/08/2022
 36340                              <1> loc_show_next:
 36341                              <1> 	;and	bx, bx ; 65536 -> 0
 36342                              <1> 	; 28/07/2022
 36343 00008CE5 21DB                <1> 	and	ebx, ebx
 36344 00008CE7 75D0                <1> 	jnz	short loc_show_next_byte
 36345 00008CE9 EBBB                <1> 	jmp     short loc_show_next_cluster
 36346                              <1> 
 36347                              <1> loc_show_dec_row_count:	; 28/07/2022
 36348 00008CEB FE0D[9C810100]      <1> 	dec	byte [Show_RowCount]
 36349                              <1> pass_show_dec_rowcount:
 36350 00008CF1 B307                <1> 	mov	bl, 7 ; (light gray character color, black background)
 36351 00008CF3 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
 36352 00008CF9 E82095FFFF          <1> 	call	_write_tty
 36353                              <1> loc_show_check_eof:
 36354 00008CFE FF05[94810100]      <1> 	inc	dword [Show_FilePointer]
 36355 00008D04 A1[94810100]        <1> 	mov	eax, [Show_FilePointer]
 36356 00008D09 3B05[90810100]      <1> 	cmp	eax, [Show_FileSize]
 36357 00008D0F 732E                <1> 	jnb	short end_of_show_file
 36358 00008D11 66FF05[98810100]    <1> 	inc	word [Show_ClusterPointer]
 36359 00008D18 0FB71D[98810100]    <1> 	movzx	ebx, word [Show_ClusterPointer]
 36360                              <1> 
 36361                              <1> 	; 17/02/2016
 36362                              <1> 	; (sector boundary -9 bits- check, 512 = 0)
 36363 00008D1F 66F7C3FF01          <1>         test    bx, 1FFh ; 1 to 511
 36364 00008D24 7593                <1> 	jnz	short loc_show_next_byte
 36365                              <1> 
 36366                              <1> 	; 16/02/2016
 36367 00008D26 8B35[88810100]      <1> 	mov	esi, [Show_LDDDT]
 36368                              <1> 	;
 36369 00008D2C 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 36370 00008D30 771C                <1> 	ja	short loc_show_check_fat_cluster_size
 36371                              <1> 
 36372                              <1> 	; Singlix FS
 36373                              <1> 	; 1 sector, more... (cluster size = 1 sector)
 36374 00008D32 A1[8C810100]        <1> 	mov	eax, [Show_Cluster]
 36375 00008D37 40                  <1> 	inc	eax
 36376 00008D38 A3[8C810100]        <1> 	mov	[Show_Cluster], eax
 36377                              <1> 
 36378                              <1> 	; 07/08/2022
 36379 00008D3D EBA6                <1> 	jmp	short loc_show_next
 36380                              <1> 
 36381                              <1> 	; 28/07/2022
 36382                              <1> end_of_show_file:
 36383                              <1> pass_show_file:
 36384 00008D3F BE[0F3B0100]        <1> 	mov	esi, nextline
 36385 00008D44 E8E1DEFFFF          <1> 	call	print_msg
 36386 00008D49 E9D7000000          <1> 	jmp	loc_file_rw_restore_retn
 36387                              <1> 	 
 36388                              <1> loc_show_check_fat_cluster_size:
 36389                              <1> 	; 17/02/2016
 36390 00008D4E 663B1D[9A810100]    <1> 	cmp	bx, [Show_ClusterSize] ; cluster size in bytes
 36391                              <1>         ;jb	short loc_show_next_byte ; 28/07/2022
 36392                              <1> 	; 07/08/2022
 36393 00008D55 7305                <1> 	jnb	short loc_show_file_cluster_ok
 36394 00008D57 E95DFFFFFF          <1> 	jmp	loc_show_next_byte
 36395                              <1> 
 36396                              <1> loc_show_file_cluster_ok:
 36397 00008D5C 66C705[98810100]00- <1> 	mov	word [Show_ClusterPointer], 0
 36398 00008D64 00                  <1>
 36399                              <1> 
 36400 00008D65 A1[8C810100]        <1> 	mov	eax, [Show_Cluster]
 36401                              <1> 	;mov	esi, [Show_LDDDT]
 36402                              <1> loc_show_get_next_cluster:
 36403 00008D6A E81B340000          <1> 	call	get_next_cluster
 36404                              <1> 	;;jc	loc_file_rw_cmd_failed
 36405                              <1> 	;jc	loc_run_cmd_failed
 36406                              <1> 	; 28/07/2022
 36407 00008D6F 733B                <1> 	jnc	short loc_show_update_ccluster
 36408 00008D71 E9DFF7FFFF          <1> 	jmp	loc_run_cmd_failed
 36409                              <1> 
 36410                              <1> loc_show_check_tab_space:
 36411 00008D76 3C09                <1> 	cmp	al, 09h
 36412                              <1> 	;jne	short pass_show_dec_rowcount ; 28/07/2022
 36413                              <1> 	; 07/08/2022
 36414 00008D78 7405                <1> 	je	short loc_show_put_tab_space
 36415 00008D7A E972FFFFFF          <1> 	jmp	pass_show_dec_rowcount
 36416                              <1> loc_show_put_tab_space:
 36417 00008D7F 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
 36418 00008D85 E83291FFFF          <1> 	call	get_cpos
 36419                              <1> 	; dl = cursor column
 36420 00008D8A 80E207              <1> 	and	dl, 7 ; 18/02/2016
 36421                              <1> 	;shr	bh, 1 ; [ACTIVE_PAGE]
 36422 00008D8D 8A3D[AE770100]      <1> 	mov	bh, [ACTIVE_PAGE]
 36423 00008D93 B307                <1> 	mov	bl, 7 ; color attribute
 36424                              <1> loc_show_put_space_chars:
 36425 00008D95 B020                <1> 	mov	al, 20h ; space
 36426                              <1> 	;mov	bh, [ACTIVE_PAGE] ; [ptty]
 36427                              <1> 	;mov	bl, 7 ; color attribute
 36428                              <1> 	;push	dx
 36429 00008D97 52                  <1> 	push	edx ; 29/12/2017
 36430 00008D98 E88194FFFF          <1> 	call	_write_tty
 36431 00008D9D 5A                  <1> 	pop	edx ; 29/12/2017
 36432                              <1> 	;pop	dx
 36433                              <1> 	; 18/02/2016
 36434 00008D9E 80FA07              <1> 	cmp	dl, 7
 36435                              <1> 	;jnb	short loc_show_check_eof ; 28/07/2022
 36436                              <1> 	; 07/08/2022
 36437 00008DA1 7205                <1> 	jb	short loc_show_next_tab_space
 36438 00008DA3 E956FFFFFF          <1> 	jmp	loc_show_check_eof
 36439                              <1> loc_show_next_tab_space:
 36440 00008DA8 FEC2                <1> 	inc	dl
 36441 00008DAA EBE9                <1> 	jmp	short loc_show_put_space_chars
 36442                              <1> 
 36443                              <1> loc_show_update_ccluster:
 36444 00008DAC A3[8C810100]        <1> 	mov	[Show_Cluster], eax
 36445 00008DB1 E9F0FEFFFF          <1>         jmp     loc_show_next_cluster
 36446                              <1> 
 36447                              <1> check_filename:
 36448                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36449                              <1> 	; 10/10/2016
 36450                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 36451                              <1> 	; 07/08/2010 (FILE.ASM, 'proc_check_filename')
 36452                              <1> 	; 10/07/2010
 36453                              <1> 	; Derived from 'proc_check_filename'
 36454                              <1> 	; in the old TRDOS.ASM (09/02/2005).
 36455                              <1> 	;
 36456                              <1> 	; INPUT -> 
 36457                              <1> 	;	ESI = Dot File Name Location
 36458                              <1> 	; OUTPUT ->
 36459                              <1> 	;	cf = 1 -> error code in AL
 36460                              <1> 	;	     AL = ERR_INV_FILE_NAME (=26)
 36461                              <1> 	;		  Invalid file name chars   
 36462                              <1> 	;	cf = 0 -> valid file name
 36463                              <1> 	; 
 36464                              <1> 	; (EAX, ECX, EDI will be changed)
 36465                              <1> 
 36466                              <1> check_invalid_filename_chars:
 36467                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36468                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 36469                              <1> 	; 10/07/2010 (FILE.ASM, 'proc_check_invalid_filename_chars')
 36470                              <1> 	; 10/02/2010
 36471                              <1> 	; Derived from 'proc_check_invalid_filename_chars'
 36472                              <1> 	; in the old TRDOS.ASM (09/02/2005).
 36473                              <1> 	;
 36474                              <1> 	; INPUT -> 
 36475                              <1> 	;	ESI = ASCIIZ FileName
 36476                              <1> 	; OUTPUT ->
 36477                              <1> 	;	cf = 1 -> invalid
 36478                              <1> 	;	cf = 0 -> valid
 36479                              <1> 	; 
 36480                              <1> 	;(EAX, ECX, EDI will be changed)
 36481                              <1>   
 36482 00008DB6 56                  <1> 	push	esi
 36483                              <1> 
 36484 00008DB7 BF[6F310100]        <1>         mov     edi, invalid_fname_chars
 36485 00008DBC AC                  <1> 	lodsb
 36486                              <1> check_filename_next_char:
 36487 00008DBD B914000000          <1> 	mov	ecx, sizeInvFnChars
 36488 00008DC2 BF[6F310100]        <1> 	mov	edi, invalid_fname_chars
 36489                              <1> loc_scan_invalid_filename_char:
 36490 00008DC7 AE                  <1> 	scasb 
 36491 00008DC8 741E                <1> 	je	short loc_invalid_filename_stc 
 36492 00008DCA E2FB                <1> 	loop	loc_scan_invalid_filename_char
 36493 00008DCC AC                  <1> 	lodsb
 36494 00008DCD 3C1F                <1> 	cmp	al, 1Fh  ; 20h and above 
 36495 00008DCF 77EC                <1> 	ja	short check_filename_next_char
 36496                              <1> 
 36497                              <1> check_filename_dot:
 36498 00008DD1 8B3424              <1> 	mov	esi, [esp]
 36499                              <1> 
 36500 00008DD4 B421                <1> 	mov	ah, 21h
 36501                              <1> 	;mov	ecx, 8
 36502                              <1> 	; 28/07/2022
 36503 00008DD6 29C9                <1> 	sub	ecx, ecx
 36504 00008DD8 B108                <1> 	mov	cl, 8
 36505                              <1> loc_check_filename_next_char:
 36506 00008DDA AC                  <1> 	lodsb
 36507 00008DDB 3C2E                <1> 	cmp	al, 2Eh
 36508 00008DDD 7511                <1> 	jne	short pass_check_fn_dot_check
 36509                              <1> loc_check_filename_ext_0:
 36510 00008DDF AC                  <1> 	lodsb
 36511 00008DE0 38E0                <1> 	cmp	al, ah ; 21h
 36512 00008DE2 7205                <1> 	jb	short loc_invalid_filename
 36513 00008DE4 3C2E                <1> 	cmp	al, 2Eh
 36514 00008DE6 7519                <1> 	jne	short loc_check_filename_ext_1
 36515                              <1> 
 36516                              <1> loc_invalid_filename_stc:
 36517                              <1> loc_check_fn_stc_rtn:
 36518 00008DE8 F9                  <1> 	stc
 36519                              <1> loc_invalid_filename:
 36520                              <1> 	; 10/10/2016 (0Bh -> 26)
 36521 00008DE9 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; (=26)
 36522                              <1> 	; Invalid file name chars
 36523                              <1> loc_check_fn_rtn:
 36524 00008DEE 5E                  <1> 	pop	esi
 36525 00008DEF C3                  <1> 	retn
 36526                              <1> 
 36527                              <1> pass_check_fn_dot_check:
 36528 00008DF0 38E0                <1> 	cmp	al, ah ; 21h
 36529 00008DF2 7224                <1> 	jb	short loc_check_fn_clc_rtn
 36530 00008DF4 E2E4                <1> 	loop	loc_check_filename_next_char
 36531 00008DF6 AC                  <1> 	lodsb
 36532 00008DF7 38E0                <1> 	cmp	al, ah ; 21h
 36533 00008DF9 721D                <1> 	jb	short loc_check_fn_clc_rtn
 36534 00008DFB 3C2E                <1> 	cmp	al, 2Eh
 36535 00008DFD 75E9                <1> 	jne	short loc_check_fn_stc_rtn
 36536 00008DFF EBDE                <1> 	jmp	short loc_check_filename_ext_0
 36537                              <1> 
 36538                              <1> loc_check_filename_ext_1:
 36539 00008E01 AC                  <1> 	lodsb
 36540 00008E02 38E0                <1> 	cmp	al, ah ; 21h
 36541 00008E04 7212                <1> 	jb	short loc_check_fn_clc_rtn
 36542 00008E06 3C2E                <1> 	cmp	al, 2Eh
 36543 00008E08 74DE                <1> 	je	short loc_check_fn_stc_rtn
 36544 00008E0A AC                  <1> 	lodsb
 36545 00008E0B 38E0                <1> 	cmp	al, ah ; 21h
 36546 00008E0D 7209                <1> 	jb	short loc_check_fn_clc_rtn
 36547 00008E0F 3C2E                <1> 	cmp	al, 2Eh
 36548 00008E11 74D5                <1> 	je	short loc_check_fn_stc_rtn
 36549 00008E13 AC                  <1> 	lodsb
 36550 00008E14 38E0                <1> 	cmp	al, ah ; 21h
 36551 00008E16 73D0                <1> 	jnb	short loc_check_fn_stc_rtn
 36552                              <1> 
 36553                              <1> loc_check_fn_clc_rtn:
 36554 00008E18 5E                  <1> 	pop	esi
 36555 00008E19 F8                  <1> 	clc
 36556 00008E1A C3                  <1> 	retn
 36557                              <1> 
 36558                              <1> loc_print_deleted_message:
 36559 00008E1B BE[5B350100]        <1> 	mov	esi, Msg_Deleted
 36560 00008E20 E805DEFFFF          <1> 	call	print_msg
 36561                              <1> 
 36562                              <1> 	;clc
 36563                              <1> 
 36564                              <1> loc_file_rw_restore_retn:
 36565                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 36566                              <1> 	; 28/02/2010 (CMD_INTR.ASM)
 36567                              <1> loc_file_rw_cmd_failed:
 36568 00008E25 9C                  <1> 	pushf 
 36569 00008E26 E892F7FFFF          <1> 	call	restore_cdir_after_cmd_fail	
 36570 00008E2B 9D                  <1> 	popf
 36571 00008E2C 720D                <1> 	jc	short loc_file_rw_check_write_fault
 36572 00008E2E C3                  <1> 	retn
 36573                              <1> 
 36574                              <1> loc_permission_denied:
 36575                              <1> 	; 27/02/2016
 36576 00008E2F BE[68350100]        <1> 	mov	esi, Msg_Permission_Denied
 36577 00008E34 E8F1DDFFFF          <1> 	call	print_msg
 36578 00008E39 EBEA                <1> 	jmp	short loc_file_rw_restore_retn
 36579                              <1> 
 36580                              <1> loc_file_rw_check_write_fault:
 36581                              <1> 	;cmp	al, 1Dh ; Write Fault
 36582 00008E3B 3C12                <1>         cmp	al, 18 ; 05/11/2016
 36583                              <1> 	;jne	loc_run_cmd_failed_cmp_al
 36584                              <1> 	; 28/07/2022
 36585 00008E3D 7405                <1> 	je	short loc_file_rw_fault
 36586 00008E3F E916F7FFFF          <1> 	jmp	loc_run_cmd_failed_cmp_al
 36587                              <1> 
 36588                              <1> loc_file_rw_fault:
 36589 00008E44 BE[50330100]        <1> 	mov	esi, Msg_Not_Ready_Write_Err
 36590                              <1> 	;call	print_msg
 36591                              <1> 	;retn
 36592 00008E49 E9DCDDFFFF          <1> 	jmp	print_msg
 36593                              <1> 
 36594                              <1> make_directory:
 36595                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36596                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 36597                              <1> 	; 12/03/2011 (CMD_INTR.ASM, 'cmp_cmd_mkdir')
 36598                              <1> 	; 14/08/2010
 36599                              <1> 	; 10/07/2010
 36600                              <1> 	; 29/11/2009
 36601                              <1> 	;
 36602                              <1> get_mkdir_fchar:
 36603                              <1> 	; esi = directory name
 36604 00008E4E 803E20              <1> 	cmp	byte [esi], 20h
 36605 00008E51 7701                <1>         ja	short loc_mkdir_parse_path_name
 36606                              <1> 
 36607                              <1> loc_mkdir_nodirname_retn:
 36608 00008E53 C3                  <1> 	retn
 36609                              <1> 
 36610                              <1> loc_mkdir_parse_path_name:
 36611 00008E54 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 36612 00008E59 E8791C0000          <1>         call    parse_path_name
 36613                              <1> 	;jc	loc_cmd_failed
 36614                              <1> 	; 28/07/2022
 36615 00008E5E 7305                <1> 	jnc	short loc_mkdir_check_dirname_exists
 36616                              <1> loc_mkdir_cmd_failed:
 36617 00008E60 E9C5F6FFFF          <1> 	jmp	loc_cmd_failed
 36618                              <1> 
 36619                              <1> loc_mkdir_check_dirname_exists:
 36620 00008E65 BE[24810100]        <1> 	mov	esi, FindFile_Name
 36621 00008E6A 803E20              <1> 	cmp	byte [esi], 20h
 36622                              <1> 	;jna	loc_cmd_failed
 36623                              <1> 	; 28/07/2022
 36624 00008E6D 76F1                <1> 	jna	short loc_mkdir_cmd_failed
 36625 00008E6F 8935[A0810100]      <1> 	mov	[DelFile_FNPointer], esi
 36626 00008E75 E83CFFFFFF          <1> 	call	check_filename
 36627 00008E7A 725B                <1> 	jc	short loc_mkdir_invalid_dir_name_chars
 36628                              <1> 
 36629                              <1> loc_mkdir_drv:
 36630 00008E7C 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 36631 00008E82 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 36632                              <1> 	
 36633 00008E88 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 36634 00008E8E 38F2                <1> 	cmp	dl, dh
 36635 00008E90 7409                <1> 	je	short loc_mkdir_change_directory
 36636                              <1> 
 36637 00008E92 E8CCE8FFFF          <1> 	call	change_current_drive
 36638                              <1> 	;jc	loc_file_rw_cmd_failed
 36639                              <1> 	; 28/07/2022
 36640 00008E97 7302                <1> 	jnc	short loc_mkdir_change_directory
 36641 00008E99 EB8A                <1> 	jmp	loc_file_rw_cmd_failed
 36642                              <1> 
 36643                              <1> loc_mkdir_change_directory:
 36644 00008E9B 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 36645 00008EA2 7614                <1> 	jna	short loc_mkdir_find_directory
 36646                              <1> 
 36647 00008EA4 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 36648 00008EAA BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 36649 00008EAF 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 36650 00008EB1 E835160000          <1> 	call	change_current_directory
 36651 00008EB6 7226                <1> 	jc	short loc_mkdir_check_error_code
 36652                              <1> 
 36653                              <1> ;loc_mkdir_change_prompt_dir_string:
 36654                              <1> 	;call	change_prompt_dir_string
 36655                              <1> 
 36656                              <1> loc_mkdir_find_directory:
 36657                              <1> 	;mov	esi, FindFile_Name
 36658 00008EB8 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 36659                              <1> 	;xor	eax, eax
 36660 00008EBE 6631C0              <1> 	xor	ax, ax ; any name (dir, file, volume)
 36661 00008EC1 E84BFBFFFF          <1> 	call	find_first_file
 36662 00008EC6 7216                <1> 	jc	short loc_mkdir_check_error_code
 36663                              <1> 
 36664                              <1> loc_mkdir_directory_found:
 36665 00008EC8 BE[B3340100]        <1> 	mov	esi, Msg_Name_Exists
 36666                              <1> loc_mkdir_inv_dname_chrs_msg:
 36667 00008ECD E858DDFFFF          <1> 	call	print_msg
 36668 00008ED2 E94EFFFFFF          <1> 	jmp	loc_file_rw_restore_retn
 36669                              <1> 
 36670                              <1> loc_mkdir_invalid_dir_name_chars:
 36671 00008ED7 BE[86340100]        <1> 	mov	esi, Msg_invalid_name_chars
 36672                              <1> 	;call	print_msg
 36673                              <1>         ;jmp	loc_file_rw_restore_retn
 36674                              <1> 	; 28/07/2022
 36675 00008EDC EBEF                <1> 	jmp	short loc_mkdir_inv_dname_chrs_msg
 36676                              <1> 
 36677                              <1> loc_mkdir_check_error_code:
 36678 00008EDE 3C02                <1> 	cmp	al, 2
 36679                              <1> 	;je	short loc_mkdir_directory_not_found
 36680 00008EE0 7406                <1> 	je	short loc_mkdir_ask_for_yes_no
 36681 00008EE2 F9                  <1> 	stc
 36682 00008EE3 E93DFFFFFF          <1>         jmp     loc_file_rw_cmd_failed
 36683                              <1> 
 36684                              <1> loc_mkdir_directory_not_found:
 36685                              <1> loc_mkdir_ask_for_yes_no:
 36686 00008EE8 BE[D4340100]        <1> 	mov	esi, Msg_DoYouWantMkdir
 36687 00008EED E838DDFFFF          <1> 	call	print_msg
 36688 00008EF2 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 36689 00008EF8 E82DDDFFFF          <1> 	call	print_msg
 36690 00008EFD BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 36691 00008F02 E823DDFFFF          <1> 	call	print_msg
 36692                              <1> 
 36693 00008F07 C605[FD340100]20    <1> 	mov	byte [Y_N_nextline], 20h
 36694                              <1> 
 36695                              <1> loc_mkdir_ask_again:
 36696 00008F0E 30E4                <1> 	xor	ah, ah
 36697 00008F10 E8B97FFFFF          <1> 	call	int16h
 36698 00008F15 3C1B                <1> 	cmp	al, 1Bh
 36699                              <1> 	;je	short loc_do_not_make_directory
 36700 00008F17 743B                <1> 	je	short loc_mkdir_y_n_escape
 36701 00008F19 24DF                <1> 	and	al, 0DFh ; y -> Y, n -> N
 36702 00008F1B 3C59                <1> 	cmp	al, 'Y' ; 'yes'
 36703 00008F1D 7404                <1> 	je	short loc_mkdir_yes_make_directory
 36704 00008F1F 3C4E                <1> 	cmp	al, 'N' ; 'no'
 36705 00008F21 75EB                <1> 	jne	short loc_mkdir_ask_again
 36706                              <1> 
 36707                              <1> loc_do_not_make_directory:
 36708                              <1> loc_mkdir_yes_make_directory:
 36709 00008F23 E830000000          <1> 	call	y_n_answer ; 29/12/2017
 36710                              <1> 	;cmp	al, 'Y' ; 'yes'
 36711                              <1> 	;cmc
 36712                              <1>         ;jnc	loc_file_rw_restore_retn
 36713 00008F28 3C4E                <1> 	cmp	al, 'N' ; 'no'
 36714                              <1> 	;je	loc_file_rw_restore_retn
 36715                              <1> 	; 28/07/2022
 36716 00008F2A 7505                <1> 	jne	short loc_mkdir_call_make_sub_dir
 36717 00008F2C E9F4FEFFFF          <1> 	jmp	loc_file_rw_restore_retn		
 36718                              <1> 
 36719                              <1> loc_mkdir_call_make_sub_dir:
 36720 00008F31 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 36721 00008F37 B110                <1> 	mov	cl, 10h ; Directory attributes 
 36722 00008F39 E88D1C0000          <1> 	call	make_sub_directory
 36723                              <1> loc_rename_file_ok: ; 06/03/2016
 36724                              <1>         ;jc	loc_file_rw_cmd_failed
 36725                              <1> 	; 28/07/2022
 36726 00008F3E 7305                <1> 	jnc	short move_source_file_to_dest_OK
 36727 00008F40 E9E0FEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 36728                              <1> move_source_file_to_dest_OK:
 36729 00008F45 BE[01350100]        <1> 	mov	esi, Msg_OK
 36730 00008F4A E8DBDCFFFF          <1> 	call	print_msg
 36731 00008F4F E9D1FEFFFF          <1> 	jmp	loc_file_rw_restore_retn
 36732                              <1> 
 36733                              <1> loc_mkdir_y_n_escape:
 36734 00008F54 B04E                <1> 	mov	al, 'N' ; 'no'
 36735 00008F56 EBCB                <1> 	jmp	short loc_do_not_make_directory
 36736                              <1> 
 36737                              <1> y_n_answer:
 36738                              <1> 	; 29/12/2017
 36739 00008F58 A2[FD340100]        <1> 	mov	[Y_N_nextline], al
 36740                              <1> 	;push	ax
 36741 00008F5D 50                  <1> 	push	eax
 36742 00008F5E BE[FD340100]        <1> 	mov	esi, Y_N_nextline
 36743 00008F63 E8C2DCFFFF          <1> 	call	print_msg
 36744 00008F68 58                  <1> 	pop	eax
 36745                              <1> 	;pop	ax
 36746 00008F69 C3                  <1> 	retn
 36747                              <1> 
 36748                              <1> delete_directory:
 36749                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36750                              <1> 	; 29/12/2017
 36751                              <1> 	; 15/10/2016
 36752                              <1> 	; 01/03/2016, 06/03/2016
 36753                              <1> 	; 27/02/2016, 28/02/2016, 29/02/2016
 36754                              <1> 	; 26/02/2016 (TRDOS 386 = TRDOS v2.0)
 36755                              <1> 	; 16/10/2010 (CMD_INTR.ASM, 'cmp_cmd_rmdir')
 36756                              <1> 	; 05/06/2010
 36757                              <1> 	;
 36758                              <1> get_fchar:
 36759                              <1> 	; esi = directory name
 36760 00008F6A 803E20              <1> 	cmp	byte [esi], 20h
 36761 00008F6D 7701                <1>         ja	short loc_rmdir_parse_path_name
 36762                              <1> 
 36763                              <1> loc_rmdir_nodirname_retn:
 36764 00008F6F C3                  <1> 	retn
 36765                              <1> 
 36766                              <1> loc_rmdir_parse_path_name:
 36767 00008F70 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 36768 00008F75 E85D1B0000          <1> 	call	parse_path_name
 36769                              <1> 	;jc	loc_cmd_failed
 36770                              <1> 	; 28/07/2022
 36771 00008F7A 7305                <1> 	jnc	short loc_rmdir_check_dirname_exists
 36772                              <1> lc_del_dir_failed:
 36773 00008F7C E9A9F5FFFF          <1> 	jmp	loc_cmd_failed
 36774                              <1> 
 36775                              <1> loc_rmdir_check_dirname_exists:
 36776 00008F81 BE[24810100]        <1> 	mov	esi, FindFile_Name
 36777 00008F86 803E20              <1> 	cmp	byte [esi], 20h
 36778                              <1> 	;jna	loc_cmd_failed
 36779                              <1> 	; 28/07/2022
 36780 00008F89 76F1                <1> 	jna	short lc_del_dir_failed 
 36781 00008F8B 8935[A0810100]      <1> 	mov	[DelFile_FNPointer], esi 
 36782                              <1> 
 36783                              <1> loc_rmdir_drv:
 36784 00008F91 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 36785 00008F97 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 36786                              <1> 
 36787 00008F9D 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 36788 00008FA3 38F2                <1> 	cmp	dl, dh
 36789 00008FA5 7407                <1> 	je	short loc_rmdir_change_directory
 36790                              <1> 
 36791 00008FA7 E8B7E7FFFF          <1> 	call	change_current_drive
 36792                              <1> 	;jc	loc_file_rw_cmd_failed
 36793                              <1> 	; 28/07/2022
 36794                              <1> 	;jnc	short loc_rmdir_change_directory
 36795                              <1> 	;jmp	loc_file_rw_cmd_failed
 36796 00008FAC 7233                <1> 	jc	short loc_rmdir_chdrv_failed
 36797                              <1> 
 36798                              <1> loc_rmdir_change_directory:
 36799 00008FAE 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 36800 00008FB5 7614                <1> 	jna	short loc_rmdir_find_directory
 36801                              <1> 
 36802 00008FB7 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 36803 00008FBD BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 36804 00008FC2 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 36805 00008FC4 E822150000          <1> 	call	change_current_directory
 36806 00008FC9 7211                <1> 	jc	short loc_rmdir_check_error_code
 36807                              <1> 
 36808                              <1> ;loc_rmdir_change_prompt_dir_string:
 36809                              <1> 	;call	change_prompt_dir_string
 36810                              <1> 
 36811                              <1> loc_rmdir_find_directory:
 36812                              <1> 	;mov	esi, FindFile_Name
 36813 00008FCB 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 36814 00008FD1 66B81008            <1> 	mov	ax, 0810h ; Only directories
 36815 00008FD5 E837FAFFFF          <1> 	call	find_first_file
 36816 00008FDA 730A                <1> 	jnc	short loc_rmdir_ambgfn_check
 36817                              <1> 
 36818                              <1> loc_rmdir_check_error_code:
 36819 00008FDC 3C02                <1> 	cmp	al, 2
 36820 00008FDE 740B                <1> 	je	short loc_rmdir_directory_not_found
 36821 00008FE0 F9                  <1> 	stc
 36822                              <1> loc_rmdir_chdrv_failed:
 36823 00008FE1 E93FFEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 36824                              <1> 
 36825                              <1> loc_rmdir_ambgfn_check:
 36826 00008FE6 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 36827 00008FE9 740F                <1> 	jz	short loc_rmdir_directory_found
 36828                              <1> 
 36829                              <1> loc_rmdir_directory_not_found:
 36830 00008FEB BE[72330100]        <1> 	mov	esi, Msg_Dir_Not_Found
 36831 00008FF0 E835DCFFFF          <1> 	call	print_msg
 36832                              <1> 
 36833 00008FF5 E92BFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
 36834                              <1> 
 36835                              <1> loc_rmdir_directory_found:
 36836 00008FFA 80E307              <1> 	and	bl, 07h ; Attributes
 36837                              <1> 	;jnz	loc_permission_denied
 36838                              <1> 	; 28/07/2022
 36839 00008FFD 7405                <1> 	jz	short loc_rmdir_save_lnel
 36840 00008FFF E92BFEFFFF          <1> 	jmp	loc_permission_denied	
 36841                              <1> 
 36842                              <1> loc_rmdir_save_lnel: ; 28/02/2016
 36843                              <1>        ;mov	bh, [LongName_EntryLength]
 36844 00009004 883D[AA810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 36845                              <1> 	; edi = Directory Entry Offset (DirBuff)
 36846                              <1> 	; esi = Directory Entry (FFF Structure)
 36847                              <1> 	;mov	[DelFile_DirEntryAddr], edi ; not required
 36848                              <1> 	;mov	ax, [edi+20] ; First Cluster High Word
 36849                              <1>         ;shl	eax, 16
 36850                              <1> 	;mov	ax, [edi+26] ; First Cluster Low Word
 36851                              <1> 	; ROOT Dir First Cluster = 0
 36852                              <1>         ;cmp	eax, 2
 36853                              <1> 	;jb	loc_update_direntry_1
 36854                              <1> 
 36855                              <1> pass_rmdir_fc_check:
 36856 0000900A 57                  <1> 	push	edi ; * (29/02/2016)
 36857                              <1> 
 36858 0000900B BE[07350100]        <1> 	mov	esi, Msg_DoYouWantRmDir
 36859 00009010 E815DCFFFF          <1> 	call	print_msg
 36860 00009015 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 36861 0000901B E80ADCFFFF          <1> 	call	print_msg
 36862 00009020 BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 36863 00009025 E800DCFFFF          <1> 	call	print_msg
 36864                              <1> 
 36865                              <1> loc_rmdir_ask_again:
 36866 0000902A 30E4                <1> 	xor	ah, ah
 36867 0000902C E89D7EFFFF          <1> 	call	int16h
 36868 00009031 3C1B                <1> 	cmp	al, 1Bh
 36869                              <1> 	;je	short loc_do_not_delete_directory
 36870 00009033 742F                <1>         je	short loc_rmdir_y_n_escape ; 06/03/2016
 36871 00009035 24DF                <1> 	and	al, 0DFh
 36872 00009037 A2[FD340100]        <1> 	mov	[Y_N_nextline], al
 36873 0000903C 3C59                <1> 	cmp	al, 'Y'
 36874 0000903E 7404                <1> 	je	short loc_rmdir_yes_delete_directory
 36875 00009040 3C4E                <1> 	cmp	al, 'N'
 36876 00009042 75E6                <1> 	jne	short loc_rmdir_ask_again
 36877                              <1> 
 36878                              <1> loc_do_not_delete_directory:
 36879                              <1> loc_rmdir_yes_delete_directory:
 36880 00009044 E80FFFFFFF          <1> 	call	y_n_answer ; 29/12/2017
 36881 00009049 5F                  <1> 	pop	edi ; * (29/02/2016)
 36882                              <1> 	;cmp	al, 'Y' ; 'yes'
 36883                              <1> 	;cmc
 36884                              <1>         ;jnc	loc_file_rw_restore_retn
 36885 0000904A 3C4E                <1> 	cmp	al, 'N' ; 'no'
 36886                              <1> 	;je	loc_file_rw_restore_retn
 36887                              <1> 	; 28/07/2022
 36888                              <1> 	;jne	short loc_delete_sub_dir
 36889                              <1> 	;jmp	loc_file_rw_restore_retn
 36890 0000904C 7411                <1> 	je	short loc_rmdir_rw_restore_retn
 36891                              <1> 
 36892                              <1> loc_delete_sub_dir:
 36893                              <1> 	; 29/12/2017
 36894 0000904E E85E000000          <1> 	call	delete_sub_directory
 36895 00009053 7213                <1> 	jc	short loc_rmdir_cmd_failed
 36896                              <1> 
 36897                              <1> loc_rmdir_ok:
 36898 00009055 BE[01350100]        <1> 	mov	esi, Msg_OK
 36899 0000905A E8CBDBFFFF          <1> 	call	print_msg
 36900                              <1> loc_rmdir_rw_restore_retn: ; 28/07/2022
 36901 0000905F E9C1FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
 36902                              <1> 
 36903                              <1> loc_rmdir_y_n_escape:
 36904 00009064 B04E                <1> 	mov	al, 'N' ; 'no'
 36905 00009066 EBDC                <1>         jmp     loc_do_not_delete_directory
 36906                              <1> 
 36907                              <1> loc_rmdir_cmd_failed:
 36908                              <1> 	; 29/12/2017
 36909 00009068 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
 36910 0000906A 7423                <1> 	jz	short loc_rmdir_directory_not_empty
 36911                              <1> 
 36912                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
 36913                              <1> 
 36914 0000906C 833D[5E7F0100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
 36915                              <1> 	;jb	loc_file_rw_cmd_failed
 36916                              <1> 	; 28/07/2022
 36917 00009073 7305                <1> 	jnb	short loc_rmdir_failed
 36918 00009075 E9ABFDFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 36919                              <1> 	
 36920                              <1> loc_rmdir_failed:
 36921 0000907A F9                  <1> 	stc
 36922                              <1> loc_rmdir_cmd_return:
 36923                              <1> 	; 01/03/2016
 36924 0000907B 9C                  <1> 	pushf
 36925                              <1> 	; ESI = Logical DOS Drive Description Table address	
 36926 0000907C 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
 36927                              <1> 	           ; BL = 0 -> Recalculate free cluster count
 36928 00009080 50                  <1> 	push	eax
 36929 00009081 E807370000          <1> 	call	calculate_fat_freespace	
 36930 00009086 58                  <1> 	pop	eax
 36931 00009087 9D                  <1> 	popf
 36932                              <1> 	;jc	loc_file_rw_cmd_failed
 36933                              <1> 	;jmp	loc_file_rw_restore_retn
 36934                              <1> 	; 28/07/2022
 36935 00009088 73D5                <1> 	jnc	short loc_rmdir_rw_restore_retn
 36936 0000908A E996FDFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 36937                              <1> 
 36938                              <1> loc_rmdir_directory_not_empty:
 36939 0000908F BE[28350100]        <1> 	mov	esi, Msg_Dir_Not_Empty
 36940 00009094 E891DBFFFF          <1> 	call	print_msg
 36941                              <1> 	; 01/03/2016
 36942 00009099 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 36943 0000909E 09C0                <1> 	or	eax, eax ; 0 ?
 36944                              <1> 	;jz	loc_file_rw_restore_retn
 36945                              <1> 	; 28/07/2022
 36946 000090A0 74BD                <1> 	jz	short loc_rmdir_rw_restore_retn	
 36947                              <1> 
 36948                              <1> 	; ESI = Logical DOS Drive Description Table address	
 36949 000090A2 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
 36950                              <1> 	           ; BL = 1 -> add free clusters
 36951 000090A6 E8E2360000          <1> 	call	calculate_fat_freespace
 36952 000090AB 09C9                <1> 	or	ecx, ecx
 36953                              <1> 	;jz	loc_file_rw_restore_retn ; ecx = 0 -> OK
 36954                              <1> 	;; ecx > 0 -> Error (Recalculation is needed)
 36955                              <1> 	;jmp	short loc_rmdir_cmd_return
 36956                              <1> 	; 28/07/2022
 36957 000090AD 75CC                <1> 	jnz	short loc_rmdir_cmd_return
 36958 000090AF EBAE                <1> 	jmp	short loc_rmdir_rw_restore_retn
 36959                              <1> 	;jmp	loc_file_rw_restore_retn
 36960                              <1> 
 36961                              <1> 
 36962                              <1> delete_sub_directory:
 36963                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 36964                              <1> 	; 29/12/2017 
 36965                              <1> 	; (moved here from 'delete_directory' for 'sysrmdir' )
 36966                              <1> 
 36967                              <1> 	; EDI = Directory buffer entry offset/address
 36968                              <1> 
 36969                              <1> loc_rmdir_delete_short_name_check_dir_empty:
 36970 000090B1 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
 36971 000090B5 C1E010              <1>         shl	eax, 16
 36972 000090B8 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
 36973                              <1> 
 36974                              <1> 	;mov 	[DelFile_FCluster], eax
 36975                              <1> 
 36976                              <1> 	;;mov	bx, [DirBuff_EntryCounter]
 36977                              <1> 	;mov	bx, [FindFile_DirEntryNumber] ; 27/02/2016
 36978                              <1> 	;mov	[DelFile_EntryCounter], bx
 36979                              <1> 
 36980 000090BC 29DB                <1>     	sub	ebx, ebx
 36981                              <1> 	; 29/12/2017
 36982 000090BE 891D[5E7F0100]      <1> 	mov	[FAT_ClusterCounter], ebx ; 0 ; Reset
 36983                              <1> 
 36984 000090C4 8A3D[E2800100]      <1> 	mov	bh, [FindFile_Drv]
 36985 000090CA BE00010900          <1> 	mov	esi, Logical_DOSDisks
 36986 000090CF 01DE                <1> 	add	esi, ebx
 36987                              <1> 
 36988 000090D1 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h
 36989 000090D7 745A                <1> 	je	short loc_rmdir_check_fs_directory
 36990                              <1> 
 36991                              <1> 	;cmp	byte [esi+LD_FATType], 1
 36992                              <1> 	;jb	short loc_rmdir_get__last_cluster_0
 36993                              <1> 
 36994                              <1> 	; 29/12/2017
 36995 000090D9 83F802              <1> 	cmp	eax, 2
 36996 000090DC 7306                <1> 	jnb	short loc_rmdir_get_last_cluster_1
 36997                              <1> 	; eax < 2
 36998                              <1> loc_rmdir_get_last_cluster_0:
 36999                              <1> 	;mov	eax, ERR_INV_FORMAT ; invalid format!
 37000 000090DE B813000000          <1> 	mov	eax, ERR_NOT_DIR ; not a valid directory!
 37001                              <1> 	;stc
 37002 000090E3 C3                  <1> 	retn
 37003                              <1> 
 37004                              <1> loc_rmdir_get_last_cluster_1:
 37005 000090E4 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3 ; FAT32
 37006 000090E8 750C                <1> 	jne	short loc_rmdir_get_last_cluster_2
 37007                              <1> 
 37008                              <1> 	; is it root directory ?
 37009 000090EA 3B4632              <1> 	cmp	eax, [esi+LD_BPB+BPB_RootClus]
 37010 000090ED 7507                <1> 	jne	short loc_rmdir_get_last_cluster_2
 37011                              <1> 
 37012                              <1> 	; root directory can not be deleted !!
 37013                              <1> loc_rmdir_permission_denied:
 37014 000090EF B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; permission denied!
 37015 000090F4 F9                  <1> 	stc
 37016 000090F5 C3                  <1> 	retn		
 37017                              <1> 
 37018                              <1> loc_rmdir_get_last_cluster_2:
 37019                              <1> 	; 29/12/2017
 37020 000090F6 A3[A4810100]        <1> 	mov 	[DelFile_FCluster], eax
 37021                              <1> 	
 37022                              <1> 	;mov	dx, [DirBuff_EntryCounter]
 37023 000090FB 668B15[5C810100]    <1> 	mov	dx, [FindFile_DirEntryNumber] ; 27/02/2016
 37024 00009102 668915[A8810100]    <1> 	mov	[DelFile_EntryCounter], dx
 37025                              <1> 	
 37026 00009109 8B15[6E7F0100]      <1> 	mov	edx, [DirBuff_Cluster]
 37027 0000910F 8915[D4810100]      <1> 	mov	[RmDir_ParentDirCluster], edx
 37028                              <1> 
 37029 00009115 893D[D0810100]      <1> 	mov	[RmDir_DirEntryOffset], edi
 37030                              <1> 
 37031                              <1> 	; 01/03/2016
 37032                              <1> 	;mov	dword [FAT_ClusterCounter], 0 ; Reset
 37033                              <1> 
 37034                              <1> loc_rmdir_get_last_cluster_3:
 37035 0000911B E8EB370000          <1> 	call	get_last_cluster
 37036                              <1>         ;jc	loc_rmdir_cmd_failed
 37037 00009120 721E                <1> 	jc	short loc_delete_sub_dir_retn ; 29/12/2017
 37038                              <1> 	
 37039 00009122 3B05[A4810100]      <1> 	cmp	eax, [DelFile_FCluster]
 37040 00009128 7517                <1> 	jne	short loc_rmdir_multi_dir_clusters
 37041                              <1> 
 37042 0000912A C605[CF810100]00    <1> 	mov	byte [RmDir_MultiClusters], 0
 37043 00009131 EB15                <1> 	jmp	short pass_rmdir_multi_dir_clusters
 37044                              <1> 
 37045                              <1> loc_rmdir_check_fs_directory:
 37046                              <1> 	; 29/12/2017
 37047 00009133 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
 37048 00009137 75B6                <1> 	jne	short loc_rmdir_permission_denied
 37049                              <1> 
 37050                              <1> loc_rmdir_delete_fs_directory:
 37051 00009139 E8CE120000          <1> 	call	delete_fs_directory
 37052                              <1> 	;jnc	loc_print_deleted_message
 37053 0000913E 7300                <1> 	jnc	short loc_delete_sub_dir_retn ; 29/12/2017
 37054                              <1> 
 37055                              <1> 	; EAX=0 -> Directory not empty !
 37056                              <1> 	; EAX>0 -> Disk r/w error or another (misc) error
 37057                              <1> 	
 37058                              <1> 	;or	eax, eax
 37059                              <1> 	;jz	loc_rmdir_directory_not_empty_2         
 37060                              <1> 	;;stc
 37061                              <1> 	;;jmp	loc_file_rw_cmd_failed
 37062                              <1> 	
 37063                              <1> loc_delete_sub_dir_retn:
 37064 00009140 C3                  <1> 	retn
 37065                              <1>  
 37066                              <1> loc_rmdir_multi_dir_clusters:
 37067 00009141 C605[CF810100]01    <1> 	mov	byte [RmDir_MultiClusters], 1
 37068                              <1> 
 37069                              <1> pass_rmdir_multi_dir_clusters:
 37070 00009148 A3[D8810100]        <1> 	mov 	[RmDir_DirLastCluster], eax
 37071 0000914D 890D[DC810100]      <1> 	mov	[RmDir_PreviousCluster], ecx
 37072                              <1> 
 37073                              <1> loc_rmdir_load_fat_sub_directory:
 37074 00009153 E8EE310000          <1> 	call	load_FAT_sub_directory
 37075                              <1> 	;jc	loc_rmdir_cmd_failed
 37076 00009158 72E6                <1> 	jc	short loc_delete_sub_dir_retn
 37077                              <1> 
 37078                              <1> loc_rmdir_find_last_dir_entry:
 37079 0000915A 56                  <1> 	push	esi
 37080 0000915B BE[C6800100]        <1> 	mov	esi, Dir_File_Name
 37081 00009160 C6062A              <1> 	mov	byte [esi], '*'
 37082 00009163 C646082A            <1> 	mov	byte [esi+8], '*'
 37083 00009167 31DB                <1> 	xor	ebx, ebx ; Entry offset  = 0
 37084                              <1> loc_rmdir_find_last_dir_entry_next:
 37085                              <1> 	;mov	ax, 0800h ; Except volume/long names
 37086                              <1> 	;xor	cx, cx ; 0 = Find a valid file or dir name
 37087                              <1> 	; 28/07/2022
 37088 00009169 31C0                <1> 	xor	eax, eax
 37089 0000916B B408                <1> 	mov	ah, 8
 37090                              <1> 	; eax = 0800h
 37091 0000916D 31C9                <1> 	xor	ecx, ecx ; 0
 37092 0000916F E8C8160000          <1> 	call	find_directory_entry
 37093 00009174 7225                <1> 	jc	short loc_rmdir_empty_dir_cluster
 37094 00009176 83FB01              <1> 	cmp	ebx, 1
 37095 00009179 771B                <1> 	ja	short loc_rmdir_directory_not_empty_1
 37096                              <1> loc_rmdir_dot_entry_check:
 37097 0000917B 80FD2E              <1> 	cmp	ch, '.' ; The first char of the dir entry
 37098 0000917E 7516                <1> 	jne	short loc_rmdir_directory_not_empty_1
 37099 00009180 08DB                <1> 	or	bl, bl
 37100 00009182 7506                <1> 	jnz	short loc_rmdir_dotdot_entry_check
 37101 00009184 807F0120            <1> 	cmp	byte [edi+1], 20h
 37102 00009188 EB06                <1> 	jmp	short pass_rmdir_dot_entry_check
 37103                              <1> 
 37104                              <1> loc_rmdir_dotdot_entry_check:
 37105 0000918A 66817F012E20        <1> 	cmp	word [edi+1], '. '
 37106                              <1> pass_rmdir_dot_entry_check:	
 37107 00009190 7504                <1> 	jne	short loc_rmdir_directory_not_empty_1 
 37108 00009192 FEC3                <1> 	inc	bl
 37109 00009194 EBD3                <1> 	jmp	short loc_rmdir_find_last_dir_entry_next 
 37110                              <1> 
 37111                              <1> loc_rmdir_directory_not_empty_1:
 37112 00009196 58                  <1> 	pop	eax ; pushed esi 
 37113 00009197 31C0                <1> 	xor	eax, eax ; 0
 37114                              <1> loc_rmdir_directory_not_empty_2:
 37115                              <1> loc_delete_sub_dir_stc_retn:
 37116 00009199 F9                  <1> 	stc
 37117 0000919A C3                  <1> 	retn
 37118                              <1> 
 37119                              <1> loc_rmdir_empty_dir_cluster:
 37120 0000919B 5E                  <1> 	pop	esi
 37121                              <1> 
 37122                              <1> loc_rmdir_set_prev_cluster_dir_last_cluster:
 37123 0000919C 803D[CF810100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
 37124 000091A3 7613                <1> 	jna	short loc_rmdir_unlink_dir_last_cluster
 37125                              <1> 
 37126 000091A5 A1[DC810100]        <1> 	mov	eax, [RmDir_PreviousCluster]
 37127                              <1> 	;xor	ecx, ecx
 37128 000091AA 49                  <1> 	dec	ecx ; FFFFFFFFh
 37129 000091AB E8C9320000          <1> 	call	update_cluster
 37130 000091B0 7306                <1> 	jnc	short loc_rmdir_unlink_dir_last_cluster
 37131                              <1> 
 37132                              <1> 	; 01/03/2016
 37133                              <1> 	;cmp	eax, 1  ; eax = 0 -> end of cluster chain
 37134                              <1> 	;cmc 
 37135                              <1> 	;jc	short loc_rmdir_cmd_failed
 37136                              <1> 	;jmp	short loc_rmdir_save_fat_buffer
 37137                              <1> 	; 29/12/2017 
 37138 000091B2 21C0                <1> 	and	eax, eax
 37139 000091B4 75E3                <1> 	jnz	short loc_delete_sub_dir_stc_retn
 37140 000091B6 EB12                <1> 	jmp	short loc_rmdir_save_fat_buffer	
 37141                              <1> 
 37142                              <1> loc_rmdir_unlink_dir_last_cluster:
 37143 000091B8 A1[D8810100]        <1> 	mov	eax, [RmDir_DirLastCluster]
 37144 000091BD 31C9                <1> 	xor	ecx, ecx ; 0
 37145 000091BF E8B5320000          <1> 	call	update_cluster
 37146 000091C4 7327                <1> 	jnc	short loc_rmdir_unlink_stc_retn_0Bh
 37147                              <1> 	; Because of it is the last cluster
 37148                              <1> 	; 'update_cluster' must return with eocc error 
 37149 000091C6 09C0                <1> 	or	eax, eax
 37150                              <1> 	;jz	short loc_rmdir_save_fat_buffer ; eocc	
 37151                              <1> 	;stc
 37152                              <1>         ;jmp	short loc_rmdir_cmd_failed
 37153                              <1> 	; 29/12/2017
 37154 000091C8 75CF                <1> 	jnz	short loc_delete_sub_dir_stc_retn
 37155                              <1> 	
 37156                              <1> loc_rmdir_save_fat_buffer:
 37157 000091CA 803D[567F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
 37158 000091D1 7527                <1> 	jne	short loc_rmdir_calculate_FAT_freespace
 37159 000091D3 E824350000          <1> 	call	save_fat_buffer
 37160                              <1> 	;jc	short loc_rmdir_cmd_failed
 37161                              <1> 	; 29/12/2017
 37162 000091D8 7219                <1> 	jc	short loc_rmdir_unlink_error_retn
 37163                              <1> 
 37164                              <1> 	; 01/03/2016
 37165 000091DA 803D[CF810100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
 37166 000091E1 7617                <1> 	jna	short loc_rmdir_calculate_FAT_freespace
 37167                              <1> 
 37168 000091E3 A1[A4810100]        <1> 	mov	eax, [DelFile_FCluster]
 37169 000091E8 E92EFFFFFF          <1>         jmp     loc_rmdir_get_last_cluster_3
 37170                              <1> 
 37171                              <1> loc_rmdir_unlink_stc_retn_0Bh:
 37172                              <1> 	; 15/10/2016 (0Bh -> 28)
 37173 000091ED B81C000000          <1> 	mov	eax, ERR_INV_FORMAT ; 28 = Invalid format
 37174                              <1> loc_rmdir_unlink_stc_retn:
 37175 000091F2 F9                  <1> 	stc
 37176                              <1> loc_rmdir_unlink_error_retn:
 37177 000091F3 C3                  <1> 	retn
 37178                              <1> 
 37179                              <1> loc_rmdir_delete_short_name_invalid_data:
 37180                              <1> 	;mov	eax, 29 ; Invalid data (15/10/2016)
 37181                              <1> 	; 28/07/2022
 37182 000091F4 29C0                <1> 	sub	eax, eax
 37183 000091F6 B01D                <1> 	mov	al, 29
 37184                              <1> 	;stc
 37185                              <1>         ;jmp	loc_rmdir_cmd_failed
 37186                              <1> 	; 29/12/2017
 37187 000091F8 EBF8                <1> 	jmp	short loc_rmdir_unlink_stc_retn
 37188                              <1> 
 37189                              <1> loc_rmdir_calculate_FAT_freespace:
 37190                              <1> 	;mov	eax, [FAT_ClusterCounter]
 37191                              <1> 	; 29/12/2017
 37192 000091FA 29C0                <1> 	sub	eax, eax ; 0
 37193 000091FC 8705[5E7F0100]      <1> 	xchg	eax, [FAT_ClusterCounter]
 37194                              <1> 	;
 37195 00009202 66BB01FF            <1> 	mov	bx, 0FF01h
 37196                              <1> 	; BL = 1 -> Add EAX to free space count
 37197                              <1> 	; BH = FFh ->
 37198                              <1> 	; ESI = Logical DOS Drive Description Table address
 37199 00009206 E882350000          <1> 	call	calculate_fat_freespace
 37200                              <1> 
 37201 0000920B 21C9                <1> 	and	ecx, ecx ; ecx = 0 -> valid free sector count
 37202 0000920D 7409                <1> 	jz 	short loc_rmdir_delete_short_name_continue
 37203                              <1> 
 37204                              <1> loc_rmdir_recalculate_FAT_freespace:
 37205 0000920F 66BB00FF            <1>         mov     bx, 0FF00h ; BL = 0 -> Recalculate free space
 37206 00009213 E875350000          <1> 	call	calculate_fat_freespace
 37207                              <1> 	          
 37208                              <1> loc_rmdir_delete_short_name_continue:
 37209 00009218 A1[D4810100]        <1> 	mov	eax, [RmDir_ParentDirCluster]
 37210 0000921D 83F802              <1> 	cmp	eax, 2
 37211 00009220 7309                <1> 	jnb	short loc_rmdir_del_short_name_load_sub_dir
 37212 00009222 E8A1300000          <1> 	call	load_FAT_root_directory
 37213                              <1> 	;jc	loc_file_rw_cmd_failed
 37214                              <1> 	; 29/12/2017
 37215 00009227 72CA                <1> 	jc	short loc_rmdir_unlink_error_retn
 37216 00009229 EB07                <1> 	jmp	short loc_rmdir_del_short_name_ld_chk_fclust
 37217                              <1> 
 37218                              <1> loc_rmdir_del_short_name_load_sub_dir:	
 37219 0000922B E816310000          <1> 	call	load_FAT_sub_directory
 37220                              <1> 	;jc	loc_file_rw_cmd_failed
 37221                              <1> 	; 29/12/2017
 37222 00009230 72C1                <1> 	jc	short loc_rmdir_unlink_error_retn
 37223                              <1> 
 37224                              <1> loc_rmdir_del_short_name_ld_chk_fclust:
 37225 00009232 0FB73D[D0810100]    <1> 	movzx	edi, word [RmDir_DirEntryOffset]
 37226 00009239 81C700000800        <1> 	add	edi, Directory_Buffer
 37227                              <1> 
 37228 0000923F 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
 37229 00009243 C1E010              <1> 	shl	eax, 16
 37230 00009246 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
 37231                              <1>         ; Not necessary... 
 37232 0000924A 3B05[A4810100]      <1> 	cmp	eax, [DelFile_FCluster]
 37233 00009250 75A2                <1> 	jne	short loc_rmdir_delete_short_name_invalid_data
 37234                              <1> 	;
 37235 00009252 C607E5              <1> 	mov	byte [edi], 0E5h ; 'Deleted' sign
 37236                              <1> 	; 27/02/2016
 37237                              <1> 	; TRDOS v1 has a bug here! it does not set
 37238                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
 37239                              <1> 	; 'save_directory_buffer' would not save the change ! 
 37240 00009255 C605[697F0100]02    <1>   	mov	byte [DirBuff_ValidData], 2 ; change sign
 37241                              <1> 	;
 37242 0000925C E8B21C0000          <1> 	call	save_directory_buffer
 37243                              <1> 	;jc	loc_file_rw_cmd_failed
 37244                              <1> 	; 29/12/2017
 37245 00009261 7290                <1> 	jc	short loc_rmdir_unlink_error_retn
 37246                              <1> 
 37247                              <1> loc_rmdir_del_long_name:
 37248 00009263 0FB615[AA810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
 37249 0000926A 08D2                <1> 	or	dl, dl
 37250 0000926C 7410                <1> 	jz	short loc_rmdir_update_parent_dir_lmdt
 37251                              <1>              
 37252 0000926E 0FB705[A8810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
 37253 00009275 29D0                <1> 	sub	eax, edx
 37254                              <1> 	; 29/12/2017
 37255 00009277 7205                <1> 	jc	short loc_rmdir_update_parent_dir_lmdt
 37256                              <1>  
 37257                              <1>  	; EAX = Directory Entry Number of the long name last entry
 37258 00009279 E8EE1D0000          <1> 	call	delete_longname
 37259                              <1> 
 37260                              <1> loc_rmdir_update_parent_dir_lmdt:
 37261 0000927E E8281D0000          <1> 	call	update_parent_dir_lmdt
 37262                              <1> 	;jc	short loc_file_rw_cmd_failed
 37263                              <1> 	; 29/12/2017
 37264                              <1> 	;jc	short loc_rmdir_unlink_error_retn
 37265                              <1> 
 37266                              <1> loc_delete_sub_directory_ok:
 37267                              <1> 	; 29/12/2017
 37268 00009283 31C0                <1> 	xor	eax, eax ;  0 ;  cf = 0
 37269 00009285 C3                  <1> 	retn
 37270                              <1> 
 37271                              <1> delete_file:
 37272                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 37273                              <1> 	; 29/02/2016
 37274                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
 37275                              <1> 	; 09/08/2010 (CMD_INTR.ASM, 'cmp_cmd_del')
 37276                              <1> 	; 28/02/2010
 37277                              <1> 
 37278                              <1> get_delfile_fchar:
 37279                              <1> 	; esi = file name
 37280 00009286 803E20              <1> 	cmp	byte [esi], 20h
 37281 00009289 7701                <1>         ja	short loc_delfile_parse_path_name
 37282                              <1> 
 37283                              <1> loc_delfile_nofilename_retn:
 37284 0000928B C3                  <1> 	retn
 37285                              <1> 
 37286                              <1> loc_delfile_parse_path_name:
 37287 0000928C BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 37288 00009291 E841180000          <1> 	call	parse_path_name
 37289                              <1> 	;jc	loc_cmd_failed
 37290                              <1> 	; 28/07/2022
 37291 00009296 7305                <1> 	jnc	short loc_delfile_check_filename_exists
 37292                              <1> loc_delfile_failed:
 37293 00009298 E98DF2FFFF          <1> 	jmp	loc_cmd_failed
 37294                              <1> 
 37295                              <1> loc_delfile_check_filename_exists:
 37296 0000929D BE[24810100]        <1> 	mov	esi, FindFile_Name
 37297 000092A2 803E20              <1> 	cmp	byte [esi], 20h
 37298                              <1> 	;jna	loc_cmd_failed
 37299                              <1> 	; 28/07/2022
 37300 000092A5 76F1                <1> 	jna	short loc_delfile_failed
 37301 000092A7 8935[A0810100]      <1> 	mov	[DelFile_FNPointer], esi 
 37302                              <1> 
 37303                              <1> loc_delfile_drv:
 37304 000092AD 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 37305 000092B3 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 37306 000092B9 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 37307 000092BF 38F2                <1> 	cmp	dl, dh
 37308 000092C1 7407                <1> 	je	short loc_delfile_change_directory
 37309                              <1> 
 37310 000092C3 E89BE4FFFF          <1> 	call	change_current_drive
 37311                              <1> 	;jc	loc_file_rw_cmd_failed
 37312                              <1> 	; 28/07/2022
 37313                              <1> 	;jnc	short loc_delfile_change_directory
 37314                              <1> 	;jmp	loc_file_rw_cmd_failed
 37315 000092C8 721D                <1> 	jc	short loc_delfile_chdrv_failed
 37316                              <1> 
 37317                              <1> loc_delfile_change_directory:
 37318 000092CA 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 37319 000092D1 7619                <1> 	jna	short loc_delfile_find
 37320                              <1> 
 37321 000092D3 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 37322 000092D9 BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 37323 000092DE 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 37324 000092E0 E806120000          <1> 	call	change_current_directory
 37325                              <1> 	;jc	loc_file_rw_cmd_failed
 37326                              <1> 	; 28/07/2022
 37327 000092E5 7305                <1> 	jnc	short loc_delfile_chdir_ok
 37328                              <1> loc_delfile_chdrv_failed:
 37329                              <1> loc_delfile_fff_failed:
 37330 000092E7 E939FBFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37331                              <1> 
 37332                              <1> loc_delfile_chdir_ok: ; 28/07/2022
 37333                              <1> 
 37334                              <1> ;loc_delfile_change_prompt_dir_string:
 37335                              <1> 	;call	change_prompt_dir_string
 37336                              <1> 
 37337                              <1> loc_delfile_find:
 37338                              <1> 	;mov	esi, FindFile_Name
 37339 000092EC 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 37340 000092F2 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
 37341 000092F6 E816F7FFFF          <1> 	call	find_first_file
 37342                              <1> 	;jc	loc_file_rw_cmd_failed
 37343                              <1> 	; 28/07/2022
 37344 000092FB 72EA                <1> 	jc	short loc_delfile_fff_failed
 37345                              <1> 
 37346                              <1> loc_delfile_ambgfn_check:
 37347 000092FD 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 37348 00009300 740A                <1> 	jz	short loc_delfile_found
 37349                              <1> 
 37350                              <1> loc_file_not_found:
 37351                              <1> 	;mov	eax, 2 ; File not found sign
 37352                              <1> 	; 28/07/2022
 37353 00009302 31C0                <1> 	xor	eax, eax
 37354 00009304 B002                <1> 	mov	al, 2
 37355 00009306 F9                  <1> 	stc
 37356 00009307 E919FBFFFF          <1> 	jmp	loc_file_rw_cmd_failed   
 37357                              <1> 
 37358                              <1> loc_delfile_found:
 37359 0000930C 80E307              <1> 	and	bl, 07h ; Attributes
 37360                              <1> 	;jnz	loc_permission_denied
 37361                              <1> 	; 28/07/2022
 37362 0000930F 7405                <1> 	jz	short loc_delfile_attrb_ok
 37363 00009311 E919FBFFFF          <1> 	jmp	loc_permission_denied
 37364                              <1> 
 37365                              <1> loc_delfile_attrb_ok: ; 28/07/2022
 37366                              <1> 
 37367                              <1> ;loc_delfile_found_save_lnel:
 37368                              <1> ;	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 37369                              <1> 
 37370                              <1> loc_delfile_ask_for_delete:
 37371 00009316 57                  <1> 	push	edi ; * (29/02/2016)
 37372                              <1> 
 37373 00009317 BE[3F350100]        <1> 	mov	esi, Msg_DoYouWantDelete
 37374 0000931C E809D9FFFF          <1> 	call	print_msg
 37375 00009321 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 37376 00009327 E8FED8FFFF          <1> 	call	print_msg
 37377 0000932C BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 37378 00009331 E8F4D8FFFF          <1> 	call	print_msg
 37379                              <1> 
 37380                              <1> loc_delfile_ask_again:
 37381 00009336 30E4                <1> 	xor	ah, ah
 37382 00009338 E8917BFFFF          <1> 	call	int16h
 37383 0000933D 3C1B                <1> 	cmp	al, 1Bh
 37384                              <1> 	;je	short loc_do_not_delete_file
 37385 0000933F 744C                <1> 	je	short loc_delfile_y_n_escape ; 06/03/2016
 37386 00009341 24DF                <1> 	and	al, 0DFh
 37387 00009343 A2[FD340100]        <1> 	mov	[Y_N_nextline], al
 37388 00009348 3C59                <1> 	cmp	al, 'Y'
 37389 0000934A 7404                <1> 	je	short loc_yes_delete_file
 37390 0000934C 3C4E                <1> 	cmp	al, 'N'
 37391 0000934E 75E6                <1> 	jne	short loc_delfile_ask_again
 37392                              <1> 
 37393                              <1> loc_do_not_delete_file:
 37394                              <1> loc_yes_delete_file:
 37395 00009350 E803FCFFFF          <1> 	call	y_n_answer ; 29/12/2017
 37396 00009355 5F                  <1> 	pop	edi ; * (29/02/2016)
 37397                              <1> 	;cmp	al, 'Y' ; 'yes'
 37398                              <1> 	;cmc
 37399                              <1>         ;jnc	loc_file_rw_restore_retn
 37400 00009356 3C4E                <1> 	cmp	al, 'N' ; 'no'
 37401                              <1>         ;je	loc_file_rw_restore_retn
 37402                              <1> 	; 28/07/2022
 37403 00009358 7505                <1> 	jne	short loc_delete_file
 37404 0000935A E9C6FAFFFF          <1> 	jmp	loc_file_rw_restore_retn
 37405                              <1> 
 37406                              <1> loc_delete_file:
 37407 0000935F 8A3D[E2800100]      <1> 	mov	bh, [FindFile_Drv]
 37408                              <1> 	;mov	bl, [DelFile_LNEL]
 37409 00009365 8A1D[31810100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
 37410                              <1> 	;mov	cx, [DirBuff_EntryCounter]
 37411 0000936B 668B0D[5C810100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
 37412                              <1> 	; (*) EDI = Directory buffer entry offset/address 
 37413 00009372 E8CD1E0000          <1> 	call	remove_file ; (FILE.ASM, 'proc_delete_file')
 37414                              <1> 	;jnc	loc_print_deleted_message
 37415                              <1> 	; 28/07/2022
 37416 00009377 7205                <1> 	jc	short loc_delete_file_err1
 37417 00009379 E99DFAFFFF          <1> 	jmp	loc_print_deleted_message
 37418                              <1> 
 37419                              <1> loc_delete_file_err1:
 37420                              <1> 	;cmp	al, 05h
 37421 0000937E 3C0B                <1> 	cmp	al, ERR_PERM_DENIED  ; 29/12/2017 (5 -> 11)
 37422                              <1> 	;je	loc_permission_denied
 37423                              <1> 	; 28/07/2022
 37424 00009380 7505                <1> 	jne	short loc_delete_file_err2
 37425 00009382 E9A8FAFFFF          <1> 	jmp	loc_permission_denied
 37426                              <1> loc_delete_file_err2:
 37427 00009387 F9                  <1> 	stc
 37428 00009388 E998FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37429                              <1> 
 37430                              <1> loc_delfile_y_n_escape:
 37431 0000938D B04E                <1> 	mov	al, 'N' ; 'no'
 37432 0000938F EBBF                <1> 	jmp	short loc_do_not_delete_file
 37433                              <1> 
 37434                              <1> set_file_attributes:
 37435                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 37436                              <1> 	; 06/03/2016
 37437                              <1> 	; 04/03/2016 (TRDOS 386 = TRDOS v2.0)
 37438                              <1> 	; 10/07/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_attrib')
 37439                              <1> 	; 23/05/2010 
 37440                              <1> 	; 17/12/2000 (P2000.ASM)
 37441                              <1> 
 37442                              <1> 	; esi = file or directory name
 37443                              <1> 	;xor	ax, ax
 37444                              <1> 	; 28/07/2022
 37445 00009391 31C0                <1> 	xor	eax, eax
 37446 00009393 66A3[90350100]      <1> 	mov	[Attr_Chars], ax
 37447 00009399 A2[F8810100]        <1> 	mov	[Attributes], al
 37448                              <1> 
 37449                              <1> get_attrib_fchar:
 37450                              <1> 	; esi = file name
 37451 0000939E 8A06                <1> 	mov	al, [esi]
 37452 000093A0 3C20                <1> 	cmp	al, 20h
 37453 000093A2 7621                <1> 	jna	short loc_attr_file_nofilename_retn
 37454                              <1> 
 37455                              <1> loc_scan_attrib_params:
 37456 000093A4 3C2D                <1> 	cmp	al, '-'
 37457                              <1> 	;ja	loc_attr_file_parse_path_name
 37458                              <1> 	;je	short loc_attr_space
 37459                              <1> 	; 28/07/2022
 37460 000093A6 7207                <1> 	jb	short loc_sfa_1
 37461 000093A8 740E                <1> 	je	short loc_attr_space
 37462 000093AA E911010000          <1> 	jmp	loc_attr_file_parse_path_name
 37463                              <1> 	
 37464                              <1> loc_sfa_1:
 37465                              <1> 	; 28/07/2022
 37466 000093AF 3C2B                <1> 	cmp	al, '+'
 37467                              <1> 	;jne	loc_cmd_failed
 37468 000093B1 7405                <1> 	je	short loc_attr_space
 37469                              <1> loc_sfa_2: 
 37470 000093B3 E972F1FFFF          <1> 	jmp	loc_cmd_failed	
 37471                              <1> loc_attr_space:
 37472 000093B8 8A6601              <1> 	mov	ah, [esi+1]
 37473 000093BB 80FC20              <1>  	cmp	ah, 20h
 37474 000093BE 7706                <1> 	ja	short pass_attr_space
 37475                              <1> 	;jb	loc_cmd_failed
 37476                              <1> 	; 28/07/2022
 37477 000093C0 72F1                <1> 	jb	short loc_sfa_2
 37478 000093C2 46                  <1> 	inc	esi
 37479 000093C3 EBF3                <1> 	jmp	short loc_attr_space
 37480                              <1> 
 37481                              <1> loc_attr_file_nofilename_retn:
 37482 000093C5 C3                  <1> 	retn
 37483                              <1> 
 37484                              <1> pass_attr_space:
 37485 000093C6 80E4DF              <1> 	and	ah, 0DFh
 37486 000093C9 80FC53              <1> 	cmp	ah, 'S'
 37487                              <1> 	;ja	loc_cmd_failed
 37488                              <1> 	; 28/07/2022
 37489 000093CC 77E5                <1> 	ja	short loc_sfa_2
 37490 000093CE 7204                <1> 	jb	short pass_attr_system
 37491 000093D0 B404                <1> 	mov	ah, 04h	; System
 37492 000093D2 EB1D                <1> 	jmp	short pass_attr_archive
 37493                              <1> 
 37494                              <1> pass_attr_system:
 37495 000093D4 80FC48              <1> 	cmp	ah, 'H'
 37496 000093D7 7706                <1> 	ja	short pass_attr_hidden
 37497 000093D9 720F                <1> 	jb	short pass_attr_read_only
 37498 000093DB B402                <1> 	mov	ah, 02h	; Hidden
 37499 000093DD EB12                <1> 	jmp	short pass_attr_archive
 37500                              <1> 
 37501                              <1> pass_attr_hidden:
 37502 000093DF 80FC52              <1> 	cmp	ah, 'R'
 37503                              <1> 	;ja	loc_cmd_failed
 37504                              <1> 	; 28/07/2022
 37505 000093E2 77CF                <1> 	ja	short loc_sfa_2
 37506 000093E4 7204                <1> 	jb	short pass_attr_read_only ; Read only
 37507 000093E6 B401                <1> 	mov	ah, 01h
 37508 000093E8 EB07                <1> 	jmp	short pass_attr_archive
 37509                              <1> 
 37510                              <1> pass_attr_read_only:
 37511 000093EA 80FC41              <1> 	cmp	ah, 'A'
 37512 000093ED 753B                <1> 	jne	short loc_chk_attr_enter
 37513 000093EF B420                <1> 	mov	ah, 20h	; Archive
 37514                              <1> 
 37515                              <1> pass_attr_archive:
 37516 000093F1 3C2D                <1> 	cmp	al, '-'
 37517 000093F3 7508                <1> 	jne	short pass_reducing_attributes
 37518 000093F5 0825[90350100]      <1> 	or	[Attr_Chars], ah
 37519 000093FB EB06                <1> 	jmp	short loc_change_attributes_inc
 37520                              <1> 
 37521                              <1> pass_reducing_attributes:
 37522 000093FD 0825[91350100]      <1> 	or	[Attr_Chars+1], ah
 37523                              <1> 
 37524                              <1> loc_change_attributes_inc:
 37525 00009403 46                  <1> 	inc	esi
 37526 00009404 8A6601              <1> 	mov	ah, [esi+1]
 37527 00009407 80FC20              <1> 	cmp	ah, 20h
 37528 0000940A 7228                <1> 	jb	short pass_change_attr
 37529 0000940C 74F5                <1> 	je	short loc_change_attributes_inc
 37530 0000940E 80FC2D              <1> 	cmp	ah, '-'
 37531 00009411 770D                <1> 	ja	short loc_chk_next_attr_char1
 37532 00009413 7405                <1> 	je	short loc_chk_next_attr_char0
 37533 00009415 80FC2B              <1> 	cmp	ah, '+'
 37534 00009418 7506                <1> 	jne	short loc_chk_next_attr_char1
 37535                              <1> 
 37536                              <1> loc_chk_next_attr_char0:
 37537 0000941A 46                  <1> 	inc	esi
 37538 0000941B 668B06              <1> 	mov	ax, [esi]
 37539 0000941E EBA6                <1> 	jmp	short pass_attr_space
 37540                              <1> 
 37541                              <1> loc_chk_next_attr_char1:
 37542 00009420 803E2D              <1> 	cmp	byte [esi], '-'
 37543 00009423 77A1                <1> 	ja	short pass_attr_space
 37544 00009425 E989000000          <1>         jmp     loc_attr_file_check_fname_fchar
 37545                              <1> 
 37546                              <1> loc_chk_attr_enter:
 37547 0000942A 80FC0D              <1> 	cmp	ah, 0Dh
 37548                              <1> 	;jne	loc_cmd_failed
 37549                              <1> 	; 28/07/202
 37550 0000942D 7405                <1> 	je	short pass_change_attr
 37551 0000942F E9F6F0FFFF          <1> 	jmp	loc_cmd_failed
 37552                              <1> 
 37553                              <1> pass_change_attr:
 37554 00009434 A0[90350100]        <1> 	mov	al, [Attr_Chars]
 37555 00009439 F6D0                <1> 	not	al
 37556 0000943B 2005[F8810100]      <1> 	and	[Attributes], al
 37557 00009441 A0[91350100]        <1> 	mov	al, [Attr_Chars+1]
 37558 00009446 0805[F8810100]      <1> 	or	[Attributes], al
 37559                              <1> 
 37560                              <1> loc_show_attributes:
 37561 0000944C BE[0F3B0100]        <1> 	mov	esi, nextline
 37562 00009451 E8D4D7FFFF          <1> 	call	print_msg
 37563                              <1> 
 37564                              <1> loc_show_attributes_no_nextline:
 37565 00009456 C705[90350100]4E4F- <1> 	mov	dword [Attr_Chars], 'NORM'
 37566 0000945E 524D                <1>
 37567 00009460 66C705[94350100]41- <1> 	mov	word [Attr_Chars+4], 'AL'
 37568 00009468 4C                  <1>
 37569 00009469 BE[90350100]        <1> 	mov	esi, Attr_Chars
 37570 0000946E A0[F8810100]        <1> 	mov	al, [Attributes]
 37571 00009473 A804                <1> 	test	al, 04h
 37572 00009475 7406                <1> 	jz	short pass_put_attr_s
 37573 00009477 66C7065300          <1> 	mov	word [esi], 0053h     ; S
 37574 0000947C 46                  <1> 	inc	esi
 37575                              <1> 
 37576                              <1> pass_put_attr_s:
 37577 0000947D A802                <1> 	test	al, 02h
 37578 0000947F 7406                <1> 	jz	short pass_put_attr_h
 37579 00009481 66C7064800          <1> 	mov	word [esi], 0048h     ; H
 37580 00009486 46                  <1> 	inc	esi
 37581                              <1> 
 37582                              <1> pass_put_attr_h:
 37583 00009487 A801                <1> 	test	al, 01h
 37584 00009489 7406                <1> 	jz	short pass_put_attr_r
 37585 0000948B 66C7065200          <1> 	mov	word [esi], 0052h     ; R
 37586 00009490 46                  <1> 	inc	esi
 37587                              <1> 
 37588                              <1> pass_put_attr_r:
 37589 00009491 3C20                <1> 	cmp	al, 20h
 37590 00009493 7205                <1> 	jb	short pass_put_attr_a
 37591 00009495 66C7064100          <1> 	mov	word [esi], 0041h     ; A
 37592                              <1> 
 37593                              <1> pass_put_attr_a:
 37594 0000949A BE[83350100]        <1> 	mov	esi, Str_Attributes
 37595 0000949F E886D7FFFF          <1> 	call	print_msg
 37596 000094A4 BE[0F3B0100]        <1> 	mov	esi, nextline
 37597 000094A9 E87CD7FFFF          <1> 	call	print_msg
 37598 000094AE E972F9FFFF          <1> 	jmp	loc_file_rw_restore_retn 
 37599                              <1> 
 37600                              <1> loc_attr_file_check_fname_fchar:
 37601 000094B3 46                  <1> 	inc	esi
 37602 000094B4 803E20              <1> 	cmp	byte [esi], 20h
 37603 000094B7 74FA                <1> 	je	short loc_attr_file_check_fname_fchar
 37604                              <1>         ;jb	pass_change_attr
 37605                              <1> 	; 28/07/2022
 37606 000094B9 7705                <1> 	ja	short loc_attr_file_parse_path_name
 37607 000094BB E974FFFFFF          <1> 	jmp	pass_change_attr	
 37608                              <1> 	   
 37609                              <1> loc_attr_file_parse_path_name:
 37610 000094C0 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 37611 000094C5 E80D160000          <1> 	call	parse_path_name
 37612                              <1> 	;jc	loc_cmd_failed
 37613                              <1> 	; 28/07/2022
 37614 000094CA 7305                <1> 	jnc	short loc_attr_file_check_filename_exists
 37615                              <1> loc_sfa_3:
 37616 000094CC E959F0FFFF          <1> 	jmp	loc_cmd_failed
 37617                              <1> 
 37618                              <1> loc_attr_file_check_filename_exists:
 37619 000094D1 BE[24810100]        <1> 	mov	esi, FindFile_Name
 37620 000094D6 803E20              <1> 	cmp	byte [esi], 20h
 37621                              <1> 	;jna	loc_cmd_failed
 37622                              <1> 	; 28/07/2022
 37623 000094D9 76F1                <1> 	jna	short loc_sfa_3
 37624 000094DB 8935[A0810100]      <1> 	mov	[DelFile_FNPointer], esi 
 37625                              <1> 
 37626                              <1> loc_attr_file_drv:
 37627 000094E1 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 37628 000094E7 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 37629                              <1> 
 37630 000094ED 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 37631 000094F3 38F2                <1> 	cmp	dl, dh
 37632 000094F5 7407                <1> 	je	short loc_attr_file_change_directory
 37633                              <1> 
 37634 000094F7 E867E2FFFF          <1> 	call	change_current_drive
 37635                              <1> 	;jc	loc_file_rw_cmd_failed
 37636                              <1> 	; 28/07/2022
 37637 000094FC 722E                <1> 	jc	short loc_sfa_4
 37638                              <1> 
 37639                              <1> loc_attr_file_change_directory:
 37640 000094FE 803D[E3800100]20    <1>         cmp     byte [FindFile_Directory], 20h
 37641 00009505 7614                <1> 	jna	short loc_attr_file_find
 37642                              <1> 
 37643 00009507 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 37644                              <1> 	
 37645 0000950D BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 37646 00009512 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 37647 00009514 E8D20F0000          <1> 	call	change_current_directory
 37648                              <1> 	;jc	loc_file_rw_cmd_failed
 37649                              <1> 	; 28/07/2022
 37650 00009519 7211                <1> 	jc	short loc_sfa_4
 37651                              <1> 
 37652                              <1> ;loc_attr_file_change_prompt_dir_string:
 37653                              <1> 	;call	change_prompt_dir_string
 37654                              <1> 
 37655                              <1> loc_attr_file_find:
 37656                              <1> 	;mov	esi, FindFile_Name
 37657 0000951B 8B35[A0810100]      <1> 	mov	esi, [DelFile_FNPointer]
 37658 00009521 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
 37659 00009525 E8E7F4FFFF          <1> 	call	find_first_file
 37660                              <1> 	;jc	loc_file_rw_cmd_failed
 37661                              <1> 	; 28/07/2022
 37662 0000952A 7305                <1> 	jnc	short loc_attr_file_ambgfn_check
 37663                              <1> loc_sfa_4:
 37664 0000952C E9F4F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37665                              <1> 
 37666                              <1> loc_attr_file_ambgfn_check:
 37667 00009531 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
 37668                              <1> 	;	(Note: It was BX in TRDOS v1)
 37669                              <1> 	;;jz	short loc_attr_file_found
 37670                              <1> 	;jnz	loc_file_not_found ; 06/03/2016
 37671                              <1> 	; 28/07/2022 
 37672 00009534 7405                <1> 	jz	short loc_attr_file_found
 37673 00009536 E9C7FDFFFF          <1> 	jmp	loc_file_not_found	
 37674                              <1> 
 37675                              <1> 	;mov	eax, 2 ; File not found sign
 37676                              <1> 	;stc
 37677                              <1> 	;jmp	loc_file_rw_cmd_failed   
 37678                              <1> 
 37679                              <1> loc_attr_file_found:
 37680                              <1> 	; EDI = Directory buffer entry offset/address
 37681                              <1> 	; BL = File (or Directory) Attributes 
 37682                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
 37683                              <1> 	; mov	bl, [EDI+0Bh]
 37684                              <1> 	
 37685 0000953B 66833D[90350100]00  <1> 	cmp	word [Attr_Chars], 0
 37686 00009543 770B                <1> 	ja	short loc_attr_file_change_attributes
 37687 00009545 881D[F8810100]      <1> 	mov	[Attributes], bl
 37688 0000954B E9FCFEFFFF          <1> 	jmp	loc_show_attributes
 37689                              <1> 
 37690                              <1> loc_attr_file_change_attributes:
 37691 00009550 A0[90350100]        <1> 	mov	al, [Attr_Chars]
 37692 00009555 F6D0                <1> 	not	al
 37693 00009557 20C3                <1> 	and	bl, al
 37694 00009559 A0[91350100]        <1> 	mov	al, [Attr_Chars+1]
 37695 0000955E 08C3                <1> 	or	bl, al
 37696                              <1> 
 37697 00009560 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 37698 00009566 741C                <1> 	je	short loc_attr_file_fs_check
 37699                              <1> 
 37700 00009568 881D[F8810100]      <1> 	mov	[Attributes], bl
 37701 0000956E 885F0B              <1> 	mov	[edi+0Bh], bl    ; Attributes (New!)
 37702                              <1> 
 37703                              <1> 	; 04/03/2016
 37704                              <1> 	; TRDOS v1 has a bug here! it does not set
 37705                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
 37706                              <1> 	; 'save_directory_buffer' would not save the new attributes ! 
 37707                              <1> 	
 37708 00009571 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 37709                              <1> 
 37710 00009578 E896190000          <1> 	call 	save_directory_buffer
 37711                              <1> 	;jc	loc_file_rw_cmd_failed
 37712                              <1> 	;jmp	short loc_print_attr_changed_message
 37713                              <1> 	; 28/07/2022
 37714 0000957D 7334                <1> 	jnc	short loc_print_attr_changed_message
 37715                              <1> loc_sfa_5:
 37716 0000957F E9A1F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed 
 37717                              <1> 
 37718                              <1> loc_attr_file_fs_check:
 37719 00009584 29C0                <1> 	sub	eax, eax
 37720 00009586 8A25[677F0100]      <1>         mov     ah, [DirBuff_DRV]
 37721 0000958C BE00010900          <1> 	mov	esi, Logical_DOSDisks
 37722 00009591 01C6                <1>         add     esi, eax
 37723 00009593 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
 37724 00009597 7309                <1> 	jnc	short loc_attr_file_change_fs_file_attributes
 37725                              <1> 	; 29/12/2017 (0Dh -> 29)	
 37726 00009599 66B81D00            <1> 	mov	ax, 29 ; Invalid Data
 37727 0000959D E983F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37728                              <1> 
 37729                              <1> loc_attr_file_change_fs_file_attributes:
 37730                              <1> 	; BL = New MS-DOS File Attributes
 37731 000095A2 88D8                <1> 	mov	al, bl ; File/Directory Attributes
 37732 000095A4 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
 37733 000095A6 E848050000          <1> 	call	change_fs_file_attributes
 37734                              <1> 	;jc	loc_file_rw_cmd_failed
 37735                              <1> 	; 28/07/2022
 37736 000095AB 72D2                <1> 	jc	short loc_sfa_5
 37737                              <1> 
 37738 000095AD 881D[F8810100]      <1> 	mov	[Attributes], bl 
 37739                              <1> 
 37740                              <1> loc_print_attr_changed_message:
 37741 000095B3 BE[7E350100]        <1> 	mov	esi, Msg_New
 37742 000095B8 E86DD6FFFF          <1> 	call	print_msg
 37743 000095BD E994FEFFFF          <1> 	jmp	loc_show_attributes_no_nextline
 37744                              <1> 
 37745                              <1> rename_file:
 37746                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 37747                              <1> 	; 13/11/2017
 37748                              <1> 	; 06/11/2016
 37749                              <1> 	; 05/11/2016
 37750                              <1> 	; 16/10/2016
 37751                              <1> 	; 08/03/2016
 37752                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
 37753                              <1> 	; 20/11/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_rename')
 37754                              <1> 	; 16/11/2010 
 37755                              <1> 
 37756                              <1> get_rename_source_fchar:
 37757                              <1> 	; esi = file name
 37758 000095C2 803E20              <1> 	cmp	byte [esi], 20h
 37759 000095C5 7613                <1>         jna	short loc_rename_nofilename_retn
 37760                              <1> 
 37761 000095C7 8935[20820100]      <1> 	mov	[SourceFilePath], esi
 37762                              <1> 
 37763                              <1> rename_scan_source_file:
 37764 000095CD 46                  <1> 	inc	esi
 37765 000095CE 803E20              <1> 	cmp	byte [esi], 20h
 37766 000095D1 7408                <1> 	je	short rename_scan_destination_file_1
 37767                              <1> 	;;jb	short loc_rename_nofilename_retn
 37768                              <1> 	;jb	loc_cmd_failed
 37769                              <1> 	;jmp	short rename_scan_source_file
 37770                              <1> 	; 28/07/2022
 37771 000095D3 77F8                <1> 	ja	short rename_scan_source_file
 37772                              <1> loc_rename_failed:
 37773 000095D5 E950EFFFFF          <1> 	jmp	loc_cmd_failed
 37774                              <1> 
 37775                              <1> loc_rename_nofilename_retn: ; 08/03/2016
 37776 000095DA C3                  <1> 	retn
 37777                              <1> 
 37778                              <1> rename_scan_destination_file_1:
 37779 000095DB C60600              <1> 	mov	byte [esi], 0
 37780                              <1> 
 37781                              <1> rename_scan_destination_file_2:
 37782 000095DE 46                  <1> 	inc	esi  
 37783 000095DF 803E20              <1> 	cmp	byte [esi], 20h
 37784 000095E2 74FA                <1> 	je	short rename_scan_destination_file_2
 37785                              <1> 	;;jb	short loc_rename_nofilename_retn
 37786                              <1> 	;jb	loc_cmd_failed
 37787                              <1> 	; 28/07/2022
 37788 000095E4 72EF                <1> 	jb	short loc_rename_failed
 37789                              <1> 
 37790 000095E6 8935[24820100]      <1> 	mov	[DestinationFilePath], esi
 37791                              <1> 
 37792                              <1> rename_scan_destination_file_3:
 37793 000095EC 46                  <1> 	inc	esi  
 37794 000095ED 803E20              <1> 	cmp	byte [esi], 20h
 37795 000095F0 77FA                <1> 	ja	short rename_scan_destination_file_3
 37796                              <1> 
 37797 000095F2 C60600              <1> 	mov	byte [esi], 0
 37798                              <1> 
 37799                              <1> loc_rename_save_current_drive:
 37800 000095F5 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 37801 000095FB 8835[9F7F0100]      <1> 	mov	byte [RUN_CDRV], dh
 37802                              <1> 
 37803                              <1> loc_rename_sf_parse_path_name:
 37804 00009601 8B35[20820100]      <1> 	mov	esi, [SourceFilePath] 
 37805 00009607 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 37806 0000960C E8C6140000          <1> 	call	parse_path_name
 37807                              <1> 	;jc	loc_cmd_failed
 37808                              <1> 	; 28/07/2022
 37809 00009611 72C2                <1> 	jc	short loc_rename_failed
 37810                              <1> 
 37811                              <1> loc_rename_sf_check_filename_exists:
 37812 00009613 BE[24810100]        <1> 	mov	esi, FindFile_Name
 37813 00009618 803E20              <1> 	cmp	byte [esi], 20h
 37814                              <1> 	;jna	loc_cmd_failed
 37815                              <1> 	; 28/07/2022
 37816 0000961B 76B8                <1> 	jna	short loc_rename_failed
 37817                              <1> 
 37818                              <1> 	;mov	[DelFile_FNPointer], esi 
 37819                              <1> 
 37820                              <1> loc_rename_sf_drv:
 37821                              <1> 	;mov	dh, [Current_Drv]
 37822                              <1> 	;mov	[RUN_CDRV], dh
 37823                              <1> 
 37824 0000961D 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 37825 00009623 38F2                <1> 	cmp	dl, dh ; dh = [Current_Drv]
 37826 00009625 7407                <1> 	je	short rename_sf_change_directory
 37827                              <1> 
 37828 00009627 E837E1FFFF          <1> 	call	change_current_drive
 37829                              <1>  	;jc	loc_file_rw_cmd_failed
 37830                              <1> 	; 28/07/2022
 37831 0000962C 722D                <1> 	jc	short loc_rename_fff_failed
 37832                              <1> 
 37833                              <1> rename_sf_change_directory:
 37834 0000962E 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 37835 00009635 7614                <1> 	jna	short rename_sf_find
 37836                              <1> 
 37837 00009637 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 37838 0000963D BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 37839 00009642 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 37840 00009644 E8A20E0000          <1> 	call	change_current_directory
 37841                              <1>  	;jc	loc_file_rw_cmd_failed
 37842                              <1> 	; 28/07/2022
 37843 00009649 7210                <1> 	jc	short loc_rename_fff_failed
 37844                              <1> 
 37845                              <1> ;rename_sf_change_prompt_dir_string:
 37846                              <1> 	;call	change_prompt_dir_string
 37847                              <1> 
 37848                              <1> rename_sf_find:
 37849                              <1> 	;mov	esi, [DelFile_FNPointer]
 37850 0000964B BE[24810100]        <1> 	mov	esi, FindFile_Name
 37851                              <1> 
 37852 00009650 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
 37853 00009654 E8B8F3FFFF          <1> 	call	find_first_file
 37854                              <1> 	;jc	loc_file_rw_cmd_failed
 37855                              <1> 	; 28/07/2022
 37856 00009659 7305                <1> 	jnc	short loc_rename_sf_ambgfn_check
 37857                              <1> 
 37858                              <1> loc_rename_fff_failed:
 37859 0000965B E9C5F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37860                              <1> 
 37861                              <1> loc_rename_sf_ambgfn_check:
 37862 00009660 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 37863                              <1> 	;	(Note: It was BX in TRDOS v1)
 37864                              <1> 	;;jz	short loc_rename_sf_found
 37865                              <1> 	;jnz	loc_file_not_found
 37866                              <1> 	; 28/07/2022
 37867 00009663 7405                <1> 	jz	short loc_rename_sf_found
 37868 00009665 E998FCFFFF          <1> 	jmp	loc_file_not_found
 37869                              <1> 
 37870                              <1> 	;mov	eax, 2 ; File not found sign
 37871                              <1> 	;stc
 37872                              <1> 	;jmp	loc_file_rw_cmd_failed   
 37873                              <1> 
 37874                              <1> loc_rename_sf_found:
 37875                              <1> 	; EDI = Directory buffer entry offset/address
 37876                              <1> 	; BL = File (or Directory) Attributes 
 37877                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
 37878                              <1> 	; mov	bl, [EDI+0Bh]
 37879                              <1> 
 37880 0000966A F6C307              <1> 	test	bl, 07h ; Attributes, S-H-R
 37881                              <1> 	;jnz	loc_permission_denied
 37882                              <1> 	; 28/07/2022
 37883 0000966D 7405                <1> 	jz	short loc_rename_attrb_ok
 37884 0000966F E9BBF7FFFF          <1> 	jmp	loc_permission_denied
 37885                              <1> 
 37886                              <1> loc_rename_attrb_ok:	
 37887 00009674 BE[E2800100]        <1>         mov     esi, FindFile_Drv
 37888 00009679 BF[28820100]        <1>         mov     edi, SourceFile_Drv
 37889 0000967E B920000000          <1> 	mov	ecx, 32
 37890 00009683 F3A5                <1> 	rep	movsd
 37891                              <1> 
 37892                              <1> loc_rename_df_parse_path_name:
 37893 00009685 8B35[24820100]      <1> 	mov	esi, [DestinationFilePath]
 37894 0000968B BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 37895 00009690 E842140000          <1> 	call	parse_path_name
 37896 00009695 7219                <1> 	jc	short loc_rename_df_cmd_failed
 37897                              <1> 
 37898                              <1> 	;mov	dh, [RUN_CDRV]
 37899 00009697 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 37900                              <1> 
 37901                              <1> 	; 'rename' command is valid only for same dos drive and same dir!
 37902                              <1> 	; ('move' command must be used if source file and destination file
 37903                              <1> 	; directories are not same!) 
 37904 0000969D 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 37905 000096A3 38F2                <1> 	cmp	dl, dh ; are source and destination drives different ?!
 37906 000096A5 7509                <1> 	jne	short loc_rename_df_cmd_failed ; yes! 
 37907                              <1> 
 37908                              <1> rename_df_check_dirname_exists:
 37909 000096A7 803D[E3800100]00    <1> 	cmp	byte [FindFile_Directory], 0
 37910 000096AE 760B                <1> 	jna	short rename_df_check_filename_exists
 37911                              <1> 
 37912                              <1> 	; different source file and destination file directories !
 37913                              <1> loc_rename_df_cmd_failed:
 37914 000096B0 B801000000          <1> 	mov	eax, 1 ; TRDOS 'Bad command or file name' error
 37915 000096B5 F9                  <1> 	stc
 37916 000096B6 E96AF7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37917                              <1> 	  
 37918                              <1> rename_df_check_filename_exists:
 37919 000096BB BE[24810100]        <1> 	mov	esi, FindFile_Name
 37920 000096C0 E8F1F6FFFF          <1> 	call	check_filename
 37921                              <1> 	;jc	loc_mkdir_invalid_dir_name_chars
 37922                              <1> 	; 28/07/2022
 37923 000096C5 7305                <1> 	jnc	short loc_rename_file_name_ok
 37924 000096C7 E90BF8FFFF          <1> 	jmp	loc_mkdir_invalid_dir_name_chars
 37925                              <1> 
 37926                              <1> loc_rename_file_name_ok:
 37927                              <1> 	;mov	[DelFile_FNPointer], esi 
 37928                              <1> 	;cmp	byte [esi], 20h
 37929                              <1> 	;ja	short loc_rename_df_find
 37930                              <1> 
 37931                              <1> 	;mov	dh, [Current_Drv] ; dh has not been changed
 37932                              <1> 
 37933                              <1> rename_df_drv_check_writable:
 37934 000096CC 0FB6F6              <1> 	movzx	esi, dh
 37935                              <1> 	;movzx	esi, byte [Current_Drv]
 37936 000096CF 81C600010900        <1> 	add	esi, Logical_DOSDisks
 37937                              <1> 
 37938 000096D5 88F2                <1> 	mov	dl, dh ; dl = [Current_Drv]
 37939 000096D7 8A7601              <1> 	mov	dh, [esi+LD_DiskType]
 37940                              <1> 
 37941 000096DA 80FE01              <1> 	cmp	dh, 1 ; 0 = Invalid
 37942 000096DD 7310                <1> 	jnb	short rename_df_compare_sf_df_name
 37943                              <1> 
 37944                              <1> 	; 16/10/2016 (13h -> 30)
 37945 000096DF B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
 37946 000096E4 8B1D[24820100]      <1> 	mov	ebx, [DestinationFilePath] 
 37947 000096EA E936F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37948                              <1> 
 37949                              <1> rename_df_compare_sf_df_name:
 37950 000096EF BE[24810100]        <1> 	mov	esi, FindFile_Name
 37951 000096F4 BF[6A820100]        <1> 	mov	edi, SourceFile_Name
 37952                              <1> 	;mov	ecx, 12
 37953                              <1> 	; 28/07/2022
 37954 000096F9 29C9                <1> 	sub	ecx, ecx
 37955 000096FB B10C                <1> 	mov	cl, 12
 37956                              <1> rename_df_compare_sf_df_name_next: 
 37957 000096FD AC                  <1> 	lodsb
 37958 000096FE AE                  <1> 	scasb
 37959 000096FF 7506                <1> 	jne	short loc_rename_df_find
 37960 00009701 08C0                <1> 	or	al, al
 37961 00009703 74AB                <1> 	jz	short loc_rename_df_cmd_failed
 37962 00009705 E2F6                <1> 	loop	rename_df_compare_sf_df_name_next 
 37963                              <1> 
 37964                              <1> loc_rename_df_find:
 37965                              <1> 	;mov	esi, [DelFile_FNPointer]
 37966 00009707 BE[24810100]        <1> 	mov	esi, FindFile_Name
 37967                              <1> 
 37968                              <1> 	;xor	ax, ax ; Any
 37969                              <1> 	; 28/07/2022
 37970 0000970C 31C0                <1> 	xor	eax, eax ; 0 ; Any
 37971 0000970E E8FEF2FFFF          <1> 	call	find_first_file
 37972                              <1> 	;;jnc	short loc_rename_df_found
 37973                              <1> 	;; 29/12/2017
 37974                              <1> 	;jnc	loc_permission_denied
 37975                              <1> 	; 28/07/2022
 37976 00009713 7205                <1> 	jc	short loc_rename_df_check_error_code
 37977 00009715 E915F7FFFF          <1> 	jmp	loc_permission_denied	
 37978                              <1> 
 37979                              <1> loc_rename_df_check_error_code:
 37980                              <1> 	;cmp	eax, 2
 37981 0000971A 3C02                <1> 	cmp	al, 2 ; Not found error
 37982 0000971C 7406                <1> 	je	short rename_df_move_find_struct_to_dest
 37983 0000971E F9                  <1> 	stc
 37984 0000971F E901F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 37985                              <1> 
 37986                              <1> ;loc_rename_df_found:
 37987                              <1> 	; 05/11/2016
 37988                              <1> 	; Permission denied error
 37989                              <1> 	;mov	eax, ERR_PERM_DENIED ; 29/12/2017
 37990                              <1> 	;stc
 37991                              <1> 	;jmp	loc_permission_denied  ; 06/11/2016
 37992                              <1> 
 37993                              <1> rename_df_move_find_struct_to_dest:
 37994 00009724 BE[E2800100]        <1>         mov     esi, FindFile_Drv
 37995 00009729 BF[A8820100]        <1>         mov     edi, DestinationFile_Drv
 37996                              <1> 	;mov	ecx, 32
 37997                              <1> 	; 28/07/2022
 37998 0000972E 29C9                <1> 	sub	ecx, ecx
 37999 00009730 B120                <1> 	mov	cl, 32
 38000 00009732 F3A5                <1> 	rep	movsd
 38001                              <1> 
 38002                              <1> loc_rename_df_process_q_sf:
 38003                              <1> 	;mov	ecx, 12
 38004 00009734 B10C                <1> 	mov	cl, 12
 38005 00009736 BE[6A820100]        <1>  	mov	esi, SourceFile_Name
 38006 0000973B BF[BF350100]        <1> 	mov	edi, Rename_OldName
 38007                              <1> rename_df_process_q_nml_1_sf:
 38008 00009740 AC                  <1> 	lodsb
 38009 00009741 3C20                <1>         cmp	al, 20h
 38010 00009743 7603                <1>         jna	short rename_df_process_q_nml_2_sf
 38011 00009745 AA                  <1> 	stosb
 38012 00009746 E2F8                <1> 	loop	rename_df_process_q_nml_1_sf
 38013                              <1> 
 38014                              <1> rename_df_process_q_nml_2_sf:
 38015 00009748 C60700              <1> 	mov	byte [edi], 0
 38016                              <1> 
 38017                              <1> loc_rename_df_process_q_df:
 38018                              <1> 	;mov	ecx, 12
 38019 0000974B B10C                <1> 	mov	cl, 12
 38020 0000974D BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 38021 00009752 BF[D0350100]        <1> 	mov	edi, Rename_NewName
 38022                              <1> rename_df_process_q_nml_1_df:
 38023 00009757 AC                  <1> 	lodsb
 38024 00009758 3C20                <1> 	cmp	al, 20h
 38025 0000975A 7603                <1> 	jna	short loc_rename_df_process_q_nml_2_df
 38026 0000975C AA                  <1> 	stosb
 38027 0000975D E2F8                <1> 	loop	rename_df_process_q_nml_1_df
 38028                              <1> 
 38029                              <1> loc_rename_df_process_q_nml_2_df:
 38030 0000975F C60700              <1> 	mov	byte [edi], 0
 38031                              <1> 
 38032                              <1> loc_rename_confirmation_question:
 38033 00009762 BE[97350100]        <1> 	mov	esi, Msg_DoYouWantRename
 38034 00009767 E8BED4FFFF          <1> 	call	print_msg
 38035                              <1> 
 38036 0000976C A0[85820100]        <1> 	mov	al, [SourceFile_DirEntry+11] ; Attributes
 38037 00009771 2410                <1> 	and	al, 10h
 38038 00009773 750C                <1> 	jnz	short rename_confirmation_question_dir
 38039                              <1> 
 38040                              <1> rename_confirmation_question_file:
 38041 00009775 BE[AE350100]        <1> 	mov	esi, Rename_File
 38042 0000977A E8ABD4FFFF          <1> 	call	print_msg 
 38043 0000977F EB0A                <1> 	jmp	short rename_confirmation_question_as 
 38044                              <1> 
 38045                              <1> rename_confirmation_question_dir:
 38046 00009781 BE[B4350100]        <1> 	mov	esi, Rename_Directory
 38047 00009786 E89FD4FFFF          <1> 	call	print_msg
 38048                              <1> 
 38049                              <1> rename_confirmation_question_as:
 38050 0000978B BE[BF350100]        <1> 	mov	esi, Rename_OldName
 38051 00009790 E895D4FFFF          <1> 	call	print_msg
 38052 00009795 BE[CC350100]        <1> 	mov	esi, Msg_File_rename_as
 38053 0000979A E88BD4FFFF          <1> 	call	print_msg
 38054 0000979F BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 38055 000097A4 E881D4FFFF          <1> 	call	print_msg
 38056                              <1> 
 38057                              <1> loc_rename_ask_again:
 38058 000097A9 30E4                <1> 	xor	ah, ah
 38059 000097AB E81E77FFFF          <1> 	call	int16h
 38060 000097B0 3C1B                <1> 	cmp	al, 1Bh
 38061 000097B2 740F                <1> 	je	short loc_do_not_rename_file
 38062 000097B4 24DF                <1> 	and	al, 0DFh
 38063 000097B6 A2[FD340100]        <1> 	mov	[Y_N_nextline], al
 38064 000097BB 3C59                <1> 	cmp	al, 'Y'
 38065 000097BD 7404                <1> 	je	short loc_yes_rename_file
 38066 000097BF 3C4E                <1> 	cmp	al, 'N'
 38067 000097C1 75E6                <1> 	jne	short loc_rename_ask_again
 38068                              <1> 
 38069                              <1> loc_do_not_rename_file:
 38070                              <1> loc_yes_rename_file:
 38071 000097C3 E890F7FFFF          <1> 	call	y_n_answer ; 29/12/2017
 38072                              <1> 	;cmp	al, 'Y' ; 'yes'
 38073                              <1> 	;cmc
 38074                              <1>         ;jnc	loc_file_rw_restore_retn
 38075 000097C8 3C4E                <1> 	cmp	al, 'N' ; 'no'
 38076                              <1> 	;je	loc_file_rw_restore_retn
 38077                              <1> 	; 28/07/2022
 38078 000097CA 7505                <1> 	jne	short loc_rename_file_yes
 38079 000097CC E954F6FFFF          <1> 	jmp	loc_file_rw_restore_retn
 38080                              <1> 
 38081                              <1> loc_rename_file_yes: ; 28/07/2022
 38082 000097D1 BE[D0350100]        <1> 	mov	esi, Rename_NewName
 38083 000097D6 668B0D[A2820100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
 38084 000097DD 66A1[8E820100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
 38085 000097E3 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
 38086 000097E6 66A1[94820100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
 38087                              <1> 
 38088 000097EC 0FB61D[77820100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
 38089 000097F3 E8E71A0000          <1>    	call	rename_directory_entry
 38090 000097F8 E941F7FFFF          <1> 	jmp	loc_rename_file_ok	
 38091                              <1> ;loc_rename_file_ok:
 38092                              <1> ;	jc	loc_run_cmd_failed
 38093                              <1> ;	mov	esi, Msg_OK
 38094                              <1> ;	call	proc_printmsg
 38095                              <1> ;	jmp	loc_file_rw_restore_retn
 38096                              <1> 
 38097                              <1> move_file:
 38098                              <1> 	; 07/08/2022
 38099                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 38100                              <1> 	; 11/03/2016
 38101                              <1> 	; 09/03/2016
 38102                              <1> 	; 08/03/2016 (TRDOS 386 = TRDOS v2.0)
 38103                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_move')
 38104                              <1> 	; 23/04/2011
 38105                              <1> 
 38106                              <1> get_move_source_fchar:
 38107                              <1> 	; esi = file name
 38108 000097FD 803E20              <1> 	cmp	byte [esi], 20h
 38109 00009800 7613                <1>         jna	short loc_move_nofilename_retn
 38110                              <1> 
 38111 00009802 8935[20820100]      <1> 	mov	[SourceFilePath], esi
 38112                              <1> 
 38113                              <1> move_scan_source_file:
 38114 00009808 46                  <1> 	inc	esi
 38115 00009809 803E20              <1> 	cmp	byte [esi], 20h
 38116 0000980C 7408                <1>         je      short move_scan_destination_1
 38117                              <1> 	;;jb	short loc_move_nofilename_retn
 38118                              <1> 	;jb	loc_cmd_failed
 38119                              <1> 	;jmp	short move_scan_source_file
 38120                              <1> 	; 28/07/2022
 38121 0000980E 77F8                <1> 	ja	short move_scan_source_file
 38122                              <1> loc_move_failed:
 38123 00009810 E915EDFFFF          <1> 	jmp	loc_cmd_failed
 38124                              <1> 
 38125                              <1> loc_move_nofilename_retn:
 38126 00009815 C3                  <1> 	retn
 38127                              <1> 
 38128                              <1> move_scan_destination_1:
 38129 00009816 C60600              <1> 	mov	byte [esi], 0
 38130                              <1> 
 38131                              <1> move_scan_destination_2:
 38132 00009819 46                  <1> 	inc	esi  
 38133 0000981A 803E20              <1> 	cmp	byte [esi], 20h
 38134 0000981D 74FA                <1> 	je	short move_scan_destination_2
 38135                              <1> 	;;jb	short loc_move_nofilename_retn
 38136                              <1> 	;jb	loc_cmd_failed
 38137                              <1> 	; 28/07/2022
 38138 0000981F 72EF                <1> 	jb	short loc_move_failed	
 38139                              <1> 
 38140 00009821 8935[24820100]      <1> 	mov	[DestinationFilePath], esi
 38141                              <1> 
 38142                              <1> move_scan_destination_3:
 38143 00009827 46                  <1> 	inc	esi  
 38144 00009828 803E20              <1> 	cmp	byte [esi], 20h
 38145 0000982B 77FA                <1> 	ja	short move_scan_destination_3
 38146 0000982D C60600              <1> 	mov	byte [esi], 0
 38147                              <1> 
 38148                              <1> loc_move_scan_destination_OK:
 38149 00009830 8B35[20820100]      <1> 	mov	esi, [SourceFilePath]
 38150 00009836 8B3D[24820100]      <1> 	mov	edi, [DestinationFilePath]
 38151                              <1> 
 38152 0000983C B001                <1> 	mov	al, 1  ; move procedure Phase 1
 38153 0000983E E8161B0000          <1> 	call	move_source_file_to_destination_file
 38154 00009843 7325                <1> 	jnc	short move_source_file_to_destination_question
 38155                              <1> 
 38156                              <1> loc_move_cmd_failed_1:
 38157 00009845 08C0                <1> 	or	al, al
 38158                              <1> 	;jz	loc_cmd_failed
 38159                              <1> 	; 28/07/2022
 38160 00009847 74C7                <1> 	jz	short loc_move_failed
 38161                              <1>  
 38162 00009849 3C11                <1> 	cmp	al, 11h
 38163 0000984B 7409                <1> 	je	short loc_msg_not_same_device   
 38164                              <1> 	;cmp	al, 05h
 38165                              <1> 	;cmp	al, ERR_PERM_DENIED ; 29/12/2017
 38166                              <1> 	;jne	loc_run_cmd_failed
 38167                              <1> 	;jmp	loc_permission_denied
 38168 0000984D 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
 38169                              <1> 	;je	loc_permission_denied
 38170                              <1> 	; 28/07/2022
 38171 0000984F 7414                <1> 	je	short loc_move_perm_denied
 38172 00009851 E9FFECFFFF          <1> 	jmp	loc_run_cmd_failed
 38173                              <1> 
 38174                              <1> 	;mov	esi, Msg_Permission_denied
 38175                              <1> 	;call	print_msg
 38176                              <1> 	;jmp	loc_file_rw_restore_retn
 38177                              <1> 
 38178                              <1> loc_msg_not_same_device:
 38179 00009856 BE[DD350100]        <1> 	mov	esi, msg_not_same_drv 
 38180 0000985B E8CAD3FFFF          <1> 	call	print_msg
 38181 00009860 E9C0F5FFFF          <1> 	jmp	loc_file_rw_restore_retn
 38182                              <1> 
 38183                              <1> 	; 28/07/2022
 38184                              <1> loc_move_perm_denied:
 38185 00009865 E9C5F5FFFF          <1> 	jmp	loc_permission_denied	
 38186                              <1> 
 38187                              <1> move_source_file_to_destination_question:
 38188 0000986A A0[28820100]        <1>         mov     al, [SourceFile_Drv]
 38189 0000986F 0441                <1> 	add	al, 'A'
 38190 00009871 A2[3F360100]        <1> 	mov	[msg_source_file_drv], al
 38191 00009876 A0[A8820100]        <1>         mov     al, [DestinationFile_Drv]
 38192 0000987B 0441                <1> 	add	al, 'A'
 38193 0000987D A2[5E360100]        <1> 	mov	[msg_destination_file_drv], al
 38194                              <1> 
 38195 00009882 57                  <1> 	push	edi ; *
 38196                              <1> 
 38197 00009883 BE[23360100]        <1> 	mov	esi, msg_source_file
 38198 00009888 E89DD3FFFF          <1> 	call	print_msg
 38199 0000988D BE[29820100]        <1> 	mov	esi, SourceFile_Directory
 38200 00009892 803E20              <1> 	cmp	byte [esi], 20h
 38201 00009895 7605                <1> 	jna	short msftdfq_sfn
 38202 00009897 E88ED3FFFF          <1> 	call	print_msg
 38203                              <1> msftdfq_sfn:
 38204 0000989C BE[6A820100]        <1> 	mov	esi, SourceFile_Name
 38205 000098A1 E884D3FFFF          <1> 	call	print_msg
 38206 000098A6 BE[42360100]        <1> 	mov	esi, msg_destination_file
 38207 000098AB E87AD3FFFF          <1> 	call	print_msg
 38208 000098B0 BE[A9820100]        <1> 	mov	esi, DestinationFile_Directory
 38209 000098B5 803E20              <1> 	cmp	byte [esi], 20h
 38210 000098B8 7605                <1> 	jna	short msftdfq_dfn
 38211 000098BA E86BD3FFFF          <1> 	call	print_msg
 38212                              <1> msftdfq_dfn:
 38213 000098BF BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 38214 000098C4 E861D3FFFF          <1> 	call	print_msg
 38215 000098C9 BE[61360100]        <1> 	mov	esi, msg_copy_nextline
 38216 000098CE E857D3FFFF          <1> 	call	print_msg
 38217 000098D3 BE[61360100]        <1> 	mov	esi, msg_copy_nextline
 38218 000098D8 E84DD3FFFF          <1> 	call	print_msg
 38219                              <1> 
 38220                              <1> loc_move_ask_for_new_file_yes_no:
 38221 000098DD BE[EF350100]        <1> 	mov	esi, Msg_DoYouWantMoveFile
 38222 000098E2 E843D3FFFF          <1> 	call	print_msg
 38223 000098E7 BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 38224 000098EC E839D3FFFF          <1> 	call	print_msg
 38225                              <1> loc_move_ask_for_new_file_again:
 38226 000098F1 30E4                <1> 	xor	ah, ah
 38227 000098F3 E8D675FFFF          <1> 	call	int16h
 38228 000098F8 3C1B                <1> 	cmp	al, 1Bh
 38229                              <1> 	;je	short loc_do_not_move_file
 38230 000098FA 743F                <1> 	je	short loc_move_y_n_escape
 38231 000098FC 24DF                <1> 	and	al, 0DFh
 38232 000098FE A2[FD340100]        <1>         mov     [Y_N_nextline], al
 38233 00009903 3C59                <1> 	cmp	al, 'Y'
 38234 00009905 7404                <1> 	je	short loc_yes_move_file
 38235 00009907 3C4E                <1> 	cmp	al, 'N'
 38236 00009909 75E6                <1> 	jne	short loc_move_ask_for_new_file_again
 38237                              <1> 
 38238                              <1> loc_do_not_move_file:
 38239                              <1> loc_yes_move_file:
 38240 0000990B E848F6FFFF          <1> 	call	y_n_answer ; 29/12/2017
 38241 00009910 5F                  <1> 	pop	edi ; *
 38242                              <1> 	;cmp	al, 'Y' ; 'yes'
 38243                              <1> 	;cmc
 38244                              <1>         ;jnc	loc_file_rw_restore_retn
 38245 00009911 3C4E                <1> 	cmp	al, 'N' ; 'no'
 38246                              <1>         ;je	loc_file_rw_restore_retn
 38247                              <1> 	; 28/07/2022
 38248 00009913 7421                <1> 	je	short loc_move_rw_restore_retn
 38249                              <1> 
 38250                              <1> loc_move_yes_move_file:
 38251 00009915 B002                <1> 	mov	al, 2 ; move procedure Phase 2
 38252 00009917 E83D1A0000          <1> 	call	move_source_file_to_destination_file
 38253                              <1> 	;;jc	short loc_move_cmd_failed_2
 38254                              <1>         ;jnc	move_source_file_to_dest_OK
 38255                              <1> 	; 28/07/2022
 38256 0000991C 7205                <1> 	jc	short loc_move_cmd_failed_2
 38257                              <1> 	; 07/08/2022
 38258 0000991E E922F6FFFF          <1> 	jmp	move_source_file_to_dest_OK
 38259                              <1> 
 38260                              <1> ;move_source_file_to_destination_OK:
 38261                              <1> ;	mov	esi, Msg_OK
 38262                              <1> ;	call	print_msg
 38263                              <1> ;	jmp	loc_file_rw_restore_retn
 38264                              <1> 
 38265                              <1> loc_move_cmd_failed_2:
 38266 00009923 3C27                <1> 	cmp	al, 27h
 38267                              <1> 	;jne	loc_run_cmd_failed
 38268                              <1> 	; 28/07/2022
 38269 00009925 7405                <1> 	je	short loc_move_ids_err
 38270 00009927 E929ECFFFF          <1> 	jmp	loc_run_cmd_failed
 38271                              <1> 
 38272                              <1> loc_move_ids_err: ; 28/07/2022
 38273 0000992C BE[08360100]        <1> 	mov	esi, msg_insufficient_disk_space
 38274 00009931 E8F4D2FFFF          <1> 	call	print_msg
 38275                              <1> 
 38276                              <1> loc_move_rw_restore_retn: ; 28/07/2022 
 38277 00009936 E9EAF4FFFF          <1> 	jmp	loc_file_rw_restore_retn
 38278                              <1> 
 38279                              <1> loc_move_y_n_escape:
 38280 0000993B B04E                <1> 	mov	al, 'N' ; 'no'
 38281 0000993D EBCC                <1> 	jmp	short loc_do_not_move_file
 38282                              <1> 
 38283                              <1> 
 38284                              <1> copy_file:
 38285                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 38286                              <1> 	; 15/10/2016
 38287                              <1> 	; 24/03/2016
 38288                              <1> 	; 21/03/2016
 38289                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
 38290                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_copy')
 38291                              <1> 	; 01/08/2010
 38292                              <1> 
 38293                              <1> get_copy_source_fchar:
 38294                              <1> 	; esi = file name
 38295 0000993F 803E20              <1> 	cmp	byte [esi], 20h
 38296 00009942 7613                <1>         jna     short loc_copy_nofilename_retn
 38297                              <1> 
 38298 00009944 8935[20820100]      <1> 	mov	[SourceFilePath], esi
 38299                              <1> 
 38300                              <1> copy_scan_source_file:
 38301 0000994A 46                  <1> 	inc	esi  
 38302 0000994B 803E20              <1> 	cmp	byte [esi], 20h
 38303 0000994E 7408                <1> 	je	short copy_scan_destination_1
 38304                              <1> 	;;jb	short loc_copy_nofilename_retn
 38305                              <1> 	;jb	loc_cmd_failed
 38306                              <1> 	;jmp	short copy_scan_source_file
 38307                              <1> 	; 25/07/2022
 38308 00009950 73F8                <1> 	jnb	short copy_scan_source_file
 38309                              <1> copy_scan_destination_0:
 38310 00009952 E9D3EBFFFF          <1> 	jmp	loc_cmd_failed
 38311                              <1> 
 38312                              <1> loc_copy_nofilename_retn:
 38313 00009957 C3                  <1> 	retn
 38314                              <1> 
 38315                              <1> copy_scan_destination_1:
 38316 00009958 C60600              <1> 	mov	byte [esi], 0
 38317                              <1> 
 38318                              <1> copy_scan_destination_2:
 38319 0000995B 46                  <1> 	inc	esi  
 38320 0000995C 803E20              <1> 	cmp	byte [esi], 20h
 38321 0000995F 74FA                <1> 	je	short copy_scan_destination_2
 38322                              <1> 	;;jb	short loc_copy_nofilename_retn
 38323                              <1> 	;jb	loc_cmd_failed
 38324                              <1> 	; 25/07/2022
 38325 00009961 72EF                <1> 	jb	short copy_scan_destination_0	
 38326                              <1> 
 38327 00009963 8935[24820100]      <1> 	mov	[DestinationFilePath], esi
 38328                              <1> 
 38329                              <1> copy_scan_destination_3:
 38330 00009969 46                  <1> 	inc	esi  
 38331 0000996A 803E20              <1> 	cmp	byte [esi], 20h
 38332 0000996D 77FA                <1> 	ja	short copy_scan_destination_3
 38333 0000996F C60600              <1> 	mov	byte [esi], 0
 38334                              <1> 
 38335                              <1> loc_copy_save_current_drive:
 38336 00009972 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 38337 00009978 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 38338                              <1> 
 38339                              <1> copy_source_file_to_destination_phase_1:
 38340 0000997E 8B35[20820100]      <1> 	mov	esi, [SourceFilePath]
 38341 00009984 8B3D[24820100]      <1> 	mov	edi, [DestinationFilePath]
 38342                              <1> 
 38343 0000998A B001                <1> 	mov	al, 1  ; copy procedure Phase 1
 38344 0000998C E8611C0000          <1> 	call	copy_source_file_to_destination_file
 38345 00009991 7327                <1> 	jnc	short copy_source_file_to_destination_question
 38346                              <1> 
 38347                              <1> loc_copy_cmd_failed_1:
 38348                              <1> 	; 18/03/2016 (restore current drive and directory)
 38349 00009993 08C0                <1> 	or	al, al
 38350 00009995 7507                <1> 	jnz	short loc_copy_cmd_failed_2
 38351                              <1> 
 38352 00009997 FEC0                <1>         inc     al ; mov al, 1 ; Bad command or file name !
 38353                              <1> loc_copy_cmd_failed_3:	; 25/07/2022
 38354 00009999 E9B7EBFFFF          <1> 	jmp	loc_run_cmd_failed
 38355                              <1> 
 38356                              <1> loc_copy_cmd_failed_2:
 38357 0000999E 3C27                <1> 	cmp	al, 27h ; Insufficient disk space 
 38358 000099A0 7409                <1> 	je	short loc_file_write_insuff_disk_space_msg
 38359                              <1>  
 38360                              <1> 	; 29/12/2017
 38361                              <1> 	;cmp	al, 05h
 38362 000099A2 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
 38363                              <1> 	;jne	loc_run_cmd_failed
 38364                              <1> 	; 25/07/2022
 38365 000099A4 75F3                <1> 	jne	short loc_copy_cmd_failed_3
 38366                              <1> 	
 38367 000099A6 E984F4FFFF          <1> 	jmp	loc_permission_denied
 38368                              <1> 
 38369                              <1> loc_file_write_insuff_disk_space_msg:
 38370 000099AB BE[08360100]        <1> 	mov	esi, msg_insufficient_disk_space
 38371 000099B0 E875D2FFFF          <1> 	call	print_msg
 38372 000099B5 E96BF4FFFF          <1>         jmp     loc_file_rw_restore_retn 
 38373                              <1> 
 38374                              <1> copy_source_file_to_destination_question:
 38375 000099BA 57                  <1> 	push	edi ; *
 38376                              <1> 
 38377                              <1> 	; dh = source file attributes
 38378                              <1> 	; dl > 0 -> destination file found
 38379 000099BB 20D2                <1> 	and	dl, dl            
 38380 000099BD 7446                <1> 	jz	short copy_source_file_to_destination_pass_owrq
 38381                              <1> 
 38382                              <1> loc_copy_ask_for_owr_yes_no:
 38383 000099BF BE[64360100]        <1> 	mov	esi, Msg_DoYouWantOverWriteFile
 38384 000099C4 E861D2FFFF          <1> 	call	print_msg
 38385 000099C9 BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 38386 000099CE E857D2FFFF          <1> 	call	print_msg
 38387 000099D3 BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 38388 000099D8 E84DD2FFFF          <1> 	call	print_msg
 38389                              <1> 
 38390                              <1> loc_copy_ask_for_owr_again:
 38391 000099DD 30E4                <1> 	xor	ah, ah
 38392 000099DF E8EA74FFFF          <1> 	call	int16h
 38393 000099E4 3C1B                <1> 	cmp	al, 1Bh
 38394                              <1>         ;je     loc_do_not_copy_file
 38395 000099E6 7419                <1>         je      short loc_copy_y_n_escape
 38396 000099E8 24DF                <1> 	and	al, 0DFh
 38397 000099EA A2[FD340100]        <1>         mov     [Y_N_nextline], al
 38398 000099EF 3C59                <1> 	cmp	al, 'Y'
 38399                              <1> 	;je	loc_yes_copy_file
 38400                              <1> 	; 25/07/2022
 38401 000099F1 7505                <1> 	jne	short loc_copy_ask_for_owr_n
 38402 000099F3 E9AD000000          <1> 	jmp	loc_yes_copy_file
 38403                              <1> 
 38404                              <1> loc_copy_ask_for_owr_n: ; 25/07/2022
 38405 000099F8 3C4E                <1> 	cmp	al, 'N'
 38406                              <1>         ;je	loc_do_not_copy_file
 38407                              <1> 	;jmp	short loc_copy_ask_for_owr_again
 38408                              <1> 	; 25/07/2022
 38409 000099FA 75E1                <1> 	jne	short loc_copy_ask_for_owr_again
 38410                              <1> loc_do_not_copy_file_j:
 38411 000099FC E9A4000000          <1> 	jmp	loc_do_not_copy_file
 38412                              <1> 
 38413                              <1> loc_copy_y_n_escape:
 38414 00009A01 B04E                <1> 	mov	al, 'N' ; 'no'
 38415                              <1> 	;jmp	loc_do_not_copy_file
 38416                              <1> 	; 25/07/2022
 38417 00009A03 EBF7                <1> 	jmp	short loc_do_not_copy_file_j
 38418                              <1> 
 38419                              <1> copy_source_file_to_destination_pass_owrq:
 38420 00009A05 A0[28820100]        <1> 	mov     al, [SourceFile_Drv]
 38421 00009A0A 0441                <1> 	add	al, 'A'
 38422 00009A0C A2[3F360100]        <1> 	mov	[msg_source_file_drv], al
 38423 00009A11 A0[A8820100]        <1>         mov     al, [DestinationFile_Drv]
 38424 00009A16 0441                <1> 	add	al, 'A'
 38425 00009A18 A2[5E360100]        <1> 	mov	[msg_destination_file_drv], al
 38426                              <1> 
 38427 00009A1D BE[23360100]        <1> 	mov	esi, msg_source_file
 38428 00009A22 E803D2FFFF          <1> 	call	print_msg
 38429 00009A27 BE[29820100]        <1> 	mov	esi, SourceFile_Directory
 38430 00009A2C 803E20              <1> 	cmp	byte [esi], 20h
 38431 00009A2F 7605                <1> 	jna	short csftdfq_sfn
 38432 00009A31 E8F4D1FFFF          <1> 	call	print_msg
 38433                              <1> csftdfq_sfn:
 38434 00009A36 BE[6A820100]        <1> 	mov	esi, SourceFile_Name
 38435 00009A3B E8EAD1FFFF          <1> 	call	print_msg
 38436 00009A40 BE[42360100]        <1> 	mov	esi, msg_destination_file
 38437 00009A45 E8E0D1FFFF          <1> 	call	print_msg
 38438 00009A4A BE[A9820100]        <1> 	mov	esi, DestinationFile_Directory
 38439 00009A4F 803E20              <1> 	cmp	byte [esi], 20h
 38440 00009A52 7605                <1> 	jna	short csftdfq_dfn
 38441 00009A54 E8D1D1FFFF          <1> 	call	print_msg
 38442                              <1> csftdfq_dfn:
 38443 00009A59 BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 38444 00009A5E E8C7D1FFFF          <1> 	call	print_msg
 38445 00009A63 BE[61360100]        <1> 	mov	esi, msg_copy_nextline
 38446 00009A68 E8BDD1FFFF          <1> 	call	print_msg
 38447 00009A6D BE[61360100]        <1> 	mov	esi, msg_copy_nextline
 38448 00009A72 E8B3D1FFFF          <1> 	call	print_msg
 38449                              <1> 
 38450                              <1> loc_copy_ask_for_new_file_yes_no:
 38451 00009A77 BE[83360100]        <1> 	mov	esi, Msg_DoYouWantCopyFile
 38452 00009A7C E8A9D1FFFF          <1> 	call	print_msg
 38453 00009A81 BE[F3340100]        <1> 	mov	esi, Msg_YesNo
 38454 00009A86 E89FD1FFFF          <1> 	call	print_msg
 38455                              <1> 
 38456                              <1> loc_copy_ask_for_new_file_again:
 38457 00009A8B 30E4                <1> 	xor	ah, ah
 38458 00009A8D E83C74FFFF          <1> 	call	int16h
 38459 00009A92 3C1B                <1> 	cmp	al, 1Bh
 38460 00009A94 740F                <1> 	je	short loc_do_not_copy_file
 38461 00009A96 24DF                <1> 	and	al, 0DFh
 38462 00009A98 A2[FD340100]        <1>         mov     [Y_N_nextline], al
 38463 00009A9D 3C59                <1> 	cmp	al, 'Y'
 38464 00009A9F 7404                <1> 	je	short loc_yes_copy_file
 38465 00009AA1 3C4E                <1> 	cmp	al, 'N'
 38466 00009AA3 75E6                <1> 	jne	short loc_copy_ask_for_new_file_again
 38467                              <1> 
 38468                              <1> loc_do_not_copy_file:
 38469                              <1> loc_yes_copy_file:
 38470 00009AA5 E8AEF4FFFF          <1> 	call	y_n_answer ; 29/12/2017
 38471 00009AAA 5F                  <1> 	pop	edi ; *
 38472                              <1> 	;cmp	al, 'Y' ; 'yes'
 38473                              <1> 	;cmc
 38474                              <1>         ;jnc	loc_file_rw_restore_retn
 38475 00009AAB 3C4E                <1> 	cmp	al, 'N' ; 'no'
 38476                              <1> 	;je	loc_file_rw_restore_retn
 38477                              <1> 	; 25/07/2022
 38478 00009AAD 7505                <1> 	jne	short copy_source_file_to_destination_pass_q
 38479 00009AAF E971F3FFFF          <1> 	jmp	loc_file_rw_restore_retn	
 38480                              <1> 
 38481                              <1> copy_source_file_to_destination_pass_q:
 38482 00009AB4 B002                <1> 	mov	al, 2  ; copy procedure Phase 2
 38483 00009AB6 E8371B0000          <1> 	call	copy_source_file_to_destination_file
 38484                              <1> 	;jc	short loc_file_write_check_disk_space_err
 38485                              <1> 
 38486                              <1> 	; 24/03/2016
 38487                              <1> 	;push	cx
 38488 00009ABB 51                  <1> 	push	ecx ; 29/12/2017
 38489 00009ABC BE[61360100]        <1> 	mov	esi, msg_copy_nextline
 38490 00009AC1 E864D1FFFF          <1> 	call	print_msg
 38491 00009AC6 58                  <1> 	pop	eax ; 29/12/2017
 38492                              <1> 	;;pop	cx
 38493                              <1> 	;pop	ax
 38494                              <1> 
 38495                              <1> 	;or	cl, cl
 38496 00009AC7 08C0                <1> 	or	al, al
 38497 00009AC9 7419                <1> 	jz	short copy_source_file_to_destination_OK
 38498                              <1> 	
 38499                              <1> 	; 15/10/2016 (1Dh -> 18)
 38500                              <1> 	; 18/03/2016 (1Dh)
 38501                              <1> 	;cmp	cl, 18 ; write error
 38502 00009ACB 3C12                <1> 	cmp	al, 18
 38503 00009ACD 7506                <1> 	jne	short copy_source_file_to_destination_not_OK
 38504                              <1> 	;
 38505                              <1> 	;mov	al, cl ; error number (write fault!)
 38506 00009ACF F9                  <1> 	stc
 38507 00009AD0 E950F3FFFF          <1> 	jmp	loc_file_rw_cmd_failed
 38508                              <1> 
 38509                              <1> copy_source_file_to_destination_not_OK:
 38510 00009AD5 BE[9C360100]        <1> 	mov	esi, Msg_read_file_error_before_EOF
 38511 00009ADA E84BD1FFFF          <1> 	call	print_msg
 38512 00009ADF E941F3FFFF          <1> 	jmp	loc_file_rw_restore_retn	      
 38513                              <1>  
 38514                              <1> copy_source_file_to_destination_OK:
 38515 00009AE4 BE[01350100]        <1> 	mov	esi, Msg_OK
 38516 00009AE9 E83CD1FFFF          <1> 	call	print_msg
 38517                              <1> 
 38518 00009AEE E932F3FFFF          <1> 	jmp	loc_file_rw_restore_retn
 38519                              <1> 
 38520                              <1> ;loc_file_write_check_disk_space_err:
 38521                              <1> 	;cmp	al, 27h ; Insufficient disk space 
 38522                              <1> 	;je	loc_file_write_insuff_disk_space_msg
 38523                              <1>         ;jb	loc_file_rw_cmd_failed
 38524                              <1> 
 38525                              <1> 	;call	print_misc_error_msg ; 15/03/2016
 38526                              <1>         ;jmp	loc_file_rw_restore_retn 
 38527                              <1> 
 38528                              <1> change_fs_file_attributes:
 38529                              <1> 	; 04/03/2016 ; Temporary
 38530                              <1> 	; AL = File or directory attributes
 38531                              <1> 	; AH = 0 -> Attributes are in MS-DOS format
 38532                              <1> 	; AH > 0 -> Attributes are in SINGLIX format
 38533                              <1> 	;push	ebx
 38534                              <1> 	; ... do somethings here ...
 38535                              <1> 	;pop	ebx
 38536                              <1> 	; BL = File or directory attributes
 38537 00009AF3 C3                  <1> 	retn
 38538                              <1> 
 38539                              <1> set_get_env:
 38540                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 38541                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
 38542                              <1> 	; 02/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_set')
 38543                              <1> 	; 2005 - 28/08/2011 
 38544                              <1> get_setenv_fchar:
 38545                              <1> 	; esi = environment variable/string
 38546 00009AF4 8A06                <1> 	mov	al, [esi]
 38547 00009AF6 3C20                <1> 	cmp	al, 20h
 38548 00009AF8 771E                <1> 	ja	short loc_find_env
 38549                              <1> 
 38550 00009AFA BE00300900          <1> 	mov	esi, Env_Page
 38551                              <1> loc_print_setline:
 38552 00009AFF 803E00              <1> 	cmp	byte [esi], 0
 38553 00009B02 7613                <1> 	jna	short loc_setenv_retn
 38554 00009B04 E821D1FFFF          <1> 	call	print_msg
 38555 00009B09 56                  <1> 	push	esi
 38556 00009B0A BE[0F3B0100]        <1> 	mov	esi, nextline
 38557 00009B0F E816D1FFFF          <1> 	call	print_msg 
 38558 00009B14 5E                  <1> 	pop	esi
 38559 00009B15 EBE8                <1> 	jmp	short loc_print_setline   
 38560                              <1> 
 38561                              <1> loc_setenv_retn: 
 38562 00009B17 C3                  <1> 	retn
 38563                              <1> 
 38564                              <1> loc_find_env:
 38565 00009B18 3C3D                <1> 	cmp	al, '='
 38566                              <1> 	;je	loc_cmd_failed
 38567                              <1> 	; 25/07/2022
 38568 00009B1A 7505                <1> 	jne	short loc_find_envr
 38569 00009B1C E909EAFFFF          <1> 	jmp	loc_cmd_failed
 38570                              <1> 
 38571                              <1> loc_find_envr:	; 25/07/2022
 38572 00009B21 56                  <1> 	push	esi
 38573                              <1> loc_repeat_env_equal_check:
 38574 00009B22 46                  <1> 	inc	esi
 38575 00009B23 803E3D              <1> 	cmp	byte [esi], '='
 38576 00009B26 7430                <1> 	je	short pass_env_equal_check
 38577 00009B28 803E20              <1> 	cmp	byte [esi], 20h
 38578 00009B2B 73F5                <1> 	jnb	short loc_repeat_env_equal_check
 38579 00009B2D C60600              <1> 	mov	byte [esi], 0 
 38580 00009B30 5E                  <1> 	pop	esi
 38581                              <1> 	; 25/07/2022 (*)
 38582                              <1> loc_print_env_string:
 38583 00009B31 BF[42790100]        <1> 	mov	edi, TextBuffer ; out buffer
 38584 00009B36 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
 38585 00009B3B 30C0                <1> 	xor	al, al ; 0 -> use [ESI]
 38586 00009B3D E877000000          <1> 	call	get_environment_string
 38587 00009B42 72D3                <1> 	jc	short loc_setenv_retn
 38588                              <1> 	 ; 25/07/2022
 38589                              <1> ;loc_print_env_string:
 38590 00009B44 BE[42790100]        <1> 	mov	esi, TextBuffer
 38591 00009B49 E8DCD0FFFF          <1> 	call	print_msg
 38592 00009B4E BE[0F3B0100]        <1> 	mov	esi, nextline
 38593                              <1> 	;call	print_msg
 38594                              <1> 	;retn
 38595                              <1> 	; 25/07/2022
 38596 00009B53 E9D2D0FFFF          <1> 	jmp	print_msg
 38597                              <1>               
 38598                              <1> pass_env_equal_check:
 38599 00009B58 46                  <1> 	inc	esi
 38600 00009B59 803E20              <1> 	cmp	byte [esi], 20h
 38601 00009B5C 73FA                <1> 	jnb	short pass_env_equal_check
 38602 00009B5E C60600              <1> 	mov	byte [esi], 0	
 38603                              <1> 
 38604                              <1> loc_call_set_env_string:
 38605 00009B61 5E                  <1> 	pop	esi
 38606 00009B62 E815010000          <1> 	call	set_environment_string
 38607 00009B67 73AE                <1> 	jnc	short loc_setenv_retn
 38608                              <1> 
 38609                              <1> loc_set_cmd_failed:
 38610 00009B69 3C08                <1> 	cmp	al, 08h
 38611                              <1> 	;jne	loc_cmd_failed
 38612                              <1> 	; 25/07/2022
 38613 00009B6B 7405                <1> 	je	short loc_set_cmd_failed_spc
 38614 00009B6D E9B8E9FFFF          <1> 	jmp	loc_cmd_failed
 38615                              <1> 
 38616                              <1> loc_set_cmd_failed_spc:
 38617 00009B72 BE[DC360100]        <1> 	mov	esi, Msg_No_Set_Space
 38618                              <1> 	;call	print_msg
 38619                              <1> 	;retn
 38620                              <1> 	; 25/07/2022
 38621 00009B77 E9AED0FFFF          <1> 	jmp	print_msg
 38622                              <1> 
 38623                              <1> set_get_path:
 38624                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 38625                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
 38626                              <1> 	; 03/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_path')
 38627                              <1> 	; 2005
 38628                              <1> get_path_fchar:
 38629                              <1>  	; esi = path
 38630 00009B7C 803E20              <1> 	cmp	byte [esi], 20h
 38631 00009B7F 7711                <1> 	ja	short loc_set_path
 38632                              <1> 
 38633 00009B81 BE00300900          <1> 	mov	esi, Env_Page
 38634                              <1> loc_print_path:
 38635 00009B86 803E00              <1> 	cmp	byte [esi], 0
 38636 00009B89 762D                <1> 	jna	short loc_path_retn
 38637                              <1> 
 38638 00009B8B BE[3C310100]        <1> 	mov	esi, Cmd_Path ; 'PATH' address
 38639                              <1> 	; 25/07/2022 (*)
 38640 00009B90 EB9F                <1> 	jmp	short loc_print_env_string
 38641                              <1> ; 25/07/2022
 38642                              <1> ;	mov	edi, TextBuffer ; out buffer
 38643                              <1> ;	xor	al, al  ; use [ESI]
 38644                              <1> ;	mov	ecx, 255 ; maximum size (limit)
 38645                              <1> ;	call	get_environment_string
 38646                              <1> ;	;jc	short loc_path_retn
 38647                              <1> ;	; 25/07/2022
 38648                              <1> ;	jnc	short loc_print_env_string
 38649                              <1> ;	retn
 38650                              <1> 
 38651                              <1> ;	mov	esi, TextBuffer
 38652                              <1> ;	call	print_msg
 38653                              <1> ;	mov	esi, nextline
 38654                              <1> ;	;call	print_msg
 38655                              <1> ;loc_path_retn: 
 38656                              <1> ;	;retn
 38657                              <1> ;	; 25/07/2022
 38658                              <1> ;	jmp	print_msg
 38659                              <1> 
 38660                              <1> loc_set_path:
 38661 00009B92 56                  <1> 	push	esi 
 38662                              <1> loc_set_path_find_end:
 38663 00009B93 46                  <1> 	inc	esi
 38664 00009B94 803E20              <1> 	cmp	byte [esi], 20h
 38665 00009B97 73FA                <1> 	jnb	short loc_set_path_find_end
 38666 00009B99 C60600              <1> 	mov	byte [esi], 0 
 38667                              <1> loc_set_path_header: 
 38668 00009B9C 5E                  <1> 	pop	esi
 38669                              <1> set_path_x: ; 31/12/2017 ('syspath')	  
 38670 00009B9D 4E                  <1> 	dec	esi
 38671 00009B9E C6063D              <1> 	mov	byte [esi], '='
 38672 00009BA1 4E                  <1> 	dec	esi
 38673 00009BA2 C60648              <1> 	mov	byte [esi], 'H'
 38674 00009BA5 4E                  <1> 	dec	esi
 38675 00009BA6 C60654              <1> 	mov	byte [esi], 'T'
 38676 00009BA9 4E                  <1> 	dec	esi
 38677 00009BAA C60641              <1> 	mov	byte [esi], 'A'
 38678 00009BAD 4E                  <1> 	dec	esi
 38679 00009BAE C60650              <1> 	mov	byte [esi], 'P'   
 38680                              <1> 
 38681                              <1> loc_path_call_set_env_string:
 38682 00009BB1 E8C6000000          <1> 	call	set_environment_string
 38683 00009BB6 72B1                <1>         jc	short loc_set_cmd_failed
 38684                              <1> loc_path_retn:	; 25/07/2022
 38685 00009BB8 C3                  <1> 	retn              
 38686                              <1> 
 38687                              <1> get_environment_string:
 38688                              <1> 	; 12/04/2016
 38689                              <1> 	; 11/04/2016
 38690                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
 38691                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
 38692                              <1> 	; 28/08/2011
 38693                              <1> 	; INPUT->
 38694                              <1> 	;	EDI = Output buffer
 38695                              <1> 	;	CX = Buffer length (<= ENV_PAGE_SIZE)
 38696                              <1> 	;
 38697                              <1> 	;	AL > 0 = AL = String sequence number
 38698                              <1> 	;	AL = 0 -> ESI = ASCIIZ Set word 
 38699                              <1> 	;		(environment variable)
 38700                              <1> 	; OUTPUT ->
 38701                              <1> 	;	ESI is not changed
 38702                              <1> 	;	EDI is not changed
 38703                              <1> 	;	EAX = String length (with zero tail)
 38704                              <1> 	;	EDX = Environment variables page address
 38705                              <1> 	;	CF = 1 -> Not found (EAX not valid)
 38706                              <1> 	;
 38707                              <1> 	; (Modified registers: EAX, EDX) 
 38708                              <1> 
 38709 00009BB9 BA00300900          <1> 	mov	edx, Env_Page
 38710 00009BBE 803A00              <1> 	cmp	byte [edx], 0
 38711 00009BC1 7474                <1> 	jz	short get_env_string_with_word_stc_retn
 38712                              <1> 
 38713 00009BC3 66890D[AC830100]    <1> 	mov	[env_var_length], cx
 38714                              <1> 
 38715 00009BCA 51                  <1> 	push	ecx ; *
 38716 00009BCB 56                  <1> 	push	esi ; **
 38717                              <1> 
 38718 00009BCC 08C0                <1> 	or	al, al
 38719 00009BCE 7449                <1> 	jz	short get_env_string_with_word
 38720                              <1> 
 38721                              <1> get_env_string_with_seq_number:
 38722 00009BD0 B101                <1> 	mov	cl, 1
 38723 00009BD2 88C5                <1> 	mov	ch, al
 38724 00009BD4 31C0                <1> 	xor	eax, eax
 38725 00009BD6 89D6                <1> 	mov	esi, edx ; Env_Page
 38726                              <1> 
 38727                              <1> get_env_string_seq_number_check:
 38728 00009BD8 38CD                <1> 	cmp	ch, cl
 38729 00009BDA 7726                <1> 	ja	short get_env_string_seq_number_next
 38730                              <1> 
 38731                              <1> get_env_string_move_to_buff:
 38732 00009BDC 57                  <1> 	push	edi ; ***
 38733                              <1> 
 38734 00009BDD 29D2                <1> 	sub	edx, edx
 38735                              <1> 
 38736                              <1> get_env_string_seq_number_repeat1:
 38737 00009BDF 42                  <1> 	inc	edx
 38738 00009BE0 AC                  <1> 	lodsb
 38739 00009BE1 AA                  <1> 	stosb
 38740                              <1> 
 38741 00009BE2 66FF0D[AC830100]    <1> 	dec	word [env_var_length]
 38742 00009BE9 7508                <1> 	jnz	short get_env_string_seq_number_repeat3
 38743                              <1> 
 38744                              <1> get_env_string_seq_number_repeat2:
 38745 00009BEB 20C0                <1> 	and	al, al
 38746 00009BED 7408                <1> 	jz	short get_env_string_seq_number_ok
 38747 00009BEF 42                  <1> 	inc	edx
 38748 00009BF0 AC                  <1> 	lodsb
 38749 00009BF1 EBF8                <1> 	jmp	short get_env_string_seq_number_repeat2
 38750                              <1> 
 38751                              <1> get_env_string_seq_number_repeat3:
 38752 00009BF3 08C0                <1> 	or	al, al
 38753 00009BF5 75E8                <1> 	jnz	short get_env_string_seq_number_repeat1
 38754                              <1> 
 38755                              <1> get_env_string_seq_number_ok:
 38756 00009BF7 5F                  <1> 	pop	edi ; ***
 38757 00009BF8 89D0                <1> 	mov	eax, edx ; Length of the environment string
 38758                              <1> 			 ; (ASCIIZ, includes ZERO tail)
 38759 00009BFA BA00300900          <1> 	mov	edx, Env_Page
 38760                              <1> 
 38761                              <1> get_env_string_stc_retn:
 38762 00009BFF 5E                  <1> 	pop	esi ; **
 38763 00009C00 59                  <1> 	pop	ecx ; *
 38764 00009C01 C3                  <1> 	retn   
 38765                              <1> 	
 38766                              <1> get_env_string_seq_number_next:
 38767 00009C02 AC                  <1> 	lodsb
 38768 00009C03 08C0                <1> 	or	al, al
 38769 00009C05 75FB                <1> 	jnz	short get_env_string_seq_number_next
 38770                              <1> 
 38771 00009C07 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; +512 (+4096)
 38772 00009C0D F5                  <1> 	cmc
 38773 00009C0E 72EF                <1> 	jc	short get_env_string_stc_retn
 38774                              <1> 
 38775 00009C10 AC                  <1> 	lodsb
 38776 00009C11 3C01                <1> 	cmp	al, 1
 38777 00009C13 72EA                <1> 	jb	short get_env_string_stc_retn
 38778 00009C15 FEC1                <1> 	inc	cl
 38779 00009C17 EBBF                <1> 	jmp	short get_env_string_seq_number_check
 38780                              <1> 
 38781                              <1> get_env_string_with_word:
 38782 00009C19 31C9                <1> 	xor	ecx, ecx
 38783                              <1> 
 38784                              <1> get_env_string_calc_word_length:
 38785 00009C1B AC                  <1> 	lodsb 
 38786 00009C1C 3C20                <1> 	cmp	al, 20h
 38787 00009C1E 7211                <1> 	jb	short get_env_string_calc_word_length_ok
 38788                              <1> 	;inc	cx
 38789 00009C20 FEC1                <1> 	inc	cl
 38790                              <1> 
 38791 00009C22 3C61                <1> 	cmp	al, 'a'
 38792 00009C24 72F5                <1> 	jb	short get_env_string_calc_word_length
 38793 00009C26 3C7A                <1> 	cmp	al, 'z'
 38794 00009C28 77F1                <1> 	ja	short get_env_string_calc_word_length
 38795 00009C2A 24DF                <1> 	and	al, 0DFh
 38796 00009C2C 8846FF              <1> 	mov	[esi-1], al
 38797 00009C2F EBEA                <1> 	jmp	short get_env_string_calc_word_length
 38798                              <1> 	
 38799                              <1> get_env_string_calc_word_length_ok:
 38800 00009C31 08C9                <1> 	or	cl, cl
 38801 00009C33 7506                <1> 	jnz	short get_env_string_calc_word_length_save
 38802                              <1>      
 38803 00009C35 5E                  <1> 	pop	esi ; **
 38804                              <1> 
 38805                              <1> get_env_string_stc_retn1:
 38806 00009C36 59                  <1> 	pop	ecx ; *
 38807                              <1>         
 38808                              <1> get_env_string_with_word_stc_retn:
 38809 00009C37 31C0                <1> 	xor	eax, eax  
 38810 00009C39 F9                  <1> 	stc
 38811 00009C3A C3                  <1> 	retn
 38812                              <1>   
 38813                              <1> get_env_string_calc_word_length_save:
 38814 00009C3B 871C24              <1> 	xchg	ebx, [esp] ; **
 38815 00009C3E 89DE                <1> 	mov	esi, ebx 
 38816                              <1> 		; Start of the env string (to be searched)
 38817                              <1> 
 38818 00009C40 57                  <1> 	push	edi ; ***
 38819 00009C41 89D7                <1> 	mov	edi, edx ; Env_Page
 38820                              <1> 
 38821                              <1> get_env_string_compare:
 38822 00009C43 57                  <1> 	push	edi ; ****
 38823 00009C44 51                  <1> 	push	ecx ; ***** ; Variable name length
 38824                              <1> 
 38825                              <1> get_env_string_compare_rep:
 38826 00009C45 AC                  <1> 	lodsb
 38827 00009C46 AE                  <1> 	scasb
 38828 00009C47 7511                <1> 	jne	short get_env_string_compare_next1
 38829 00009C49 E2FA                <1> 	loop	get_env_string_compare_rep
 38830                              <1> 	
 38831 00009C4B 803F3D              <1> 	cmp	byte [edi], '='
 38832 00009C4E 750A                <1> 	jne	short get_env_string_compare_next1
 38833                              <1>  
 38834 00009C50 59                  <1> 	pop	ecx ; *****
 38835 00009C51 5F                  <1> 	pop	edi ; ****
 38836 00009C52 89FE                <1> 	mov	esi, edi
 38837 00009C54 5F                  <1> 	pop	edi ; ***
 38838 00009C55 871C24              <1> 	xchg	ebx, [esp] ; **
 38839 00009C58 EB82                <1> 	jmp	short get_env_string_move_to_buff
 38840                              <1> 
 38841                              <1> get_env_string_compare_next1:
 38842 00009C5A 89FE                <1> 	mov	esi, edi
 38843 00009C5C 59                  <1> 	pop	ecx ; *****
 38844 00009C5D 5F                  <1> 	pop	edi ; ****
 38845                              <1> get_env_string_compare_next2:
 38846 00009C5E 81FEFF310900        <1> 	cmp	esi, Env_Page + Env_Page_Size - 1 ; +511 (+4095)
 38847 00009C64 7310                <1> 	jnb	short get_env_string_compare_not_ok
 38848 00009C66 20C0                <1> 	and	al, al
 38849 00009C68 AC                  <1> 	lodsb
 38850 00009C69 75F3                <1> 	jnz	short get_env_string_compare_next2
 38851 00009C6B 08C0                <1> 	or	al, al
 38852 00009C6D 7407                <1> 	jz	short get_env_string_compare_not_ok
 38853 00009C6F 4E                  <1> 	dec	esi ; 12/04/2016
 38854 00009C70 89F7                <1> 	mov	edi, esi
 38855 00009C72 89DE                <1> 	mov	esi, ebx
 38856 00009C74 EBCD                <1> 	jmp	short get_env_string_compare
 38857                              <1> 
 38858                              <1> get_env_string_compare_not_ok:
 38859 00009C76 5F                  <1> 	pop	edi ; ***
 38860 00009C77 89DE                <1> 	mov	esi, ebx
 38861 00009C79 5B                  <1> 	pop	ebx ; **
 38862 00009C7A EBBA                <1> 	jmp	short get_env_string_stc_retn1
 38863                              <1> 
 38864                              <1> set_environment_string:
 38865                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 38866                              <1> 	; 13/04/2016
 38867                              <1> 	; 12/04/2016
 38868                              <1> 	; 11/04/2016
 38869                              <1> 	; 06/04/2016
 38870                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
 38871                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
 38872                              <1> 	; 29/08/2011
 38873                              <1> 	; 29/08/2011
 38874                              <1> 	; INPUT->
 38875                              <1> 	;	ESI = ASCIIZ environment string
 38876                              <1> 	; OUTPUT ->
 38877                              <1> 	;	ESI is not changed
 38878                              <1> 	;	CF = 1 -> Could not set, 
 38879                              <1> 	;	     insufficient environment space
 38880                              <1> 	;
 38881                              <1> 	; (EAX, EDX will be changed) 
 38882                              <1> 	;
 38883                              <1> 	;    (EAX = Start address of the env string if > 0)	
 38884                              <1> 	;    (EDX = Environment string length)	
 38885                              <1> 
 38886 00009C7C 56                  <1> 	push 	esi ; *
 38887                              <1> 
 38888 00009C7D 31C0                <1> 	xor	eax, eax
 38889                              <1> 
 38890                              <1> set_env_chk_validation1:
 38891 00009C7F FEC4                <1> 	inc	ah ; variable (string) length
 38892 00009C81 AC                  <1> 	lodsb
 38893 00009C82 3C3D                <1> 	cmp	al, '='
 38894 00009C84 7415                <1> 	je	short set_env_chk_validation2
 38895 00009C86 3C20                <1> 	cmp	al, 20h
 38896 00009C88 720F                <1> 	jb	short set_env_string_stc
 38897                              <1> 
 38898                              <1> 	; 06/04/2016
 38899 00009C8A 3C61                <1> 	cmp	al, 'a'
 38900 00009C8C 72F1                <1> 	jb	short set_env_chk_validation1
 38901 00009C8E 3C7A                <1> 	cmp	al, 'z'
 38902 00009C90 77ED                <1> 	ja	short set_env_chk_validation1
 38903 00009C92 2C20                <1> 	sub	al, 'a'-'A'
 38904 00009C94 8846FF              <1> 	mov	[esi-1], al
 38905 00009C97 EBE6                <1> 	jmp	short set_env_chk_validation1
 38906                              <1> 
 38907                              <1> set_env_string_stc:
 38908 00009C99 5E                  <1> 	pop	esi ; *
 38909                              <1> 	;stc
 38910 00009C9A C3                  <1> 	retn 
 38911                              <1> 	   
 38912                              <1> set_env_chk_validation2:
 38913 00009C9B 51                  <1> 	push	ecx ; **
 38914 00009C9C 53                  <1> 	push	ebx ; *** 
 38915 00009C9D 57                  <1> 	push	edi ; ****
 38916                              <1> 
 38917                              <1> 	; 12/04/2016
 38918                              <1> 	;mov	ebx, [esp+12]
 38919                              <1> 	; 25/07/2022
 38920 00009C9E 8B54240C            <1> 	mov	edx, [esp+12]
 38921                              <1> 
 38922                              <1> set_env_chk_validation2w:
 38923 00009CA2 89F7                <1> 	mov	edi, esi
 38924 00009CA4 4F                  <1> 	dec	edi
 38925                              <1> 
 38926 00009CA5 807FFF20            <1> 	cmp	byte [edi-1], 20h
 38927 00009CA9 771A                <1> 	ja	short set_env_chk_validation2z
 38928                              <1> 	
 38929 00009CAB 56                  <1> 	push	esi
 38930 00009CAC 89FE                <1> 	mov	esi, edi
 38931 00009CAE 4E                  <1> 	dec	esi
 38932                              <1> 
 38933                              <1> set_env_chk_validation2x:
 38934 00009CAF 4E                  <1> 	dec	esi
 38935                              <1> 
 38936                              <1> 	;cmp	esi, ebx
 38937 00009CB0 39D6                <1> 	cmp	esi, edx ; 25/07/2022
 38938 00009CB2 7207                <1> 	jb	short set_env_chk_validation2y
 38939                              <1> 
 38940 00009CB4 4F                  <1> 	dec	edi
 38941                              <1> 
 38942 00009CB5 8A06                <1> 	mov	al, [esi]
 38943 00009CB7 8807                <1> 	mov	[edi], al
 38944                              <1> 
 38945 00009CB9 EBF4                <1> 	jmp	short set_env_chk_validation2x
 38946                              <1> 
 38947                              <1> set_env_chk_validation2y:
 38948 00009CBB 5E                  <1> 	pop	esi
 38949                              <1> 
 38950                              <1> 	;;mov	byte [ebx], 20h
 38951                              <1> 	; 25/07/2022
 38952                              <1> 	;mov	byte [edx], 20h		
 38953                              <1> 
 38954                              <1> 	;inc 	ebx
 38955                              <1> 	;mov	[esp+12], ebx
 38956                              <1> 	; 25/07/2022
 38957 00009CBC 42                  <1> 	inc	edx
 38958 00009CBD 8954240C            <1> 	mov	[esp+12], edx
 38959                              <1> 
 38960 00009CC1 FECC                <1> 	dec 	ah ; 13/04/2016
 38961                              <1> 
 38962 00009CC3 EBDD                <1> 	jmp	short set_env_chk_validation2w
 38963                              <1> 	
 38964                              <1> set_env_chk_validation2z:	
 38965                              <1> 	;mov	edx, Env_Page
 38966                              <1> 	;mov	edi, edx
 38967                              <1> 	; 25/07/2022
 38968 00009CC5 BB00300900          <1> 	mov	ebx, Env_Page
 38969 00009CCA 89DF                <1> 	mov	edi, ebx
 38970                              <1> 
 38971                              <1> set_env_chk_validation3:
 38972 00009CCC AC                  <1> 	lodsb
 38973 00009CCD 3C20                <1> 	cmp	al, 20h
 38974 00009CCF 74FB                <1> 	je	short set_env_chk_validation3
 38975                              <1> 
 38976 00009CD1 9C                  <1> 	pushf
 38977                              <1> 
 38978                              <1> 	; 12/04/2016
 38979                              <1> set_env_chk_validation3n:
 38980 00009CD2 3C61                <1> 	cmp	al, 'a'
 38981 00009CD4 720C                <1> 	jb	short set_env_chk_validation3c
 38982 00009CD6 3C7A                <1> 	cmp	al, 'z'
 38983 00009CD8 7705                <1> 	ja	short set_env_chk_validation3x
 38984 00009CDA 2C20                <1> 	sub	al, 'a'-'A'
 38985 00009CDC 8846FF              <1> 	mov	[esi-1], al
 38986                              <1> 
 38987                              <1> set_env_chk_validation3x:
 38988 00009CDF AC                  <1> 	lodsb
 38989 00009CE0 EBF0                <1> 	jmp	short set_env_chk_validation3n
 38990                              <1> 
 38991                              <1> set_env_chk_validation3c:
 38992 00009CE2 3C20                <1> 	cmp	al, 20h
 38993 00009CE4 73F9                <1> 	jnb	short set_env_chk_validation3x
 38994                              <1> 		
 38995 00009CE6 803F00              <1> 	cmp	byte [edi], 0
 38996 00009CE9 772B                <1> 	ja	short set_env_chk_validation4
 38997                              <1> 
 38998 00009CEB 9D                  <1> 	popf
 38999 00009CEC 7222                <1> 	jb	short set_env_string_nothing
 39000                              <1> 
 39001 00009CEE B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)
 39002                              <1> 
 39003                              <1> 	;mov	esi, ebx ; 12/04/2016
 39004                              <1> 	; 25/07/2022
 39005 00009CF3 89D6                <1> 	mov	esi, edx
 39006                              <1> 
 39007                              <1> 	; 25/07/2022
 39008 00009CF5 89CA                <1> 	mov	edx, ecx
 39009                              <1> 
 39010                              <1> set_env_string_copy_to_envb:
 39011 00009CF7 AC                  <1> 	lodsb
 39012 00009CF8 3C20                <1> 	cmp	al, 20h
 39013 00009CFA 7207                <1> 	jb	short set_env_string_copy_to_envb_z
 39014 00009CFC AA                  <1> 	stosb
 39015 00009CFD E2F8                <1> 	loop	set_env_string_copy_to_envb
 39016                              <1> 
 39017                              <1> 	; 11/04/2016
 39018                              <1> 	;mov	edi, edx ; Env_Page
 39019                              <1> 	; 25/07/2022
 39020 00009CFF 89DF                <1> 	mov	edi, ebx
 39021                              <1> 	; 25/07/2022
 39022                              <1> 	;mov	ecx, Env_Page_Size 
 39023 00009D01 89D1                <1> 	mov	ecx, edx
 39024                              <1> 
 39025                              <1> set_env_string_copy_to_envb_z:
 39026                              <1> 	; 25/07/2022
 39027                              <1> 	;push	edx  ; Start address of the variable
 39028                              <1> 	
 39029                              <1> 	;;mov	edx, Env_Page_Size
 39030                              <1> 	;; 25/07/2022
 39031 00009D03 29CA                <1> 	sub	edx, ecx ; variable (string) length
 39032                              <1> 
 39033 00009D05 28C0                <1> 	sub	al, al ; 0
 39034 00009D07 F3AA                <1>  	rep	stosb ; clear remain bytes of the env page
 39035                              <1> 
 39036                              <1> 	;pop	eax  ; Start address of the variable
 39037                              <1> 	; 25/07/2022
 39038 00009D09 89D8                <1> 	mov	eax, ebx
 39039                              <1> 
 39040                              <1> set_env_string_allocate_envb_retn:  ; stc or clc return
 39041 00009D0B 5F                  <1> 	pop	edi ; ****
 39042 00009D0C 5B                  <1> 	pop	ebx ; ***
 39043 00009D0D 59                  <1> 	pop	ecx ; **
 39044 00009D0E 5E                  <1> 	pop	esi ; *	
 39045 00009D0F C3                  <1> 	retn
 39046                              <1> 
 39047                              <1> set_env_string_nothing:
 39048 00009D10 31C0                <1> 	xor	eax, eax
 39049 00009D12 31D2                <1> 	xor	edx, edx ; 11/04/2016
 39050 00009D14 EBF5                <1> 	jmp	short set_env_string_allocate_envb_retn
 39051                              <1> 
 39052                              <1> set_env_chk_validation4:
 39053                              <1> 	; 11/04/2016
 39054 00009D16 9D                  <1> 	popf
 39055                              <1> 
 39056                              <1> 	;mov	esi, edx  ; Env_Page
 39057                              <1> 	; 25/07/2022
 39058 00009D17 89DE                <1> 	mov	esi, ebx
 39059                              <1> 
 39060                              <1> set_env_chk_validation5:	
 39061                              <1> 	;mov	edi, ebx  ; ASCIIZ environment string address	
 39062                              <1> 	; 25/07/2022
 39063 00009D19 89D7                <1> 	mov	edi, edx
 39064 00009D1B 0FB6CC              <1> 	movzx	ecx, ah ; Variable (string) length (with '=')
 39065                              <1> 
 39066                              <1> set_env_chk_validation5_loop:
 39067 00009D1E AC                  <1> 	lodsb
 39068 00009D1F AE                  <1> 	scasb
 39069 00009D20 7508                <1> 	jne	short set_env_chk_validation6
 39070 00009D22 E2FA                <1> 	loop	set_env_chk_validation5_loop
 39071                              <1> 
 39072 00009D24 3C3D                <1> 	cmp	al, '='
 39073                              <1>         ;je	set_env_change_variable
 39074                              <1> 	; 25/07/2022
 39075 00009D26 7502                <1> 	jne	short set_env_chk_validation6
 39076 00009D28 EB7E                <1> 	jmp	set_env_change_variable
 39077                              <1> 
 39078                              <1> set_env_chk_validation6:
 39079 00009D2A 08C0                <1> 	or	al, al ; 0
 39080 00009D2C 7403                <1> 	jz	short set_env_chk_validation7
 39081                              <1> 
 39082 00009D2E AC                  <1> 	lodsb
 39083 00009D2F EBF9                <1> 	jmp	short set_env_chk_validation6
 39084                              <1> 
 39085                              <1> set_env_chk_validation7:
 39086 00009D31 88E1                <1> 	mov	cl, ah
 39087 00009D33 01F1                <1> 	add	ecx, esi
 39088 00009D35 81F9FF310900        <1> 	cmp	ecx, Env_Page + Env_Page_Size - 1 
 39089                              <1> 		; 511 (4095) 
 39090                              <1> 		; strlen + '=' + 0
 39091 00009D3B 72DC                <1> 	jb	short set_env_chk_validation5
 39092                              <1> 
 39093                              <1> set_env_chk_validation8: ; variable not found
 39094 00009D3D 0FB6F4              <1> 	movzx	esi, ah  ; variable name length (with '=') 
 39095                              <1> 	;add	esi, ebx ; position just after of the '='
 39096                              <1> 	; 25/07/2022
 39097 00009D40 01D6                <1> 	add	esi, edx
 39098                              <1> 
 39099                              <1> set_env_chk_validation8_loop:
 39100 00009D42 AC                  <1> 	lodsb
 39101 00009D43 3C20                <1> 	cmp	al, 20h
 39102 00009D45 74FB                <1> 	je	short set_env_chk_validation8_loop	
 39103 00009D47 72C7                <1> 	jb	short set_env_string_nothing
 39104                              <1> 
 39105                              <1> set_env_chk_validation9:
 39106 00009D49 AC                  <1> 	lodsb
 39107 00009D4A 3C20                <1> 	cmp	al, 20h
 39108 00009D4C 73FB                <1> 	jnb	short set_env_chk_validation9
 39109                              <1> 
 39110                              <1> 	; End of ASCIIZ environment string
 39111                              <1> 
 39112                              <1> set_env_add_variable:
 39113                              <1> 	;sub	esi, ebx ; variable+definition length
 39114                              <1> 	; 25/07/2022
 39115 00009D4E 29D6                <1> 	sub	esi, edx	
 39116                              <1> 
 39117 00009D50 56                  <1> 	push	esi ; *****
 39118                              <1> 
 39119                              <1> 	;mov	esi, edx ; Environment page address
 39120                              <1> 	; 25/07/2022
 39121 00009D51 89DE                <1> 	mov	esi, ebx
 39122                              <1> 
 39123 00009D53 B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)	
 39124                              <1> 
 39125                              <1> set_env_add_variable_loop:
 39126 00009D58 AC                  <1> 	lodsb
 39127 00009D59 20C0                <1> 	and	al, al		
 39128 00009D5B 7406                <1> 	jz	short set_env_add_variable_chk1 ; 0
 39129 00009D5D E2F9                <1> 	loop	set_env_add_variable_loop
 39130                              <1> 
 39131                              <1> 	; 11/04/2016
 39132 00009D5F 884EFF              <1> 	mov	[esi-1], cl ; 0
 39133 00009D62 41                  <1> 	inc	ecx
 39134                              <1> 	
 39135                              <1> set_env_add_variable_chk1: 
 39136 00009D63 49                  <1> 	dec	ecx
 39137 00009D64 7408                <1> 	jz	short set_env_add_variable_nspc
 39138 00009D66 AC                  <1> 	lodsb
 39139 00009D67 08C0                <1> 	or 	al, al
 39140 00009D69 740B                <1> 	jz	short set_env_add_variable_chk2 ; 00
 39141 00009D6B 49                  <1> 	dec	ecx
 39142 00009D6C 75EA                <1> 	jnz	short set_env_add_variable_loop
 39143                              <1> 
 39144                              <1> set_env_add_variable_nspc: ; no space on environment page
 39145 00009D6E 58                  <1> 	pop	eax ; *****
 39146                              <1> 	;mov	eax, 8 ; No space for new environment string
 39147                              <1> 	; 25/07/2022
 39148 00009D6F 29C0                <1> 	sub	eax, eax
 39149 00009D71 B008                <1> 	mov	al, 8
 39150 00009D73 F9                  <1> 	stc
 39151 00009D74 EB95                <1>         jmp     short set_env_string_allocate_envb_retn
 39152                              <1> 
 39153                              <1> set_env_add_variable_chk2:
 39154 00009D76 8B0C24              <1> 	mov	ecx, [esp] ; *****
 39155 00009D79 4E                  <1> 	dec	esi ; beginning address of the new variable
 39156 00009D7A 89F0                <1> 	mov	eax, esi
 39157 00009D7C 01C8                <1> 	add	eax, ecx ; string length (with CR)
 39158                              <1> 	;add	edx, Env_Page_Size ; 512 (4096)
 39159                              <1> 	; 25/07/2022
 39160 00009D7E 81C300020000        <1> 	add	ebx, Env_Page_Size
 39161                              <1> 	;cmp	eax, edx 
 39162 00009D84 39D8                <1> 	cmp	eax, ebx ; 25/07/2022
 39163 00009D86 77E6                <1> 	ja	short set_env_add_variable_nspc
 39164 00009D88 49                  <1> 	dec	ecx ; except CR at the end
 39165                              <1> 	;mov	edx, ecx ; 12/04/2016
 39166                              <1> 	; 25/07/2022
 39167 00009D89 89CB                <1> 	mov	ebx, ecx
 39168 00009D8B 89F7                <1> 	mov	edi, esi
 39169 00009D8D 893C24              <1> 	mov	[esp], edi ; ***** ; Start address of new variable
 39170                              <1> 	;mov	esi, ebx ; ASCIIZ environment string address
 39171                              <1> 	; 25/07/2022
 39172 00009D90 89D6                <1> 	mov	esi, edx
 39173 00009D92 F3A4                <1> 	rep	movsb
 39174 00009D94 28C0                <1> 	sub	al, al
 39175 00009D96 AA                  <1> 	stosb
 39176 00009D97 58                  <1> 	pop	eax ; ***** ; Beginning address of new variable			
 39177 00009D98 81FF00320900        <1>         cmp     edi, Env_Page + Env_Page_Size ; 12/04/2016
 39178                              <1> 	;jnb	set_env_string_allocate_envb_retn ; OK !
 39179                              <1> 	; 25/07/2022
 39180 00009D9E 7303                <1>  	jnb	short set_env_add_variable_chk3
 39181 00009DA0 880F                <1> 	mov	[edi], cl ; 0
 39182 00009DA2 F8                  <1> 	clc	; 13/04/2016
 39183                              <1> set_env_add_variable_chk3:
 39184 00009DA3 E963FFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
 39185                              <1> 
 39186                              <1> set_env_change_variable:
 39187                              <1> 	; 06/04/2016
 39188                              <1> 	; esi = Variable's address in environment page (after '=')
 39189                              <1> 	; edi = ASCIIZ environment string address (after '=')
 39190                              <1> 
 39191                              <1> 	; ah = variable length from start to the '='
 39192 00009DA8 8825[AC830100]      <1> 	mov	[env_var_length], ah
 39193                              <1> 
 39194 00009DAE 28C9                <1> 	sub	cl, cl ; ecx = 0
 39195                              <1> 
 39196 00009DB0 57                  <1> 	push	edi ; *****
 39197                              <1> 
 39198 00009DB1 89F7                <1> 	mov	edi, esi ; 11/04/2016
 39199                              <1> 
 39200                              <1> set_env_change_variable_calc1:
 39201 00009DB3 AC                  <1> 	lodsb
 39202 00009DB4 08C0                <1> 	or	al, al
 39203 00009DB6 7403                <1> 	jz	short set_env_change_variable_calc2
 39204                              <1> 
 39205 00009DB8 41                  <1> 	inc	ecx ; length of environment string (after the '=')
 39206                              <1> 
 39207 00009DB9 EBF8                <1> 	jmp	short set_env_change_variable_calc1	
 39208                              <1> 
 39209                              <1> set_env_change_variable_calc2:
 39210 00009DBB 8B3424              <1> 	mov	esi, [esp] ; ASCIIZ environment string address
 39211                              <1> 	
 39212 00009DBE 29D2                <1> 	sub	edx, edx
 39213                              <1> 
 39214                              <1> set_env_change_variable_calc3:
 39215 00009DC0 AC                  <1> 	lodsb
 39216 00009DC1 3C20                <1> 	cmp	al, 20h
 39217 00009DC3 7203                <1> 	jb	short set_env_change_variable_calc4
 39218                              <1> 
 39219 00009DC5 42                  <1> 	inc	edx ; length of ASCIIZ string (after the '=')
 39220                              <1> 	
 39221 00009DC6 EBF8                <1> 	jmp	short set_env_change_variable_calc3
 39222                              <1> 	
 39223                              <1> set_env_change_variable_calc4:
 39224 00009DC8 C646FF00            <1> 	mov	byte [esi-1], 0  ; put ZERO instead of CR
 39225                              <1> 	
 39226 00009DCC 5E                  <1> 	pop	esi ; ***** ; ASCIIZ string address (after '=')
 39227                              <1> 
 39228                              <1> 	; EDI = Old variable's address (after '=')
 39229                              <1> 	
 39230                              <1> 	; compare the new string with the old string
 39231 00009DCD 39CA                <1> 	cmp	edx, ecx
 39232 00009DCF 7718                <1> 	ja	short set_env_change_variable_calc5 ; longer
 39233                              <1> 	;jb	set_env_change_variable_calc9 ; shorter
 39234                              <1> 	; 25/07/2022
 39235 00009DD1 7405                <1> 	je	short set_env_change_variable_calc22
 39236 00009DD3 E98C000000          <1> 	jmp	set_env_change_variable_calc9 
 39237                              <1> 
 39238                              <1> set_env_change_variable_calc22:	
 39239                              <1> 	;same length (simple copy)
 39240 00009DD8 0FB6C4              <1> 	movzx	eax, ah
 39241 00009DDB 01C2                <1> 	add	edx, eax
 39242 00009DDD F7D8                <1> 	neg	eax
 39243 00009DDF 01F8                <1> 	add	eax, edi
 39244                              <1> 	; EAX = Start address of the variable
 39245                              <1> 	; EDX = Variable length (without ZERO at the end of variable)
 39246                              <1> 
 39247 00009DE1 F3A4                <1> 	rep	movsb
 39248 00009DE3 F8                  <1> 	clc	; 13/04/2016
 39249 00009DE4 E922FFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
 39250                              <1> 
 39251                              <1> set_env_change_variable_calc5:
 39252                              <1> 	; 11/04/2016
 39253 00009DE9 52                  <1> 	push	edx ; *****
 39254 00009DEA 29CA                <1> 	sub	edx, ecx ; difference ; (the new string is longer)
 39255 00009DEC 89F3                <1> 	mov 	ebx, esi
 39256 00009DEE 89FE                <1> 	mov	esi, edi
 39257                              <1> 
 39258                              <1> set_env_change_variable_calc6:
 39259 00009DF0 AC                  <1> 	lodsb 
 39260 00009DF1 20C0                <1> 	and	al, al
 39261 00009DF3 75FB                <1> 	jnz	short set_env_change_variable_calc6
 39262                              <1> 
 39263 00009DF5 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
 39264 00009DFB 0F836DFFFFFF        <1>         jnb     set_env_add_variable_nspc
 39265                              <1> 
 39266 00009E01 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
 39267 00009E03 89F7                <1> 	mov	edi, esi  ; next variable's address 
 39268                              <1> 
 39269 00009E05 AC                  <1> 	lodsb
 39270 00009E06 08C0                <1> 	or	al, al
 39271 00009E08 7417                <1> 	jz	short set_env_change_variable_calc8 ; 00
 39272                              <1> 
 39273                              <1> set_env_change_variable_calc7:
 39274 00009E0A AC                  <1> 	lodsb
 39275 00009E0B 20C0                <1> 	and	al, al
 39276 00009E0D 75FB                <1> 	jnz	short set_env_change_variable_calc7
 39277                              <1> 
 39278 00009E0F 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
 39279                              <1> 	;jnb	set_env_add_variable_nspc
 39280                              <1> 	; 25/07/2022
 39281 00009E15 7205                <1> 	jb	short set_env_change_variable_calc24
 39282                              <1> set_env_change_variable_calc23:
 39283 00009E17 E952FFFFFF          <1> 	jmp	set_env_add_variable_nspc
 39284                              <1> 
 39285                              <1> set_env_change_variable_calc24:
 39286 00009E1C AC                  <1> 	lodsb
 39287 00009E1D 08C0                <1> 	or	al, al
 39288 00009E1F 75E9                <1> 	jnz	short set_env_change_variable_calc7
 39289                              <1> 
 39290                              <1> set_env_change_variable_calc8:
 39291 00009E21 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
 39292                              <1> 
 39293 00009E22 01F2                <1> 	add	edx, esi ; final position of the last 0
 39294                              <1> 
 39295 00009E24 81FA00320900        <1> 	cmp	edx, Env_Page + Env_Page_Size ; 512 (4096)
 39296                              <1> 	;jnb     set_env_add_variable_nspc
 39297                              <1> 	; 25/07/2022
 39298 00009E2A 73EB                <1> 	jnb	short set_env_change_variable_calc23
 39299                              <1> 
 39300 00009E2C 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
 39301                              <1> 
 39302 00009E2E 89F1                <1> 	mov	ecx, esi 
 39303 00009E30 29F9                <1> 	sub	ecx, edi ; count of bytes to move forward
 39304                              <1> 
 39305                              <1> 	; 13/04/2016
 39306 00009E32 C60200              <1> 	mov	byte [edx], 0
 39307 00009E35 89D7                <1> 	mov	edi, edx
 39308 00009E37 29F2                <1> 	sub	edx, esi ; difference (additional byte count)
 39309 00009E39 4F                  <1> 	dec	edi ; the last zero address (first byte of the 00)
 39310 00009E3A 89FE                <1> 	mov	esi, edi
 39311 00009E3C 29D6                <1> 	sub	esi, edx ; - displacement
 39312                              <1> 	
 39313 00009E3E FA                  <1> 	cli	; disable interrupts
 39314 00009E3F FD                  <1> 	std	; backward
 39315                              <1> 
 39316 00009E40 F3A4                <1> 	rep	movsb ; move ECX bytes from DS:ESI to ES:EDI
 39317                              <1> 
 39318 00009E42 FC                  <1> 	cld	; forward (default)
 39319 00009E43 FB                  <1> 	sti	; enable interrupts
 39320                              <1> 	
 39321 00009E44 89C7                <1> 	mov	edi, eax
 39322 00009E46 59                  <1> 	pop	ecx ; ***** ; byte count (after '=')
 39323 00009E47 89CA                <1> 	mov	edx, ecx
 39324 00009E49 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
 39325 00009E4B 89FB                <1> 	mov	ebx, edi
 39326                              <1> 
 39327 00009E4D F3A4                <1> 	rep	movsb
 39328                              <1> 
 39329 00009E4F 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
 39330                              <1> 
 39331 00009E51 0FB605[AC830100]    <1> 	movzx	eax, byte [env_var_length]
 39332 00009E58 01C2                <1> 	add	edx, eax ; variable length (total)
 39333 00009E5A F7D8                <1> 	neg	eax
 39334 00009E5C 01D8                <1> 	add	eax, ebx ; start address of the variable
 39335 00009E5E F8                  <1> 	clc	; 13/04/2016
 39336 00009E5F E9A7FEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
 39337                              <1> 
 39338                              <1> set_env_change_variable_calc9:
 39339                              <1> 	; 11/04/2016
 39340 00009E64 21D2                <1> 	and	edx, edx ; is empty ?
 39341 00009E66 753B                <1> 	jnz	short set_env_change_variable_calc15
 39342                              <1> 	
 39343 00009E68 0FB6DC              <1> 	movzx	ebx, ah
 39344 00009E6B F7DB                <1> 	neg	ebx
 39345 00009E6D 01FB                <1> 	add	ebx, edi
 39346                              <1> 
 39347                              <1> 	; EBX = Start address of the variable (in env page)
 39348                              <1> 	; EDX = Variable length = 0
 39349                              <1> 	
 39350 00009E6F 89FE                <1> 	mov	esi, edi
 39351                              <1> 
 39352                              <1> set_env_change_variable_calc10:
 39353 00009E71 AC                  <1> 	lodsb
 39354 00009E72 08C0                <1> 	or	al, al
 39355 00009E74 75FB                <1> 	jnz	short set_env_change_variable_calc10
 39356                              <1> 
 39357 00009E76 B9FF310900          <1> 	mov	ecx, Env_Page + Env_Page_Size - 1
 39358                              <1> 
 39359 00009E7B 39CE                <1> 	cmp	esi, ecx ; +511 (+4095)
 39360 00009E7D 7604                <1> 	jna	short set_env_change_variable_calc11
 39361                              <1> 
 39362 00009E7F 89CE                <1> 	mov	esi, ecx
 39363 00009E81 8806                <1> 	mov	[esi], al ; 0
 39364                              <1> 
 39365                              <1> set_env_change_variable_calc11:
 39366 00009E83 89DF                <1> 	mov	edi, ebx ; old variable's start address
 39367                              <1> 
 39368                              <1> set_env_change_variable_calc12:
 39369 00009E85 AC                  <1> 	lodsb
 39370 00009E86 AA                  <1> 	stosb
 39371 00009E87 20C0                <1> 	and	al, al
 39372 00009E89 75FA                <1> 	jnz	short set_env_change_variable_calc12
 39373 00009E8B 39CE                <1> 	cmp	esi, ecx
 39374 00009E8D 7706                <1> 	ja	short set_env_change_variable_calc13
 39375 00009E8F AC                  <1> 	lodsb
 39376 00009E90 AA                  <1> 	stosb
 39377 00009E91 20C0                <1> 	and	al, al
 39378 00009E93 75F0                <1> 	jnz	short set_env_change_variable_calc12	
 39379                              <1> 
 39380                              <1> set_env_change_variable_calc13:
 39381 00009E95 29F9                <1> 	sub	ecx, edi
 39382 00009E97 7203                <1> 	jb	short set_env_change_variable_calc14
 39383 00009E99 41                  <1> 	inc	ecx ; 1-512 (1-4096)
 39384 00009E9A F3AA                <1> 	rep	stosb ; al = 0	
 39385                              <1> 
 39386                              <1> set_env_change_variable_calc14:
 39387 00009E9C 29C0                <1> 	sub	eax, eax ; Start address of the variable
 39388                              <1> 	; EAX = 0 -> Variable is removed
 39389                              <1> 	; EDX = Variable length = 0	
 39390                              <1> 
 39391 00009E9E E968FEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
 39392                              <1> 	    
 39393                              <1> set_env_change_variable_calc15:	
 39394 00009EA3 52                  <1> 	push	edx ; *****
 39395 00009EA4 F7DA                <1> 	neg	edx
 39396 00009EA6 01CA                <1> 	add	edx, ecx ; difference (the old string is longer)
 39397 00009EA8 89F3                <1> 	mov 	ebx, esi
 39398 00009EAA 89FE                <1> 	mov	esi, edi
 39399                              <1> 
 39400                              <1> set_env_change_variable_calc16:
 39401 00009EAC AC                  <1> 	lodsb 
 39402 00009EAD 20C0                <1> 	and	al, al
 39403 00009EAF 75FB                <1> 	jnz	short set_env_change_variable_calc16
 39404                              <1> 
 39405 00009EB1 B900320900          <1> 	mov	ecx, Env_Page + Env_Page_Size
 39406                              <1> 
 39407 00009EB6 39CE                <1> 	cmp	esi, ecx ; +512 (+4096)
 39408 00009EB8 7605                <1> 	jna	short set_env_change_variable_calc17
 39409                              <1> 
 39410 00009EBA 89CE                <1> 	mov	esi, ecx
 39411 00009EBC 8846FF              <1> 	mov	[esi-1], al ; 0
 39412                              <1> 
 39413                              <1> set_env_change_variable_calc17:
 39414 00009EBF 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
 39415 00009EC1 89F7                <1> 	mov	edi, esi  ; next variable's address 
 39416                              <1> 
 39417 00009EC3 AC                  <1> 	lodsb
 39418 00009EC4 08C0                <1> 	or	al, al
 39419 00009EC6 741D                <1> 	jz	short set_env_change_variable_calc20
 39420                              <1> 
 39421                              <1> set_env_change_variable_calc18:
 39422 00009EC8 AC                  <1> 	lodsb
 39423 00009EC9 20C0                <1> 	and	al, al
 39424 00009ECB 75FB                <1> 	jnz	short set_env_change_variable_calc18
 39425                              <1> 
 39426 00009ECD 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size
 39427 00009ED3 720B                <1> 	jb	short set_env_change_variable_calc19
 39428 00009ED5 740E                <1> 	je	short set_env_change_variable_calc20
 39429                              <1> 
 39430 00009ED7 BEFF310900          <1> 	mov	esi, Env_Page + Env_Page_Size - 1
 39431 00009EDC 8806                <1> 	mov	[esi], al ; 0
 39432 00009EDE EB06                <1> 	jmp	short set_env_change_variable_calc21
 39433                              <1> 
 39434                              <1> set_env_change_variable_calc19:
 39435 00009EE0 AC                  <1> 	lodsb
 39436 00009EE1 08C0                <1> 	or	al, al
 39437 00009EE3 75E3                <1> 	jnz	short set_env_change_variable_calc18
 39438                              <1> 
 39439                              <1> set_env_change_variable_calc20:
 39440 00009EE5 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
 39441                              <1> 
 39442                              <1> set_env_change_variable_calc21:
 39443                              <1> 	; edx = difference (byte count)
 39444                              <1> 	
 39445 00009EE6 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
 39446                              <1> 
 39447 00009EE8 89F1                <1> 	mov	ecx, esi 
 39448 00009EEA 29F9                <1> 	sub	ecx, edi ; count of bytes to move backward
 39449                              <1> 
 39450 00009EEC 89FE                <1> 	mov	esi, edi ; next variable's address
 39451 00009EEE 29D7                <1> 	sub	edi, edx ; (displacement)
 39452                              <1> 	
 39453 00009EF0 F3A4                <1> 	rep	movsb
 39454                              <1> 
 39455 00009EF2 880F                <1> 	mov	[edi], cl ; 0 ; 00 ; end of environment variables
 39456                              <1> 
 39457 00009EF4 89C7                <1> 	mov	edi, eax
 39458 00009EF6 5A                  <1> 	pop	edx ; ***** ; byte count (after '=')
 39459 00009EF7 89D1                <1> 	mov	ecx, edx
 39460 00009EF9 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
 39461 00009EFB 89FB                <1> 	mov	ebx, edi
 39462                              <1> 	
 39463 00009EFD F3A4                <1> 	rep	movsb
 39464                              <1> 
 39465 00009EFF 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
 39466                              <1> 
 39467 00009F01 0FB605[AC830100]    <1> 	movzx	eax, byte [env_var_length]
 39468 00009F08 01C2                <1> 	add	edx, eax ; variable length (total)
 39469 00009F0A F7D8                <1> 	neg	eax
 39470 00009F0C 01D8                <1> 	add	eax, ebx ; start address of the variable
 39471 00009F0E F8                  <1> 	clc	; 13/04/2016
 39472 00009F0F E9F7FDFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
 39473                              <1> 
 39474                              <1> mainprog_startup_configuration:
 39475                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 39476                              <1> 	; 22/11/2017
 39477                              <1> 	; 06/05/2016
 39478                              <1> 	; 14/04/2016 (TRDOS 386 = TRDOS v2.0)
 39479                              <1> 	; 17/09/2011 (TRDOS v1, MAINPROG.ASM)
 39480                              <1> 	;
 39481                              <1> loc_load_mainprog_cfg_file:
 39482 00009F14 BE[B6300100]        <1> 	mov	esi, MainProgCfgFile
 39483 00009F19 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
 39484 00009F1D E8EFEAFFFF          <1> 	call	find_first_file
 39485 00009F22 7256                <1> 	jc	short loc_load_mainprog_cfg_exit
 39486                              <1> 
 39487                              <1> 	;or	eax, eax
 39488                              <1> 	;jz	short loc_load_mainprog_cfg_exit
 39489                              <1> 
 39490                              <1> loc_start_mainprog_configuration:
 39491                              <1> 	; ESI = FindFile_DirEntry Location
 39492                              <1> 	; EAX = File Size
 39493                              <1> 
 39494 00009F24 A3[30780100]        <1> 	mov	[MainProgCfg_FileSize], eax
 39495                              <1> 
 39496 00009F29 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
 39497 00009F2D C1E210              <1> 	shl	edx, 16
 39498 00009F30 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
 39499 00009F34 8915[60830100]      <1> 	mov	[csftdf_sf_cluster], edx
 39500                              <1> 
 39501 00009F3A 89C1                <1> 	mov	ecx, eax
 39502 00009F3C 29C0                <1> 	sub	eax, eax
 39503                              <1> 
 39504                              <1> 	; TRDOS 386 (TRDOS v2.0)
 39505                              <1> 	; Allocate contiguous memory block for loading the file
 39506                              <1> 	
 39507                              <1> 	; eax = 0 (Allocate memory from the beginning)
 39508                              <1> 	; ecx = File (Allocation) size in bytes
 39509                              <1> 	
 39510 00009F3E E87ABCFFFF          <1> 	call	allocate_memory_block
 39511 00009F43 7235                <1> 	jc	short loc_load_mainprog_cfg_exit
 39512                              <1> 
 39513 00009F45 A3[58830100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
 39514 00009F4A 890D[5C830100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
 39515                              <1> 
 39516 00009F50 31DB                <1> 	xor	ebx, ebx
 39517                              <1> 	;mov	[csftdf_sf_rbytes], ebx ; 0, reset
 39518                              <1> 
 39519 00009F52 8A3D[42780100]      <1> 	mov	bh, [Current_Drv] ; [FindFile_Drv]
 39520 00009F58 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 39521 00009F5D 01DE                <1> 	add	esi, ebx
 39522                              <1> 
 39523 00009F5F 8B1D[58830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
 39524                              <1> 
 39525 00009F65 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 39526 00009F69 7710                <1>         ja	short loc_mcfg_load_fat_file
 39527                              <1> 
 39528 00009F6B C705[68830100]0000- <1> 	mov	dword [csftdf_r_size], 65536
 39529 00009F73 0100                <1>
 39530 00009F75 E99A010000          <1>         jmp     loc_mcfg_load_fs_file
 39531                              <1> 
 39532                              <1> loc_load_mainprog_cfg_exit:
 39533 00009F7A C3                  <1> 	retn 
 39534                              <1> 
 39535                              <1> loc_mcfg_load_fat_file:
 39536 00009F7B 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 39537 00009F7F 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 39538 00009F83 F7E1                <1> 	mul	ecx
 39539 00009F85 A3[68830100]        <1> 	mov	[csftdf_r_size], eax
 39540                              <1> 
 39541                              <1> loc_mcfg_load_fat_file_next:
 39542 00009F8A E81D010000          <1> 	call	mcfg_read_fat_file_sectors
 39543 00009F8F 7259                <1>         jc	short mcfg_deallocate_mem ; 25/07/2022
 39544                              <1> 
 39545 00009F91 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
 39546 00009F93 74F5                <1> 	jz	short loc_mcfg_load_fat_file_next
 39547                              <1> 
 39548                              <1> loc_mcfg_load_fat_file_ok:
 39549                              <1> 	; 06/05/2016
 39550 00009F95 C705[FC830100]-     <1> 	mov	dword [mainprog_return_addr], loc_mcfg_ci_return_addr 
 39551 00009F9B [67A00000]          <1>
 39552                              <1> 	;
 39553 00009F9F 8B35[58830100]      <1> 	mov	esi, [csftdf_sf_mem_addr]
 39554 00009FA5 8935[34780100]      <1> 	mov	[MainProgCfg_LineOffset], esi
 39555                              <1> 	
 39556 00009FAB A1[30780100]        <1> 	mov	eax, [MainProgCfg_FileSize]
 39557 00009FB0 89C2                <1> 	mov	edx, eax
 39558 00009FB2 01F2                <1> 	add	edx, esi
 39559                              <1> 
 39560                              <1> loc_mcfg_process_next_line_check:
 39561 00009FB4 89C1                <1> 	mov	ecx, eax
 39562                              <1> 
 39563 00009FB6 803E2A              <1> 	cmp	byte [esi], "*" ; Remark sign
 39564 00009FB9 7503                <1> 	jne	short loc_mcfg_process_next_line
 39565 00009FBB 46                  <1> 	inc	esi
 39566 00009FBC EB16                <1> 	jmp	short loc_move_mainprog_cfg_nl1
 39567                              <1> 
 39568                              <1> loc_mcfg_process_next_line:
 39569 00009FBE 83F94F              <1> 	cmp	ecx, 79
 39570 00009FC1 7604                <1> 	jna	short loc_start_mainprog_cfg_process
 39571                              <1> 	
 39572                              <1> 	;mov	ecx, 79 
 39573                              <1> 	; 25/07/2022
 39574 00009FC3 29C9                <1> 	sub	ecx, ecx
 39575 00009FC5 B14F                <1> 	mov	cl, 79
 39576                              <1> 
 39577                              <1> loc_start_mainprog_cfg_process:
 39578 00009FC7 BF[F2780100]        <1> 	mov	edi, CommandBuffer
 39579                              <1> 
 39580                              <1> loc_move_mainprog_cfg_line:
 39581 00009FCC AC                  <1> 	lodsb
 39582 00009FCD 3C20                <1> 	cmp	al, 20h
 39583 00009FCF 720C                <1> 	jb	short loc_move_mainprog_cfg_nl2
 39584 00009FD1 AA                  <1> 	stosb
 39585 00009FD2 E2F8                <1> 	loop	loc_move_mainprog_cfg_line
 39586                              <1> 
 39587                              <1> loc_move_mainprog_cfg_nl1:
 39588 00009FD4 39D6                <1> 	cmp	esi, edx ; + configuration file size
 39589 00009FD6 7322                <1> 	jnb	short loc_end_of_mainprog_cfg_line
 39590 00009FD8 AC                  <1> 	lodsb
 39591 00009FD9 3C20                <1> 	cmp	al, 20h
 39592 00009FDB 73F7                <1> 	jnb	short loc_move_mainprog_cfg_nl1
 39593                              <1> 
 39594                              <1> loc_move_mainprog_cfg_nl2:
 39595 00009FDD 39D6                <1> 	cmp	esi, edx
 39596 00009FDF 7319                <1> 	jnb	short loc_end_of_mainprog_cfg_line
 39597 00009FE1 8A06                <1> 	mov	al, [esi]
 39598 00009FE3 3C20                <1> 	cmp	al, 20h
 39599 00009FE5 7713                <1>  	ja	short loc_end_of_mainprog_cfg_line
 39600 00009FE7 46                  <1> 	inc	esi
 39601 00009FE8 EBF3                <1> 	jmp	short loc_move_mainprog_cfg_nl2	
 39602                              <1> 
 39603                              <1> 	; 25/07/2022
 39604                              <1> mcfg_deallocate_mem:
 39605 00009FEA A1[58830100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
 39606 00009FEF 8B0D[5C830100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
 39607                              <1> 	;call	deallocate_memory_block
 39608                              <1> 	;retn
 39609 00009FF5 E9D0BDFFFF          <1> 	jmp	deallocate_memory_block               
 39610                              <1> 
 39611                              <1> loc_end_of_mainprog_cfg_line:
 39612 00009FFA C60700              <1> 	mov	byte [edi], 0
 39613                              <1> 
 39614 00009FFD 8935[34780100]      <1> 	mov	[MainProgCfg_LineOffset], esi
 39615                              <1> 
 39616                              <1> 	; 22/11/2017
 39617 0000A003 BE[FA780100]        <1> 	mov	esi, CommandBuffer + 8
 39618 0000A008 29FE                <1> 	sub	esi, edi
 39619 0000A00A 7606                <1> 	jna	short loc_move_mainprog_cfg_command
 39620 0000A00C 30C0                <1> 	xor	al, al
 39621                              <1> loc_mainprog_cfg_clear_chrs:
 39622 0000A00E AA                  <1> 	stosb
 39623 0000A00F 4E                  <1> 	dec	esi
 39624 0000A010 75FC                <1> 	jnz	short loc_mainprog_cfg_clear_chrs	
 39625                              <1> 
 39626                              <1> loc_move_mainprog_cfg_command:
 39627 0000A012 BE[F2780100]        <1> 	mov	esi, CommandBuffer
 39628 0000A017 89F7                <1> 	mov	edi, esi
 39629 0000A019 31DB                <1> 	xor	ebx, ebx
 39630                              <1> 	;xor	ecx, ecx
 39631 0000A01B 30C9                <1> 	xor	cl, cl
 39632                              <1> 
 39633                              <1> loc_move_mcfg_first_cmd_char:
 39634 0000A01D 8A041E              <1> 	mov	al, [esi+ebx]
 39635 0000A020 FEC3                <1> 	inc	bl 
 39636 0000A022 3C20                <1> 	cmp	al, 20h
 39637 0000A024 7712                <1> 	ja	short loc_move_mcfg_cmd_capitalizing
 39638 0000A026 7237                <1> 	jb	short loc_move_mcfg_cmd_arguments_ok
 39639 0000A028 80FB4F              <1> 	cmp	bl, 79
 39640 0000A02B 72F0                <1> 	jb	short loc_move_mcfg_first_cmd_char
 39641 0000A02D EB30                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
 39642                              <1> 
 39643                              <1> loc_move_mcfg_next_cmd_char:
 39644 0000A02F 8A041E              <1> 	mov	al, [esi+ebx]
 39645 0000A032 FEC3                <1> 	inc	bl
 39646 0000A034 3C20                <1> 	cmp	al, 20h
 39647 0000A036 7614                <1> 	jna	short loc_move_mcfg_cmd_ok
 39648                              <1> 
 39649                              <1> loc_move_mcfg_cmd_capitalizing:
 39650 0000A038 3C61                <1> 	cmp	al, 61h ; 'a'
 39651 0000A03A 7206                <1> 	jb	short loc_move_mcfg_cmd_caps_ok
 39652 0000A03C 3C7A                <1> 	cmp	al, 7Ah ; 'z'
 39653 0000A03E 7702                <1> 	ja	short loc_move_mcfg_cmd_caps_ok
 39654 0000A040 24DF                <1> 	and	al, 0DFh ; sub	al, 'a'-'A'
 39655                              <1> 
 39656                              <1> loc_move_mcfg_cmd_caps_ok:
 39657 0000A042 AA                  <1> 	stosb 
 39658 0000A043 FEC1                <1> 	inc	cl
 39659 0000A045 80FB4F              <1> 	cmp	bl, 79
 39660 0000A048 72E5                <1> 	jb	short loc_move_mcfg_next_cmd_char
 39661 0000A04A EB13                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
 39662                              <1> 
 39663                              <1> loc_move_mcfg_cmd_ok:
 39664 0000A04C 30C0                <1> 	xor	al, al ; 0
 39665                              <1> 
 39666                              <1> loc_move_mcfg_cmd_arguments:
 39667 0000A04E 8807                <1> 	mov	[edi], al
 39668 0000A050 47                  <1> 	inc	edi
 39669 0000A051 80FB4F              <1> 	cmp	bl, 79
 39670 0000A054 7309                <1> 	jnb	short loc_move_mcfg_cmd_arguments_ok
 39671 0000A056 8A041E              <1> 	mov	al, [esi+ebx]
 39672 0000A059 FEC3                <1> 	inc	bl
 39673 0000A05B 3C20                <1> 	cmp	al, 20h
 39674 0000A05D 73EF                <1> 	jnb	short loc_move_mcfg_cmd_arguments
 39675                              <1> 	
 39676                              <1> loc_move_mcfg_cmd_arguments_ok:
 39677 0000A05F C60700              <1> 	mov	byte [edi], 0
 39678                              <1>        
 39679                              <1> loc_mcfg_process_cmd_interpreter:
 39680 0000A062 E8E8E0FFFF          <1> 	call    command_interpreter
 39681                              <1> 
 39682                              <1> loc_mcfg_ci_return_addr: 
 39683 0000A067 A1[30780100]        <1> 	mov	eax, [MainProgCfg_FileSize]
 39684 0000A06C 89C2                <1> 	mov	edx, eax
 39685 0000A06E 8B35[34780100]      <1> 	mov	esi, [MainProgCfg_LineOffset]
 39686 0000A074 01F2                <1> 	add	edx, esi
 39687 0000A076 0305[58830100]      <1> 	add	eax, [csftdf_sf_mem_addr]
 39688 0000A07C 29F0                <1> 	sub	eax, esi
 39689 0000A07E 0F8730FFFFFF        <1>         ja      loc_mcfg_process_next_line_check
 39690                              <1> 
 39691 0000A084 E861FFFFFF          <1> 	call	mcfg_deallocate_mem
 39692                              <1>  
 39693 0000A089 B94F000000          <1>  	mov	ecx, 79 ; 80 ?
 39694 0000A08E BF[F2780100]        <1> 	mov	edi, CommandBuffer
 39695 0000A093 30C0                <1> 	xor	al, al
 39696 0000A095 F3AA                <1> 	rep	stosb
 39697                              <1> 
 39698                              <1> 	; 06/05/2016
 39699 0000A097 BE[0F3B0100]        <1> 	mov	esi, nextline
 39700 0000A09C E889CBFFFF          <1> 	call	print_msg
 39701 0000A0A1 E9FAD7FFFF          <1> 	jmp	dos_prompt
 39702                              <1> 
 39703                              <1> mcfg_read_file_sectors:
 39704                              <1> 	; 14/04/2016
 39705 0000A0A6 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 39706 0000A0AA 7668                <1>         jna	short mcfg_read_fs_file_sectors
 39707                              <1> 
 39708                              <1> mcfg_read_fat_file_sectors:
 39709                              <1> 	; return:
 39710                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
 39711                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
 39712                              <1> 	;   CF = 1 -> read error (error code in AL)	
 39713                              <1> 
 39714                              <1> mcfg_read_fat_file_secs_0:
 39715 0000A0AC 8B15[30780100]      <1> 	mov	edx, [MainProgCfg_FileSize]
 39716 0000A0B2 2B15[70830100]      <1> 	sub	edx, [csftdf_sf_rbytes]
 39717 0000A0B8 3B15[68830100]      <1> 	cmp	edx, [csftdf_r_size]	
 39718 0000A0BE 7306                <1> 	jnb	short mcfg_read_fat_file_secs_1
 39719 0000A0C0 8915[68830100]      <1> 	mov	[csftdf_r_size], edx
 39720                              <1> 		
 39721                              <1> mcfg_read_fat_file_secs_1:
 39722 0000A0C6 A1[68830100]        <1> 	mov	eax, [csftdf_r_size]
 39723 0000A0CB 29D2                <1> 	sub	edx, edx
 39724 0000A0CD 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
 39725 0000A0D1 01C8                <1> 	add	eax, ecx
 39726 0000A0D3 48                  <1> 	dec	eax
 39727 0000A0D4 F7F1                <1> 	div	ecx
 39728 0000A0D6 89C1                <1> 	mov	ecx, eax ; sector count
 39729 0000A0D8 A1[60830100]        <1> 	mov	eax, [csftdf_sf_cluster]
 39730                              <1> 
 39731                              <1> 	; EBX = memory block address (current)
 39732                              <1> 	
 39733 0000A0DD E8A8220000          <1> 	call	read_fat_file_sectors
 39734 0000A0E2 7230                <1> 	jc	short mcfg_read_fat_file_secs_3
 39735                              <1> 
 39736                              <1> 	; EBX = next memory address
 39737                              <1> 
 39738 0000A0E4 A1[70830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
 39739 0000A0E9 0305[68830100]      <1> 	add	eax, [csftdf_r_size]
 39740 0000A0EF 8B15[30780100]      <1> 	mov	edx, [MainProgCfg_FileSize]
 39741 0000A0F5 39D0                <1> 	cmp	eax, edx
 39742 0000A0F7 731B                <1> 	jnb	short mcfg_read_fat_file_secs_3 ; edx > 0
 39743 0000A0F9 A3[70830100]        <1> 	mov	[csftdf_sf_rbytes], eax
 39744                              <1> 
 39745 0000A0FE 53                  <1> 	push	ebx ; *
 39746                              <1> 	; get next cluster (csftdf_r_size! bytes)
 39747 0000A0FF A1[60830100]        <1> 	mov	eax, [csftdf_sf_cluster]
 39748 0000A104 E881200000          <1> 	call	get_next_cluster
 39749 0000A109 5B                  <1> 	pop	ebx ; *
 39750 0000A10A 7301                <1> 	jnc	short mcfg_read_fat_file_secs_2
 39751                              <1> 
 39752                              <1> 	;mov	eax, 17; Read error !
 39753 0000A10C C3                  <1> 	retn
 39754                              <1> 
 39755                              <1> mcfg_read_fat_file_secs_2:
 39756 0000A10D 29D2                <1> 	sub	edx, edx ; 0
 39757 0000A10F A3[60830100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
 39758                              <1> 
 39759                              <1> ; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 39760                              <1> 
 39761                              <1> mcfg_read_fat_file_secs_3:
 39762                              <1> 	;retn
 39763                              <1> 
 39764                              <1> mcfg_read_fs_file_sectors:
 39765                              <1> 	;retn
 39766                              <1> 
 39767                              <1> loc_mcfg_load_fs_file:
 39768 0000A114 C3                  <1> 	retn
 39769                              <1> 
 39770                              <1> load_and_execute_file:
 39771                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 39772                              <1> 	; 04/01/2017
 39773                              <1> 	; 06/05/2016 - 07/05/2016 - 11/05/2016
 39774                              <1> 	; 23/04/2016 - 24/04/2016
 39775                              <1> 	; 22/04/2016 (TRDOS 386 = TRDOS v2.0)
 39776                              <1> 	; 05/11/2011 
 39777                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'cmp_cmd_run', 'cmp_cmd_external')
 39778                              <1> 	; ('loc_run_check_filename')
 39779                              <1> 	; 29/08/2011
 39780                              <1> 	; 10/09/2011
 39781                              <1> 	; INPUT->
 39782                              <1> 	;	ESI = Path Name address (CommandBuffer address)
 39783                              <1> 	; OUTPUT ->
 39784                              <1> 	;	none (error message will be shown if an error will occur)
 39785                              <1> 	;
 39786                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI, EBP will be changed) 
 39787                              <1> 	;
 39788                              <1> loc_run_check_filename:
 39789 0000A115 803E20              <1> 	cmp	byte [esi], 20h
 39790                              <1> 	;jb	loc_cmd_failed
 39791                              <1> 	; 25/07/2022
 39792 0000A118 7237                <1> 	jb	short loc_run_ppn_failed
 39793 0000A11A 7703                <1> 	ja	short loc_run_check_filename_ok
 39794 0000A11C 46                  <1> 	inc	esi
 39795 0000A11D EBF6                <1> 	jmp	short loc_run_check_filename
 39796                              <1> 
 39797                              <1> loc_run_check_filename_ok:
 39798 0000A11F C605[A3780100]00    <1> 	mov	byte [CmdArgStart], 0 ; reset
 39799 0000A126 56                  <1> 	push	esi ; *
 39800                              <1> loc_run_get_first_arg_pos:
 39801 0000A127 46                  <1> 	inc	esi
 39802 0000A128 8A06                <1> 	mov	al, [esi]
 39803 0000A12A 3C20                <1> 	cmp	al, 20h
 39804 0000A12C 77F9                <1> 	ja	short loc_run_get_first_arg_pos
 39805 0000A12E C60600              <1> 	mov	byte [esi], 0
 39806                              <1> loc_run_get_external_arg_pos:
 39807                              <1> 	; 11/05/2016
 39808 0000A131 46                  <1> 	inc	esi
 39809 0000A132 8A06                <1> 	mov	al, [esi]
 39810 0000A134 3C20                <1> 	cmp	al, 20h
 39811 0000A136 760C                <1> 	jna	short loc_run_parse_path_name
 39812 0000A138 89F0                <1> 	mov	eax, esi
 39813 0000A13A 2D[F2780100]        <1> 	sub	eax, CommandBuffer
 39814 0000A13F A2[A3780100]        <1> 	mov	byte [CmdArgStart], al
 39815                              <1> loc_run_parse_path_name:
 39816 0000A144 5E                  <1> 	pop	esi ; *
 39817 0000A145 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 39818 0000A14A E888090000          <1> 	call	parse_path_name
 39819                              <1> 	;jc	loc_cmd_failed
 39820                              <1> 	; 25/07/2022
 39821 0000A14F 7305                <1> 	jnc	short loc_run_check_filename_exists
 39822                              <1> loc_run_ppn_failed:
 39823 0000A151 E9D4E3FFFF          <1> 	jmp	loc_cmd_failed
 39824                              <1> 
 39825                              <1> loc_run_check_filename_exists:
 39826 0000A156 BE[24810100]        <1> 	mov	esi, FindFile_Name
 39827 0000A15B 803E20              <1> 	cmp	byte [esi], 20h
 39828                              <1> 	;jna	loc_cmd_failed
 39829                              <1> 	; 25/07/2022
 39830 0000A15E 76F1                <1> 	jna	short loc_run_ppn_failed
 39831                              <1> 
 39832                              <1> loc_run_check_exe_filename_ext:
 39833 0000A160 E874020000          <1> 	call	check_prg_filename_ext
 39834                              <1> 	;jc	loc_cmd_failed
 39835                              <1> 	; 25/07/2022
 39836 0000A165 72EA                <1> 	jc	short loc_run_ppn_failed
 39837                              <1> 	
 39838                              <1> loc_run_check_exe_filename_ext_ok:
 39839 0000A167 66A3[FA830100]      <1> 	mov	word [EXE_ID], ax
 39840                              <1> 
 39841                              <1> loc_run_drv:
 39842 0000A16D C605[F9830100]00    <1> 	mov	byte [Run_Manual_Path], 0
 39843 0000A174 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 39844 0000A179 A3[F4830100]        <1>         mov     [Run_CDirFC], eax
 39845                              <1> 	;
 39846 0000A17E 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 39847 0000A184 8835[9F7F0100]      <1> 	mov	[RUN_CDRV], dh
 39848                              <1> 
 39849 0000A18A 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 39850 0000A190 38F2                <1> 	cmp	dl, dh
 39851 0000A192 7413                <1> 	je	short loc_run_change_directory
 39852                              <1>                
 39853 0000A194 8005[F9830100]02    <1> 	add	byte [Run_Manual_Path], 2
 39854                              <1> 
 39855 0000A19B E8C3D5FFFF          <1> 	call	change_current_drive
 39856                              <1> 	;jc	loc_run_cmd_failed
 39857                              <1> 	; 25/07/2022
 39858 0000A1A0 7305                <1> 	jnc	short loc_run_change_directory
 39859 0000A1A2 E9AEE3FFFF          <1> 	jmp	loc_run_cmd_failed
 39860                              <1> 
 39861                              <1> loc_run_change_directory:
 39862 0000A1A7 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 39863 0000A1AE 7624                <1> 	jna	short loc_run_find_executable_file
 39864                              <1> 
 39865 0000A1B0 FE05[F9830100]      <1> 	inc	byte [Run_Manual_Path]
 39866                              <1>      
 39867 0000A1B6 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 39868                              <1> 
 39869 0000A1BC BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 39870 0000A1C1 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 39871 0000A1C3 E823030000          <1> 	call	change_current_directory
 39872                              <1> 	;jc	loc_run_cmd_failed
 39873                              <1> 	; 25/07/2022
 39874 0000A1C8 7305                <1> 	jnc	short loc_run_change_prompt_dir_string
 39875 0000A1CA E986E3FFFF          <1> 	jmp	loc_run_cmd_failed
 39876                              <1> 
 39877                              <1> loc_run_change_prompt_dir_string:
 39878 0000A1CF E83B020000          <1> 	call	change_prompt_dir_string
 39879                              <1> 
 39880                              <1> loc_run_find_executable_file:
 39881 0000A1D4 66C705[F8830100]00- <1> 	mov	word [Run_Auto_Path], 0
 39882 0000A1DC 00                  <1>
 39883                              <1> 
 39884                              <1> loc_run_find_executable_file_next:
 39885 0000A1DD BE[24810100]        <1> 	mov	esi, FindFile_Name
 39886                              <1> loc_run_find_program_file_next:
 39887 0000A1E2 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
 39888 0000A1E6 E826E8FFFF          <1> 	call	find_first_file
 39889                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 39890                              <1> 	; EDI = Directory Buffer Directory Entry Location
 39891                              <1> 	; EAX = File size
 39892                              <1> 	;jnc	loc_load_and_run_file
 39893                              <1> 	; 25/07/2022
 39894 0000A1EB 7205                <1> 	jc	short loc_run_program_file_not_found
 39895 0000A1ED E946010000          <1> 	jmp	loc_load_and_run_file
 39896                              <1> 
 39897                              <1> loc_run_program_file_not_found:	 
 39898 0000A1F2 3C02                <1> 	cmp	al, 2 ; file not found
 39899                              <1> 	;jne	loc_run_cmd_failed
 39900                              <1> 	; 25/07/2022
 39901 0000A1F4 7405                <1> 	je	short loc_run_progr_file_chk_prg_ext
 39902 0000A1F6 E95AE3FFFF          <1> 	jmp	loc_run_cmd_failed
 39903                              <1> 
 39904                              <1> loc_run_progr_file_chk_prg_ext: ; 25/07/2022
 39905 0000A1FB 66A1[FA830100]      <1> 	mov	ax, word [EXE_ID]
 39906 0000A201 80FC2E              <1> 	cmp	ah, '.' ; File name has extension sign
 39907 0000A204 7424                <1> 	je	short loc_run_check_auto_path
 39908                              <1> 
 39909 0000A206 08C0                <1> 	or	al, al
 39910 0000A208 7520                <1> 	jnz	short loc_run_check_auto_path
 39911                              <1> 
 39912 0000A20A 80FC08              <1> 	cmp	ah, 8 ; count of file name chars
 39913 0000A20D 771B                <1> 	ja	short loc_run_check_auto_path
 39914                              <1> 
 39915                              <1> loc_run_change_file_ext_to_prg:
 39916 0000A20F 0FB6DC              <1> 	movzx	ebx, ah ; count of file name chars
 39917 0000A212 BE[24810100]        <1> 	mov	esi, FindFile_Name
 39918 0000A217 01F3                <1> 	add	ebx, esi	
 39919                              <1> 	; 07/05/2016
 39920 0000A219 C7032E505247        <1> 	mov	dword [ebx],  '.PRG'
 39921 0000A21F 66C705[FA830100]50- <1> 	mov	word [EXE_ID], 'P.'
 39922 0000A227 2E                  <1>
 39923 0000A228 EBB8                <1> 	jmp	short loc_run_find_program_file_next	
 39924                              <1> 
 39925                              <1> loc_run_check_auto_path:
 39926                              <1> 	; NOTE: /// 07/05/2016 ///
 39927                              <1> 	; If the path is given, value of byte [Run_Manual_Path]
 39928                              <1> 	; will not be ZERO. If so, file searching by using
 39929                              <1> 	; Automatic Path (via 'PATH' environment variable)
 39930                              <1> 	; will not be applicable, because the program file 
 39931                              <1> 	; is already/absolutely not found.
 39932                              <1> 
 39933 0000A22A A0[F9830100]        <1> 	mov	al, [Run_Manual_Path]
 39934 0000A22F 08C0                <1> 	or	al, al
 39935                              <1> 	;jnz	loc_cmd_failed
 39936                              <1> 	; 25/07/2022
 39937 0000A231 7524                <1> 	jnz	short loc_run_cap_failed
 39938                              <1> 
 39939                              <1> loc_run_check_auto_path_again:
 39940 0000A233 66833D[F8830100]FF  <1> 	cmp	word [Run_Auto_Path], 0FFFFh		 
 39941                              <1> 		; 0FFFFh = Not a valid run path (in ENV block) 
 39942                              <1> 	;jnb	loc_cmd_failed
 39943                              <1> 	; 25/07/2022
 39944 0000A23B 731A                <1> 	jnb	short loc_run_cap_failed
 39945                              <1> 	; xor	al, al 
 39946 0000A23D BE[3C310100]        <1> 	mov	esi, Cmd_Path ; 'PATH'
 39947 0000A242 BF[42790100]        <1> 	mov	edi, TextBuffer
 39948 0000A247 E86DF9FFFF          <1> 	call	get_environment_string
 39949 0000A24C 730E                <1> 	jnc	short loc_run_chk_filename_ext_again
 39950 0000A24E 66C705[F8830100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; invalid
 39951 0000A256 FF                  <1>
 39952                              <1> loc_run_cap_failed: ; 25/07/2022	
 39953 0000A257 E9CEE2FFFF          <1> 	jmp	loc_cmd_failed
 39954                              <1> 
 39955                              <1> loc_run_chk_filename_ext_again:
 39956 0000A25C 89C1                <1> 	mov	ecx, eax ; string length (with zero tail)
 39957 0000A25E 49                  <1> 	dec	ecx ; without zero tail
 39958 0000A25F 66A1[FA830100]      <1> 	mov	ax, [EXE_ID]
 39959 0000A265 80FC2E              <1> 	cmp	ah, '.'
 39960 0000A268 740E                <1> 	je	short loc_run_chk_auto_path_pos
 39961                              <1> 	 
 39962                              <1> loc_run_change_file_ext_to_noext_again:
 39963 0000A26A 0FB6DC              <1> 	movzx	ebx, ah
 39964 0000A26D BE[24810100]        <1> 	mov	esi, FindFile_Name
 39965 0000A272 01F3                <1> 	add 	ebx, esi
 39966 0000A274 29C0                <1> 	sub	eax, eax
 39967 0000A276 8903                <1> 	mov	[ebx], eax ; 0 ; erase extension (.PRG)
 39968                              <1> 
 39969                              <1> loc_run_chk_auto_path_pos:
 39970                              <1> 	;movzx	eax,  word [Run_Auto_Path]
 39971 0000A278 66A1[F8830100]      <1> 	mov	ax, [Run_Auto_Path]
 39972 0000A27E 39C8                <1> 	cmp	eax, ecx ; ecx = string length (except zero tail)
 39973                              <1> 	;jnb	loc_cmd_failed
 39974                              <1>  	; 25/07/2022
 39975 0000A280 73D5                <1> 	jnb	short loc_run_cap_failed
 39976                              <1> 
 39977                              <1> 	;or	eax, eax
 39978 0000A282 6609C0              <1> 	or	ax, ax
 39979 0000A285 7502                <1> 	jnz	short loc_run_auto_path_pos_move
 39980 0000A287 B005                <1> 	mov	al, 5
 39981                              <1> 
 39982                              <1> loc_run_auto_path_pos_move:
 39983 0000A289 89FE                <1> 	mov	esi, edi ; offset TextBuffer
 39984 0000A28B 01C6                <1> 	add	esi, eax
 39985                              <1> 
 39986                              <1> loc_run_auto_path_pos_space_loop:
 39987 0000A28D AC                  <1> 	lodsb
 39988 0000A28E 3C20                <1> 	cmp	al, 20h 
 39989 0000A290 74FB                <1> 	je	short loc_run_auto_path_pos_space_loop
 39990                              <1> 	;jb	loc_cmd_failed
 39991                              <1>  	; 25/07/2022
 39992 0000A292 72C3                <1> 	jb	short loc_run_cap_failed
 39993                              <1> 	;
 39994 0000A294 AA                  <1> 	stosb
 39995                              <1> loc_run_auto_path_pos_move_next: 
 39996 0000A295 AC                  <1> 	lodsb
 39997 0000A296 3C3B                <1> 	cmp	al, ';'
 39998 0000A298 7414                <1> 	je	short loc_run_auto_path_pos_move_last_byte
 39999 0000A29A 3C20                <1> 	cmp	al, 20h
 40000 0000A29C 74F7                <1> 	je	short loc_run_auto_path_pos_move_next
 40001 0000A29E 7203                <1> 	jb	short loc_byte_ptr_end_of_path
 40002 0000A2A0 AA                  <1> 	stosb
 40003 0000A2A1 EBF2                <1> 	jmp	short loc_run_auto_path_pos_move_next 
 40004                              <1> 
 40005                              <1> loc_byte_ptr_end_of_path: 
 40006 0000A2A3 66C705[F8830100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; end of path
 40007 0000A2AB FF                  <1>
 40008 0000A2AC EB0D                <1> 	jmp	short loc_run_auto_path_move_ok 
 40009                              <1> 
 40010                              <1> loc_run_auto_path_pos_move_last_byte:
 40011 0000A2AE 89F0                <1> 	mov	eax, esi
 40012 0000A2B0 2D[42790100]        <1> 	sub	eax, TextBuffer 
 40013 0000A2B5 66A3[F8830100]      <1> 	mov	[Run_Auto_Path], ax ; next path position
 40014                              <1> 
 40015                              <1> loc_run_auto_path_move_ok:
 40016 0000A2BB 4F                  <1> 	dec	edi
 40017 0000A2BC B02F                <1> 	mov	al, '/'
 40018 0000A2BE 3807                <1> 	cmp	[edi], al
 40019 0000A2C0 7403                <1> 	je	short loc_run_auto_path_move_file_name
 40020 0000A2C2 47                  <1> 	inc	edi
 40021 0000A2C3 8807                <1> 	mov	[edi], al
 40022                              <1> 
 40023                              <1> loc_run_auto_path_move_file_name:
 40024 0000A2C5 47                  <1> 	inc	edi   
 40025 0000A2C6 BE[24810100]        <1> 	mov	esi, FindFile_Name
 40026                              <1> 
 40027                              <1> loc_run_auto_path_move_fn_loop:
 40028 0000A2CB AC                  <1> 	lodsb
 40029 0000A2CC AA                  <1> 	stosb
 40030 0000A2CD 08C0                <1> 	or	al, al
 40031 0000A2CF 75FA                <1> 	jnz	short loc_run_auto_path_move_fn_loop
 40032                              <1> 
 40033 0000A2D1 BE[42790100]        <1> 	mov	esi, TextBuffer
 40034 0000A2D6 BF[E2800100]        <1> 	mov	edi, FindFile_Drv
 40035 0000A2DB E8F7070000          <1> 	call	parse_path_name
 40036                              <1> 	;jc	loc_run_cmd_failed
 40037                              <1> 	; 25/07/2022
 40038                              <1> 	;jnc	short loc_run_change_current_drive
 40039                              <1> 	;jmp	loc_run_cmd_failed
 40040 0000A2E0 7234                <1> 	jc	short loc_run_path_failed
 40041                              <1> 
 40042                              <1> loc_run_change_current_drive: 
 40043 0000A2E2 8A35[42780100]      <1> 	mov	dh, [Current_Drv]
 40044 0000A2E8 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 40045 0000A2EE 38F2                <1> 	cmp	dl, dh
 40046 0000A2F0 7407                <1> 	je	short loc_run_change_directory_again
 40047                              <1>              
 40048 0000A2F2 E86CD4FFFF          <1> 	call	change_current_drive
 40049                              <1> 	;jc	loc_run_cmd_failed
 40050                              <1> 	; 25/07/2022
 40051                              <1> 	;jnc	short loc_run_change_directory_again
 40052                              <1> 	;jmp	loc_run_cmd_failed
 40053 0000A2F7 721D                <1> 	jc	short loc_run_path_failed
 40054                              <1> 
 40055                              <1> loc_run_change_directory_again:
 40056 0000A2F9 803D[E3800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
 40057 0000A300 761E                <1> 	jna	short loc_load_executable_cdir_chk_again
 40058                              <1> 
 40059 0000A302 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 40060 0000A308 BE[E3800100]        <1> 	mov	esi, FindFile_Directory
 40061 0000A30D 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 40062 0000A30F E8D7010000          <1> 	call	change_current_directory
 40063                              <1> 	;jc	loc_run_cmd_failed
 40064                              <1> 	; 25/07/2022
 40065 0000A314 7305                <1> 	jnc	short loc_run_chg_prompt_dir_str_again
 40066                              <1> loc_run_path_failed: ; 25/07/2022
 40067 0000A316 E93AE2FFFF          <1> 	jmp	loc_run_cmd_failed
 40068                              <1> 
 40069                              <1> loc_run_chg_prompt_dir_str_again:
 40070 0000A31B E8EF000000          <1> 	call	change_prompt_dir_string
 40071                              <1> 
 40072                              <1> loc_load_executable_cdir_chk_again:
 40073 0000A320 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 40074 0000A325 3B05[F4830100]      <1> 	cmp	eax, [Run_CDirFC]
 40075 0000A32B 0F85ACFEFFFF        <1> 	jne	loc_run_find_executable_file_next
 40076 0000A331 30C0                <1> 	xor	al, al ; 0
 40077 0000A333 E9FBFEFFFF          <1> 	jmp	loc_run_check_auto_path_again
 40078                              <1> 
 40079                              <1> loc_load_and_run_file:
 40080                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 40081                              <1> 	; 13/11/2017
 40082                              <1> 	; 04/01/2017
 40083                              <1> 	; 23/04/2016
 40084 0000A338 BE[24810100]        <1> 	mov	esi, FindFile_Name
 40085 0000A33D BF[42790100]        <1> 	mov	edi, TextBuffer
 40086                              <1> 
 40087                              <1>  	; 24/04/2016
 40088 0000A342 31D2                <1> 	xor	edx, edx
 40089                              <1> 	;mov	word [argc], dx ; 0
 40090                              <1> 	; 25/07/2022
 40091 0000A344 8915[14020300]      <1> 	mov	dword [argc], edx
 40092 0000A34A 8915[48010300]      <1> 	mov	dword [u.nread], edx ; 0
 40093                              <1> 
 40094                              <1> loc_load_and_run_file_1:
 40095 0000A350 AC                  <1> 	lodsb	
 40096 0000A351 AA                  <1> 	stosb
 40097 0000A352 FF05[48010300]      <1> 	inc	dword [u.nread]
 40098 0000A358 20C0                <1> 	and	al, al
 40099 0000A35A 75F4                <1> 	jnz 	short loc_load_and_run_file_1
 40100                              <1> 	
 40101 0000A35C A0[A3780100]        <1> 	mov	al, [CmdArgStart]
 40102 0000A361 20C0                <1> 	and	al, al
 40103 0000A363 7442                <1> 	jz	short loc_load_and_run_file_7
 40104                              <1> 
 40105 0000A365 0FB6F0              <1> 	movzx	esi, al ; 11/05/2016
 40106                              <1> 	;mov	ecx, 80
 40107                              <1> 	; 25/07/2022
 40108 0000A368 31C9                <1> 	xor	ecx, ecx
 40109 0000A36A B150                <1> 	mov	cl, 80
 40110                              <1> 	;sub	ecx, esi
 40111 0000A36C 28C1                <1> 	sub	cl, al
 40112 0000A36E 81C6[F2780100]      <1> 	add	esi, CommandBuffer
 40113                              <1> 
 40114                              <1> 	;inc	word [argc] ; 11/05/2016
 40115                              <1> 	; 25/07/2022
 40116 0000A374 FF05[14020300]      <1> 	inc	dword [argc]
 40117                              <1> 
 40118                              <1> loc_load_and_run_file_2:
 40119 0000A37A AC                  <1> 	lodsb
 40120 0000A37B 3C20                <1> 	cmp	al, 20h
 40121 0000A37D 7716                <1> 	ja	short loc_load_and_run_file_5	
 40122 0000A37F 721D                <1> 	jb	short loc_load_and_run_file_6
 40123                              <1> 
 40124                              <1> loc_load_and_run_file_3:
 40125 0000A381 803E20              <1> 	cmp	byte [esi], 20h
 40126 0000A384 7707                <1> 	ja	short loc_load_and_run_file_4
 40127 0000A386 7216                <1> 	jb	short loc_load_and_run_file_6
 40128 0000A388 46                  <1> 	inc	esi
 40129 0000A389 E2F6                <1> 	loop	loc_load_and_run_file_3
 40130 0000A38B EB11                <1> 	jmp	short loc_load_and_run_file_6
 40131                              <1> 
 40132                              <1> loc_load_and_run_file_4:
 40133 0000A38D 28C0                <1> 	sub	al, al ; 0
 40134                              <1> 	;inc	word [argc]
 40135                              <1> 	; 25/07/2022
 40136 0000A38F FF05[14020300]      <1> 	inc	dword [argc]
 40137                              <1> loc_load_and_run_file_5:
 40138 0000A395 AA                  <1> 	stosb
 40139 0000A396 FF05[48010300]      <1> 	inc	dword [u.nread]
 40140 0000A39C E2DC                <1> 	loop	loc_load_and_run_file_2
 40141                              <1> 			
 40142                              <1> loc_load_and_run_file_6:
 40143 0000A39E 30C0                <1> 	xor	al, al ; 0
 40144 0000A3A0 AA                  <1> 	stosb
 40145 0000A3A1 FF05[48010300]      <1> 	inc	dword [u.nread]
 40146                              <1> loc_load_and_run_file_7:
 40147 0000A3A7 8807                <1> 	mov 	[edi], al ; 0
 40148                              <1> 	;inc	word [argc] ; 24/04/2016
 40149                              <1> 	; 25/07/2022
 40150 0000A3A9 FF05[14020300]      <1> 	inc	dword [argc]
 40151 0000A3AF FF05[48010300]      <1> 	inc	dword [u.nread] ; 24/04/2016
 40152 0000A3B5 BE[42790100]        <1> 	mov	esi, TextBuffer
 40153 0000A3BA 8B15[50810100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
 40154 0000A3C0 66A1[48810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
 40155 0000A3C6 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
 40156 0000A3C9 66A1[4E810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
 40157                              <1> 	; EAX = First Cluster number
 40158                              <1> 	; EDX = File Size
 40159                              <1> 	; ESI = Argument list address
 40160                              <1> 	; [argc] = argument count
 40161                              <1> 	; [u.nread] = argument list length
 40162 0000A3CF E8CA630000          <1> 	call	load_and_run_file ; trdosk6.s
 40163                              <1>         ;jc	loc_run_cmd_failed ; 04/01/2017
 40164                              <1> loc_load_and_run_file_8: ; 06/05/2016
 40165 0000A3D4 E94CEAFFFF          <1> 	jmp	loc_file_rw_restore_retn
 40166                              <1> 
 40167                              <1> check_prg_filename_ext:
 40168                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
 40169                              <1> 	; 10/09/2011 
 40170                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'proc_check_exe_filename_ext')
 40171                              <1> 	; 14/11/2009
 40172                              <1> 	; INPUT -> 
 40173                              <1> 	;	ESI = Dot File Name
 40174                              <1> 	; OUTPUT ->
 40175                              <1> 	;     cf = 0 -> EXE_ID in AL
 40176                              <1> 	;	ESI = Last char + 1 position
 40177                              <1> 	;     cf = 1 -> Invalid executable file name
 40178                              <1> 	;	or no file name extension if AH<=8
 40179                              <1> 	;	AL = Last file name char     
 40180                              <1> 	;     cf = 0 -> AL='P' (PRG), AL=0 (no extension)
 40181                              <1> 	;
 40182                              <1> 	; (Modified registers: EAX, ESI)
 40183                              <1>   
 40184 0000A3D9 30E4                <1> 	xor	ah, ah
 40185                              <1> loc_run_check_filename_ext:	
 40186 0000A3DB AC                  <1> 	lodsb
 40187 0000A3DC 3C21                <1> 	cmp	al, 21h
 40188 0000A3DE 7229                <1> 	jb	short loc_check_exe_fn_retn 
 40189 0000A3E0 FEC4                <1> 	inc	ah
 40190 0000A3E2 3C2E                <1> 	cmp	al, '.'
 40191 0000A3E4 75F5                <1> 	jne	short loc_run_check_filename_ext	
 40192                              <1> 		 
 40193                              <1> loc_run_check_filename_ext_dot:
 40194 0000A3E6 80FC02              <1> 	cmp	ah, 2  ; .??? is not valid
 40195 0000A3E9 88C4                <1> 	mov	ah, al ; '.' 
 40196 0000A3EB 7219                <1> 	jb	short loc_check_prg_fn_retn
 40197                              <1> 
 40198                              <1> loc_run_check_filename_ext_dot_ok:
 40199 0000A3ED AC                  <1> 	lodsb
 40200 0000A3EE 24DF                <1> 	and	al, 0DFh 
 40201                              <1> 
 40202                              <1> loc_run_check_filename_ext_prg:
 40203 0000A3F0 3C50                <1> 	cmp	al, 'P'
 40204 0000A3F2 7212                <1> 	jb	short loc_check_prg_fn_retn
 40205 0000A3F4 7711                <1> 	ja	short loc_check_prg_fn_stc
 40206 0000A3F6 AC                  <1> 	lodsb
 40207 0000A3F7 24DF                <1> 	and	al, 0DFh 
 40208 0000A3F9 3C52                <1> 	cmp	al, 'R'
 40209 0000A3FB 750A                <1> 	jne	short loc_check_prg_fn_stc
 40210 0000A3FD AC                  <1> 	lodsb
 40211 0000A3FE 24DF                <1> 	and	al, 0DFh
 40212 0000A400 3C47                <1> 	cmp	al, 'G'
 40213 0000A402 7503                <1> 	jne	short loc_check_prg_fn_stc
 40214                              <1> 
 40215 0000A404 B050                <1> 	mov	al, 'P'
 40216                              <1> loc_check_prg_fn_retn:
 40217 0000A406 C3                  <1> 	retn
 40218                              <1> 
 40219                              <1> ; 25/07/2022 - TRDOS 386 Kernel v2.0.5
 40220                              <1> 
 40221                              <1> loc_check_prg_fn_stc:
 40222 0000A407 F9                  <1> 	stc
 40223 0000A408 C3                  <1> 	retn
 40224                              <1>  
 40225                              <1> loc_check_exe_fn_retn:
 40226 0000A409 28C0                <1> 	sub	al, al ; 0
 40227                              <1> 	;retn
 40228                              <1>               
 40229                              <1> find_and_list_files:
 40230                              <1> 	;retn
 40231                              <1> set_exec_arguments:
 40232 0000A40B C3                  <1> 	retn
 40233                              <1> 
 40234                              <1> delete_fs_directory:
 40235 0000A40C 31C0                <1> 	xor	eax, eax
 40236 0000A40E C3                  <1> 	retn
 40237                                  %include 'trdosk4.s' ; 24/01/2016
 40238                              <1> ; ****************************************************************************
 40239                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - Directory Functions : trdosk4.s
 40240                              <1> ; ----------------------------------------------------------------------------
 40241                              <1> ; Last Update: 11/08/2022  (Previous: 02/03/2021)
 40242                              <1> ; ----------------------------------------------------------------------------
 40243                              <1> ; Beginning: 24/01/2016
 40244                              <1> ; ----------------------------------------------------------------------------
 40245                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 40246                              <1> ; ----------------------------------------------------------------------------
 40247                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 40248                              <1> ; DIR.ASM (09/10/2011)
 40249                              <1> ; ****************************************************************************
 40250                              <1> 
 40251                              <1> ; DIR.ASM  [ TRDOS KERNEL - COMMAND EXECUTER SECTION - DIRECTORY FUNCTIONS ]
 40252                              <1> ; (c) 2004-2010  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/10/2011
 40253                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
 40254                              <1> 
 40255                              <1> change_prompt_dir_string:
 40256                              <1> 	; 05/10/2016
 40257                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
 40258                              <1> 	; 27/03/2011
 40259                              <1> 	; 09/10/2009
 40260                              <1> 	; INPUT/OUTPUT => none
 40261                              <1> 	; this procedure changes current directory string/text  
 40262                              <1> 	; 2005
 40263                              <1> 
 40264 0000A40F BE[A07F0100]        <1> 	mov	esi, PATH_Array
 40265                              <1> change_prompt_dir_str: ; 05/10/2016 (call from 'set_working_path')
 40266 0000A414 BF[46780100]        <1> 	mov	edi, Current_Directory
 40267 0000A419 8A25[40780100]      <1> 	mov	ah, [Current_Dir_Level]
 40268 0000A41F E807000000          <1> 	call	set_current_directory_string
 40269 0000A424 880D[A1780100]      <1> 	mov	[Current_Dir_StrLen], cl
 40270                              <1> 
 40271 0000A42A C3                  <1> 	retn
 40272                              <1> 
 40273                              <1> set_current_directory_string:
 40274                              <1> 	; 11/08/2022 (TRDOS 386 Kernel v2.0.5)
 40275                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
 40276                              <1> 	; 27/03/2011
 40277                              <1> 	; 09/10/2009
 40278                              <1> 	; INPUT:
 40279                              <1> 	;    ESI = Path Array Address 
 40280                              <1> 	;    EDI = Current Directory String Buffer
 40281                              <1> 	;    AH = Current Directory Level
 40282                              <1> 	; OUTPUT => EAX, EBX, ESI will be changed
 40283                              <1> 	;    EDI will be same with input
 40284                              <1> 	;    ECX = Current Directory String Length 
 40285                              <1> 
 40286 0000A42B 57                  <1> 	push    edi
 40287 0000A42C 80FC00              <1> 	cmp     ah, 0
 40288 0000A42F 7651                <1> 	jna	short pass_write_path
 40289 0000A431 83C610              <1> 	add	esi, 16
 40290 0000A434 89F3                <1> 	mov	ebx, esi
 40291                              <1> loc_write_path:
 40292                              <1> 	;mov	ecx, 8
 40293                              <1> 	; 11/08/2022
 40294 0000A436 29C9                <1> 	sub	ecx, ecx
 40295 0000A438 B108                <1> 	mov	cl, 8
 40296                              <1> path_write_dirname1:
 40297 0000A43A AC                  <1> 	lodsb
 40298 0000A43B 3C20                <1> 	cmp	al, 20h
 40299 0000A43D 7612                <1> 	jna	short pass_write_dirname1
 40300 0000A43F AA                  <1> 	stosb
 40301 0000A440 81FF[A0780100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
 40302 0000A446 733A                <1> 	jnb	short pass_write_path
 40303 0000A448 E2F0                <1> 	loop	path_write_dirname1
 40304 0000A44A 803E20              <1> 	cmp	byte [esi], 20h
 40305 0000A44D 7624                <1> 	jna	short pass_write_dirname2
 40306 0000A44F EB0A                <1> 	jmp     short loc_put_dot_cont_ext
 40307                              <1> pass_write_dirname1:
 40308 0000A451 89DE                <1> 	mov	esi, ebx
 40309 0000A453 83C608              <1> 	add	esi, 8
 40310 0000A456 803E20              <1> 	cmp	byte [esi], 20h
 40311 0000A459 7618                <1> 	jna	short pass_write_dirname2
 40312                              <1> loc_put_dot_cont_ext:
 40313 0000A45B C6072E              <1> 	mov	byte [edi], "."
 40314                              <1> 	;mov	ecx, 3
 40315 0000A45E B103                <1> 	mov	cl, 3
 40316                              <1> loc_check_dir_name_ext:
 40317 0000A460 AC                  <1> 	lodsb
 40318 0000A461 47                  <1> 	inc	edi
 40319 0000A462 3C20                <1> 	cmp	al, 20h
 40320 0000A464 760D                <1> 	jna	short pass_write_dirname2
 40321 0000A466 8807                <1> 	mov	[edi], al
 40322 0000A468 81FF[A0780100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
 40323 0000A46E 7312                <1> 	jnb	short pass_write_path
 40324 0000A470 E2EE                <1> 	loop    loc_check_dir_name_ext
 40325 0000A472 47                  <1> 	inc	edi
 40326                              <1> pass_write_dirname2:
 40327 0000A473 FECC                <1> 	dec	ah
 40328 0000A475 740B                <1> 	jz      short pass_write_path
 40329 0000A477 83C310              <1> 	add	ebx, 16
 40330 0000A47A 89DE                <1> 	mov	esi, ebx
 40331 0000A47C C6072F              <1> 	mov	byte [edi],"/"
 40332 0000A47F 47                  <1> 	inc	edi
 40333 0000A480 EBB4                <1> 	jmp	short loc_write_path
 40334                              <1> pass_write_path:
 40335 0000A482 C60700              <1> 	mov	byte [edi], 0
 40336 0000A485 47                  <1> 	inc	edi
 40337 0000A486 89F9                <1> 	mov	ecx, edi
 40338 0000A488 5F                  <1> 	pop	edi
 40339 0000A489 29F9                <1> 	sub	ecx, edi
 40340                              <1> 	; ECX = Current Directory String Length
 40341 0000A48B C3                  <1> 	retn
 40342                              <1> 
 40343                              <1> get_current_directory:
 40344                              <1> 	; 11/08/2022
 40345                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 40346                              <1> 	; 15/10/2016
 40347                              <1> 	; 14/02/2016
 40348                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
 40349                              <1> 	; 27/03/2011
 40350                              <1> 	;
 40351                              <1> 	; INPUT-> ESI = Current Directory Buffer
 40352                              <1> 	;         DL = TRDOS Logical Dos Drive Number + 1
 40353                              <1> 	;              (0= Default/Current Drive)
 40354                              <1> 	;           
 40355                              <1> 	;   Note: Required dir buffer length may be <= 92 bytes
 40356                              <1> 	;         for TRDOS (7*12 name chars + 7 slash + 0)
 40357                              <1> 	; OUTPUT ->  ESI = Current Directory Buffer
 40358                              <1> 	;            EAX, EBX, ECX, EDX, EDI will be changed
 40359                              <1> 	;            CX/CL = Current Directory String Length
 40360                              <1> 	;	     DL = Drive Number (0 based)
 40361                              <1> 	;            (If input is 0, output is current drv number) 
 40362                              <1> 	;            DH = same with input 
 40363                              <1> 	;   cf = 0 -> AL = 0
 40364                              <1> 	;   cf = 1 -> error code in AL 
 40365                              <1>               
 40366                              <1> loc_get_current_drive_0:
 40367 0000A48C 80FA00              <1> 	cmp	dl, 0
 40368 0000A48F 7708                <1> 	ja	short loc_get_current_drive_1
 40369 0000A491 8A15[42780100]      <1> 	mov	dl, [Current_Drv]
 40370 0000A497 EB16                <1> 	jmp	short loc_get_current_drive_2
 40371                              <1> loc_get_current_drive_1:
 40372 0000A499 FECA                <1> 	dec 	dl
 40373 0000A49B 3A15[67300100]      <1> 	cmp	dl, [Last_DOS_DiskNo]
 40374 0000A4A1 760C                <1> 	jna	short loc_get_current_drive_2
 40375                              <1> 	;mov	eax, 0Fh ; Invalid drive (Drive not ready!)
 40376                              <1> 	;cmc 	; stc
 40377                              <1> 	; 28/07/2022
 40378 0000A4A3 29C0                <1> 	sub	eax, eax
 40379 0000A4A5 B00F                <1> 	mov	al, 0Fh
 40380 0000A4A7 F9                  <1> 	stc
 40381 0000A4A8 C3                  <1> 	retn
 40382                              <1> 
 40383                              <1> loc_get_current_drive_not_ready_retn:
 40384 0000A4A9 5E                  <1> 	pop	esi
 40385                              <1> 	;mov	eax, 15
 40386 0000A4AA 66B80F00            <1> 	mov	ax, 15 ; Drive not ready
 40387 0000A4AE C3                  <1> 	retn  
 40388                              <1>  
 40389                              <1> loc_get_current_drive_2:
 40390 0000A4AF 31C0                <1> 	xor	eax, eax
 40391 0000A4B1 88D4                <1> 	mov	ah, dl
 40392 0000A4B3 56                  <1> 	push	esi
 40393 0000A4B4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 40394 0000A4B9 01C6                <1> 	add	esi, eax
 40395 0000A4BB 8A06                <1> 	mov	al, [esi+LD_Name] 
 40396 0000A4BD 3C41                <1> 	cmp	al, 'A'
 40397 0000A4BF 72E8                <1> 	jb	short loc_get_current_drive_not_ready_retn
 40398                              <1> 
 40399                              <1> 	; 28/07/2022
 40400 0000A4C1 31C9                <1> 	xor	ecx, ecx
 40401                              <1> 
 40402 0000A4C3 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
 40403 0000A4C6 08E4                <1> 	or	ah, ah
 40404 0000A4C8 7505                <1> 	jnz	short loc_get_current_drive_3
 40405                              <1> 
 40406                              <1> 	;xor	ah, ah ; mov ah, 0
 40407                              <1> 	
 40408                              <1> 	; 11/08/2022- BugFix (*)
 40409 0000A4CA 5E                  <1> 	pop	esi ; (*) Current Directory Buffer address
 40410                              <1> 	
 40411 0000A4CB 8826                <1> 	mov	[esi], ah
 40412                              <1> 	; 28/07/2022
 40413                              <1> 	;xor	ecx, ecx
 40414 0000A4CD EB19                <1> 	jmp	short loc_get_current_drive_4
 40415                              <1> 
 40416                              <1> loc_get_current_drive_3:
 40417 0000A4CF BF[A07F0100]        <1>         mov     edi, PATH_Array
 40418 0000A4D4 57                  <1> 	push	edi
 40419 0000A4D5 81C680000000        <1> 	add	esi, LD_CurrentDirectory
 40420                              <1> 	;mov	ecx, 32
 40421                              <1> 	; 28/07/2022
 40422 0000A4DB B120                <1> 	mov	cl, 32
 40423 0000A4DD F3A5                <1> 	rep	movsd
 40424 0000A4DF 5E                  <1> 	pop	esi ; Path Array Address
 40425 0000A4E0 5F                  <1> 	pop	edi ; pushed esi (current dir buffer offset) 
 40426                              <1> 	;
 40427 0000A4E1 E845FFFFFF          <1> 	call	set_current_directory_string
 40428 0000A4E6 89FE                <1> 	mov	esi, edi
 40429                              <1> 
 40430                              <1> loc_get_current_drive_4:
 40431 0000A4E8 30C0                <1> 	xor	al, al
 40432 0000A4EA C3                  <1> 	retn
 40433                              <1> 
 40434                              <1> change_current_directory:
 40435                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 40436                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
 40437                              <1> 	; 19/02/2016
 40438                              <1> 	; 11/02/2016
 40439                              <1> 	; 10/02/2016
 40440                              <1> 	; 08/02/2016
 40441                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
 40442                              <1> 	; 18/09/2011 (DIR.ASM, 09/10/2011)	
 40443                              <1> 	; 04/10/2009
 40444                              <1> 	; 2005
 40445                              <1> 	; INPUT -> 
 40446                              <1> 	;	ESI = Directory string
 40447                              <1> 	;	ah = CD command (CDh = save current dir string)
 40448                              <1> 	; OUTPUT -> 
 40449                              <1> 	; 	EDI = DOS Drive Description Table
 40450                              <1> 	; 	cf = 1 -> error
 40451                              <1> 	;	   EAX = Error code
 40452                              <1> 	;	cf = 0 -> successful
 40453                              <1> 	;	   ESI = PATH_Array
 40454                              <1> 	;	   EAX = Current Directory First Cluster
 40455                              <1> 	;
 40456                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
 40457                              <1> 	
 40458 0000A4EB 8825[2E800100]      <1> 	mov	[CD_COMMAND], ah
 40459 0000A4F1 803E2F              <1> 	cmp	byte [esi], '/'
 40460 0000A4F4 7505                <1> 	jne	short loc_ccd_cdir_level
 40461 0000A4F6 46                  <1> 	inc	esi
 40462 0000A4F7 30C0                <1> 	xor	al, al
 40463 0000A4F9 EB05                <1> 	jmp	short loc_ccd_parse_path_name
 40464                              <1> loc_ccd_cdir_level:
 40465 0000A4FB A0[40780100]        <1> 	mov	al, [Current_Dir_Level]
 40466                              <1> loc_ccd_parse_path_name:
 40467 0000A500 88C4                <1> 	mov	ah, al
 40468 0000A502 BF[A07F0100]        <1> 	mov	edi, PATH_Array
 40469                              <1> 
 40470                              <1> ; Reset directory levels > cdir level
 40471                              <1> 	; is this required !?
 40472                              <1> 	;
 40473                              <1> 	; Relations:
 40474                              <1> 	; MAINPROG.ASM (pass_ccdrv_reset_cdir_FAT_fcluster)
 40475                              <1> 	; proc_parse_dir_name,
 40476                              <1> 	; proc_change_current_directory (this procedure)
 40477                              <1> 	; proc_change_prompt_dir_string 
 40478                              <1>  
 40479 0000A507 0FB6C8              <1> 	movzx	ecx, al
 40480 0000A50A FEC1                <1> 	inc	cl
 40481 0000A50C C0E104              <1> 	shl	cl, 4
 40482 0000A50F 01CF                <1> 	add	edi, ecx
 40483 0000A511 B107                <1> 	mov	cl, 7
 40484 0000A513 28C1                <1> 	sub	cl, al
 40485 0000A515 C0E102              <1> 	shl	cl, 2
 40486 0000A518 89C3                <1> 	mov	ebx, eax
 40487 0000A51A 31C0                <1> 	xor	eax, eax ; 0
 40488 0000A51C F3AB                <1> 	rep	stosd
 40489 0000A51E 89D8                <1> 	mov	eax, ebx
 40490                              <1> 
 40491 0000A520 BF[A07F0100]        <1> 	mov	edi, PATH_Array
 40492                              <1> 
 40493 0000A525 803E20              <1> 	cmp	byte [esi], 20h
 40494 0000A528 F5                  <1> 	cmc
 40495 0000A529 7305                <1> 	jnc	short pass_ccd_parse_dir_name
 40496                              <1> 
 40497                              <1> 		; ESI = Path name
 40498                              <1> 		; AL = CCD_Level
 40499 0000A52B E871010000          <1>         call    parse_dir_name
 40500                              <1> 		; AL = CCD_Level 
 40501                              <1> 		; AH = Last_Dir_Level
 40502                              <1> 		; (EDI = PATH_Array)
 40503                              <1> 
 40504                              <1> pass_ccd_parse_dir_name:
 40505 0000A530 9C                  <1> 	pushf
 40506                              <1> 
 40507                              <1> 	;mov	[CCD_Level], al
 40508                              <1>         ;mov	[Last_Dir_Level], ah
 40509 0000A531 66A3[24800100]      <1> 	mov	[CCD_Level], ax
 40510                              <1> 
 40511 0000A537 31DB                <1> 	xor	ebx, ebx
 40512 0000A539 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 40513 0000A53F BE00010900          <1> 	mov	esi, Logical_DOSDisks
 40514 0000A544 01DE                <1> 	add	esi, ebx
 40515                              <1> 
 40516 0000A546 9D                  <1> 	popf 
 40517 0000A547 720A                <1> 	jc	short loc_ccd_bad_path_name_retn
 40518                              <1> 
 40519 0000A549 8935[20800100]      <1> 	mov	[CCD_DriveDT], esi
 40520                              <1> 
 40521 0000A54F 3C07                <1> 	cmp	al, 7
 40522 0000A551 7208                <1> 	jb	short loc_ccd_load_child_dir
 40523                              <1> 
 40524                              <1> loc_ccd_bad_path_name_retn:
 40525 0000A553 87F7                <1> 	xchg	esi, edi
 40526                              <1> 	;mov	eax, 19 ; Bad directory/path name 
 40527                              <1> 	; 28/07/2022
 40528 0000A555 29C0                <1> 	sub	eax, eax
 40529 0000A557 B013                <1> 	mov	al, 19
 40530 0000A559 F9                  <1> 	stc
 40531                              <1> loc_ccd_retn_p:
 40532 0000A55A C3                  <1> 	retn
 40533                              <1> 
 40534                              <1> loc_ccd_load_child_dir:
 40535                              <1> 	; AL = CCD_Level
 40536 0000A55B 08C0                <1> 	or	al, al
 40537 0000A55D 7467                <1> 	jz	short loc_ccd_load_root_dir
 40538                              <1> 
 40539                              <1> 	;mov	cx, ax
 40540                              <1> 	; 28/07/2022
 40541 0000A55F 89C1                <1> 	mov	ecx, eax
 40542 0000A561 C0E004              <1> 	shl	al, 4
 40543 0000A564 0FB6F0              <1> 	movzx	esi, al
 40544 0000A567 01FE                <1>      	add	esi, edi  ; offset PATH_Array
 40545                              <1> 
 40546 0000A569 8B460C              <1> 	mov	eax, [esi+12]
 40547 0000A56C 38E9                <1> 	cmp	cl, ch
 40548                              <1> 	;je	loc_ccd_load_sub_directory
 40549                              <1> 	; 28/07/2022
 40550 0000A56E 7505                <1> 	jne	short loc_ccd_1
 40551 0000A570 E9FA000000          <1> 	jmp	loc_ccd_load_sub_directory	
 40552                              <1> 
 40553                              <1> loc_ccd_1:	; 28/07/2022
 40554 0000A575 A3[3C780100]        <1> 	mov	[Current_Dir_FCluster], eax
 40555                              <1> 
 40556                              <1> loc_ccd_load_child_dir_next:
 40557 0000A57A 83C610              <1> 	add	esi, 16 ; DOS DirEntry Format FileName Address
 40558                              <1> 
 40559                              <1>  	; Directory attribute : 10h
 40560 0000A57D B010                <1> 	mov	al, 00010000b ; 10h (Attrib AND mask)
 40561                              <1> 	;mov	ah, 11001000b ; C8h
 40562                              <1> 	; Volume name attribute: 8h
 40563 0000A57F B408                <1> 	mov	ah, 00001000b ; 08h (Attrib NAND, AND --> zero mask)
 40564                              <1> 
 40565                              <1> 	;xor	cx, cx  
 40566 0000A581 31C9                <1> 	xor	ecx, ecx ; 02/03/2021
 40567 0000A583 E8B6010000          <1> 	call	locate_current_dir_file
 40568 0000A588 7353                <1> 	jnc	short loc_ccd_set_dir_cluster_ptr
 40569                              <1> 
 40570                              <1> 	; 19/02/2016
 40571                              <1> 	;mov	edi, [CCD_DriveDT]
 40572 0000A58A 8A25[24800100]      <1> 	mov	ah, [CCD_Level]
 40573 0000A590 803D[2E800100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
 40574 0000A597 7509                <1> 	jne	short loc_ccd_load_child_dir_err
 40575                              <1> 	; It is better to save recent successful part 
 40576                              <1> 	; of the (requested) path as current directory.
 40577                              <1> 	; (Otherwise the path would be reset to back
 40578                              <1> 	; on the next 'CD' command.)
 40579 0000A599 88E1                <1> 	mov	cl, ah
 40580 0000A59B 50                  <1> 	push	eax
 40581 0000A59C E8E4000000          <1> 	call	loc_ccd_save_current_dir
 40582 0000A5A1 58                  <1> 	pop	eax
 40583                              <1> loc_ccd_load_child_dir_err:            
 40584 0000A5A2 3C03                <1> 	cmp	al, 3	; AL = 2 => File not found error
 40585 0000A5A4 7202                <1> 	jb	short loc_ccd_path_not_found_retn
 40586 0000A5A6 F9                  <1> 	stc
 40587 0000A5A7 C3                  <1> 	retn
 40588                              <1> 
 40589                              <1> loc_ccd_path_not_found_retn:
 40590 0000A5A8 B003                <1> 	mov	al, 3	; Path not found
 40591 0000A5AA C3                  <1> 	retn
 40592                              <1> 
 40593                              <1> loc_ccd_load_FAT_root_dir:
 40594 0000A5AB 803D[41780100]02    <1> 	cmp	byte [Current_FATType], 2
 40595 0000A5B2 776B                <1> 	ja	short loc_ccd_load_FAT32_root_dir
 40596                              <1> 
 40597                              <1> 	;mov	esi, [CCD_DriveDT]
 40598                              <1> 	;push	esi
 40599 0000A5B4 E80F1D0000          <1> 	call	load_FAT_root_directory
 40600                              <1> 	;pop	edi ; Dos Drv Description Table
 40601                              <1> 
 40602 0000A5B9 89F7                <1> 	mov	edi, esi
 40603 0000A5BB BE[A07F0100]        <1> 	mov	esi, PATH_Array
 40604 0000A5C0 7298                <1> 	jc	short loc_ccd_retn_p
 40605                              <1> 
 40606 0000A5C2 31C0                <1> 	xor	eax, eax
 40607 0000A5C4 EB78                <1>         jmp	short loc_ccd_set_cdfc
 40608                              <1> 
 40609                              <1> loc_ccd_load_root_dir:
 40610 0000A5C6 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 40611 0000A5CD 73DC                <1> 	jnb	short loc_ccd_load_FAT_root_dir
 40612                              <1> 
 40613                              <1> loc_ccd_load_FS_root_dir:
 40614 0000A5CF E8AC1D0000          <1> 	call	load_FS_root_directory
 40615 0000A5D4 EB5C                <1> 	jmp	short pass_ccd_load_FAT_sub_directory
 40616                              <1> 
 40617                              <1> loc_ccd_load_FS_sub_directory_next:
 40618 0000A5D6 E8A51D0000          <1> 	call	load_FS_sub_directory
 40619 0000A5DB EB1F                <1> 	jmp	short pass_ccd_set_dir_cluster_ptr  
 40620                              <1> 
 40621                              <1> loc_ccd_set_dir_cluster_ptr:
 40622                              <1> 	; EDI = Directory Entry
 40623 0000A5DD 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
 40624 0000A5E1 C1E010              <1> 	shl	eax, 16
 40625 0000A5E4 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
 40626                              <1> 
 40627 0000A5E8 8B35[20800100]      <1> 	mov	esi, [CCD_DriveDT]
 40628 0000A5EE 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 40629 0000A5F5 72DF                <1> 	jb	short loc_ccd_load_FS_sub_directory_next
 40630                              <1> 	;push	esi
 40631 0000A5F7 E84A1D0000          <1> 	call	load_FAT_sub_directory
 40632                              <1> 	;pop	edi ; Dos Drv Description Table
 40633                              <1> 
 40634                              <1> pass_ccd_set_dir_cluster_ptr:
 40635                              <1> 	;mov	edi, esi
 40636 0000A5FC BE[A07F0100]        <1> 	mov	esi, PATH_Array
 40637 0000A601 7265                <1> 	jc	short loc_ccd_retn_c
 40638                              <1> 
 40639 0000A603 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 40640                              <1> 
 40641 0000A608 FE05[24800100]      <1> 	inc	byte [CCD_Level]
 40642 0000A60E 0FB61D[24800100]    <1> 	movzx	ebx, byte [CCD_Level]
 40643 0000A615 C0E304              <1> 	shl	bl, 4 ; * 16 (<= 128)   
 40644 0000A618 01DE                <1> 	add	esi, ebx ; 19/02/2016
 40645 0000A61A 89460C              <1> 	mov	[esi+12], eax
 40646 0000A61D EB1F                <1> 	jmp	short loc_ccd_set_cdfc
 40647                              <1> 
 40648                              <1> loc_ccd_load_FAT32_root_dir:
 40649 0000A61F BE[A07F0100]        <1> 	mov	esi, PATH_Array
 40650 0000A624 8B460C              <1> 	mov	eax, [esi+12]
 40651 0000A627 8B35[20800100]      <1> 	mov	esi, [CCD_DriveDT]
 40652                              <1>  
 40653                              <1> loc_ccd_load_FAT_sub_directory:
 40654                              <1> 	;push	esi
 40655 0000A62D E8141D0000          <1> 	call	load_FAT_sub_directory
 40656                              <1> 	;pop	edi ; Dos Drv Description Table
 40657                              <1> 
 40658                              <1> pass_ccd_load_FAT_sub_directory:
 40659                              <1> 	;mov	edi, esi
 40660 0000A632 BE[A07F0100]        <1> 	mov	esi, PATH_Array
 40661 0000A637 722F                <1> 	jc	short loc_ccd_retn_c
 40662                              <1> 
 40663 0000A639 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 40664                              <1> 
 40665                              <1> loc_ccd_set_cdfc:
 40666 0000A63E 8A0D[24800100]      <1> 	mov	cl, [CCD_Level]
 40667 0000A644 880D[40780100]      <1> 	mov	[Current_Dir_Level], cl
 40668 0000A64A A3[3C780100]        <1> 	mov	[Current_Dir_FCluster], eax
 40669                              <1> 
 40670 0000A64F 8A2D[25800100]      <1> 	mov	ch, [Last_Dir_Level]
 40671 0000A655 38E9                <1> 	cmp	cl, ch 
 40672                              <1> 	;jb	loc_ccd_load_child_dir_next
 40673                              <1> 	; 28/07/2022
 40674 0000A657 7305                <1> 	jnb	short loc_ccd_2	
 40675 0000A659 E91CFFFFFF          <1> 	jmp	loc_ccd_load_child_dir_next
 40676                              <1> loc_ccd_2:
 40677 0000A65E 803D[2E800100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
 40678 0000A665 741E                <1> 	je	short loc_ccd_save_current_dir
 40679                              <1> 
 40680                              <1>         ; jne -> don't save, restore (the previous cdir) later !
 40681                              <1>         ; (saving the cdir would prevent previous cdir restoration!)
 40682                              <1> 
 40683 0000A667 F8                  <1> 	clc
 40684                              <1> 
 40685                              <1> loc_ccd_retn_c:
 40686 0000A668 8B3D[20800100]      <1> 	mov	edi, [CCD_DriveDT]
 40687 0000A66E C3                  <1> 	retn
 40688                              <1> 
 40689                              <1> loc_ccd_load_sub_directory:
 40690 0000A66F 8B35[20800100]      <1> 	mov	esi, [CCD_DriveDT]
 40691 0000A675 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 40692 0000A67C 73AF                <1> 	jnb	short loc_ccd_load_FAT_sub_directory 
 40693 0000A67E E8FD1C0000          <1> 	call	load_FS_sub_directory
 40694 0000A683 EBAD                <1> 	jmp	short pass_ccd_load_FAT_sub_directory 
 40695                              <1> 
 40696                              <1> loc_ccd_save_current_dir:
 40697                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
 40698                              <1> 	; ('find_directory_entry' has been fixed to prevent large
 40699                              <1> 	; ECX value > 65535)
 40700                              <1> 	; 
 40701 0000A685 BE[A07F0100]        <1> 	mov	esi, PATH_Array ; 19/02/2016
 40702 0000A68A 8B3D[20800100]      <1> 	mov	edi, [CCD_DriveDT]
 40703 0000A690 57                  <1> 	push	edi
 40704 0000A691 83C77F              <1>         add     edi, LD_CDirLevel
 40705 0000A694 880F                <1> 	mov	[edi], cl
 40706 0000A696 47                  <1> 	inc	edi ; LD_CurrentDirectory 
 40707 0000A697 56                  <1> 	push	esi
 40708                              <1> 	;;mov	ecx, 32  ; always < 65536 (in this procedure)
 40709 0000A698 66B92000            <1> 	mov	cx, 32
 40710                              <1> 	; 02/03/2021
 40711                              <1> 	;mov	ecx, 32
 40712 0000A69C F3A5                <1> 	rep	movsd
 40713                              <1> 	; Current directory has been saved to 
 40714                              <1> 	; the DOS drive description table, cdir area !
 40715 0000A69E 5E                  <1> 	pop	esi  ; PATH_Array
 40716 0000A69F 5F                  <1> 	pop	edi  ; Dos Drv Description Table
 40717                              <1> 
 40718 0000A6A0 C3                  <1> 	retn
 40719                              <1> 
 40720                              <1> parse_dir_name:
 40721                              <1> 	; 11/02/2016
 40722                              <1> 	; 10/02/2016
 40723                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
 40724                              <1> 	; 18/09/2011
 40725                              <1> 	; 17/10/2009
 40726                              <1> 	; INPUT ->
 40727                              <1> 	;	ESI = ASCIIZ Directory String Address
 40728                              <1> 	;	AL = Current Directory Level
 40729                              <1> 	;	EDI = Destination Adress
 40730                              <1> 	;	     (8 levels, each one 12+4 byte)
 40731                              <1> 	; OUTPUT ->
 40732                              <1> 	;	EDI = Dir Entry Formatted Array
 40733                              <1> 	;	     with zero cluster pointer at the last level
 40734                              <1> 	;	AH = Last Dir Level
 40735                              <1> 	;	AL = Current Dir Level
 40736                              <1> 	;
 40737                              <1> 	; (esi, ebx, ecx will be changed) 
 40738                              <1> 
 40739                              <1> 	;mov	[PATH_Array_Ptr], edi
 40740 0000A6A1 88C4                <1> 	mov	ah, al
 40741 0000A6A3 66A3[C4800100]      <1> 	mov	[PATH_CDLevel], ax
 40742                              <1> repeat_ppdn_check_slash:
 40743 0000A6A9 AC                  <1> 	lodsb
 40744 0000A6AA 3C2F                <1> 	cmp	al, '/'
 40745 0000A6AC 74FB                <1> 	je	short repeat_ppdn_check_slash
 40746 0000A6AE 3C21                <1> 	cmp	al, 21h
 40747 0000A6B0 7219                <1> 	jb	short loc_ppdn_retn
 40748 0000A6B2 57                  <1> 	push	edi
 40749                              <1> loc_ppdn_get_dir_name:
 40750 0000A6B3 B90C000000          <1> 	mov	ecx, 12
 40751 0000A6B8 BF[C6800100]        <1> 	mov	edi, Dir_File_Name
 40752                              <1> repeat_ppdn_get_dir_name:
 40753 0000A6BD AA                  <1> 	stosb
 40754 0000A6BE AC                  <1> 	lodsb
 40755 0000A6BF 3C2F                <1> 	cmp	al, '/'
 40756 0000A6C1 740A                <1> 	je	short loc_check_level_dot_conv_dir_name
 40757 0000A6C3 3C20                <1> 	cmp	al, 20h
 40758 0000A6C5 7605                <1> 	jna	short loc_ppdn_end_of_path_scan
 40759 0000A6C7 E2F4                <1> 	loop	repeat_ppdn_get_dir_name
 40760 0000A6C9 5F                  <1> 	pop	edi
 40761 0000A6CA F9                  <1> 	stc
 40762                              <1> loc_ppdn_retn:
 40763 0000A6CB C3                  <1> 	retn
 40764                              <1> 
 40765                              <1> loc_ppdn_end_of_path_scan:
 40766 0000A6CC 4E                  <1> 	dec	esi
 40767                              <1> loc_check_level_dot_conv_dir_name:
 40768 0000A6CD 31C0                <1> 	xor	eax, eax
 40769 0000A6CF AA                  <1> 	stosb
 40770 0000A6D0 89F3                <1> 	mov	ebx, esi
 40771 0000A6D2 BE[C6800100]        <1> 	mov	esi, Dir_File_Name
 40772 0000A6D7 AC                  <1> 	lodsb
 40773                              <1> repeat_ppdn_name_check_dot:
 40774 0000A6D8 3C2E                <1> 	cmp	al, '.'
 40775 0000A6DA 7509                <1> 	jne	short loc_ppdn_convert_sub_dir_name
 40776                              <1> repeat_ppdn_name_dot_dot:
 40777 0000A6DC AC                  <1> 	lodsb
 40778 0000A6DD 3C2E                <1> 	cmp	al, '.'
 40779 0000A6DF 743E                <1> 	je	short loc_ppdn_dot_dot
 40780 0000A6E1 3C21                <1> 	cmp	al, 21h
 40781 0000A6E3 7226                <1> 	jb	short pass_ppdn_convert_sub_dir_name
 40782                              <1> loc_ppdn_convert_sub_dir_name:
 40783 0000A6E5 8A25[C5800100]      <1> 	mov	ah, [PATH_Level]
 40784 0000A6EB 80FC07              <1> 	cmp	ah, 7
 40785 0000A6EE 731B                <1> 	jnb	short pass_ppdn_convert_sub_dir_name
 40786 0000A6F0 FEC4                <1> 	inc	ah  
 40787 0000A6F2 8825[C5800100]      <1> 	mov	[PATH_Level], ah
 40788 0000A6F8 BE[C6800100]        <1> 	mov	esi, Dir_File_Name
 40789                              <1> 	;mov	edi, [PATH_Array_Ptr]
 40790 0000A6FD B010                <1> 	mov	al, 16
 40791 0000A6FF F6E4                <1> 	mul	ah
 40792 0000A701 8B3C24              <1> 	mov	edi, [esp]
 40793                              <1> 	;push	edi 
 40794 0000A704 01C7                <1> 	add	edi, eax
 40795 0000A706 E802030000          <1> 	call	convert_file_name
 40796                              <1> 	;pop	edi
 40797                              <1> pass_ppdn_convert_sub_dir_name:
 40798 0000A70B 89DE                <1> 	mov	esi, ebx
 40799                              <1> repeat_ppdn_check_last_slash:
 40800 0000A70D AC                  <1> 	lodsb
 40801 0000A70E 3C2F                <1> 	cmp	al, '/'
 40802 0000A710 74FB                <1> 	je	short repeat_ppdn_check_last_slash
 40803 0000A712 3C21                <1> 	cmp	al, 21h
 40804 0000A714 739D                <1> 	jnb	short loc_ppdn_get_dir_name
 40805                              <1> end_of_parse_dir_name:
 40806 0000A716 5F                  <1> 	pop	edi
 40807 0000A717 F5                  <1> 	cmc  
 40808                              <1> 	;mov	al, [PATH_CDLevel]
 40809                              <1> 	;mov	ah, [PATH_Level]
 40810 0000A718 66A1[C4800100]      <1> 	mov	ax, [PATH_CDLevel]
 40811 0000A71E C3                  <1> 	retn
 40812                              <1> 
 40813                              <1> loc_ppdn_dot_dot:
 40814 0000A71F AC                  <1> 	lodsb
 40815 0000A720 3C21                <1> 	cmp	al, 21h
 40816 0000A722 73F2                <1> 	jnb	short end_of_parse_dir_name 
 40817                              <1> loc_ppdn_dot_dot_prev_level:
 40818 0000A724 66A1[C4800100]      <1> 	mov	ax, [PATH_CDLevel]
 40819 0000A72A 80EC01              <1> 	sub	ah, 1
 40820 0000A72D 80D400              <1> 	adc	ah, 0
 40821 0000A730 38E0                <1> 	cmp	al, ah
 40822 0000A732 7602                <1> 	jna	short pass_ppdn_set_al_to_ah
 40823 0000A734 88E0                <1> 	mov	al, ah
 40824                              <1> pass_ppdn_set_al_to_ah:
 40825 0000A736 66A3[C4800100]      <1> 	mov	[PATH_CDLevel], ax
 40826 0000A73C EBCD                <1> 	jmp	short pass_ppdn_convert_sub_dir_name
 40827                              <1> 
 40828                              <1> locate_current_dir_file:
 40829                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 40830                              <1> 	; 20/11/2017
 40831                              <1> 	; 14/02/2016
 40832                              <1> 	; 13/02/2016
 40833                              <1> 	; 10/02/2016
 40834                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
 40835                              <1> 	; 14/08/2010
 40836                              <1> 	; 19/09/2009
 40837                              <1>         ; 2005
 40838                              <1> 	; INPUT ->
 40839                              <1> 	;	ESI = DOS DirEntry Format FileName Address
 40840                              <1> 	;	AL = Attributes Mask 
 40841                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
 40842                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
 40843                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
 40844                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
 40845                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
 40846                              <1> 	;	CL = E5h -> Return the 1st deleted entry
 40847                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
 40848                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
 40849                              <1> 	;	     proper entry (which fits with Atributes Masks)
 40850                              <1> 	;	CX = 0 Find Valid File/Directory/VolumeName
 40851                              <1> 	;	? = Any One Char
 40852                              <1> 	;	* = Every Chars
 40853                              <1> 	; OUTPUT ->
 40854                              <1> 	;	EDI = Directory Entry Address (in Directory Buffer)
 40855                              <1> 	;	ESI = DOS DirEntry Format FileName Address
 40856                              <1> 	;	CF = 0 -> No Error, Proper Entry,
 40857                              <1> 	;	DL = Attributes
 40858                              <1> 	;	DH = Previous Entry Attr (LongName Check)
 40859                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
 40860                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
 40861                              <1> 	;	AX = 0 -> Filename full fits with directory entry
 40862                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
 40863                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in EAX/AL
 40864                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
 40865                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
 40866                              <1> 	;	CL > 0 -> Entry not found, CH invalid
 40867                              <1> 	;	CF = 0 -> 
 40868                              <1> 	;	EBX = Current Directory Entry Index/Number (BX)
 40869                              <1> 
 40870                              <1> 	;mov	word [DirBuff_EntryCounter], 0 ; Zero Based
 40871                              <1> 
 40872 0000A73E 8935[28800100]      <1> 	mov	[CDLF_FNAddress], esi
 40873 0000A744 66A3[26800100]      <1> 	mov	[CDLF_AttributesMask], ax
 40874 0000A74A 66890D[2C800100]    <1> 	mov	[CDLF_DEType], cx
 40875                              <1> 
 40876 0000A751 31DB                <1> 	xor	ebx, ebx
 40877 0000A753 881D[3C800100]      <1> 	mov	[PreviousAttr], bl ; 0  ; 13/02/2016
 40878                              <1> 
 40879 0000A759 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 40880 0000A75F 381D[697F0100]      <1> 	cmp	byte [DirBuff_ValidData], bl ; 0
 40881 0000A765 761D                <1> 	jna	short loc_lcdf_reload_current_dir2
 40882 0000A767 8A1D[677F0100]      <1>         mov     bl, [DirBuff_DRV]
 40883 0000A76D 80EB41              <1> 	sub	bl, 'A'
 40884 0000A770 38DF                <1> 	cmp	bh, bl
 40885 0000A772 750E                <1> 	jne	short loc_lcdf_reload_current_dir1
 40886 0000A774 8B15[6E7F0100]      <1> 	mov	edx, [DirBuff_Cluster]
 40887 0000A77A 3B15[3C780100]      <1> 	cmp	edx, [Current_Dir_FCluster]
 40888 0000A780 7412                <1> 	je	short loc_cdir_locatefile_search
 40889                              <1> 
 40890                              <1> loc_lcdf_reload_current_dir1:
 40891 0000A782 30DB                <1> 	xor	bl, bl
 40892                              <1> loc_lcdf_reload_current_dir2:
 40893 0000A784 89DE                <1> 	mov	esi, ebx
 40894 0000A786 81C600010900        <1>         add     esi, Logical_DOSDisks
 40895 0000A78C E872000000          <1> 	call	reload_current_directory 
 40896 0000A791 735B                <1> 	jnc	short loc_locatefile_search_again 
 40897 0000A793 C3                  <1> 	retn  
 40898                              <1> 
 40899                              <1> loc_cdir_locatefile_search:
 40900 0000A794 31DB                <1> 	xor	ebx, ebx
 40901 0000A796 55                  <1> 	push	ebp ; 20/11/2017
 40902 0000A797 E8A0000000          <1> 	call	find_directory_entry
 40903 0000A79C 5D                  <1> 	pop	ebp ; 20/11/2017
 40904 0000A79D 7347                <1> 	jnc	short loc_cdir_locate_file_retn
 40905                              <1> 
 40906                              <1> loc_locatefile_check_stc_reason:
 40907 0000A79F 08ED                <1> 	or	ch, ch
 40908 0000A7A1 7442                <1> 	jz	short loc_cdir_locate_file_stc_retn
 40909                              <1> 
 40910                              <1> loc_locatefile_check_next_entryblock:
 40911                              <1> 	;mov	bh, [Current_Drv]
 40912                              <1> 	;sub	bl, bl
 40913                              <1> 	;movzx	esi, bx
 40914                              <1> 	; 28/07/2022
 40915 0000A7A3 31DB                <1>         xor	ebx, ebx
 40916 0000A7A5 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 40917 0000A7AB 89DE                <1> 	mov	esi, ebx
 40918 0000A7AD 81C600010900        <1> 	add     esi, Logical_DOSDisks
 40919                              <1> 
 40920 0000A7B3 803D[40780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
 40921 0000A7BA 760A                <1> 	jna	short loc_locatefile_check_FAT_type
 40922                              <1>             
 40923 0000A7BC 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 40924 0000A7C3 730A                <1> 	jnb	short loc_locatefile_load_subdir_cluster
 40925 0000A7C5 C3                  <1> 	retn  
 40926                              <1> 
 40927                              <1> loc_locatefile_check_FAT_type:
 40928 0000A7C6 803D[41780100]03    <1> 	cmp	byte [Current_FATType], 3
 40929 0000A7CD 7217                <1> 	jb	short loc_cdir_locate_file_retn
 40930                              <1> 
 40931                              <1> loc_locatefile_load_subdir_cluster:
 40932 0000A7CF A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 40933 0000A7D4 E8B1190000          <1> 	call	get_next_cluster
 40934 0000A7D9 730C                <1> 	jnc	short loc_locatefile_next_cluster
 40935 0000A7DB 09C0                <1> 	or	eax, eax
 40936 0000A7DD 7506                <1> 	jnz	short loc_locatefile_drive_not_ready_read_err
 40937                              <1> 	;stc
 40938                              <1> 	; 28/07/2022
 40939                              <1> ;loc_locatefile_file_notfound:
 40940                              <1> 	;mov	eax, 2 ; File/Directory/VolName not found
 40941 0000A7DF 31C0                <1> 	xor	eax, eax
 40942 0000A7E1 B002                <1> 	mov	al, 2
 40943 0000A7E3 F9                  <1> 	stc
 40944 0000A7E4 C3                  <1> 	retn
 40945                              <1> 
 40946                              <1> loc_locatefile_drive_not_ready_read_err:
 40947                              <1> 	;mov	eax, 17 ;Drive not ready or read error
 40948                              <1> loc_cdir_locate_file_stc_retn:
 40949 0000A7E5 F5                  <1> 	cmc ;stc
 40950                              <1> loc_cdir_locate_file_retn:
 40951 0000A7E6 C3                  <1> 	retn
 40952                              <1> 
 40953                              <1> loc_locatefile_next_cluster:
 40954 0000A7E7 E85A1B0000          <1> 	call	load_FAT_sub_directory
 40955                              <1> 	;jc	short loc_locatefile_drive_not_ready_read_err
 40956 0000A7EC 72F8                <1> 	jc	short loc_cdir_locate_file_retn 
 40957                              <1> 
 40958                              <1> loc_locatefile_search_again:
 40959 0000A7EE 8B35[28800100]      <1> 	mov	esi, [CDLF_FNAddress] 
 40960 0000A7F4 66A1[26800100]      <1> 	mov	ax, [CDLF_AttributesMask]
 40961 0000A7FA 668B0D[2C800100]    <1> 	mov	cx, [CDLF_DEType] 
 40962 0000A801 EB91                <1> 	jmp	short loc_cdir_locatefile_search
 40963                              <1> 
 40964                              <1> reload_current_directory:
 40965                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 40966                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
 40967                              <1> 	; 13/06/2010
 40968                              <1> 	; 22/09/2009
 40969                              <1>         ;
 40970                              <1> 	; INPUT ->
 40971                              <1> 	;	ESI = Dos drive description table address
 40972                              <1> 	
 40973                              <1> 	;mov	al, [esi+LD_FATType]
 40974 0000A803 A0[41780100]        <1> 	mov	al, [Current_FATType]
 40975 0000A808 3C02                <1> 	cmp	al, 2
 40976 0000A80A 7726                <1> 	ja	short loc_reload_FAT_sub_directory
 40977 0000A80C 8A25[40780100]      <1> 	mov	ah, [Current_Dir_Level]
 40978 0000A812 08C0                <1> 	or	al, al
 40979 0000A814 7409                <1> 	jz	short loc_reload_FS_directory
 40980 0000A816 08E4                <1> 	or	ah, ah
 40981 0000A818 7518                <1> 	jnz	short loc_reload_FAT_sub_directory
 40982                              <1> loc_reload_FAT_12_16_root_directory:
 40983                              <1> 	;call	load_FAT_root_directory
 40984                              <1> 	;retn
 40985                              <1> 	; 28/07/2022
 40986 0000A81A E9A91A0000          <1> 	jmp	load_FAT_root_directory
 40987                              <1> loc_reload_FS_directory:
 40988 0000A81F 20E4                <1> 	and	ah, ah
 40989 0000A821 7505                <1> 	jnz	short loc_reload_FS_sub_directory 
 40990                              <1> loc_reload_FS_root_directory: 
 40991                              <1> 	;call	load_FS_root_directory
 40992                              <1> 	;retn
 40993                              <1> 	; 28/07/2022
 40994 0000A823 E9581B0000          <1> 	jmp	load_FS_root_directory
 40995                              <1> loc_reload_FS_sub_directory:
 40996 0000A828 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 40997                              <1> 	;call	load_FS_sub_directory
 40998                              <1> 	;retn
 40999 0000A82D E94E1B0000          <1> 	jmp	load_FS_sub_directory 
 41000                              <1> loc_reload_FAT_sub_directory:
 41001 0000A832 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 41002                              <1> 	;call	load_FAT_sub_directory
 41003                              <1> 	;retn
 41004                              <1> 	; 28/07/2022
 41005 0000A837 E90A1B0000          <1> 	jmp	load_FAT_sub_directory
 41006                              <1> 
 41007                              <1> find_directory_entry:
 41008                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 41009                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
 41010                              <1> 	; 14/02/2016
 41011                              <1> 	; 13/02/2016
 41012                              <1> 	; 10/02/2016
 41013                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
 41014                              <1> 	; 14/08/2010 (DIR.ASM, "proc_find_direntry")
 41015                              <1> 	; 19/09/2009
 41016                              <1> 	; 2005
 41017                              <1> 	; INPUT ->
 41018                              <1> 	;	ESI = Sub Dir or File Name Address
 41019                              <1> 	;	AL = Attributes Mask 
 41020                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
 41021                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
 41022                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
 41023                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
 41024                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
 41025                              <1> 	;	CL = E5h -> Return the 1st deleted entry
 41026                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
 41027                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
 41028                              <1> 	;            proper entry (which fits with Atributes Masks)
 41029                              <1> 	;	CX = 0 -> Find Valid File/Directory/VolumeName
 41030                              <1> 	;	? = Any One Char
 41031                              <1> 	;	* = Every Chars
 41032                              <1> 	;	EBX = Current Dir Entry (BX)
 41033                              <1> 	;
 41034                              <1> 	; OUTPUT -> 
 41035                              <1> 	;	EDI = Directory Entry Address (in DirectoryBuffer)
 41036                              <1> 	;	ESI = Sub Dir or File Name Address
 41037                              <1> 	;	CF = 0 -> No Error, Proper Entry,
 41038                              <1> 	;	DL = Attributes
 41039                              <1> 	;	DH = Previous Entry Attr (LongName Check)
 41040                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
 41041                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
 41042                              <1> 	;	AX = 0 -> Filename full fits with directory entry
 41043                              <1> 	;	EBX = CurrentDirEntry (BX)
 41044                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
 41045                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in AX/AL
 41046                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
 41047                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
 41048                              <1> 	;	CL > 0 -> Entry not found, CH invalid
 41049                              <1> 	;
 41050                              <1> 	; (EAX, EBX, ECX, EDX, EDI, EBP will be changed)	 
 41051                              <1> 
 41052 0000A83C 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 41053 0000A843 7728                <1> 	ja      short loc_ffde_stc_retn_255 ; 28/07/2022
 41054                              <1> 
 41055                              <1> 	;mov    [DirBuff_CurrentEntry], bx  
 41056                              <1> 
 41057 0000A845 BF00000800          <1>   	mov	edi, Directory_Buffer
 41058 0000A84A 66A3[38800100]      <1> 	mov	[FDE_AttrMask], ax
 41059                              <1> 
 41060 0000A850 29C0                <1> 	sub	eax, eax
 41061                              <1>             
 41062                              <1> 	;;mov	[PreviousAttr], al ; 0 ;; 13/02/2016
 41063 0000A852 66A3[3A800100]      <1> 	mov	[AmbiguousFileName], ax ; 0
 41064                              <1> 
 41065 0000A858 6689D8              <1> 	mov	ax, bx
 41066                              <1> 	;shl	ax, 5 ; ; * 32 ; Directory entry size
 41067                              <1> 	; 28/07/2022
 41068 0000A85B C1E005              <1> 	shl	eax, 5
 41069 0000A85E 01C7                <1> 	add     edi, eax
 41070                              <1> 
 41071 0000A860 08ED                <1> 	or	ch, ch
 41072                              <1> 	;jnz	loc_find_free_deleted_entry_0
 41073                              <1> 	; 28/07/2022
 41074 0000A862 7405                <1> 	jz	short loc_fde_any_valid_entry_opt
 41075 0000A864 E911010000          <1> 	jmp	loc_find_free_deleted_entry_0
 41076                              <1> 
 41077                              <1> loc_fde_any_valid_entry_opt:
 41078 0000A869 08C9                <1> 	or      cl, cl
 41079                              <1>         ;jnz	loc_ffde_stc_retn_255
 41080                              <1> 	; 28/07/2022
 41081 0000A86B 742E                <1> 	jz	short check_find_dir_entry
 41082                              <1> 
 41083                              <1> 	; 28/07/2022
 41084                              <1> loc_ffde_stc_retn_255:
 41085                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
 41086                              <1> 	; (ECX must not be > 65535)
 41087                              <1> 	; ((because 'loc_ccd_save_current_dir'
 41088                              <1> 	;  sets CX to 32 for 'rep movsd')) 
 41089 0000A86D 66B9FFFF            <1> 	mov	cx, 0FFFFh
 41090                              <1> 	;xor	ecx, ecx
 41091                              <1> 	;dec	ecx ; 0FFFFFFFFh
 41092                              <1> 	;xor	eax, eax
 41093                              <1> loc_find_direntry_stc_retn:
 41094                              <1> loc_check_ffde_retn_1:
 41095                              <1> 	;mov	ax, 2
 41096                              <1> 	;mov	eax, 2 ; File Not Found
 41097                              <1> 	; 28/07/2022
 41098 0000A871 29C0                <1> 	sub	eax, eax
 41099 0000A873 B002                <1> 	mov	al, 2
 41100 0000A875 8A35[3C800100]      <1> 	mov	dh, [PreviousAttr]
 41101 0000A87B 66891D[6A7F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
 41102 0000A882 F9                  <1> 	stc
 41103 0000A883 C3                  <1> 	retn
 41104                              <1> 
 41105                              <1> 	; 28/07/2022
 41106                              <1> loc_find_dir_next_entry_prevdeleted:
 41107 0000A884 80CA80              <1> 	or	dl, 80h  ; Bit 7 -> deleted entry sign
 41108                              <1> 	;jmp	short loc_find_dir_next_entry
 41109                              <1> 
 41110                              <1> 	; 28/07/2022
 41111                              <1> loc_find_dir_next_entry:
 41112 0000A887 8815[3C800100]      <1> 	mov	byte [PreviousAttr], dl ; LongName check
 41113                              <1> loc_find_dir_next_entry_1:
 41114 0000A88D 5E                  <1> 	pop	esi
 41115 0000A88E 83C720              <1> 	add	edi, 32
 41116                              <1> 	;;inc	word [DirBuff_EntryCounter]
 41117                              <1> 	;inc	bx
 41118                              <1> 	; 28/07/2022
 41119 0000A891 43                  <1> 	inc	ebx
 41120 0000A892 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 41121 0000A899 77D2                <1> 	ja	short loc_ffde_stc_retn_255
 41122                              <1>         ; 28/07/2022
 41123                              <1> 	;jmp	short check_find_dir_entry 
 41124                              <1>  
 41125                              <1> check_find_dir_entry:
 41126 0000A89B 66A1[38800100]      <1> 	mov	ax, [FDE_AttrMask]
 41127 0000A8A1 8A2F                <1> 	mov	ch, [edi]
 41128 0000A8A3 80FD00              <1> 	cmp     ch, 0 ; Is it never used entry?
 41129                              <1> 	;jna	loc_find_direntry_stc_retn
 41130                              <1> 	; 28/07/2022
 41131 0000A8A6 7702                <1> 	ja	short loc_fde_check_attrib
 41132                              <1> 	; end of directory entries
 41133 0000A8A8 EBC7                <1> 	jmp	loc_find_direntry_stc_retn
 41134                              <1> loc_fde_check_attrib: 
 41135 0000A8AA 56                  <1> 	push	esi
 41136 0000A8AB 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
 41137 0000A8AE 80FDE5              <1> 	cmp	ch, 0E5h ; Is it a deleted file?
 41138 0000A8B1 74D1                <1> 	je	short loc_find_dir_next_entry_prevdeleted
 41139                              <1> 
 41140 0000A8B3 80FA0F              <1> 	cmp     dl, 0Fh ; longname sub component check
 41141 0000A8B6 7505                <1> 	jne     short loc_check_attributes_mask
 41142 0000A8B8 E8A6010000          <1> 	call	save_longname_sub_component
 41143                              <1> 
 41144                              <1> loc_check_attributes_mask:
 41145 0000A8BD 88C6                <1> 	mov	dh, al
 41146 0000A8BF 20D6                <1> 	and	dh, dl 
 41147                              <1> 	; 28/07/2022   
 41148 0000A8C1 38F0                <1> 	cmp	al, dh
 41149 0000A8C3 75C2                <1> 	jne	short loc_find_dir_next_entry
 41150 0000A8C5 20D4                <1> 	and	ah, dl
 41151 0000A8C7 75BE                <1>         jnz	short loc_find_dir_next_entry
 41152 0000A8C9 80FA0F              <1> 	cmp	dl, 0Fh
 41153 0000A8CC 7515                <1> 	jne	short pass_direntry_attr_check
 41154                              <1> 
 41155 0000A8CE 3C0F                <1> 	cmp	al, 0Fh ; AL = 0Fh -> find long name
 41156 0000A8D0 75B5                <1> 	jne	short loc_find_dir_next_entry
 41157                              <1> 
 41158 0000A8D2 5E                  <1> 	pop	esi
 41159                              <1> 	;xor	ax, ax
 41160                              <1> 	; 28/07/2022
 41161                              <1> 	;sub	eax, eax
 41162 0000A8D3 30C0                <1> 	xor	al, al
 41163 0000A8D5 8A35[3C800100]      <1> 	mov	dh, [PreviousAttr]
 41164 0000A8DB 66891D[6A7F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
 41165 0000A8E2 C3                  <1> 	retn
 41166                              <1> 
 41167                              <1> pass_direntry_attr_check:
 41168 0000A8E3 89FD                <1> 	mov	ebp, edi ; 14/02/2016
 41169                              <1> 	;mov	ecx, 8
 41170                              <1> 	; 28/07/2022
 41171 0000A8E5 29C9                <1> 	sub	ecx, ecx
 41172 0000A8E7 B108                <1> 	mov	cl, 8
 41173                              <1> loc_lodsb_find_dir:
 41174 0000A8E9 AC                  <1> 	lodsb
 41175 0000A8EA 3C2A                <1> 	cmp	al, '*'
 41176 0000A8EC 7508                <1> 	jne	short pass_fde_ambiguous1_check
 41177 0000A8EE FE05[3B800100]      <1>         inc     byte [AmbiguousFileName+1]
 41178 0000A8F4 EB23                <1> 	jmp	short loc_check_direntry_extension
 41179                              <1> 
 41180                              <1> pass_fde_ambiguous1_check:
 41181 0000A8F6 3C3F                <1> 	cmp	al, '?'
 41182 0000A8F8 750D                <1> 	jne	short pass_fde_ambiguous2_check
 41183 0000A8FA FE05[3A800100]      <1> 	inc	byte [AmbiguousFileName]
 41184 0000A900 803F20              <1> 	cmp	byte [edi], 20h
 41185 0000A903 763E                <1> 	jna	short loc_find_dir_next_entry_ebp
 41186 0000A905 EB0F                <1> 	jmp	short loc_scasb_find_dir_inc_di
 41187                              <1> 
 41188                              <1> pass_fde_ambiguous2_check:
 41189 0000A907 3C20                <1> 	cmp	al, 20h
 41190 0000A909 7507                <1> 	jne	short loc_scasb_find_dir
 41191 0000A90B 803F20              <1> 	cmp	byte [edi], 20h
 41192 0000A90E 7533                <1> 	jne	short loc_find_dir_next_entry_ebp
 41193 0000A910 EB07                <1> 	jmp	short loc_check_direntry_extension
 41194                              <1> 
 41195                              <1> loc_scasb_find_dir:
 41196 0000A912 3A07                <1> 	cmp	al, [edi]
 41197 0000A914 752D                <1> 	jne	short loc_find_dir_next_entry_ebp
 41198                              <1> loc_scasb_find_dir_inc_di:
 41199 0000A916 47                  <1> 	inc	edi
 41200 0000A917 E2D0                <1> 	loop	loc_lodsb_find_dir
 41201                              <1> 
 41202                              <1> loc_check_direntry_extension:
 41203 0000A919 BE08000000          <1> 	mov	esi, 8
 41204 0000A91E 89F7                <1> 	mov	edi, esi ; 8
 41205 0000A920 033424              <1> 	add	esi, [esp] ; Sub Dir or File Name Address
 41206 0000A923 01EF                <1> 	add	edi, ebp
 41207 0000A925 B103                <1> 	mov	cl, 3
 41208                              <1> loc_lodsb_find_dir_ext:
 41209 0000A927 AC                  <1> 	lodsb
 41210 0000A928 3C2A                <1> 	cmp	al, '*'
 41211 0000A92A 7508                <1> 	jne	short pass_fde_ambiguous3_check
 41212 0000A92C FE05[3B800100]      <1> 	inc	byte [AmbiguousFileName+1]
 41213 0000A932 EB1F                <1> 	jmp	short loc_find_dir_proper_direntry
 41214                              <1> 
 41215                              <1> pass_fde_ambiguous3_check:
 41216 0000A934 3C3F                <1> 	cmp	al, '?'
 41217 0000A936 7512                <1> 	jne	short pass_fde_ambiguous4_check
 41218 0000A938 FE05[3A800100]      <1> 	inc	byte [AmbiguousFileName]
 41219 0000A93E 803F20              <1> 	cmp	byte [edi], 20h
 41220                              <1> 	;jna	short loc_find_dir_next_entry_ebp
 41221                              <1> 	;jmp	short loc_scasb_find_dir_ext_inc_di
 41222                              <1> 	; 28/07/2022
 41223 0000A941 7732                <1> 	ja	short loc_scasb_find_dir_ext_inc_di 
 41224                              <1> 
 41225                              <1> loc_find_dir_next_entry_ebp:
 41226 0000A943 89EF                <1> 	mov	edi, ebp ; 14/02/2016
 41227 0000A945 E93DFFFFFF          <1> 	jmp	loc_find_dir_next_entry ; 28/07/2022
 41228                              <1> 
 41229                              <1> pass_fde_ambiguous4_check:
 41230 0000A94A 3C20                <1> 	cmp	al, 20h
 41231 0000A94C 7523                <1> 	jne	short loc_scasb_find_dir_ext
 41232 0000A94E 803F20              <1> 	cmp	byte [edi], 20h
 41233                              <1> 	; 28/07/2022
 41234 0000A951 75F0                <1> 	jne	short loc_find_dir_next_entry_ebp
 41235                              <1> 	;jmp	short loc_find_dir_proper_direntry
 41236                              <1> 
 41237                              <1> loc_find_dir_proper_direntry:
 41238 0000A953 30C9                <1> 	xor	cl, cl
 41239                              <1> loc_find_dir_proper_direntry_1:
 41240 0000A955 5E                  <1> 	pop	esi
 41241 0000A956 89EF                <1>         mov     edi, ebp
 41242 0000A958 8A2F                <1> 	mov	ch, [edi]
 41243 0000A95A 8A570B              <1> 	mov     dl, [edi+0Bh] ; Dir entry attributes
 41244 0000A95D 66A1[3A800100]      <1> 	mov	ax, [AmbiguousFileName]
 41245                              <1> loc_find_dir_proper_direntry_2:
 41246 0000A963 8A35[3C800100]      <1> 	mov     dh, [PreviousAttr]
 41247 0000A969 66891D[6A7F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
 41248 0000A970 C3                  <1> 	retn
 41249                              <1> 
 41250                              <1> loc_scasb_find_dir_ext:
 41251 0000A971 3A07                <1> 	cmp	al, [edi]
 41252 0000A973 75CE                <1> 	jne	short loc_find_dir_next_entry_ebp
 41253                              <1> loc_scasb_find_dir_ext_inc_di:
 41254 0000A975 47                  <1> 	inc	edi
 41255 0000A976 E2AF                <1> 	loop    loc_lodsb_find_dir_ext
 41256 0000A978 EBDB                <1> 	jmp	short loc_find_dir_proper_direntry_1
 41257                              <1> 
 41258                              <1> loc_find_free_deleted_entry_0:
 41259 0000A97A 66A1[38800100]      <1> 	mov	ax, [FDE_AttrMask]
 41260 0000A980 8A2F                <1> 	mov	ch, [edi]
 41261 0000A982 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
 41262 0000A985 08C9                <1> 	or	cl, cl 
 41263 0000A987 7407                <1> 	jz	short loc_check_ffde_0_repeat
 41264                              <1> 	;cmp	cl, 0E5h
 41265                              <1> 	;je	short pass_loc_check_ffde_0_err
 41266 0000A989 80F9FF              <1> 	cmp	cl, 0FFh
 41267 0000A98C 7430                <1> 	je	short loc_find_free_deleted_entry_1
 41268 0000A98E EB4A                <1> 	jmp	short pass_loc_check_ffde_0_err
 41269                              <1> 
 41270                              <1> loc_check_ffde_0_repeat:
 41271 0000A990 08ED                <1> 	or	ch, ch
 41272 0000A992 7510                <1> 	jnz	short loc_check_ffde_0_next
 41273                              <1> 
 41274                              <1> loc_check_ffde_retn_2:
 41275                              <1> 	;sub	ax, ax
 41276                              <1> 	; 28/07/2022
 41277 0000A994 29C0                <1> 	sub	eax, eax
 41278 0000A996 8A35[3C800100]      <1> 	mov	dh, [PreviousAttr]
 41279 0000A99C 66891D[6A7F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
 41280 0000A9A3 C3                  <1> 	retn
 41281                              <1>  
 41282                              <1> loc_check_ffde_0_next:
 41283                              <1> 	;inc	bx
 41284                              <1> 	; 28/07/2022
 41285 0000A9A4 43                  <1> 	inc	ebx
 41286 0000A9A5 83C720              <1> 	add	edi, 32
 41287                              <1> 	;inc	word [DirBuff_EntryCounter]
 41288                              <1> 	 
 41289 0000A9A8 663B1D[6C7F0100]    <1>         cmp	bx, [DirBuff_LastEntry]
 41290                              <1> 	;ja	short loc_ffde_stc_retn_255
 41291                              <1> 	; 07/08/2022
 41292 0000A9AF 773A                <1> 	ja	short jmp_ffde_stc_retn_255
 41293                              <1> 
 41294 0000A9B1 8815[3C800100]      <1> 	mov	[PreviousAttr], dl
 41295 0000A9B7 8A2F                <1> 	mov	ch, [edi]
 41296 0000A9B9 8A570B              <1> 	mov	dl, [edi+0Bh] ; file attributes
 41297 0000A9BC EBD2                <1> 	jmp	short loc_check_ffde_0_repeat
 41298                              <1> 
 41299                              <1> loc_find_free_deleted_entry_1:
 41300 0000A9BE 28D2                <1> 	sub	dl, dl      
 41301                              <1> loc_find_free_deleted_entry_2:
 41302 0000A9C0 20ED                <1> 	and	ch, ch  
 41303 0000A9C2 74D0                <1> 	jz	short loc_check_ffde_retn_2
 41304 0000A9C4 80FDE5              <1> 	cmp	ch, 0E5h
 41305 0000A9C7 74CB                <1> 	je	short loc_check_ffde_retn_2
 41306                              <1> 	;inc	bx
 41307                              <1> 	; 28/07/2022
 41308 0000A9C9 43                  <1> 	inc	ebx
 41309 0000A9CA 83C720              <1> 	add	edi, 32
 41310 0000A9CD 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 41311                              <1> 	;ja	short loc_ffde_stc_retn_255
 41312                              <1> 	; 07/08/2022
 41313 0000A9D4 7715                <1> 	ja	short jmp_ffde_stc_retn_255
 41314                              <1> 
 41315 0000A9D6 8A2F                <1> 	mov	ch, [edi]
 41316 0000A9D8 EBE6                <1> 	jmp	short loc_find_free_deleted_entry_2
 41317                              <1> 
 41318                              <1> pass_loc_check_ffde_0_err:
 41319 0000A9DA 38CD                <1> 	cmp	ch, cl
 41320 0000A9DC 741F                <1> 	je	short loc_check_ffde_attrib 
 41321                              <1> 
 41322                              <1> 	;inc	bx
 41323                              <1> 	; 28/07/2022
 41324 0000A9DE 43                  <1> 	inc	ebx
 41325 0000A9DF 83C720              <1> 	add	edi, 32
 41326 0000A9E2 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 41327                              <1>         ;ja	loc_ffde_stc_retn_255
 41328                              <1> 	; 28/07/2022
 41329 0000A9E9 7605                <1> 	jna	short loc_ffe_save_prev_attr
 41330                              <1> jmp_ffde_stc_retn_255:	; 07/08/2022
 41331 0000A9EB E97DFEFFFF          <1> 	jmp	loc_ffde_stc_retn_255
 41332                              <1> 
 41333                              <1> loc_ffe_save_prev_attr: ; 28/07/2022
 41334 0000A9F0 8815[3C800100]      <1> 	mov	[PreviousAttr], dl
 41335 0000A9F6 8A2F                <1> 	mov	ch, [edi]
 41336 0000A9F8 8A570B              <1> 	mov	dl, [edi+0Bh]
 41337 0000A9FB EBDD                <1> 	jmp	short pass_loc_check_ffde_0_err
 41338                              <1> 
 41339                              <1> loc_check_ffde_attrib:
 41340 0000A9FD 88C6                <1> 	mov	dh, al
 41341 0000A9FF 20D6                <1> 	and	dh, dl    
 41342 0000AA01 38F0                <1> 	cmp	al, dh
 41343 0000AA03 759F                <1> 	jne	short loc_check_ffde_0_next
 41344 0000AA05 20D4                <1> 	and	ah, dl
 41345 0000AA07 759B                <1> 	jnz	short loc_check_ffde_0_next
 41346 0000AA09 30C9                <1> 	xor	cl, cl 
 41347 0000AA0B EB87                <1>         jmp	short loc_check_ffde_retn_2
 41348                              <1> 
 41349                              <1> convert_file_name:
 41350                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 41351                              <1> 	; 06/03/2016
 41352                              <1> 	; 11/02/2016
 41353                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
 41354                              <1> 	; 06/10/2009
 41355                              <1> 	; 2005
 41356                              <1> 	;
 41357                              <1> 	; INPUT  ->
 41358                              <1> 	;	ESI = Dot File Name Location
 41359                              <1> 	;	EDI = Dir Entry Format File Name Location
 41360                              <1> 	; OUTPUT ->
 41361                              <1> 	;	EDI = Dir Entry Format File Name Location
 41362                              <1> 	;	ESI = Dot File Name Location (capitalized)
 41363                              <1> 	;
 41364                              <1> 	; (ECX, AL will be changed) 
 41365                              <1>      
 41366 0000AA0D 56                  <1> 	push	esi  
 41367 0000AA0E 57                  <1> 	push	edi
 41368                              <1> 
 41369                              <1> 	;mov	ecx, 11
 41370                              <1> 	; 29/07 2022
 41371 0000AA0F 29C9                <1> 	sub	ecx, ecx
 41372 0000AA11 B10B                <1> 	mov	cl, 11
 41373 0000AA13 B020                <1> 	mov	al, 20h
 41374 0000AA15 F3AA                <1> 	rep	stosb
 41375                              <1> 
 41376 0000AA17 8B3C24              <1> 	mov	edi, [esp]
 41377                              <1> 
 41378 0000AA1A B10C                <1> 	mov	cl, 12 ; file name length (max.)
 41379                              <1> 	; 06/03/2016
 41380                              <1> 	; Directory entry name limit (11 bytes) check for
 41381                              <1> 	; 'rename_directory_entry' procedure.
 41382                              <1> 	; (EDI points to Directory Entry)
 41383                              <1> 	; (If the file name would not contain a dot
 41384                              <1> 	; and file name length would be 12, this would cause to
 41385                              <1> 	; overwrite the attributes byte of the directory entry.)
 41386                              <1> 	;
 41387 0000AA1C B50B                <1> 	mov	ch, 11 ; directory entry's name length
 41388                              <1> loc_check_first_dot:
 41389 0000AA1E 8A06                <1> 	mov	al, [esi]
 41390 0000AA20 3C2E                <1> 	cmp	al, 2Eh
 41391 0000AA22 750C                <1> 	jne	short pass_check_first_dot
 41392 0000AA24 8807                <1> 	mov	[edi], al
 41393 0000AA26 47                  <1> 	inc	edi
 41394 0000AA27 46                  <1> 	inc	esi
 41395 0000AA28 FEC9                <1> 	dec	cl
 41396 0000AA2A 75F2                <1> 	jnz	short loc_check_first_dot
 41397                              <1> 	;;(ecx <= 12)
 41398                              <1> 	;;loop	loc_check_first_dot 
 41399 0000AA2C EB30                <1> 	jmp	short stop_convert_file
 41400                              <1> 
 41401                              <1> loc_get_fchar:
 41402 0000AA2E 8A06                <1> 	mov	al, [esi]
 41403                              <1> pass_check_first_dot:
 41404 0000AA30 3C61                <1> 	cmp	al, 61h ; 'a'
 41405 0000AA32 7208                <1> 	jb	short pass_name_capitalize
 41406 0000AA34 3C7A                <1> 	cmp	al, 7Ah ; 'z'
 41407 0000AA36 7704                <1> 	ja	short pass_name_capitalize
 41408 0000AA38 24DF                <1> 	and	al, 0DFh
 41409 0000AA3A 8806                <1> 	mov	[esi], al
 41410                              <1> pass_name_capitalize:
 41411 0000AA3C 3C21                <1> 	cmp	al, 21h
 41412 0000AA3E 721E                <1> 	jb	short stop_convert_file
 41413 0000AA40 3C2E                <1> 	cmp	al, 2Eh ; '.'
 41414 0000AA42 750C                <1> 	jne	short pass_dot_space
 41415                              <1> add_dot_space: 
 41416 0000AA44 80F904              <1> 	cmp	cl, 4
 41417 0000AA47 760E                <1> 	jna	short inc_and_loop
 41418 0000AA49 47                  <1> 	inc	edi
 41419 0000AA4A FECD                <1> 	dec	ch ; 06/03/2016
 41420 0000AA4C FEC9                <1> 	dec	cl
 41421 0000AA4E EBF4                <1> 	jmp	short add_dot_space
 41422                              <1> 	
 41423                              <1> 	;mov	al, 4
 41424                              <1> 	;cmp	cl, al
 41425                              <1> 	;jna	short inc_and_loop
 41426                              <1> 	;sub	cl, al
 41427                              <1> 	;add	edi, ecx
 41428                              <1> 	;mov	cl, al
 41429                              <1> 	;jmp	short inc_and_loop	
 41430                              <1> 
 41431                              <1> pass_dot_space:
 41432 0000AA50 8807                <1> 	mov	[edi], al
 41433                              <1> loc_after_double_dot:
 41434                              <1> 	; 06/03/2016
 41435 0000AA52 FECD                <1> 	dec	ch ; count down for 11 bytes dir entry limit
 41436 0000AA54 740A                <1> 	jz	short stop_convert_file_x
 41437 0000AA56 47                  <1> 	inc	edi
 41438                              <1> inc_and_loop:
 41439 0000AA57 FEC9                <1> 	dec	cl ; count down for 12 bytes filename limit 
 41440 0000AA59 7403                <1> 	jz	short stop_convert_file	
 41441 0000AA5B 46                  <1> 	inc	esi
 41442                              <1> 	;;(ecx <= 12)
 41443                              <1> 	;;loop	loc_get_fchar
 41444 0000AA5C EBD0                <1> 	jmp	short loc_get_fchar
 41445                              <1> 
 41446                              <1> stop_convert_file:
 41447                              <1> 	; 06/03/2016
 41448 0000AA5E 30ED                <1> 	xor	ch, ch
 41449                              <1> 	; ECX < 256 ; 'find_first_file' -> xor cl, cl
 41450                              <1> stop_convert_file_x:
 41451 0000AA60 5F                  <1> 	pop	edi
 41452 0000AA61 5E                  <1> 	pop	esi
 41453 0000AA62 C3                  <1> 	retn
 41454                              <1>  
 41455                              <1> save_longname_sub_component:
 41456                              <1> 	; 13/02/2016
 41457                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
 41458                              <1> 	; 28/02/2010
 41459                              <1> 	; 17/10/2009
 41460                              <1> 	; INPUT ->
 41461                              <1> 	;	EDI = Directory Entry    
 41462                              <1> 	;     	// This procedure is called
 41463                              <1> 	;	// from 'find_directory_entry' procedure.
 41464                              <1> 	;	// If the last entry returns with
 41465                              <1> 	;	// a non-zero LongnameFound value and
 41466                              <1> 	;	// if LFN_CheckSum value is equal to
 41467                              <1> 	;	// the next shortname checksum,
 41468                              <1> 	;	// long name is valid.
 41469                              <1> 	;	// If a longname is longer than 65 bytes,
 41470                              <1> 	;	// it is invalid for trdos. (>45h)
 41471                              <1>  
 41472 0000AA63 57                  <1> 	push	edi
 41473 0000AA64 56                  <1> 	push	esi
 41474                              <1> 	;push	ebx
 41475                              <1> 	;push	ecx
 41476                              <1> 	;push	edx
 41477 0000AA65 50                  <1> 	push	eax
 41478                              <1>            
 41479 0000AA66 29C9                <1> 	sub	ecx, ecx
 41480                              <1> 	;sub	eax, eax
 41481 0000AA68 B11A                <1> 	mov	cl, 26
 41482                              <1> 
 41483 0000AA6A 0FB607              <1> 	movzx	eax, byte [edi] ; LDIR_Order
 41484 0000AA6D 3C41                <1> 	cmp	al, 41h  ; 40h (last long entry sign) + 1
 41485 0000AA6F 722B                <1> 	jb	short pass_pslnsc_last_long_entry
 41486                              <1> 
 41487 0000AA71 88C4                <1> 	mov	ah, al
 41488 0000AA73 80EC40              <1> 	sub	ah, 40h
 41489 0000AA76 8825[3E800100]      <1> 	mov	[LFN_EntryLength], ah
 41490                              <1> 	
 41491 0000AA7C 3C45                <1> 	cmp	al, 45h  ; 40h (last long entry sign) + 5
 41492                              <1>  		; Max 130 byte length is usable in TRDOS
 41493                              <1> ; 26*5 = 130
 41494 0000AA7E 7753                <1> 	ja	short loc_pslnsc_retn
 41495                              <1> 
 41496 0000AA80 2407                <1> 	and	al, 07h ; 0Fh
 41497 0000AA82 A2[3D800100]        <1> 	mov	[LongNameFound], al
 41498                              <1> 
 41499 0000AA87 FEC8                <1> 	dec	al
 41500                              <1> 	;mov	cl, 26
 41501 0000AA89 F6E1                <1> 	mul	cl
 41502                              <1> 
 41503 0000AA8B 89C6                <1> 	mov	esi, eax
 41504 0000AA8D 01CE                <1> 	add	esi, ecx
 41505                              <1> 		; to make is an ASCIIZ string
 41506                              <1> 		; with ax+26 bytes length
 41507 0000AA8F 81C6[40800100]      <1> 	add	esi, LongFileName
 41508 0000AA95 66C7060000          <1> 	mov	word [esi], 0   
 41509 0000AA9A EB16                <1> 	jmp	short loc_pslsc_move_ldir_name2 
 41510                              <1> 
 41511                              <1> pass_pslnsc_last_long_entry:
 41512 0000AA9C 3C04                <1> 	cmp	al, 04h
 41513 0000AA9E 7733                <1> 	ja	short loc_pslnsc_retn
 41514 0000AAA0 FE0D[3D800100]      <1> 	dec	byte [LongNameFound]
 41515 0000AAA6 3A05[3D800100]      <1> 	cmp	al, [LongNameFound]
 41516 0000AAAC 7525                <1> 	jne	short loc_pslnsc_retn
 41517                              <1> 
 41518                              <1> loc_pslsc_move_ldir_name1:
 41519 0000AAAE FEC8                <1> 	dec	al
 41520                              <1> 	;mov	cl, 26
 41521 0000AAB0 F6E1                <1> 	mul	cl
 41522                              <1> 
 41523                              <1> loc_pslsc_move_ldir_name2:
 41524 0000AAB2 8A4F0D              <1> 	mov	cl, [edi+0Dh] ; long name checksum
 41525 0000AAB5 880D[3F800100]      <1> 	mov	[LFN_CheckSum], cl 
 41526 0000AABB 89FE                <1> 	mov	esi, edi ; LDIR_Order
 41527 0000AABD BF[40800100]        <1> 	mov	edi, LongFileName
 41528 0000AAC2 01C7                <1> 	add	edi, eax
 41529 0000AAC4 46                  <1> 	inc	esi
 41530 0000AAC5 B105                <1> 	mov	cl, 5 ; chars 1 to 5
 41531 0000AAC7 F366A5              <1> 	rep	movsw
 41532 0000AACA 83C603              <1> 	add	esi, 3
 41533 0000AACD A5                  <1> 	movsd	; char 6 & 7 
 41534 0000AACE A5                  <1> 	movsd	; char 8 & 9
 41535 0000AACF A5                  <1> 	movsd	; char 10 & 11
 41536 0000AAD0 46                  <1> 	inc	esi
 41537 0000AAD1 46                  <1> 	inc	esi 
 41538 0000AAD2 A5                  <1> 	movsd   ; char 12 & 13 
 41539                              <1> 
 41540                              <1> loc_pslnsc_retn:
 41541 0000AAD3 58                  <1>  	pop	eax
 41542                              <1> 	;pop	edx
 41543                              <1> 	;pop	ecx
 41544                              <1> 	;pop	ebx
 41545 0000AAD4 5E                  <1> 	pop	esi  
 41546 0000AAD5 5F                  <1> 	pop	edi
 41547                              <1>  
 41548 0000AAD6 C3                  <1>     	retn
 41549                              <1> 
 41550                              <1> parse_path_name:
 41551                              <1> 	; 09/08/2022
 41552                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 41553                              <1> 	; 10/02/2016
 41554                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
 41555                              <1> 	; 10/009/2011 ('proc_parse_pathname')
 41556                              <1> 	; 27/11/2009
 41557                              <1> 	; 05/12/2004
 41558                              <1> 	;
 41559                              <1> 	; INPUT ->
 41560                              <1> 	;	ESI = Beginning of ASCIIZ pathname string
 41561                              <1> 	;       EDI = Destination Address
 41562                              <1> 	;	      (which is TR-DOS FindFile data buffer)
 41563                              <1> 	; OUTPUT ->
 41564                              <1> 	;	CF = 1 -> Error
 41565                              <1> 	;	     EAX = Error Code (AL)
 41566                              <1> 	;
 41567                              <1> 	; (Modified registers: eax, ecx, esi, edi) 
 41568                              <1> 	
 41569                              <1> 	; Clear the pathname bytes in TR-DOS Findfile data buffer 
 41570 0000AAD7 57                  <1> 	push	edi
 41571                              <1> 	;mov	ecx, 20  ; 80 bytes
 41572                              <1> 	; 29/07/2022
 41573 0000AAD8 29C9                <1> 	sub	ecx, ecx
 41574 0000AADA B114                <1> 	mov	cl, 20
 41575 0000AADC 31C0                <1> 	xor	eax, eax
 41576 0000AADE F3AB                <1> 	rep	stosd 
 41577 0000AAE0 5F                  <1> 	pop	edi
 41578                              <1> 
 41579 0000AAE1 668B06              <1> 	mov	ax, [esi]
 41580 0000AAE4 80FC3A              <1> 	cmp	ah, ':'
 41581 0000AAE7 741C                <1> 	je	short loc_ppn_change_drive
 41582 0000AAE9 A0[42780100]        <1> 	mov	al, [Current_Drv]
 41583 0000AAEE EB33                <1> 	jmp	short pass_ppn_change_drive
 41584                              <1> 
 41585                              <1> pass_ppn_cdir:
 41586 0000AAF0 8B35[62810100]      <1> 	mov	esi, [First_Path_Pos]
 41587 0000AAF6 AC                  <1> 	lodsb
 41588                              <1> loc_ppn_get_filename:
 41589 0000AAF7 83C741              <1> 	add	edi, 65 ; FindFile_Name location
 41590                              <1> 	; TRDOS Filename length must not be more than 12 bytes
 41591                              <1> 	;mov	ecx, 12
 41592 0000AAFA B10C                <1> 	mov	cl, 12
 41593                              <1> loc_ppn_get_fnchar_next:
 41594 0000AAFC AA                  <1> 	stosb
 41595 0000AAFD AC                  <1> 	lodsb
 41596 0000AAFE 3C21                <1> 	cmp	al, 21h
 41597 0000AB00 726F                <1> 	jb	short loc_ppn_clc_return 
 41598 0000AB02 E2F8                <1>         loop    loc_ppn_get_fnchar_next
 41599                              <1> loc_ppn_return:
 41600 0000AB04 C3                  <1> 	retn
 41601                              <1> 
 41602                              <1> loc_ppn_change_drive:
 41603                              <1> 	; 29/07/2022
 41604                              <1> 	; ecx = 0
 41605 0000AB05 24DF                <1> 	and	al, 0DFh
 41606 0000AB07 2C41                <1> 	sub	al, 'A'; A:
 41607 0000AB09 726A                <1> 	jc	short loc_ppn_invalid_drive
 41608 0000AB0B 3805[67300100]      <1> 	cmp	[Last_DOS_DiskNo], al
 41609 0000AB11 7262                <1> 	jb	short loc_ppn_invalid_drive
 41610                              <1> 
 41611 0000AB13 46                  <1> 	inc	esi
 41612 0000AB14 46                  <1> 	inc	esi
 41613 0000AB15 8A26                <1> 	mov	ah, [esi]
 41614 0000AB17 80FC21              <1> 	cmp	ah, 21h
 41615 0000AB1A 7307                <1> 	jnb	short pass_ppn_change_drive
 41616                              <1> 
 41617                              <1> loc_ppn_cmd_failed:
 41618                              <1> 	; File or directory name is not existing
 41619 0000AB1C 8807                <1> 	mov	[edi], al ; Drv 
 41620 0000AB1E 66B80100            <1> 	mov	ax, 1 ; eax = 1
 41621                              <1> 	; TR-DOS Error Code 01h = Bad Command Argument
 41622                              <1> 	; MS-DOS Error Code 01h : Invalid Function Number
 41623                              <1> 	;stc
 41624                              <1> 	; (MainProg ErrMsg: "Bad command or file name!")
 41625 0000AB22 C3                  <1> 	retn
 41626                              <1> 
 41627                              <1> pass_ppn_change_drive:
 41628 0000AB23 8935[62810100]      <1> 	mov	[First_Path_Pos], esi
 41629                              <1> 	;mov	dword [Last_Slash_Pos], 0
 41630                              <1> 	; 29/07/2022
 41631 0000AB29 890D[66810100]      <1> 	mov	[Last_Slash_Pos], ecx ; 0
 41632 0000AB2F AA                  <1> 	stosb
 41633 0000AB30 8A06                <1> 	mov	al, [esi]
 41634                              <1> loc_scan_ppn_dslash:
 41635 0000AB32 3C2F                <1> 	cmp	al, '/'
 41636 0000AB34 7506                <1>   	jne	short loc_scan_next_slash_pos
 41637 0000AB36 8935[66810100]      <1> 	mov	[Last_Slash_Pos], esi
 41638                              <1> loc_scan_next_slash_pos:
 41639 0000AB3C 46                  <1> 	inc	esi
 41640 0000AB3D 8A06                <1> 	mov	al, [esi]
 41641 0000AB3F 3C20                <1> 	cmp	al, 20h
 41642 0000AB41 77EF                <1> 	ja	short loc_scan_ppn_dslash
 41643                              <1> 	;cmp	dword [Last_Slash_Pos], 0
 41644                              <1> 	; 09/08/2022
 41645 0000AB43 390D[66810100]      <1> 	cmp	[Last_Slash_Pos], ecx ; 0 ?
 41646 0000AB49 76A5                <1> 	jna	short pass_ppn_cdir
 41647                              <1> 	
 41648 0000AB4B 8B0D[66810100]      <1> 	mov	ecx, [Last_Slash_Pos]
 41649 0000AB51 8B35[62810100]      <1> 	mov	esi, [First_Path_Pos]
 41650 0000AB57 29F1                <1> 	sub	ecx, esi
 41651 0000AB59 41                  <1> 	inc	ecx
 41652                              <1> 	;cmp	ecx, 64
 41653 0000AB5A 80F940              <1> 	cmp	cl, 64
 41654 0000AB5D 7715                <1> 	ja	short loc_ppn_invalid_drive_stc
 41655                              <1> 
 41656 0000AB5F 89F8                <1> 	mov	eax, edi ; Dest Dir String Location (65 byte)
 41657 0000AB61 F3A4                <1> 	rep	movsb
 41658                              <1> 	;mov	[edi], cl ; 0, End of Dir String
 41659 0000AB63 8B35[66810100]      <1> 	mov	esi, [Last_Slash_Pos]
 41660 0000AB69 46                  <1> 	inc	esi
 41661 0000AB6A 89C7                <1> 	mov	edi, eax
 41662 0000AB6C AC                  <1> 	lodsb
 41663 0000AB6D 3C21                <1> 	cmp	al, 21h
 41664 0000AB6F 7386                <1> 	jnb	short loc_ppn_get_filename
 41665                              <1> loc_ppn_clc_return:
 41666                              <1> 	;clc
 41667 0000AB71 31C0                <1> 	xor	eax, eax
 41668 0000AB73 C3                  <1> 	retn
 41669                              <1> 
 41670                              <1> loc_ppn_invalid_drive_stc:
 41671 0000AB74 F5                  <1> 	cmc	 ; stc
 41672                              <1> loc_ppn_invalid_drive:
 41673                              <1> 	; cf = 1
 41674                              <1> 	; The Drive Letter/Char < "A" or > "Z"
 41675 0000AB75 66B80F00            <1> 	mov	ax, 0Fh
 41676                              <1> 	; MS-DOS Error Code 0Fh = Disk Drive Invalid 
 41677                              <1> 	; (MainProg ErrMsg: "Drive not ready or read error!")
 41678 0000AB79 C3                  <1> 	retn
 41679                              <1> 
 41680                              <1> find_longname:
 41681                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 41682                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
 41683                              <1> 	; 24/01/2010 (DIR.ASM, 'proc_find_longname')
 41684                              <1> 	; 17/10/2009
 41685                              <1> 	
 41686                              <1> 	; INPUT -> 
 41687                              <1> 	;	ESI = DOS short file name address
 41688                              <1> 	; 	for example: "filename.ext"
 41689                              <1> 	;
 41690                              <1> 	; OUTPUT ->
 41691                              <1> 	; 	ESI = ASCIIZ longname address (cf = 0)
 41692                              <1> 	;	cf = 1 -> error number returns in EAX (AL)
 41693                              <1> 	;	AL = 0 & CF=1 -> longname not found
 41694                              <1> 	;	     the file/directory has no longname
 41695                              <1> 	; 	cf = 0 -> AL = FAT Type 
 41696                              <1>  
 41697                              <1> 	; 17/10/2009
 41698                              <1> 	; ASCIIZ string will be returned
 41699                              <1> 	; as LongFileName
 41700                              <1> 	; clearing/reset is not needed
 41701                              <1> 	;mov	ecx, 33
 41702                              <1> 	;mov	edi, LongFileName
 41703                              <1> 	;sub	ax, ax ; 0
 41704                              <1> 	;rep	stosw
 41705                              <1> 
 41706                              <1> 	;mov	byte [LongNameFound], 0
 41707                              <1> 
 41708                              <1> 	; ESI = ASCIIZ file/directory name address
 41709                              <1> 	;   AL = Attributes AND mask 
 41710                              <1> 	;	(Result of AND must be equal to AL)
 41711                              <1> 	;   AH = Negative attributes mask 
 41712                              <1> 	;	(Result of AND must be ZERO)
 41713 0000AB7A 66B80008            <1> 	mov	ax, 0800h 
 41714                              <1> 		; it must not be volume name or longname
 41715 0000AB7E E88EDEFFFF          <1> 	call	find_first_file
 41716 0000AB83 7212                <1> 	jc	short loc_fln_retn
 41717                              <1>  
 41718                              <1> loc_fln_check_FAT_Type:
 41719 0000AB85 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 41720 0000AB8C 7302                <1> 	jnb	short loc_fln_check_longname_yes_sign
 41721                              <1> 
 41722                              <1> 	;call	get_fs_longname
 41723                              <1> 	;retn
 41724                              <1> 	; 29/07/2022
 41725 0000AB8E EB37                <1> 	jmp	get_fs_longname
 41726                              <1> 
 41727                              <1> loc_fln_check_longname_yes_sign:
 41728 0000AB90 08FF                <1> 	or	bh, bh
 41729 0000AB92 7504                <1> 	jnz	short loc_fln_check_longnamefound_number
 41730                              <1> loc_fln_longname_not_found_retn:
 41731 0000AB94 31C0                <1> 	xor	eax, eax 
 41732                              <1> 	; cf = 1 & al = 0 -> longname not found
 41733 0000AB96 F9                  <1> 	stc
 41734                              <1> loc_fln_retn:
 41735 0000AB97 C3                  <1> 	retn
 41736                              <1> 
 41737                              <1> loc_fln_check_longnamefound_number:
 41738                              <1> 	; 'LongNameFound' is set by
 41739                              <1>         ; by 'save_longname_sub_component'
 41740                              <1> 	; which is called from
 41741                              <1> 	; 'find_directory_entry' 
 41742                              <1> 	; which is called from 
 41743                              <1> 	; 'find_first_file'
 41744                              <1> 	; It must 1 if the longname is valid
 41745 0000AB98 803D[3D800100]01    <1>         cmp     byte [LongNameFound], 1
 41746 0000AB9F 75F3                <1> 	jne	short loc_fln_longname_not_found_retn
 41747                              <1>              
 41748                              <1> loc_fln_calculate_checksum: 
 41749 0000ABA1 E813000000          <1> 	call	calculate_checksum
 41750                              <1> 	; AL = shortname checksum
 41751                              <1> 
 41752                              <1> loc_fln_longname_validation:
 41753                              <1> 	; 'LFN_CheckSum' has been set already
 41754                              <1> 	; by 'save_longname_sub_component'
 41755                              <1> 	; which is called from
 41756                              <1> 	; 'find_directory_entry' 
 41757                              <1> 	; which is called from 
 41758                              <1> 	; 'find_first_file'
 41759 0000ABA6 3805[3F800100]      <1> 	cmp	[LFN_CheckSum], al
 41760 0000ABAC 75E6                <1> 	jne	short loc_fln_longname_not_found_retn
 41761                              <1> 
 41762 0000ABAE BE[40800100]        <1> 	mov	esi, LongFileName
 41763 0000ABB3 A0[41780100]        <1> 	mov	al, [Current_FATType]
 41764 0000ABB8 C3                  <1> 	retn
 41765                              <1> 
 41766                              <1> calculate_checksum:
 41767                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 41768                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
 41769                              <1> 	; 17/10/2009 (DIR.ASM, 'proc_calculate_checksum')
 41770                              <1>         ;    
 41771                              <1> 	; INPUT ->
 41772                              <1> 	;	ESI = 11 byte DOS File Name location
 41773                              <1> 	;	(in DOS Directory Entry Format)
 41774                              <1> 	; OUTPUT ->
 41775                              <1> 	;	 AL = 8 bit checksum (CRC) value
 41776                              <1> 	;
 41777                              <1> 	; (Modified registers: EAX, ECX, ESI)
 41778                              <1> 
 41779                              <1> 	; Erdogan Tan [ 17-10-2009 ]
 41780                              <1> 	;  'ror al, 1' instruction
 41781                              <1> 
 41782                              <1> 	; Erdogan Tan [ 20-06-2004 ]
 41783                              <1> 	; This 8086 assembly code is an original code
 41784                              <1> 	; which is adapted from C code in
 41785                              <1> 	; Microsoft FAT32 File System Specification
 41786                              <1> 	; Version 1.03, December 6, 2000
 41787                              <1> 	; Page 28
 41788                              <1> 
 41789 0000ABB9 30C0                <1> 	xor	al, al
 41790                              <1> 	;mov	ecx, 11
 41791                              <1> 	; 29/07/2022
 41792 0000ABBB 29C9                <1> 	sub	ecx, ecx
 41793 0000ABBD B10B                <1> 	mov	cl, 11
 41794                              <1> loc_next_sum:
 41795                              <1> 	;xor	ah, ah
 41796                              <1> 	;test	al, 1
 41797                              <1> 	;jz	short pass_ah_80h
 41798                              <1> 	;mov	ah, 80h
 41799                              <1> ;pass_ah_80h:
 41800                              <1> 	;shr	al, 1
 41801 0000ABBF D0C8                <1> 	ror	al, 1 ; 17/10/2009  
 41802 0000ABC1 0206                <1> 	add	al, [esi]
 41803 0000ABC3 46                  <1> 	inc	esi
 41804                              <1> 	;add	al, ah
 41805 0000ABC4 E2F9                <1> 	loop	loc_next_sum
 41806 0000ABC6 C3                  <1> 	retn
 41807                              <1> 
 41808                              <1> get_fs_longname:
 41809                              <1> 	; temporary (13/02/2016)
 41810 0000ABC7 31C0                <1> 	xor	eax, eax
 41811 0000ABC9 F9                  <1> 	stc
 41812 0000ABCA C3                  <1> 	retn
 41813                              <1> 
 41814                              <1> make_sub_directory:
 41815                              <1> 	; 07/08/2022
 41816                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 41817                              <1> 	; 16/10/2016
 41818                              <1> 	; 02/03/2016, 03/03/2016
 41819                              <1> 	; 26/02/2016, 27/02/2016
 41820                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 41821                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_make_directory')
 41822                              <1> 	; 10/07/2010
 41823                              <1> 	; INPUT ->
 41824                              <1> 	; 	ESI = ASCIIZ Directory Name
 41825                              <1> 	;	CL = Directory Attributes
 41826                              <1> 	; OUTPUT ->
 41827                              <1> 	;	EAX = New sub dir's first cluster
 41828                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
 41829                              <1> 	;	CF = 1 -> error code in AL (EAX)
 41830                              <1> 
 41831                              <1> 	;test	cl, 10h  ; directory
 41832                              <1> 	;jz	short loc_make_directory_access_denied
 41833                              <1> 	;test	cl, 08h ; volume name
 41834                              <1> 	;jnz	short loc_make_directory_access_denied
 41835                              <1> 
 41836 0000ABCB 80E107              <1> 	and	cl, 07h
 41837 0000ABCE 880D[BC810100]      <1> 	mov	byte [mkdir_attrib], cl
 41838                              <1> 
 41839 0000ABD4 56                  <1> 	push	esi
 41840 0000ABD5 31DB                <1> 	xor	ebx, ebx
 41841 0000ABD7 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 41842 0000ABDD BE00010900          <1> 	mov	esi, Logical_DOSDisks
 41843 0000ABE2 01DE                <1> 	add	esi, ebx
 41844 0000ABE4 5B                  <1> 	pop	ebx
 41845                              <1> 
 41846                              <1> 	; 10/07/2010 -> 1st writable disk check for trdos
 41847                              <1> 	; LD_DiskType = 0 for write protection (read only) 
 41848 0000ABE5 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
 41849 0000ABE9 7308                <1> 	jnb	short loc_mkdir_check_file_sytem
 41850                              <1> 	; 16/10/2016 (13h -> 30)
 41851                              <1> 	;mov	eax, 30 ; 'Disk write-protected' error
 41852                              <1> 	;mov	edx, 0
 41853                              <1> 	; 29/07/2022
 41854 0000ABEB 29C0                <1> 	sub	eax, eax
 41855 0000ABED B01E                <1> 	mov	al, 30
 41856 0000ABEF 29D2                <1> 	sub	edx, edx ; 0
 41857 0000ABF1 F9                  <1> 	stc
 41858                              <1> 	; err retn: EDX = 0, EBX = Dir name offset
 41859                              <1> 	;ESI = Logical DOS drive description table address
 41860 0000ABF2 C3                  <1> 	retn
 41861                              <1> 
 41862                              <1> ;loc_make_directory_access_denied:
 41863                              <1> 	;mov	ax, 05h ; access denied (invalid attributes input)
 41864                              <1> 	;stc
 41865                              <1> 	;retn
 41866                              <1> 
 41867                              <1> loc_mkdir_check_file_sytem:
 41868 0000ABF3 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
 41869 0000ABF7 730A                <1> 	jnb	short loc_mkdir_check_free_sectors
 41870                              <1> 
 41871                              <1> loc_make_fs_directory:
 41872 0000ABF9 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 41873                              <1> 	
 41874                              <1> 	; EAX = Parent directory DDT Address
 41875                              <1> 	; ESI = Logical DOS Drive DT Address
 41876                              <1> 	; EBX = Directory name offset (as ASCIIZ name)
 41877                              <1> 	
 41878                              <1> 	;call	make_fs_directory
 41879                              <1> 	;retn
 41880                              <1> 	; 29/07/2022
 41881 0000ABFE E986150000          <1> 	jmp	make_fs_directory  
 41882                              <1> 
 41883                              <1> loc_mkdir_check_free_sectors:
 41884 0000AC03 0FB64613            <1>         movzx   eax, byte [esi+LD_BPB+SecPerClust]
 41885 0000AC07 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
 41886 0000AC0A 39C1                <1> 	cmp	ecx, eax
 41887 0000AC0C 7254                <1> 	jb	short loc_mkdir_insufficient_disk_space
 41888                              <1> 
 41889                              <1> loc_make_fat_directory:
 41890 0000AC0E 891D[AC810100]      <1> 	mov	[mkdir_DirName_Offset], ebx
 41891 0000AC14 890D[B8810100]      <1> 	mov	[mkdir_FreeSectors], ecx
 41892                              <1> 
 41893                              <1> 	;mov	al, [esi+LD_BPB+SecPerClust]
 41894 0000AC1A A2[BE810100]        <1> 	mov	byte [mkdir_SecPerClust], al
 41895                              <1> 
 41896                              <1> loc_mkdir_gffc_1:
 41897 0000AC1F E888170000          <1> 	call	get_first_free_cluster
 41898 0000AC24 722A                <1> 	jc	short loc_mkdir_gffc_retn
 41899                              <1> 
 41900                              <1> ;loc_mkdir_gffc_1_cont: 
 41901                              <1> 	;cmp	eax, 2
 41902                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
 41903                              <1> 
 41904                              <1> ;loc_mkdir_gffc_1_save_fcluster:  
 41905 0000AC26 A3[B0810100]        <1> 	mov	[mkdir_FFCluster], eax
 41906                              <1> 
 41907                              <1> loc_mkdir_locate_ffe:
 41908                              <1> 	; Current directory fcluster <> Directory buffer cluster
 41909                              <1> 	; Current directory will be reloaded by
 41910                              <1> 	; 'locate_current_dir_file' procedure
 41911                              <1> 	;
 41912                              <1> 	; ESI = Logical DOS Drive Description Table Address 
 41913                              <1> 	;push	esi ; 27/02/2016
 41914 0000AC2B 31C0                <1> 	xor	eax, eax
 41915 0000AC2D 89C1                <1>         mov	ecx, eax
 41916 0000AC2F 6649                <1> 	dec	cx ; FFFFh  
 41917                              <1> 	; CX = FFFFh -> find first deleted or free entry
 41918                              <1> 	; ESI would be ASCIIZ filename address if the call
 41919                              <1> 	; would not be for first free or deleted dir entry
 41920 0000AC31 E808FBFFFF          <1> 	call	locate_current_dir_file
 41921 0000AC36 734A                <1> 	jnc	short loc_mkdir_set_ff_dir_entry_1
 41922                              <1> 	;pop	esi 
 41923                              <1> 	; ESI = Logical DOS Drive Description Table Address 
 41924 0000AC38 83F802              <1> 	cmp	eax, 2  ; cmp al, 2 ; File/Dir not found !
 41925 0000AC3B 7529                <1> 	jne	short loc_mkdir_stc_return
 41926                              <1> 
 41927                              <1> loc_mkdir_add_new_cluster:
 41928 0000AC3D 3805[41780100]      <1> 	cmp	byte [Current_FATType], al ; 2
 41929                              <1> 	;cmp	byte ptr [esi+LD_FATType], 2
 41930 0000AC43 770C                <1> 	ja	short loc_mkdir_add_new_cluster_check_fsc
 41931 0000AC45 803D[40780100]01    <1> 	cmp	byte [Current_Dir_Level], 1
 41932                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
 41933 0000AC4C 7303                <1> 	jnb	short loc_mkdir_add_new_cluster_check_fsc
 41934                              <1> 
 41935 0000AC4E B00C                <1> 	mov	al, 12 ; No more files 
 41936                              <1> loc_mkdir_gffc_retn:
 41937 0000AC50 C3                  <1> 	retn
 41938                              <1> 
 41939                              <1> loc_mkdir_add_new_cluster_check_fsc:
 41940 0000AC51 8B0D[B8810100]      <1> 	mov	ecx, [mkdir_FreeSectors]
 41941                              <1> 	;movzx	eax, byte [mkdir_SecPerClust]
 41942 0000AC57 A0[BE810100]        <1> 	mov	al, [mkdir_SecPerClust]
 41943                              <1> 	;shl	ax, 1 ; AX = 2 * AX
 41944                              <1> 	; 29/07/2022
 41945 0000AC5C D1E0                <1> 	shl	eax, 1
 41946 0000AC5E 39C1                <1> 	cmp	ecx, eax
 41947 0000AC60 7350                <1> 	jnb	short loc_mkdir_add_new_subdir_cluster
 41948                              <1> 
 41949                              <1> loc_mkdir_insufficient_disk_space:
 41950                              <1> 	;mov	edx, ecx
 41951                              <1> ;loc_mkdir_gffc_insufficient_disk_space:
 41952                              <1> 	; 29/07/2022
 41953                              <1> 	;mov	ax, 27h ; MSDOS err => insufficient disk space
 41954                              <1> 	
 41955                              <1> 	; err retn: EDX = Free sectors, EBX = Dir name offset
 41956                              <1>         ; ESI -> Dos drive description table address
 41957                              <1> 	;; ecx = edx
 41958                              <1> 	
 41959                              <1> 	;retn
 41960                              <1> 	
 41961                              <1> 	; 29/07/2022
 41962 0000AC62 30E4                <1> 	xor	ah, ah
 41963 0000AC64 B027                <1> 	mov	al, 27h
 41964                              <1> 
 41965                              <1> loc_mkdir_stc_return:
 41966 0000AC66 F9                  <1> 	stc
 41967 0000AC67 C3                  <1> 	retn 
 41968                              <1> 
 41969                              <1> loc_mkdir_gffc_2:
 41970 0000AC68 E83F170000          <1> 	call	get_first_free_cluster
 41971 0000AC6D 72E1                <1> 	jc	short loc_mkdir_gffc_retn
 41972                              <1> 
 41973                              <1> ;loc_mkdir_gffc_1_cont: 
 41974                              <1> 	;cmp	eax, 2
 41975                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
 41976                              <1> 
 41977                              <1> ;loc_mkdir_gffc_2_save_fcluster:  
 41978 0000AC6F A3[B0810100]        <1> 	mov	[mkdir_FFCluster], eax
 41979                              <1> 
 41980 0000AC74 A1[B4810100]        <1> 	mov	eax, [mkdir_LastDirCluster]
 41981                              <1> 
 41982 0000AC79 E8C8160000          <1> 	call	load_FAT_sub_directory 
 41983 0000AC7E 72D0                <1> 	jc	short loc_mkdir_gffc_retn
 41984                              <1> 
 41985 0000AC80 31FF                <1> 	xor	edi, edi
 41986                              <1> loc_mkdir_set_ff_dir_entry_1:
 41987                              <1> 	; 27/02/2016
 41988 0000AC82 56                  <1> 	push	esi ; Logical DOS Drv Desc. Tbl. address
 41989                              <1> 	; EDI = Directory Entry Address
 41990 0000AC83 8B35[AC810100]      <1> 	mov	esi, [mkdir_DirName_Offset]
 41991 0000AC89 A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 41992                              <1> 
 41993 0000AC8E 66B91000            <1> 	mov	cx, 10h	; CL = Directory attribute
 41994                              <1> 			; CH = 0 -> File size is 0
 41995 0000AC92 0A0D[BC810100]      <1> 	or	cl, [mkdir_attrib] ; S, H, R  
 41996 0000AC98 E8A3010000          <1> 	call	make_directory_entry
 41997                              <1> 
 41998 0000AC9D 5E                  <1> 	pop	esi
 41999                              <1> 
 42000 0000AC9E C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 42001 0000ACA5 E869020000          <1> 	call	save_directory_buffer
 42002                              <1>         ;jnc	loc_mkdir_set_ff_dir_entry_2
 42003                              <1> 	; 29/07/2022
 42004 0000ACAA 7205                <1> 	jc	short loc_mkdir_return
 42005 0000ACAC E9CA000000          <1> 	jmp	loc_mkdir_set_ff_dir_entry_2
 42006                              <1> 
 42007                              <1> loc_mkdir_return:
 42008 0000ACB1 C3                  <1> 	retn
 42009                              <1> 
 42010                              <1> loc_mkdir_add_new_subdir_cluster:
 42011 0000ACB2 8B15[6E7F0100]      <1> 	mov	edx, [DirBuff_Cluster]
 42012 0000ACB8 8915[B4810100]      <1> 	mov	[mkdir_LastDirCluster], edx       
 42013                              <1> 
 42014 0000ACBE A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42015 0000ACC3 E87E160000          <1> 	call	load_FAT_sub_directory 
 42016 0000ACC8 72E7                <1> 	jc	short loc_mkdir_return
 42017                              <1> 	; eax = 0
 42018                              <1> 	; ecx = directory buffer sector count (<= 128)
 42019                              <1> 
 42020                              <1> pass_mkdir_add_new_subdir_cluster:
 42021                              <1> 
 42022                              <1> ; 29/07/2022
 42023                              <1> ;	;sub	edi, edi ; 0
 42024                              <1> ;	; 29/07/2022 - BUGFIX !
 42025                              <1> ;	mov	edi, Directory_Buffer
 42026                              <1> ;
 42027                              <1> ;	;mov	al, 128 ; double word
 42028                              <1> ;	;mul	ecx ; ecx =  directory buffer sector count
 42029                              <1> ;	;mov	ecx, eax
 42030                              <1> ;	;shl	cx, 7 ; 128 * sector count	
 42031                              <1> ;	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
 42032                              <1> ;	;shr	ax, 2 ; 'byte count / 4' for 'stosd'
 42033                              <1> ;	; 29/07/2022
 42034                              <1> ;	shr	eax, 2
 42035                              <1> ;	;mul	cx ; max = 128*(512/4) -> 16384 (stosd)
 42036                              <1> ;	;mov	cx, ax
 42037                              <1> ;	;sub	ax, ax ; 0
 42038                              <1> ;	; 29/07/2022
 42039                              <1> ;	mul	ecx
 42040                              <1> ;	mov	ecx, eax
 42041                              <1> ;	sub	eax, eax
 42042                              <1> ;	rep	stosd ; clear directory buffer
 42043                              <1> 
 42044                              <1> 	; 29/07/2022
 42045 0000ACCA E85C010000          <1> 	call	clear_directory_buffer
 42046                              <1> 
 42047 0000ACCF C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 42048 0000ACD6 E838020000          <1> 	call	save_directory_buffer 
 42049 0000ACDB 72D4                <1> 	jc	short loc_mkdir_return
 42050                              <1> 
 42051                              <1> loc_mkdir_save_added_cluster:
 42052 0000ACDD A1[B4810100]        <1> 	mov	eax, [mkdir_LastDirCluster]
 42053 0000ACE2 8B0D[B0810100]      <1> 	mov	ecx, [mkdir_FFCluster]
 42054                              <1> 	; 01/03/2016
 42055 0000ACE8 31D2                <1> 	xor	edx, edx
 42056 0000ACEA 8915[5E7F0100]      <1> 	mov	[FAT_ClusterCounter], edx ; 0 ; reset
 42057 0000ACF0 E884170000          <1> 	call	update_cluster
 42058 0000ACF5 7304                <1> 	jnc	short loc_mkdir_save_fat_buffer_0
 42059 0000ACF7 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 42060 0000ACF9 7518                <1> 	jnz	short loc_mkdir_save_fat_buffer_stc_retn
 42061                              <1> 
 42062                              <1> loc_mkdir_save_fat_buffer_0:
 42063 0000ACFB A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42064 0000AD00 A3[B4810100]        <1> 	mov	[mkdir_LastDirCluster], eax
 42065                              <1> 
 42066 0000AD05 31C9                <1> 	xor	ecx, ecx
 42067 0000AD07 49                  <1> 	dec	ecx ; FFFFFFFFh
 42068                              <1> 	; ESI = Logical DOS Drive Description Table address 
 42069 0000AD08 E86C170000          <1> 	call	update_cluster
 42070 0000AD0D 731A                <1> 	jnc	short loc_mkdir_save_fat_buffer_1
 42071 0000AD0F 09C0                <1> 	or	eax, eax
 42072 0000AD11 7416                <1> 	jz	short loc_mkdir_save_fat_buffer_1
 42073                              <1> 
 42074                              <1> loc_mkdir_save_fat_buffer_stc_retn:
 42075                              <1> 	; 01/03/2016
 42076 0000AD13 803D[5E7F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
 42077 0000AD1A 720C                <1> 	jb	short loc_mkdir_save_fat_buffer_retn
 42078                              <1> 
 42079 0000AD1C 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
 42080                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
 42081 0000AD20 50                  <1> 	push	eax
 42082 0000AD21 E8671A0000          <1> 	call	calculate_fat_freespace
 42083 0000AD26 58                  <1> 	pop	eax
 42084 0000AD27 F9                  <1> 	stc
 42085                              <1> loc_mkdir_save_fat_buffer_retn:
 42086 0000AD28 C3                  <1> 	retn
 42087                              <1> 
 42088                              <1> loc_mkdir_save_fat_buffer_1:
 42089                              <1> 	; byte [FAT_BuffValidData] = 2 
 42090 0000AD29 E8CE190000          <1> 	call	save_fat_buffer
 42091 0000AD2E 72E3                <1> 	jc	short loc_mkdir_save_fat_buffer_stc_retn
 42092                              <1> 
 42093                              <1> 	; 01/03/2016
 42094 0000AD30 803D[5E7F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
 42095 0000AD37 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_2
 42096                              <1> 
 42097                              <1> 	; ESI = Logical DOS Drive Description Table address 
 42098 0000AD39 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 42099 0000AD3E 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
 42100 0000AD42 E8461A0000          <1> 	call	calculate_fat_freespace
 42101                              <1> 
 42102                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
 42103                              <1> 	;jnz	short loc_mkdir_save_fat_buffer_2
 42104                              <1> 
 42105                              <1> 	; ecx > 0 -> Recalculation is needed
 42106 0000AD47 09C9                <1> 	or	ecx, ecx 
 42107 0000AD49 7409                <1> 	jz	short loc_mkdir_save_fat_buffer_2
 42108                              <1> 
 42109 0000AD4B 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
 42110 0000AD4F E8391A0000          <1> 	call	calculate_fat_freespace
 42111                              <1> 
 42112                              <1> loc_mkdir_save_fat_buffer_2:
 42113 0000AD54 C605[BF810100]01    <1> 	mov	byte [mkdir_add_new_cluster], 1
 42114 0000AD5B E9B0000000          <1> 	jmp	loc_mkdir_upd_parent_dir_lmdt
 42115                              <1> 
 42116                              <1> loc_mkdir_update_sub_dir_cluster:
 42117 0000AD60 A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42118 0000AD65 29C9                <1> 	sub	ecx, ecx ; 0
 42119                              <1> 	; 01/03/2016
 42120 0000AD67 890D[5E7F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; Reset
 42121 0000AD6D 49                  <1> 	dec	ecx ; 0FFFFFFFFh
 42122                              <1> 
 42123                              <1> 	; ESI = Logical DOS Drive Descisption Table address  
 42124 0000AD6E E806170000          <1> 	call	update_cluster
 42125 0000AD73 7364                <1> 	jnc	short loc_mkdir_save_fat_buffer_3
 42126 0000AD75 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 42127 0000AD77 7460                <1> 	jz	short loc_mkdir_save_fat_buffer_3
 42128                              <1> 	; 01/03/2016
 42129 0000AD79 EB98                <1> 	jmp	short loc_mkdir_save_fat_buffer_stc_retn
 42130                              <1> 
 42131                              <1> loc_mkdir_set_ff_dir_entry_2:
 42132                              <1> 	; ESI = Logical DOS Drive Description Table address  
 42133 0000AD7B A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42134                              <1> 	; Load disk sectors as a directory cluster
 42135 0000AD80 E8C1150000          <1> 	call	load_FAT_sub_directory 
 42136 0000AD85 7251                <1> 	jc	short retn_make_fat_directory
 42137                              <1> 	
 42138                              <1> 	; eax = 0
 42139                              <1> 	; ecx = directory buffer sector count (<= 128)
 42140                              <1> 
 42141                              <1> ; 29/07/2022
 42142                              <1> ;	mov	edi, Directory_Buffer + 64 ; 26/02/2016
 42143                              <1> ;
 42144                              <1> ;	; 02/03/2016
 42145                              <1> ;	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
 42146                              <1> ;	;shr	ax, 2 ; 'byte count / 4' for 'stosd'
 42147                              <1> ;	; 29/07/2022
 42148                              <1> ;	shr	eax, 2
 42149                              <1> ;	mul 	ecx
 42150                              <1> ;	mov	ecx, eax
 42151                              <1> ;	;
 42152                              <1> ;	; 29/07/2022 - BUGFIX !
 42153                              <1> ;	sub	ecx, 16 ; - 64 bytes
 42154                              <1> ;			; (space for '.' & '..' entries)
 42155                              <1> ;	;sub	ax, ax
 42156                              <1> ;	sub	eax, eax
 42157                              <1> ;	rep	stosd
 42158                              <1> ;
 42159                              <1> ;	;;mov	al, 128 ; double word (count in sector)
 42160                              <1> ;	;;mul	ecx ; ecx = directory buffer sector count
 42161                              <1> ;	;;mov	ecx, eax
 42162                              <1> ;	;shl	cx, 7 ; 128 * sector count
 42163                              <1> ;	;sub	ecx, 64 ; 29/07/2022
 42164                              <1> ;	;;sub	eax, eax
 42165                              <1> ;	;;sub	al, al ; 0
 42166                              <1> ;	;rep	stosd ; clear directory buffer
 42167                              <1> 
 42168                              <1> 	; 29/07/2022
 42169 0000AD87 E89F000000          <1> 	call	clear_directory_buffer
 42170                              <1> 
 42171 0000AD8C BF00000800          <1> 	mov	edi, Directory_Buffer ; 26/02/2016
 42172                              <1> 	
 42173 0000AD91 56                  <1> 	push	esi
 42174                              <1> 
 42175 0000AD92 BE[C0810100]        <1> 	mov	esi, mkdir_Name
 42176 0000AD97 66C7062E00          <1> 	mov	word [esi], 2Eh ; db '.', '0'
 42177                              <1> 
 42178 0000AD9C A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42179                              <1> 	;mov	cx, 10h ; CL = Directory attribute
 42180                              <1> 			; CH = 0 -> File size is 0
 42181                              <1> 	; 29/07/2022
 42182 0000ADA1 B110                <1> 	mov	cl, 10h
 42183 0000ADA3 E898000000          <1> 	call	make_directory_entry
 42184                              <1> 
 42185 0000ADA8 BF20000800          <1> 	mov	edi, Directory_Buffer + 32 ; 26/02/2016
 42186                              <1> 
 42187                              <1> 	; 03/03/2016
 42188                              <1> 	; Following modification has been done according to 
 42189                              <1> 	; 'Microsoft Extensible Firmware Initiative
 42190                              <1> 	; FAT32 File System Specification' document,
 42191                              <1> 	; 'FAT: General Overview of On-Disk FormatPage 25'.
 42192                              <1> 	; "Finally, you set DIR_FstClusLO and DIR_FstClusHI
 42193                              <1> 	; for the dotdot entry (the second entry) to the
 42194                              <1> 	; first cluster number of the directory in which you 
 42195                              <1> 	; just created the directory (value is 0 if this directory
 42196                              <1> 	; is the root directory even for FAT32 volumes)."
 42197                              <1> 	; (Correctness of this modification has been verified
 42198                              <1> 	;  by using Windows 98 'scandisk.exe'.)
 42199                              <1> 
 42200 0000ADAD 29C0                <1> 	sub	eax, eax
 42201 0000ADAF 3805[40780100]      <1> 	cmp	byte [Current_Dir_Level], al ; 0
 42202 0000ADB5 7605                <1> 	jna	short loc_mkdir_set_ff_dir_entry_3
 42203 0000ADB7 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster] ; parent dir
 42204                              <1> loc_mkdir_set_ff_dir_entry_3:
 42205 0000ADBC 66C746012E00        <1> 	mov	word [esi+1], 2Eh ; db '.', '0'
 42206                              <1> 
 42207                              <1> 	;mov	cx, 10h
 42208 0000ADC2 E879000000          <1> 	call	make_directory_entry
 42209                              <1> 
 42210 0000ADC7 5E                  <1> 	pop	esi
 42211                              <1> 
 42212 0000ADC8 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 42213 0000ADCF E83F010000          <1> 	call	save_directory_buffer
 42214                              <1> 	;jnc	loc_mkdir_update_sub_dir_cluster
 42215                              <1> 	; 29/07/2022
 42216 0000ADD4 7202                <1> 	jc	short retn_make_fat_directory
 42217 0000ADD6 EB88                <1> 	jmp	loc_mkdir_update_sub_dir_cluster
 42218                              <1> 
 42219                              <1> retn_make_fat_directory:
 42220 0000ADD8 C3                  <1> 	retn
 42221                              <1> 
 42222                              <1> loc_mkdir_save_fat_buffer_3:
 42223                              <1> 	; 01/03/2016
 42224                              <1> 	; byte [FAT_BuffValidData] = 2 
 42225 0000ADD9 E81E190000          <1> 	call	save_fat_buffer
 42226                              <1> 	;jc	short loc_mkdir_save_fat_buffer_stc_retn
 42227                              <1> 	; 07/08/2022
 42228 0000ADDE 7305                <1> 	jnc	short loc_mkdir_save_fat_buffer_4
 42229 0000ADE0 E92EFFFFFF          <1> 	jmp	loc_mkdir_save_fat_buffer_stc_retn
 42230                              <1> 
 42231                              <1> loc_mkdir_save_fat_buffer_4:
 42232 0000ADE5 803D[5E7F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
 42233 0000ADEC 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_5
 42234                              <1> 
 42235                              <1> 	; ESI = Logical DOS Drive Description Table address 
 42236 0000ADEE A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 42237 0000ADF3 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
 42238 0000ADF7 E891190000          <1> 	call	calculate_fat_freespace
 42239                              <1> 
 42240                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
 42241                              <1>         ;jnz    short loc_mkdir_save_fat_buffer_5
 42242                              <1> 
 42243                              <1> 	; ecx > 0 -> Recalculation is needed
 42244 0000ADFC 09C9                <1> 	or	ecx, ecx 
 42245 0000ADFE 7409                <1>         jz      short loc_mkdir_save_fat_buffer_5
 42246                              <1> 
 42247 0000AE00 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space
 42248 0000AE04 E884190000          <1> 	call	calculate_fat_freespace
 42249                              <1> 
 42250                              <1> loc_mkdir_save_fat_buffer_5:	
 42251 0000AE09 C605[BF810100]00    <1> 	mov	byte [mkdir_add_new_cluster], 0
 42252                              <1> 
 42253                              <1> loc_mkdir_upd_parent_dir_lmdt:
 42254 0000AE10 E896010000          <1> 	call	update_parent_dir_lmdt
 42255                              <1> 
 42256                              <1> 	; 01/03/2016
 42257 0000AE15 803D[BF810100]00    <1> 	cmp	byte [mkdir_add_new_cluster], 0
 42258                              <1> 	;ja	loc_mkdir_gffc_2
 42259                              <1> 	; 29/07/2022
 42260 0000AE1C 7605                <1> 	jna	short loc_mkdir_retn_new_dir_cluster
 42261 0000AE1E E945FEFFFF          <1> 	jmp	loc_mkdir_gffc_2
 42262                              <1> 
 42263                              <1> loc_mkdir_retn_new_dir_cluster:
 42264 0000AE23 A1[B0810100]        <1> 	mov	eax, [mkdir_FFCluster]
 42265 0000AE28 31D2                <1> 	xor	edx, edx
 42266                              <1> loc_mkdir_retn:
 42267 0000AE2A C3                  <1> 	retn
 42268                              <1> 
 42269                              <1> clear_directory_buffer:
 42270                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42271                              <1> 	;
 42272                              <1> 	; eax = 0
 42273                              <1> 	; ecx = directory buffer sector count (<= 128)
 42274                              <1> 	;
 42275 0000AE2B BF00000800          <1> 	mov	edi, Directory_Buffer
 42276                              <1> 	;mov	al, 128 ; double word
 42277                              <1> 	;mul	ecx ; ecx = directory buffer sector count
 42278                              <1> 	;mov	ecx, eax
 42279                              <1> 	;shl	cx, 7 ; 128 * sector count	
 42280 0000AE30 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
 42281 0000AE34 C1E802              <1> 	shr	eax, 2 ; 'byte count / 4' for 'stosd'
 42282 0000AE37 F7E1                <1> 	mul	ecx ; max = 128*(512/4) -> 16384 (stosd)
 42283 0000AE39 89C1                <1> 	mov	ecx, eax
 42284 0000AE3B 29C0                <1> 	sub	eax, eax
 42285 0000AE3D F3AB                <1> 	rep	stosd ; clear directory buffer
 42286 0000AE3F C3                  <1> 	retn
 42287                              <1> 
 42288                              <1> make_directory_entry:
 42289                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42290                              <1> 	; 02/03/2016
 42291                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 42292                              <1> 	; 09/08/2010 (DIR.ASM, 'proc_make_directory_entry')
 42293                              <1> 	; 17/07/2010
 42294                              <1> 	; INPUT ->
 42295                              <1> 	; 	EDI = Directory Entry Address
 42296                              <1> 	;	ESI = Dot File Name Location
 42297                              <1> 	;	EAX = First Cluster
 42298                              <1> 	;	File Size = 0 (Must be set later)
 42299                              <1> 	;	CL = Attributes
 42300                              <1> 	;	CH = 0 (File size = 0) 
 42301                              <1> 	;	(If CH>0, File size is in dword [EBX]) (*)
 42302                              <1> 	; OUTPUT -> 
 42303                              <1> 	;	EDI = Directory Entry Address
 42304                              <1> 	;	ESI = Dot File Name Location (Capitalized)
 42305                              <1> 	;	If CH input = 0, File Size = 0
 42306                              <1> 	;	Otherwise file size is as dword [EBX] (*)
 42307                              <1> 	;	DX = Date, AX = Time in DOS Dir Entry format
 42308                              <1> 	;	EBX = same
 42309                              <1> 	;	ECX = same
 42310                              <1> 
 42311 0000AE40 51                  <1> 	push	ecx
 42312                              <1> 
 42313 0000AE41 884F0B              <1> 	mov	[edi+11], cl ; Attributes
 42314 0000AE44 6689471A            <1> 	mov	[edi+26], ax ; FClusterLw, 26
 42315 0000AE48 C1E810              <1> 	shr	eax, 16
 42316 0000AE4B 66894714            <1> 	mov	[edi+20], ax ; FClusterHw, 20
 42317                              <1> 	;xor	ax, ax 
 42318                              <1> 	; 29/07/2022
 42319 0000AE4F 31C0                <1> 	xor	eax, eax
 42320 0000AE51 6689470C            <1> 	mov	[edi+12], ax ; NTReserved, 12
 42321                              <1> 			     ; CrtTimeTenth, 13
 42322 0000AE55 08ED                <1> 	or	ch, ch
 42323 0000AE57 7402                <1> 	jz	short loc_make_direntry_set_filesize
 42324                              <1> 
 42325 0000AE59 8B03                <1> 	mov	eax, [ebx]
 42326                              <1>         
 42327                              <1> loc_make_direntry_set_filesize:
 42328 0000AE5B 89471C              <1> 	mov	[edi+28], eax ; FileSize, 28
 42329                              <1> 	
 42330 0000AE5E E8AAFBFFFF          <1> 	call	convert_file_name
 42331                              <1> 	;EDI = Dir Entry Format File Name Location
 42332                              <1> 	;ESI = Dot File Name Location (capitalized)
 42333                              <1> 
 42334 0000AE63 E816000000          <1> 	call	convert_current_date_time
 42335                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 42336                              <1>         ; 	    AX = Time in dos dir entry format
 42337 0000AE68 6689470E            <1> 	mov	[edi+14], ax ; CrtTime, 14
 42338 0000AE6C 66895710            <1> 	mov	[edi+16], dx ; CrtDate, 16
 42339 0000AE70 66895712            <1> 	mov	[edi+18], dx ; LastAccDate, 18
 42340 0000AE74 66894716            <1> 	mov	[edi+22], ax ; WrtTime, 14
 42341 0000AE78 66895718            <1> 	mov	[edi+24], dx ; WrtDate, 16
 42342 0000AE7C 59                  <1> 	pop	ecx
 42343                              <1> 
 42344 0000AE7D C3                  <1> 	retn
 42345                              <1> 
 42346                              <1> convert_current_date_time:
 42347                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42348                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 42349                              <1> 	; 13/06/2010 (DIR.ASM, 'proc_convert_current_date_time')
 42350                              <1> 	; converts date&time to dos dir entry format
 42351                              <1> 	; INPUT -> none
 42352                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 42353                              <1> 	;           AX = Time in dos dir entry format
 42354                              <1>  
 42355 0000AE7E B404                <1> 	mov	ah, 04h ; Return Current Date
 42356 0000AE80 E8D4B2FFFF          <1> 	call	int1Ah 
 42357                              <1> 
 42358 0000AE85 88E8                <1> 	mov	al, ch ; <- century BCD
 42359 0000AE87 240F                <1> 	and	al, 0Fh
 42360 0000AE89 88EC                <1> 	mov	ah, ch
 42361 0000AE8B C0EC04              <1> 	shr	ah, 4
 42362 0000AE8E D50A                <1> 	aad
 42363 0000AE90 88C5                <1> 	mov	ch, al ; -> century 
 42364                              <1> 
 42365 0000AE92 88C8                <1> 	mov	al, cl ; <- year BCD
 42366 0000AE94 240F                <1> 	and	al, 0Fh
 42367 0000AE96 88CC                <1> 	mov	ah, cl
 42368 0000AE98 C0EC04              <1> 	shr	ah, 4
 42369 0000AE9B D50A                <1> 	aad
 42370 0000AE9D 88C1                <1> 	mov	cl, al ; -> year
 42371                              <1> 
 42372                              <1> 	;mov	al, ch
 42373                              <1> 	;mov	ah, 100
 42374                              <1> 	;mul	ah
 42375                              <1> 	; 29/07/2022
 42376 0000AE9F B064                <1> 	mov	al, 100
 42377 0000AEA1 F6E5                <1> 	mul	ch	
 42378                              <1> 
 42379                              <1> 	;xor	ch, ch
 42380                              <1> 	;add	ax, cx
 42381                              <1> 	; 29/07/2022
 42382 0000AEA3 00C8                <1> 	add	al, cl
 42383 0000AEA5 80D400              <1> 	adc	ah, 0
 42384 0000AEA8 662DBC07            <1> 	sub	ax, 1980 ; ms-dos epoch
 42385                              <1> 	;mov	cx, ax
 42386                              <1> 	; 29/07/2022
 42387 0000AEAC 88C1                <1> 	mov	cl, al
 42388                              <1> 	;mov	ecx, eax
 42389                              <1> 
 42390 0000AEAE 88F0                <1> 	mov	al, dh ; <- month in bcd
 42391 0000AEB0 240F                <1> 	and	al, 0Fh
 42392 0000AEB2 88F4                <1> 	mov	ah, dh
 42393 0000AEB4 C0EC04              <1> 	shr	ah, 4
 42394 0000AEB7 D50A                <1> 	aad
 42395 0000AEB9 88C6                <1> 	mov	dh, al ; -> month
 42396                              <1> 
 42397 0000AEBB 88D0                <1> 	mov	al, dl ; <- day BCD
 42398 0000AEBD 240F                <1> 	and	al, 0Fh
 42399 0000AEBF 88D4                <1> 	mov	ah, dl
 42400 0000AEC1 C0EC04              <1> 	shr	ah, 4
 42401 0000AEC4 D50A                <1> 	aad
 42402 0000AEC6 88C2                <1> 	mov	dl, al ; -> day
 42403                              <1> 
 42404 0000AEC8 88C8                <1> 	mov	al, cl ; count of years from 1980
 42405                              <1> 	;shl	ax, 4
 42406                              <1> 	; 29/07/2022
 42407                              <1> 	;mov	eax, ecx
 42408 0000AECA C1E004              <1> 	shl	eax, 4
 42409                              <1> 
 42410 0000AECD 08F0                <1> 	or	al, dh ; month of year, 1 to 12
 42411                              <1> 	;shl	ax, 5
 42412                              <1> 	; 29/07/2022
 42413 0000AECF C1E005              <1> 	shl	eax, 5
 42414 0000AED2 08D0                <1> 	or	al, dl ; day of year, 1 to 31
 42415                              <1> 	
 42416                              <1> 	;push	ax ; push date
 42417                              <1> 	; 29/07/2022
 42418 0000AED4 50                  <1> 	push	eax
 42419                              <1> 
 42420 0000AED5 B402                <1> 	mov	ah, 02h ; Return Current Time
 42421 0000AED7 E87DB2FFFF          <1> 	call	int1Ah
 42422                              <1> 
 42423 0000AEDC 88E8                <1> 	mov	al, ch ; <- hours BCD
 42424 0000AEDE 240F                <1> 	and	al, 0Fh
 42425 0000AEE0 88EC                <1> 	mov	ah, ch
 42426 0000AEE2 C0EC04              <1> 	shr	ah, 4
 42427 0000AEE5 D50A                <1> 	aad
 42428 0000AEE7 88C5                <1> 	mov	ch, al ; -> hours
 42429                              <1> 
 42430 0000AEE9 88C8                <1> 	mov	al, cl ; <- minutes BCD
 42431 0000AEEB 240F                <1> 	and	al, 0Fh
 42432 0000AEED 88CC                <1> 	mov	ah, cl
 42433 0000AEEF C0EC04              <1> 	shr	ah, 4
 42434 0000AEF2 D50A                <1> 	aad
 42435 0000AEF4 88C1                <1> 	mov	cl, al ; -> minutes
 42436                              <1> 
 42437 0000AEF6 88F0                <1> 	mov	al, dh ; <- seconds BCD
 42438 0000AEF8 240F                <1> 	and	al, 0Fh
 42439 0000AEFA 88F4                <1> 	mov	ah, dh
 42440 0000AEFC C0EC04              <1> 	shr	ah, 4
 42441 0000AEFF D50A                <1> 	aad
 42442 0000AF01 88C6                <1> 	mov	dh, al ; -> seconds
 42443                              <1> 
 42444 0000AF03 88E8                <1> 	mov	al, ch ; hours
 42445                              <1> 	;shl	ax, 6
 42446                              <1> 	; 29/07/2022
 42447 0000AF05 C1E006              <1> 	shl	eax, 6
 42448 0000AF08 08C8                <1> 	or	al, cl ; minutes
 42449                              <1> 	;shl	ax, 5
 42450                              <1> 	; 29/07/2022
 42451 0000AF0A C1E005              <1> 	shl	eax, 5
 42452 0000AF0D D0EE                <1> 	shr	dh, 1 ; 2 seconds
 42453                              <1> 	; There is a bug in TRDOS v1 here !
 42454                              <1> 	; it was 'or al, dl' ! 
 42455 0000AF0F 08F0                <1> 	or	al, dh ; seconds
 42456                              <1> 
 42457                              <1> 	;pop	dx ; pop date
 42458                              <1> 	; 29/07/2022
 42459 0000AF11 5A                  <1> 	pop	edx	
 42460                              <1> 
 42461 0000AF12 C3                  <1> 	retn
 42462                              <1> 
 42463                              <1> save_directory_buffer:
 42464                              <1> 	; 30/07/2022
 42465                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42466                              <1> 	; 15/10/2016
 42467                              <1> 	; 23/03/2016
 42468                              <1> 	; 26/02/2016
 42469                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
 42470                              <1> 	; 01/08/2011
 42471                              <1> 	; 14/03/2010
 42472                              <1> 	; INPUT ->
 42473                              <1> 	; 	 none
 42474                              <1> 	; OUTPUT ->
 42475                              <1> 	;  cf = 0 -> write OK...
 42476                              <1> 	;  cf = 1 -> error code in AL (EAX)
 42477                              <1> 	;  cf = 1 & AL = 0Dh => CH & CL = FS & FAT type
 42478                              <1> 	;  EBX = Directory Buffer Address
 42479                              <1> 	;
 42480                              <1> 	;  (EAX, ECX, EDX will be modified)
 42481                              <1>  
 42482 0000AF13 BB00000800          <1> 	mov	ebx, Directory_Buffer
 42483 0000AF18 803D[697F0100]02    <1> 	cmp	byte [DirBuff_ValidData], 2
 42484 0000AF1F 7403                <1> 	je	short loc_save_dir_buffer
 42485 0000AF21 31C0                <1> 	xor	eax, eax
 42486 0000AF23 C3                  <1> 	retn            
 42487                              <1> 
 42488                              <1> loc_save_dir_buffer:
 42489 0000AF24 56                  <1> 	push	esi
 42490 0000AF25 31DB                <1> 	xor	ebx, ebx 
 42491 0000AF27 8A3D[677F0100]      <1>         mov     bh, [DirBuff_DRV]
 42492 0000AF2D 80EF41              <1> 	sub	bh, 'A'
 42493 0000AF30 BE00010900          <1>         mov     esi, Logical_DOSDisks
 42494 0000AF35 01DE                <1> 	add	esi, ebx
 42495 0000AF37 668B4E03            <1>         mov     cx, [esi+LD_FATType]
 42496                              <1> 	; CH = FS Type (A1h for FS)
 42497                              <1> 	; CL = FAT Type (0 for FS)
 42498 0000AF3B 08C9                <1> 	or	cl, cl
 42499 0000AF3D 7431                <1> 	jz	short loc_save_dir_buff_stc_retn
 42500                              <1> 
 42501                              <1> loc_save_dir_buffer_check_cluster_no:    
 42502 0000AF3F A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 42503 0000AF44 28FF                <1> 	sub	bh, bh ; ebx = 0
 42504 0000AF46 09C0                <1> 	or	eax, eax
 42505 0000AF48 753E                <1> 	jnz	short loc_save_sub_dir_buffer
 42506 0000AF4A 8A25[687F0100]      <1> 	mov	ah, [DirBuff_FATType]
 42507 0000AF50 FEC3                <1> 	inc	bl ;  bl = 1
 42508 0000AF52 38DC                <1> 	cmp	ah, bl
 42509 0000AF54 721B                <1> 	jb	short loc_save_dir_buff_inv_data_retn
 42510 0000AF56 FEC3                <1> 	inc	bl ; bl = 2
 42511 0000AF58 38E3                <1> 	cmp	bl, ah
 42512 0000AF5A 7215                <1> 	jb	short loc_save_dir_buff_inv_data_retn
 42513                              <1> 
 42514                              <1> loc_save_root_dir_buffer:
 42515 0000AF5C 668B5E17            <1> 	mov	bx, [esi+LD_BPB+RootDirEnts]
 42516 0000AF60 6683C30F            <1> 	add	bx, 15
 42517                              <1> 	;shr	bx, 4 ; 16 dir entries per sector
 42518                              <1> 	; 29/07/2022
 42519 0000AF64 C1EB04              <1> 	shr	ebx, 4
 42520                              <1> 	;or	bx, bx
 42521 0000AF67 09DB                <1> 	or	ebx, ebx
 42522 0000AF69 7405                <1> 	jz	short loc_save_dir_buff_stc_retn
 42523                              <1> 	;mov	ecx, ebx 
 42524 0000AF6B 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin] ; 26/02/2016
 42525 0000AF6E EB22                <1> 	jmp	short loc_write_directory_to_disk
 42526                              <1> 
 42527                              <1> loc_save_dir_buff_stc_retn:
 42528 0000AF70 F9                  <1> 	stc
 42529                              <1> loc_save_dir_buff_inv_data_retn:
 42530                              <1> 	; 15/10/2016 (0Dh -> 29)
 42531 0000AF71 B01D                <1> 	mov	al, 29 ; Invalid data !
 42532 0000AF73 C605[697F0100]00    <1> 	mov	byte [DirBuff_ValidData], 0
 42533 0000AF7A EB05                <1> 	jmp	short loc_save_dir_buff_retn 
 42534                              <1> 
 42535                              <1> loc_write_directory_to_disk_err:
 42536                              <1> 	; 15/10/2016 (disk write error code, 1Dh -> 18)
 42537 0000AF7C B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error 
 42538                              <1> 
 42539                              <1> loc_save_dir_buff_retn:
 42540 0000AF81 BB00000800          <1> 	mov	ebx, Directory_Buffer
 42541 0000AF86 5E                  <1> 	pop	esi
 42542 0000AF87 C3                  <1> 	retn
 42543                              <1>  
 42544                              <1> loc_save_sub_dir_buffer:
 42545                              <1> 	; ebx  = 0
 42546                              <1> 	;sub	eax, 2
 42547                              <1> 	; 30/07/2022
 42548 0000AF88 48                  <1> 	dec	eax
 42549 0000AF89 48                  <1> 	dec	eax
 42550 0000AF8A 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
 42551 0000AF8D F7E3                <1> 	mul	ebx
 42552 0000AF8F 034668              <1>         add     eax, [esi+LD_DATABegin]
 42553                              <1>  	;mov	ecx, ebx
 42554                              <1> 
 42555                              <1> loc_write_directory_to_disk:
 42556 0000AF92 89D9                <1>  	mov	ecx, ebx
 42557 0000AF94 BB00000800          <1> 	mov	ebx, Directory_Buffer
 42558 0000AF99 E87C6D0000          <1> 	call	disk_write
 42559 0000AF9E 72DC                <1> 	jc	short loc_write_directory_to_disk_err
 42560                              <1> 
 42561                              <1> loc_save_dir_buff_validate_retn:
 42562 0000AFA0 C605[697F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
 42563 0000AFA7 31C0                <1> 	xor	eax, eax
 42564                              <1> 	; 26/02/2016
 42565 0000AFA9 EBD6                <1> 	jmp	short loc_save_dir_buff_retn
 42566                              <1> 
 42567                              <1> update_parent_dir_lmdt:
 42568                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42569                              <1> 	; 29/12/2017
 42570                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
 42571                              <1> 	; 01/08/2011
 42572                              <1> 	; 16/10/2010 
 42573                              <1> 	; 
 42574                              <1> 	; INPUT -> 
 42575                              <1> 	;	none
 42576                              <1>  	; OUTPUT ->
 42577                              <1> 	;	(last modification date & time of the parent dir
 42578                              <1> 	;	will be changed/updated)
 42579                              <1> 	;
 42580                              <1> 	; (EAX, EBX, ECX, EDX, EDI will be changed)
 42581                              <1> 
 42582 0000AFAB 29C0                <1> 	sub	eax, eax
 42583 0000AFAD 8A25[40780100]      <1> 	mov	ah, [Current_Dir_Level]
 42584 0000AFB3 A0[41780100]        <1> 	mov	al, [Current_FATType]
 42585 0000AFB8 3C01                <1> 	cmp	al, 1
 42586 0000AFBA 7239                <1> 	jb	short loc_UPDLMDT_proc_retn
 42587                              <1>     
 42588                              <1> loc_update_parent_dir_lm_date_time:
 42589 0000AFBC 08E4                <1> 	or	ah, ah
 42590 0000AFBE 7435                <1> 	jz	short loc_UPDLMDT_proc_retn
 42591                              <1> 
 42592 0000AFC0 56                  <1> 	push	esi ; *
 42593 0000AFC1 8825[E0810100]      <1> 	mov	[UPDLMDT_CDirLevel], ah
 42594 0000AFC7 8B15[3C780100]      <1> 	mov	edx, [Current_Dir_FCluster]
 42595 0000AFCD 8915[E1810100]      <1> 	mov	[UPDLMDT_CDirFCluster], edx
 42596                              <1> 
 42597 0000AFD3 FECC                <1> 	dec	ah
 42598                              <1> 	;mov	ecx, 12
 42599                              <1>         ; 29/07/2022
 42600 0000AFD5 29C9                <1> 	sub	ecx, ecx
 42601 0000AFD7 B10C                <1> 	mov	cl, 12
 42602                              <1> 	;
 42603 0000AFD9 BE[A07F0100]        <1> 	mov     esi, PATH_Array
 42604                              <1> 
 42605 0000AFDE 8825[40780100]      <1> 	mov	[Current_Dir_Level], ah
 42606 0000AFE4 08E4                <1> 	or	ah, ah
 42607 0000AFE6 750E                <1> 	jnz	short loc_update_parent_dir_lmdt_load_sub_dir_1
 42608 0000AFE8 803D[41780100]02    <1> 	cmp	byte [Current_FATType], 2
 42609 0000AFEF 770B                <1> 	ja	short loc_update_parent_dir_lmdt_load_sub_dir_2
 42610 0000AFF1 28C0                <1> 	sub	al, al ; eax = 0
 42611 0000AFF3 EB0A                <1> 	jmp	short loc_update_parent_dir_lmdt_load_sub_dir_3
 42612                              <1> 
 42613                              <1> loc_UPDLMDT_proc_retn:
 42614 0000AFF5 C3                  <1> 	retn
 42615                              <1>          
 42616                              <1> loc_update_parent_dir_lmdt_load_sub_dir_1:
 42617 0000AFF6 B010                <1> 	mov	al, 16
 42618 0000AFF8 F6E4                <1> 	mul	ah 
 42619 0000AFFA 01C6                <1> 	add	esi, eax
 42620                              <1> 
 42621                              <1> loc_update_parent_dir_lmdt_load_sub_dir_2:  
 42622 0000AFFC 8B460C              <1> 	mov	eax, [esi+12] ; Parent Dir First Cluster
 42623                              <1> 
 42624                              <1> loc_update_parent_dir_lmdt_load_sub_dir_3:
 42625 0000AFFF A3[3C780100]        <1> 	mov	[Current_Dir_FCluster], eax
 42626                              <1> 
 42627 0000B004 83C610              <1> 	add	esi, 16
 42628 0000B007 66BF[C680]          <1> 	mov	di, Dir_File_Name  
 42629 0000B00B F3A4                <1> 	rep	movsb
 42630                              <1> 	
 42631 0000B00D BE00010900          <1> 	mov	esi, Logical_DOSDisks
 42632 0000B012 29DB                <1> 	sub	ebx, ebx
 42633 0000B014 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 42634 0000B01A 01DE                <1> 	add	esi, ebx
 42635 0000B01C E8E2F7FFFF          <1> 	call	reload_current_directory
 42636 0000B021 722F                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
 42637                              <1> 
 42638                              <1> loc_update_parent_dir_lmdt_locate_dir: 
 42639 0000B023 BE[C6800100]        <1> 	mov	esi, Dir_File_Name        
 42640                              <1> 	;xor	cx, cx
 42641                              <1> 	; 29/07/2022
 42642 0000B028 31C9                <1> 	xor	ecx, ecx
 42643 0000B02A 66B81008            <1> 	mov	ax, 0810h ; Only directories
 42644 0000B02E E80BF7FFFF          <1>         call    locate_current_dir_file
 42645                              <1> 	; EDI = DirBuff Directory Entry Address
 42646 0000B033 721D                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
 42647                              <1> 
 42648 0000B035 E844FEFFFF          <1> 	call	convert_current_date_time
 42649 0000B03A 66895712            <1> 	mov	[edi+18], dx ; Last Access Date
 42650 0000B03E 66895718            <1> 	mov	[edi+24], dx ; Last Write Date
 42651 0000B042 66894716            <1> 	mov	[edi+22], ax ; Last Write Time
 42652                              <1> 
 42653 0000B046 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 42654 0000B04D E8C1FEFFFF          <1> 	call	save_directory_buffer
 42655                              <1> 	; 29/12/2017
 42656                              <1> 	;jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
 42657                              <1> 	;xor	al, al 
 42658                              <1> loc_update_parent_dir_lmdt_restore_cdirlevel:
 42659                              <1>  	;current directory level restoration
 42660 0000B052 8A25[E0810100]      <1> 	mov	ah, [UPDLMDT_CDirLevel]
 42661 0000B058 8825[40780100]      <1> 	mov	[Current_Dir_Level], ah
 42662 0000B05E 8B15[E1810100]      <1>         mov     edx, [UPDLMDT_CDirFCluster]
 42663 0000B064 8915[3C780100]      <1> 	mov	[Current_Dir_FCluster], edx
 42664                              <1> 
 42665 0000B06A 5E                  <1> 	pop	esi ; *
 42666 0000B06B C3                  <1> 	retn
 42667                              <1> 
 42668                              <1> delete_longname:
 42669                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42670                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
 42671                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_longname')
 42672                              <1> 	; 14/03/2010
 42673                              <1> 	; INPUT ->
 42674                              <1> 	; 	EAX = Directory Entry (Index) Number (< 65536)
 42675                              <1> 	; OUTPUT ->
 42676                              <1> 	;	cf = 0 -> OK  (EAX = 0)
 42677                              <1> 	; 	cf = 1 -> error code in EAX (AL)
 42678                              <1> 	;
 42679                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
 42680                              <1> 
 42681 0000B06C 66A3[10820100]      <1> 	mov	[DLN_EntryNumber], ax
 42682 0000B072 C605[12820100]40    <1>         mov     byte [DLN_40h], 40h
 42683                              <1> 
 42684 0000B079 E857000000          <1> 	call	locate_current_dir_entry
 42685 0000B07E 7307                <1> 	jnc	short loc_dln_check_attributes
 42686 0000B080 C3                  <1> 	retn
 42687                              <1> 
 42688                              <1> loc_dln_longname_not_found:
 42689                              <1> 	;mov	eax, 2
 42690                              <1> 	; 29/07/2022
 42691 0000B081 29C0                <1> 	sub	eax, eax
 42692 0000B083 B002                <1> 	mov	al, 2
 42693 0000B085 F9                  <1> 	stc
 42694 0000B086 C3                  <1> 	retn
 42695                              <1> 
 42696                              <1> loc_dln_check_attributes:
 42697 0000B087 B00F                <1> 	mov	al, 0Fh  ; long name
 42698 0000B089 8A670B              <1> 	mov	ah, [edi+0Bh] ; dir entry attributes
 42699 0000B08C 38C4                <1> 	cmp	ah, al
 42700 0000B08E 75F1                <1> 	jne	short loc_dln_longname_not_found
 42701 0000B090 8A27                <1> 	mov	ah, [edi]
 42702 0000B092 2A25[12820100]      <1> 	sub	ah, [DLN_40h]
 42703 0000B098 76E7                <1> 	jna	short loc_dln_longname_not_found         
 42704 0000B09A 80FC14              <1> 	cmp	ah, 14h ; 84-64=20 -> 20*13=260 bytes
 42705 0000B09D 77E2                <1> 	ja	short loc_dln_longname_not_found
 42706                              <1>              
 42707 0000B09F C607E5              <1> 	mov	byte [edi], 0E5h  ; deleted sign
 42708 0000B0A2 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; changed/write sign
 42709 0000B0A9 C605[12820100]00    <1> 	mov	byte [DLN_40h], 0 ; 40h -> 0
 42710                              <1> 	  
 42711                              <1> loc_dln_delete_next_ln_entry:
 42712 0000B0B0 80FC01              <1> 	cmp	ah, 1
 42713 0000B0B3 7616                <1> 	jna	short loc_dln_longname_retn
 42714                              <1> loc_dln_delete_next_ln_entry_0:
 42715 0000B0B5 66FF05[10820100]    <1> 	inc	word [DLN_EntryNumber]
 42716 0000B0BC 0FB705[10820100]    <1> 	movzx	eax, word [DLN_EntryNumber] 
 42717 0000B0C3 E80D000000          <1> 	call	locate_current_dir_entry
 42718 0000B0C8 73BD                <1> 	jnc	short loc_dln_check_attributes
 42719                              <1> 
 42720                              <1> loc_dln_longname_stc_retn:
 42721 0000B0CA C3                  <1> 	retn 
 42722                              <1> 	   
 42723                              <1> loc_dln_longname_retn:
 42724                              <1> 	;cmp	byte [DirBuff_ValidData], 2
 42725                              <1> 	;jne	short loc_dln_longname_retn_xor_eax
 42726 0000B0CB E843FEFFFF          <1> 	call	save_directory_buffer
 42727 0000B0D0 72F8                <1> 	jc	short loc_dln_longname_stc_retn
 42728                              <1> 
 42729                              <1> loc_dln_longname_retn_xor_eax:
 42730 0000B0D2 31C0                <1> 	xor	eax, eax
 42731 0000B0D4 C3                  <1> 	retn
 42732                              <1> 
 42733                              <1> locate_current_dir_entry:
 42734                              <1> 	; 30/07/2022
 42735                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42736                              <1> 	; 16/10/2016
 42737                              <1> 	; 15/10/2016
 42738                              <1> 	; 23/03/2016
 42739                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
 42740                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_locate_current_dir_entry')
 42741                              <1> 	; 07/03/2010
 42742                              <1> 	; INPUT ->
 42743                              <1> 	;	EAX = Directory Entry (Index) Number (< 65536) 
 42744                              <1> 	; OUTPUT ->
 42745                              <1> 	;	EDI = Directory Entry Address
 42746                              <1> 	; 	EAX = Cluster Number of Directory Buffer
 42747                              <1> 	;	EBX = Directory Buffer Entry Offset
 42748                              <1> 	;	ECX = DirBuff Valid Data identifier (CL)
 42749                              <1> 	;   	If CF = 0 and CL = 2 then
 42750                              <1> 	;	   directory buffer modified and
 42751                              <1> 	;	   must be written to disk.
 42752                              <1> 	; 	If CF = 0  and CL = 1 then
 42753                              <1> 	;	   dir buffer has been written to disk, already.
 42754                              <1> 	;	CF = 1 -> Error code in EAX (AL)
 42755                              <1> 	;
 42756                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
 42757                              <1> 
 42758                              <1> loc_locate_current_dir_entry:
 42759 0000B0D5 56                  <1> 	push	esi
 42760 0000B0D6 89C1                <1> 	mov	ecx, eax
 42761                              <1> 	;mov	edx, 32
 42762                              <1> 	; 29/07/2022
 42763 0000B0D8 29D2                <1> 	sub	edx, edx
 42764 0000B0DA B220                <1> 	mov	dl, 32
 42765 0000B0DC F7E2                <1> 	mul	edx 
 42766 0000B0DE A3[1C820100]        <1> 	mov	[LCDE_ByteOffset], eax
 42767 0000B0E3 31DB                <1> 	xor	ebx, ebx
 42768 0000B0E5 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 42769 0000B0EB A0[677F0100]        <1>         mov     al, [DirBuff_DRV]
 42770 0000B0F0 2C41                <1> 	sub	al, 'A'
 42771 0000B0F2 BE00010900          <1>         mov     esi, Logical_DOSDisks
 42772 0000B0F7 01DE                <1> 	add	esi, ebx
 42773 0000B0F9 38C7                <1> 	cmp	bh, al
 42774                              <1> 	;jne	loc_lcde_reload_current_directory
 42775                              <1> 	; 29/07/2022
 42776 0000B0FB 7405                <1> 	je	short loc_lcde_cdl_check
 42777 0000B0FD E986000000          <1> 	jmp	loc_lcde_reload_current_directory
 42778                              <1> loc_lcde_cdl_check:
 42779                              <1> 	; 29/07/2022
 42780 0000B102 31C0                <1> 	xor	eax, eax
 42781 0000B104 803D[40780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
 42782 0000B10B 7728                <1> 	ja	short loc_lcde_calc_dirbuff_cluster_offset
 42783                              <1> 	; 27/02/2016
 42784                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
 42785                              <1> 	; (Root Directory Entries for FAT32 = 0)
 42786 0000B10D 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
 42787 0000B111 7322                <1> 	jnb	short loc_lcde_calc_dirbuff_cluster_offset
 42788                              <1> 
 42789                              <1> loc_lcde_cdl_check_FAT12_16:
 42790                              <1> 	; 29/07/2022
 42791                              <1> 	;xor	eax, eax
 42792 0000B113 668B4617            <1> 	mov	ax, [esi+LD_BPB+RootDirEnts]
 42793                              <1> 	;dec	ax
 42794 0000B117 48                  <1> 	dec	eax
 42795                              <1> 	;xor	dx, dx  
 42796                              <1> 	;cmp	ax, cx ; cx = Directory Entry (Index) Number
 42797                              <1> 	; 29/07/2022
 42798 0000B118 39C8                <1> 	cmp	eax, ecx
 42799 0000B11A 720E                <1> 	jb	short loc_lcde_stc_12h_retn
 42800 0000B11C 66890D[14820100]    <1> 	mov	[LCDE_EntryIndex], cx
 42801 0000B123 31C0                <1> 	xor	eax, eax
 42802 0000B125 E985000000          <1>         jmp     loc_lcde_check_dir_buffer_cluster
 42803                              <1> 
 42804                              <1> loc_lcde_stc_12h_retn:
 42805 0000B12A 5E                  <1> 	pop	esi
 42806 0000B12B 89CB                <1> 	mov	ebx, ecx
 42807 0000B12D 89D1                <1> 	mov	ecx, edx
 42808                              <1> 	; 16/10/2016 (12h -> 12)
 42809 0000B12F B80C000000          <1> 	mov	eax, 12 ; No more files
 42810 0000B134 C3                  <1> 	retn 
 42811                              <1> 
 42812                              <1> loc_lcde_calc_dirbuff_cluster_offset:
 42813                              <1> 	;mov	bl, [esi+LD_BPB+SecPerClust]
 42814                              <1> 	;xor	bh, bh
 42815                              <1> 	;mov	ax, [esi+LD_BPB+BytesPerSec]
 42816                              <1> 	;mul	bx
 42817                              <1>  	;;or	dx, dx ; If bytes per cluster > 32KB it is invalid
 42818                              <1> 	;; 29/07/2022
 42819                              <1> 	;or	dl, dl
 42820                              <1> 	;jnz	short loc_lcde_invalid_format
 42821                              <1> 	; 29/07/2022
 42822 0000B135 31DB                <1> 	xor	ebx, ebx
 42823 0000B137 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
 42824 0000B13A 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
 42825 0000B13E F7E3                <1> 	mul	ebx
 42826 0000B140 89C1                <1> 	mov	ecx, eax
 42827                              <1> 	;mov	cx, ax ; BYTES PER CLUSTER
 42828 0000B142 A1[1C820100]        <1> 	mov	eax, [LCDE_ByteOffset]
 42829                              <1> 	;sub	edx, edx
 42830 0000B147 F7F1                <1> 	div	ecx
 42831 0000B149 3DFFFF0000          <1> 	cmp	eax, 65535
 42832 0000B14E 7746                <1> 	ja	short loc_lcde_invalid_format
 42833                              <1> 
 42834                              <1> 	; cluster sequence number of directory (< 65536)
 42835 0000B150 66A3[16820100]      <1> 	mov	[LCDE_ClusterSN], ax 
 42836                              <1> 
 42837                              <1> 	;mov	ax, dx ; byte offset in cluster (directory buffer)
 42838                              <1> 	; 29/07/2022
 42839 0000B156 89D0                <1> 	mov	eax, edx
 42840                              <1> 	;mov	bx, 32	; 1 dir entry = 32 bytes
 42841 0000B158 B320                <1>         mov	bl, 32
 42842                              <1> 	;sub	dx, dx	; 0
 42843                              <1> 	;div	bx 
 42844 0000B15A 29D2                <1> 	sub	edx, edx
 42845 0000B15C F7F3                <1> 	div	ebx
 42846 0000B15E 66A3[14820100]      <1> 	mov	[LCDE_EntryIndex], ax ; dir entry index/sequence number
 42847                              <1> 				      ; (in directory buffer/cluster)	  
 42848                              <1> loc_lcde_get_current_sub_dir_fcluster:
 42849 0000B164 A1[3C780100]        <1> 	mov	eax, [Current_Dir_FCluster]
 42850                              <1> 
 42851                              <1> loc_lcde_get_next_cluster:
 42852 0000B169 66833D[16820100]00  <1> 	cmp	word [LCDE_ClusterSN], 0
 42853 0000B171 763C                <1> 	jna	short loc_lcde_check_dir_buffer_cluster
 42854 0000B173 A3[18820100]        <1> 	mov	[LCDE_Cluster], eax
 42855 0000B178 E80D100000          <1> 	call	get_next_cluster
 42856 0000B17D 721E                <1> 	jc	short loc_lcde_check_gnc_error
 42857 0000B17F 66FF0D[16820100]    <1>   	dec	word [LCDE_ClusterSN]
 42858 0000B186 EBE1                <1> 	jmp	short loc_lcde_get_next_cluster
 42859                              <1> 
 42860                              <1> loc_lcde_reload_current_directory:
 42861 0000B188 51                  <1> 	push	ecx
 42862 0000B189 E875F6FFFF          <1> 	call	reload_current_directory
 42863 0000B18E 59                  <1> 	pop	ecx
 42864                              <1> 	;jnc	loc_lcde_cdl_check
 42865                              <1> 	;pop	esi
 42866                              <1> 	;retn
 42867                              <1> 	; 09/08/2022
 42868 0000B18F 727E                <1> 	jc	short loc_lcde_retn
 42869 0000B191 E96CFFFFFF          <1> 	jmp	loc_lcde_cdl_check
 42870                              <1> 
 42871                              <1> loc_lcde_invalid_format:
 42872                              <1> 	; 15/10/2016 (0Bh -> 28)
 42873                              <1> 	;mov	eax, 28 ; Invalid Format !
 42874                              <1> 	; 29/07/2022
 42875 0000B196 29C0                <1> 	sub	eax, eax
 42876 0000B198 B01C                <1> 	mov	al, 28
 42877                              <1> loc_lcde_drive_not_ready_read_err:
 42878 0000B19A F9                  <1> 	stc
 42879 0000B19B 5E                  <1> 	pop	esi 
 42880 0000B19C C3                  <1> 	retn  
 42881                              <1> 
 42882                              <1> loc_lcde_check_gnc_error:
 42883 0000B19D 09C0                <1> 	or	eax, eax
 42884 0000B19F 75F9                <1> 	jnz	short loc_lcde_drive_not_ready_read_err
 42885 0000B1A1 66FF0D[16820100]    <1> 	dec	word [LCDE_ClusterSN]
 42886 0000B1A8 75EC                <1> 	jnz	short loc_lcde_invalid_format 
 42887 0000B1AA A1[18820100]        <1> 	mov	eax, [LCDE_Cluster]
 42888                              <1> 
 42889                              <1> loc_lcde_check_dir_buffer_cluster:
 42890 0000B1AF 3B05[6E7F0100]      <1> 	cmp	eax, [DirBuff_Cluster]
 42891 0000B1B5 755A                <1> 	jne	short loc_lcde_load_dir_cluster
 42892 0000B1B7 803D[697F0100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
 42893 0000B1BE 7726                <1> 	ja	short lcde_check_dir_buffer_cluster_next
 42894 0000B1C0 803D[40780100]00    <1> 	cmp	byte [Current_Dir_Level], 0    
 42895 0000B1C7 775D                <1> 	ja	short loc_lcde_load_dir_cluster_0
 42896                              <1> 	; 27/02/2016
 42897                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
 42898 0000B1C9 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
 42899 0000B1CD 7357                <1> 	jnb	short loc_lcde_load_dir_cluster_0
 42900                              <1> 	;
 42901 0000B1CF 0FB74E17            <1> 	movzx	ecx, word [esi+LD_BPB+RootDirEnts]
 42902 0000B1D3 6683C10F            <1> 	add	cx, 15 ; round up (16 entries per sector)
 42903                              <1> 	;shr	cx, 4 ; 1 sector contains 16 dir entries	
 42904                              <1> 	; 29/07/2022
 42905 0000B1D7 C1E904              <1> 	shr	ecx, 4
 42906 0000B1DA 8B4664              <1>         mov     eax, [esi+LD_ROOTBegin]
 42907 0000B1DD EB52                <1> 	jmp	short loc_lcde_load_dir_cluster_1 
 42908                              <1> 
 42909                              <1> loc_lcde_validate_dirBuff:
 42910 0000B1DF C605[697F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
 42911                              <1> 
 42912                              <1> lcde_check_dir_buffer_cluster_next:
 42913 0000B1E6 0FB71D[14820100]    <1> 	movzx	ebx, word [LCDE_EntryIndex]
 42914 0000B1ED 663B1D[6C7F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
 42915 0000B1F4 77A0                <1> 	ja	short loc_lcde_invalid_format 
 42916                              <1> 	;mov	eax, 32
 42917                              <1> 	; 29/07/2022
 42918 0000B1F6 31C0                <1> 	xor	eax, eax
 42919 0000B1F8 B020                <1> 	mov	al, 32
 42920 0000B1FA F7E3                <1> 	mul	ebx
 42921                              <1> 	;or	edx, edx
 42922                              <1> 	;jnz	short loc_lcde_invalid_format
 42923                              <1> 
 42924 0000B1FC BF00000800          <1> 	mov	edi, Directory_Buffer  
 42925 0000B201 01C7                <1> 	add	edi, eax ; add entry offset to buffer address
 42926                              <1> 
 42927                              <1> loc_lcde_dir_buffer_last_check:
 42928 0000B203 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 42929 0000B208 0FB60D[697F0100]    <1> 	movzx	ecx, byte [DirBuff_ValidData]
 42930                              <1> 
 42931                              <1> loc_lcde_retn:
 42932 0000B20F 5E                  <1> 	pop	esi
 42933 0000B210 C3                  <1> 	retn
 42934                              <1> 
 42935                              <1> loc_lcde_load_dir_cluster:
 42936                              <1> 	;cmp	byte [DirBuff_ValidData], 2
 42937                              <1> 	;jne	short loc_lcde_load_dir_cluster_n2
 42938 0000B211 50                  <1> 	push	eax
 42939 0000B212 E8FCFCFFFF          <1> 	call	save_directory_buffer
 42940 0000B217 58                  <1> 	pop	eax
 42941 0000B218 72F5                <1> 	jc	short loc_lcde_retn
 42942                              <1> 
 42943                              <1> loc_lcde_load_dir_cluster_n2:
 42944 0000B21A C605[697F0100]00    <1> 	mov	byte [DirBuff_ValidData], 0
 42945 0000B221 A3[6E7F0100]        <1> 	mov	[DirBuff_Cluster], eax
 42946                              <1> 
 42947                              <1> loc_lcde_load_dir_cluster_0:
 42948                              <1> 	;sub	eax, 2
 42949                              <1> 	; 30/07/2022
 42950 0000B226 48                  <1> 	dec	eax
 42951 0000B227 48                  <1> 	dec	eax
 42952 0000B228 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 42953 0000B22C F7E1                <1> 	mul	ecx
 42954 0000B22E 034668              <1>         add     eax, [esi+LD_DATABegin]
 42955                              <1> 
 42956                              <1> loc_lcde_load_dir_cluster_1:
 42957 0000B231 BB00000800          <1> 	mov	ebx, Directory_Buffer
 42958                              <1> 	; ecx = sector count
 42959 0000B236 E8EE6A0000          <1> 	call	disk_read
 42960 0000B23B 73A2                <1> 	jnc	short loc_lcde_validate_dirBuff
 42961                              <1> 
 42962                              <1> 	; 15/10/2016 
 42963                              <1> 	; (Disk read error instead of drv not ready err)
 42964 0000B23D B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 42965 0000B242 EBCB                <1> 	jmp	short loc_lcde_retn
 42966                              <1> 
 42967                              <1> 
 42968                              <1> remove_file:
 42969                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 42970                              <1> 	; 15/10/2016
 42971                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
 42972                              <1> 	; 10/04/2011 (FILE.ASM, 'proc_delete_file')
 42973                              <1> 	; 09/08/2010
 42974                              <1> 	; INPUT ->
 42975                              <1> 	;	EDI = Directory Buffer Entry Address
 42976                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
 42977                              <1> 	;	 BL = Longname Entry Length
 42978                              <1> 	;	 BH = Logical DOS Drive Number 
 42979                              <1> 
 42980 0000B244 29C0                <1> 	sub	eax, eax
 42981 0000B246 88FC                <1> 	mov	ah, bh
 42982 0000B248 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 42983 0000B24D 01C6                <1> 	add	esi, eax
 42984                              <1> 
 42985 0000B24F 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
 42986 0000B253 7311                <1> 	jnb	short loc_del_fat_file 
 42987                              <1>               
 42988 0000B255 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
 42989 0000B259 7406                <1> 	je	short loc_del_fs_file
 42990                              <1> 
 42991                              <1> loc_del_file_invalid_format:
 42992 0000B25B 30E4                <1> 	xor	ah, ah
 42993                              <1> 	; 15/10/2016 (0Bh -> 28)
 42994 0000B25D B01C                <1> 	mov	al, 28  ; Invalid Format
 42995 0000B25F F9                  <1> 	stc 
 42996 0000B260 C3                  <1> 	retn
 42997                              <1> 
 42998                              <1> loc_del_fs_file:
 42999                              <1> 	;call	delete_fs_file
 43000                              <1> 	;retn
 43001                              <1> 	; 29/07/2022
 43002 0000B261 E9230F0000          <1> 	jmp	delete_fs_file	
 43003                              <1> 
 43004                              <1> loc_del_fat_file:
 43005 0000B266 E808000000          <1> 	call	delete_directory_entry
 43006 0000B26B 7205                <1> 	jc	short loc_del_file_err_retn 
 43007                              <1> 
 43008                              <1> loc_delfile_unlink_cluster_chain:
 43009 0000B26D E8C8160000          <1> 	call	truncate_cluster_chain
 43010                              <1> 	;jc	short loc_del_file_err_retn
 43011                              <1> 
 43012                              <1> loc_delfile_return:
 43013                              <1> loc_del_file_err_retn:
 43014 0000B272 C3                  <1> 	retn
 43015                              <1> 
 43016                              <1> delete_directory_entry:
 43017                              <1> 	; 15/10/2016
 43018                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
 43019                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_directory_entry')
 43020                              <1> 	; 10/04/2011 
 43021                              <1> 	; INPUT ->
 43022                              <1> 	; 	ESI = Logical Dos Drive Descripton Table Address 
 43023                              <1> 	;	EDI = Directory Buffer Entry Address
 43024                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
 43025                              <1> 	;	 BL = Longname Entry Length
 43026                              <1> 	; OUTPUT ->
 43027                              <1> 	; 	ESI = Logical dos drive descripton table address 
 43028                              <1> 	;	EAX = First cluster to be truncated/unlinked
 43029                              <1> 	;       CF = 1 -> Error code in EAX (AL)
 43030                              <1> 	;       CF = 0 & BH <> 0 -> LMDT write error  (BH = 1)
 43031                              <1> 	;       CF = 0 & BL <> 0 -> Long name delete error (BL = FFh) 
 43032                              <1> 	;
 43033                              <1> 	;  (EDI, EBX, ECX register contents will be changed)
 43034                              <1> 
 43035 0000B273 881D[AA810100]      <1> 	mov	[DelFile_LNEL], bl
 43036 0000B279 66890D[A8810100]    <1> 	mov	[DelFile_EntryCounter], cx
 43037                              <1> 
 43038 0000B280 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
 43039 0000B284 C1E010              <1> 	shl	eax, 16
 43040 0000B287 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
 43041                              <1> 
 43042 0000B28B A3[A4810100]        <1> 	mov	[DelFile_FCluster], eax
 43043                              <1> 
 43044                              <1> loc_del_short_name:
 43045 0000B290 C607E5              <1> 	mov	byte [edi], 0E5h  ; Deleted sign
 43046                              <1> 
 43047 0000B293 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 43048 0000B29A E874FCFFFF          <1> 	call	save_directory_buffer
 43049 0000B29F 723D                <1> 	jc	short loc_delete_direntry_err_return
 43050                              <1>  
 43051                              <1> loc_del_long_name:
 43052 0000B2A1 0FB615[AA810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
 43053 0000B2A8 08D2                <1> 	or	dl, dl
 43054 0000B2AA 7416                <1> 	jz	short loc_del_dir_entry_update_parent_dir_lm_date
 43055                              <1> 
 43056 0000B2AC 8835[AA810100]      <1> 	mov	[DelFile_LNEL], dh ; 0              
 43057                              <1>   
 43058 0000B2B2 0FB705[A8810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
 43059 0000B2B9 29D0                <1> 	sub	eax, edx
 43060                              <1> 	;jnc	short loc_del_long_name_continue
 43061 0000B2BB 7205                <1> 	jc	short loc_del_dir_entry_update_parent_dir_lm_date   
 43062                              <1> 
 43063                              <1> ;loc_del_direntry_inv_data_return: ; 15/10/2016 (0Dh -> 29)
 43064                              <1> ;	mov	eax, 29 ; 0Dh (TRDOS 8086) ; Invalid data
 43065                              <1> ;	retn
 43066                              <1> 
 43067                              <1> loc_del_long_name_continue: 
 43068                              <1> 	; AX = Directory Entry Number of the long name last entry
 43069 0000B2BD E8AAFDFFFF          <1> 	call	delete_longname
 43070                              <1> 	;jc	short loc_delete_direntry_err_return
 43071                              <1> 
 43072                              <1> loc_del_dir_entry_update_parent_dir_lm_date:
 43073 0000B2C2 801D[AA810100]00    <1> 	sbb	byte [DelFile_LNEL], 0 ; 0FFh if cf = 1
 43074                              <1> 
 43075 0000B2C9 E8DDFCFFFF          <1> 	call	update_parent_dir_lmdt
 43076 0000B2CE B700                <1> 	mov	bh, 0
 43077 0000B2D0 80D700              <1> 	adc	bh, 0
 43078                              <1> 
 43079 0000B2D3 8A1D[AA810100]      <1> 	mov	bl, byte [DelFile_LNEL]
 43080                              <1>  
 43081                              <1> loc_delete_direntry_return:
 43082 0000B2D9 A1[A4810100]        <1> 	mov	eax, [DelFile_FCluster]
 43083                              <1> loc_delete_direntry_err_return:
 43084 0000B2DE C3                  <1> 	retn
 43085                              <1> 
 43086                              <1> rename_directory_entry:
 43087                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 43088                              <1> 	; 13/11/2017
 43089                              <1> 	; 15/10/2016
 43090                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
 43091                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_rename_directory_entry')
 43092                              <1> 	; 19/11/2010
 43093                              <1> 	; INPUT -> (Current Directory)
 43094                              <1> 	;	CX = Directory Entry Number
 43095                              <1> 	;      EAX = First Cluster number of file or directory
 43096                              <1> 	;      EBX = Longname Length (dir entry count) (< 256)
 43097                              <1> 	;      ESI = New file (or directory) name (no path).
 43098                              <1> 	;           (ASCIIZ string)  
 43099                              <1> 	; OUTPUT -> 
 43100                              <1> 	;      CF = 0 -> successfull
 43101                              <1> 	;      CF = 1 -> error code in EAX (AL)
 43102                              <1> 	;
 43103                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
 43104                              <1> 
 43105 0000B2DF 803D[41780100]00    <1> 	cmp	byte [Current_FATType], 0
 43106 0000B2E6 7705                <1> 	ja	short loc_rename_directory_entry
 43107                              <1> 
 43108                              <1> 	;call	rename_fs_file_or_directory
 43109                              <1> 	;retn
 43110                              <1> 	; 29/07/2022
 43111 0000B2E8 E99C0E0000          <1>  	jmp	rename_fs_file_or_directory	
 43112                              <1> 	
 43113                              <1> loc_rename_directory_entry:
 43114 0000B2ED 881D[AA810100]      <1> 	mov	[DelFile_LNEL], bl
 43115 0000B2F3 66890D[A8810100]    <1> 	mov	[DelFile_EntryCounter], cx
 43116 0000B2FA A3[A4810100]        <1> 	mov	[DelFile_FCluster], eax
 43117                              <1> 
 43118 0000B2FF 0FB7C1              <1> 	movzx	eax, cx
 43119 0000B302 E8CEFDFFFF          <1> 	call	locate_current_dir_entry
 43120 0000B307 7307                <1> 	jnc	short loc_rename_direntry_check_fcluster
 43121                              <1> 
 43122                              <1> loc_rename_direntry_pop_retn:
 43123 0000B309 C3                  <1> 	retn
 43124                              <1> 
 43125                              <1> loc_rename_direntry_pop_invd_retn:
 43126                              <1> 	; 29/07/2022
 43127                              <1> 	;stc
 43128                              <1> loc_rename_direntry_invd_retn:
 43129                              <1> 	; 15/10/2016 (0Dh -> 29)
 43130                              <1> 	;mov	eax, 29 ; Invalid data
 43131                              <1> 	; 29/07/2022
 43132 0000B30A 29C0                <1> 	sub	eax, eax
 43133 0000B30C B01D                <1> 	mov	al, 29
 43134 0000B30E F9                  <1> 	stc
 43135                              <1> loc_rename_retn:
 43136 0000B30F C3                  <1> 	retn 
 43137                              <1> 
 43138                              <1> loc_rename_direntry_check_fcluster:
 43139 0000B310 668B5714            <1> 	mov	dx, [edi+20] ; First Cluster HW
 43140 0000B314 C1E210              <1> 	shl	edx, 16 ; 13/11/2017
 43141 0000B317 668B571A            <1> 	mov	dx, [edi+26] ; First Cluster LW
 43142 0000B31B 3B15[A4810100]      <1> 	cmp	edx, [DelFile_FCluster]
 43143 0000B321 75E7                <1> 	jne	short loc_rename_direntry_pop_invd_retn
 43144                              <1> 	; ESI = New file (or directory) name. (ASCIIZ string)
 43145                              <1> 	; 06/03/2016
 43146                              <1> 	; TRDOS v2 - NOTE: 'convert_file_name' procedure
 43147                              <1> 	; has been modified for eliminating following situation.
 43148                              <1> 	; 
 43149                              <1> 	; TRDOS v1 - NOTE: If file/dir name is more than 11 bytes
 43150                              <1> 	; without a dot, attributes (edi+11) byte will be overwritten !
 43151                              <1> 	; (Dot file name input must be proper for 11 byte dir entry
 43152                              <1> 	;  type file name output.) 
 43153 0000B323 E8E5F6FFFF          <1> 	call	convert_file_name
 43154                              <1> 
 43155 0000B328 C605[697F0100]02    <1>         mov     byte [DirBuff_ValidData], 2
 43156 0000B32F E8DFFBFFFF          <1> 	call	save_directory_buffer
 43157 0000B334 72D9                <1> 	jc	short loc_rename_retn
 43158                              <1> 
 43159                              <1> loc_rename_direntry_del_ln:
 43160 0000B336 0FB615[AA810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
 43161 0000B33D 08D2                <1> 	or	dl, dl
 43162 0000B33F 7410                <1> 	jz	short loc_rename_direntry_update_parent_dir_lm_date
 43163                              <1> 
 43164 0000B341 0FB705[A8810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
 43165 0000B348 29D0                <1> 	sub	eax, edx
 43166 0000B34A 72BE                <1> 	jc	short loc_rename_direntry_invd_retn
 43167                              <1> 
 43168                              <1> loc_rename_direntry_del_ln_continue: 
 43169                              <1> 	; EAX = Directory Entry Number of the long name last entry
 43170 0000B34C E81BFDFFFF          <1> 	call	delete_longname
 43171                              <1> 
 43172                              <1> loc_rename_direntry_update_parent_dir_lm_date:
 43173 0000B351 E855FCFFFF          <1> 	call	update_parent_dir_lmdt
 43174 0000B356 31C0                <1> 	xor	eax, eax 
 43175 0000B358 C3                  <1> 	retn
 43176                              <1> 
 43177                              <1> move_source_file_to_destination_file:
 43178                              <1> 	; 07/08/2022
 43179                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 43180                              <1> 	; 15/10/2016
 43181                              <1> 	; 11/03/2016
 43182                              <1> 	; 10/03/2016 (TRDOS 386 = TRDOS v2.0)
 43183                              <1> 	; 01/08/2011 (FILE.ASM)
 43184                              <1> 	; 04/08/2010
 43185                              <1> 	;
 43186                              <1> 	;   Phase 1 -> Check destination file, 
 43187                              <1> 	;              'not found' is required
 43188                              <1> 	;   Phase 2 -> Check source file
 43189                              <1> 	;              'found' and proper attributes is required
 43190                              <1> 	;   Phase 3 -> Make destination directory entry,
 43191                              <1> 	;           add new dir cluster or section if it is required
 43192                              <1> 	;   Phase 4 -> Delete source directory entry.
 43193                              <1> 	;       cf = 1 causes to return before the phase 4.
 43194                              <1> 	;    (source file protection against any possible errors)    
 43195                              <1> 	;
 43196                              <1> 	; 08/05/2011 major modification
 43197                              <1> 	;            -> destination file deleting is removed   
 43198                              <1> 	;            for msdos move/rename compatibility.
 43199                              <1> 	;            (Access denied error will return if
 43200                              <1> 	;            the destination file is found...)
 43201                              <1> 	; INPUT ->
 43202                              <1> 	;	 ESI = Source File Pathname (Asciiz)
 43203                              <1> 	;        EDI = Destination File Pathname (Asciiz)
 43204                              <1> 	;        AL = 0 --> Interrupt (System call)
 43205                              <1> 	;        AL > 0 --> Command Interpreter (Question)
 43206                              <1> 	;        AL = 1 --> Question Phase
 43207                              <1> 	;        AL = 2 --> Progress Phase        
 43208                              <1> 	; OUTPUT -> 
 43209                              <1> 	;	 cf = 0 -> OK
 43210                              <1> 	;        EAX = Destination directory first cluster
 43211                              <1> 	;        ESI = Logical DOS drive description table 
 43212                              <1> 	;        EBX = Destination file structure offset
 43213                              <1> 	;        CX = 0 (CX > 0 --> calculate free space error)
 43214                              <1> 	;        cf = 1 -> Error code in EAX (AL) 
 43215                              <1> 	;
 43216                              <1> 	;  (EDX, ECX, EBX, ESI, EDI will be changed)
 43217                              <1> 
 43218 0000B359 3C02                <1> 	cmp	al, 2
 43219                              <1> 	;je	msftdf_df2_check_directory
 43220                              <1> 	; 29/07/2022
 43221 0000B35B 7505                <1> 	jne	short msftdf
 43222 0000B35D E97B010000          <1> 	jmp	msftdf_df2_check_directory
 43223                              <1> msftdf:
 43224 0000B362 A2[2A830100]        <1> 	mov	[move_cmd_phase], al
 43225                              <1> 
 43226                              <1> msftdf_parse_sf_path:
 43227                              <1> 	; ESI = ASCIIZ pathname (Source)
 43228 0000B367 57                  <1> 	push	edi 
 43229 0000B368 BF[28820100]        <1> 	mov	edi, SourceFile_Drv
 43230 0000B36D E865F7FFFF          <1> 	call	parse_path_name
 43231 0000B372 5E                  <1> 	pop	esi
 43232 0000B373 7211                <1> 	jc	short msftdf_psf_retn
 43233                              <1> 
 43234                              <1> msftdf_parse_df_path:
 43235                              <1> 	; ESI = ASCIIZ pathname	(Destination)
 43236 0000B375 BF[A8820100]        <1> 	mov	edi, DestinationFile_Drv
 43237 0000B37A E858F7FFFF          <1> 	call	parse_path_name
 43238 0000B37F 7306                <1> 	jnc	short msftdf_check_sf_drv
 43239                              <1> 
 43240 0000B381 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
 43241 0000B383 7602                <1> 	jna	short msftdf_check_sf_drv
 43242                              <1> 
 43243                              <1> msftdf_stc_retn:
 43244 0000B385 F9                  <1> 	stc
 43245                              <1> msftdf_psf_retn:
 43246 0000B386 C3                  <1> 	retn 
 43247                              <1> 
 43248                              <1> msftdf_check_sf_drv:
 43249 0000B387 A0[28820100]        <1> 	mov	al, [SourceFile_Drv]
 43250                              <1> 
 43251                              <1> msftdf_check_df_drv:
 43252 0000B38C 8A15[A8820100]      <1> 	mov	dl, [DestinationFile_Drv]
 43253                              <1> 
 43254                              <1> msftdf_compare_sf_df_drv:
 43255 0000B392 29DB                <1> 	sub	ebx, ebx
 43256 0000B394 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 43257 0000B39A 38C2                <1> 	cmp	dl, al
 43258 0000B39C 7408                <1> 	je	short msftdf_check_sf_df_drv_ok
 43259                              <1> 
 43260                              <1> msftdf_not_same_drv:
 43261                              <1>         ; DL = source file's drive number
 43262 0000B39E 88C6                <1> 	mov	dh, al ; destination file's drive number
 43263                              <1> 	; 15/10/2016 (11h -> 21)
 43264                              <1> 	;mov	eax, 21 ; Not the same drive
 43265                              <1> 	; 29/07/2022
 43266 0000B3A0 29C0                <1> 	sub	eax, eax
 43267 0000B3A2 B015                <1> 	mov	al, 21
 43268 0000B3A4 F9                  <1> 	stc
 43269 0000B3A5 C3                  <1> 	retn 
 43270                              <1> 
 43271                              <1> msftdf_check_sf_df_drv_ok:
 43272 0000B3A6 8815[2B830100]      <1> 	mov	[msftdf_sf_df_drv], dl
 43273                              <1> 
 43274 0000B3AC 29C0                <1>         sub	eax, eax
 43275 0000B3AE 88D4                <1> 	mov	ah, dl
 43276 0000B3B0 0500010900          <1> 	add	eax, Logical_DOSDisks
 43277 0000B3B5 A3[2C830100]        <1> 	mov	[msftdf_drv_offset], eax
 43278                              <1> 
 43279 0000B3BA 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
 43280 0000B3BC 7407                <1> 	je	short msftdf_df_check_directory
 43281                              <1> 
 43282                              <1> msftdf_change_drv:
 43283 0000B3BE E8A0C3FFFF          <1> 	call 	change_current_drive
 43284 0000B3C3 726D                <1> 	jc	short msftdf_df_error_retn
 43285                              <1> 	  
 43286                              <1> msftdf_check_destination_file:
 43287                              <1> msftdf_df_check_directory:
 43288 0000B3C5 BE[A9820100]        <1> 	mov	esi, DestinationFile_Directory
 43289 0000B3CA 803E20              <1> 	cmp	byte [esi], 20h
 43290 0000B3CD 760F                <1> 	jna	short msftdf_df_find_1
 43291                              <1> 
 43292                              <1> msftdf_df_change_directory:
 43293 0000B3CF FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43294 0000B3D5 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 43295 0000B3D7 E80FF1FFFF          <1> 	call	change_current_directory
 43296 0000B3DC 7254                <1> 	jc	short msftdf_df_error_retn
 43297                              <1> 
 43298                              <1> ;msftdf_df_change_prompt_dir_string:
 43299                              <1> ;	call 	change_prompt_dir_string
 43300                              <1> 
 43301                              <1> msftdf_df_find_1:
 43302 0000B3DE BE[EA820100]        <1>         mov     esi, DestinationFile_Name
 43303 0000B3E3 803E20              <1> 	cmp	byte [esi], 20h
 43304 0000B3E6 7632                <1> 	jna	short msftdf_df_copy_sf_name
 43305                              <1> 
 43306                              <1> msftdf_df_find_2:
 43307 0000B3E8 6631C0              <1> 	xor	ax, ax ; DestinationFile_AttributesMask -> any/zero
 43308 0000B3EB E821D6FFFF          <1> 	call	find_first_file
 43309                              <1> 	;jnc	msftdf_permission_denied_retn
 43310                              <1> 	; 29/07/2022
 43311 0000B3F0 7205                <1> 	jc	short msftdf_df_check_error_code
 43312 0000B3F2 E98B000000          <1> 	jmp	msftdf_permission_denied_retn 
 43313                              <1> 
 43314                              <1> msftdf_df_check_error_code:
 43315                              <1> 	;cmp	eax, 2 ; File not found error
 43316 0000B3F7 3C02                <1> 	cmp	al, 2
 43317 0000B3F9 7536                <1> 	jne	short msftdf_df_stc_retn
 43318                              <1>               
 43319                              <1> msftdf_df_check_fname:
 43320                              <1> 	; 15/10/2016
 43321 0000B3FB BE[EA820100]        <1> 	mov	esi, DestinationFile_Name ; *
 43322 0000B400 E8B1D9FFFF          <1> 	call	check_filename
 43323 0000B405 7307                <1> 	jnc	short msftdf_convert_df_direntry_name
 43324                              <1> 	; invalid file name chars !
 43325 0000B407 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26
 43326 0000B40C EB23                <1> 	jmp	short msftdf_df_stc_retn
 43327                              <1> 
 43328                              <1> msftdf_convert_df_direntry_name:
 43329                              <1> 	; mov	esi, DestinationFile_Name ; *
 43330 0000B40E BF[FA820100]        <1> 	mov	edi, DestinationFile_DirEntry
 43331 0000B413 E8F5F5FFFF          <1> 	call	convert_file_name
 43332 0000B418 EB19                <1>   	jmp	short msftdf_restore_current_dir_1
 43333                              <1> 
 43334                              <1> msftdf_df_copy_sf_name:
 43335 0000B41A 89F7                <1> 	mov	edi, esi
 43336 0000B41C 57                  <1> 	push	edi 
 43337 0000B41D BE[6A820100]        <1>         mov     esi, SourceFile_Name
 43338                              <1> 	;mov	ecx, 12
 43339                              <1> 	; 29/07/2022
 43340 0000B422 29C9                <1> 	sub	ecx, ecx
 43341 0000B424 B10C                <1> 	mov	cl, 12
 43342                              <1> msftdf_df_copy_sf_name_loop:
 43343 0000B426 AC                  <1> 	lodsb
 43344 0000B427 AA                  <1>         stosb
 43345 0000B428 08C0                <1> 	or	al, al
 43346 0000B42A 7402                <1> 	jz	short msftdf_df_copy_sf_name_ok	
 43347 0000B42C E2F8                <1>         loop    msftdf_df_copy_sf_name_loop
 43348                              <1> msftdf_df_copy_sf_name_ok:	
 43349 0000B42E 5E                  <1> 	pop	esi  
 43350 0000B42F EBB7                <1> 	jmp	short msftdf_df_find_2
 43351                              <1> 
 43352                              <1> msftdf_df_stc_retn:
 43353 0000B431 F9                  <1> 	stc
 43354                              <1> msftdf_restore_cdir_failed:
 43355                              <1> msftdf_df_error_retn:
 43356 0000B432 C3                  <1> 	retn
 43357                              <1> 
 43358                              <1> msftdf_restore_current_dir_1:
 43359 0000B433 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 43360 0000B43A 760D                <1> 	jna	short msftdf_sf_check_directory
 43361 0000B43C 8B35[2C830100]      <1> 	mov	esi, [msftdf_drv_offset] 
 43362 0000B442 E8D2C3FFFF          <1> 	call	restore_current_directory
 43363 0000B447 72E9                <1> 	jc	short msftdf_restore_cdir_failed
 43364                              <1> 
 43365                              <1> msftdf_sf_check_directory:
 43366 0000B449 BE[29820100]        <1> 	mov	esi, SourceFile_Directory
 43367 0000B44E 803E20              <1> 	cmp	byte [esi], 20h
 43368 0000B451 760F                <1> 	jna	short msftdf_sf_find
 43369                              <1> msftdf_sf_change_directory:
 43370 0000B453 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43371 0000B459 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 43372 0000B45B E88BF0FFFF          <1> 	call	change_current_directory
 43373 0000B460 7225                <1> 	jc	short msftdf_return
 43374                              <1> 
 43375                              <1> ;msftdf_sf_change_prompt_dir_string:
 43376                              <1> ;	call	change_prompt_dir_string
 43377                              <1> 
 43378                              <1> msftdf_sf_find:
 43379 0000B462 BE[6A820100]        <1>         mov     esi, SourceFile_Name  ; Offset 66
 43380 0000B467 66B80018            <1> 	mov	ax, 1800h ; Only files
 43381 0000B46B E8A1D5FFFF          <1> 	call	find_first_file
 43382 0000B470 7215                <1> 	jc	short msftdf_return
 43383                              <1> 
 43384                              <1> msftdf_sf_ambgfn_check:
 43385 0000B472 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
 43386 0000B475 7406                <1> 	jz	short msftdf_sf_found
 43387                              <1> 
 43388                              <1> msftdf_ambiguous_file_name_error:
 43389                              <1> 	;mov	eax, 2 ; File not found error
 43390                              <1> 	; 29/07/2022
 43391 0000B477 29C0                <1> 	sub	eax, eax
 43392 0000B479 B002                <1> 	mov	al, 2
 43393 0000B47B F9                  <1> 	stc
 43394 0000B47C C3                  <1> 	retn
 43395                              <1> 
 43396                              <1> msftdf_sf_found:
 43397 0000B47D 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
 43398 0000B480 7415                <1> 	jz	short msftdf_save_sf_structure
 43399                              <1> 
 43400                              <1> msftdf_permission_denied_retn:
 43401                              <1> 	;mov	eax, 05h ; Access (Permission) denied !
 43402                              <1> 	; 29/07/2022
 43403 0000B482 29C0                <1> 	sub	eax, eax
 43404 0000B484 B005                <1> 	mov	al, 5
 43405 0000B486 F9                  <1> 	stc
 43406                              <1> msftdf_rest_cdir_err_retn:
 43407                              <1> msftdf_return:
 43408 0000B487 C3                  <1> 	retn
 43409                              <1> 
 43410                              <1> msftdf_phase_1_return:
 43411 0000B488 31C0                <1> 	xor	eax, eax
 43412 0000B48A A2[2A830100]        <1> 	mov	[move_cmd_phase], al ; 0
 43413 0000B48F FEC0                <1> 	inc	al ; mov al, 1
 43414 0000B491 BB[DDB40000]        <1> 	mov	ebx, msftdf_df2_check_directory
 43415                              <1> 	;mov	edx, 0FFFFFFFFh 
 43416 0000B496 C3                  <1> 	retn
 43417                              <1> 
 43418                              <1> msftdf_save_sf_structure:
 43419 0000B497 BE[34810100]        <1> 	mov	esi, FindFile_DirEntry
 43420 0000B49C BF[7A820100]        <1> 	mov	edi, SourceFile_DirEntry
 43421                              <1> 	;mov	ecx, 8
 43422                              <1> 	; 29/07/2022
 43423 0000B4A1 29C9                <1> 	sub	ecx, ecx
 43424 0000B4A3 B108                <1> 	mov	cl, 8
 43425 0000B4A5 F3A5                <1> 	rep	movsd
 43426                              <1> 
 43427                              <1> msftdf_df_copy_sf_parameters:
 43428 0000B4A7 BE0B000000          <1> 	mov	esi, 11
 43429 0000B4AC 89F7                <1> 	mov	edi, esi
 43430 0000B4AE 81C6[7A820100]      <1> 	add	esi, SourceFile_DirEntry
 43431 0000B4B4 81C7[FA820100]      <1> 	add	edi, DestinationFile_DirEntry
 43432                              <1> 	;mov	ecx, 21
 43433 0000B4BA B115                <1> 	mov	cl, 21
 43434 0000B4BC F3A4                <1> 	rep	movsb
 43435                              <1> 
 43436                              <1> msftdf_restore_current_dir_2:
 43437 0000B4BE 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 43438 0000B4C5 760D                <1> 	jna	short msftdf_df2_check_move_cmd_phase
 43439 0000B4C7 8B35[2C830100]      <1>  	mov	esi, [msftdf_drv_offset]
 43440 0000B4CD E847C3FFFF          <1> 	call	restore_current_directory
 43441 0000B4D2 72B3                <1> 	jc	short msftdf_rest_cdir_err_retn
 43442                              <1> 
 43443                              <1> msftdf_df2_check_move_cmd_phase:
 43444 0000B4D4 803D[2A830100]01    <1> 	cmp	byte [move_cmd_phase], 1
 43445 0000B4DB 74AB                <1> 	je	short msftdf_phase_1_return
 43446                              <1> 
 43447                              <1> msftdf_df2_check_directory:
 43448 0000B4DD BE[A9820100]        <1> 	mov	esi, DestinationFile_Directory
 43449 0000B4E2 803E20              <1> 	cmp	byte [esi], 20h
 43450 0000B4E5 760F                <1> 	jna	short msftdf_make_dfde_locate_ffe_on_directory
 43451                              <1> msftdf_df2_change_directory:
 43452 0000B4E7 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43453 0000B4ED 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 43454 0000B4EF E8F7EFFFFF          <1> 	call	change_current_directory
 43455 0000B4F4 7291                <1> 	jc	short msftdf_return
 43456                              <1> 
 43457                              <1> ;msftdf_df2_change_prompt_dir_string:
 43458                              <1> ;	call	change_prompt_dir_string
 43459                              <1> 
 43460                              <1> msftdf_make_dfde_locate_ffe_on_directory:
 43461                              <1> 	; Current directory fcluster <> Directory buffer cluster
 43462                              <1> 	; Current directory will be reloaded by
 43463                              <1> 	; 'locate_current_dir_file' procedure
 43464                              <1> 	;
 43465                              <1> 	;xor	ax, ax
 43466 0000B4F6 31C0                <1> 	xor	eax, eax
 43467 0000B4F8 89C1                <1> 	mov	ecx, eax
 43468 0000B4FA 6649                <1> 	dec	cx ; FFFFh  
 43469                              <1> 		; CX = FFFFh -> find first deleted or free entry
 43470                              <1> 		; ESI would be ASCIIZ filename address if the call
 43471                              <1> 		; would not be for first free or deleted dir entry  
 43472 0000B4FC E83DF2FFFF          <1> 	call	locate_current_dir_file
 43473                              <1> 	; 07/08/2022
 43474 0000B501 733F                <1> 	jnc	short msftdf_make_dfde_set_ff_dir_entry
 43475                              <1> 	
 43476                              <1> 	;cmp	eax, 2
 43477 0000B503 3C02                <1>         cmp	al, 2
 43478 0000B505 7537                <1> 	jne	short msftdf_error_retn
 43479                              <1> 
 43480                              <1> msftdf_add_new_dir_entry_check_fs:
 43481 0000B507 8B35[2C830100]      <1> 	mov	esi, [msftdf_drv_offset]
 43482 0000B50D A1[6E7F0100]        <1> 	mov 	eax, [DirBuff_Cluster]
 43483 0000B512 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 43484 0000B516 7711                <1> 	ja	short msftdf_add_new_subdir_cluster
 43485                              <1> 
 43486                              <1> msftdf_add_new_fs_subdir_section:
 43487                              <1> 	;CL=0, CH=E5h --> deleted entry, CH=0 --> free entry
 43488                              <1>         ;xor	cx, cx
 43489 0000B518 30ED                <1> 	xor	ch, ch ; cx = 0 --> add a new subdir section
 43490 0000B51A E86A0C0000          <1> 	call	add_new_fs_section
 43491 0000B51F 721E                <1>         jc	short msftdf_dsfde_error_retn
 43492                              <1> 	;mov	[createfile_LastDirCluster], eax
 43493                              <1> 
 43494 0000B521 E85A0E0000          <1> 	call	load_FS_sub_directory 
 43495                              <1> 	;mov	ebx, Directory_Buffer 
 43496 0000B526 7318                <1> 	jnc	short msftdf_add_new_fs_subdir_section_ok
 43497 0000B528 C3                  <1> 	retn	 
 43498                              <1> 
 43499                              <1> msftdf_add_new_subdir_cluster:
 43500 0000B529 E8E8140000          <1> 	call	add_new_cluster
 43501 0000B52E 720F                <1> 	jc	short msftdf_dsfde_error_retn
 43502                              <1> 	
 43503                              <1> 	;mov	[createfile_LastDirCluster], eax
 43504                              <1> 
 43505 0000B530 E8110E0000          <1> 	call	load_FAT_sub_directory
 43506 0000B535 7309                <1> 	jnc	short msftdf_add_new_subdir_cluster_ok
 43507                              <1> 	; EBX = Directory buffer address
 43508                              <1> 
 43509                              <1> msftdf_ansdc_update_parent_dir_lmdt:
 43510                              <1> msftdf_make_dfde_err_upd_pdir_lmdt:
 43511 0000B537 50                  <1> 	push	eax
 43512 0000B538 E86EFAFFFF          <1> 	call	update_parent_dir_lmdt
 43513 0000B53D 58                  <1> 	pop	eax
 43514                              <1> 
 43515                              <1> msftdf_error_retn:
 43516 0000B53E F9                  <1> 	stc
 43517                              <1> msftdf_dsfde_restore_cdir_failed:
 43518                              <1> msftdf_dsfde_error_retn:
 43519 0000B53F C3                  <1> 	retn
 43520                              <1> 
 43521                              <1> msftdf_add_new_fs_subdir_section_ok:
 43522                              <1> msftdf_add_new_subdir_cluster_ok:
 43523 0000B540 89DF                <1> 	mov	edi, ebx ; Directory buffer address
 43524                              <1> 
 43525                              <1> msftdf_make_dfde_set_ff_dir_entry:
 43526 0000B542 8B15[3C780100]      <1> 	mov	edx, [Current_Dir_FCluster]
 43527 0000B548 8915[90830100]      <1> 	mov	[createfile_FFCluster], edx
 43528                              <1> 	; EDI = Directory entry offset
 43529 0000B54E BE[FA820100]        <1> 	mov	esi, DestinationFile_DirEntry
 43530                              <1> 	;mov	ecx, 8
 43531                              <1> 	; 29/07/2022
 43532 0000B553 29C9                <1> 	sub	ecx, ecx
 43533 0000B555 B108                <1> 	mov	cl, 8
 43534 0000B557 F3A5                <1> 	rep	movsd
 43535                              <1> 
 43536 0000B559 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
 43537 0000B560 E8AEF9FFFF          <1> 	call	save_directory_buffer
 43538 0000B565 72D0                <1> 	jc	short msftdf_make_dfde_err_upd_pdir_lmdt
 43539                              <1> 
 43540                              <1> msftdf_make_dfde_update_pdir_lmdt:
 43541 0000B567 E83FFAFFFF          <1> 	call	update_parent_dir_lmdt
 43542                              <1> 
 43543                              <1> msftdf_dsfde_restore_current_dir_1:
 43544 0000B56C 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 43545 0000B573 760D                <1> 	jna	short msftdf_dsfde_check_directory
 43546 0000B575 8B35[2C830100]      <1>  	mov	esi, [msftdf_drv_offset]
 43547 0000B57B E899C2FFFF          <1> 	call	restore_current_directory
 43548 0000B580 72BD                <1> 	jc	short msftdf_dsfde_restore_cdir_failed
 43549                              <1> 
 43550                              <1> msftdf_dsfde_check_directory:
 43551 0000B582 BE[29820100]        <1> 	mov	esi, SourceFile_Directory
 43552 0000B587 803E20              <1> 	cmp	byte [esi], 20h
 43553 0000B58A 760F                <1> 	jna	short msftdf_dsfde_find_file
 43554                              <1> 
 43555                              <1> msftdf_dsfde_change_directory:
 43556 0000B58C FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43557 0000B592 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
 43558 0000B594 E852EFFFFF          <1> 	call	change_current_directory
 43559 0000B599 72A4                <1> 	jc	short msftdf_dsfde_error_retn
 43560                              <1> 
 43561                              <1> ;msftdf_dsfde_sf_change_prompt_dir_string:
 43562                              <1> ;	call	change_prompt_dir_string
 43563                              <1> 
 43564                              <1> msftdf_dsfde_find_file:
 43565 0000B59B BE[6A820100]        <1> 	mov	esi, SourceFile_Name  ; Offset 66
 43566 0000B5A0 668B460E            <1> 	mov	ax, [esi+14] ; 80 -> SourceFile_AttributesMask
 43567 0000B5A4 E868D4FFFF          <1> 	call	find_first_file
 43568 0000B5A9 7294                <1> 	jc	short msftdf_dsfde_error_retn
 43569                              <1> 
 43570                              <1> msftdf_dsfde_delete_direntry:
 43571 0000B5AB 8B35[2C830100]      <1> 	mov	esi, [msftdf_drv_offset]
 43572                              <1> 	
 43573 0000B5B1 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 43574 0000B5B5 770A                <1> 	ja	short msftdf_delete_FAT_direntry
 43575                              <1> 	
 43576 0000B5B7 30DB                <1> 	xor	bl, bl
 43577                              <1> 	; BL = 0 -> File
 43578                              <1> 	; EDI -> Directory buffer entry offset/address 
 43579 0000B5B9 E8CB0B0000          <1> 	call	delete_fs_directory_entry
 43580 0000B5BE 7315                <1> 	jnc	short msftdf_dsfde_restore_current_dir_2
 43581 0000B5C0 C3                  <1> 	retn
 43582                              <1> 
 43583                              <1> msftdf_delete_FAT_direntry:	
 43584 0000B5C1 8A1D[31810100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
 43585 0000B5C7 668B0D[5C810100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
 43586                              <1> 	; ESI = Logical DOS drive description table address
 43587                              <1> 	; EDI = Directory buffer entry offset/address 
 43588 0000B5CE E8A0FCFFFF          <1> 	call	delete_directory_entry
 43589 0000B5D3 721C                <1> 	jc	short msftdf_retn
 43590                              <1> 
 43591                              <1> msftdf_dsfde_restore_current_dir_2:
 43592 0000B5D5 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 43593 0000B5DC 7607                <1> 	jna	short msftdf_new_dir_fcluster_retn
 43594                              <1> 	;mov	esi, [msftdf_drv_offset]
 43595 0000B5DE E836C2FFFF          <1> 	call	restore_current_directory
 43596 0000B5E3 720C                <1> 	jc	short msftdf_retn
 43597                              <1> 
 43598                              <1> msftdf_new_dir_fcluster_retn:
 43599 0000B5E5 31C9                <1> 	xor	ecx, ecx 
 43600 0000B5E7 A1[90830100]        <1> 	mov	eax, [createfile_FFCluster]
 43601 0000B5EC BB[A8820100]        <1> 	mov	ebx, DestinationFile_Drv
 43602                              <1> 
 43603                              <1> msftdf_retn:
 43604 0000B5F1 C3                  <1> 	retn
 43605                              <1> 
 43606                              <1> 
 43607                              <1> copy_source_file_to_destination_file:
 43608                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 43609                              <1> 	; 17/10/2016
 43610                              <1> 	; 16/10/2016
 43611                              <1> 	; 15/10/2016
 43612                              <1> 	; 30/03/2016, 31/03/2016
 43613                              <1> 	; 24/03/2016, 25/03/2016, 28/03/2016
 43614                              <1> 	; 21/03/2016, 22/03/2016, 23/03/2016
 43615                              <1> 	; 16/03/2016, 17/03/2016, 18/03/2016
 43616                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
 43617                              <1> 	; 02/09/2011 (FILE.ASM 'copy_source_file_to_destination_file')
 43618                              <1> 	; 01/08/2010 - 18/05/2011
 43619                              <1> 	;
 43620                              <1> 	;   Command Interpreter phase 1 enter ->
 43621                              <1> 	;           AL = 1 -> Caller is command interpreter
 43622                              <1> 	;           AL = 2 -> The second call, re-enter/continue
 43623                              <1> 	;   Phase 1 -> Check source file
 43624                              <1> 	;              'found' is required
 43625                              <1> 	;   Phase 2 -> Check destination file, 
 43626                              <1> 	;              save 'found' or 'not found' status
 43627                              <1> 	;              'permission denied' error will be return
 43628                              <1> 	;              if attributes have not for ordinary file 
 43629                              <1> 	;              without readonly attribute
 43630                              <1> 	;   Command Interpreter phase 1 return ->
 43631                              <1> 	;              DH = Source file attributes
 43632                              <1> 	;              DL = Destination file found status
 43633                              <1> 	;              EAX = 0 
 43634                              <1> 	;   Command Interpreter phase 2 enter ->
 43635                              <1> 	;              AL = 2 -> Continue from the last position
 43636                              <1> 	;              AH = 
 43637                              <1> 	;   Phase 3 -> Load source file or use read/write cluster method
 43638                              <1> 	;   Phase 4 -> Create destination file if it is not found
 43639                              <1> 	;   Phase 5 -> Open destination file
 43640                              <1> 	;   Phase 6 -> Read from source and write to destination
 43641                              <1> 	;   Phase 7 -> Unload source file, if it is loaded at memory
 43642                              <1> 	;       cf = 1 causes to return before the phase 7
 43643                              <1> 	;              but loaded file will be unloaded
 43644                              <1> 	;	       (allocated memory block will be deallocated) 
 43645                              <1> 	;
 43646                              <1> 	; INPUT -> 
 43647                              <1> 	;	 ESI = Source File Pathname (Asciiz)
 43648                              <1> 	;        EDI = Destination File Pathname (Asciiz)
 43649                              <1> 	;        AL = 0 --> Interrupt (System call)
 43650                              <1> 	;        AL > 0 --> Command Interpreter (Question)
 43651                              <1> 	;        AL = 1 --> Question Phase
 43652                              <1> 	;        AL = 2 --> Progress Phase        
 43653                              <1> 	;
 43654                              <1> 	; OUTPUT -> 
 43655                              <1> 	;	cf = 0 -> OK
 43656                              <1> 	;	EAX = Destination file first cluster
 43657                              <1> 	;
 43658                              <1> 	;        CL > 0 if there is file reading error before EOF
 43659                              <1> 	;	        (incomplete copy) 
 43660                              <1> 	;        CH > 0 if file is (full) loaded at memory
 43661                              <1> 	;
 43662                              <1> 	;	cf = 1 -> Error code in AL (EAX) 
 43663                              <1> 	;
 43664                              <1> 	; (EBX, ECX, ESI, EDI register contents will be changed)           
 43665                              <1> 
 43666                              <1> 
 43667 0000B5F2 3C02                <1> 	cmp	al, 2
 43668                              <1> 	;je	csftdf2_check_cdrv
 43669                              <1> 	; 29/07/2022
 43670 0000B5F4 7205                <1> 	jb	short csftdf_ph1
 43671                              <1> 	;jmp	csftdf2_check_cdrv
 43672 0000B5F6 E94F020000          <1> 	jmp	csftdf_ph2
 43673                              <1> 
 43674                              <1> ; Phase 1
 43675                              <1> 	; 29/07/2022
 43676                              <1> csftdf_ph1:
 43677 0000B5FB A2[50830100]        <1> 	mov	byte [copy_cmd_phase], al
 43678                              <1> 
 43679 0000B600 57                  <1> 	push	edi ; *
 43680                              <1> 
 43681                              <1> csftdf_parse_sf_path:
 43682 0000B601 BF[28820100]        <1> 	mov	edi, SourceFile_Drv
 43683 0000B606 E8CCF4FFFF          <1> 	call	parse_path_name
 43684 0000B60B 721C                <1> 	jc	short csftdf_parse_sf_path_failed
 43685                              <1> 
 43686                              <1> csftdf_parse_df_path:	
 43687 0000B60D 5E                  <1> 	pop	esi ; * (pushed edi) 
 43688                              <1> 
 43689                              <1> csftdf_sf_check_filename_exists:
 43690 0000B60E 803D[6A820100]21    <1> 	cmp	byte [SourceFile_Name], 21h
 43691 0000B615 7215                <1> 	jb	short csftdf_sf_file_not_found_error
 43692                              <1> 
 43693 0000B617 BF[A8820100]        <1> 	mov	edi, DestinationFile_Drv
 43694 0000B61C E8B6F4FFFF          <1> 	call	parse_path_name
 43695 0000B621 7310                <1> 	jnc	short csftdf_check_sf_cdrv
 43696                              <1> 	
 43697 0000B623 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
 43698 0000B625 760C                <1> 	jna	short csftdf_check_sf_cdrv
 43699                              <1> 
 43700                              <1> csftdf_parse_df_path_failed:
 43701 0000B627 F9                  <1> 	stc 
 43702                              <1> csftdf_sf_error_retn: 
 43703 0000B628 C3                  <1> 	retn
 43704                              <1> 
 43705                              <1> csftdf_parse_sf_path_failed:	
 43706 0000B629 5F                  <1> 	pop	edi ; *
 43707 0000B62A EBFC                <1> 	jmp	short csftdf_sf_error_retn
 43708                              <1> 
 43709                              <1> csftdf_sf_file_not_found_error:
 43710 0000B62C B802000000          <1> 	mov	eax, 2 ; File not found 
 43711 0000B631 EBF5                <1> 	jmp	short csftdf_sf_error_retn
 43712                              <1> 
 43713                              <1> csftdf_check_sf_cdrv:
 43714 0000B633 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 43715                              <1> 
 43716 0000B639 883D[53830100]      <1> 	mov	[csftdf_cdrv], bh ; 23/03/2016
 43717                              <1> 
 43718 0000B63F 8A15[28820100]      <1> 	mov	dl, [SourceFile_Drv]
 43719 0000B645 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
 43720 0000B647 7407                <1> 	je	short csftdf_sf_check_directory
 43721                              <1> 
 43722 0000B649 E815C1FFFF          <1> 	call	change_current_drive
 43723 0000B64E 72D8                <1> 	jc	short csftdf_sf_error_retn
 43724                              <1> 
 43725                              <1> csftdf_sf_check_directory:
 43726 0000B650 BE[29820100]        <1> 	mov	esi, SourceFile_Directory
 43727 0000B655 803E20              <1> 	cmp	byte [esi], 20h
 43728 0000B658 760F                <1> 	jna	short csftdf_find_sf
 43729                              <1> 
 43730                              <1> csftdf_sf_change_directory:
 43731 0000B65A FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43732 0000B660 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
 43733 0000B662 E884EEFFFF          <1> 	call	change_current_directory
 43734 0000B667 72BF                <1> 	jc	short csftdf_sf_error_retn
 43735                              <1> 
 43736                              <1> ;csftdf_sf_change_prompt_dir_string:
 43737                              <1> ;	call	change_prompt_dir_string
 43738                              <1> 
 43739                              <1> csftdf_find_sf:
 43740 0000B669 BE[6A820100]        <1> 	mov	esi, SourceFile_Name
 43741 0000B66E 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
 43742 0000B672 E89AD3FFFF          <1> 	call	find_first_file
 43743 0000B677 72AF                <1> 	jc	short csftdf_sf_error_retn
 43744                              <1> 
 43745                              <1> csftdf_sf_ambgfn_check:
 43746 0000B679 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 43747 0000B67C 7406                <1> 	jz	short csftdf_sf_found
 43748                              <1> 
 43749                              <1> csftdf_ambiguous_file_name_error:
 43750                              <1> 	;mov	eax, 2 ; File not found error
 43751                              <1> 	; 29/07/2022
 43752 0000B67E 29C0                <1> 	sub	eax, eax
 43753 0000B680 B002                <1> 	mov	al, 2
 43754 0000B682 F9                  <1> 	stc
 43755 0000B683 C3                  <1> 	retn
 43756                              <1> 
 43757                              <1> csftdf_sf_found:
 43758 0000B684 A3[54830100]        <1> 	mov	[csftdf_filesize], eax
 43759                              <1> 
 43760 0000B689 09C0                <1> 	or	eax, eax
 43761 0000B68B 7506                <1> 	jnz	short csftdf_set_source_file_direntry
 43762                              <1> 
 43763                              <1> csftdf_sf_file_size_zero:
 43764                              <1> 	;mov	eax, 20 ; TRDOS zero length (file size) error
 43765                              <1> 	; 29/07/2022
 43766 0000B68D 29C0                <1> 	sub	eax, eax
 43767 0000B68F B014                <1> 	mov	al, 20
 43768 0000B691 F9                  <1> 	stc
 43769 0000B692 C3                  <1> 	retn
 43770                              <1> 
 43771                              <1> csftdf_set_source_file_direntry:
 43772 0000B693 BE[34810100]        <1> 	mov	esi, FindFile_DirEntry
 43773 0000B698 BF[7A820100]        <1> 	mov	edi, SourceFile_DirEntry
 43774                              <1> 	;mov	ecx, 8
 43775                              <1> 	; 29/07/2022
 43776 0000B69D 31C9                <1> 	xor	ecx, ecx
 43777 0000B69F B108                <1> 	mov	cl, 8
 43778 0000B6A1 F3A5                <1> 	rep	movsd
 43779                              <1> 
 43780                              <1> csftdf_sf_restore_cdrv:
 43781                              <1> 	; 22/03/2016
 43782 0000B6A3 8A15[53830100]      <1> 	mov	dl, [csftdf_cdrv]
 43783 0000B6A9 3A15[42780100]      <1> 	cmp	dl, [Current_Drv]
 43784 0000B6AF 7407                <1> 	je	short csftdf_sf_restore_cdir
 43785 0000B6B1 E8ADC0FFFF          <1> 	call	change_current_drive 
 43786 0000B6B6 724F                <1> 	jc	short csftdf_df_error_retn ; 30/03/2016
 43787                              <1> 
 43788                              <1> csftdf_sf_restore_cdir:
 43789 0000B6B8 803D[68300100]00    <1> 	cmp	byte [Restore_CDIR], 0
 43790 0000B6BF 7612                <1> 	jna	short csftdf_df_check_filename_exists
 43791 0000B6C1 29C0                <1> 	sub	eax, eax
 43792 0000B6C3 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 43793 0000B6C8 88D4                <1> 	mov	ah, dl ; byte [csftdf_cdrv]
 43794 0000B6CA 01C6                <1> 	add	esi, eax
 43795 0000B6CC E848C1FFFF          <1> 	call	restore_current_directory
 43796 0000B6D1 7234                <1> 	jc	short csftdf_df_error_retn
 43797                              <1>   
 43798                              <1> csftdf_df_check_filename_exists:
 43799 0000B6D3 803D[EA820100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
 43800 0000B6DA 7716                <1> 	ja	short csftdf_check_df_cdrv
 43801                              <1> 
 43802                              <1> csftdf_copy_sf_name:
 43803 0000B6DC BF[EA820100]        <1> 	mov	edi, DestinationFile_Name
 43804 0000B6E1 BE[6A820100]        <1> 	mov	esi, SourceFile_Name
 43805 0000B6E6 B10C                <1> 	mov	cl, 12
 43806                              <1> 
 43807                              <1> csftdf_df_copy_sf_name_loop:
 43808 0000B6E8 AC                  <1> 	lodsb
 43809 0000B6E9 AA                  <1> 	stosb
 43810 0000B6EA 08C0                <1> 	or	al, al
 43811 0000B6EC 7404                <1> 	jz	short csftdf_check_df_cdrv             
 43812 0000B6EE FEC9                <1> 	dec	cl
 43813 0000B6F0 75F6                <1> 	jnz	csftdf_df_copy_sf_name_loop
 43814                              <1> 
 43815                              <1> csftdf_check_df_cdrv:
 43816 0000B6F2 8A15[A8820100]      <1> 	mov	dl, [DestinationFile_Drv]
 43817 0000B6F8 3A15[42780100]      <1> 	cmp	dl, [Current_Drv]
 43818 0000B6FE 7408                <1> 	je	short csftdf_df_check_directory
 43819                              <1> 
 43820 0000B700 E85EC0FFFF          <1> 	call	change_current_drive
 43821 0000B705 7301                <1> 	jnc	short csftdf_df_check_directory
 43822                              <1> 
 43823                              <1> csftdf_df_error_retn:
 43824 0000B707 C3                  <1> 	retn
 43825                              <1> 
 43826                              <1> csftdf_df_check_directory:
 43827 0000B708 BE[A9820100]        <1> 	mov	esi, DestinationFile_Directory
 43828 0000B70D 803E20              <1>         cmp     byte [esi], 20h
 43829 0000B710 760F                <1> 	jna	short csftdf_find_df
 43830                              <1> 
 43831                              <1> csftdf_df_change_directory:
 43832 0000B712 FE05[68300100]      <1> 	inc	byte [Restore_CDIR]
 43833 0000B718 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
 43834 0000B71A E8CCEDFFFF          <1> 	call	change_current_directory
 43835 0000B71F 72E6                <1> 	jc	short csftdf_df_error_retn
 43836                              <1> 
 43837                              <1> ;csftdf_df_change_prompt_dir_string:
 43838                              <1> ;	call	change_prompt_dir_string
 43839                              <1> 
 43840                              <1> csftdf_find_df:
 43841                              <1> 	; 23/03/2016
 43842 0000B721 29DB                <1> 	sub	ebx, ebx
 43843 0000B723 8A3D[A8820100]      <1> 	mov	bh,  [DestinationFile_Drv]
 43844 0000B729 81C300010900        <1> 	add	ebx, Logical_DOSDisks
 43845 0000B72F 891D[80830100]      <1> 	mov	[csftdf_df_drv_dt], ebx
 43846                              <1> 
 43847 0000B735 BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 43848 0000B73A 6631C0              <1> 	xor	ax, ax 
 43849                              <1> 		; DestinationFile_AttributesMask -> any/zero
 43850 0000B73D E8CFD2FFFF          <1> 	call	find_first_file
 43851 0000B742 7217                <1> 	jc	short csftdf_df_check_error_code
 43852                              <1> 
 43853                              <1> csftdf_df_ambgfn_check:
 43854 0000B744 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
 43855 0000B747 7529                <1> 	jnz	short csftdf_df_error_inv_fname
 43856                              <1> 	
 43857                              <1> csftdf_df_found:
 43858 0000B749 C605[52830100]01    <1> 	mov	byte [DestinationFileFound], 1
 43859                              <1> 	; 17/10/2016 (cl -> bl)
 43860 0000B750 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
 43861 0000B753 7459                <1> 	jz	short csftdf_df_save_first_cluster
 43862                              <1> 
 43863                              <1> csftdf_df_permission_denied_retn:	 
 43864                              <1> 	;mov	eax, 05h ; Access/Permission denied.
 43865                              <1> 	; 29/07/2022
 43866 0000B755 29C0                <1> 	sub	eax, eax
 43867 0000B757 B005                <1> 	mov	al, 5
 43868                              <1> csftdf_df_error_stc_retn:
 43869 0000B759 F9                  <1> 	stc
 43870 0000B75A C3                  <1> 	retn
 43871                              <1> 
 43872                              <1> csftdf_df_check_error_code:
 43873                              <1> 	;cmp	eax, 2
 43874 0000B75B 3C02                <1> 	cmp	al, 2
 43875 0000B75D 75FA                <1> 	jne	short csftdf_df_error_stc_retn
 43876                              <1> 
 43877 0000B75F C605[52830100]00    <1> 	mov	byte [DestinationFileFound], 0
 43878                              <1> 
 43879                              <1> 	; 15/10/2016
 43880 0000B766 BE[24810100]        <1> 	mov	esi, FindFile_Name ; *
 43881 0000B76B E846D6FFFF          <1> 	call	check_filename
 43882 0000B770 7306                <1> 	jnc	short csftdf_df_valid_fname
 43883                              <1> csftdf_df_error_inv_fname: ; 'invalid file name !'
 43884                              <1> 	;mov 	eax, ERR_INV_FILE_NAME  ; 26
 43885                              <1> 	; 29/07/2022
 43886 0000B772 29C0                <1> 	sub	eax, eax
 43887 0000B774 B01A                <1> 	mov	al, ERR_INV_FILE_NAME ; 26
 43888 0000B776 F9                  <1> 	stc	
 43889 0000B777 C3                  <1> 	retn
 43890                              <1> 
 43891                              <1> csftdf_df_valid_fname:	
 43892                              <1> 	; 21/03/2016
 43893                              <1> 	; (Capitalized file name)
 43894                              <1> 	;mov	esi, FindFile_Name ; * ; 15/10/2016
 43895 0000B778 BF[EA820100]        <1> 	mov	edi, DestinationFile_Name
 43896 0000B77D A5                  <1> 	movsd
 43897 0000B77E A5                  <1> 	movsd	
 43898 0000B77F A5                  <1> 	movsd
 43899                              <1> 	;movsb
 43900                              <1> 
 43901                              <1> csftdf_check_disk_free_size_0:
 43902 0000B780 A1[96820100]        <1> 	mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
 43903                              <1> 
 43904                              <1> csftdf_check_disk_free_size_1:
 43905                              <1> 	;sub	ebx, ebx
 43906                              <1> 	;mov 	esi, Logical_DOSDisks
 43907                              <1> 	;mov	bh,  [DestinationFile_Drv]
 43908                              <1> 	;add	esi, ebx
 43909                              <1> 	
 43910 0000B785 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
 43911                              <1> 
 43912 0000B78B 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
 43913 0000B78F 01C8                <1> 	add	eax, ecx
 43914 0000B791 48                  <1> 	dec	eax  ; file size (additional bytes) + 511 (round up)
 43915                              <1> csftdf_check_disk_free_size_3: ; 16/03/2016
 43916 0000B792 29D2                <1> 	sub	edx, edx
 43917 0000B794 F7F1                <1> 	div	ecx ; bytes per sector
 43918                              <1> 
 43919                              <1> csftdf_check_disk_free_size:
 43920 0000B796 3B4674              <1> 	cmp	eax, [esi+LD_FreeSectors]
 43921                              <1>         ;jb	csftdf_check_disk_free_size_ok
 43922                              <1> 	; 29/07/2022
 43923 0000B799 7208                <1> 	jb	short csftdf_check_dfs_ok
 43924 0000B79B 770B                <1> 	ja	short csftdf_df_insufficient_disk_space
 43925                              <1> 
 43926 0000B79D 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0 ; FS needs FDT sector also.
 43927                              <1> 	;ja	csftdf_check_disk_free_size_ok 
 43928                              <1> 	; 29/07/2022
 43929 0000B7A1 7605                <1> 	jna	short csftdf_df_insufficient_disk_space
 43930                              <1> csftdf_check_dfs_ok:
 43931 0000B7A3 E985000000          <1> 	jmp	csftdf_check_disk_free_size_ok 
 43932                              <1> 
 43933                              <1> csftdf_df_insufficient_disk_space:
 43934                              <1> 	;mov	eax, 27h ; insufficient disk space
 43935                              <1> 	; 29/07/2022
 43936 0000B7A8 29C0                <1> 	sub	eax, eax
 43937 0000B7AA B027                <1> 	mov	al, 27h
 43938 0000B7AC EBAB                <1> 	jmp	short csftdf_df_error_stc_retn
 43939                              <1> 
 43940                              <1> csftdf_df_save_first_cluster:
 43941                              <1> 	; ESI = FindFile_DirEntry (for the old destination file)
 43942                              <1> 	; EAX = Old destination file size
 43943                              <1> 	; 24/03/2016
 43944                              <1> 	; EDI = Directory entry address (within Dir Buffer boundaries)
 43945 0000B7AE 81EF00000800        <1> 	sub	edi, Directory_Buffer  ; (<65536)
 43946                              <1> 	;shr	di, 5 ; Convert entry offset to entry index/number
 43947                              <1> 	; 29/07/2022
 43948 0000B7B4 C1EF05              <1> 	shr	edi, 5
 43949 0000B7B7 66893D[22830100]    <1> 	mov	[DestinationFile_DirEntryNumber], di ; (<2048)
 43950                              <1> 
 43951                              <1> csftdf_df_check_sf_df_fcluster:
 43952 0000B7BE 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
 43953 0000B7C2 C1E210              <1> 	shl	edx, 16
 43954 0000B7C5 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
 43955 0000B7C9 8915[64830100]      <1> 	mov	[csftdf_df_cluster], edx
 43956                              <1> csftdf_df_check_sf_df_fcluster_1:
 43957 0000B7CF 668B15[8E820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
 43958 0000B7D6 C1E210              <1> 	shl	edx, 16
 43959 0000B7D9 668B15[94820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
 43960 0000B7E0 3B15[64830100]      <1> 	cmp	edx, [csftdf_df_cluster]
 43961 0000B7E6 7512                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
 43962                              <1> csftdf_df_check_sf_df_drv:
 43963 0000B7E8 8A15[28820100]      <1> 	mov	dl, [SourceFile_Drv]
 43964 0000B7EE 3A15[A8820100]      <1> 	cmp	dl, [DestinationFile_Drv]
 43965 0000B7F4 7504                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
 43966                              <1> 
 43967                              <1> 	; source and destination files are same !
 43968                              <1> 	; (they have same first cluster value on same logical disk)
 43969                              <1> 
 43970 0000B7F6 31C0                <1> 	xor	eax, eax ; mov eax, 0 -> Bad command or file name !
 43971 0000B7F8 F9                  <1> 	stc
 43972 0000B7F9 C3                  <1> 	retn 
 43973                              <1>    
 43974                              <1> csftdf_df_check_sf_df_fcluster_ok:
 43975                              <1> csftdf_df_move_findfile_struct:
 43976                              <1> 	; mov	esi, FindFile_DirEntry
 43977 0000B7FA BF[FA820100]        <1> 	mov	edi, DestinationFile_DirEntry
 43978                              <1> 	;mov	ecx, 8
 43979 0000B7FF 31C9                <1> 	xor	ecx, ecx
 43980 0000B801 B108                <1> 	mov	cl, 8
 43981 0000B803 F3A5                <1> 	rep	movsd
 43982                              <1> 	
 43983                              <1> csftdf_check_disk_free_size_2:
 43984 0000B805 89C2                <1> 	mov	edx, eax ; Old destination file size
 43985                              <1> 
 43986                              <1> 	;mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
 43987 0000B807 A1[54830100]        <1> 	mov	eax, [csftdf_filesize] ; 23/03/2016
 43988                              <1> 
 43989                              <1> 	;;sub	ecx, ecx ; 0
 43990                              <1> 	;mov 	esi, Logical_DOSDisks
 43991                              <1> 	;mov	ch,  [DestinationFile_Drv]
 43992                              <1> 	;add	esi, ecx
 43993                              <1> 	;
 43994                              <1> 	;mov	[csftdf_df_drv_dt], esi
 43995                              <1> 
 43996 0000B80C 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
 43997                              <1> 
 43998 0000B812 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
 43999 0000B816 01CA                <1> 	add	edx, ecx ; + 512
 44000 0000B818 01C8                <1> 	add	eax, ecx ; + 512
 44001 0000B81A 4A                  <1> 	dec	edx ; old file size + 511 (round up)
 44002 0000B81B 48                  <1> 	dec	eax ; new file size + 511 (round up)
 44003 0000B81C F7D9                <1> 	neg	ecx ; -512 ; 0FFFFFE00h
 44004 0000B81E 21CA                <1> 	and	edx, ecx ; = old sector count * 512 
 44005 0000B820 21C8                <1> 	and	eax, ecx ; = new sector count * 512 
 44006                              <1> 
 44007 0000B822 29D0                <1> 	sub	eax, edx ; new file size - old file size (on disk)
 44008 0000B824 7607                <1> 	jna	short csftdf_check_disk_free_size_ok
 44009                              <1> 
 44010 0000B826 F7D9                <1> 	neg	ecx ; 512 (bytes per sector) ; 200h
 44011                              <1> 	; check free space for additional sectors
 44012                              <1> 	; eax = number of additional sectors * bytes per sector
 44013                              <1> 	; esi = Logical DOS drive number (of destination disk)
 44014 0000B828 E965FFFFFF          <1>         jmp     csftdf_check_disk_free_size_3
 44015                              <1>  
 44016                              <1> csftdf_check_disk_free_size_ok:
 44017                              <1> 	; 18/03/2016
 44018                              <1> csftdf_df_check_copy_cmd_phase:
 44019 0000B82D A0[50830100]        <1> 	mov	al, [copy_cmd_phase]
 44020 0000B832 3C01                <1> 	cmp	al, 1
 44021 0000B834 7514                <1> 	jne	short csftdf2_check_cdrv
 44022                              <1> 	
 44023 0000B836 31C0                <1> 	xor	eax, eax
 44024 0000B838 A2[50830100]        <1> 	mov	[copy_cmd_phase], al ; 0
 44025                              <1> 
 44026 0000B83D 8A15[52830100]      <1> 	mov	dl, [DestinationFileFound]            
 44027 0000B843 8A35[85820100]      <1> 	mov	dh, [SourceFile_DirEntry+11] ; Attributes
 44028                              <1>  
 44029                              <1> csftdf_return:	
 44030 0000B849 C3                  <1> 	retn
 44031                              <1> 
 44032                              <1> ; Phase 2
 44033                              <1> csftdf_ph2:
 44034                              <1> 	; 29/07/2022
 44035                              <1> csftdf2_check_cdrv:
 44036                              <1> 	; 18/03/2016
 44037                              <1> 	; Here, destination drive and directory are ready !
 44038                              <1> 	; (checking/restoring is not needed)
 44039                              <1> 	; (Since at the end of the phase 1)
 44040                              <1> 
 44041                              <1> ;	mov	dl, [DestinationFile_Drv]
 44042                              <1> ;	cmp	dl, [Current_Drv]
 44043                              <1> ;	je	short csftdf2_df_check_directory
 44044                              <1> ;
 44045                              <1> ;	call	change_current_drive
 44046                              <1> ;	jc	short csftdf2_read_error
 44047                              <1> ;
 44048                              <1> ;csftdf2_df_check_directory:
 44049                              <1> ;	mov	esi, DestinationFile_Directory  
 44050                              <1> ;	cmp	byte [esi], 20h
 44051                              <1> ;	jna	short csftdf2_df_check_found_or_not
 44052                              <1> ;
 44053                              <1> ;csftdf2_df_change_directory:
 44054                              <1> ;	inc	byte [Restore_CDIR]
 44055                              <1> ;	xor	ah, ah ; CD_COMMAND sign -> 0 
 44056                              <1> ;	call	change_current_directory
 44057                              <1> ;	jc	short csftdf2_stc_return
 44058                              <1> ;
 44059                              <1> ;;csftdf2_df_change_prompt_dir_string:
 44060                              <1> ;;	call	change_prompt_dir_string
 44061                              <1> 
 44062                              <1> csftdf2_df_check_found_or_not:
 44063                              <1> 	; 21/03/2016
 44064 0000B84A 803D[52830100]00    <1> 	cmp	byte [DestinationFileFound], 0 
 44065 0000B851 773A                <1> 	ja	short csftdf2_set_sf_percentage
 44066                              <1> 
 44067                              <1> csftdf2_create_file:
 44068 0000B853 BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 44069 0000B858 A1[54830100]        <1> 	mov	eax, [csftdf_filesize]
 44070 0000B85D 30C9                <1> 	xor	cl, cl ; 0
 44071                              <1> 
 44072 0000B85F 31DB                <1> 	xor	ebx, ebx ; 0
 44073 0000B861 4B                  <1> 	dec	ebx ; 0FFFFFFFFh 
 44074                              <1> 
 44075                              <1> 	; INPUT ->
 44076                              <1> 	; 	EAX -> File Size
 44077                              <1> 	; 	ESI = ASCIIZ File name
 44078                              <1> 	;	 CL = File attributes
 44079                              <1> 	;	EBX = FFFFFFFFh -> empty file sign for FAT fs
 44080                              <1> 	;	EBX <> FFFFFFFFh -> use file size for FAT fs 
 44081                              <1> 	;
 44082                              <1> 	; OUTPUT ->
 44083                              <1> 	;	EAX = New file's first cluster
 44084                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
 44085                              <1> 	;	EBX = CreateFile_Size address
 44086                              <1> 	;	ECX = Sectors per cluster (<256)
 44087                              <1> 	;	EDX = Directory Entry Index/Number (<65536)
 44088                              <1> 	;		
 44089                              <1> 	;	cf = 1 -> error code in AL (EAX)
 44090                              <1> 
 44091 0000B862 E8EC050000          <1> 	call	create_file
 44092                              <1> 	;pop	esi
 44093                              <1> 	;jc	csftdf2_rw_error
 44094                              <1> 	; 29/07/2022
 44095 0000B867 7305                <1> 	jnc	short csftdf2_create_file_OK
 44096 0000B869 E9A3050000          <1> 	jmp	csftdf2_rw_error
 44097                              <1> 
 44098                              <1> csftdf2_create_file_OK:
 44099 0000B86E A3[64830100]        <1> 	mov	[csftdf_df_cluster], eax
 44100                              <1> 	
 44101                              <1> 	; 24/03/2016
 44102 0000B873 668915[22830100]    <1> 	mov	[DestinationFile_DirEntryNumber], dx 
 44103                              <1> 
 44104                              <1> 	; 21/03/2016
 44105 0000B87A BE00000800          <1> 	mov	esi, Directory_Buffer
 44106 0000B87F C1E205              <1> 	shl	edx, 5 ; 32 * index number
 44107 0000B882 01D6                <1> 	add	esi, edx
 44108 0000B884 BF[FA820100]        <1> 	mov	edi, DestinationFile_DirEntry	
 44109 0000B889 B108                <1> 	mov	cl, 8 ; 32 bytes
 44110 0000B88B F3A5                <1> 	rep	movsd
 44111                              <1> 
 44112                              <1> csftdf2_set_sf_percentage:
 44113                              <1> 	; 17/03/2016
 44114 0000B88D 31C0                <1> 	xor	eax, eax	
 44115 0000B88F A2[78830100]        <1> 	mov 	[csftdf_percentage], al ; 0, reset
 44116                              <1> 
 44117 0000B894 A3[70830100]        <1> 	mov	[csftdf_sf_rbytes], eax ; 0, reset
 44118 0000B899 A3[74830100]        <1> 	mov	[csftdf_df_wbytes], eax ; 0, reset
 44119                              <1> 
 44120 0000B89E 8A25[28820100]      <1> 	mov	ah, [SourceFile_Drv]	
 44121 0000B8A4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 44122 0000B8A9 01C6                <1> 	add	esi, eax
 44123                              <1> 	
 44124 0000B8AB 8935[7C830100]      <1> 	mov	[csftdf_sf_drv_dt], esi ; 23/03/2016
 44125                              <1> 
 44126 0000B8B1 668B15[8E820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
 44127 0000B8B8 C1E210              <1> 	shl	edx, 16
 44128 0000B8BB 668B15[94820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
 44129 0000B8C2 8915[60830100]      <1> 	mov	[csftdf_sf_cluster], edx
 44130                              <1> 
 44131                              <1> 	; 16/03/2016
 44132                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
 44133                              <1> 	;	related calculations) has same offset
 44134                              <1> 	;	values from LD_BPB as in FAT file system.
 44135                              <1> 	;	[esi+LD_BPB+SecPerClust] is 1 for Singlix FS.
 44136                              <1> 	;	
 44137 0000B8C8 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 44138 0000B8CC 880D[A6820100]      <1> 	mov	[SourceFile_SecPerClust], cl
 44139                              <1> 
 44140                              <1> 	; 17/03/2016
 44141 0000B8D2 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
 44142 0000B8D5 7707                <1> 	ja	short csftdf2_set_sf_percent_rsize1
 44143                              <1> 
 44144 0000B8D7 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
 44145 0000B8DC EB06                <1> 	jmp	short csftdf2_set_sf_percent_rsize2	
 44146                              <1>  
 44147                              <1> csftdf2_set_sf_percent_rsize1:
 44148 0000B8DE 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
 44149 0000B8E2 F7E1                <1> 	mul	ecx
 44150                              <1> 	;sub	edx, edx
 44151                              <1> csftdf2_set_sf_percent_rsize2:
 44152 0000B8E4 A3[68830100]        <1> 	mov	[csftdf_r_size], eax
 44153                              <1> 
 44154                              <1> csftdf2_set_df_percentage:
 44155                              <1> 	;sub	eax, eax
 44156                              <1> 	;mov	ah, [DestinationFile_Drv]	
 44157                              <1> 	;mov	edi, Logical_DOSDisks
 44158                              <1> 	;add	edi, eax
 44159                              <1> 	;mov	[csftdf_df_drv_dt], edi ; 17/03/2016
 44160                              <1> 
 44161 0000B8E9 8B3D[80830100]      <1> 	mov	edi, [csftdf_df_drv_dt] ; 23/03/2016
 44162                              <1> 
 44163                              <1> 	; 16/03/2016
 44164                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
 44165                              <1> 	;	related calculations) has same offset
 44166                              <1> 	;	values from LD_BPB as in FAT file system.
 44167                              <1> 	;	[edi+LD_BPB+SecPerClust] is 1 for Singlix FS.
 44168                              <1> 	;	
 44169                              <1> 	;movzx	ecx, byte [edi+LD_BPB+SecPerClust]
 44170 0000B8EF 8A4F13              <1> 	mov	cl, [edi+LD_BPB+SecPerClust]
 44171 0000B8F2 880D[26830100]      <1> 	mov	[DestinationFile_SecPerClust], cl
 44172                              <1> 
 44173                              <1> 	; 17/03/2016
 44174 0000B8F8 386F03              <1> 	cmp	[edi+LD_FATType], ch ; 0
 44175 0000B8FB 7707                <1> 	ja	short csftdf2_set_df_percent_wsize1
 44176                              <1> 	
 44177 0000B8FD B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
 44178 0000B902 EB06                <1> 	jmp	short csftdf2_set_df_percent_wsize2	
 44179                              <1> 
 44180                              <1> csftdf2_set_df_percent_wsize1:
 44181 0000B904 0FB74711            <1> 	movzx	eax, word [edi+LD_BPB+BytesPerSec]
 44182 0000B908 F7E1                <1> 	mul	ecx
 44183                              <1> 	;sub	edx, edx
 44184                              <1> csftdf2_set_df_percent_wsize2:
 44185 0000B90A A3[6C830100]        <1> 	mov	[csftdf_w_size], eax
 44186                              <1> 
 44187 0000B90F A1[54830100]        <1> 	mov	eax, [csftdf_filesize]
 44188                              <1> 
 44189 0000B914 3D00000100          <1> 	cmp	eax, 65536 ; 64KB	; small file
 44190 0000B919 721F                <1> 	jb	short csftdf2_load_file ; do not display percentage
 44191                              <1> 	
 44192                              <1> csftdf2_reset_wf_percent_ptr_chk_64k:
 44193 0000B91B B201                <1> 	mov	dl, 1 ; 25/03/2016
 44194                              <1> 
 44195 0000B91D 3D00000400          <1> 	cmp	eax, 65536*4 ; 256KB
 44196 0000B922 7310                <1> 	jnb	short csftdf2_enable_percentage_display ; big file
 44197                              <1> 
 44198                              <1> 	; 64-128KB file size for floppy disks
 44199 0000B924 3815[28820100]      <1> 	cmp	byte [SourceFile_Drv], dl ; 1 ; read from floppy disk ?
 44200 0000B92A 7608                <1> 	jna	short csftdf2_enable_percentage_display
 44201                              <1> 
 44202 0000B92C 3815[A8820100]      <1> 	cmp	byte [DestinationFile_Drv], dl ; 1 ; write to floppy disk ?
 44203 0000B932 7706                <1> 	ja	short csftdf2_load_file
 44204                              <1> 
 44205                              <1> csftdf2_enable_percentage_display:	
 44206 0000B934 8815[78830100]      <1> 	mov	[csftdf_percentage], dl ; 1	
 44207                              <1> 	
 44208                              <1> csftdf2_load_file:
 44209                              <1> 	; 13/05/2016
 44210                              <1> 	; 19/03/2016
 44211                              <1> 	; 18/03/2016
 44212                              <1> 	; 17/03/2016
 44213 0000B93A B40F                <1> 	mov	ah, 0Fh
 44214 0000B93C E8955DFFFF          <1> 	call	_int10h
 44215                              <1> 	; 13/05/2016
 44216 0000B941 883D[79830100]      <1> 	mov	[csftdf_videopage], bh ; active video page
 44217 0000B947 B403                <1> 	mov	ah, 03h
 44218 0000B949 E8885DFFFF          <1> 	call	_int10h
 44219 0000B94E 668915[7A830100]    <1> 	mov	[csftdf_cursorpos], dx
 44220                              <1> 
 44221 0000B955 29C0                <1> 	sub	eax, eax
 44222 0000B957 A2[51830100]        <1> 	mov	[csftdf_rw_err], al ; 0 
 44223                              <1> 
 44224                              <1> ; ///
 44225                              <1> csftdf_sf_amb: ; 15/03/2016
 44226 0000B95C 8B0D[54830100]      <1> 	mov	ecx, [csftdf_filesize]	; 23/03/2016
 44227                              <1> 
 44228                              <1> 	; TRDOS 386 (TRDOS v2.0)
 44229                              <1> 	; Allocate contiguous memory block for loading the file
 44230                              <1> 	
 44231                              <1> 	;mov	ecx, [SourceFile_DirEntry+DirEntry_FileSize]
 44232                              <1> 	
 44233                              <1> 	;sub	eax, eax ; First free memory aperture
 44234                              <1> 	
 44235                              <1> 	; eax = 0 (Allocate memory from the beginning)
 44236                              <1> 	; ecx = File (Allocation) size in bytes
 44237                              <1> 	
 44238 0000B962 E856A2FFFF          <1> 	call	allocate_memory_block
 44239 0000B967 7304                <1> 	jnc	short loc_check_sf_save_loading_parms
 44240                              <1> 
 44241 0000B969 29C0                <1> 	sub	eax, eax
 44242 0000B96B 29C9                <1> 	sub	ecx, ecx
 44243                              <1> 	
 44244                              <1> loc_check_sf_save_loading_parms:
 44245 0000B96D A3[58830100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
 44246 0000B972 890D[5C830100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
 44247                              <1> ; ///   
 44248                              <1> 	; 19/03/2016
 44249 0000B978 8B35[7C830100]      <1> 	mov	esi, [csftdf_sf_drv_dt] ; logical dos drv desc. tbl.
 44250                              <1> 
 44251                              <1> 	; 17/03/2016
 44252 0000B97E 09C0                <1> 	or	eax, eax ; contiguous free memory block address 
 44253                              <1> 	;jz	csftdf2_read_sf_cluster
 44254                              <1> 	; 29/07/2022
 44255 0000B980 7505                <1> 	jnz	short csftdf2_1
 44256 0000B982 E95E010000          <1> 	jmp	csftdf2_read_sf_cluster
 44257                              <1> 
 44258                              <1> csftdf2_1:
 44259                              <1> 	; 18/03/2016
 44260 0000B987 8B1D[58830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
 44261                              <1> 
 44262 0000B98D 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 44263                              <1>         ;jna	csftdf2_load_fs_file
 44264                              <1> 	; 29/07/2022
 44265 0000B991 7705                <1> 	ja	short csftdf2_load_fat_file
 44266 0000B993 E900020000          <1> 	jmp	csftdf2_load_fs_file
 44267                              <1> 
 44268                              <1> csftdf2_load_fat_file:
 44269 0000B998 53                  <1> 	push	ebx ; *
 44270                              <1> 
 44271                              <1> csftdf2_load_fat_file_next:
 44272 0000B999 BE[BF360100]        <1> 	mov	esi, msg_reading
 44273 0000B99E E887B2FFFF          <1> 	call	print_msg
 44274                              <1> 
 44275 0000B9A3 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44276 0000B9AA 7605                <1> 	jna	short csftdf2_load_fat_file_1
 44277                              <1> 	
 44278 0000B9AC E87E000000          <1> 	call	csftdf2_print_percentage ; 19/03/2016
 44279                              <1> 
 44280                              <1> csftdf2_load_fat_file_1:
 44281 0000B9B1 8B35[7C830100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
 44282 0000B9B7 5B                  <1> 	pop	ebx ; *
 44283                              <1> 
 44284                              <1> csftdf2_load_fat_file_2:
 44285 0000B9B8 E8BA000000          <1> 	call	csftdf2_read_fat_file_sectors ; 19/03/2016
 44286                              <1> 	;jc	csftdf2_rw_error ; eocc! or disk error! 
 44287                              <1> 	; 29/07/2022
 44288 0000B9BD 7305                <1> 	jnc	short csftdf2_load_fat_file_3 
 44289 0000B9BF E94D040000          <1> 	jmp	csftdf2_rw_error
 44290                              <1> csftdf2_load_fat_file_3:
 44291 0000B9C4 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
 44292 0000B9C6 7520                <1> 	jnz	short csftdf2_load_fat_file_ok
 44293                              <1> 
 44294 0000B9C8 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44295 0000B9CF 76E7                <1> 	jna	short csftdf2_load_fat_file_2
 44296                              <1> 
 44297 0000B9D1 53                  <1> 	push	ebx ; *	
 44298                              <1> 
 44299                              <1> 	; Set cursor position
 44300                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
 44301 0000B9D2 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44302 0000B9D8 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44303 0000B9DF B402                <1> 	mov	ah, 2
 44304 0000B9E1 E8F05CFFFF          <1> 	call	_int10h
 44305 0000B9E6 EBB1                <1> 	jmp	short csftdf2_load_fat_file_next
 44306                              <1> 	
 44307                              <1> csftdf2_load_fat_file_ok:
 44308 0000B9E8 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44309                              <1> 	;jna	csftdf2_save_file ; 25/03/2016
 44310                              <1> 	; 29/07/2022
 44311 0000B9EF 7705                <1> 	ja	short csftdf2_2
 44312 0000B9F1 E94B020000          <1> 	jmp	csftdf2_save_file
 44313                              <1> csftdf2_2:	
 44314                              <1> 	; "Reading... 100%"
 44315 0000B9F6 BF[D7360100]        <1> 	mov	edi, percentagestr
 44316 0000B9FB B031                <1> 	mov	al, '1'
 44317 0000B9FD AA                  <1> 	stosb
 44318 0000B9FE B030                <1> 	mov	al, '0'
 44319 0000BA00 AA                  <1> 	stosb
 44320 0000BA01 AA                  <1> 	stosb
 44321                              <1> 
 44322 0000BA02 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44323 0000BA08 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44324 0000BA0F B402                <1> 	mov	ah, 2
 44325 0000BA11 E8C05CFFFF          <1> 	call	_int10h
 44326                              <1> 
 44327 0000BA16 BE[BF360100]        <1> 	mov	esi, msg_reading
 44328 0000BA1B E80AB2FFFF          <1> 	call	print_msg
 44329                              <1> 	
 44330 0000BA20 BE[D7360100]        <1> 	mov	esi, percentagestr
 44331 0000BA25 E800B2FFFF          <1> 	call	print_msg
 44332                              <1> 
 44333 0000BA2A E912020000          <1>         jmp     csftdf2_save_file ; 25/03/2016
 44334                              <1> 
 44335                              <1> csftdf2_print_percentage:
 44336                              <1> 	; 09/12/2017
 44337                              <1> 	; 19/03/2016
 44338                              <1> 	; 18/03/2016
 44339 0000BA2F B020                <1> 	mov	al, 20h
 44340 0000BA31 BF[D7360100]        <1> 	mov	edi, percentagestr
 44341 0000BA36 AA                  <1> 	stosb
 44342 0000BA37 AA                  <1> 	stosb
 44343 0000BA38 A1[70830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
 44344                              <1> 	;mov	edx, 100
 44345                              <1> 	; 29/07/2022
 44346 0000BA3D 29D2                <1> 	sub	edx, edx
 44347 0000BA3F B264                <1> 	mov	dl, 100
 44348 0000BA41 F7E2                <1> 	mul	edx
 44349 0000BA43 8B0D[54830100]      <1> 	mov	ecx, [csftdf_filesize]	
 44350 0000BA49 F7F1                <1> 	div	ecx
 44351 0000BA4B B10A                <1> 	mov	cl, 10
 44352 0000BA4D F6F1                <1> 	div	cl
 44353 0000BA4F 80C430              <1> 	add	ah, '0'
 44354 0000BA52 8827                <1> 	mov	[edi], ah
 44355 0000BA54 20C0                <1> 	and	al, al
 44356 0000BA56 740A                <1> 	jz	short csftdf2_print_percent_1
 44357 0000BA58 4F                  <1> 	dec	edi
 44358                              <1> 	;cbw
 44359 0000BA59 28E4                <1> 	sub	ah, ah ; 09/12/2017
 44360 0000BA5B F6F1                <1> 	div	cl
 44361 0000BA5D 80C430              <1> 	add	ah, '0'
 44362 0000BA60 8827                <1> 	mov	[edi], ah
 44363                              <1> 	;and	al, al
 44364                              <1> 	;jz	short csftdf2_print_percent_1
 44365                              <1> 	;dec	edi
 44366                              <1> 	;mov	[edi], '1' ; 100%		
 44367                              <1> 
 44368                              <1> csftdf2_print_percent_1:
 44369 0000BA62 BE[D7360100]        <1> 	mov	esi, percentagestr
 44370                              <1> 	;call	print_msg
 44371                              <1> 	;retn
 44372 0000BA67 E9BEB1FFFF          <1> 	jmp	print_msg
 44373                              <1> 
 44374                              <1> csftdf2_read_file_sectors:
 44375                              <1> 	; 19/03/2016
 44376 0000BA6C 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 44377                              <1> 	;jna	csftdf2_read_fs_file_sectors
 44378                              <1> 	; 29/07/2022
 44379 0000BA70 7705                <1> 	ja	short csftdf2_read_fat_file_sectors
 44380 0000BA72 E912070000          <1> 	jmp	csftdf2_read_fs_file_sectors
 44381                              <1> 
 44382                              <1> csftdf2_read_fat_file_sectors:
 44383                              <1> 	; 19/03/2016
 44384                              <1> 	; 18/03/2016
 44385                              <1> 	; return:
 44386                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
 44387                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
 44388                              <1> 	;   CF = 1 -> read error (error code in AL)	
 44389                              <1> 
 44390                              <1> csftdf2_read_fat_file_secs_0:
 44391 0000BA77 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44392 0000BA7D 2B15[70830100]      <1> 	sub	edx, [csftdf_sf_rbytes]
 44393 0000BA83 3B15[68830100]      <1> 	cmp	edx, [csftdf_r_size]	
 44394 0000BA89 7306                <1> 	jnb	short csftdf2_read_fat_file_secs_1
 44395 0000BA8B 8915[68830100]      <1> 	mov	[csftdf_r_size], edx
 44396                              <1> 		
 44397                              <1> csftdf2_read_fat_file_secs_1:
 44398 0000BA91 A1[68830100]        <1> 	mov	eax, [csftdf_r_size]
 44399 0000BA96 29D2                <1> 	sub	edx, edx
 44400 0000BA98 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
 44401 0000BA9C 01C8                <1> 	add	eax, ecx
 44402 0000BA9E 48                  <1> 	dec	eax
 44403 0000BA9F F7F1                <1> 	div	ecx
 44404 0000BAA1 89C1                <1> 	mov	ecx, eax ; sector count
 44405 0000BAA3 A1[60830100]        <1> 	mov	eax, [csftdf_sf_cluster]
 44406                              <1> 
 44407                              <1> 	; EBX = memory block address (current)
 44408                              <1> 	
 44409 0000BAA8 E8DD080000          <1> 	call	read_fat_file_sectors
 44410 0000BAAD 7235                <1> 	jc	short csftdf2_read_fat_file_secs_3
 44411                              <1> 
 44412                              <1> 	; EBX = next memory address
 44413                              <1> 
 44414 0000BAAF A1[70830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
 44415 0000BAB4 0305[68830100]      <1> 	add	eax, [csftdf_r_size]
 44416 0000BABA 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44417 0000BAC0 39D0                <1> 	cmp	eax, edx
 44418 0000BAC2 7320                <1> 	jnb	short csftdf2_read_fat_file_secs_3 ; edx > 0
 44419 0000BAC4 A3[70830100]        <1> 	mov	[csftdf_sf_rbytes], eax
 44420                              <1> 
 44421 0000BAC9 53                  <1> 	push	ebx ; *
 44422                              <1> 	; get next cluster (csftdf_r_size! bytes)
 44423 0000BACA A1[60830100]        <1> 	mov	eax, [csftdf_sf_cluster]
 44424 0000BACF E8B6060000          <1> 	call	get_next_cluster
 44425 0000BAD4 5B                  <1> 	pop	ebx ; *
 44426 0000BAD5 7306                <1> 	jnc	short csftdf2_read_fat_file_secs_2
 44427                              <1> 
 44428                              <1> 	; 15/10/2016
 44429                              <1> 	;Disk read error instad of drv not ready err
 44430 0000BAD7 B811000000          <1> 	mov	eax, 17 ; Read error !
 44431 0000BADC C3                  <1> 	retn
 44432                              <1> 
 44433                              <1> csftdf2_read_fat_file_secs_2:
 44434 0000BADD 29D2                <1> 	sub	edx, edx ; 0
 44435 0000BADF A3[60830100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
 44436                              <1> 
 44437                              <1> csftdf2_read_fat_file_secs_3:
 44438 0000BAE4 C3                  <1> 	retn
 44439                              <1> 
 44440                              <1> csftdf2_read_sf_cluster:
 44441                              <1> 	; 19/03/2016
 44442 0000BAE5 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
 44443                              <1> 
 44444 0000BAEA 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44445 0000BAF1 760D                <1> 	jna	short csftdf2_read_sf_clust_2
 44446                              <1> 
 44447 0000BAF3 53                  <1> 	push	ebx ; *	
 44448                              <1> 
 44449                              <1> csftdf2_read_sf_clust_next:
 44450 0000BAF4 E836FFFFFF          <1> 	call	csftdf2_print_percentage
 44451                              <1> 
 44452                              <1> csftdf2_read_sf_clust_0:
 44453 0000BAF9 8B35[7C830100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
 44454                              <1> csftdf2_read_sf_clust_1:
 44455 0000BAFF 5B                  <1> 	pop	ebx ; *
 44456                              <1> 
 44457                              <1> csftdf2_read_sf_clust_2:
 44458 0000BB00 89DA                <1> 	mov	edx, ebx
 44459 0000BB02 0315[68830100]      <1> 	add	edx, [csftdf_r_size]
 44460 0000BB08 81FA00000800        <1> 	cmp	edx, Cluster_Buffer + 65536
 44461 0000BB0E 772B                <1> 	ja	short csftdf2_write_df_cluster
 44462                              <1> 
 44463 0000BB10 E857FFFFFF          <1> 	call	csftdf2_read_file_sectors ; 19/03/2016
 44464                              <1> 	;jc	csftdf2_save_fat_file_err2 ; eocc! or disk error! 
 44465                              <1> 	; 29/07/2022
 44466 0000BB15 7236                <1> 	jc	short csftdf2_3
 44467                              <1> 
 44468 0000BB17 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
 44469 0000BB19 7520                <1> 	jnz	short csftdf2_write_df_cluster
 44470                              <1> 
 44471 0000BB1B 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44472 0000BB22 76DC                <1> 	jna	short csftdf2_read_sf_clust_2
 44473                              <1> 
 44474 0000BB24 53                  <1> 	push	ebx ; *	
 44475                              <1> 
 44476                              <1> 	; Set cursor position
 44477                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
 44478 0000BB25 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44479 0000BB2B 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44480 0000BB32 B402                <1> 	mov	ah, 2
 44481 0000BB34 E89D5BFFFF          <1> 	call	_int10h
 44482 0000BB39 EBB9                <1> 	jmp	short csftdf2_read_sf_clust_next
 44483                              <1> 
 44484                              <1> csftdf2_write_df_cluster:
 44485                              <1> 	; 19/03/2016
 44486 0000BB3B 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt]	
 44487 0000BB41 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
 44488                              <1> 
 44489                              <1> csftdf2_write_df_clust_next:
 44490 0000BB46 E852000000          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016
 44491                              <1> 	;jc	csftdf2_save_fat_file_err2 ; eocc! or disk error! 
 44492                              <1> 	; 29/07/2022
 44493 0000BB4B 7305                <1> 	jnc	short csftdf2_4
 44494                              <1> csftdf2_3:
 44495 0000BB4D E946020000          <1> 	jmp	csftdf2_save_fat_file_err2
 44496                              <1> csftdf2_4:
 44497 0000BB52 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
 44498 0000BB54 750A                <1> 	jnz	short csftdf2_rw_f_clust_ok
 44499                              <1> 
 44500 0000BB56 81FB00000800        <1> 	cmp	ebx, Cluster_Buffer + 65536
 44501 0000BB5C 72E8                <1> 	jb	short csftdf2_write_df_clust_next
 44502                              <1> 	
 44503 0000BB5E EB85                <1> 	jmp	short csftdf2_read_sf_cluster
 44504                              <1>  
 44505                              <1> csftdf2_rw_f_clust_ok:
 44506 0000BB60 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44507                              <1> 	;jna	csftdf2_save_fat_file_4 ; 25/03/2016
 44508                              <1> 	; 29/07/2022
 44509 0000BB67 762A                <1> 	jna	short csftdf2_5
 44510                              <1> 
 44511                              <1> 	; "100%"
 44512 0000BB69 BF[D7360100]        <1> 	mov	edi, percentagestr
 44513 0000BB6E B031                <1> 	mov	al, '1'
 44514 0000BB70 AA                  <1> 	stosb
 44515 0000BB71 B030                <1> 	mov	al, '0'
 44516 0000BB73 AA                  <1> 	stosb
 44517 0000BB74 AA                  <1> 	stosb
 44518                              <1> 
 44519 0000BB75 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44520 0000BB7B 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44521 0000BB82 B402                <1> 	mov	ah, 2
 44522 0000BB84 E84D5BFFFF          <1> 	call	_int10h
 44523                              <1> 
 44524 0000BB89 BE[D7360100]        <1> 	mov	esi, percentagestr
 44525 0000BB8E E897B0FFFF          <1> 	call	print_msg
 44526                              <1> csftdf2_5:
 44527 0000BB93 E987010000          <1>         jmp     csftdf2_save_fat_file_4
 44528                              <1> 
 44529                              <1> csftdf2_load_fs_file:
 44530                              <1> 	; temporary - 18/03/2016
 44531 0000BB98 E972020000          <1>         jmp     csftdf2_read_error
 44532                              <1> 
 44533                              <1> csftdf2_write_file_sectors:
 44534                              <1> 	; 19/03/2016
 44535 0000BB9D 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 44536                              <1> 	;jna	csftdf2_write_fs_file_sectors
 44537                              <1> 	; 29/07/2022
 44538 0000BBA1 7705                <1> 	ja	short csftdf2_write_fat_file_sectors
 44539 0000BBA3 E9E1050000          <1> 	jmp	csftdf2_write_fs_file_sectors
 44540                              <1> 
 44541                              <1> csftdf2_write_fat_file_sectors:
 44542                              <1> 	; 19/03/2016
 44543                              <1> 	; 18/03/2016
 44544                              <1> 	; return:
 44545                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
 44546                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
 44547                              <1> 	;   CF = 1 -> write error (error code in AL)	
 44548                              <1> 
 44549                              <1> csftdf2_write_fat_file_secs_0:
 44550 0000BBA8 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44551 0000BBAE 2B15[74830100]      <1> 	sub	edx, [csftdf_df_wbytes]
 44552 0000BBB4 3B15[6C830100]      <1> 	cmp	edx, [csftdf_w_size]	
 44553 0000BBBA 7306                <1> 	jnb	short csftdf2_write_fat_file_secs_1
 44554 0000BBBC 8915[6C830100]      <1> 	mov	[csftdf_w_size], edx		
 44555                              <1> 
 44556                              <1> csftdf2_write_fat_file_secs_1:
 44557 0000BBC2 A1[6C830100]        <1> 	mov	eax, [csftdf_w_size]
 44558 0000BBC7 29D2                <1> 	sub	edx, edx
 44559 0000BBC9 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
 44560 0000BBCD 01C8                <1> 	add	eax, ecx
 44561 0000BBCF 48                  <1> 	dec	eax
 44562 0000BBD0 F7F1                <1> 	div	ecx
 44563 0000BBD2 89C1                <1> 	mov	ecx, eax ; sector count
 44564 0000BBD4 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster]
 44565                              <1> 
 44566                              <1> 	; EBX = memory block address (current)	
 44567                              <1> 
 44568 0000BBD9 E80A0F0000          <1> 	call	write_fat_file_sectors
 44569 0000BBDE 7259                <1> 	jc	short csftdf2_write_fat_file_secs_4
 44570                              <1> 
 44571                              <1> 	; EBX = next memory address
 44572                              <1> 
 44573 0000BBE0 A1[74830100]        <1> 	mov	eax, [csftdf_df_wbytes]
 44574 0000BBE5 0305[6C830100]      <1> 	add	eax, [csftdf_w_size]
 44575 0000BBEB 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44576 0000BBF1 39D0                <1> 	cmp	eax, edx
 44577 0000BBF3 7344                <1> 	jnb	short csftdf2_write_fat_file_secs_4
 44578 0000BBF5 A3[74830100]        <1> 	mov	[csftdf_df_wbytes], eax
 44579                              <1> 	;
 44580 0000BBFA A3[16830100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
 44581                              <1> 
 44582 0000BBFF 53                  <1> 	push	ebx ; *
 44583                              <1> 
 44584 0000BC00 803D[52830100]01    <1> 	cmp	byte [DestinationFileFound], 1
 44585 0000BC07 7210                <1> 	jb	short csftdf2_write_fat_file_secs_2
 44586                              <1> 
 44587                              <1> 	; get next cluster (csftdf_w_size! bytes)
 44588 0000BC09 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster]
 44589 0000BC0E E877050000          <1> 	call	get_next_cluster
 44590 0000BC13 731C                <1> 	jnc	short csftdf2_write_fat_file_secs_3
 44591                              <1> 
 44592 0000BC15 21C0                <1> 	and	eax, eax ; end of cluster chain!?
 44593 0000BC17 7521                <1> 	jnz	short csftdf2_write_fat_file_secs_5 ; disk error !
 44594                              <1> 
 44595                              <1> csftdf2_write_fat_file_secs_2:
 44596 0000BC19 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
 44597 0000BC1E E8F30D0000          <1> 	call	add_new_cluster		
 44598 0000BC23 7215                <1> 	jc	short csftdf2_write_fat_file_secs_5
 44599                              <1> 
 44600                              <1> 	; NOTE: Destination file size may be bigger than
 44601                              <1> 	; source file size when the last reading fails after here.
 44602                              <1> 	; (The last -empty- cluster of destination file must be 
 44603                              <1> 	; truncated and LMDT must be current date&time for partial
 44604                              <1> 	; copy result!) 
 44605 0000BC25 8B15[6C830100]      <1> 	mov	edx, [csftdf_w_size] ; bytes per cluster
 44606 0000BC2B 0115[16830100]      <1> 	add	[DestinationFile_DirEntry+DirEntry_FileSize], edx
 44607                              <1> 
 44608                              <1> csftdf2_write_fat_file_secs_3:
 44609 0000BC31 5B                  <1> 	pop	ebx ; *
 44610 0000BC32 29D2                <1> 	sub	edx, edx ; 0
 44611 0000BC34 A3[64830100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
 44612                              <1> 
 44613                              <1> csftdf2_write_fat_file_secs_4:
 44614 0000BC39 C3                  <1> 	retn
 44615                              <1> 
 44616                              <1> csftdf2_write_fat_file_secs_5:
 44617 0000BC3A 5B                  <1> 	pop	ebx ; *
 44618                              <1> 	; 16/10/2016 (1Dh -> 18)
 44619 0000BC3B B812000000          <1> 	mov	eax, 18 ; Write error !
 44620 0000BC40 C3                  <1> 	retn
 44621                              <1> 
 44622                              <1> csftdf2_save_file:
 44623                              <1> 	; 09/12/2017
 44624                              <1> 	; 25/03/2016
 44625                              <1> 	; 19/03/2016
 44626                              <1> 	; 18/03/2016
 44627 0000BC41 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; logical dos drv desc. tbl.
 44628                              <1> 
 44629 0000BC47 8B1D[58830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
 44630                              <1> 
 44631 0000BC4D 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 44632                              <1> 	;jna	csftdf2_save_fs_file
 44633                              <1> 	; 29/07/2022	
 44634 0000BC51 7705                <1> 	ja	short csftdf2_save_fat_file
 44635 0000BC53 E9F5010000          <1> 	jmp	csftdf2_save_fs_file
 44636                              <1> 
 44637                              <1> csftdf2_save_fat_file:
 44638 0000BC58 53                  <1> 	push	ebx; *
 44639                              <1> 
 44640 0000BC59 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44641 0000BC60 7724                <1> 	ja	short csftdf2_save_fat_file_0
 44642                              <1> 
 44643                              <1> 	; Set cursor position
 44644                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
 44645 0000BC62 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44646 0000BC68 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44647 0000BC6F B402                <1> 	mov	ah, 2
 44648 0000BC71 E8605AFFFF          <1> 	call	_int10h
 44649                              <1> 	
 44650 0000BC76 BE[CB360100]        <1> 	mov	esi, msg_writing
 44651 0000BC7B E8AAAFFFFF          <1> 	call	print_msg
 44652                              <1> 
 44653                              <1> csftdf2_save_fat_file_next:
 44654 0000BC80 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 25/03/2016
 44655                              <1> 
 44656                              <1> csftdf2_save_fat_file_0:
 44657 0000BC86 5B                  <1> 	pop	ebx ; *
 44658                              <1> 
 44659                              <1> csftdf2_save_fat_file_1:
 44660 0000BC87 E811FFFFFF          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016	
 44661                              <1> 	;jc	csftdf2_rw_error ; eocc! or disk error! 
 44662                              <1> 	; 29/07/2022
 44663 0000BC8C 7305                <1> 	jnc	short csftdf2_6
 44664 0000BC8E E97E010000          <1> 	jmp	csftdf2_rw_error
 44665                              <1> 
 44666                              <1> csftdf2_6:
 44667 0000BC93 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
 44668 0000BC95 756C                <1>         jnz     short csftdf2_save_fat_file_3 ; 25/03/2016
 44669                              <1> 
 44670 0000BC97 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44671 0000BC9E 76E7                <1> 	jna	short csftdf2_save_fat_file_1
 44672                              <1> 
 44673 0000BCA0 B020                <1> 	mov	al, 20h
 44674 0000BCA2 BF[D7360100]        <1> 	mov	edi, percentagestr
 44675 0000BCA7 AA                  <1> 	stosb
 44676 0000BCA8 AA                  <1> 	stosb
 44677 0000BCA9 A1[74830100]        <1> 	mov	eax, [csftdf_df_wbytes]
 44678                              <1> 	;mov	edx, 100
 44679                              <1> 	; 29/07/2022
 44680 0000BCAE 31D2                <1> 	xor	edx, edx
 44681 0000BCB0 B264                <1> 	mov	dl, 100
 44682 0000BCB2 F7E2                <1> 	mul	edx
 44683 0000BCB4 8B0D[54830100]      <1> 	mov	ecx, [csftdf_filesize]	
 44684 0000BCBA F7F1                <1> 	div	ecx
 44685 0000BCBC B10A                <1> 	mov	cl, 10
 44686 0000BCBE F6F1                <1> 	div	cl
 44687 0000BCC0 80C430              <1> 	add	ah, '0'
 44688 0000BCC3 8827                <1> 	mov	[edi], ah
 44689 0000BCC5 20C0                <1> 	and	al, al
 44690 0000BCC7 740A                <1> 	jz	short csftdf2_save_fat_file_2
 44691 0000BCC9 4F                  <1> 	dec	edi
 44692                              <1> 	;cbw
 44693 0000BCCA 30E4                <1> 	xor	ah, ah ; 09/12/2017
 44694 0000BCCC F6F1                <1> 	div	cl
 44695 0000BCCE 80C430              <1> 	add	ah, '0'
 44696 0000BCD1 8827                <1> 	mov	[edi], ah
 44697                              <1> 	;and	al, al
 44698                              <1> 	;jz	short csftdf2_save_fat_file_2
 44699                              <1> 	;dec	edi
 44700                              <1> 	;mov	[edi], '1' ; 100%		
 44701                              <1> 
 44702                              <1> csftdf2_save_fat_file_2:
 44703 0000BCD3 53                  <1> 	push	ebx ; *
 44704                              <1> 
 44705 0000BCD4 E802000000          <1> 	call	csftdf2_print_wr_percentage ; 25/03/2016
 44706                              <1> 
 44707 0000BCD9 EBA5                <1>         jmp     csftdf2_save_fat_file_next
 44708                              <1> 
 44709                              <1> csftdf2_print_wr_percentage:
 44710                              <1> 	; Set cursor position
 44711                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
 44712 0000BCDB 8A3D[79830100]      <1> 	mov	bh, [csftdf_videopage]
 44713 0000BCE1 668B15[7A830100]    <1> 	mov	dx, [csftdf_cursorpos]
 44714 0000BCE8 B402                <1> 	mov	ah, 2
 44715 0000BCEA E8E759FFFF          <1> 	call	_int10h
 44716                              <1> 
 44717 0000BCEF BE[CB360100]        <1> 	mov	esi, msg_writing
 44718 0000BCF4 E831AFFFFF          <1> 	call	print_msg
 44719                              <1> 
 44720 0000BCF9 BE[D7360100]        <1> 	mov	esi, percentagestr
 44721                              <1> 	;call	print_msg
 44722                              <1> 	;retn
 44723 0000BCFE E927AFFFFF          <1> 	jmp	print_msg
 44724                              <1> 
 44725                              <1> csftdf2_save_fat_file_3:
 44726 0000BD03 803D[78830100]00    <1> 	cmp	byte [csftdf_percentage], 0
 44727                              <1>         ;jna	csftdf2_save_fat_file_4 ; 25/03/2016
 44728                              <1> 	; 29/07/2022
 44729 0000BD0A 7702                <1> 	ja	short csftdf2_7
 44730 0000BD0C EB11                <1> 	jmp	csftdf2_save_fat_file_4
 44731                              <1> 
 44732                              <1> csftdf2_7:
 44733                              <1> 	; "100%"
 44734 0000BD0E BF[D7360100]        <1> 	mov	edi, percentagestr
 44735 0000BD13 B031                <1> 	mov	al, '1'
 44736 0000BD15 AA                  <1> 	stosb
 44737 0000BD16 B030                <1> 	mov	al, '0'
 44738 0000BD18 AA                  <1> 	stosb
 44739 0000BD19 AA                  <1> 	stosb
 44740                              <1> 
 44741 0000BD1A E8BCFFFFFF          <1> 	call	csftdf2_print_wr_percentage
 44742                              <1> 
 44743                              <1> csftdf2_save_fat_file_4:
 44744 0000BD1F 803D[52830100]00    <1> 	cmp	byte [DestinationFileFound], 0
 44745 0000BD26 7647                <1> 	jna	short csftdf2_save_fat_file_6
 44746                              <1> 
 44747 0000BD28 8B35[80830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 31/03/2016	
 44748                              <1> 
 44749 0000BD2E A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
 44750 0000BD33 E852040000          <1> 	call	get_next_cluster
 44751 0000BD38 7235                <1> 	jc	short csftdf2_save_fat_file_6 ; eocc! or disk error!
 44752                              <1> 
 44753 0000BD3A A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
 44754                              <1> 	;xor	ecx, ecx
 44755                              <1> 	;mov	[FAT_ClusterCounter], ecx ; 0 ; reset
 44756                              <1> 	;dec	ecx ; 0FFFFFFFFh
 44757                              <1> 	;shr	ecx, 4 ; 28 bit ; 0FFFFFFFh
 44758 0000BD3F B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
 44759 0000BD44 E830070000          <1> 	call	update_cluster
 44760 0000BD49 7224                <1> 	jc	short csftdf2_save_fat_file_6 ; really last cluster!?
 44761                              <1> 
 44762 0000BD4B A3[64830100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
 44763                              <1> 	
 44764                              <1> 	; byte [FAT_BuffValidData] = 2 
 44765 0000BD50 E8A7090000          <1> 	call	save_fat_buffer
 44766 0000BD55 730E                <1> 	jnc	short csftdf2_save_fat_file_5
 44767                              <1> 	
 44768 0000BD57 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44769 0000BD5D 8915[16830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
 44770 0000BD63 EB58                <1> 	jmp	short csftdf2_save_fat_file_err3
 44771                              <1> 
 44772                              <1> csftdf2_save_fat_file_5:
 44773 0000BD65 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster]
 44774                              <1> 
 44775                              <1> 	; EAX = First cluster to be truncated/unlinked
 44776                              <1> 	; ESI = Logical dos drive description table address
 44777 0000BD6A E8CB0B0000          <1> 	call	truncate_cluster_chain
 44778                              <1> 
 44779                              <1> csftdf2_save_fat_file_6:
 44780                              <1> 	; 28/03/2016
 44781 0000BD6F BE[85820100]        <1> 	mov	esi, SourceFile_DirEntry+DirEntry_Attr ; +11 to + 18
 44782 0000BD74 BF[05830100]        <1> 	mov	edi, DestinationFile_DirEntry+DirEntry_Attr ; +11 to + 18
 44783 0000BD79 A4                  <1> 	movsb ; +11
 44784 0000BD7A A5                  <1> 	movsd ; +12 .. +15
 44785 0000BD7B 66A5                <1> 	movsw ; +16 .. +17
 44786                              <1> 		; + 18
 44787 0000BD7D 83C604              <1> 	add	esi, 4
 44788 0000BD80 83C704              <1> 	add	edi, 4
 44789 0000BD83 A5                  <1> 	movsd	; DirEntry_WrtTime ; +22 .. +25
 44790                              <1> 
 44791 0000BD84 8B15[54830100]      <1> 	mov	edx, [csftdf_filesize]
 44792 0000BD8A 8915[16830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
 44793                              <1> 
 44794 0000BD90 E8E9F0FFFF          <1> 	call	convert_current_date_time
 44795                              <1> 	; DX = Date in dos dir entry format
 44796                              <1> 	; AX = Time in dos dir entry format
 44797 0000BD95 EB4D                <1> 	jmp	short csftdf2_save_fat_file_7
 44798                              <1> 
 44799                              <1> csftdf2_save_fat_file_err1:
 44800 0000BD97 5B                  <1> 	pop	ebx ; *	
 44801                              <1> csftdf2_save_fat_file_err2:
 44802 0000BD98 A1[74830100]        <1> 	mov	eax, [csftdf_df_wbytes]
 44803 0000BD9D 8B15[16830100]      <1> 	mov	edx, [DestinationFile_DirEntry+DirEntry_FileSize]
 44804 0000BDA3 39C2                <1> 	cmp	edx, eax
 44805 0000BDA5 7616                <1> 	jna	short csftdf2_save_fat_file_err3
 44806 0000BDA7 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last (empty) cluster
 44807                              <1> 	; ESI = Logical dos drive description table address
 44808 0000BDAC E8890B0000          <1> 	call	truncate_cluster_chain
 44809 0000BDB1 720A                <1> 	jc	short csftdf2_save_fat_file_err3
 44810 0000BDB3 A1[74830100]        <1> 	mov	eax, [csftdf_df_wbytes]	
 44811 0000BDB8 A3[16830100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
 44812                              <1> csftdf2_save_fat_file_err3:
 44813 0000BDBD E8BCF0FFFF          <1> 	call	convert_current_date_time
 44814                              <1> 	; DX = Date in dos dir entry format
 44815                              <1> 	; AX = Time in dos dir entry format
 44816 0000BDC2 C605[07830100]00    <1> 	mov	byte [DestinationFile_DirEntry+DirEntry_CrtTimeTenth], 0
 44817 0000BDC9 66A3[08830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtTime], ax
 44818 0000BDCF 668915[0A830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtDate], dx		
 44819 0000BDD6 66A3[10830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtTime], ax
 44820 0000BDDC 668915[12830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtDate], dx
 44821 0000BDE3 F9                  <1> 	stc
 44822                              <1> csftdf2_save_fat_file_7:
 44823 0000BDE4 9C                  <1> 	pushf
 44824 0000BDE5 668915[0C830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_LastAccDate], dx
 44825 0000BDEC BE[FA820100]        <1> 	mov	esi, DestinationFile_DirEntry
 44826 0000BDF1 BF00000800          <1> 	mov	edi, Directory_Buffer
 44827 0000BDF6 0FB70D[22830100]    <1> 	movzx	ecx, word [DestinationFile_DirEntryNumber] ; (<2048)
 44828                              <1> 	;shl	cx, 5 ; 32 * directory entry number
 44829                              <1> 	; 29/07/2022
 44830 0000BDFD C1E105              <1> 	shl	ecx, 5
 44831 0000BE00 01CF                <1> 	add	edi, ecx
 44832                              <1> 	;mov	ecx, 8
 44833                              <1> 	;mov	cx, 8
 44834                              <1> 	; 29/07/2022
 44835                              <1> 	;sub	ecx, ecx
 44836 0000BE02 28ED                <1> 	sub	ch, ch
 44837 0000BE04 B108                <1> 	mov	cl, 8
 44838 0000BE06 F3A5                <1> 	rep	movsd
 44839 0000BE08 9D                  <1> 	popf
 44840 0000BE09 730B                <1> 	jnc	short csftdf2_write_file_OK
 44841                              <1> 	 		
 44842                              <1> csftdf2_write_error:
 44843                              <1> 	; 18/03/2016
 44844 0000BE0B B01D                <1> 	mov	al, 1Dh ; write error
 44845 0000BE0D EB02                <1> 	jmp	short csftdf2_rw_error
 44846                              <1> 
 44847                              <1> 	; 16/03/2016
 44848                              <1> csftdf2_read_error:
 44849 0000BE0F B011                <1> 	mov	al, 17 ; ; Drive not ready or read error!
 44850                              <1> csftdf2_rw_error:
 44851 0000BE11 A2[51830100]        <1> 	mov	[csftdf_rw_err], al 
 44852                              <1> 
 44853                              <1> csftdf2_write_file_OK:
 44854                              <1> 	; 18/03/2016
 44855 0000BE16 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 44856 0000BE1D E8F1F0FFFF          <1> 	call	save_directory_buffer
 44857                              <1> 
 44858                              <1>  	; Update last modification date&time of destination
 44859                              <1> 	; file's (parent) directory
 44860 0000BE22 E884F1FFFF          <1> 	call	update_parent_dir_lmdt
 44861                              <1> 	;
 44862 0000BE27 A1[58830100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
 44863                              <1> 
 44864 0000BE2C 21C0                <1> 	and	eax, eax
 44865 0000BE2E 750E                <1> 	jnz	short csftdf2_dealloc_mblock
 44866                              <1> 
 44867 0000BE30 88C5                <1> 	mov	ch, al ; 0 (Cluster r/w, not full loading)
 44868                              <1> csftdf2_dealloc_retn:
 44869 0000BE32 8A0D[51830100]      <1> 	mov	cl, [csftdf_rw_err]
 44870 0000BE38 A1[64830100]        <1> 	mov	eax, [csftdf_df_cluster]
 44871 0000BE3D C3                  <1> 	retn
 44872                              <1> 
 44873                              <1> csftdf2_dealloc_mblock:
 44874 0000BE3E 8B0D[5C830100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
 44875 0000BE44 E8819FFFFF          <1> 	call	deallocate_memory_block
 44876 0000BE49 B5FF                <1>         mov     ch, 0FFh ; (File was full loaded at memory)
 44877 0000BE4B EBE5                <1> 	jmp	short csftdf2_dealloc_retn
 44878                              <1> 
 44879                              <1> csftdf2_save_fs_file:
 44880                              <1> 	; 16/10/2016 (1Dh -> 18)
 44881                              <1> 	; temporary - (21/03/2016)
 44882                              <1> 	;mov	eax, 18 ; write error
 44883                              <1> 	; 29/07/2022
 44884 0000BE4D 31C0                <1> 	xor	eax, eax
 44885 0000BE4F B012                <1> 	mov	al, 18
 44886 0000BE51 F9                  <1> 	stc
 44887 0000BE52 C3                  <1> 	retn
 44888                              <1> 
 44889                              <1> create_file:
 44890                              <1> 	; 30/07/2022
 44891                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 44892                              <1> 	; 16/10/2016
 44893                              <1> 	; 24/03/2016, 31/03/2016
 44894                              <1> 	; 20/03/2016, 21/03/2016, 23/03/2016
 44895                              <1> 	; 19/03/2016 (TRDOS 396 = TRDOS v2.0)
 44896                              <1> 	; 03/09/2011 (FILE.ASM, 'proc_create_file')
 44897                              <1> 	; 09/08/2010
 44898                              <1> 	;
 44899                              <1> 	; INPUT ->
 44900                              <1> 	; 	EAX = File Size
 44901                              <1> 	; 	ESI = ASCIIZ File Name
 44902                              <1> 	; 	CL = File Attributes 
 44903                              <1> 	;	EBX = FFFFFFFFh -> create empty file 
 44904                              <1> 	;			 (only for FAT fs) 
 44905                              <1> 	; OUTPUT ->
 44906                              <1> 	;     CF = 0 ->
 44907                              <1> 	;	EAX = New file's first cluster
 44908                              <1> 	; 	ESI = Logical Dos Drv Descr. Table Addr.
 44909                              <1> 	; 	EBX = offset CreateFile_Size
 44910                              <1> 	; 	ECX = Sectors per cluster (<256) 
 44911                              <1> 	; 	EDX = Directory entry index/number (<65536)
 44912                              <1> 	;     CF = 1 -> error code in AL
 44913                              <1> 
 44914                              <1> ;	test	cl, 18h (directory or volume name)
 44915                              <1> ;	jnz	short loc_createfile_access_denied
 44916 0000BE53 80E107              <1> 	and	cl, 07h ; S, H, R
 44917 0000BE56 880D[A0830100]      <1>         mov     [createfile_attrib], cl 
 44918                              <1> 
 44919 0000BE5C 89D9                <1> 	mov	ecx, ebx
 44920 0000BE5E 89F3                <1> 	mov	ebx, esi ; ASCIIZ File Name address
 44921 0000BE60 29D2                <1> 	sub	edx, edx
 44922 0000BE62 8A35[42780100]      <1>         mov     dh, [Current_Drv]
 44923 0000BE68 BE00010900          <1>         mov     esi, Logical_DOSDisks
 44924 0000BE6D 01D6                <1> 	add	esi, edx
 44925                              <1> 
 44926 0000BE6F 8815[AB830100]      <1> 	mov	[createfile_UpdatePDir], dl ; 0 ; 31/03/2016 
 44927                              <1> 
 44928                              <1> 	; LD_DiskType = 0 for write protection (read only) 
 44929 0000BE75 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
 44930 0000BE79 7308                <1> 	jnb	short loc_createfile_check_file_sytem
 44931                              <1> 	; 16/10/2016 (TRDOS Error code: 30, disk write protected) 
 44932                              <1> 	;mov	eax, 30 ; 13h, MSDOS err : Disk write-protected 
 44933                              <1> 	;mov	dx, 0
 44934                              <1> 	; 29/07/2022
 44935 0000BE7B 31D2                <1> 	xor	edx, edx ; 0
 44936 0000BE7D 31C0                <1> 	xor	eax, eax ; 0
 44937 0000BE7F B01E                <1> 	mov	al, 30	
 44938 0000BE81 F9                  <1> 	stc
 44939                              <1> 	; err retn: EDX = 0, EBX = File name offset
 44940                              <1> 	; ESI -> Dos drive description table address	
 44941 0000BE82 C3                  <1> 	retn
 44942                              <1> 
 44943                              <1> ;loc_createfile_access_denied:
 44944                              <1> ;	mov	eax, 05h ; access denied (invalid attributes input)
 44945                              <1> ;	stc
 44946                              <1> ;	retn
 44947                              <1> 
 44948                              <1> loc_createfile_check_file_sytem:
 44949 0000BE83 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
 44950 0000BE87 730A                <1> 	jnb	short loc_createfile_chk_empty_FAT_file_sign1
 44951                              <1> 
 44952 0000BE89 A3[8C830100]        <1> 	mov	[createfile_size], eax
 44953                              <1> 	; ESI = Logical Dos Drive Description Table address
 44954                              <1> 	; EBX = ASCIIZ File Name address
 44955 0000BE8E E9F6020000          <1> 	jmp	create_fs_file
 44956                              <1> 
 44957                              <1> loc_createfile_chk_empty_FAT_file_sign1:
 44958                              <1> 	; ECX = FFFFFFFFh -> create empty file if drive has FAT fs
 44959 0000BE93 41                  <1> 	inc	ecx
 44960 0000BE94 7506                <1> 	jnz	short loc_createfile_chk_empty_FAT_file_sign2
 44961 0000BE96 890D[8C830100]      <1> 	mov	[createfile_size], ecx ; 0 ; empty file
 44962                              <1> 
 44963                              <1> loc_createfile_chk_empty_FAT_file_sign2:
 44964                              <1> 	; 23/03/2016
 44965 0000BE9C 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec]
 44966 0000BEA0 66890D[A8830100]    <1> 	mov	[createfile_BytesPerSec], cx
 44967                              <1> 	
 44968                              <1> 	; EBX = ASCIIZ File Name address
 44969 0000BEA7 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 44970 0000BEAB 8815[A1830100]      <1> 	mov	[createfile_SecPerClust], dl
 44971 0000BEB1 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
 44972 0000BEB4 39D1                <1> 	cmp	ecx, edx ; byte [createfile_SecPerClust]
 44973 0000BEB6 7306                <1> 	jnb	short loc_create_fat_file
 44974                              <1> 	  
 44975                              <1> loc_createfile_insufficient_disk_space:
 44976 0000BEB8 B827000000          <1> 	mov	eax, 27h
 44977                              <1> loc_createfile_gffc_retn:
 44978 0000BEBD C3                  <1> 	retn
 44979                              <1> 
 44980                              <1> loc_create_fat_file:
 44981 0000BEBE 891D[84830100]      <1> 	mov	[createfile_Name_Offset], ebx
 44982 0000BEC4 890D[88830100]      <1> 	mov	[createfile_FreeSectors], ecx
 44983                              <1> 
 44984                              <1> loc_createfile_gffc_1:
 44985 0000BECA E8DD040000          <1> 	call	get_first_free_cluster
 44986 0000BECF 72EC                <1> 	jc	short loc_createfile_gffc_retn
 44987                              <1> 
 44988 0000BED1 A3[90830100]        <1> 	mov	[createfile_FFCluster], eax
 44989                              <1> 
 44990                              <1> loc_createfile_locate_ffe_on_directory:
 44991                              <1> 	; Current directory fcluster <> Directory buffer cluster
 44992                              <1> 	; Current directory will be reloaded by
 44993                              <1> 	; 'locate_current_dir_file' procedure
 44994                              <1> 	;
 44995                              <1> 	; ESI = Logical Dos Drv Desc. Table Adress
 44996 0000BED6 56                  <1> 	push	esi ; *
 44997 0000BED7 31C0                <1> 	xor	eax, eax
 44998                              <1> 
 44999 0000BED9 A3[5E7F0100]        <1> 	mov	dword [FAT_ClusterCounter], eax ; 0
 45000                              <1> 	; 21/03/2016
 45001 0000BEDE A2[AA830100]        <1> 	mov	byte [createfile_wfc], al ; 0 
 45002                              <1> 
 45003 0000BEE3 89C1                <1>  	mov	ecx, eax
 45004 0000BEE5 6649                <1> 	dec	cx ; FFFFh  
 45005                              <1> 	; CX = FFFFh -> find first deleted or free entry
 45006                              <1> 	; ESI would be ASCIIZ filename address if the call
 45007                              <1> 	; would not be for first free or deleted dir entry  
 45008 0000BEE7 E852E8FFFF          <1> 	call	locate_current_dir_file
 45009                              <1> 	;jnc	loc_createfile_set_ff_dir_entry
 45010                              <1> 	; 29/07/2022
 45011 0000BEEC 7205                <1> 	jc	short loc_createfile_locate_file_err
 45012 0000BEEE E9EC000000          <1> 	jmp	loc_createfile_set_ff_dir_entry	
 45013                              <1> 
 45014                              <1> loc_createfile_locate_file_err: ; 29/07/2022
 45015 0000BEF3 5E                  <1> 	pop	esi ; *
 45016                              <1> 	 ; ESI = Logical DOS Drv. Description Table Address 
 45017 0000BEF4 83F802              <1> 	cmp	eax, 2
 45018 0000BEF7 7402                <1> 	je	short loc_createfile_add_new_cluster
 45019                              <1> loc_createfile_locate_file_stc_retn:
 45020 0000BEF9 F9                  <1> 	stc
 45021 0000BEFA C3                  <1> 	retn
 45022                              <1> 
 45023                              <1> loc_createfile_add_new_cluster:
 45024 0000BEFB 803D[41780100]02    <1> 	cmp	byte [Current_FATType], 2
 45025                              <1> 	;cmp	byte [esi+LD_FATType], 2
 45026 0000BF02 770C                <1> 	ja	short loc_createfile_add_new_cluster_check_fsc
 45027 0000BF04 803D[40780100]01    <1> 	cmp	byte [Current_Dir_Level], 1
 45028                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
 45029 0000BF0B 7303                <1> 	jnb	short loc_createfile_add_new_cluster_check_fsc
 45030                              <1> 	
 45031                              <1> 	;mov	eax, 12
 45032 0000BF0D B00C                <1> 	mov	al, 12 ; No more files 
 45033                              <1> 
 45034                              <1> loc_createfile_anc_retn:
 45035 0000BF0F C3                  <1> 	retn
 45036                              <1> 
 45037                              <1> loc_createfile_add_new_cluster_check_fsc:
 45038 0000BF10 8B0D[88830100]      <1> 	mov	ecx, [createfile_FreeSectors]
 45039 0000BF16 0FB605[A1830100]    <1> 	movzx	eax, byte [createfile_SecPerClust]
 45040                              <1> 	;shl	ax, 1 ; AX = 2 * AX
 45041                              <1> 	; 29/07/2022
 45042 0000BF1D D1E0                <1> 	shl	eax, 1
 45043 0000BF1F 39C1                <1> 	cmp	ecx, eax
 45044 0000BF21 7295                <1>         jb	short loc_createfile_insufficient_disk_space
 45045                              <1> 
 45046                              <1> loc_createfile_add_new_subdir_cluster:
 45047 0000BF23 8B15[6E7F0100]      <1> 	mov	edx, [DirBuff_Cluster]
 45048 0000BF29 8915[94830100]      <1> 	mov	[createfile_LastDirCluster], edx	
 45049                              <1> 
 45050 0000BF2F A1[90830100]        <1> 	mov	eax, [createfile_FFCluster]
 45051 0000BF34 E80D040000          <1> 	call	load_FAT_sub_directory 
 45052 0000BF39 72D4                <1> 	jc	short loc_createfile_anc_retn
 45053                              <1> 
 45054                              <1> pass_createfile_add_new_subdir_cluster:
 45055                              <1> 	;movzx	eax, word [esi+LD_BPB+BytesPerSec]
 45056 0000BF3B 0FB705[A8830100]    <1> 	movzx	eax, word [createfile_BytesPerSec] ; 23/03/2016
 45057 0000BF42 F7E1                <1> 	mul	ecx ; ecx = directory buffer sector count
 45058 0000BF44 89C1                <1> 	mov	ecx, eax
 45059 0000BF46 C1E902              <1> 	shr	ecx, 2 ; dword count
 45060 0000BF49 29C0                <1> 	sub	eax, eax ; 0
 45061 0000BF4B F3AB                <1> 	rep	stosd 
 45062                              <1> 	;
 45063 0000BF4D C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
 45064 0000BF54 E8BAEFFFFF          <1> 	call	save_directory_buffer
 45065 0000BF59 72B4                <1> 	jc	short loc_createfile_anc_retn
 45066                              <1> 
 45067                              <1> loc_createfile_save_added_subdir_cluster:
 45068 0000BF5B A1[94830100]        <1> 	mov	eax, [createfile_LastDirCluster]
 45069 0000BF60 8B0D[90830100]      <1> 	mov	ecx, [createfile_FFCluster]
 45070 0000BF66 E80E050000          <1> 	call	update_cluster
 45071 0000BF6B 7304                <1> 	jnc	short loc_createfile_save_fat_buffer_0
 45072 0000BF6D 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 45073 0000BF6F 751A                <1> 	jnz	short loc_createfile_save_fat_buffer_stc_retn
 45074                              <1> 
 45075                              <1> loc_createfile_save_fat_buffer_0:
 45076 0000BF71 A1[90830100]        <1> 	mov	eax, [createfile_FFCluster]
 45077 0000BF76 A3[94830100]        <1> 	mov	[createfile_LastDirCluster], eax
 45078 0000BF7B B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh ; 28 bit
 45079 0000BF80 E8F4040000          <1> 	call	update_cluster
 45080 0000BF85 7306                <1> 	jnc	short loc_createfile_save_fat_buffer_1
 45081 0000BF87 09C0                <1> 	or	eax, eax ; Was it free cluster
 45082 0000BF89 7402                <1> 	jz	short loc_createfile_save_fat_buffer_1
 45083                              <1> 
 45084                              <1> loc_createfile_save_fat_buffer_stc_retn:
 45085 0000BF8B F9                  <1> 	stc
 45086                              <1> loc_createfile_save_fat_buffer_retn:
 45087                              <1> loc_createfile_gffc_2_stc_retn:
 45088 0000BF8C C3                  <1> 	retn
 45089                              <1> 
 45090                              <1> loc_createfile_save_fat_buffer_1:
 45091                              <1> 	; byte [FAT_BuffValidData] = 2 
 45092 0000BF8D E86A070000          <1> 	call	save_fat_buffer
 45093 0000BF92 72F8                <1> 	jc	short loc_createfile_save_fat_buffer_retn
 45094                              <1> 
 45095 0000BF94 803D[5E7F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
 45096 0000BF9B 7222                <1> 	jb	short loc_createfile_save_fat_buffer_2
 45097                              <1> 
 45098                              <1> 	; ESI = Logical DOS Drive Description Table address 
 45099 0000BF9D A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 45100                              <1> 
 45101 0000BFA2 C605[5E7F0100]00    <1> 	mov	byte [FAT_ClusterCounter], 0 ; 21/03/2016
 45102                              <1> 
 45103 0000BFA9 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
 45104 0000BFAD E8DB070000          <1> 	call	calculate_fat_freespace
 45105                              <1> 
 45106                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
 45107                              <1> 	;jnz	short loc_createfile_save_fat_buffer_2
 45108                              <1> 
 45109                              <1> 	; ecx > 0 -> Recalculation is needed
 45110 0000BFB2 09C9                <1> 	or	ecx, ecx 
 45111 0000BFB4 7409                <1> 	jz	short loc_createfile_save_fat_buffer_2
 45112                              <1> 
 45113 0000BFB6 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
 45114 0000BFBA E8CE070000          <1> 	call	calculate_fat_freespace
 45115                              <1> 
 45116                              <1> loc_createfile_save_fat_buffer_2:
 45117                              <1> 	;call	update_parent_dir_lmdt
 45118                              <1> 
 45119                              <1> loc_createfile_gffc_2:
 45120 0000BFBF E8E8030000          <1> 	call	get_first_free_cluster
 45121 0000BFC4 72C6                <1> 	jc	short loc_createfile_gffc_2_stc_retn
 45122                              <1> 
 45123 0000BFC6 A3[90830100]        <1> 	mov	[createfile_FFCluster], eax
 45124                              <1> 
 45125 0000BFCB A1[94830100]        <1> 	mov	eax, [createfile_LastDirCluster]
 45126                              <1> 	
 45127 0000BFD0 E871030000          <1> 	call	load_FAT_sub_directory 
 45128 0000BFD5 72B5                <1> 	jc	short loc_createfile_gffc_2_stc_retn
 45129                              <1> 
 45130 0000BFD7 BF00000800          <1> 	mov	edi, Directory_Buffer
 45131                              <1> 
 45132                              <1> 	;sub	bx, bx ; directory entry index/number = 0
 45133                              <1> 	; 29/07/2022
 45134 0000BFDC 29C9                <1> 	sub	ecx, ecx
 45135                              <1> 
 45136 0000BFDE 56                  <1> 	push	esi ; * ; 23/03/2016
 45137                              <1> 
 45138                              <1> loc_createfile_set_ff_dir_entry:
 45139                              <1> 	;mov	[createfile_DirIndex], bx
 45140                              <1> 	; 29/07/2022
 45141 0000BFDF 66890D[A2830100]    <1> 	mov	[createfile_DirIndex], cx ; 0
 45142                              <1> 
 45143                              <1>         ; EDI = Directory entry address
 45144 0000BFE6 8B35[84830100]      <1> 	mov	esi, [createfile_Name_Offset]
 45145 0000BFEC A1[90830100]        <1> 	mov	eax, [createfile_FFCluster]
 45146 0000BFF1 A3[98830100]        <1> 	mov	[createfile_Cluster], eax ; 24/03/2016
 45147                              <1> 	;mov	ch, 0FFh
 45148                              <1>         ; 29/07/2022
 45149                              <1> 	; ecx = 0
 45150 0000BFF6 FECD                <1> 	dec	ch ; 0 -> 0FFh
 45151 0000BFF8 8A0D[A0830100]      <1> 	mov	cl, [createfile_attrib] ; file attributes
 45152                              <1> 	; CH > 0 -> File size is in [EBX]
 45153 0000BFFE BB[8C830100]        <1> 	mov	ebx, createfile_size
 45154                              <1>   
 45155 0000C003 E838EEFFFF          <1> 	call	make_directory_entry
 45156                              <1> 	
 45157 0000C008 5E                  <1> 	pop	esi ; * ; ESI = Logical Dos Drv Desc. Table address
 45158                              <1> 
 45159 0000C009 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
 45160 0000C010 E8FEEEFFFF          <1> 	call	save_directory_buffer
 45161 0000C015 7221                <1> 	jc	short loc_createfile_set_ff_dir_entry_retn
 45162                              <1> 
 45163 0000C017 C605[AB830100]01    <1> 	mov	byte [createfile_UpdatePDir], 1 ; 31/03/2016 
 45164                              <1> 
 45165                              <1> loc_createfile_get_set_write_file_cluster:
 45166 0000C01E A1[8C830100]        <1> 	mov	eax, [createfile_size]
 45167 0000C023 09C0                <1> 	or	eax, eax
 45168 0000C025 756B                <1> 	jnz	short loc_createfile_get_set_wfc_cont
 45169 0000C027 40                  <1> 	inc	eax
 45170                              <1> 	; 23/03/2016
 45171 0000C028 0FB61D[A1830100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
 45172                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512
 45173 0000C02F 0FB70D[A8830100]    <1>         movzx   ecx, word [createfile_BytesPerSec] ; 512
 45174 0000C036 EB77                <1> 	jmp	loc_createfile_set_cluster_count 
 45175                              <1> 
 45176                              <1> loc_createfile_set_ff_dir_entry_retn:
 45177 0000C038 C3                  <1> 	retn
 45178                              <1> 
 45179                              <1> loc_createfile_write_fcluster_to_disk:
 45180 0000C039 034668              <1> 	add	eax, [esi+LD_DATABegin] ; convert to physical address
 45181 0000C03C BB00000700          <1> 	mov	ebx, Cluster_Buffer
 45182                              <1> 	; ESI = Logical DOS Drv. Desc. Tbl. address
 45183                              <1> 	; EAX = Disk address
 45184                              <1> 	; EBX = Sector Buffer
 45185                              <1> 	; ECX = sectors per cluster
 45186 0000C041 E8D45C0000          <1> 	call	disk_write
 45187 0000C046 7211                <1> 	jc	short loc_createfile_dsk_wr_err
 45188                              <1> 
 45189                              <1> loc_createfile_update_fat_cluster:
 45190                              <1> 	; 21/03/2016	
 45191 0000C048 803D[AA830100]00    <1> 	cmp	byte [createfile_wfc], 0 
 45192 0000C04F 7711                <1> 	ja	short loc_createfile_update_fat_cluster_n1
 45193                              <1> 
 45194 0000C051 FE05[AA830100]      <1> 	inc	byte [createfile_wfc] ; 1
 45195 0000C057 EB1F                <1> 	jmp	short loc_createfile_update_fat_cluster_n2
 45196                              <1> 
 45197                              <1> loc_createfile_dsk_wr_err:
 45198                              <1> 	; 16/10/2016 (1Dh -> 18)
 45199                              <1> 	; 23/03/2016
 45200                              <1> 	;mov	eax, 18 ; Drive not ready or write error !
 45201                              <1> 	; 29/07/2022
 45202 0000C059 29C0                <1> 	sub	eax, eax
 45203 0000C05B B012                <1> 	mov	al, 18
 45204                              <1> loc_cf_stc_retn:
 45205 0000C05D E9B7000000          <1> 	jmp	loc_createfile_stc_retn
 45206                              <1> 
 45207                              <1> loc_createfile_update_fat_cluster_n1:
 45208 0000C062 A1[9C830100]        <1> 	mov	eax, [createfile_PCluster]
 45209 0000C067 8B0D[98830100]      <1> 	mov	ecx, [createfile_Cluster]
 45210 0000C06D E807040000          <1> 	call	update_cluster
 45211 0000C072 7304                <1> 	jnc	short loc_createfile_update_fat_cluster_n2
 45212 0000C074 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 45213                              <1> 	;jnz	loc_createfile_stc_retn
 45214                              <1> 	; 29/07/2022
 45215 0000C076 75E5                <1> 	jnz	short loc_cf_stc_retn
 45216                              <1> 
 45217                              <1> loc_createfile_update_fat_cluster_n2:
 45218 0000C078 A1[98830100]        <1>         mov	eax, [createfile_Cluster]
 45219 0000C07D B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
 45220 0000C082 E8F2030000          <1> 	call	update_cluster
 45221 0000C087 734D                <1> 	jnc	short loc_createfile_save_fat_buffer_3
 45222 0000C089 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 45223 0000C08B 7449                <1> 	jz	short loc_createfile_save_fat_buffer_3
 45224                              <1> 
 45225                              <1> loc_cf_upd_fat_fcluster_stc_retn:
 45226 0000C08D E987000000          <1> 	jmp	loc_createfile_stc_retn
 45227                              <1> 
 45228                              <1> loc_createfile_get_set_wfc_cont:
 45229                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512	
 45230 0000C092 0FB70D[A8830100]    <1> 	movzx	ecx, word [createfile_BytesPerSec] ; 512
 45231 0000C099 01C8                <1> 	add	eax, ecx
 45232 0000C09B 48                  <1> 	dec	eax  ; add eax, 511
 45233 0000C09C 29D2                <1> 	sub	edx, edx
 45234 0000C09E F7F1                <1> 	div	ecx
 45235 0000C0A0 0FB61D[A1830100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
 45236 0000C0A7 01D8                <1> 	add	eax, ebx
 45237 0000C0A9 48                  <1> 	dec	eax  ; add eax, SecPerClust - 1
 45238 0000C0AA 6631D2              <1> 	xor	dx, dx
 45239 0000C0AD F7F3                <1> 	div	ebx
 45240                              <1> 
 45241                              <1> loc_createfile_set_cluster_count:
 45242 0000C0AF A3[A4830100]        <1> 	mov 	[createfile_CCount], eax
 45243                              <1> 	
 45244 0000C0B4 BF00000700          <1> 	mov	edi, Cluster_Buffer
 45245 0000C0B9 89C8                <1> 	mov	eax, ecx ; Bytes per Sector
 45246 0000C0BB F7E3                <1> 	mul	ebx ; Sectors per Cluster 
 45247                              <1> 	; EAX = Bytes per Cluster
 45248 0000C0BD 89C1                <1> 	mov	ecx, eax
 45249 0000C0BF C1E902              <1> 	shr	ecx, 2 ; dword count
 45250 0000C0C2 31C0                <1> 	xor	eax, eax
 45251 0000C0C4 F3AB                <1> 	rep	stosd ; clear cluster buffer
 45252                              <1> 
 45253 0000C0C6 A1[98830100]        <1> 	mov	eax, [createfile_Cluster] ; 24/03/2016
 45254                              <1> 
 45255 0000C0CB 89D9                <1> 	mov	ecx, ebx
 45256                              <1> 
 45257                              <1> loc_createfile_get_set_wf_fclust_cont:
 45258                              <1> 	;sub	eax, 2
 45259                              <1> 	; 30/07/2022
 45260 0000C0CD 48                  <1> 	dec	eax
 45261 0000C0CE 48                  <1> 	dec	eax
 45262 0000C0CF F7E1                <1> 	mul	ecx
 45263                              <1> 	; EAX = Logical DOS disk address (offset)
 45264 0000C0D1 E963FFFFFF          <1>         jmp     loc_createfile_write_fcluster_to_disk
 45265                              <1> 
 45266                              <1> loc_createfile_save_fat_buffer_3:
 45267                              <1> 	; byte [FAT_BuffValidData] = 2
 45268 0000C0D6 E821060000          <1> 	call	save_fat_buffer
 45269                              <1> 	;jc	loc_createfile_stc_retn
 45270                              <1> 	; 29/07/2022
 45271 0000C0DB 72B0                <1> 	jc	short loc_cf_upd_fat_fcluster_stc_retn
 45272                              <1> 
 45273                              <1> 	; 21/03/2016
 45274 0000C0DD 803D[5E7F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
 45275 0000C0E4 721B                <1> 	jb	short loc_createfile_save_fat_buffer_4
 45276                              <1> 
 45277                              <1> 	; ESI = Logical DOS Drive Description Table address 
 45278 0000C0E6 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 45279 0000C0EB 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
 45280 0000C0EF E899060000          <1> 	call	calculate_fat_freespace
 45281                              <1> 
 45282                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
 45283                              <1> 	;jnz	short loc_createfile_save_fat_buffer_4
 45284                              <1> 
 45285                              <1> 	; ecx > 0 -> Recalculation is needed
 45286 0000C0F4 09C9                <1> 	or	ecx, ecx 
 45287 0000C0F6 7409                <1> 	jz	short loc_createfile_save_fat_buffer_4
 45288                              <1> 
 45289 0000C0F8 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
 45290 0000C0FC E88C060000          <1> 	call	calculate_fat_freespace
 45291                              <1> 
 45292                              <1> loc_createfile_save_fat_buffer_4:
 45293 0000C101 FF0D[A4830100]      <1> 	dec	dword [createfile_CCount]
 45294                              <1> 	;jz	short loc_createfile_upd_dir_modif_date_time
 45295 0000C107 743E                <1> 	jz	short loc_createfile_stc_retn_cc ; 31/03/2016
 45296                              <1> 
 45297                              <1> loc_createfile_get_set_write_next_cluster:
 45298 0000C109 E89E020000          <1> 	call	get_first_free_cluster
 45299 0000C10E 7209                <1> 	jc	short loc_createfile_stc_retn
 45300                              <1> 
 45301                              <1> loc_createfile_get_set_write_next_cluster_1:
 45302 0000C110 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
 45303 0000C113 7212                <1> 	jb	short loc_createfile_get_set_write_next_cluster_2
 45304                              <1> 
 45305                              <1> loc_createfile_wnc_insufficient_disk_space:	
 45306                              <1> 	;mov	eax, 27h ; Insufficient disk space
 45307                              <1> 	; 29/07/2022
 45308 0000C115 31C0                <1> 	xor	eax, eax
 45309 0000C117 B027                <1> 	mov	al, 27h
 45310                              <1> 
 45311                              <1> loc_createfile_stc_retn:
 45312 0000C119 803D[AA830100]01    <1> 	cmp	byte [createfile_wfc], 1
 45313 0000C120 7324                <1> 	jnb	short loc_createfile_err_retn
 45314 0000C122 C3                  <1> 	retn
 45315                              <1> 
 45316                              <1> loc_createfile_wnc_inv_format_retn:
 45317                              <1> 	;mov	eax, 28
 45318 0000C123 B01C                <1> 	mov	al, 28 ; Invalid format
 45319 0000C125 EBF2                <1> 	jmp	short loc_createfile_stc_retn
 45320                              <1> 	         
 45321                              <1> loc_createfile_get_set_write_next_cluster_2:
 45322 0000C127 83F802              <1> 	cmp	eax, 2
 45323 0000C12A 72F7                <1> 	jb	short loc_createfile_wnc_inv_format_retn
 45324                              <1> 
 45325                              <1> loc_createfile_get_set_write_next_cluster_3:
 45326 0000C12C 8B0D[98830100]      <1> 	mov	ecx, [createfile_Cluster]
 45327 0000C132 A3[98830100]        <1> 	mov	[createfile_Cluster], eax
 45328 0000C137 890D[9C830100]      <1> 	mov	[createfile_PCluster], ecx
 45329 0000C13D 0FB60D[A1830100]    <1> 	movzx	ecx, byte [createfile_SecPerClust]
 45330 0000C144 EB87                <1> 	jmp	short loc_createfile_get_set_wf_fclust_cont
 45331                              <1> 
 45332                              <1> loc_createfile_err_retn:
 45333 0000C146 F9                  <1> 	stc
 45334                              <1> 
 45335                              <1> ;loc_createfile_upd_dir_modif_date_time:
 45336                              <1> loc_createfile_stc_retn_cc: ; 31/03/2016
 45337 0000C147 9C                  <1> 	pushf	; cpu is here for an error return or completion 
 45338 0000C148 50                  <1> 	push	eax ; error code if cf = 1
 45339                              <1> 
 45340                              <1> 	;call	update_parent_dir_lmdt
 45341                              <1> 
 45342                              <1> ;loc_createfile_stc_retn_cc:
 45343 0000C149 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 45344 0000C14E 09C0                <1> 	or	eax, eax
 45345 0000C150 741A                <1> 	jz	short loc_createfile_stc_retn_pop_eax
 45346 0000C152 8A3D[42780100]      <1> 	mov	bh, [Current_Drv]
 45347 0000C158 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
 45348                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
 45349                              <1> 	; (If EAX value is negative, Free Cluster Count will be decreased)
 45350 0000C15A E82E060000          <1>   	call	calculate_fat_freespace
 45351                              <1>         ; ESI = Logical DOS Drive Description Table Address 
 45352                              <1>         ;jc	short loc_createfile_stc_retn_pop_eax_cf
 45353 0000C15F 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
 45354 0000C161 7409                <1> 	jz	short loc_createfile_stc_retn_pop_eax
 45355                              <1> 
 45356                              <1> loc_createfile_stc_retn_recalc_FAT_freespace:
 45357 0000C163 66BB00FF            <1> 	mov	bx, 0FF00h ; bh = 0FFh -> 
 45358                              <1> 	; ESI = Logical DOS Drv DT Addr
 45359                              <1> 	; BL = 0 -> Recalculate 
 45360 0000C167 E821060000          <1> 	call	calculate_fat_freespace
 45361                              <1> 
 45362                              <1> loc_createfile_stc_retn_pop_eax:
 45363 0000C16C 58                  <1> 	pop	eax
 45364 0000C16D 9D                  <1> 	popf
 45365 0000C16E 7218                <1> 	jc	short loc_createfile_retn
 45366                              <1> 
 45367                              <1> loc_createfile_retn_fcluster:
 45368 0000C170 A1[90830100]        <1> 	mov	eax, [createfile_FFCluster]
 45369 0000C175 BB[8C830100]        <1> 	mov	ebx, createfile_size
 45370                              <1> 	;movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 45371 0000C17A 0FB60D[A1830100]    <1> 	movzx	ecx, byte [createfile_SecPerClust] ; 23/03/2016
 45372 0000C181 0FB715[A2830100]    <1> 	movzx	edx, word [createfile_DirIndex]
 45373                              <1> 
 45374                              <1> loc_createfile_retn:
 45375 0000C188 C3                  <1> 	retn
 45376                              <1> 
 45377                              <1> ; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
 45378                              <1> 
 45379                              <1> create_fs_file:
 45380                              <1> 	; temporary (21/03/2016)
 45381                              <1> 	;retn
 45382                              <1> 
 45383                              <1> delete_fs_file:
 45384                              <1> 	; temporary (28/02/2016)
 45385                              <1> 	;retn
 45386                              <1> 
 45387                              <1> rename_fs_file_or_directory:
 45388                              <1> 	;retn
 45389                              <1> 
 45390                              <1> make_fs_directory:
 45391                              <1> 	; temporary (21/02/2016)
 45392                              <1> 	;retn
 45393                              <1> 
 45394                              <1> add_new_fs_section:
 45395                              <1> 	; temporary (11/03/2016)
 45396                              <1> 	;retn
 45397                              <1> 
 45398                              <1> delete_fs_directory_entry:
 45399                              <1> 	; temporary (11/03/2016)
 45400                              <1> 	;retn
 45401                              <1> 
 45402                              <1> csftdf2_read_fs_file_sectors:
 45403                              <1> 	; temporary (19/03/2016)
 45404                              <1> 	;retn
 45405                              <1> 
 45406                              <1> csftdf2_write_fs_file_sectors:
 45407                              <1> 	; temporary (19/03/2016)
 45408 0000C189 C3                  <1> 	retn
 45409                                  %include 'trdosk5.s' ; 24/01/2016
 45410                              <1> ; ****************************************************************************
 45411                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - File System Procedures : trdosk5s
 45412                              <1> ; ----------------------------------------------------------------------------
 45413                              <1> ; Last Update: 07/08/2022 (Previous: 23/10/2016)
 45414                              <1> ; ----------------------------------------------------------------------------
 45415                              <1> ; Beginning: 24/01/2016
 45416                              <1> ; ----------------------------------------------------------------------------
 45417                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
 45418                              <1> ; ----------------------------------------------------------------------------
 45419                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 45420                              <1> ; DRV_FAT.ASM (21/08/2011)
 45421                              <1> ; ****************************************************************************
 45422                              <1> ; DRV_FAT.ASM (c) 2005-2011 Erdogan TAN [ 07/07/2009 ] Last Update: 21/08/2011
 45423                              <1> 
 45424                              <1> get_next_cluster:
 45425                              <1> 	; 07/08/2022
 45426                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45427                              <1> 	; 15/10/2016
 45428                              <1> 	; 23/03/2016
 45429                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
 45430                              <1> 	; 05/07/2011
 45431                              <1> 	; 07/07/2009
 45432                              <1> 	; 2005
 45433                              <1> 	; INPUT ->
 45434                              <1> 	;	EAX = Cluster Number (32 bit)
 45435                              <1> 	;	ESI = Logical DOS Drive Parameters Table
 45436                              <1> 	; OUTPUT ->
 45437                              <1> 	;	cf = 0 -> No Error, EAX valid
 45438                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
 45439                              <1> 	;	cf = 1 & EAX > 0 -> Error
 45440                              <1> 	;	ECX = Current/Previous cluster (if CF = 0)
 45441                              <1> 	;	EAX = Next Cluster Number (32 bit)
 45442                              <1> 	;
 45443                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 45444                              <1> 
 45445 0000C18A A3[527F0100]        <1> 	mov	[FAT_CurrentCluster], eax
 45446                              <1> check_next_cluster_fat_type:
 45447 0000C18F 29D2                <1> 	sub	edx, edx ; 0
 45448 0000C191 807E0302            <1> 	cmp     byte [esi+LD_FATType], 2
 45449 0000C195 7243                <1> 	jb	short get_FAT12_next_cluster
 45450                              <1> 	;ja	get_FAT32_next_cluster
 45451                              <1> 	; 25/07/2022
 45452 0000C197 7605                <1> 	jna	short get_FAT16_next_cluster
 45453 0000C199 E9B2000000          <1> 	jmp	get_FAT32_next_cluster
 45454                              <1> 
 45455                              <1> get_FAT16_next_cluster:
 45456 0000C19E BB00030000          <1> 	mov	ebx, 300h ;768
 45457 0000C1A3 F7F3                <1> 	div	ebx
 45458                              <1> 	; EAX = Count of 3 FAT sectors
 45459                              <1> 	; EDX = Cluster Offset (< 768)
 45460                              <1> 	;shl	dx, 1 ; Multiply by 2
 45461                              <1> 	; 25/07/2022
 45462 0000C1A5 D1E2                <1> 	shl	edx, 1
 45463 0000C1A7 89D3                <1> 	mov	ebx, edx ; Byte Offset
 45464 0000C1A9 81C3001C0900        <1> 	add	ebx, FAT_Buffer
 45465 0000C1AF 66BA0300            <1> 	mov	dx, 3
 45466 0000C1B3 F7E2                <1> 	mul	edx  
 45467                              <1> 	; EAX = FAT Sector (<= 256)
 45468                              <1> 	; EDX = 0
 45469 0000C1B5 8A0E                <1> 	mov	cl, [esi+LD_Name]
 45470                              <1> 	;cmp	byte [FAT_BuffValidData], 0
 45471 0000C1B7 3815[567F0100]      <1>         cmp	[FAT_BuffValidData], dl ; 0
 45472 0000C1BD 7674                <1> 	jna     short load_FAT_sectors0
 45473 0000C1BF 3A0D[577F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
 45474 0000C1C5 756C                <1>         jne     short load_FAT_sectors0
 45475 0000C1C7 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 45476 0000C1CD 756A                <1>         jne     short load_FAT_sectors1
 45477                              <1> 	;movzx	eax, word [ebx]
 45478 0000C1CF 668B03              <1> 	mov	ax, [ebx]
 45479                              <1> 	; 01/02/2016
 45480                              <1> 	; DRV_FAT.ASM (21/08/2011) had a FATal bug here !
 45481                              <1> 	; (cmp ah, 0Fh) ! (ax >= FF7h)
 45482                              <1> 	; (how can i do a such mistake!?)
 45483                              <1> 	;cmp	al, 0F7h
 45484                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
 45485                              <1> 	;cmp	ah, 0FFh
 45486                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
 45487 0000C1D2 6683F8F7            <1> 	cmp	ax, 0FFF7h
 45488 0000C1D6 724E                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
 45489                              <1> 	; ax >= FFF7h (cluster 0002h to FFF6h is valid, in use)
 45490 0000C1D8 EB4A                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
 45491                              <1> 
 45492                              <1> get_FAT12_next_cluster:
 45493 0000C1DA BB00040000          <1> 	mov	ebx, 400h ;1024
 45494 0000C1DF F7F3                <1> 	div	ebx
 45495                              <1> 	; EAX = Count of 3 FAT sectors
 45496                              <1> 	; EDX = Cluster Offset (< 1024)
 45497                              <1> 	; 25/07/2022
 45498                              <1> 	;push	ax
 45499 0000C1E1 50                  <1> 	push	eax
 45500                              <1> 	;mov	ax, 3	
 45501 0000C1E2 B003                <1> 	mov	al, 3
 45502                              <1> 	;mul	dx    	; Multiply by 3
 45503 0000C1E4 F7E2                <1> 	mul	edx
 45504                              <1> 	;shr	ax, 1	; Divide by 2
 45505 0000C1E6 D1E8                <1>         shr	eax, 1
 45506                              <1> 	;mov	bx, ax 	; Byte Offset
 45507 0000C1E8 89C3                <1> 	mov	ebx, eax
 45508 0000C1EA 81C3001C0900        <1> 	add	ebx, FAT_Buffer
 45509 0000C1F0 58                  <1> 	pop	eax
 45510                              <1> 	;pop	ax
 45511                              <1> 	;mov	dx, 3
 45512 0000C1F1 B203                <1> 	mov	dl, 3
 45513 0000C1F3 F7E2                <1> 	mul	edx 
 45514                              <1> 	; EAX = FAT Sector (<= 12)
 45515                              <1> 	; EDX = 0
 45516 0000C1F5 8A0E                <1> 	mov	cl, [esi+LD_Name]
 45517                              <1> 	;cmp	byte [FAT_BuffValidData], 0
 45518 0000C1F7 3815[567F0100]      <1> 	cmp	[FAT_BuffValidData], dl ; 0
 45519 0000C1FD 7634                <1> 	jna	short load_FAT_sectors0
 45520 0000C1FF 3A0D[577F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
 45521 0000C205 752C                <1> 	jne	short load_FAT_sectors0
 45522 0000C207 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 45523 0000C20D 752A                <1> 	jne	short load_FAT_sectors1
 45524 0000C20F A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 45525                              <1> 	;shr	ax, 1
 45526                              <1> 	; 25/07/2022
 45527 0000C214 D1E8                <1> 	shr	eax, 1
 45528                              <1> 	;movzx	eax, word [ebx]
 45529 0000C216 668B03              <1> 	mov	ax, [ebx]
 45530 0000C219 7313                <1> 	jnc	short get_FAT12_nc_even
 45531                              <1> 	;shr	ax, 4
 45532 0000C21B C1E804              <1> 	shr	eax, 4
 45533                              <1> loc_gnc_fat12_eoc_check:
 45534                              <1> 	;cmp	al, 0F7h
 45535                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
 45536                              <1> 	;cmp	ah, 0Fh
 45537                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
 45538 0000C21E 663DF70F            <1> 	cmp	ax, 0FF7h
 45539 0000C222 7202                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
 45540                              <1> 	; ax >= FF7h (cluster 0002h to FF6h is valid, in use)
 45541                              <1> 
 45542                              <1> loc_pass_gnc_FAT16_eoc_check_xor_eax:
 45543 0000C224 31C0                <1> 	xor	eax, eax ; 0
 45544                              <1> loc_pass_gnc_FAT16_eoc_check:
 45545                              <1> loc_pass_gnc_FAT32_eoc_check:
 45546 0000C226 8B0D[527F0100]      <1> 	mov	ecx, [FAT_CurrentCluster]
 45547 0000C22C F5                  <1> 	cmc
 45548 0000C22D C3                  <1> 	retn
 45549                              <1> 
 45550                              <1> get_FAT12_nc_even:
 45551 0000C22E 80E40F              <1> 	and	ah, 0Fh
 45552 0000C231 EBEB                <1> 	jmp	short loc_gnc_fat12_eoc_check
 45553                              <1> 
 45554                              <1> load_FAT_sectors0:
 45555 0000C233 880D[577F0100]      <1> 	mov	[FAT_BuffDrvName], cl
 45556                              <1> load_FAT_sectors1:
 45557                              <1> 	; 25/07/2022
 45558                              <1> 	;sub	edx, edx
 45559                              <1> 	; edx = 0
 45560 0000C239 A3[5A7F0100]        <1> 	mov	[FAT_BuffSector], eax
 45561 0000C23E 89C3                <1> 	mov	ebx, eax
 45562 0000C240 034660              <1>         add     eax, [esi+LD_FATBegin]
 45563 0000C243 B202                <1> 	mov	dl, 2
 45564                              <1> 	;cmp	byte [esi+LD_FATType], 2
 45565 0000C245 385603              <1>         cmp	[esi+LD_FATType], dl ; 2
 45566 0000C248 7748                <1> 	ja      short load_FAT_sectors3
 45567 0000C24A 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
 45568 0000C24E EB45                <1> 	jmp	short load_FAT_sectors4
 45569                              <1> 
 45570                              <1> 	; 07/08/2022
 45571                              <1> get_FAT32_next_cluster:
 45572 0000C250 BB80010000          <1> 	mov	ebx, 180h ;384
 45573 0000C255 F7F3                <1> 	div	ebx
 45574                              <1> 	; EAX = Count of 3 FAT sectors
 45575                              <1> 	; EDX = Cluster Offset (< 384)
 45576                              <1> 	;shl	dx, 2	; Multiply by 4
 45577                              <1> 	; 25/07/2022
 45578 0000C257 C1E202              <1> 	shl	edx, 2
 45579 0000C25A 89D3                <1> 	mov	ebx, edx ; Byte Offset
 45580 0000C25C 81C3001C0900        <1> 	add	ebx, FAT_Buffer
 45581 0000C262 66BA0300            <1> 	mov	dx, 3
 45582 0000C266 F7E2                <1> 	mul	edx	
 45583                              <1>         ; EAX = FAT Sector (<= 2097152) ; (FFFFFF7h * 4) / 512
 45584                              <1> 	; 	for 32KB cluster size:
 45585                              <1> 	;	EAX <= 1024 = (4GB / 32KB) * 4) / 512 	
 45586                              <1> 	; EDX = 0
 45587 0000C268 8A0E                <1> 	mov	cl, [esi+LD_Name]
 45588                              <1> 	;cmp	byte [FAT_BuffValidData], 0
 45589 0000C26A 3815[567F0100]      <1> 	cmp	[FAT_BuffValidData], dl ; 0
 45590 0000C270 76C1                <1> 	jna	short load_FAT_sectors0
 45591 0000C272 3A0D[577F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
 45592 0000C278 75B9                <1> 	jne	short load_FAT_sectors0
 45593 0000C27A 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector] ; 0, 3, 6, 9 ...
 45594 0000C280 75B7                <1> 	jne	short load_FAT_sectors1
 45595 0000C282 8B03                <1> 	mov	eax, [ebx]
 45596 0000C284 25FFFFFF0F          <1>  	and	eax, 0FFFFFFFh ; 28 bit Cluster
 45597 0000C289 3DF7FFFF0F          <1> 	cmp	eax, 0FFFFFF7h
 45598 0000C28E 7296                <1> 	jb	short loc_pass_gnc_FAT32_eoc_check
 45599                              <1> 	; eax >= FFFFFF7h (cluster 0002h to FFFFFF6h is valid)
 45600 0000C290 EB92                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
 45601                              <1> 
 45602                              <1> load_FAT_sectors3:
 45603 0000C292 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+BPB_FATSz32]
 45604                              <1> load_FAT_sectors4:
 45605 0000C295 29D9                <1> 	sub	ecx, ebx ; [FAT_BuffSector]
 45606                              <1> 	; 25/07/2022
 45607 0000C297 FEC2                <1> 	inc	dl
 45608                              <1> 	; edx = 3
 45609                              <1>         ;cmp	ecx, 3
 45610 0000C299 39D1                <1>         cmp	ecx, edx ; 3
 45611 0000C29B 7602                <1> 	jna     short load_FAT_sectors5
 45612                              <1> 	;mov	ecx, 3
 45613                              <1> 	; 25/07/2022
 45614 0000C29D 89D1                <1> 	mov	ecx, edx ; 3
 45615                              <1> load_FAT_sectors5:
 45616 0000C29F BB001C0900          <1> 	mov	ebx, FAT_Buffer
 45617 0000C2A4 E8805A0000          <1> 	call	disk_read
 45618 0000C2A9 730C                <1> 	jnc	short load_FAT_sectors_ok
 45619                              <1> 	; 15/10/2016 (15h -> 17)
 45620                              <1> 	; 23/03/2016 (15h)
 45621 0000C2AB B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
 45622                              <1> 	;mov	byte [FAT_BuffValidData], 0
 45623                              <1> 	; 25/07/2022
 45624 0000C2B0 8825[567F0100]      <1> 	mov	byte [FAT_BuffValidData], ah ; 0
 45625 0000C2B6 C3                  <1> 	retn
 45626                              <1> load_FAT_sectors_ok:
 45627 0000C2B7 C605[567F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
 45628 0000C2BE A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 45629 0000C2C3 E9C7FEFFFF          <1>         jmp     check_next_cluster_fat_type
 45630                              <1> 
 45631                              <1> load_FAT_root_directory:
 45632                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45633                              <1> 	; 23/10/2016
 45634                              <1> 	; 15/10/2016
 45635                              <1> 	; 07/02/2016
 45636                              <1> 	; 02/02/2016
 45637                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
 45638                              <1> 	; 21/05/2011
 45639                              <1> 	; 22/08/2009
 45640                              <1> 	;
 45641                              <1> 	; INPUT ->
 45642                              <1> 	;	ESI = Logical DOS Drive Description Table
 45643                              <1> 	; OUTPUT ->
 45644                              <1> 	;	cf = 1 -> Root directory could not be loaded
 45645                              <1> 	;	    EAX > 0 -> Error number
 45646                              <1> 	;	cf = 0 -> EAX = 0
 45647                              <1> 	;	ECX = Directory buffer size in sectors (CL)
 45648                              <1> 	;	EBX = Directory buffer address
 45649                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
 45650                              <1> 	;
 45651                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 45652                              <1> 
 45653                              <1> 	; NOTE: Only for FAT12 and FAT16 file systems !
 45654                              <1> 	; (FAT32 fs root dir must be loaded as sub directory)
 45655                              <1> 
 45656 0000C2C8 8A1E                <1> 	mov	bl, [esi+LD_Name]
 45657 0000C2CA 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
 45658                              <1> 
 45659                              <1> 	;mov	[DirBuff_DRV], bl
 45660                              <1> 	;mov	[DirBuff_FATType], bh
 45661 0000C2CD 66891D[677F0100]    <1> 	mov	[DirBuff_DRV], bx
 45662                              <1> 	
 45663                              <1> 	;cmp	bh, 2
 45664                              <1> 	;ja	short load_FAT32_root_dir0 ; FAT32 root dir
 45665                              <1> 
 45666                              <1> load_FAT_root_dir0: ; 23/10/2016
 45667 0000C2D4 0FB75617            <1> 	movzx	edx, word [esi+LD_BPB+RootDirEnts]
 45668                              <1> 
 45669                              <1> 	;or	dx, dx ; 0 for FAT32 file systems
 45670                              <1> 	;jz	short load_FAT32_root_dir0 ; FAT32 root dir
 45671                              <1> 	
 45672                              <1> 	; 25/07/2022
 45673 0000C2D8 89D0                <1> 	mov	eax, edx
 45674 0000C2DA 6681FA0002          <1> 	cmp	dx, 512 ; Number of Root Dir Entries
 45675 0000C2DF 740B                <1> 	je	short lrd_mov_ecx_32
 45676                              <1> 	;mov	eax, edx ; 25/07/2022
 45677                              <1> 	; 23/10/2016
 45678 0000C2E1 89C1                <1> 	mov	ecx, eax
 45679 0000C2E3 6683C10F            <1> 	add	cx, 15 ; round up 
 45680                              <1> 	;shr	cx, 4  ; 16 entries per sector (512/32)
 45681                              <1> 	; 25/07/2022
 45682 0000C2E7 C1E904              <1> 	shr	ecx, 4
 45683                              <1> 	; ecx = Root directory size in sectors
 45684                              <1> 	;;shl	ax, 5 ; Root directory size in bytes
 45685                              <1> 	; 25/07/2022
 45686                              <1> 	;shl	eax, 5
 45687                              <1> 	;;dec	dx    ; Last entry number of root dir
 45688                              <1> 	;dec	edx
 45689                              <1> 	; cx = Dir Buffer sector count             
 45690 0000C2EA EB04                <1> 	jmp	short lrd_check_dir_buffer
 45691                              <1> 
 45692                              <1> lrd_mov_ecx_32:
 45693                              <1> 	;mov	ecx, 32
 45694                              <1> 	; 25/07/2022
 45695 0000C2EC 29C9                <1> 	sub	ecx, ecx
 45696 0000C2EE B120                <1> 	mov	cl, 32
 45697                              <1> 	;dec	dx ; 511
 45698                              <1> 	;mov	ax, 32*512 
 45699                              <1> 
 45700                              <1> lrd_check_dir_buffer:
 45701                              <1> 	; 25/07/2022
 45702 0000C2F0 4A                  <1> 	dec	edx ; root dir entries - 1
 45703 0000C2F1 C1E005              <1> 	shl	eax, 5 ; * 32
 45704                              <1> 	;
 45705 0000C2F4 29DB                <1> 	sub	ebx, ebx ; 0
 45706 0000C2F6 881D[697F0100]      <1> 	mov	[DirBuff_ValidData], bl ; 0
 45707 0000C2FC 668915[6C7F0100]    <1> 	mov	[DirBuff_LastEntry], dx
 45708 0000C303 891D[6E7F0100]      <1> 	mov	[DirBuff_Cluster], ebx ; 0
 45709 0000C309 66A3[727F0100]      <1> 	mov	[DirBuffer_Size], ax
 45710                              <1> 
 45711 0000C30F 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin]
 45712                              <1> read_directory:
 45713 0000C312 BB00000800          <1> 	mov	ebx, Directory_Buffer
 45714 0000C317 51                  <1> 	push	ecx ; Directory buffer sector count
 45715 0000C318 53                  <1> 	push	ebx
 45716 0000C319 E80B5A0000          <1> 	call	disk_read
 45717 0000C31E 5B                  <1> 	pop	ebx
 45718 0000C31F 720B                <1> 	jc	short load_DirBuff_error
 45719                              <1> 
 45720                              <1> validate_DirBuff_and_return:
 45721 0000C321 59                  <1> 	pop	ecx ; Number of loaded sectors
 45722 0000C322 C605[697F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
 45723 0000C329 31C0                <1> 	xor	eax, eax ; 0 = no error
 45724 0000C32B C3                  <1> 	retn
 45725                              <1> 
 45726                              <1> load_DirBuff_error:
 45727 0000C32C 89C8                <1> 	mov	eax, ecx ; remaining sectors
 45728 0000C32E 59                  <1> 	pop	ecx ; sector count
 45729 0000C32F 29C1                <1> 	sub	ecx, eax ; Number of loaded sectors
 45730                              <1> 	; 15/10/2016 (15h -> 17)
 45731                              <1> 	;mov	eax, 17 ; DRV NOT READY OR READ ERROR !
 45732                              <1> 	; 25/07/2022
 45733                              <1> 	;sub	eax, eax
 45734 0000C331 B011                <1> 	mov	al, 17
 45735 0000C333 F9                  <1> 	stc
 45736 0000C334 C3                  <1>         retn
 45737                              <1> 
 45738                              <1> load_FAT32_root_directory:
 45739                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45740                              <1> 	; 02/02/2016 (TRDOS 386 = TRDOS v2.0)
 45741                              <1> 	;
 45742                              <1> 	; INPUT ->
 45743                              <1> 	;	ESI = Logical DOS Drive Description Table
 45744                              <1> 	; OUTPUT ->
 45745                              <1> 	;	cf = 1 -> Root directory could not be loaded
 45746                              <1> 	;	    EAX > 0 -> Error number
 45747                              <1> 	;	cf = 0 -> EAX = 0
 45748                              <1> 	;	ECX = Directory buffer size in sectors (CL)
 45749                              <1> 	;	EBX = Directory buffer address
 45750                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
 45751                              <1> 	;
 45752                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 45753                              <1> 
 45754 0000C335 8A1E                <1> 	mov	bl, [esi+LD_Name]
 45755 0000C337 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
 45756                              <1> 
 45757                              <1> 	;mov	[DirBuff_DRV], bl
 45758                              <1> 	;mov	[DirBuff_FATType], bh
 45759 0000C33A 66891D[677F0100]    <1> 	mov	[DirBuff_DRV], bx
 45760                              <1> 
 45761                              <1> load_FAT32_root_dir0:
 45762 0000C341 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
 45763 0000C344 EB0C                <1> 	jmp	short load_FAT_sub_dir0
 45764                              <1> 	
 45765                              <1> load_FAT_sub_directory:
 45766                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45767                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
 45768                              <1> 	; 05/07/2011
 45769                              <1> 	; 23/08/2009
 45770                              <1> 	;
 45771                              <1> 	; INPUT ->
 45772                              <1> 	;	ESI = Logical DOS Drive Description Table
 45773                              <1> 	;	EAX = Cluster Number
 45774                              <1> 	; OUTPUT ->
 45775                              <1> 	;	cf = 1 -> Sub directory could not be loaded
 45776                              <1> 	;	    EAX > 0 -> Error number
 45777                              <1> 	;	cf = 0 -> EAX = 0
 45778                              <1> 	;	ECX = Directory buffer size in sectors (CL)
 45779                              <1> 	;	EBX = Directory buffer address
 45780                              <1> 	;
 45781                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
 45782                              <1> 	;
 45783                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 45784                              <1> 
 45785 0000C346 8A1E                <1> 	mov	bl, [esi+LD_Name]
 45786 0000C348 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
 45787                              <1> 
 45788                              <1> 	;mov	[DirBuff_DRV], bl
 45789                              <1> 	;mov	[DirBuff_FATType], bh
 45790 0000C34B 66891D[677F0100]    <1> 	mov	[DirBuff_DRV], bx
 45791                              <1> 
 45792                              <1> load_FAT_sub_dir0:
 45793 0000C352 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 45794                              <1> 
 45795 0000C356 882D[697F0100]      <1> 	mov	[DirBuff_ValidData], ch ; 0
 45796 0000C35C A3[6E7F0100]        <1> 	mov	[DirBuff_Cluster], eax
 45797                              <1> 
 45798 0000C361 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 45799 0000C365 F7E1                <1> 	mul	ecx
 45800 0000C367 C1E805              <1> 	shr	eax, 5 ; directory entry count (dir size / 32)
 45801                              <1> 	;dec	ax ; last entry
 45802                              <1> 	; 25/07/2022
 45803 0000C36A 48                  <1> 	dec	eax
 45804 0000C36B 66A3[6C7F0100]      <1> 	mov	[DirBuff_LastEntry], ax
 45805                              <1> 
 45806 0000C371 A1[6E7F0100]        <1> 	mov	eax, [DirBuff_Cluster]
 45807 0000C376 83E802              <1> 	sub	eax, 2
 45808 0000C379 F7E1                <1> 	mul	ecx
 45809 0000C37B 034668              <1> 	add	eax, [esi+LD_DATABegin]
 45810                              <1> 	; ecx = sectors per cluster (dir buffer size <= 128 sectors)
 45811 0000C37E EB92                <1> 	jmp	short read_directory
 45812                              <1> 
 45813                              <1> ; DRV_FS.ASM
 45814                              <1> 
 45815                              <1> ; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45816                              <1> 
 45817                              <1> load_current_FS_directory:
 45818                              <1> 	;retn
 45819                              <1> load_FS_root_directory:
 45820                              <1> 	;retn
 45821                              <1> load_FS_sub_directory:
 45822 0000C380 C3                  <1> 	retn
 45823                              <1> 
 45824                              <1> read_cluster:
 45825                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45826                              <1> 	; 15/10/2016
 45827                              <1> 	; 18/03/2016
 45828                              <1> 	; 16/03/2016
 45829                              <1> 	; 17/02/2016
 45830                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 45831                              <1> 	;
 45832                              <1> 	; INPUT ->
 45833                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
 45834                              <1> 	;	ESI = Logical DOS Drive Description Table address
 45835                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
 45836                              <1> 	;	Only for SINGLIX FS:
 45837                              <1> 	;	EDX = File Number (The 1st FDT address) 
 45838                              <1> 	; OUTPUT ->
 45839                              <1> 	;	cf = 1 -> Cluster can not be loaded at the buffer
 45840                              <1> 	;	    EAX > 0 -> Error number
 45841                              <1> 	;	cf = 0 -> Cluster has been loaded at the buffer
 45842                              <1> 	;
 45843                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 45844                              <1> 	
 45845 0000C381 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
 45846                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
 45847                              <1> 
 45848                              <1> read_file_sectors: ; 16/03/2016
 45849                              <1> 	;cmp	byte [esi+LD_FATType], 0
 45850                              <1> 	; 25/07/2022
 45851 0000C385 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
 45852 0000C388 761C                <1> 	jna	short read_fs_cluster
 45853                              <1> 
 45854                              <1> read_fat_file_sectors: ; 18/03/2016
 45855 0000C38A 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
 45856 0000C38D 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
 45857 0000C391 F7E2                <1> 	mul	edx
 45858 0000C393 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
 45859                              <1> 
 45860                              <1> 	; EAX = Disk sector address
 45861                              <1> 	; ECX = Sector count
 45862                              <1> 	; EBX = Buffer address
 45863                              <1> 	; (EDX = 0)
 45864                              <1> 	; ESI = Logical DOS drive description table address	
 45865                              <1> 
 45866 0000C396 E88E590000          <1> 	call	disk_read
 45867 0000C39B 7306                <1> 	jnc	short rclust_retn
 45868                              <1> 	
 45869                              <1> 	; 15/10/2016 (15h -> 17)
 45870 0000C39D B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 45871 0000C3A2 C3                  <1> 	retn
 45872                              <1> 
 45873                              <1> rclust_retn:
 45874 0000C3A3 29C0                <1> 	sub	eax, eax ; 0
 45875 0000C3A5 C3                  <1> 	retn
 45876                              <1> 
 45877                              <1> read_fs_cluster:
 45878                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45879                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 45880                              <1> 	; Singlix FS
 45881                              <1> 	
 45882                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
 45883                              <1> 	
 45884                              <1> 	; EDX = File number is the first File Descriptor Table address 
 45885                              <1> 	;	of the file. (Absolute address of the FDT).
 45886                              <1> 	
 45887                              <1> 	; eax = sector index (0 for the first sector)
 45888                              <1> 	; edx = FDT0 address
 45889                              <1> 		; 64 KB buffer = 128 sectors (limit) 
 45890                              <1> 	;mov	ecx, 128 ; maximum count of sectors (before eof) 
 45891                              <1> 	; 25/07/2022
 45892 0000C3A6 29C9                <1> 	sub	ecx, ecx
 45893 0000C3A8 B180                <1> 	mov	cl, 128
 45894                              <1> 	;call	read_fs_sectors
 45895                              <1> 	;retn
 45896                              <1> 	;jmp	short read_fs_sectors
 45897                              <1> 
 45898                              <1> read_fs_sectors:
 45899                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
 45900 0000C3AA F9                  <1> 	stc
 45901 0000C3AB C3                  <1> 	retn
 45902                              <1> 
 45903                              <1> get_first_free_cluster:
 45904                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 45905                              <1> 	; 02/03/2016
 45906                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 45907                              <1> 	; 26/10/2010 (DRV_FAT.ASM, 'proc_get_first_free_cluster')
 45908                              <1> 	; 10/07/2010
 45909                              <1> 	; INPUT ->
 45910                              <1> 	;	ESI = Logical DOS Drive Description Table address
 45911                              <1> 	; OUTPUT ->
 45912                              <1> 	;	cf = 1 -> Error code in AL (EAX)
 45913                              <1> 	;	cf = 0 -> 
 45914                              <1> 	;	  EAX = Cluster number 
 45915                              <1> 	;	  If EAX = FFFFFFFFh -> no free space
 45916                              <1> 	;	If the drive has FAT32 fs:
 45917                              <1> 	;	  EBX = FAT32 FSI sector buffer address (if > 0)
 45918                              <1> 
 45919 0000C3AC 8B4678              <1> 	mov	eax, [esi+LD_Clusters]
 45920 0000C3AF 40                  <1> 	inc	eax ; add eax, 1
 45921 0000C3B0 A3[F0810100]        <1> 	mov	[gffc_last_free_cluster], eax
 45922                              <1> 
 45923 0000C3B5 31DB                <1> 	xor	ebx, ebx ; 0 ; 02/03/2016
 45924                              <1> 
 45925 0000C3B7 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
 45926 0000C3BB 760E                <1> 	jna	short loc_gffc_get_first_fat_free_cluster0
 45927                              <1> 
 45928                              <1> loc_gffc_get_first_fat32_free_cluster:
 45929                              <1> 	; 02/03/2016
 45930 0000C3BD E8FF050000          <1> 	call	get_fat32_fsinfo_sector_parms
 45931 0000C3C2 7207                <1> 	jc	short loc_gffc_get_first_fat_free_cluster0 
 45932                              <1> 
 45933                              <1> loc_gffc_check_fsinfo_parms:
 45934                              <1> 	;;mov	ebx, DOSBootSectorBuff
 45935                              <1> 	;cmp	dword [ebx], 41615252h
 45936                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
 45937                              <1> 	;cmp	dword [ebx+484], 61417272h
 45938                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
 45939                              <1> 	;mov	eax, [ebx+492] ; FSI_Next_Free
 45940                              <1> 	;EAX = First free cluster 
 45941                              <1> 	;(from FAT32 FSInfo sector)
 45942 0000C3C4 89D0                <1> 	mov	eax, edx ; FSI_Next_Free (First Free Cluster)
 45943 0000C3C6 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; invalid (unknown) !
 45944 0000C3C9 7204                <1> 	jb	short loc_gffc_get_first_fat_free_cluster1
 45945                              <1> 
 45946                              <1> 	; Start from the 1st cluster of the FAT(32) file system
 45947                              <1> loc_gffc_get_first_fat_free_cluster0:
 45948                              <1> 	;mov	eax, 2
 45949                              <1> 	; 25/07/2022
 45950 0000C3CB 29C0                <1> 	sub	eax, eax
 45951 0000C3CD B002                <1> 	mov	al, 2
 45952                              <1> 	;xor	edx, edx
 45953                              <1> 
 45954                              <1> loc_gffc_get_first_fat_free_cluster1:
 45955 0000C3CF 53                  <1> 	push	ebx ; 02/03/2016 
 45956                              <1> 
 45957                              <1> loc_gffc_get_first_fat_free_cluster2:   
 45958 0000C3D0 A3[EC810100]        <1> 	mov	[gffc_first_free_cluster], eax
 45959 0000C3D5 A3[E8810100]        <1> 	mov	[gffc_next_free_cluster], eax
 45960                              <1> 
 45961                              <1> 	; EBX = FAT32 FSINFO sector buffer address
 45962                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
 45963                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
 45964                              <1> 
 45965                              <1> loc_gffc_get_first_fat_free_cluster3:
 45966 0000C3DA E8ABFDFFFF          <1> 	call	get_next_cluster
 45967 0000C3DF 7307                <1> 	jnc	short loc_gffc_get_first_fat_free_cluster4
 45968 0000C3E1 09C0                <1> 	or	eax, eax
 45969 0000C3E3 740B                <1> 	jz	short loc_gffc_first_free_fat_cluster_next
 45970 0000C3E5 5B                  <1> 	pop	ebx ; 02/03/2016
 45971 0000C3E6 F5                  <1> 	cmc 	; stc
 45972 0000C3E7 C3                  <1> 	retn
 45973                              <1> 
 45974                              <1> loc_gffc_get_first_fat_free_cluster4:
 45975 0000C3E8 21C0                <1> 	and	eax, eax ; next cluster value
 45976 0000C3EA 7504                <1> 	jnz	short loc_gffc_first_free_fat_cluster_next
 45977 0000C3EC 89C8                <1> 	mov	eax, ecx ; current (previous cluster) value
 45978 0000C3EE EB22                <1> 	jmp	short loc_gffc_check_for_set
 45979                              <1>  
 45980                              <1> loc_gffc_first_free_fat_cluster_next:
 45981 0000C3F0 A1[E8810100]        <1> 	mov	eax, [gffc_next_free_cluster]
 45982 0000C3F5 3B05[F0810100]      <1> 	cmp	eax, [gffc_last_free_cluster]
 45983 0000C3FB 7308                <1> 	jnb	short retn_stc_from_get_first_free_cluster
 45984                              <1> pass_gffc_last_cluster_eax_check:
 45985 0000C3FD 40                  <1> 	inc	eax ; add eax, 1
 45986 0000C3FE A3[E8810100]        <1> 	mov	[gffc_next_free_cluster], eax
 45987 0000C403 EBD5                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster3
 45988                              <1> 
 45989                              <1> retn_stc_from_get_first_free_cluster:
 45990 0000C405 A1[EC810100]        <1> 	mov	eax, [gffc_first_free_cluster]
 45991 0000C40A 83F802              <1> 	cmp	eax, 2
 45992 0000C40D 7709                <1> 	ja	short loc_gffc_check_previous_clusters
 45993 0000C40F 29C0                <1> 	sub	eax, eax
 45994 0000C411 48                  <1> 	dec	eax ; FFFFFFFFh
 45995                              <1> 
 45996                              <1> loc_gffc_check_for_set:
 45997                              <1> 	; 02/03/2016
 45998 0000C412 5B                  <1> 	pop	ebx
 45999                              <1> 
 46000                              <1> 	; EBX = FAT32 FSINFO sector buffer address
 46001                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
 46002                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
 46003                              <1> 
 46004 0000C413 09DB                <1> 	or	ebx, ebx
 46005 0000C415 750D                <1> 	jnz	short loc_gffc_set_ffree_fat32_cluster
 46006                              <1> 
 46007                              <1> 	;cmp	byte [esi+LD_FATType], 3
 46008                              <1> 	;jnb	short loc_gffc_set_ffree_fat32_cluster
 46009                              <1> 
 46010                              <1> 	;xor	ebx, ebx ; 0
 46011                              <1> 
 46012                              <1> loc_gffc_retn:
 46013 0000C417 C3                  <1> 	retn
 46014                              <1> 
 46015                              <1> loc_gffc_check_previous_clusters:
 46016 0000C418 48                  <1> 	dec	eax ; sub eax, 1
 46017 0000C419 A3[F0810100]        <1> 	mov	[gffc_last_free_cluster], eax 
 46018                              <1> 	;mov	eax, 2
 46019                              <1> 	; 25/07/2022
 46020 0000C41E 31C0                <1> 	xor	eax, eax
 46021 0000C420 B002                <1> 	mov	al, 2
 46022                              <1> 	; eax = 2
 46023                              <1> 	;xor	edx, edx
 46024 0000C422 EBAC                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster2
 46025                              <1> 
 46026                              <1> loc_gffc_set_ffree_fat32_cluster:
 46027                              <1> 	;call	set_first_free_cluster
 46028                              <1> 	;retn
 46029                              <1> 	;jmp	short set_first_free_cluster	
 46030                              <1> 
 46031                              <1> set_first_free_cluster:
 46032                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 46033                              <1> 	; 15/10/2016
 46034                              <1> 	; 23/03/2016
 46035                              <1> 	; 02/03/2016
 46036                              <1> 	; 29/02/2016
 46037                              <1> 	; 26/02/2016
 46038                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
 46039                              <1> 	; 21/08/2011 (DRV_FAT.ASM, 'proc_set_first_free_cluster')
 46040                              <1> 	; 11/07/2010
 46041                              <1> 	; INPUT -> 
 46042                              <1> 	;	ESI = Logical DOS Drive Description Table address
 46043                              <1> 	;	EAX = First free cluster
 46044                              <1> 	;	EBX = FSINFO sector buffer address
 46045                              <1> 	;  	;;If EBX > 0, it is FSINFO sector buffer address
 46046                              <1> 	;	;;EBX = 0, if FSINFO sector is not loaded
 46047                              <1> 	; OUTPUT->
 46048                              <1> 	;	ESI = Logical DOS Drive Description Table address
 46049                              <1> 	;  	If EBX > 0, it is FSINFO sector buffer address
 46050                              <1> 	;	EBX = 0, if FSINFO sector could not be loaded
 46051                              <1> 	; 	CF = 1 -> Error code in AL (EAX)
 46052                              <1> 	;	CF = 0 -> first free cluster is successfully updated 
 46053                              <1> 
 46054                              <1> 	;cmp	byte [esi+LD_FATType], 3
 46055                              <1> 	;jb	short loc_sffc_invalid_drive
 46056                              <1> 
 46057                              <1> 	; Save First Free Cluster value for 'update_cluster'
 46058 0000C424 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First free Cluster	
 46059                              <1> 
 46060                              <1> 	;or	ebx, ebx
 46061                              <1> 	;jnz	short loc_sffc_read_fsinfo_sector
 46062                              <1> 
 46063 0000C427 813B52526141        <1> 	cmp     dword [ebx], 41615252h
 46064 0000C42D 753C                <1> 	jne	short loc_sffc_read_fsinfo_sector
 46065 0000C42F 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
 46066 0000C438 61                  <1>
 46067 0000C439 7530                <1> 	jne	short loc_sffc_read_fsinfo_sector
 46068                              <1> 
 46069 0000C43B 3B83EC010000        <1> 	cmp	eax, [ebx+492]  ; FSI_Next_Free
 46070 0000C441 741E                <1> 	je	short loc_sffc_retn
 46071                              <1> 
 46072                              <1> loc_sffc_write_fsinfo_sector:
 46073                              <1> 	; EBX = FSINFO sector buffer
 46074                              <1> 	; [CFS_FAT32FSINFOSEC] is set in 'get_fat32_fsinfo_sector_parms'
 46075 0000C443 8983EC010000        <1> 	mov	[ebx+492], eax
 46076 0000C449 A1[00820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC] 
 46077                              <1> 	;mov	ecx, 1
 46078                              <1> 	; 25/07/2022
 46079 0000C44E 31C9                <1> 	xor	ecx, ecx
 46080 0000C450 FEC1                <1> 	inc	cl
 46081                              <1> 	; ecx = 1
 46082 0000C452 53                  <1> 	push	ebx
 46083 0000C453 E8C2580000          <1> 	call	disk_write
 46084 0000C458 7208                <1> 	jc      short loc_sffc_read_fsinfo_sector_err1
 46085 0000C45A 5B                  <1> 	pop	ebx
 46086                              <1> 
 46087 0000C45B 8B83EC010000        <1> 	mov	eax, [ebx+492] ; First (Next) Free Cluster
 46088                              <1> 
 46089                              <1> loc_sffc_retn:
 46090 0000C461 C3                  <1> 	retn
 46091                              <1> 
 46092                              <1> ;loc_sffc_invalid_drive:
 46093                              <1> ;	mov	eax, 0Fh ; MSDOS Error : Invalid drive
 46094                              <1> ;	push	edx
 46095                              <1> 
 46096                              <1> loc_sffc_read_fsinfo_sector_err1:
 46097                              <1> 	; 25/07/2022
 46098                              <1> 	;mov	ebx, 0
 46099                              <1> 	; 15/10/2016 (1Dh -> 18)
 46100                              <1> 	; 23/03/2016 (1Dh)
 46101                              <1> 	;mov	eax, 18 ; Drive not ready or write error
 46102 0000C462 31C0                <1> 	xor	eax, eax
 46103 0000C464 89C3                <1> 	mov	ebx, eax ; 0
 46104 0000C466 B012                <1> 	mov	al, 18	
 46105 0000C468 F9                  <1> 	stc
 46106                              <1> loc_sffc_read_fsinfo_sector_err2:
 46107 0000C469 5A                  <1> 	pop	edx
 46108 0000C46A C3                  <1> 	retn
 46109                              <1> 	
 46110                              <1> loc_sffc_read_fsinfo_sector:
 46111 0000C46B 50                  <1> 	push	eax
 46112                              <1> 
 46113 0000C46C E850050000          <1> 	call	get_fat32_fsinfo_sector_parms
 46114 0000C471 72F6                <1> 	jc	short loc_sffc_read_fsinfo_sector_err2
 46115                              <1> 
 46116 0000C473 58                  <1> 	pop	eax
 46117                              <1> 	; EDX = First (Next) Free Cluster value from FSINFO sector
 46118                              <1> 	; EAX = First Free Cluster value from 'get_next_cluster'
 46119                              <1> 	; (edx = old value)
 46120 0000C474 39D0                <1> 	cmp	eax, edx ; First free Cluster (eax = new value) 
 46121 0000C476 75CB                <1> 	jne	short loc_sffc_write_fsinfo_sector
 46122                              <1> 
 46123 0000C478 C3                  <1> 	retn	
 46124                              <1> 
 46125                              <1> update_cluster:
 46126                              <1> 	; 07/08/2022
 46127                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 46128                              <1> 	; 23/10/2016
 46129                              <1> 	; 23/03/2016
 46130                              <1> 	; 02/03/2016
 46131                              <1> 	; 01/03/2016
 46132                              <1> 	; 29/02/2016
 46133                              <1> 	; 27/02/2016
 46134                              <1> 	; 26/02/2016
 46135                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
 46136                              <1> 	; 11/08/2011  
 46137                              <1> 	; 09/02/2005
 46138                              <1> 	; INPUT ->
 46139                              <1> 	;	EAX = Cluster Number
 46140                              <1> 	;	ECX = New Cluster Value
 46141                              <1> 	;	ESI = Logical Dos Drive Parameters Table
 46142                              <1> 	;
 46143                              <1> 	;	/// dword [FAT_ClusterCounter] ///
 46144                              <1> 	;
 46145                              <1> 	; OUTPUT ->
 46146                              <1> 	;	cf = 0 -> No Error, EAX is valid
 46147                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
 46148                              <1> 	; 	cf = 1 & EAX > 0 -> Error
 46149                              <1> 	;		(ECX -> any value)
 46150                              <1> 	; 	EAX = Next Cluster
 46151                              <1> 	;	ECX = New Cluster Value
 46152                              <1> 	;
 46153                              <1> 	;	/// [FAT_ClusterCounter] is updated,
 46154                              <1> 	;	/// decreased when a free cluster is assigned,
 46155                              <1> 	;	/// increased if an assigned cluster is freed.	
 46156                              <1> 	;		
 46157                              <1> 	;
 46158                              <1> 	; (Modified registers: EAX, EBX, -ECX-, EDX)
 46159                              <1> 	
 46160 0000C479 A3[527F0100]        <1> 	mov	[FAT_CurrentCluster], eax
 46161 0000C47E 890D[F4810100]      <1> 	mov	[ClusterValue], ecx
 46162                              <1> 
 46163                              <1> loc_update_cluster_check_fat_buffer:
 46164 0000C484 8A1E                <1> 	mov	bl, [esi+LD_Name]
 46165 0000C486 381D[577F0100]      <1> 	cmp	[FAT_BuffDrvName], bl
 46166 0000C48C 7418                <1> 	je	short loc_update_cluster_check_fat_type
 46167 0000C48E 803D[567F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
 46168                              <1> 	;je	loc_uc_save_fat_buffer
 46169                              <1> 	; 25/07/2022
 46170 0000C495 7502                <1> 	jne	short loc_uc_reset_fat_buffer_validation
 46171 0000C497 EB65                <1> 	jmp	loc_uc_save_fat_buffer
 46172                              <1> 
 46173                              <1> loc_uc_reset_fat_buffer_validation:
 46174 0000C499 C605[567F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
 46175                              <1> 
 46176                              <1> loc_uc_check_fat_type_reset_drvname:
 46177 0000C4A0 881D[577F0100]      <1> 	mov	[FAT_BuffDrvName], bl
 46178                              <1> 
 46179                              <1> loc_update_cluster_check_fat_type:
 46180 0000C4A6 29D2                <1> 	sub	edx, edx ; 26/02/2016
 46181 0000C4A8 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
 46182 0000C4AB 83F802              <1> 	cmp	eax, 2
 46183 0000C4AE 721D                <1>         jb	short update_cluster_inv_data
 46184 0000C4B0 80FB02              <1> 	cmp	bl, 2 
 46185                              <1>         ;ja	update_fat32_cluster
 46186                              <1> 	; 25/07/2022
 46187 0000C4B3 7605                <1> 	jna	short loc_uc_check_fat_type_1
 46188 0000C4B5 E98D010000          <1> 	jmp	update_fat32_cluster
 46189                              <1> 
 46190                              <1> loc_uc_check_fat_type_1:
 46191                              <1> 	;cmp	bl, 1
 46192                              <1> 	;jb	short update_cluster_inv_data
 46193 0000C4BA 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
 46194 0000C4BD 41                  <1> 	inc	ecx  
 46195 0000C4BE 890D[627F0100]      <1> 	mov	[LastCluster], ecx
 46196 0000C4C4 39C8                <1> 	cmp	eax, ecx ; dword [LastCluster]
 46197                              <1> 	;ja	return_uc_fat_stc
 46198                              <1> 	; 25/07/2022
 46199 0000C4C6 7608                <1> 	jna	short loc_uc_check_fat_type_2
 46200 0000C4C8 E9D6000000          <1> 	jmp	return_uc_fat_stc
 46201                              <1> 
 46202                              <1> 	; 25/07/2022
 46203                              <1> update_cluster_inv_data:
 46204                              <1> 	;mov	eax, 0Dh
 46205 0000C4CD B00D                <1> 	mov	al, 0Dh  ; Invalid Data
 46206 0000C4CF C3                  <1> 	retn 
 46207                              <1> 
 46208                              <1> loc_uc_check_fat_type_2:
 46209                              <1> 	; TRDOS v1 has a FATal bug here ! 
 46210                              <1> 		; or bl, bl ; cmp bl, 0
 46211                              <1> 		; jz short update_fat12_cluster
 46212                              <1> 	; !! It would destroy FAT12 floppy disk fs here !!
 46213                              <1> 	; ('A:' disks of TRDOS v1 operating system project
 46214                              <1> 	; had 'singlix fs', so, I could not differ this mistake
 46215                              <1> 	; on a drive 'A:')
 46216 0000C4D0 80FB01              <1> 	cmp	bl, 1 ; correct comparison is this !
 46217                              <1> 	;jna	update_fat12_cluster
 46218                              <1> 	; 25/07/2022
 46219 0000C4D3 7705                <1> 	ja	short update_fat16_cluster
 46220 0000C4D5 E9CE000000          <1> 	jmp	update_fat12_cluster	 
 46221                              <1> 
 46222                              <1> update_fat16_cluster:
 46223                              <1> pass_uc_fat16_errc:
 46224                              <1> 	;sub	edx, edx
 46225 0000C4DA BB00030000          <1> 	mov	ebx, 300h ;768
 46226 0000C4DF F7F3                <1> 	div	ebx
 46227                              <1> 	; EAX = Count of 3 FAT sectors
 46228                              <1> 	; DX = Cluster offset in FAT buffer
 46229                              <1> 	;mov	bx, dx  
 46230                              <1> 	; 25/07/2022
 46231 0000C4E1 89D3                <1> 	mov	ebx, edx
 46232                              <1> 	;shl	bx, 1 ; Multiply by 2
 46233                              <1> 	; 25/07/2022
 46234 0000C4E3 D1E3                <1> 	shl	ebx, 1
 46235 0000C4E5 66BA0300            <1> 	mov	dx, 3
 46236 0000C4E9 F7E2                <1> 	mul	edx  
 46237                              <1> 	; EAX = FAT Sector
 46238                              <1> 	; EDX = 0
 46239                              <1> 	; EBX = Byte offset in FAT buffer
 46240 0000C4EB 8A0D[567F0100]      <1> 	mov	cl, [FAT_BuffValidData]
 46241 0000C4F1 80F902              <1> 	cmp	cl, 2
 46242 0000C4F4 7518                <1> 	jne	short loc_uc_check_fat16_buff_sector_load
 46243                              <1> 
 46244                              <1> loc_uc_check_fat16_buff_sector_save:
 46245 0000C4F6 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46246                              <1> 	;jne	short loc_uc_save_fat_buffer
 46247                              <1> 	;jmp	short loc_update_fat16_cell
 46248                              <1> 	; 07/08/2022
 46249 0000C4FC 741D                <1> 	je	short loc_update_fat16_cell
 46250                              <1> 	;jmp	loc_uc_save_fat_buffer
 46251                              <1> 	
 46252                              <1> 	; 07/08/2022
 46253                              <1> loc_uc_save_fat_buffer:
 46254                              <1> 	; byte [FAT_BuffValidData] = 2 
 46255 0000C4FE E8F9010000          <1> 	call	save_fat_buffer
 46256 0000C503 7267                <1>         jc      short loc_fat_sectors_rw_error2
 46257                              <1> 	;mov	byte [FAT_BuffValidData], 1
 46258 0000C505 A1[527F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
 46259                              <1> 	;mov	ecx, [ClusterValue]
 46260                              <1> 	;jmp	short loc_update_cluster_check_fat_buffer
 46261 0000C50A 8A1E                <1> 	mov	bl, [esi+LD_Name] ; 01/03/2016
 46262 0000C50C EB8B                <1>         jmp     loc_uc_reset_fat_buffer_validation
 46263                              <1> 
 46264                              <1> loc_uc_check_fat16_buff_sector_load:
 46265 0000C50E 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
 46266 0000C511 7560                <1>         jne     short loc_uc_load_fat_sectors
 46267 0000C513 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46268 0000C519 7558                <1>         jne     short loc_uc_load_fat_sectors
 46269                              <1> 
 46270                              <1> loc_update_fat16_cell:
 46271                              <1> loc_update_fat16_buffer:
 46272 0000C51B 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
 46273                              <1> 	;movzx	eax, word [ebx]
 46274 0000C521 668B03              <1> 	mov	ax, [ebx]
 46275                              <1> 	; 01/03/2016
 46276 0000C524 89C2                <1> 	mov	edx, eax ; old value of the cluster
 46277 0000C526 A3[527F0100]        <1> 	mov	[FAT_CurrentCluster], eax
 46278 0000C52B 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
 46279 0000C531 66890B              <1> 	mov	[ebx], cx ; 16 bits !
 46280                              <1> 
 46281 0000C534 C605[567F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
 46282                              <1> 	
 46283 0000C53B 6683F802            <1> 	cmp	ax, 2
 46284 0000C53F 7262                <1> 	jb	short return_uc_fat16_stc
 46285 0000C541 3B05[627F0100]      <1> 	cmp	eax, [LastCluster]
 46286 0000C547 775A                <1> 	ja	short return_uc_fat16_stc
 46287                              <1> 
 46288                              <1> loc_fat_buffer_updated:
 46289                              <1> 	; 01/03/2016
 46290 0000C549 F8                  <1> 	clc
 46291                              <1> loc_fat_buffer_stc_1:
 46292 0000C54A 9C                  <1> 	pushf
 46293 0000C54B 21C9                <1> 	and	ecx, ecx
 46294 0000C54D 7506                <1> 	jnz	short loc_fat_buffer_updated_1
 46295                              <1> 
 46296                              <1> 	; 01/03/2016 
 46297                              <1> 	; new value of the cluster = 0 (free)
 46298                              <1> 	; increase free(d) cluster count
 46299 0000C54F FF05[5E7F0100]      <1> 	inc	dword [FAT_ClusterCounter]
 46300                              <1> 
 46301                              <1> loc_fat_buffer_updated_1: ; new value of the cluster > 0
 46302 0000C555 09D2                <1> 	or	edx, edx ; 02/03/2016
 46303 0000C557 7506                <1> 	jnz	short loc_fat_buffer_updated_2
 46304                              <1> 	; old value of the cluster = 0 (it was free cluster)
 46305                              <1> 	; decrease free(d) cluster count
 46306 0000C559 FF0D[5E7F0100]      <1> 	dec	dword [FAT_ClusterCounter] ; it may be negative number
 46307                              <1> 
 46308                              <1> loc_fat_buffer_updated_2:
 46309 0000C55F 9D                  <1> 	popf
 46310 0000C560 C3                  <1> 	retn
 46311                              <1> 
 46312                              <1> 	; 25/07/2022
 46313                              <1> loc_fat_sectors_rw_error1:
 46314                              <1> 	;mov	byte [FAT_BuffValidData], 0
 46315                              <1> 	; 23/10/2016 (15h -> 17)
 46316                              <1> 	; 23/03/2016
 46317 0000C561 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
 46318 0000C566 8825[567F0100]      <1> 	mov	[FAT_BuffValidData], ah ; 0
 46319                              <1> 
 46320                              <1> loc_fat_sectors_rw_error2:
 46321                              <1> 	;mov	eax, error code
 46322                              <1> 	;mov	edx, 0
 46323 0000C56C 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue]
 46324 0000C572 C3                  <1> 	retn
 46325                              <1> 
 46326                              <1> 	; 25/07/2022
 46327                              <1> loc_uc_load_fat_sectors:
 46328 0000C573 A3[5A7F0100]        <1> 	mov	[FAT_BuffSector], eax
 46329                              <1> 
 46330                              <1> load_uc_fat_sectors_zero:
 46331 0000C578 034660              <1> 	add	eax, [esi+LD_FATBegin]
 46332 0000C57B BB001C0900          <1> 	mov	ebx, FAT_Buffer
 46333 0000C580 B903000000          <1> 	mov	ecx, 3
 46334 0000C585 E89F570000          <1> 	call	disk_read
 46335 0000C58A 72D5                <1> 	jc	short loc_fat_sectors_rw_error1
 46336                              <1> 
 46337 0000C58C C605[567F0100]01    <1>         mov     byte [FAT_BuffValidData], 1
 46338 0000C593 A1[527F0100]        <1> 	mov 	eax, [FAT_CurrentCluster]
 46339 0000C598 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue]
 46340 0000C59E E903FFFFFF          <1>         jmp     loc_update_cluster_check_fat_type
 46341                              <1> 
 46342                              <1> return_uc_fat16_stc:
 46343                              <1> 	; 25/07/2022
 46344                              <1> return_uc_fat_stc:
 46345                              <1> 	; 01/03/2016
 46346 0000C5A3 31C0                <1> 	xor	eax, eax
 46347 0000C5A5 F9                  <1> 	stc
 46348 0000C5A6 EBA2                <1> 	jmp	short loc_fat_buffer_stc_1
 46349                              <1> 
 46350                              <1> update_fat12_cluster:
 46351                              <1> pass_uc_fat12_errc:
 46352                              <1> 	;sub	edx, edx
 46353 0000C5A8 BB00040000          <1> 	mov	ebx, 400h ;1024
 46354 0000C5AD F7F3                <1> 	div	ebx
 46355                              <1> 	; EAX = Count of 3 FAT sectors
 46356                              <1> 	; DX = Cluster offset in FAT buffer
 46357                              <1> 	;mov	cx, 3
 46358                              <1> 	; 25/07/2022
 46359 0000C5AF 29C9                <1> 	sub	ecx, ecx
 46360 0000C5B1 B103                <1> 	mov	cl, 3
 46361                              <1> 	; ecx = 3
 46362                              <1> 	;mov	bx, ax
 46363 0000C5B3 89C3                <1> 	mov	ebx, eax
 46364                              <1> 	;mov	ax, cx ; 3
 46365 0000C5B5 89C8                <1> 	mov	eax, ecx
 46366                              <1> 	;mul	dx     ; Multiply by 3
 46367 0000C5B7 F7E2                <1> 	mul	edx
 46368                              <1> 	;shr	ax, 1  ; Divide by 2
 46369 0000C5B9 D1E8                <1> 	shr	eax, 1
 46370                              <1> 	;xchg	bx, ax
 46371 0000C5BB 93                  <1> 	xchg	ebx, eax
 46372                              <1> 	; EAX = Count of 3 FAT sectors
 46373                              <1> 	; EBX = Byte Offset in FAT buffer   
 46374                              <1> 	;mul	cx  ; 3 * AX
 46375 0000C5BC F7E1                <1> 	mul	ecx ; 3 * EAX
 46376                              <1> 	; EAX = FAT Beginning Sector
 46377                              <1> 	; EDX = 0
 46378 0000C5BE 8A0D[567F0100]      <1> 	mov	cl, [FAT_BuffValidData]
 46379                              <1> 	; TRDOS v1 has a FATal bug here ! 
 46380                              <1> 	; (it does not have 'cmp cl, 2' instruction here !
 46381                              <1> 	;  while 'jne' is existing !)
 46382 0000C5C4 80F902              <1> 	cmp	cl, 2 ; 2 = dirty buffer (must be written to disk)
 46383 0000C5C7 750D                <1> 	jne	short loc_uc_check_fat12_buff_sector_load
 46384                              <1> 
 46385                              <1> loc_uc_check_fat12_buff_sector_save:
 46386 0000C5C9 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46387                              <1>         ;jne	short loc_uc_save_fat_buffer
 46388                              <1> 	;jmp	short loc_update_fat12_cell
 46389                              <1> 	; 07/08/2022
 46390 0000C5CF 7412                <1> 	je	short loc_update_fat12_cell
 46391 0000C5D1 E928FFFFFF          <1> 	jmp	loc_uc_save_fat_buffer
 46392                              <1> 
 46393                              <1> loc_uc_check_fat12_buff_sector_load:
 46394 0000C5D6 80F901              <1> 	cmp	cl, 1 ; byte ptr [FAT_BuffValidData]
 46395 0000C5D9 7598                <1>         jne     short loc_uc_load_fat_sectors
 46396 0000C5DB 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46397 0000C5E1 7590                <1> 	jne	short loc_uc_load_fat_sectors
 46398                              <1> 	; 07/08/2022
 46399                              <1> 	;je	short loc_update_fat12_cell
 46400                              <1> 	;jmp	loc_uc_load_fat_sectors
 46401                              <1> 
 46402                              <1> loc_update_fat12_cell:
 46403 0000C5E3 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
 46404                              <1> 	;mov	cx, [FAT_CurrentCluster]
 46405                              <1> 	; 25/07/2022
 46406 0000C5E9 8B0D[527F0100]      <1> 	mov	ecx, [FAT_CurrentCluster] 
 46407                              <1> 	;shr	cx, 1
 46408                              <1> 	; 25/07/2022
 46409 0000C5EF D1E9                <1> 	shr	ecx, 1
 46410 0000C5F1 668B03              <1> 	mov	ax, [ebx]
 46411                              <1> 	;mov	dx, ax
 46412 0000C5F4 89C2                <1> 	mov	edx, eax ; 25/07/2022
 46413 0000C5F6 7336                <1> 	jnc	short uc_fat12_nc_even
 46414                              <1> 
 46415                              <1> 	;and	ax, 0Fh
 46416                              <1> 	; 25/07/2022
 46417 0000C5F8 240F                <1> 	and	al, 0Fh
 46418 0000C5FA 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
 46419                              <1> 	;shl	cx, 4
 46420 0000C600 C1E104              <1> 	shl	ecx, 4
 46421                              <1> 	;or	cx, ax
 46422 0000C603 08C1                <1> 	or	cl, al ; 25/07/2022
 46423                              <1> 	;mov	ax, dx
 46424 0000C605 89D0                <1> 	mov	eax, edx
 46425 0000C607 66890B              <1> 	mov	[ebx], cx  ; 16 bits !
 46426                              <1> 	;shr	ax, 4 ; al(bit4..7)+ah(bit0..7)
 46427                              <1> 	; 25/07/2022
 46428 0000C60A C1E804              <1> 	shr	eax, 4
 46429                              <1> 
 46430                              <1> update_fat12_buffer:
 46431 0000C60D A3[527F0100]        <1> 	mov	[FAT_CurrentCluster], eax
 46432 0000C612 89C2                <1> 	mov	edx, eax ; 01/03/2016
 46433 0000C614 C605[567F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
 46434 0000C61B 6683F802            <1> 	cmp	ax, 2
 46435 0000C61F 725E                <1>         jb      short return_uc_fat12_stc
 46436 0000C621 3B05[627F0100]      <1> 	cmp	eax, [LastCluster]
 46437 0000C627 7756                <1>         ja      short return_uc_fat12_stc
 46438 0000C629 E91BFFFFFF          <1>         jmp     loc_fat_buffer_updated
 46439                              <1> 
 46440                              <1> uc_fat12_nc_even:
 46441 0000C62E 662500F0            <1> 	and	ax, 0F000h
 46442 0000C632 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
 46443 0000C638 80E50F              <1> 	and	ch, 0Fh
 46444                              <1> 	;or	cx, ax
 46445                              <1> 	; 25/07/2022
 46446 0000C63B 09C1                <1> 	or	ecx, eax
 46447                              <1> 	;mov	ax, dx
 46448 0000C63D 89D0                <1> 	mov	eax, edx
 46449 0000C63F 66890B              <1> 	mov	[ebx], cx ; 16 bits !
 46450 0000C642 80E40F              <1> 	and	ah, 0Fh ; al(bit0..7)+ah(bit0..3)
 46451 0000C645 EBC6                <1> 	jmp	short update_fat12_buffer
 46452                              <1> 
 46453                              <1> update_fat32_cluster:
 46454 0000C647 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
 46455 0000C64A 41                  <1> 	inc	ecx
 46456 0000C64B 890D[627F0100]      <1> 	mov	[LastCluster], ecx
 46457                              <1> 
 46458 0000C651 39C8                <1> 	cmp	eax, ecx
 46459 0000C653 772A                <1>         ja      short return_uc_fat32_stc ; 25/07/2022
 46460                              <1> 
 46461                              <1> pass_uc_fat32_errc:
 46462                              <1> 	;sub	edx, edx
 46463 0000C655 BB80010000          <1> 	mov	ebx, 180h ;384
 46464 0000C65A F7F3                <1> 	div	ebx
 46465                              <1> 	; EAX = Count of 3 FAT sectors
 46466                              <1> 	; DX = Cluster offset in FAT buffer
 46467 0000C65C 89D3                <1> 	mov	ebx, edx
 46468 0000C65E C1E302              <1> 	shl	ebx, 2 ; Multiply by 4
 46469                              <1> 	;mov	edx, 3	
 46470                              <1> 	; 25/07/2022
 46471                              <1> 	;xor	dh, dh
 46472                              <1> 	;mov	dl, 3
 46473 0000C661 66BA0300            <1> 	mov	dx, 3
 46474 0000C665 F7E2                <1> 	mul	edx
 46475                              <1> 	; EBX = Cluster Offset in FAT buffer
 46476                              <1> 	; EAX = FAT Sector
 46477                              <1> 	; EDX = 0
 46478 0000C667 8A0D[567F0100]      <1> 	mov	cl, [FAT_BuffValidData]
 46479 0000C66D 80F902              <1> 	cmp	cl, 2
 46480 0000C670 7515                <1> 	jne	short loc_uc_check_fat32_buff_sector_load
 46481                              <1> 
 46482                              <1> loc_uc_check_fat32_buff_sector_save:
 46483 0000C672 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46484                              <1> 	;jne	loc_uc_save_fat_buffer
 46485                              <1> 	;jmp	short loc_update_fat32_cell
 46486                              <1> 	; 25/07/2022
 46487 0000C678 741F                <1> 	je	short loc_update_fat32_cell
 46488 0000C67A E97FFEFFFF          <1> 	jmp	loc_uc_save_fat_buffer
 46489                              <1> 
 46490                              <1> return_uc_fat12_stc:
 46491                              <1> return_uc_fat32_stc:
 46492                              <1> 	; 25/07/2022
 46493 0000C67F 29C0                <1> 	sub	eax, eax
 46494 0000C681 F9                  <1> 	stc
 46495 0000C682 E9C3FEFFFF          <1> 	jmp	loc_fat_buffer_stc_1
 46496                              <1> 
 46497                              <1> loc_uc_check_fat32_buff_sector_load:
 46498 0000C687 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
 46499                              <1> 	;jne	loc_uc_load_fat_sectors
 46500                              <1> 	; 25/07/2022
 46501 0000C68A 7508                <1> 	jne	short loc_uc_load_fat_sects
 46502 0000C68C 3B05[5A7F0100]      <1> 	cmp	eax, [FAT_BuffSector]
 46503                              <1> 	;jne	loc_uc_load_fat_sectors
 46504                              <1> 	; 25/07/2022
 46505 0000C692 7405                <1> 	je	short loc_update_fat32_cell
 46506                              <1> loc_uc_load_fat_sects:
 46507 0000C694 E9DAFEFFFF          <1> 	jmp	loc_uc_load_fat_sectors	
 46508                              <1> 
 46509                              <1> loc_update_fat32_cell:
 46510                              <1> loc_update_fat32_buffer:
 46511 0000C699 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
 46512 0000C69F 8B03                <1> 	mov	eax, [ebx]
 46513 0000C6A1 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh ; 28 bit cluster value
 46514                              <1> 	
 46515 0000C6A6 8B15[527F0100]      <1> 	mov	edx, [FAT_CurrentCluster] ; 01/03/2016
 46516                              <1> 
 46517 0000C6AC A3[527F0100]        <1> 	mov 	[FAT_CurrentCluster], eax
 46518 0000C6B1 8B0D[F4810100]      <1> 	mov	ecx, [ClusterValue]
 46519 0000C6B7 890B                <1> 	mov	[ebx], ecx ; 29/02/2016 
 46520                              <1> 
 46521 0000C6B9 C605[567F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
 46522                              <1> 
 46523                              <1> 	; 01/03/2016
 46524 0000C6C0 21C0                <1> 	and	eax, eax ; was it free cluster ?
 46525 0000C6C2 7513                <1> 	jnz	short loc_upd_fat32_c0
 46526                              <1> 
 46527                              <1> 	;or	ecx, ecx ; it will be left free ?!
 46528                              <1> 	;jz	short loc_upd_fat32_c3
 46529                              <1> 
 46530 0000C6C4 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
 46531 0000C6C7 751F                <1> 	jne	short loc_upd_fat32_c3
 46532                              <1> 
 46533 0000C6C9 3B15[627F0100]      <1> 	cmp	edx, [LastCluster]
 46534 0000C6CF 7206                <1> 	jb	short loc_upd_fat32_c0
 46535                              <1> 
 46536                              <1> 	;mov	edx, 2 ; rewind !
 46537                              <1> 	; 25/07/2022
 46538 0000C6D1 29D2                <1> 	sub	edx, edx
 46539 0000C6D3 B202                <1> 	mov	dl, 2
 46540 0000C6D5 EB0E                <1> 	jmp	short loc_upd_fat32_c2
 46541                              <1> 
 46542                              <1> loc_upd_fat32_c0:
 46543 0000C6D7 FF463E              <1> 	inc	dword [esi+LD_BPB+BPB_Reserved+4] ; set it to next cluster		
 46544 0000C6DA EB0C                <1> 	jmp	short loc_upd_fat32_c3
 46545                              <1> 
 46546                              <1> loc_upd_fat32_c1:
 46547 0000C6DC 09C9                <1> 	or	ecx, ecx ; will it be free cluster ?
 46548 0000C6DE 7508                <1> 	jnz	short loc_upd_fat32_c3
 46549                              <1> 
 46550 0000C6E0 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
 46551 0000C6E3 7303                <1> 	jnb	short loc_upd_fat32_c3
 46552                              <1> 
 46553                              <1> loc_upd_fat32_c2:	
 46554 0000C6E5 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx			
 46555                              <1> 
 46556                              <1> loc_upd_fat32_c3:
 46557 0000C6E8 89C2                <1> 	mov	edx, eax
 46558                              <1> 
 46559                              <1> loc_upd_fat32_c4:
 46560 0000C6EA 83F802              <1> 	cmp	eax, 2
 46561 0000C6ED 7290                <1> 	jb	short return_uc_fat32_stc ; 25/07/2022 
 46562                              <1> 
 46563                              <1> pass_uc_fat32_c_zero_check_2:
 46564 0000C6EF 3B05[627F0100]      <1> 	cmp	eax, [LastCluster]
 46565 0000C6F5 7788                <1> 	ja	short return_uc_fat32_stc ; 25/07/2022
 46566                              <1> 	
 46567 0000C6F7 E94DFEFFFF          <1> 	jmp     loc_fat_buffer_updated
 46568                              <1> 
 46569                              <1> 
 46570                              <1> save_fat_buffer:
 46571                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 46572                              <1> 	; 15/10/2016
 46573                              <1> 	; 01/03/2016
 46574                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
 46575                              <1> 	; 11/08/2011
 46576                              <1> 	; 09/02/2005 
 46577                              <1> 	; INPUT ->
 46578                              <1> 	;	None
 46579                              <1> 	; OUTPUT ->
 46580                              <1> 	;	cf = 0 -> OK.
 46581                              <1> 	;	cf = 1 -> error code in AL (EAX)
 46582                              <1> 	;
 46583                              <1> 	;	EBX = FAT_Buffer address
 46584                              <1> 	;
 46585                              <1> 	; (EAX, EDX, ECX will be modified)
 46586                              <1> 
 46587                              <1> 	;cmp	byte [FAT_BuffValidData], 2 
 46588                              <1> 	;je	short loc_save_fat_buff
 46589                              <1> 
 46590                              <1> ;loc_save_fat_buffer_retn:
 46591                              <1> ;	xor	eax, eax
 46592                              <1> ;	retn
 46593                              <1> 
 46594                              <1> loc_save_fat_buff:
 46595 0000C6FC 31D2                <1> 	xor	edx, edx
 46596 0000C6FE 8A35[577F0100]      <1> 	mov	dh, [FAT_BuffDrvName]
 46597 0000C704 80FE41              <1> 	cmp	dh, 'A'
 46598 0000C707 7252                <1> 	jb	short loc_save_fat_buffer_inv_data_retn
 46599 0000C709 80EE41              <1> 	sub	dh, 'A'
 46600 0000C70C 56                  <1> 	push	esi ; *
 46601 0000C70D BE00010900          <1>         mov     esi, Logical_DOSDisks
 46602 0000C712 01D6                <1> 	add	esi, edx
 46603                              <1> 	
 46604 0000C714 8A5603              <1> 	mov	dl, [esi+LD_FATType]
 46605 0000C717 20D2                <1> 	and	dl, dl
 46606 0000C719 743F                <1> 	jz	short loc_save_fat_buffer_inv_data_pop_retn 
 46607                              <1> 
 46608 0000C71B A1[5A7F0100]        <1> 	mov	eax, [FAT_BuffSector]
 46609 0000C720 80FA02              <1> 	cmp	dl, 2
 46610 0000C723 772E                <1> 	ja	short loc_save_fat32_buff
 46611                              <1> 
 46612                              <1> loc_save_fat_12_16_buff:
 46613                              <1> 	; 01/03/2016
 46614                              <1> 	; TRDOS v1 has a FATal bug here!
 46615                              <1> 	; Correct code: mov dx, word ptr [FAT_BuffSector]+2
 46616                              <1> 	; (DX:AX in TRDOS v1 -> EAX in TRDOS v2)
 46617                              <1> 	;
 46618 0000C725 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+FATSecs] 
 46619 0000C729 29C1                <1> 	sub	ecx, eax
 46620                              <1> 	; TRDOS v1 has a bug here... ('pop esi' was forgotten!)
 46621                              <1> 	;jna	short loc_save_fat_buffer_inv_data_retn ; wrong addr!
 46622 0000C72B 762D                <1> 	jna	short loc_save_fat_buffer_inv_data_pop_retn ; correct addr.
 46623                              <1> 	; 25/07/2022
 46624                              <1> 	;jmp	short loc_save_fat_buffer_check_rs3
 46625                              <1> 
 46626                              <1> loc_save_fat_buffer_check_rs3:
 46627                              <1> 	; 25/07/2022
 46628 0000C72D 29DB                <1> 	sub	ebx, ebx
 46629 0000C72F B303                <1> 	mov	bl, 3
 46630                              <1> 	;cmp	ecx, 3
 46631 0000C731 39D9                <1> 	cmp	ecx, ebx ; 3
 46632 0000C733 7602                <1> 	jna	short loc_save_fat_buff_continue
 46633 0000C735 89D9                <1> 	mov	ecx, ebx ; mov ecx, 3
 46634                              <1> loc_save_fat_buff_continue:
 46635 0000C737 BB001C0900          <1> 	mov	ebx, FAT_Buffer
 46636 0000C73C 034660              <1> 	add	eax, [esi+LD_FATBegin]
 46637 0000C73F 51                  <1> 	push	ecx
 46638 0000C740 E8D5550000          <1> 	call	disk_write
 46639 0000C745 59                  <1> 	pop	ecx
 46640 0000C746 7239                <1> 	jc	short loc_save_FAT_buff_write_err
 46641                              <1> 	
 46642 0000C748 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
 46643 0000C74C 7613                <1> 	jna	short loc_calc_2nd_fat12_16_addr
 46644                              <1> 
 46645                              <1> loc_calc_2nd_fat32_addr:
 46646 0000C74E 8B462A              <1> 	mov	eax, [esi+LD_BPB+FAT32_FAT_Size]
 46647 0000C751 EB12                <1> 	jmp	short loc_calc_2nd_fat_addr
 46648                              <1> 
 46649                              <1> 	; 25/07/2022
 46650                              <1> loc_save_fat32_buff:
 46651 0000C753 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+FAT32_FAT_Size]
 46652 0000C756 29C1                <1> 	sub	ecx, eax
 46653 0000C758 77D3                <1> 	ja	short loc_save_fat_buffer_check_rs3
 46654                              <1> 
 46655                              <1> loc_save_fat_buffer_inv_data_pop_retn:
 46656 0000C75A 5E                  <1> 	pop	esi ; *
 46657                              <1> loc_save_fat_buffer_inv_data_retn:
 46658                              <1> 	;mov	eax, 0Dh ; Invalid DATA
 46659                              <1> 	; 25/07/2022
 46660 0000C75B 29C0                <1> 	sub	eax, eax
 46661 0000C75D B00D                <1> 	mov	al, 0Dh  ; Invalid DATA
 46662 0000C75F F9                  <1> 	stc	; cf = 1
 46663 0000C760 C3                  <1> 	retn
 46664                              <1> 
 46665                              <1> loc_calc_2nd_fat12_16_addr:
 46666 0000C761 0FB7461C            <1> 	movzx	eax, word [esi+LD_BPB+FATSecs]
 46667                              <1> 
 46668                              <1> loc_calc_2nd_fat_addr:
 46669 0000C765 034660              <1> 	add	eax, [esi+LD_FATBegin]
 46670 0000C768 0305[5A7F0100]      <1> 	add	eax, [FAT_BuffSector]
 46671 0000C76E BB001C0900          <1> 	mov	ebx, FAT_Buffer
 46672                              <1> 	; ecx = 1 to 3
 46673 0000C773 E8A2550000          <1> 	call	disk_write
 46674 0000C778 7207                <1> 	jc	short loc_save_FAT_buff_write_err
 46675                              <1>  	; Valid  buffer (1 = valid but do not save)
 46676 0000C77A C605[567F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
 46677                              <1> 
 46678                              <1> loc_save_FAT_buff_write_err:
 46679 0000C781 5E                  <1> 	pop	esi ; *
 46680 0000C782 BB001C0900          <1> 	mov	ebx, FAT_Buffer
 46681                              <1> 	; 15/10/2016 (1Dh -> 18)
 46682                              <1> 	; 23/03/2016 (1Dh)
 46683 0000C787 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
 46684 0000C78C C3                  <1> 	retn
 46685                              <1> 
 46686                              <1> calculate_fat_freespace:
 46687                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 46688                              <1> 	; 23/03/2016
 46689                              <1> 	; 02/03/2016
 46690                              <1> 	; 01/03/2016
 46691                              <1> 	; 29/02/2016
 46692                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
 46693                              <1> 	; 30/04/2011
 46694                              <1> 	; 03/04/2010
 46695                              <1> 	; 2005
 46696                              <1> 	; INPUT ->
 46697                              <1> 	;	EAX = Cluster count to be added or subtracted
 46698                              <1> 	; 	If BH = FFh, ESI = TR-DOS Logical Drive Description Table
 46699                              <1> 	; 	If BH < FFh, BH = TR-DOS Logical Drive Number
 46700                              <1> 	; 	BL: 
 46701                              <1> 	;	0 = Calculate, 1 = Add, 2 = Subtract, 3 = Get (Not Set/Calc)
 46702                              <1> 	; OUTPUT ->
 46703                              <1> 	;	EAX = Free Space in sectors
 46704                              <1> 	;	ESI = Logical Dos Drive Description Table address
 46705                              <1> 	;	BH = Logical Dos Drive Number (same with input value of BH)
 46706                              <1> 	;	BL = Type of operation (same with input value of BL)
 46707                              <1> 	;	ECX = 0 -> valid
 46708                              <1> 	;	ECX > 0 -> error or invalid
 46709                              <1> 	;	If EAX = FFFFFFFFh, it is 're-calculation needed'
 46710                              <1> 	;			          sign due to r/w error   
 46711                              <1> 
 46712 0000C78D 66891D[FA810100]    <1> 	mov	[CFS_OPType], bx
 46713 0000C794 A3[FC810100]        <1> 	mov	[CFS_CC], eax
 46714                              <1> 	
 46715 0000C799 80FFFF              <1> 	cmp	bh, 0FFh
 46716 0000C79C 740B                <1> 	je	short pass_calculate_freespace_get_drive_dt_offset
 46717                              <1> 
 46718                              <1> loc_calculate_freespace_get_drive_dt_offset:     
 46719 0000C79E 31C0                <1> 	xor	eax, eax
 46720 0000C7A0 88FC                <1>         mov     ah, bh
 46721 0000C7A2 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 46722 0000C7A7 01C6                <1>         add     esi, eax
 46723                              <1> 
 46724                              <1> pass_calculate_freespace_get_drive_dt_offset:
 46725 0000C7A9 08DB                <1> 	or	bl, bl
 46726 0000C7AB 7436                <1> 	jz	short loc_reset_fcc
 46727                              <1> 	
 46728                              <1> loc_get_free_sectors:
 46729 0000C7AD 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
 46730                              <1> 
 46731                              <1> 	;xor	ecx, ecx
 46732                              <1> 	;dec	ecx ; 0FFFFFFFFh
 46733                              <1> 	;cmp	eax, ecx ; 29/02/2016
 46734                              <1> 	;je	short loc_get_free_sectors_retn ; recalculation is needed!
 46735                              <1> 	
 46736                              <1> 	; 23/03/2016
 46737 0000C7B0 8B4E70              <1> 	mov	ecx, [esi+LD_TotalSectors]
 46738 0000C7B3 39C1                <1> 	cmp	ecx, eax ; Total sectors must be greater than Free sectors !
 46739 0000C7B5 7707                <1> 	ja	short loc_get_free_sectors_check_optype
 46740                              <1> 	
 46741 0000C7B7 31C0                <1> 	xor	eax, eax
 46742 0000C7B9 48                  <1> 	dec	eax ; 0FFFFFFFFh  ; recalculation is needed!
 46743 0000C7BA 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; reset (for recalculation)
 46744                              <1> 		
 46745                              <1> loc_get_free_sectors_retn:
 46746 0000C7BD C3                  <1> 	retn
 46747                              <1> 	
 46748                              <1> loc_get_free_sectors_check_optype:
 46749 0000C7BE 80FB03              <1> 	cmp	bl, 3
 46750 0000C7C1 7203                <1> 	jb	short loc_set_fcc_1 ; 25/07/2022
 46751                              <1> 
 46752 0000C7C3 29C9                <1> 	sub	ecx, ecx ; 0
 46753                              <1> 
 46754 0000C7C5 C3                  <1> 	retn	
 46755                              <1> 
 46756                              <1> loc_set_fcc_1:
 46757 0000C7C6 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
 46758                              <1> 	;ja	loc_update_FAT32_fs_info_fcc
 46759                              <1> 	; 25/07/2022
 46760 0000C7CA 7605                <1> 	jna	short loc_set_fcc_2
 46761 0000C7CC E9DD000000          <1> 	jmp	loc_update_FAT32_fs_info_fcc
 46762                              <1> 
 46763                              <1> loc_set_fcc_2:
 46764                              <1> 	;mov	eax, [esi+LD_FreeSectors]
 46765 0000C7D1 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
 46766 0000C7D5 29D2                <1> 	sub	edx, edx
 46767 0000C7D7 F7F1                <1> 	div	ecx
 46768                              <1> 	;or	dx, dx 
 46769                              <1> 	;	; DX -> Remain sectors < SecPerClust
 46770                              <1> 	;	; DX > 0 -> invalid free sector count
 46771                              <1> 	;jnz	short loc_reset_fcc 
 46772                              <1> 
 46773                              <1> ;pass_set_fcc_div32:
 46774 0000C7D9 A3[747F0100]        <1> 	mov	[FreeClusterCount], eax
 46775 0000C7DE E986000000          <1>         jmp     loc_set_free_sectors_FAT12_FAT16
 46776                              <1> 
 46777                              <1> loc_reset_fcc:
 46778 0000C7E3 31C0                <1> 	xor	eax, eax
 46779 0000C7E5 A3[747F0100]        <1> 	mov	[FreeClusterCount], eax ; 0
 46780 0000C7EA 8B5678              <1> 	mov	edx, [esi+LD_Clusters]
 46781 0000C7ED 42                  <1> 	inc	edx
 46782 0000C7EE 8915[627F0100]      <1> 	mov	[LastCluster], edx
 46783                              <1> 
 46784 0000C7F4 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
 46785 0000C7F8 7645                <1> 	jna	short loc_count_free_fat_clusters_0  
 46786                              <1> 
 46787 0000C7FA 48                  <1> 	dec	eax ; FFFFFFFFh
 46788 0000C7FB A3[04820100]        <1> 	mov	[CFS_FAT32FC], eax
 46789                              <1> 
 46790                              <1> 	; 29/02/2016
 46791 0000C800 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; reset
 46792 0000C803 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; reset
 46793                              <1> 	
 46794                              <1> 	;mov 	eax, 2
 46795                              <1> 	; 25/07/2022
 46796 0000C806 40                  <1> 	inc	eax ; eax = 0
 46797 0000C807 B002                <1> 	mov	al, 2
 46798                              <1> 
 46799                              <1> loc_count_fc_next_cluster_0:
 46800 0000C809 50                  <1> 	push	eax
 46801 0000C80A E87BF9FFFF          <1> 	call	get_next_cluster
 46802 0000C80F 7310                <1> 	jnc	short loc_check_fat32_ff_cluster
 46803 0000C811 09C0                <1> 	or	eax, eax
 46804 0000C813 741E                <1> 	jz	short pass_inc_cfs_fcc_0
 46805                              <1> 
 46806                              <1> loc_put_fcc_unknown_sign:
 46807 0000C815 58                  <1> 	pop	eax
 46808                              <1> 	; "Free count is Unknown" sign
 46809                              <1> 	;mov	dword [FreeClusterCount], 0FFFFFFFFh
 46810                              <1> 
 46811                              <1> 	; 29/02/2016
 46812                              <1> 	; Save Free Cluster Count value in FAT32 'BPB_Reserved' area
 46813                              <1> 	;mov	[esi+LD_BPB+BPB_Reserved], 0FFFFFFFFh ; unknown!
 46814 0000C816 8B15[04820100]      <1> 	mov	edx, [CFS_FAT32FC] ; First Free Cluster
 46815                              <1> 	; Save First Free Cluster value in FAT32 'BPB_Reserved+4' area
 46816 0000C81C 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx
 46817                              <1> 	
 46818 0000C81F EB7D                <1>         jmp     loc_put_fcc_invalid_sign
 46819                              <1> 
 46820                              <1> loc_check_fat32_ff_cluster:
 46821 0000C821 09C0                <1> 	or	eax, eax
 46822 0000C823 750E                <1> 	jnz	short pass_inc_cfs_fcc_0
 46823 0000C825 58                  <1> 	pop	eax
 46824 0000C826 A3[04820100]        <1> 	mov	[CFS_FAT32FC], eax
 46825                              <1> 	;mov	dword [FreeClusterCount], 1
 46826 0000C82B FF05[747F0100]      <1> 	inc	dword [FreeClusterCount]
 46827 0000C831 EB27                <1> 	jmp	short pass_inc_cfs_fcc_1
 46828                              <1> 
 46829                              <1> pass_inc_cfs_fcc_0:
 46830 0000C833 58                  <1> 	pop	eax
 46831                              <1> 
 46832                              <1> pass_inc_cfs_fcc_0c:
 46833 0000C834 40                  <1> 	inc	eax ; add eax, 1
 46834 0000C835 3B05[627F0100]      <1> 	cmp	eax, [LastCluster]
 46835 0000C83B 76CC                <1> 	jna 	short loc_count_fc_next_cluster_0
 46836 0000C83D EB6F                <1> 	jmp	short loc_update_FAT32_fs_info_fcc
 46837                              <1> 
 46838                              <1> loc_count_free_fat_clusters_0:
 46839                              <1> 	;mov	eax, 2
 46840 0000C83F B002                <1> 	mov	al, 2
 46841                              <1> 
 46842                              <1> loc_count_fc_next_cluster:
 46843 0000C841 50                  <1> 	push	eax
 46844 0000C842 E843F9FFFF          <1> 	call	get_next_cluster
 46845 0000C847 720C                <1> 	jc	short loc_count_fcc_stc
 46846                              <1> 
 46847                              <1> loc_count_free_clusters_1:
 46848 0000C849 21C0                <1> 	and	eax, eax
 46849 0000C84B 750C                <1> 	jnz	short pass_inc_cfs_fcc
 46850                              <1> 
 46851 0000C84D FF05[747F0100]      <1> 	inc	dword [FreeClusterCount]
 46852 0000C853 EB04                <1> 	jmp	short pass_inc_cfs_fcc
 46853                              <1> 
 46854                              <1> loc_count_fcc_stc:
 46855 0000C855 09C0                <1> 	or	eax, eax
 46856 0000C857 75BC                <1> 	jnz	short loc_put_fcc_unknown_sign ; 29/02/2016
 46857                              <1> 
 46858                              <1> pass_inc_cfs_fcc:
 46859 0000C859 58                  <1> 	pop	eax
 46860                              <1> 
 46861                              <1> pass_inc_cfs_fcc_1:
 46862 0000C85A 40                  <1> 	inc	eax ; add eax, 1
 46863 0000C85B 3B05[627F0100]      <1> 	cmp	eax, [LastCluster]
 46864 0000C861 76DE                <1> 	jna	short loc_count_fc_next_cluster
 46865                              <1> 
 46866                              <1> loc_set_free_sectors:
 46867 0000C863 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
 46868 0000C867 7745                <1> 	ja	short loc_update_FAT32_fs_info_fcc
 46869                              <1> 
 46870                              <1> loc_set_free_sectors_FAT12_FAT16:
 46871 0000C869 803D[FA810100]00    <1> 	cmp	byte [CFS_OPType], 0
 46872 0000C870 761C                <1> 	jna	short pass_FAT_add_sub_fcc
 46873 0000C872 A1[FC810100]        <1> 	mov	eax, [CFS_CC]
 46874 0000C877 803D[FA810100]01    <1> 	cmp	byte [CFS_OPType], 1
 46875 0000C87E 7708                <1> 	ja	short pass_FAT_add_fcc
 46876 0000C880 0105[747F0100]      <1> 	add 	[FreeClusterCount], eax
 46877 0000C886 EB06                <1> 	jmp	short pass_FAT_add_sub_fcc
 46878                              <1> 
 46879                              <1> pass_FAT_add_fcc:
 46880 0000C888 2905[747F0100]      <1> 	sub	[FreeClusterCount], eax
 46881                              <1> 
 46882                              <1> pass_FAT_add_sub_fcc:
 46883 0000C88E 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
 46884 0000C892 8B15[747F0100]      <1> 	mov	edx, [FreeClusterCount]
 46885 0000C898 F7E2                <1> 	mul	edx
 46886                              <1> 
 46887 0000C89A 31C9                <1> 	xor	ecx, ecx 
 46888 0000C89C EB05                <1> 	jmp	short loc_cfs_retn_params
 46889                              <1> 
 46890                              <1> loc_put_fcc_invalid_sign:
 46891 0000C89E 29C0                <1>        	sub	eax, eax ; 0
 46892 0000C8A0 48                  <1> 	dec	eax ; FFFFFFFFh
 46893                              <1> loc_fat32_ffc_recalc_needed:
 46894 0000C8A1 89C1                <1> 	mov	ecx, eax
 46895                              <1> 
 46896                              <1> loc_cfs_retn_params:
 46897 0000C8A3 894674              <1> 	mov 	[esi+LD_FreeSectors], eax
 46898 0000C8A6 0FB71D[FA810100]    <1> 	movzx	ebx, word [CFS_OPType]
 46899 0000C8AD C3                  <1> 	retn
 46900                              <1> 
 46901                              <1> loc_update_FAT32_fs_info_fcc:
 46902                              <1> loc_check_fcc_FSINFO_op:
 46903                              <1> 	; 29/02/2016
 46904                              <1> 	; EAX = Free cluster count (before this update) ; value from disk
 46905                              <1> 	; EDX = First Free Cluster (before this update) ; value from disk
 46906 0000C8AE 803D[FA810100]01    <1> 	cmp	byte [CFS_OPType], 1
 46907 0000C8B5 7221                <1> 	jb	short loc_cfs_FAT32_get_rcalc_parms ; 0 = recalculated
 46908 0000C8B7 7406                <1> 	je	short loc_check_fcc_FSINFO_op1 ; 1 = add
 46909                              <1> loc_check_fcc_FSINFO_op2: ; subtract
 46910 0000C8B9 F71D[FC810100]      <1> 	neg	dword [CFS_CC] ; prepare to subtract ; 2 = sub (add negative)
 46911                              <1> loc_check_fcc_FSINFO_op1:
 46912                              <1> 	; 01/03/2016
 46913 0000C8BF 31D2                <1> 	xor	edx, edx ; 0
 46914 0000C8C1 4A                  <1> 	dec	edx ; 0FFFFFFFFh
 46915 0000C8C2 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved]
 46916 0000C8C5 39D0                <1> 	cmp	eax, edx
 46917 0000C8C7 73D5                <1> 	jnb	short loc_put_fcc_invalid_sign
 46918 0000C8C9 0305[FC810100]      <1>         add     eax, [CFS_CC] ; free cluster count on disk + current count
 46919 0000C8CF 72CD                <1> 	jc	short loc_put_fcc_invalid_sign
 46920                              <1> 	
 46921 0000C8D1 A3[747F0100]        <1> 	mov	[FreeClusterCount], eax
 46922 0000C8D6 EB0E                <1> 	jmp	short loc_cfs_write_FSINFO_sector
 46923                              <1> 
 46924                              <1> loc_cfs_FAT32_get_rcalc_parms:
 46925 0000C8D8 8B15[04820100]      <1> 	mov	edx, [CFS_FAT32FC]
 46926 0000C8DE A1[747F0100]        <1> 	mov	eax, [FreeClusterCount]
 46927 0000C8E3 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
 46928                              <1> loc_cfs_write_FSINFO_sector:
 46929 0000C8E6 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
 46930                              <1> 	; 01/03/2016
 46931 0000C8E9 E8AA000000          <1> 	call	set_fat32_fsinfo_sector_parms
 46932 0000C8EE 72AE                <1>         jc      short loc_put_fcc_invalid_sign
 46933                              <1> 
 46934                              <1> loc_set_FAT32_free_sectors:
 46935                              <1> 	; 29/02/2016
 46936                              <1> 	;mov	eax, [FreeClusterCount]
 46937                              <1> 	;mov	ecx, eax
 46938                              <1> 	;cmp	eax, 0FFFFFFFFh ; Invalid !
 46939                              <1> 	;je	short loc_cfs_retn_params
 46940                              <1> 	;
 46941 0000C8F0 8B0D[747F0100]      <1> 	mov	ecx, [FreeClusterCount]
 46942 0000C8F6 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
 46943 0000C8FA F7E1                <1> 	mul	ecx
 46944                              <1> 	; 29/02/2016
 46945 0000C8FC 31C9                <1> 	xor	ecx, ecx ; 0
 46946 0000C8FE 09D2                <1> 	or	edx, edx ; 0 ?
 46947 0000C900 759C                <1>         jnz	short loc_put_fcc_invalid_sign ; 25/07/2022
 46948 0000C902 394670              <1> 	cmp	[esi+LD_TotalSectors], eax ; Volume size in sectors
 46949 0000C905 7697                <1>         jna     short loc_put_fcc_invalid_sign
 46950                              <1> 	;
 46951                              <1> loc_set_FAT32_free_sectors_ok:
 46952 0000C907 31D2                <1> 	xor	edx, edx ; 0
 46953 0000C909 EB98                <1>         jmp     short loc_cfs_retn_params 
 46954                              <1> 	;
 46955                              <1> 
 46956                              <1> get_last_cluster:
 46957                              <1> 	; 22/10/2016
 46958                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
 46959                              <1> 	; 12/06/2010 (DRV_FAT.ASM, 'proc_get_last_custer')
 46960                              <1> 	; 06/06/2010
 46961                              <1> 	; INPUT ->
 46962                              <1> 	;	EAX = First Cluster Number
 46963                              <1> 	; 	ESI = Logical Dos Drive Parameters Table
 46964                              <1> 	; OUTPUT ->
 46965                              <1> 	;	cf = 0 -> No Error, EAX is valid
 46966                              <1> 	;	cf = 1 -> EAX > 0 -> Error
 46967                              <1> 	;	EAX = Last Cluster Number
 46968                              <1> 	;       ECX = Previous Cluster -just before the last cluster-
 46969                              <1> 	;       ; 22/10/2016
 46970                              <1> 	;	[glc_index] = cluster index number of the last cluster	
 46971                              <1> 	;
 46972                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 46973                              <1> 
 46974 0000C90B 89C1                <1> 	mov	ecx, eax
 46975                              <1> 
 46976 0000C90D C705[0C820100]FFFF- <1> 	mov	dword [glc_index], 0FFFFFFFFh ; 22/10/2016	
 46977 0000C915 FFFF                <1>
 46978                              <1> 
 46979                              <1> loc_glc_get_next_cluster_1:
 46980 0000C917 890D[08820100]      <1> 	mov	[glc_prevcluster], ecx
 46981                              <1>  	; 22/10/2016
 46982 0000C91D FF05[0C820100]      <1> 	inc	dword [glc_index]
 46983                              <1> 
 46984                              <1> loc_glc_get_next_cluster_2:
 46985 0000C923 E862F8FFFF          <1> 	call	get_next_cluster
 46986                              <1> 	; ecx = current/previous cluster 
 46987                              <1> 	; eax = next/last cluster
 46988 0000C928 73ED                <1> 	jnc	short loc_glc_get_next_cluster_1
 46989                              <1> 
 46990 0000C92A 09C0                <1> 	or	eax, eax
 46991 0000C92C 7509                <1> 	jnz	short loc_glc_stc_retn
 46992                              <1> 
 46993                              <1> 	; ecx = previous cluster
 46994 0000C92E 89C8                <1>         mov	eax, ecx
 46995                              <1> 
 46996                              <1> 	; previous cluster becomes last cluster (ecx -> eax)
 46997                              <1> 	; previous of previous cluster becomes previous cluster (ecx)
 46998                              <1> 
 46999                              <1> loc_glc_prev_cluster_retn:
 47000 0000C930 8B0D[08820100]      <1> 	mov	ecx, [glc_prevcluster] 
 47001 0000C936 C3                  <1> 	retn
 47002                              <1> 
 47003                              <1> loc_glc_stc_retn:
 47004 0000C937 F5                  <1> 	cmc	;stc
 47005 0000C938 EBF6                <1>         jmp	short loc_glc_prev_cluster_retn
 47006                              <1> 
 47007                              <1> truncate_cluster_chain:
 47008                              <1> 	; 01/03/2016
 47009                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
 47010                              <1> 	; 22/01/2011 (DRV_FAT.ASM, 'proc_truncate_cluster_chain')
 47011                              <1> 	; 11/09/2010
 47012                              <1> 	; INPUT ->
 47013                              <1> 	;	ESI = Logical dos drive description table address
 47014                              <1> 	;	EAX = First cluster to be truncated/unlinked 
 47015                              <1> 	; OUTPUT ->
 47016                              <1> 	;	ESI = Logical dos drive description table address
 47017                              <1> 	; 	ECX = Count of truncated/removed clusters
 47018                              <1> 	; 	CF = 0 -> EAX = Free sectors
 47019                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
 47020                              <1> 
 47021                              <1> 	; NOTE: This procedure does not update lm date&time ! 
 47022                              <1> 
 47023                              <1> loc_truncate_cc:	
 47024 0000C93A 31C9                <1> 	xor	ecx, ecx ; mov ecx, 0
 47025                              <1> 	;mov	byte [FAT_BuffValidData], 0
 47026 0000C93C 890D[5E7F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
 47027                              <1> 
 47028                              <1> loc_tcc_unlink_clusters:
 47029 0000C942 E832FBFFFF          <1> 	call	update_cluster
 47030                              <1> 	; EAX = Next Cluster
 47031                              <1> 	; ECX = Cluster Value
 47032                              <1> 	; Note:
 47033                              <1> 	; Returns count of unlinked clusters in
 47034                              <1> 	; dword ptr FAT_ClusterCounter
 47035 0000C947 73F9                <1> 	jnc	short loc_tcc_unlink_clusters
 47036                              <1> 
 47037                              <1> pass_tcc_unlink_clusters:
 47038 0000C949 A2[13820100]        <1> 	mov	byte [TCC_FATErr], al
 47039 0000C94E 803D[567F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
 47040 0000C955 750E                <1> 	jne	short loc_tcc_calculate_FAT_freespace
 47041 0000C957 E8A0FDFFFF          <1> 	call	save_fat_buffer
 47042 0000C95C 7307                <1> 	jnc	short loc_tcc_calculate_FAT_freespace
 47043 0000C95E A2[13820100]        <1> 	mov	byte [TCC_FATErr], al ; Error
 47044                              <1> 	;mov	byte [FAT_BuffValidData], 0
 47045                              <1> 
 47046                              <1> 	; 01/03/2016
 47047 0000C963 EB12                <1> 	jmp	short loc_tcc_recalculate_FAT_freespace
 47048                              <1> 
 47049                              <1> loc_tcc_calculate_FAT_freespace:
 47050 0000C965 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter] ; signed (+-) number
 47051 0000C96A 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI = Dos drv desc. table
 47052                              <1> 			   ; BL = 1 -> add cluster(s)
 47053 0000C96E E81AFEFFFF          <1> 	call	calculate_fat_freespace
 47054 0000C973 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
 47055 0000C975 7409                <1> 	jz	short pass_truncate_cc_recalc_FAT_freespace
 47056                              <1> 
 47057                              <1> loc_tcc_recalculate_FAT_freespace:
 47058 0000C977 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate !
 47059 0000C97B E80DFEFFFF          <1> 	call	calculate_fat_freespace
 47060                              <1>               
 47061                              <1> loc_tcc_calculate_FAT_freespace_err:
 47062                              <1> pass_truncate_cc_recalc_FAT_freespace:
 47063 0000C980 8B0D[5E7F0100]      <1> 	mov	ecx, [FAT_ClusterCounter]
 47064                              <1> 
 47065 0000C986 803D[13820100]00    <1> 	cmp	byte [TCC_FATErr], 0
 47066 0000C98D 7608                <1> 	jna	short loc_tcc_unlink_clusters_retn
 47067                              <1> 
 47068                              <1> loc_tcc_unlink_clusters_error:
 47069 0000C98F 0FB605[13820100]    <1> 	movzx	eax, byte [TCC_FATErr]
 47070 0000C996 F9                  <1> 	stc
 47071                              <1> loc_tcc_unlink_clusters_retn:
 47072 0000C997 C3                  <1> 	retn
 47073                              <1> 
 47074                              <1> set_fat32_fsinfo_sector_parms:
 47075                              <1> 	; 15/10/2016
 47076                              <1> 	; 23/03/2016
 47077                              <1> 	; 29/02/2016 (TRDOS 386 = TRDOS v2.0)
 47078                              <1> 	; INPUT ->
 47079                              <1> 	;	ESI = Logical dos drive description table address
 47080                              <1> 	;	[esi+LD_BPB+BPB_Reserved] = Free Cluster Count
 47081                              <1> 	;	[esi+LD_BPB+BPB_Reserved+4] = First Free Cluster 
 47082                              <1> 	; OUTPUT ->
 47083                              <1> 	;	ESI = Logical dos drive description table address
 47084                              <1> 	; 	CF = 0 -> OK..
 47085                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
 47086                              <1> 	;
 47087                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
 47088                              <1> 
 47089 0000C998 E824000000          <1> 	call	get_fat32_fsinfo_sector_parms
 47090 0000C99D 7221                <1> 	jc	short update_fat32_fsinfo_sector_retn
 47091                              <1> 
 47092 0000C99F 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved] ; Free Cluster Count
 47093 0000C9A2 8B563E              <1> 	mov	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free Cluster	
 47094                              <1> 
 47095                              <1>         ;mov	ebx, DOSBootSectorBuff
 47096 0000C9A5 8983E8010000        <1> 	mov	[ebx+488], eax
 47097 0000C9AB 8993EC010000        <1> 	mov	[ebx+492], edx	
 47098                              <1> 
 47099 0000C9B1 A1[00820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
 47100 0000C9B6 B901000000          <1> 	mov	ecx, 1
 47101 0000C9BB E85A530000          <1> 	call	disk_write
 47102                              <1> 	;jnc	short update_fat32_fsinfo_sector_retn
 47103                              <1> 
 47104                              <1> 	; 15/10/2016 (1Dh -> 18)
 47105                              <1> 	; 23/03/2016 (1Dh)
 47106                              <1> 	;mov	eax, 18 ; Drive not ready or write error
 47107                              <1> 
 47108                              <1> update_fat32_fsinfo_sector_retn:
 47109 0000C9C0 C3                  <1> 	retn
 47110                              <1> 
 47111                              <1> get_fat32_fsinfo_sector_parms:
 47112                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 47113                              <1> 	; 15/10/2016
 47114                              <1> 	; 23/03/2016
 47115                              <1> 	; 01/03/2016
 47116                              <1> 	; 29/02/2016 (TRDOS 386 = TRDOS v2.0)
 47117                              <1> 	; INPUT ->
 47118                              <1> 	;	ESI = Logical dos drive description table address
 47119                              <1> 	; OUTPUT ->
 47120                              <1> 	;	ESI = Logical dos drive description table address
 47121                              <1> 	;	EBX = FSINFO sector buffer address (DOSBootSectorBuff)	
 47122                              <1> 	;	CF = 0 -> OK..
 47123                              <1> 	;	   EAX = FsInfo sector address
 47124                              <1> 	;	   ECX = Free cluster count
 47125                              <1> 	;	   EDX = First free cluster 	
 47126                              <1> 	;	CF = 1 -> Error code in AL (EAX)
 47127                              <1> 	;	   EBX = 0
 47128                              <1> 	;	
 47129                              <1> 	;	[CFS_FAT32FSINFOSEC] = FAT32 FSINFO sector address
 47130                              <1>         ;
 47131                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
 47132                              <1> 
 47133 0000C9C1 0FB74636            <1> 	movzx	eax, word [esi+LD_BPB+FAT32_FSInfoSec]
 47134 0000C9C5 03466C              <1> 	add	eax, [esi+LD_StartSector]
 47135 0000C9C8 A3[00820100]        <1> 	mov	[CFS_FAT32FSINFOSEC], eax
 47136                              <1> 	
 47137 0000C9CD BB[527D0100]        <1>         mov     ebx, DOSBootSectorBuff
 47138                              <1> 	;mov	ecx, 1
 47139                              <1> 	; 25/07/2022
 47140 0000C9D2 29C9                <1> 	sub	ecx, ecx
 47141 0000C9D4 FEC1                <1> 	inc	cl
 47142                              <1> 	; ecx = 1
 47143 0000C9D6 E84E530000          <1> 	call	disk_read
 47144 0000C9DB 722F                <1> 	jc	short loc_read_FAT32_fsinfo_sec_err
 47145                              <1> 
 47146 0000C9DD BB[527D0100]        <1> 	mov	ebx, DOSBootSectorBuff
 47147                              <1> 
 47148 0000C9E2 813B52526141        <1> 	cmp	dword [ebx], 41615252h
 47149 0000C9E8 751E                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
 47150                              <1> 
 47151 0000C9EA 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
 47152 0000C9F3 61                  <1>
 47153 0000C9F4 7512                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
 47154                              <1> 
 47155 0000C9F6 A1[00820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
 47156 0000C9FB 8B8BE8010000        <1> 	mov	ecx, [ebx+488] ; free cluster count
 47157 0000CA01 8B93EC010000        <1> 	mov	edx, [ebx+492] ; first (next) free cluster	
 47158                              <1> 
 47159 0000CA07 C3                  <1> 	retn
 47160                              <1> 
 47161                              <1> loc_read_FAT32_fsinfo_sec_stc: 
 47162                              <1> 	; 15/10/2016 (0Bh -> 28)
 47163                              <1> 	;mov	eax, 28 ; Invalid format!
 47164                              <1> 	; 25/07/2022
 47165 0000CA08 B31C                <1> 	mov	bl, 28
 47166 0000CA0A EB02                <1> 	jmp	short loc_read_FAT32_fsinfo_sec_stc_retn
 47167                              <1> 
 47168                              <1> loc_read_FAT32_fsinfo_sec_err:
 47169                              <1> 	; 15/10/2016 (15h -> 17)
 47170                              <1> 	; 23/03/2016 (15h)
 47171                              <1> 	;mov	eax, 17 ; Drive not ready or read error
 47172                              <1> 	; 25/07/2022
 47173 0000CA0C B311                <1> 	mov	bl, 17
 47174                              <1> loc_read_FAT32_fsinfo_sec_stc_retn:
 47175                              <1> 	; 25/07/2022
 47176 0000CA0E 29C0                <1> 	sub	eax, eax
 47177 0000CA10 88D8                <1> 	mov	al, bl ; error code
 47178                              <1> 	; eax = error code
 47179 0000CA12 29DB                <1> 	sub	ebx, ebx ; 0
 47180 0000CA14 F9                  <1> 	stc
 47181 0000CA15 C3                  <1> 	retn
 47182                              <1> 
 47183                              <1> add_new_cluster:
 47184                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 47185                              <1> 	; 15/10/2016
 47186                              <1> 	; 16/05/2016
 47187                              <1> 	; 18/03/2016, 24/03/2016
 47188                              <1> 	; 11/03/2016 (TRDOS 386 = TRDOS v2.0)
 47189                              <1> 	; 30/07/2011 (DRV_FAT.ASM)
 47190                              <1> 	; 11/09/2010
 47191                              <1> 	; INPUT ->
 47192                              <1> 	;	ESI = Logical dos drv desc. table address
 47193                              <1> 	;	EAX = Last cluster
 47194                              <1> 	; OUTPUT ->
 47195                              <1> 	;	ESI = Logical dos drv desc. table address
 47196                              <1> 	;	EAX = New Last cluster (next cluster)
 47197                              <1> 	;	cf = 1 -> error code in EAX (AL)
 47198                              <1> 	;	cf = 1 -> EBX = sectors per cluster
 47199                              <1> 	;	ECX = Free sectors
 47200                              <1> 	;;;	25/07/2022
 47201                              <1> 	;	(EBX = sectors per cluster -not used-)
 47202                              <1> 	;	EDX = 0 (if cf = 0)
 47203                              <1> 	; NOTE:
 47204                              <1> 	; This procedure does not update lm date&time !
 47205                              <1> 	;
 47206                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, EDI)
 47207                              <1> 
 47208 0000CA16 A3[30830100]        <1> 	mov	[FAT_anc_LCluster], eax
 47209                              <1> 	
 47210 0000CA1B E88CF9FFFF          <1> 	call	get_first_free_cluster
 47211 0000CA20 720A                <1> 	jc	short loc_add_new_cluster_retn
 47212                              <1> 	; EAX >= 2 and EAX < FFFFFFFFh is valid
 47213                              <1> 
 47214 0000CA22 89C2                <1> 	mov	edx, eax
 47215                              <1> 
 47216 0000CA24 42                  <1> 	inc	edx
 47217                              <1> 	;jnz	short loc_add_new_cluster_check_ffc_eax
 47218 0000CA25 7510                <1> 	jnz	short loc_add_new_cluster_save_fcc
 47219                              <1> 
 47220                              <1> loc_add_new_cluster_no_disk_space_retn:
 47221                              <1> 	;mov	eax, 27h ; MSDOS err => insufficient disk space
 47222                              <1> 	; 25/07/2022
 47223 0000CA27 31C0                <1> 	xor	eax, eax
 47224 0000CA29 B027                <1> 	mov	al, 27h
 47225                              <1> loc_add_new_cluster_stc_retn:
 47226 0000CA2B F9                  <1> 	stc
 47227                              <1> loc_add_new_cluster_retn:
 47228                              <1> 	; 25/07/2022
 47229                              <1> 	;movzx	ebx, byte [esi+LD_BPB+SecPerClust]
 47230 0000CA2C 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
 47231                              <1> 	;xor	edx, edx
 47232                              <1> 	;stc
 47233 0000CA2F C3                  <1> 	retn
 47234                              <1> 
 47235                              <1> loc_anc_invalid_format_stc_retn:
 47236 0000CA30 F9                  <1> 	stc
 47237                              <1> loc_add_new_cluster_invalid_format_retn:
 47238                              <1> 	; 15/10/2016 (0Bh -> 28)
 47239                              <1> 	;mov	eax, 28 ; Invalid format
 47240                              <1> 	;jmp	short loc_add_new_cluster_retn 
 47241                              <1> 	; 25/07/2022
 47242 0000CA31 29C0                <1> 	sub	eax, eax
 47243 0000CA33 B01C                <1> 	mov	al, 28
 47244 0000CA35 EBF4                <1> 	jmp	short loc_add_new_cluster_stc_retn
 47245                              <1> 
 47246                              <1> ;loc_add_new_cluster_check_ffc_eax:
 47247                              <1> ;	cmp	eax, 2
 47248                              <1> ;	jb	short loc_add_new_cluster_invalid_format_retn
 47249                              <1> 
 47250                              <1> loc_add_new_cluster_save_fcc:  
 47251 0000CA37 A3[34830100]        <1> 	mov	[FAT_anc_FFCluster], eax
 47252                              <1> 
 47253 0000CA3C 83E802              <1> 	sub	eax, 2
 47254 0000CA3F 0FB65E13            <1> 	movzx   ebx, byte [esi+LD_BPB+SecPerClust]
 47255 0000CA43 F7E3                <1> 	mul	ebx
 47256 0000CA45 09D2                <1> 	or	edx, edx
 47257 0000CA47 75E7                <1> 	jnz	short loc_anc_invalid_format_stc_retn
 47258                              <1> 
 47259                              <1> loc_add_new_cluster_allocate_cluster:
 47260                              <1> 	; 18/03/2016
 47261 0000CA49 92                  <1> 	xchg	edx, eax ; eax = 0
 47262                              <1> 	; 16/05/2016
 47263                              <1> 	;cmp	[ClusterBuffer_Valid], al ; 0
 47264                              <1> 	;jna	short loc_anc_clear_cluster_buffer
 47265                              <1> 	;; 'copy' command, 
 47266                              <1> 	;; writing destination file clust after reading source file clust
 47267                              <1> 	;mov	[ClusterBuffer_Valid], al ; 0 ; reset
 47268                              <1> 	;jmp	short loc_add_new_cluster_write_nc_to_disk
 47269                              <1> 
 47270                              <1> loc_anc_clear_cluster_buffer:
 47271                              <1> 	; 11/03/2016
 47272                              <1> 	; Clear buffer
 47273 0000CA4A BF00000700          <1> 	mov	edi, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
 47274 0000CA4F 89D9                <1> 	mov	ecx, ebx ; sector count
 47275 0000CA51 C1E107              <1> 	shl	ecx, 7 ; 1 sector = 512 bytes -> 128 double words
 47276                              <1> 	;xor	eax, eax ; 0
 47277 0000CA54 F3AB                <1> 	rep	stosd
 47278                              <1> 
 47279                              <1> loc_add_new_cluster_write_nc_to_disk:
 47280                              <1> 	; 11/03/2016
 47281                              <1> 	;xchg	eax, edx ; edx = 0, eax = sector offset
 47282 0000CA56 89D0                <1> 	mov	eax, edx
 47283 0000CA58 034668              <1>         add     eax, [esi+LD_DATABegin]
 47284 0000CA5B 72D4                <1> 	jc	short loc_add_new_cluster_invalid_format_retn 
 47285                              <1> 		
 47286 0000CA5D 89D9                <1> 	mov	ecx, ebx ; ECX = sectors per cluster (<256)
 47287 0000CA5F BB00000700          <1> 	mov	ebx, Cluster_Buffer
 47288 0000CA64 E8B1520000          <1> 	call	disk_write
 47289 0000CA69 7306                <1> 	jnc	short loc_add_new_cluster_update_fat_nlc
 47290                              <1> 	
 47291                              <1> 	; 15/10/2016 (1Dh -> 18)
 47292                              <1> 	;mov	eax, 18 ; Write Error
 47293                              <1> 	; 25/07/2022
 47294 0000CA6B 31C0                <1> 	xor	eax, eax
 47295 0000CA6D B012                <1> 	mov	al, 18
 47296 0000CA6F EBBA                <1> 	jmp	short loc_add_new_cluster_stc_retn
 47297                              <1> 
 47298                              <1> loc_add_new_cluster_update_fat_nlc:
 47299 0000CA71 A1[34830100]        <1> 	mov	eax, [FAT_anc_FFCluster]
 47300 0000CA76 31C9                <1> 	xor	ecx, ecx
 47301 0000CA78 890D[5E7F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
 47302 0000CA7E 49                  <1> 	dec	ecx ; 0FFFFFFFFh
 47303 0000CA7F E8F5F9FFFF          <1> 	call	update_cluster
 47304 0000CA84 7304                <1> 	jnc	short loc_add_new_cluster_update_fat_plc
 47305 0000CA86 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 47306 0000CA88 75A1                <1> 	jnz	short loc_add_new_cluster_stc_retn
 47307                              <1> 
 47308                              <1> loc_add_new_cluster_update_fat_plc:
 47309 0000CA8A A1[30830100]        <1> 	mov	eax, [FAT_anc_LCluster]
 47310 0000CA8F 8B0D[34830100]      <1> 	mov	ecx, [FAT_anc_FFCluster]
 47311 0000CA95 E8DFF9FFFF          <1> 	call	update_cluster
 47312 0000CA9A 7314                <1> 	jnc	short loc_add_new_cluster_save_fat_buffer
 47313 0000CA9C 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
 47314 0000CA9E 7410                <1> 	jz	short loc_add_new_cluster_save_fat_buffer
 47315                              <1> 
 47316                              <1> loc_anc_save_fat_buffer_err_retn:
 47317                              <1> 	;cmp	byte [FAT_ClusterCounter], 1
 47318                              <1> 	;jb	short loc_add_new_cluster_retn
 47319                              <1> 
 47320 0000CAA0 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
 47321                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
 47322 0000CAA4 50                  <1> 	push	eax
 47323 0000CAA5 E8E3FCFFFF          <1> 	call	calculate_fat_freespace
 47324 0000CAAA 58                  <1> 	pop	eax
 47325 0000CAAB E97BFFFFFF          <1>         jmp     loc_add_new_cluster_stc_retn
 47326                              <1> 
 47327                              <1> loc_add_new_cluster_save_fat_buffer:
 47328                              <1> 	;cmp	byte [FAT_BuffValidData], 2
 47329                              <1> 	;jne	short loc_add_new_cluster_calc_FAT_freespace 
 47330                              <1> 	;Byte [FAT_BuffValidData] = 2 
 47331 0000CAB0 E847FCFFFF          <1> 	call	save_fat_buffer
 47332 0000CAB5 72E9                <1> 	jc	short loc_anc_save_fat_buffer_err_retn
 47333                              <1> 
 47334                              <1> loc_add_new_cluster_calc_FAT_freespace:
 47335                              <1> 	;mov	eax, 1 ; Only one Cluster
 47336 0000CAB7 A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 47337 0000CABC 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI -> Dos drv desc. table
 47338                              <1> 		; BL = 1 -> add cluster(s)
 47339 0000CAC0 B301                <1> 	mov	bl, 01h
 47340                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
 47341                              <1> 	; (Free Cluster Count is decreased when EAX value is negative)
 47342 0000CAC2 E8C6FCFFFF          <1>         call    calculate_fat_freespace
 47343                              <1> 	; ECX = 0 -> no error, ECX > 0 -> error or invalid return
 47344 0000CAC7 21C9                <1> 	and	ecx, ecx ; ECX = 0 -> valid free sector count
 47345 0000CAC9 7409                <1> 	jz	short loc_add_new_cluster_return_cluster_number
 47346                              <1> 
 47347                              <1> loc_add_new_cluster_recalc_FAT_freespace:
 47348 0000CACB 66BB00FF            <1> 	mov	bx, 0FF00h  ; recalculate free space
 47349 0000CACF E8B9FCFFFF          <1>         call    calculate_fat_freespace
 47350                              <1> 	; cf = 0
 47351                              <1> loc_add_new_cluster_return_cluster_number:
 47352 0000CAD4 89C1                <1> 	mov	ecx, eax ; Free sector count
 47353 0000CAD6 A1[34830100]        <1> 	mov	eax, [FAT_anc_FFCluster]
 47354                              <1> 	;mov	edi, Cluster_Buffer
 47355                              <1> 	; 25/07/2022 (EBX is not used by callers of this sprocedure)
 47356                              <1> 	;movzx	ebx, byte [esi+LD_BPB+SecPerClust]
 47357 0000CADB 31D2                <1> 	xor	edx, edx ; 0
 47358 0000CADD C3                  <1>         retn
 47359                              <1> 
 47360                              <1> write_cluster:
 47361                              <1> 	; 15/10/2016
 47362                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
 47363                              <1> 	;
 47364                              <1> 	; INPUT ->
 47365                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
 47366                              <1> 	;	ESI = Logical DOS Drive Description Table address
 47367                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
 47368                              <1> 	;	Only for SINGLIX FS:
 47369                              <1> 	;	EDX = File Number (The 1st FDT address) 
 47370                              <1> 	; OUTPUT ->
 47371                              <1> 	;	cf = 1 -> Cluster can not be written onto disk
 47372                              <1> 	;	    EAX > 0 -> Error number
 47373                              <1> 	;	cf = 0 -> Cluster has been written successfully
 47374                              <1> 	;
 47375                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
 47376                              <1> 	
 47377 0000CADE 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
 47378                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
 47379                              <1> 
 47380                              <1> write_file_sectors: ; 16/03/2016
 47381 0000CAE2 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 47382 0000CAE6 761C                <1> 	jna	short write_fs_cluster
 47383                              <1> 
 47384                              <1> write_fat_file_sectors: 
 47385 0000CAE8 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
 47386 0000CAEB 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
 47387 0000CAEF F7E2                <1> 	mul	edx
 47388 0000CAF1 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
 47389                              <1> 
 47390                              <1> 	; EAX = Disk sector address
 47391                              <1> 	; ECX = Sector count
 47392                              <1> 	; EBX = Buffer address
 47393                              <1> 	; (EDX = 0)
 47394                              <1> 	; ESI = Logical DOS drive description table address	
 47395                              <1> 
 47396 0000CAF4 E821520000          <1> 	call	disk_write
 47397 0000CAF9 7306                <1> 	jnc	short wclust_retn
 47398                              <1> 	
 47399                              <1> 	; 15/10/2016 (1Dh -> 18)
 47400 0000CAFB B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
 47401 0000CB00 C3                  <1> 	retn
 47402                              <1> 
 47403                              <1> wclust_retn:
 47404 0000CB01 29C0                <1> 	sub	eax, eax ; 0
 47405 0000CB03 C3                  <1> 	retn
 47406                              <1> 
 47407                              <1> write_fs_cluster:
 47408                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 47409                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
 47410                              <1> 	; Singlix FS
 47411                              <1> 	
 47412                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
 47413                              <1> 	
 47414                              <1> 	; EDX = File number is the first File Descriptor Table address 
 47415                              <1> 	;	of the file. (Absolute address of the FDT).
 47416                              <1> 	
 47417                              <1> 	; eax = sector index (0 for the first sector)
 47418                              <1> 	; edx = FDT0 address
 47419                              <1> 		; 64 KB buffer = 128 sectors (limit) 
 47420                              <1> 	;mov	ecx, 128 ; maximum count of sectors (before eof) 
 47421                              <1> 	; 25/07/2022
 47422 0000CB04 29C9                <1> 	sub	ecx, ecx
 47423 0000CB06 B180                <1> 	mov	cl, 128
 47424                              <1> 	;call	write_fs_sectors
 47425                              <1> 	;retn
 47426                              <1> 	;jmp	short write_fs_sectors
 47427                              <1> 
 47428                              <1> write_fs_sectors:
 47429                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
 47430 0000CB08 F9                  <1> 	stc
 47431 0000CB09 C3                  <1> 	retn
 47432                              <1> 
 47433                              <1> get_cluster_by_index:
 47434                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 47435                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 47436                              <1> 	; INPUT ->
 47437                              <1> 	; 	EAX = Beginning cluster
 47438                              <1> 	; 	EDX = Sector index in disk/file section
 47439                              <1> 	;	      (Only for SINGLIX file system!)
 47440                              <1> 	; 	ECX = Cluster sequence number after the beginning cluster
 47441                              <1> 	; 	ESI = Logical DOS Drive Description Table address
 47442                              <1> 	; OUTPUT ->
 47443                              <1> 	;	EAX = Cluster number 
 47444                              <1> 	;	cf = 1 -> Error code in AL (EAX)
 47445                              <1> 	;
 47446                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
 47447                              <1> 	;	
 47448 0000CB0A 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
 47449 0000CB0E 721D                <1>         jb      short get_fs_section_by_index 
 47450                              <1> 
 47451 0000CB10 3B4E78              <1> 	cmp	ecx, [esi+LD_Clusters]
 47452 0000CB13 7206                <1> 	jb	short gcbi_1
 47453                              <1> gcbi_0:
 47454                              <1> 	;stc
 47455                              <1> 	;mov	eax, 23h ; Cluster not available ! 
 47456                              <1> 			 ; MSDOS error code: FCB unavailable
 47457                              <1> 	; 25/07/2022
 47458 0000CB15 29C0                <1> 	sub	eax, eax
 47459                              <1> gcbi_4:
 47460 0000CB17 B023                <1> 	mov	al, 23h
 47461 0000CB19 F9                  <1> 	stc
 47462 0000CB1A C3                  <1> 	retn
 47463                              <1> gcbi_1:
 47464 0000CB1B 51                  <1> 	push	ecx
 47465 0000CB1C E869F6FFFF          <1> 	call	get_next_cluster
 47466 0000CB21 59                  <1> 	pop	ecx
 47467 0000CB22 7203                <1> 	jc	short gcbi_3
 47468 0000CB24 E2F5                <1> 	loop	gcbi_1
 47469                              <1> gcbi_2:
 47470 0000CB26 C3                  <1> 	retn
 47471                              <1> gcbi_3:
 47472 0000CB27 09C0                <1> 	or	eax, eax
 47473                              <1> 	;jz	short gcbi_0
 47474                              <1> 	; 25/07/2022
 47475 0000CB29 74EC                <1> 	jz	short gcbi_4
 47476 0000CB2B F5                  <1> 	cmc 	; stc
 47477 0000CB2C C3                  <1> 	retn
 47478                              <1> 
 47479                              <1> get_fs_section_by_index:
 47480                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 47481                              <1> 	; INPUT ->
 47482                              <1> 	; 	EAX = Beginning FDT number/address
 47483                              <1> 	; 	EDX = Sector index in disk/file section
 47484                              <1> 	; 	ECX = Sector sequence number after the beginning FDT
 47485                              <1> 	; 	ESI = Logical DOS Drive Description Table address
 47486                              <1> 	; OUTPUT ->
 47487                              <1> 	; 	EAX = FDT number/address
 47488                              <1> 	; 	EDX = Sector index of the section (0,1,2,3,4...)
 47489                              <1> 	;	cf = 1 -> Error code in AL (EAX)
 47490                              <1> 	;
 47491                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
 47492                              <1> 	;
 47493 0000CB2D B8FFFFFFFF          <1> 	mov	eax, 0FFFFFFFFh
 47494 0000CB32 C3                  <1> 	retn
 47495                              <1> 
 47496                              <1> get_last_section:
 47497                              <1> 	; 22/10/2016 (TRDOS 386 = TRDOS v2.0)	
 47498                              <1> 	; INPUT ->
 47499                              <1> 	; 	EAX = (The 1st) FDT number/address
 47500                              <1> 	; 	ESI = Logical DOS Drive Description Table address
 47501                              <1> 	; OUTPUT ->
 47502                              <1> 	; 	EAX = FDT number/address of the last section
 47503                              <1> 	; 	EDX = Last sector of the section (0,1,2,3,4...)
 47504                              <1> 	;	[glc_index] = sector index number of the last sector
 47505                              <1> 	;		      (for file, not for the last section)  	
 47506                              <1> 	;		   	
 47507                              <1> 	;	cf = 1 -> Error code in AL (EAX)
 47508                              <1> 	;
 47509                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
 47510                              <1> 	;
 47511 0000CB33 B800000000          <1> 	mov	eax, 0
 47512 0000CB38 BA00000000          <1> 	mov	edx, 0
 47513 0000CB3D C3                  <1> 	retn
 47514                                  %include 'trdosk6.s' ; 24/01/2016
 47515                              <1> ; ****************************************************************************
 47516                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - MAIN PROGRAM : trdosk6.s
 47517                              <1> ; ----------------------------------------------------------------------------
 47518                              <1> ; Last Update: 11/08/2022  (Previous: 17/04/2021)
 47519                              <1> ; ----------------------------------------------------------------------------
 47520                              <1> ; Beginning: 24/01/2016
 47521                              <1> ; ----------------------------------------------------------------------------
 47522                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 47523                              <1> ; ----------------------------------------------------------------------------
 47524                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 47525                              <1> ; u1.s (27/17/2015), u2.s (03/01/2016)
 47526                              <1> ; ****************************************************************************
 47527                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 47528                              <1> ; TRDOS2.ASM (09/11/2011)
 47529                              <1> ; ----------------------------------------------------------------------------
 47530                              <1> ; INT_21H.ASM (c) 2009-2011 Erdogan TAN  [14/11/2009] Last Update: 08/11/2011
 47531                              <1> 
 47532                              <1> ; Ref: Retro UNIX 386 v1.2 Kernel (v0.2.2.3) - ux.s - 15/07/2022
 47533                              <1> 
 47534                              <1> sysent: ; < enter to system call >
 47535                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 47536                              <1> 	; 17/03/2017
 47537                              <1> 	; 03/03/2017
 47538                              <1> 	; 19/02/2017
 47539                              <1> 	; 13/01/2017
 47540                              <1> 	; 06/06/2016
 47541                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 47542                              <1> 	; 16/04/2015 - 19/10/2015 (Retro UNIX 386 v1)
 47543                              <1> 	; 10/04/2013 - 18/01/2014 (Retro UNIX 8086 v1)
 47544                              <1> 	;
 47545                              <1> 	; 'unkni' or 'sysent' is sytem entry from various traps. 
 47546                              <1> 	; The trap type is determined and an indirect jump is made to 
 47547                              <1> 	; the appropriate system call handler. If there is a trap inside
 47548                              <1> 	; the system a jump to panic is made. All user registers are saved 
 47549                              <1> 	; and u.sp points to the end of the users stack. The sys (trap)
 47550                              <1> 	; instructor is decoded to get the the system code part (see
 47551                              <1> 	; trap instruction in the PDP-11 handbook) and from this 
 47552                              <1> 	; the indirect jump address is calculated. If a bad system call is
 47553                              <1> 	; made, i.e., the limits of the jump table are exceeded, 'badsys'
 47554                              <1> 	; is called. If the call is legitimate control passes to the
 47555                              <1> 	; appropriate system routine.
 47556                              <1> 	;
 47557                              <1> 	; Calling sequence:
 47558                              <1> 	;	Through a trap caused by any sys call outside the system.
 47559                              <1> 	; Arguments:
 47560                              <1> 	;	Arguments of particular system call.	
 47561                              <1> 	; ...............................................................
 47562                              <1> 	;	
 47563                              <1> 	; Retro UNIX 8086 v1 modification: 
 47564                              <1> 	;       System call number is in EAX register.
 47565                              <1> 	;
 47566                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
 47567                              <1> 	;	registers depending of function details.
 47568                              <1>   	;
 47569                              <1> 	; 16/04/2015
 47570 0000CB3E 368925[14010300]    <1>         mov     [ss:u.sp], esp ; Kernel stack points to return address
 47571                              <1> 
 47572                              <1> 	; save user registers
 47573 0000CB45 1E                  <1> 	push	ds
 47574 0000CB46 06                  <1> 	push	es
 47575 0000CB47 0FA0                <1> 	push	fs
 47576 0000CB49 0FA8                <1> 	push	gs
 47577 0000CB4B 60                  <1> 	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
 47578                              <1> 	;
 47579                              <1> 	; ESPACE = [ss:u.sp] - esp ; 4*12 = 48 ; 17/09/2015 ; 06/06/2016
 47580                              <1> 	; 	(ESPACE is size of space in kernel stack 
 47581                              <1> 	;	for saving/restoring user registers.)
 47582                              <1> 	;
 47583 0000CB4C 50                  <1> 	push	eax ; 01/07/2015
 47584 0000CB4D 66B81000            <1> 	mov     ax, KDATA
 47585 0000CB51 8ED8                <1>         mov     ds, ax
 47586 0000CB53 8EC0                <1>         mov     es, ax
 47587 0000CB55 8EE0                <1>         mov     fs, ax
 47588 0000CB57 8EE8                <1>         mov     gs, ax
 47589 0000CB59 A1[80770100]        <1> 	mov	eax, [k_page_dir]
 47590 0000CB5E 0F22D8              <1> 	mov	cr3, eax
 47591 0000CB61 58                  <1> 	pop	eax ; 01/07/2015
 47592                              <1> 	; 19/10/2015
 47593 0000CB62 FC                  <1> 	cld
 47594                              <1> 	;
 47595 0000CB63 FE05[10010300]      <1> 	inc	byte [sysflg]
 47596                              <1> 		; incb sysflg / indicate a system routine is in progress
 47597 0000CB69 FB                  <1>         sti 	; 18/01/2014
 47598                              <1> 	;jnz	panic ; 24/05/2013
 47599                              <1> 		; beq 1f
 47600                              <1> 		; jmp panic ; / called if trap inside system
 47601                              <1> 	; 23/07/2022
 47602 0000CB6A 7405                <1> 	jz	short sysent0
 47603 0000CB6C E918A1FFFF          <1> 	jmp	panic
 47604                              <1> ;1:
 47605                              <1> sysent0:
 47606                              <1> 	; 17/03/2017
 47607 0000CB71 80642438FE          <1> 	and	byte [esp+ESPACE+8], ~1 ; clear carry flag
 47608                              <1> 
 47609                              <1> 	; 16/04/2015
 47610 0000CB76 A3[1C010300]        <1> 	mov	[u.r0], eax
 47611 0000CB7B 8925[18010300]      <1> 	mov	[u.usp], esp ; kernel stack points to user's registers
 47612                              <1> 
 47613                              <1> 	; 13/01/2017 (TRDOS 386 Feaure only !)
 47614 0000CB81 803D[90010300]00    <1> 	cmp	byte [u.t_lock], 0 ; timer interrupt lock ?
 47615                              <1> 	;ja	sysrele		   ; yes, sys release only !!!
 47616                              <1> 	; 23/07/2022
 47617 0000CB88 7605                <1> 	jna	short sysent1
 47618 0000CB8A E9FE010000          <1> 	jmp	sysrele
 47619                              <1> 		; mov $s.syst+2,clockp
 47620                              <1> 		; mov r0,-(sp) / save user registers 
 47621                              <1> 		; mov sp,u.r0 / pointer to bottom of users stack 
 47622                              <1> 			   ; / in u.r0
 47623                              <1> 		; mov r1,-(sp)
 47624                              <1> 		; mov r2,-(sp)
 47625                              <1> 		; mov r3,-(sp)
 47626                              <1> 		; mov r4,-(sp)
 47627                              <1> 		; mov r5,-(sp)
 47628                              <1> 		; mov ac,-(sp) / "accumulator" register for extended
 47629                              <1> 		             ; / arithmetic unit
 47630                              <1> 		; mov mq,-(sp) / "multiplier quotient" register for the
 47631                              <1> 		             ; / extended arithmetic unit
 47632                              <1> 		; mov sc,-(sp) / "step count" register for the extended
 47633                              <1> 		             ; / arithmetic unit
 47634                              <1> 		; mov sp,u.sp / u.sp points to top of users stack
 47635                              <1> 		; mov 18.(sp),r0 / store pc in r0
 47636                              <1> 		; mov -(r0),r0 / sys inst in r0      10400xxx
 47637                              <1> 		; sub $sys,r0 / get xxx code
 47638                              <1> sysent1:
 47639 0000CB8F C1E002              <1> 	shl	eax, 2
 47640                              <1> 		; asl r0 / multiply by 2 to jump indirect in bytes
 47641 0000CB92 3DB8000000          <1> 	cmp	eax, end_of_syscalls - syscalls
 47642                              <1> 		; cmp r0,$2f-1f / limit of table (35) exceeded
 47643                              <1> 	;jnb	short badsys
 47644                              <1> 		; bhis badsys / yes, bad system call
 47645 0000CB97 F5                  <1> 	cmc
 47646 0000CB98 9C                  <1> 	pushf	
 47647 0000CB99 50                  <1> 	push	eax
 47648 0000CB9A 8B2D[14010300]      <1>  	mov 	ebp, [u.sp] ; Kernel stack at the beginning of sys call
 47649 0000CBA0 B0FE                <1> 	mov	al, 0FEh ; 11111110b
 47650 0000CBA2 1400                <1> 	adc	al, 0 ; al = al + cf
 47651 0000CBA4 204508              <1> 	and	[ebp+8], al ; flags (reset carry flag)
 47652                              <1> 		; bic $341,20.(sp) / set users processor priority to 0 
 47653                              <1> 				 ; / and clear carry bit
 47654 0000CBA7 5D                  <1> 	pop	ebp ; eax
 47655 0000CBA8 9D                  <1> 	popf
 47656 0000CBA9 720B                <1>         jc      short badsys ; 23/07/2022
 47657 0000CBAB A1[1C010300]        <1> 	mov	eax, [u.r0]
 47658                              <1> 	; system call registers: EAX, EDX, ECX, EBX, ESI, EDI
 47659 0000CBB0 FFA5[03CC0000]      <1> 	jmp	dword [ebp+syscalls]
 47660                              <1> 		; jmp *1f(r0) / jump indirect thru table of addresses
 47661                              <1> 		            ; / to proper system routine.
 47662                              <1> 	; 30/07/2022
 47663                              <1> 	; 23/07/2022
 47664                              <1> badsys:
 47665                              <1> 	; 25/12/2016
 47666                              <1> 	; 18/04/2016 (TRDOS 386 = TRDOS v2.0)
 47667                              <1> 	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
 47668                              <1> 	; 03/02/2011 ('trdos_ifc_routine')
 47669                              <1> 	;
 47670                              <1> 	; 16/04/2015 (Retro UNIX 386 v1, 'badsys')
 47671                              <1> 	; (EIP, EAX values will be shown on screen with error message)
 47672                              <1> 	; (EIP = 'CD 40h' instruction address -INT 40h-)
 47673                              <1> 	; (EAX = Function number)  
 47674                              <1> 	;
 47675 0000CBB6 FE05[6C010300]      <1> 	inc	byte [u.bsys]
 47676                              <1> 	;
 47677 0000CBBC 8B1D[14010300]      <1> 	mov	ebx, [u.sp] ; esp at the beginning of 'sysent'
 47678 0000CBC2 8B03                <1> 	mov	eax, [ebx] ; EIP (return address, not 'INT 30h' address)
 47679                              <1> 	;sub	eax, 2 ; CDh, ##h
 47680                              <1> 	; 30/07/2022
 47681 0000CBC4 48                  <1> 	dec	eax
 47682 0000CBC5 48                  <1> 	dec	eax
 47683 0000CBC6 E86E75FFFF          <1> 	call	dwordtohex
 47684 0000CBCB 8915[7D370100]      <1> 	mov	[eip_str], edx
 47685 0000CBD1 A3[81370100]        <1> 	mov	[eip_str+4], eax
 47686 0000CBD6 A1[1C010300]        <1> 	mov	eax, [u.r0]
 47687 0000CBDB E85975FFFF          <1> 	call	dwordtohex
 47688 0000CBE0 8915[6C370100]      <1> 	mov	[eax_str], edx
 47689 0000CBE6 A3[70370100]        <1> 	mov	[eax_str+4], eax
 47690                              <1> 
 47691 0000CBEB 66C705[61370100]34- <1> 	mov	word [int_num_str], SYSCALL_INT_NUM ; 25/12/2016
 47692 0000CBF3 30                  <1>
 47693                              <1> 
 47694 0000CBF4 BE[33370100]        <1> 	mov	esi, ifc_msg ; "invalid funtion call !" msg (trdosk9.s)
 47695 0000CBF9 E82CA0FFFF          <1> 	call	print_msg
 47696                              <1> 
 47697 0000CBFE E92C020000          <1> 	jmp	sysexit
 47698                              <1> 
 47699                              <1> syscalls: ; 1:
 47700                              <1> 	; 31/12/2017
 47701                              <1> 	; 28/02/2017
 47702                              <1> 	; 20/02/2017
 47703                              <1> 	; 19/02/2017
 47704                              <1> 	; 15/10/2016
 47705                              <1> 	; 20/05/2016
 47706                              <1> 	; 19/05/2016
 47707                              <1> 	; 16/05/2016
 47708                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 47709                              <1> 	; 21/09/2015
 47710                              <1> 	; 01/07/2015
 47711                              <1> 	; 16/04/2015 (32 bit address modification) 
 47712 0000CC03 [790C0100]          <1> 	dd sysver	; 0 ; Get TRDOS 386 version number (v2.0)	
 47713 0000CC07 [2FCE0000]          <1> 	dd sysexit 	; 1
 47714 0000CC0B [FCCF0000]          <1> 	dd sysfork 	; 2
 47715 0000CC0F [89D30000]          <1> 	dd sysread 	; 3
 47716 0000CC13 [A8D30000]          <1> 	dd syswrite 	; 4
 47717 0000CC17 [D7D10000]          <1> 	dd sysopen 	; 5
 47718 0000CC1B [5FD30000]          <1> 	dd sysclose 	; 6
 47719 0000CC1F [84CF0000]          <1> 	dd syswait 	; 7
 47720 0000CC23 [04D10000]          <1> 	dd syscreat 	; 8
 47721 0000CC27 [851A0100]          <1> 	dd sysrename	; 9  ; TRDOS 386, Rename File (31/12/2017)
 47722 0000CC2B [18160100]          <1> 	dd sysdelete	; 10 ; TRDOS 386, Delete File (29/12/2017)
 47723 0000CC2F [C6000100]          <1> 	dd sysexec 	; 11
 47724 0000CC33 [34170100]          <1> 	dd syschdir 	; 12
 47725 0000CC37 [EF180100]          <1> 	dd systime 	; 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
 47726 0000CC3B [22D30000]          <1> 	dd sysmkdir 	; 14
 47727 0000CC3F [68170100]          <1> 	dd syschmod 	; 15 ; TRDOS 386, Change Attributes (30/12/2017) 
 47728 0000CC43 [7F160100]          <1> 	dd sysrmdir 	; 16 ; TRDOS 386, Remove Directory (29/12/2017)
 47729 0000CC47 [62050100]          <1> 	dd sysbreak 	; 17
 47730 0000CC4B [44180100]          <1> 	dd sysdrive 	; 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
 47731 0000CC4F [A3050100]          <1> 	dd sysseek 	; 19
 47732 0000CC53 [B5050100]          <1> 	dd systell 	; 20
 47733 0000CC57 [9B1B0100]          <1> 	dd sysmem 	; 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
 47734 0000CC5B [D11B0100]          <1> 	dd sysprompt 	; 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
 47735 0000CC5F [121C0100]          <1> 	dd syspath 	; 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
 47736 0000CC63 [771C0100]          <1> 	dd sysenv 	; 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
 47737 0000CC67 [70190100]          <1> 	dd sysstime 	; 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
 47738 0000CC6B [1B060100]          <1> 	dd sysquit 	; 26
 47739 0000CC6F [0F060100]          <1> 	dd sysintr 	; 27
 47740 0000CC73 [93180100]          <1> 	dd sysdir 	; 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
 47741 0000CC77 [BBCC0000]          <1> 	dd sysemt 	; 29
 47742 0000CC7B [CE180100]          <1> 	dd sysldrvt	; 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
 47743 0000CC7F [9AD50000]          <1> 	dd sysvideo 	; 31 ; TRDOS 386 Video Functions (16/05/2016)
 47744 0000CC83 [CD240100]          <1> 	dd sysaudio 	; 32 ; TRDOS 386 Audio Functions (16/05/2016)
 47745 0000CC87 [05D40000]          <1> 	dd systimer 	; 33 ; TRDOS 386 Timer Functions (18/05/2016)
 47746 0000CC8B [27060100]          <1> 	dd syssleep 	; 34 ; Retro UNIX 8086 v1 feature only !
 47747                              <1> 			     ; 11/06/2014
 47748 0000CC8F [61060100]          <1> 	dd sysmsg	; 35 ; Retro UNIX 386 v1 feature only !
 47749                              <1> 			     ; 01/07/2015
 47750 0000CC93 [7B070100]          <1> 	dd sysgeterr	; 36 ; Retro UNIX 386 v1 feature only !
 47751                              <1> 			     ; 21/09/2015 - get last error number
 47752 0000CC97 [EF150100]          <1> 	dd sysfpstat	; 37 ; TRDOS 386 FPU state option (28/02/2017)
 47753 0000CC9B [880C0100]          <1> 	dd syspri 	; 38 ; change priority - TRDOS 386 (20/05/2016)
 47754 0000CC9F [8DCD0000]          <1> 	dd sysrele	; 39 ; TRDOS 386 (19/05/2016) (0 -> 39)
 47755 0000CCA3 [B30D0100]          <1> 	dd sysfff	; 40 ; Find First File - TRDOS 386 (15/10/2016)
 47756 0000CCA7 [870E0100]          <1> 	dd sysfnf	; 41 ; Find Next File - TRDOS 386 (15/10/2016)
 47757 0000CCAB [DD140100]          <1> 	dd sysalloc	; 42 ; Allocate contiguous memory block/pages
 47758                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions		
 47759 0000CCAF [97150100]          <1> 	dd sysdalloc	; 43 ; Deallocate contiguous memory block/pages
 47760                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions
 47761 0000CCB3 [D2150100]          <1> 	dd syscalbac	; 44 ; IRQ Callback and Signal Response Byte
 47762                              <1> 			     ; service setup - TRDOS 386 (20/02/2017)
 47763                              <1> 			     ; 28/08/2017 (20/08/2017)	
 47764 0000CCB7 [2A2D0100]          <1> 	dd sysdma	; 45 ; TRDOS 386 - (ISA) DMA service
 47765                              <1> 	
 47766                              <1> end_of_syscalls:
 47767                              <1> 
 47768                              <1> sysemt: ; enable (or disable) multi tasking -time sharing-
 47769                              <1> 	;
 47770                              <1> 	; 08/08/2022
 47771                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 47772                              <1> 	; 23/05/2016 - TRDOS 386 (TRDOS v2.0)
 47773                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
 47774                              <1> 	; 10/12/2013 - 20/04/2014 (Retro UNIX 8086 v1)
 47775                              <1> 	;
 47776                              <1> 	; Retro UNIX 8086 v1 modification: 
 47777                              <1> 	;	'Enable Multi Tasking'  system call instead 
 47778                              <1> 	;	of 'Emulator Trap' in original UNIX v1 for PDP-11.
 47779                              <1> 	;
 47780                              <1> 	; Retro UNIX 8086 v1 feature only!
 47781                              <1> 	;	Using purpose: Kernel will start without time-out
 47782                              <1> 	;	(internal clock/timer) functionality.
 47783                              <1> 	;	Then etc/init will enable clock/timer for
 47784                              <1> 	;	multi tasking. 
 47785                              <1> 	;
 47786                              <1> 	; INPUT ->
 47787                              <1> 	;	BL = 0 -> disable multi tasking
 47788                              <1> 	;	BL > 1 -> enable multi tasking (time sharing) 
 47789                              <1> 	; OUTPUT ->
 47790                              <1> 	;	none	
 47791                              <1> 	;
 47792                              <1> 	;  Note: Multi tasking is disabled during system
 47793                              <1> 	;	 initialization, it must be enabled by using
 47794                              <1> 	;	 this system call. (Otherwise, running proces 
 47795                              <1> 	;	 will not be changed by another process within
 47796                              <1> 	;	 run time sequence/schedule, if running process
 47797                              <1> 	;	 will not 'release' itself. Only 'wakeup' procedure
 47798                              <1> 	;	 for waiting processes and programmed timer events
 47799                              <1> 	;	 for other processes can change running process 
 47800                              <1> 	;	 while multi tasking is disabled.) ** 23/05/2016 **
 47801                              <1> 
 47802 0000CCBB 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0 ; root ?
 47803                              <1> 	;ja	short error
 47804                              <1> 	; 23/07/2022
 47805                              <1> 	;ja	short badsys ; 14/05/2015
 47806                              <1> 	; 08/08/2022
 47807 0000CCC2 7605                <1> 	jna	short sysemt_root
 47808 0000CCC4 E9EDFEFFFF          <1> 	jmp	badsys
 47809                              <1> sysemt_root:	; 08/08/2022
 47810 0000CCC9 FA                  <1> 	cli
 47811 0000CCCA 881D[0E840100]      <1> 	mov	[multi_tasking], bl ; 0 to disable, >0 to enable
 47812 0000CCD0 EB20                <1> 	jmp	sysret
 47813                              <1> 
 47814                              <1> error:
 47815                              <1> 	; 18/05/2016
 47816                              <1> 	; 13/05/2016
 47817                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 47818                              <1> 	; 16/04/2015 - 17/09/2015 (Retro UNIX 386 v1)
 47819                              <1> 	; 10/04/2013 - 07/08/2013 (Retro UNIX 8086 v1)
 47820                              <1> 	;
 47821                              <1> 	; 'error' merely sets the error bit off the processor status (c-bit)
 47822                              <1> 	; then falls right into the 'sysret', 'sysrele' return sequence.
 47823                              <1> 	;
 47824                              <1> 	; INPUTS -> none
 47825                              <1> 	; OUTPUTS ->
 47826                              <1> 	;	processor status - carry (c) bit is set (means error)
 47827                              <1> 	;
 47828                              <1> 	; 26/05/2013 (Stack pointer must be reset here! 
 47829                              <1> 	; 	      Because, jumps to error procedure
 47830                              <1> 	;	      disrupts push-pop nesting balance)
 47831                              <1> 	;
 47832 0000CCD2 8B2D[14010300]      <1> 	mov	ebp, [u.sp] ; interrupt (system call) return (iretd) address
 47833 0000CCD8 804D0801            <1> 	or	byte [ebp+8], 1  ; set carry bit of flags register
 47834                              <1> 				 ; (system call will return with cf = 1)
 47835                              <1> 		; bis $1,20.(r1) / set c bit in processor status word below
 47836                              <1> 		               ; / users stack
 47837                              <1> 	; 17/09/2015
 47838 0000CCDC 83ED30              <1> 	sub	ebp, ESPACE ; 48 ; total size of stack frame ('sysdefs.inc')
 47839                              <1> 				 ; for saving/restoring user registers	
 47840                              <1> 	;cmp	ebp, [u.usp]
 47841                              <1> 	;je	short err0	
 47842 0000CCDF 892D[18010300]      <1> 	mov	[u.usp], ebp
 47843                              <1> ;err0:
 47844                              <1> 	; 01/09/2015
 47845 0000CCE5 8B25[18010300]      <1> 	mov	esp, [u.usp] 	    ; Retro Unix 8086 v1 modification!
 47846                              <1> 				    ; 10/04/2013
 47847                              <1> 				    ; (If an I/O error occurs during disk I/O,
 47848                              <1> 				    ; related procedures will jump to 'error'
 47849                              <1> 				    ; procedure directly without returning to 
 47850                              <1> 				    ; the caller procedure. So, stack pointer
 47851                              <1>                                     ; must be restored here.)
 47852                              <1> 	; 13/05/2016
 47853                              <1> 	; NOTE: (The last) error code is in 'u.error', it can be retrieved by
 47854                              <1> 	;	'get last error' system call later. 	
 47855                              <1> 
 47856                              <1> 	; 03/09/2015 - 09/06/2015 - 07/08/2013
 47857 0000CCEB C605[82010300]00    <1> 	mov 	byte [u.kcall], 0 ; namei_r, mkdir_w reset
 47858                              <1> 
 47859                              <1> sysret: ; < return from system call>
 47860                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 47861                              <1> 	; 01/03/2017
 47862                              <1> 	; 28/02/2017
 47863                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 47864                              <1> 	; 16/04/2015 - 10/09/2015 (Retro UNIX 386 v1)
 47865                              <1> 	; 10/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
 47866                              <1> 	;
 47867                              <1> 	; 'sysret' first checks to see if process is about to be 
 47868                              <1> 	; terminated (u.bsys). If it is, 'sysexit' is called.
 47869                              <1> 	; If not, following happens:	 
 47870                              <1> 	; 	1) The user's stack pointer is restored.
 47871                              <1> 	;	2) r1=0 and 'iget' is called to see if last mentioned
 47872                              <1> 	;	   i-node has been modified. If it has, it is written out
 47873                              <1> 	;	   via 'ppoke'.
 47874                              <1> 	;	3) If the super block has been modified, it is written out
 47875                              <1> 	;	   via 'ppoke'.				
 47876                              <1> 	;	4) If the dismountable file system's super block has been
 47877                              <1> 	;	   modified, it is written out to the specified device
 47878                              <1> 	;	   via 'ppoke'.
 47879                              <1> 	;	5) A check is made if user's time quantum (uquant) ran out
 47880                              <1> 	;	   during his execution. If so, 'tswap' is called to give
 47881                              <1> 	;	   another user a chance to run.
 47882                              <1> 	;	6) 'sysret' now goes into 'sysrele'. 
 47883                              <1> 	;	    (See 'sysrele' for conclusion.)		
 47884                              <1> 	;
 47885                              <1> 	; Calling sequence:
 47886                              <1> 	;	jump table or 'br sysret'
 47887                              <1> 	; Arguments: 
 47888                              <1> 	;	-	
 47889                              <1> 	; ...............................................................
 47890                              <1> 	;	
 47891                              <1> 	; ((AX=r1 for 'iget' input))
 47892                              <1> 	;	
 47893 0000CCF2 31C0                <1> 	xor	eax, eax ; 28/02/2017
 47894                              <1> sysret0: ; 29/07/2015 (eax = 0, jump from sysexec)
 47895 0000CCF4 FEC0                <1> 	inc	al ; 04/05/2013
 47896 0000CCF6 3805[6C010300]      <1> 	cmp	[u.bsys], al ; 1
 47897                              <1> 		; tstb u.bsys / is a process about to be terminated because
 47898                              <1>         ;jnb	sysexit ; 04/05/2013
 47899                              <1> 		; bne sysexit / of an error? yes, go to sysexit
 47900                              <1> 	; 23/07/2022
 47901 0000CCFC 7205                <1> 	jb	short sysret1
 47902 0000CCFE E92C010000          <1> 	jmp	sysexit
 47903                              <1> sysret1:	; 23/07/2022
 47904                              <1> 	;mov	esp, [u.usp] ; 24/05/2013 (that is not needed here)
 47905                              <1> 		; mov u.sp,sp / no point stack to users stack
 47906 0000CD03 FEC8                <1> 	dec 	al ; mov ax, 0
 47907                              <1> 		; clr r1 / zero r1 to check last mentioned i-node
 47908 0000CD05 E80F500000          <1> 	call	iget
 47909                              <1> 		; jsr r0,iget / if last mentioned i-node has been modified
 47910                              <1> 		            ; / it is written out
 47911                              <1> 	; 10/01/2017
 47912                              <1> 	; 09/01/2017
 47913                              <1> ;sysrele: ; < release >
 47914                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 47915                              <1> 	; 16/04/2015 - 14/10/2015 (Retro UNIX 386 v1)
 47916                              <1> 	; 10/04/2013 - 07/03/2014 (Retro UNIX 8086 v1)
 47917                              <1> 	;
 47918                              <1> 	; 'sysrele' first calls 'tswap' if the time quantum for a user is
 47919                              <1> 	;  zero (see 'sysret'). It then restores the user's registers and
 47920                              <1> 	; turns off the system flag. It then checked to see if there is
 47921                              <1> 	; an interrupt from the user by calling 'isintr'. If there is, 
 47922                              <1> 	; the output gets flashed (see isintr) and interrupt action is
 47923                              <1> 	; taken by a branch to 'intract'. If there is no interrupt from
 47924                              <1> 	; the user, a rti is made.
 47925                              <1> 	;
 47926                              <1> 	; Calling sequence:
 47927                              <1> 	;	Fall through a 'bne' in 'sysret' & ?
 47928                              <1> 	; Arguments:
 47929                              <1> 	;	-	
 47930                              <1> 	; ...............................................................
 47931                              <1> 	;	
 47932                              <1> 	; 23/02/2014 (swapret)
 47933                              <1> 	; 22/09/2013
 47934                              <1> sysrel0: ;1:
 47935 0000CD0A 803D[64010300]00    <1> 	cmp	byte [u.quant], 0 ; 16/05/2013
 47936                              <1> 		; tstb uquant / is the time quantum 0?
 47937 0000CD11 7705                <1>         ja      short swapret
 47938                              <1> 		; bne 1f / no, don't swap it out
 47939                              <1> sysrelease: ; 07/12/2013 (jump from 'clock')
 47940 0000CD13 E8293E0000          <1> 	call	tswap
 47941                              <1> 		; jsr r0,tswap / yes, swap it out
 47942                              <1> 	
 47943                              <1> ; Retro Unix 8086 v1 feature: return from 'swap' to 'swapret' address.
 47944                              <1> swapret: ;1:
 47945                              <1> 	; 10/09/2015
 47946                              <1> 	; 01/09/2015
 47947                              <1> 	; 14/05/2015
 47948                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit, pm modifications)
 47949                              <1> 	; 26/05/2013 (Retro UNIX 8086 v1)
 47950                              <1> 	; cli
 47951                              <1> 	; 24/07/2015
 47952                              <1> 	;
 47953                              <1> 	;; 'esp' must be already equal to '[u.usp]' here ! 
 47954                              <1> 	;; mov	esp, [u.usp]
 47955                              <1> 
 47956                              <1> 	; 22/09/2013
 47957 0000CD18 E8FC4F0000          <1> 	call	isintr
 47958                              <1> 	; 20/10/2013
 47959 0000CD1D 7405                <1> 	jz	short sysrel1
 47960 0000CD1F E8F4000000          <1> 	call	intract
 47961                              <1> 		; jsr r0,isintr / is there an interrupt from the user
 47962                              <1> 		;     br intract / yes, output gets flushed, take interrupt
 47963                              <1> 		               ; / action
 47964                              <1> sysrel1:
 47965 0000CD24 FA                  <1> 	cli	; 14/10/2015
 47966                              <1> sysrel2:
 47967                              <1> 	; 28/02/2017
 47968                              <1> 	; Check if there is a (delayed) callback for current user/process
 47969 0000CD25 A0[93010300]        <1> 	mov	al, [u.irqwait]
 47970 0000CD2A 240F                <1> 	and	al, 0Fh ; is there a waiting IRQ callback service ?
 47971 0000CD2C 7444                <1> 	jz	short sysrel8 ; no
 47972                              <1> 
 47973                              <1> 	; Set return to IRQ callback service and return from the service
 47974 0000CD2E 0FB6D8              <1> 	movzx	ebx, al
 47975 0000CD31 883D[93010300]      <1> 	mov 	[u.irqwait], bh ; 0 ; reset
 47976 0000CD37 8A9B[8A370100]      <1> 	mov	bl, [ebx+IRQenum] ; (available) IRQ index +1 (1 to 9)
 47977                              <1> 	; 01/03/2017
 47978 0000CD3D FECB                <1> 	dec	bl ; IRQ index number, 0 to 8
 47979 0000CD3F 7831                <1> 	js	short sysrel8 ; 0 -> FFh (not in use!?) 
 47980                              <1> 	;
 47981 0000CD41 A0[6D010300]        <1> 	mov 	al, [u.uno] ; current process (user) number 
 47982 0000CD46 3883[58890100]      <1> 	cmp	[ebx+IRQ.owner], al
 47983 0000CD4C 7524                <1> 	jne	short sysrel8 ; it is not the current user/process !?
 47984 0000CD4E F683[6A890100]01    <1> 	test	byte [ebx+IRQ.method], 1 ; callback ?
 47985 0000CD55 741B                <1> 	jz	short sysrel8 ; not a callback method !?
 47986                              <1> 
 47987 0000CD57 8B93[7C890100]      <1> 	mov	edx, [ebx+IRQ.addr] ; IRQ callback service address (virtual)
 47988 0000CD5D C605[94010300]01    <1> 	mov	byte [u.r_lock], 1 ; IRQ callback service in progress flag
 47989                              <1> 
 47990 0000CD64 E8803E0000          <1> 	call	wswap ; save user's registers & status 
 47991                              <1> 		      ;	(for return from IRQ callback service)
 47992                              <1> 
 47993 0000CD69 8B2D[14010300]      <1> 	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
 47994 0000CD6F 895500              <1> 	mov	[ebp], edx ; IRQ call back service address
 47995                              <1> sysrel8:
 47996 0000CD72 FE0D[10010300]      <1> 	dec	byte [sysflg]
 47997                              <1> 		; decb sysflg / turn system flag off
 47998                              <1> 	
 47999 0000CD78 A1[74010300]        <1> 	mov	eax, [u.pgdir]	
 48000 0000CD7D 0F22D8              <1> 	mov	cr3, eax  ; 1st PDE points to Kernel Page Table 0 (1st 4 MB)
 48001                              <1> 			  ; (others are different than kernel page tables) 
 48002                              <1> 	; 10/09/2015
 48003 0000CD80 61                  <1> 	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
 48004                              <1> 		; mov (sp)+,sc / restore user registers
 48005                              <1> 		; mov (sp)+,mq
 48006                              <1> 		; mov (sp)+,ac
 48007                              <1> 		; mov (sp)+,r5
 48008                              <1> 		; mov (sp)+,r4
 48009                              <1> 		; mov (sp)+,r3
 48010                              <1> 		; mov (sp)+,r2
 48011                              <1> 	;
 48012 0000CD81 A1[1C010300]        <1> 	mov	eax, [u.r0]  ; ((return value in EAX))
 48013 0000CD86 0FA9                <1> 	pop	gs
 48014 0000CD88 0FA1                <1> 	pop	fs
 48015 0000CD8A 07                  <1> 	pop	es
 48016 0000CD8B 1F                  <1> 	pop	ds
 48017                              <1> 	;or	word [esp+8], 200h ; 22/01/2017 ; force enabling interrupts
 48018 0000CD8C CF                  <1> 	iretd	
 48019                              <1> 		; rti / no, return from interrupt
 48020                              <1> 
 48021                              <1> sysrele:
 48022                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 48023                              <1> 	; 24/03/2017
 48024                              <1> 	; 28/02/2017
 48025                              <1> 	; 27/02/2017
 48026                              <1> 	; 29/01/2017
 48027                              <1> 	; 14/01/2017
 48028                              <1> 	; 13/01/2017
 48029                              <1> 	; 09/01/2017 - 10/01/2017 - 12/01/2017
 48030                              <1> 	; Major modification for TRDOS 386 (CallBack return)
 48031                              <1> 	;
 48032                              <1> 	; 'sysrele' system call restores previously saved
 48033                              <1> 	; registers and addresses of the process
 48034                              <1> 	; (Main purpose -in TRDOS 386- is to return from
 48035                              <1> 	; timer callback service routine in ring 3 -user mode-.)
 48036                              <1> 	;
 48037                              <1> 	; check if the process is in timer callback phase
 48038 0000CD8D 803D[90010300]00    <1> 	cmp	byte [u.t_lock], 0 ; TIMER INT LOCK
 48039                              <1> 	;je	short sysrel0 ; classic (Retro UNIX 386 type) sysrele
 48040 0000CD94 7735                <1> 	ja	short sysrel3
 48041                              <1> 	; 27/02/2017
 48042 0000CD96 803D[94010300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback lock	
 48043                              <1> 	;jna	sysrel0 ; classic sysrele ; 24/03/2017
 48044                              <1> 	; 23/07/2022
 48045 0000CD9D 7705                <1> 	ja	short sysrel9
 48046 0000CD9F E966FFFFFF          <1> 	jmp	sysrel0
 48047                              <1> sysrel9:	; 23/07/2022
 48048 0000CDA4 E859000000          <1> 	call	sysrel7
 48049 0000CDA9 803D[94010300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback service lock
 48050 0000CDB0 7628                <1> 	jna	short sysrel4
 48051 0000CDB2 C605[94010300]00    <1> 	mov	byte [u.r_lock], 0 ; reset
 48052                              <1> 	;mov	byte [u.irqwait], 0 ; reset ; 28/02/2017
 48053 0000CDB9 A0[95010300]        <1> 	mov	al, [u.r_mode]
 48054 0000CDBE 08C0                <1> 	or	al, al
 48055 0000CDC0 7518                <1> 	jnz	short sysrel4
 48056 0000CDC2 FEC8                <1> 	dec	al
 48057 0000CDC4 A2[95010300]        <1> 	mov	[u.r_mode], al ; 0FFh ; not necessary !?
 48058 0000CDC9 EB32                <1> 	jmp	short sysrel6		
 48059                              <1> sysrel3:
 48060                              <1> 	; 27/02/2017
 48061 0000CDCB E832000000          <1> 	call	sysrel7
 48062                              <1> 	; 14/01/2017
 48063 0000CDD0 28C0                <1> 	sub	al, al
 48064 0000CDD2 3805[90010300]      <1> 	cmp	[u.t_lock], al ; 0 ; TIMER INT LOCK
 48065 0000CDD8 770E                <1> 	ja	short sysrel5 ; yes
 48066                              <1> sysrel4:
 48067                              <1> 	; 29/01/2017
 48068 0000CDDA 8B44241C            <1> 	mov	eax, [esp+28] ; eax
 48069 0000CDDE A3[1C010300]        <1> 	mov	[u.r0], eax
 48070 0000CDE3 E93DFFFFFF          <1> 	jmp	sysrel2
 48071                              <1> sysrel5:
 48072 0000CDE8 A2[90010300]        <1> 	mov	[u.t_lock], al ; 0 ; reset
 48073 0000CDED A0[91010300]        <1> 	mov	al, [u.t_mode]
 48074 0000CDF2 20C0                <1> 	and	al, al
 48075                              <1> 	;jnz	short sysrel2 ; 0FFh ; user mode
 48076 0000CDF4 75E4                <1> 	jnz	short sysrel4 ; 29/01/2017
 48077 0000CDF6 FEC8                <1> 	dec	al
 48078 0000CDF8 A2[91010300]        <1> 	mov	[u.t_mode], al ; 0FFh ; not necessary !?
 48079                              <1> sysrel6:
 48080                              <1> 	; cpu will continue from the interrupted sytem call addr
 48081 0000CDFD 61                  <1> 	popad		; edi, esi, ebp, esp, ebx, edx, ecx, eax
 48082 0000CDFE 83C410              <1> 	add	esp, 16	; pass segment segisters: ds, es, fs, gs		
 48083 0000CE01 CF                  <1> 	iretd		; eip, cs, eflags
 48084                              <1> 
 48085                              <1> sysrel7:
 48086 0000CE02 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; current process number
 48087                              <1> 	;shl	bx, 2
 48088                              <1> 	; 23/07/2022
 48089 0000CE09 C1E302              <1> 	shl	ebx, 2
 48090                              <1> 	;cmp	[ebx+p.tcb-4], eax ; 0 ; is there callback address ?
 48091                              <1> 	;jna	short sysrel0 
 48092                              <1> 	; yes, reset callback address then restore process registers 
 48093                              <1> 	;mov	[ebx+p.tcb-4], eax ; 0 ; reset
 48094 0000CE0C 8B83[6C000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address
 48095 0000CE12 FA                  <1> 	cli	; disable interrupts till 'iretd'
 48096 0000CE13 E9093E0000          <1> 	jmp	rswap ; restore process 'u' structure
 48097                              <1>  
 48098                              <1> intract: ; / interrupt action
 48099                              <1> 	; 14/10/2015
 48100                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
 48101                              <1> 	; 09/05/2013 - 07/12/2013 (Retro UNIX 8086 v1)
 48102                              <1> 	;
 48103                              <1> 	; Retro UNIX 8086 v1 modification !
 48104                              <1> 	; (Process/task switching and quit routine by using
 48105                              <1> 	; Retro UNIX 8086 v1 keyboard interrupt output.))
 48106                              <1> 	;
 48107                              <1> 	; input -> 'u.quit'  (also value of 'u.intr' > 0)
 48108                              <1> 	; output -> If value of 'u.quit' = FFFFh ('ctrl+brk' sign)
 48109                              <1> 	;		'intract' will jump to 'sysexit'.
 48110                              <1> 	;	    Intract will return to the caller 
 48111                              <1> 	;		if value of 'u.quit' <> FFFFh. 	 
 48112                              <1> 	; 14/10/2015
 48113 0000CE18 FB                  <1> 	sti
 48114                              <1> 	; 07/12/2013	
 48115 0000CE19 66FF05[6A010300]    <1> 	inc 	word [u.quit]
 48116 0000CE20 7408                <1> 	jz	short intrct0 ; FFFFh -> 0
 48117 0000CE22 66FF0D[6A010300]    <1> 	dec	word [u.quit]
 48118                              <1> 	; 16/04/2015
 48119 0000CE29 C3                  <1> 	retn
 48120                              <1> intrct0:	
 48121 0000CE2A 58                  <1> 	pop	eax ; call intract -> retn
 48122                              <1> 	;
 48123 0000CE2B 31C0                <1> 	xor 	eax, eax
 48124 0000CE2D FEC0                <1> 	inc	al  ; mov ax, 1
 48125                              <1> ;;;
 48126                              <1> 	; UNIX v1 original 'intract' routine... 
 48127                              <1> 	; / interrupt action
 48128                              <1> 		;cmp *(sp),$rti / are you in a clock interrupt?
 48129                              <1> 		; bne 1f / no, 1f
 48130                              <1> 		; cmp (sp)+,(sp)+ / pop clock pointer
 48131                              <1> 	; 1: / now in user area
 48132                              <1> 		; mov r1,-(sp) / save r1
 48133                              <1> 		; mov u.ttyp,r1 
 48134                              <1> 			; / pointer to tty buffer in control-to r1
 48135                              <1> 		; cmpb 6(r1),$177
 48136                              <1> 			; / is the interrupt char equal to "del"
 48137                              <1> 		; beq 1f / yes, 1f
 48138                              <1> 		; clrb 6(r1) 
 48139                              <1> 		        ; / no, clear the byte 
 48140                              <1> 			; / (must be a quit character)
 48141                              <1> 		; mov (sp)+,r1 / restore r1
 48142                              <1> 		; clr u.quit / clear quit flag
 48143                              <1> 		; bis $20,2(sp) 
 48144                              <1> 		    	; / set trace for quit (sets t bit of 
 48145                              <1> 			; / ps-trace trap)
 48146                              <1> 		; rti   ;  / return from interrupt
 48147                              <1> 	; 1: / interrupt char = del
 48148                              <1> 		; clrb 6(r1) / clear the interrupt byte 
 48149                              <1> 			   ; / in the buffer
 48150                              <1> 		; mov (sp)+,r1 / restore r1
 48151                              <1> 		; cmp u.intr,$core / should control be 
 48152                              <1> 				; / transferred to loc core?
 48153                              <1> 		; blo 1f
 48154                              <1> 		; jmp *u.intr / user to do rti yes, 
 48155                              <1> 				; / transfer to loc core
 48156                              <1> 	; 1:
 48157                              <1> 		; sys 1 / exit
 48158                              <1> 
 48159                              <1> sysexit: ; <terminate process>
 48160                              <1> 	; 30/07/2022
 48161                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 48162                              <1> 	; 14/11/2017
 48163                              <1> 	; 27/05/2017
 48164                              <1> 	; 10/04/2017
 48165                              <1> 	; 26/02/2017 - 28/02/2017
 48166                              <1> 	; 02/01/2017 - 23/01/2017
 48167                              <1> 	; 06/06/2016 - 10/06/2016
 48168                              <1> 	; 19/05/2016 - 23/05/2016
 48169                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 48170                              <1> 	; 16/04/2015 - 01/09/2015 (Retro UNIX 386 v1)
 48171                              <1> 	; 19/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 48172                              <1> 	;
 48173                              <1> 	; 'sysexit' terminates a process. First each file that
 48174                              <1> 	; the process has opened is closed by 'flose'. The process
 48175                              <1> 	; status is then set to unused. The 'p.pid' table is then
 48176                              <1> 	; searched to find children of the dying process. If any of
 48177                              <1> 	; children are zombies (died by not waited for), they are
 48178                              <1> 	; set free. The 'p.pid' table is then searched to find the
 48179                              <1> 	; dying process's parent. When the parent is found, it is
 48180                              <1> 	; checked to see if it is free or it is a zombie. If it is
 48181                              <1> 	; one of these, the dying process just dies. If it is waiting
 48182                              <1> 	; for a child process to die, it notified that it doesn't 
 48183                              <1> 	; have to wait anymore by setting it's status from 2 to 1
 48184                              <1> 	; (waiting to active). It is awakened and put on runq by
 48185                              <1> 	; 'putlu'. The dying process enters a zombie state in which
 48186                              <1> 	; it will never be run again but stays around until a 'wait'
 48187                              <1> 	; is completed by it's parent process. If the parent is not
 48188                              <1> 	; found, process just dies. This means 'swap' is called with
 48189                              <1> 	; 'u.uno=0'. What this does is the 'wswap' is not called
 48190                              <1> 	; to write out the process and 'rswap' reads the new process
 48191                              <1> 	; over the one that dies..i.e., the dying process is 
 48192                              <1> 	; overwritten and destroyed.	
 48193                              <1>  	;
 48194                              <1> 	; Calling sequence:
 48195                              <1> 	;	sysexit or conditional branch.
 48196                              <1> 	; Arguments:
 48197                              <1> 	;	-	
 48198                              <1> 	; ...............................................................
 48199                              <1> 	;	
 48200                              <1> 	; Retro UNIX 8086 v1 modification: 
 48201                              <1> 	;       System call number (=1) is in EAX register.
 48202                              <1> 	;
 48203                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
 48204                              <1> 	;       registers depending of function details.
 48205                              <1> 	;
 48206                              <1> 	; ('swap' procedure is mostly different than original UNIX v1.)
 48207                              <1> 	;
 48208                              <1> ; / terminate process
 48209                              <1> 	; AX = 1
 48210 0000CE2F 6648                <1> 	dec 	ax ; 0
 48211 0000CE31 66A3[68010300]      <1> 	mov	[u.intr], ax ; 0
 48212                              <1> 		; clr u.intr / clear interrupt control word
 48213                              <1> 		; clr r1 / clear r1
 48214                              <1> sysexit_0:
 48215                              <1> 	; 30/07/2022
 48216                              <1> 	; 23/01/2017
 48217                              <1> 	; 02/01/2017
 48218                              <1> 	; 10/06/2016
 48219                              <1> 	; 06/06/2016
 48220                              <1> 	; 23/05/2016
 48221                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
 48222                              <1> 	; Check and stop/clear timer event(s) of this (dying) process
 48223                              <1> 	; if there is.
 48224                              <1> 
 48225                              <1> 	; 02/01/2017 
 48226 0000CE37 FA                  <1> 	cli	; disable interrupts
 48227                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
 48228 0000CE38 B036                <1> 	mov	al, 00110110b ; 36h
 48229 0000CE3A E643                <1>  	out	43h, al
 48230 0000CE3C 28C0                <1> 	sub	al, al ; 0
 48231 0000CE3E E640                <1> 	out	40h, al ; LB
 48232 0000CE40 E640                <1> 	out	40h, al ; HB
 48233                              <1>  	; 
 48234 0000CE42 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno]
 48235                              <1> 	;mov	bl, [u.uno] ; process number of dying process
 48236 0000CE49 3883[AF000300]      <1> 	cmp	byte [ebx+p.timer-1], al ; 0
 48237 0000CE4F 7639                <1> 	jna	short sysexit_12 ; no timer events for this process
 48238 0000CE51 8883[AF000300]      <1> 	mov	byte [ebx+p.timer-1], al ; 0 ; reset
 48239                              <1> 	;mov	al, [timer_events]
 48240                              <1> 	;or	al, al
 48241                              <1>  	;jz	short sysexit_12 ; no timer events
 48242                              <1> 	;mov	cl, al
 48243 0000CE57 8A0D[0F840100]      <1> 	mov	cl, [timer_events] ; 14/11/2017
 48244                              <1> 	;cli	; disable interrupts 
 48245 0000CE5D B410                <1> 	mov	ah, 16 ; number of available timer events
 48246 0000CE5F BE[2C020300]        <1> 	mov	esi, timer_set ; beginning address of timer events
 48247                              <1> sysexit_7:
 48248 0000CE64 8A06                <1> 	mov	al, [esi] ; process number (of timer event)
 48249 0000CE66 38D8                <1> 	cmp	al, bl ; process number comparison
 48250 0000CE68 7411                <1> 	je	short sysexit_10
 48251 0000CE6A 20C0                <1> 	and	al, al
 48252 0000CE6C 7404                <1> 	jz	short sysexit_9
 48253                              <1> sysexit_8:
 48254 0000CE6E FEC9                <1> 	dec	cl
 48255 0000CE70 7416                <1> 	jz	short sysexit_11
 48256                              <1> sysexit_9:
 48257 0000CE72 FECC                <1> 	dec	ah
 48258 0000CE74 7414                <1> 	jz	short sysexit_12
 48259 0000CE76 83C610              <1> 	add	esi, 16
 48260 0000CE79 EBE9                <1> 	jmp	short sysexit_7
 48261                              <1> 
 48262                              <1> sysexit_10:
 48263                              <1> 	;mov	byte [esi], 0
 48264 0000CE7B 66C7060000          <1> 	mov	word [esi], 0
 48265                              <1> 	;mov	dword [esi+12], 0
 48266                              <1> 	;
 48267 0000CE80 FE0D[0F840100]      <1> 	dec	byte [timer_events] ; 02/01/2017
 48268                              <1> 	;
 48269 0000CE86 EBE6                <1> 	jmp	short sysexit_8
 48270                              <1> 
 48271                              <1> sysexit_11:
 48272                              <1> 	;sub	ax, ax ; 0 ; 26/02/2017
 48273                              <1> 	; 30/07/2022
 48274 0000CE88 29C0                <1> 	sub	eax, eax ; 0
 48275                              <1> sysexit_12:
 48276                              <1> 	; 26/02/2017 (Unlink IRQ callbacks belong to the user)
 48277 0000CE8A 803D[92010300]00    <1> 	cmp	byte [u.irqc], 0 ; Count of IRQ callbacks
 48278 0000CE91 7E2E                <1> 	jng	short sysexit_16 ; zero or invalid
 48279                              <1> 	; 28/02/2017
 48280                              <1> 	; clear IRQ callback flags (for 'sysrele' and 'sysret')
 48281 0000CE93 A2[93010300]        <1> 	mov	[u.irqwait], al ; 0 ; force to clear waiting flag
 48282 0000CE98 A2[94010300]        <1> 	mov	[u.r_lock], al ; 0 ; force to clear busy flag
 48283 0000CE9D BE[58890100]        <1> 	mov	esi, IRQ.owner
 48284                              <1> sysexit_13:	
 48285 0000CEA2 AC                  <1> 	lodsb
 48286 0000CEA3 3A05[6D010300]      <1> 	cmp	al, [u.uno] ; owner = current user ?
 48287 0000CEA9 750C                <1> 	jne	short sysexit_14
 48288 0000CEAB C646FF00            <1> 	mov	byte [esi-1], 0 ; owner = 0 : Free
 48289 0000CEAF FE0D[92010300]      <1> 	dec	byte [u.irqc]
 48290 0000CEB5 7408                <1> 	jz	short sysexit_15
 48291                              <1> sysexit_14:
 48292 0000CEB7 81FE[60890100]      <1> 	cmp	esi, IRQ.owner + 8 ; the last IRQ index number ?
 48293 0000CEBD 76E3                <1> 	jna	short sysexit_13 ; no
 48294                              <1> sysexit_15:
 48295 0000CEBF 30C0                <1> 	xor	al, al ; 0
 48296                              <1> sysexit_16: ; 2:
 48297 0000CEC1 FB                  <1> 	sti	; enable interrupts 
 48298                              <1> 	;
 48299                              <1> 	; AX = 0
 48300                              <1> sysexit_1: ; 1:
 48301                              <1> 	; AX = File descriptor
 48302                              <1> 		; / r1 has file descriptor (index to u.fp list)
 48303                              <1> 		; / Search the whole list
 48304 0000CEC2 E8D8350000          <1> 	call	fclose
 48305                              <1> 		; jsr r0,fclose / close all files the process opened
 48306                              <1> 	;; ignore error return
 48307                              <1> 		; br .+2 / ignore error return
 48308                              <1> 	;inc	ax
 48309 0000CEC7 FEC0                <1> 	inc	al
 48310                              <1> 		; inc r1 / increment file descriptor
 48311                              <1> 	;cmp	ax, 10
 48312 0000CEC9 3C0A                <1> 	cmp	al, 10
 48313                              <1> 		; cmp r1,$10. / end of u.fp list?
 48314 0000CECB 72F5                <1> 	jb	short sysexit_1
 48315                              <1> 		; blt 1b / no, go back
 48316                              <1> 	;movzx	ebx, byte [u.uno]
 48317 0000CECD 8A1D[6D010300]      <1> 	mov	bl, [u.uno] ; 02/01/2017
 48318                              <1> 		; movb	u.uno,r1 / yes, move dying process's number to r1
 48319 0000CED3 88A3[5F000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
 48320                              <1> 		; clrb p.stat-1(r1) / free the process
 48321                              <1> 	; 10/04/2017
 48322 0000CED9 381D[D1890100]      <1> 	cmp	[audio_user], bl
 48323 0000CEDF 7518                <1> 	jne	short sysexit_17
 48324                              <1> 	; reset audio device (current) owner and 'initializated' flag
 48325 0000CEE1 883D[D1890100]      <1> 	mov	[audio_user], bh ; 0
 48326                              <1> 	; 27/05/2017
 48327 0000CEE7 8B0D[BC890100]      <1> 	mov	ecx,  [audio_buffer]
 48328 0000CEED 09C9                <1> 	or	ecx, ecx
 48329 0000CEEF 7408                <1> 	jz	short sysexit_17
 48330                              <1> 	; 'deallocate_user_pages' is not necessary in sysexit !!!
 48331                              <1> 	;push	ebx
 48332                              <1> 	;mov	ebx, ecx
 48333                              <1> 	;mov	ecx, [audio_buff_size]
 48334                              <1> 	;call	deallocate_user_pages
 48335                              <1> 	;; (Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP)
 48336 0000CEF1 29C9                <1> 	sub	ecx, ecx
 48337 0000CEF3 890D[BC890100]      <1> 	mov	[audio_buffer], ecx ; 0
 48338                              <1> 	;pop	ebx
 48339                              <1> sysexit_17:
 48340                              <1> 	;shl	bx, 1
 48341 0000CEF9 D0E3                <1> 	shl	bl, 1
 48342                              <1> 		; asl r1 / use r1 for index into the below tables
 48343 0000CEFB 668B8B[FEFF0200]    <1> 	mov	cx, [ebx+p.pid-2]
 48344                              <1> 		; mov p.pid-2(r1),r3 / move dying process's name to r3
 48345 0000CF02 668B93[1E000300]    <1> 	mov	dx, [ebx+p.ppid-2]
 48346                              <1> 		; mov p.ppid-2(r1),r4 / move its parents name to r4
 48347                              <1> 	; xor 	bx, bx ; 0
 48348 0000CF09 30DB                <1> 	xor	bl, bl ; 0
 48349                              <1> 		; clr r2
 48350 0000CF0B 31F6                <1> 	xor	esi, esi ; 0
 48351                              <1> 		; clr r5 / initialize reg
 48352                              <1> sysexit_2: ; 1:
 48353                              <1> 	        ; / find children of this dying process, 
 48354                              <1> 		; / if they are zombies, free them
 48355                              <1> 	;add	bx, 2
 48356 0000CF0D 80C302              <1> 	add	bl, 2
 48357                              <1> 		; add $2,r2 / search parent process table 
 48358                              <1> 		          ; / for dying process's name
 48359 0000CF10 66398B[1E000300]    <1> 	cmp	[ebx+p.ppid-2], cx
 48360                              <1> 		; cmp p.ppid-2(r2),r3 / found it?
 48361 0000CF17 7513                <1> 	jne	short sysexit_4
 48362                              <1> 		; bne 3f / no
 48363                              <1> 	;shr	bx, 1
 48364 0000CF19 D0EB                <1> 	shr	bl, 1
 48365                              <1> 		; asr r2 / yes, it is a parent
 48366 0000CF1B 80BB[5F000300]03    <1> 	cmp	byte [ebx+p.stat-1], 3 ; SZOMB
 48367                              <1> 		; cmpb p.stat-1(r2),$3 / is the child of this 
 48368                              <1> 				     ; / dying process a zombie
 48369 0000CF22 7506                <1> 	jne	short sysexit_3 
 48370                              <1> 		; bne 2f / no
 48371 0000CF24 88A3[5F000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
 48372                              <1> 		; clrb p.stat-1(r2) / yes, free the child process
 48373                              <1> sysexit_3: ; 2:
 48374                              <1> 	;shr	bx, 1
 48375 0000CF2A D0E3                <1> 	shl	bl, 1
 48376                              <1> 		; asl r2
 48377                              <1> sysexit_4: ; 3:
 48378                              <1> 		; / search the process name table 
 48379                              <1> 		; / for the dying process's parent
 48380 0000CF2C 663993[FEFF0200]    <1> 	cmp	[ebx+p.pid-2], dx
 48381                              <1> 		; cmp p.pid-2(r2),r4 / found it?
 48382 0000CF33 7502                <1> 	jne	short sysexit_5
 48383                              <1> 		; bne 3f / no
 48384 0000CF35 89DE                <1> 	mov	esi, ebx
 48385                              <1> 		; mov r2,r5 / yes, put index to p.pid table (parents
 48386                              <1> 		          ; / process # x2) in r5
 48387                              <1> sysexit_5: ; 3:
 48388                              <1> 	;cmp	bx, nproc + nproc
 48389 0000CF37 80FB20              <1> 	cmp	bl, nproc + nproc
 48390                              <1> 		; cmp r2,$nproc+nproc / has whole table been searched?
 48391 0000CF3A 72D1                <1> 	jb	short sysexit_2
 48392                              <1> 		; blt 1b / no, go back
 48393                              <1> 		; mov r5,r1 / yes, r1 now has parents process # x2
 48394 0000CF3C 21F6                <1> 	and	esi, esi ; r5=r1
 48395 0000CF3E 7435                <1> 	jz	short sysexit_6
 48396                              <1> 		; beq 2f / no parent has been found. 
 48397                              <1> 		       ; / The process just dies
 48398                              <1> 	;shr	si, 1
 48399                              <1> 	; 23/07/2022
 48400 0000CF40 D1EE                <1> 	shr	esi, 1
 48401                              <1> 		; asr r1 / set up index to p.stat
 48402 0000CF42 8A86[5F000300]      <1> 	mov	al, [esi+p.stat-1]
 48403                              <1> 		; movb p.stat-1(r1),r2 / move status of parent to r2
 48404 0000CF48 20C0                <1> 	and	al, al
 48405 0000CF4A 7429                <1> 	jz	short sysexit_6
 48406                              <1> 		; beq 2f / if its been freed, 2f
 48407 0000CF4C 3C03                <1> 	cmp	al, 3
 48408                              <1> 		; cmp r2,$3 / is parent a zombie?
 48409 0000CF4E 7425                <1> 	je	short sysexit_6
 48410                              <1> 		; beq 2f / yes, 2f
 48411                              <1> 	; BH = 0
 48412 0000CF50 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
 48413                              <1> 		; movb u.uno,r3 / move dying process's number to r3
 48414 0000CF56 C683[5F000300]03    <1> 	mov	byte [ebx+p.stat-1], 3  ; SZOMB
 48415                              <1> 		; movb $3,p.stat-1(r3) / make the process a zombie
 48416 0000CF5D 3C01                <1> 	cmp	al, 1 ; SRUN
 48417 0000CF5F 7414                <1> 	je	short sysexit_6
 48418                              <1> 	;cmp	al, 2
 48419                              <1> 		; cmp r2,$2 / is the parent waiting for 
 48420                              <1> 			  ; / this child to die
 48421                              <1> 	;jne	short sysexit_6	
 48422                              <1> 		; bne 2f / yes, notify parent not to wait any more
 48423                              <1> 	; p.stat = 2 --> waiting
 48424                              <1> 	; p.stat = 4 --> sleeping
 48425 0000CF61 C686[5F000300]01    <1> 	mov	byte [esi+p.stat-1], 1 ; SRUN
 48426                              <1> 	;dec	byte [esi+p.stat-1]
 48427                              <1> 		; decb	p.stat-1(r1) / awaken it by putting it (parent)
 48428 0000CF68 6689F0              <1> 	mov	ax, si ; r1  (process number in AL)
 48429                              <1> 	; 
 48430                              <1> 	;mov	ebx, runq + 4
 48431                              <1> 		; mov $runq+4,r2 / on the runq
 48432 0000CF6B BB[0C010300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017
 48433 0000CF70 E8E43C0000          <1> 	call	putlu
 48434                              <1> 		; jsr r0, putlu
 48435                              <1> sysexit_6: 
 48436                              <1> 		; / the process dies
 48437 0000CF75 C605[6D010300]00    <1> 	mov	byte [u.uno], 0
 48438                              <1> 		; clrb u.uno / put zero as the process number, 
 48439                              <1> 	           ; / so "swap" will
 48440 0000CF7C E8DA3B0000          <1> 	call	swap
 48441                              <1> 		; jsr r0,swap / overwrite process with another process
 48442                              <1> hlt_sys:
 48443                              <1> 	;sti
 48444                              <1> hlts0:
 48445 0000CF81 F4                  <1> 	hlt
 48446 0000CF82 EBFD                <1> 	jmp	short hlts0
 48447                              <1> 		; 0 / and thereby kill it; halt?
 48448                              <1> 
 48449                              <1> syswait: ; < wait for a processs to die >
 48450                              <1> 	; 30/07/2022
 48451                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 48452                              <1> 	; 17/09/2015
 48453                              <1> 	; 02/09/2015
 48454                              <1> 	; 01/09/2015
 48455                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
 48456                              <1> 	; 24/05/2013 - 05/02/2014 (Retro UNIX 8086 v1)
 48457                              <1> 	;
 48458                              <1> 	; 'syswait' waits for a process die. 
 48459                              <1> 	; It works in following way:
 48460                              <1> 	;    1) From the parent process number, the parent's 
 48461                              <1> 	; 	process name is found. The p.ppid table of parent
 48462                              <1> 	;	names is then searched for this process name.
 48463                              <1> 	;	If a match occurs, r2 contains child's process
 48464                              <1> 	;	number. The child status is checked to see if it is
 48465                              <1> 	;	a zombie, i.e; dead but not waited for (p.stat=3)
 48466                              <1> 	;	If it is, the child process is freed and it's name
 48467                              <1> 	;	is put in (u.r0). A return is then made via 'sysret'.
 48468                              <1> 	;	If the child is not a zombie, nothing happens and
 48469                              <1> 	;	the search goes on through the p.ppid table until
 48470                              <1> 	;	all processes are checked or a zombie is found.
 48471                              <1> 	;    2) If no zombies are found, a check is made to see if
 48472                              <1> 	;	there are any children at all. If there are none,
 48473                              <1> 	;	an error return is made. If there are, the parent's
 48474                              <1> 	;	status is set to 2 (waiting for child to die),
 48475                              <1> 	;	the parent is swapped out, and a branch to 'syswait'
 48476                              <1> 	;	is made to wait on the next process.
 48477                              <1> 	;
 48478                              <1> 	; Calling sequence:
 48479                              <1> 	;	?
 48480                              <1> 	; Arguments:
 48481                              <1> 	;	-
 48482                              <1> 	; Inputs: - 
 48483                              <1> 	; Outputs: if zombie found, it's name put in u.r0.	
 48484                              <1> 	; ...............................................................
 48485                              <1> 	;				
 48486                              <1> 	
 48487                              <1> ; / wait for a process to die
 48488                              <1> 
 48489                              <1> syswait_0:
 48490 0000CF84 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; 01/09/2015
 48491                              <1> 		; movb u.uno,r1 / put parents process number in r1
 48492 0000CF8B D0E3                <1> 	shl	bl, 1
 48493                              <1> 	;shl	bx, 1
 48494                              <1> 		; asl r1 / x2 to get index into p.pid table
 48495 0000CF8D 668B83[FEFF0200]    <1> 	mov	ax, [ebx+p.pid-2]
 48496                              <1> 		; mov p.pid-2(r1),r1 / get the name of this process
 48497 0000CF94 31F6                <1> 	xor	esi, esi
 48498                              <1> 		; clr r2
 48499 0000CF96 31C9                <1> 	xor	ecx, ecx ; 30/10/2013
 48500                              <1> 	;xor 	cl, cl
 48501                              <1> 		; clr r3 / initialize reg 3
 48502                              <1> syswait_1: ; 1:
 48503                              <1> 	;add	si, 2
 48504                              <1> 	; 23/07/2022
 48505 0000CF98 46                  <1> 	inc	esi
 48506 0000CF99 46                  <1> 	inc	esi
 48507                              <1> 		; add $2,r2 / use r2 for index into p.ppid table
 48508                              <1> 			  ; / search table of parent processes 
 48509                              <1> 			  ; / for this process name
 48510 0000CF9A 663B86[1E000300]    <1> 	cmp	ax, [esi+p.ppid-2]
 48511                              <1> 		; cmp p.ppid-2(r2),r1 / r2 will contain the childs 
 48512                              <1> 			            ; / process number
 48513 0000CFA1 7531                <1> 	jne	short syswait_3
 48514                              <1> 		;bne 3f / branch if no match of parent process name
 48515                              <1> 	;inc	cx
 48516 0000CFA3 FEC1                <1> 	inc	cl
 48517                              <1> 		;inc r3 / yes, a match, r3 indicates number of children
 48518                              <1> 	;shr	si, 1
 48519                              <1> 	; 23/07/2022
 48520 0000CFA5 D1EE                <1> 	shr	esi, 1 
 48521                              <1> 		; asr r2 / r2/2 to get index to p.stat table
 48522                              <1> 	; The possible states ('p.stat' values) of a process are:
 48523                              <1> 	;	0 = free or unused
 48524                              <1> 	;	1 = active
 48525                              <1> 	;	2 = waiting for a child process to die
 48526                              <1> 	;	3 = terminated, but not yet waited for (zombie).	
 48527 0000CFA7 80BE[5F000300]03    <1> 	cmp	byte [esi+p.stat-1], 3 ; SZOMB, 05/02/2014
 48528                              <1> 		; cmpb p.stat-1(r2),$3 / is the child process a zombie?
 48529 0000CFAE 7522                <1> 	jne	short syswait_2
 48530                              <1> 		; bne 2f / no, skip it
 48531 0000CFB0 88BE[5F000300]      <1> 	mov	[esi+p.stat-1], bh ; 0
 48532                              <1> 		; clrb p.stat-1(r2) / yes, free it
 48533                              <1> 	;shl	si, 1
 48534                              <1> 	; 23/07/2022
 48535 0000CFB6 D1E6                <1> 	shl	esi, 1
 48536                              <1> 		; asl r2 / r2x2 to get index into p.pid table
 48537 0000CFB8 0FB786[FEFF0200]    <1> 	movzx	eax, word [esi+p.pid-2]
 48538 0000CFBF A3[1C010300]        <1> 	mov	[u.r0], eax
 48539                              <1> 		; mov p.pid-2(r2),*u.r0 
 48540                              <1> 			      ; / put childs process name in (u.r0)
 48541                              <1> 	;
 48542                              <1> 	; Retro UNIX 386 v1 modification ! (17/09/2015)
 48543                              <1> 	;
 48544                              <1> 	; Parent process ID -p.ppid- field (of the child process)
 48545                              <1> 	; must be cleared in order to prevent infinitive 'syswait'
 48546                              <1> 	; system call loop from the application/program if it calls
 48547                              <1> 	; 'syswait' again (mistakenly) while there is not a zombie
 48548                              <1> 	; or running child process to wait. ('forktest.s', 17/09/2015)
 48549                              <1> 	;
 48550                              <1> 	; Note: syswait will return with error if there is not a
 48551                              <1> 	;       zombie or running process to wait.	
 48552                              <1> 	
 48553                              <1> 	;sub	ax, ax
 48554                              <1> 	; 30/07/2022
 48555 0000CFC4 29C0                <1> 	sub	eax, eax ; 0
 48556 0000CFC6 668986[1E000300]    <1> 	mov 	[esi+p.ppid-2], ax ; 0 ; 17/09/2015
 48557 0000CFCD E922FDFFFF          <1> 	jmp	sysret0 ; ax = 0
 48558                              <1> 	;
 48559                              <1> 	;jmp	sysret
 48560                              <1> 		; br sysret1 / return cause child is dead
 48561                              <1> syswait_2: ; 2:
 48562                              <1> 	;shl	si, 1
 48563                              <1> 	; 23/07/2022
 48564 0000CFD2 D1E6                <1> 	shl	esi, 1
 48565                              <1> 		; asl r2 / r2x2 to get index into p.ppid table
 48566                              <1> syswait_3: ; 3:
 48567 0000CFD4 6683FE20            <1> 	cmp	si, nproc+nproc
 48568                              <1> 		; cmp r2,$nproc+nproc / have all processes been checked?
 48569 0000CFD8 72BE                <1> 	jb	short syswait_1
 48570                              <1> 		; blt 1b / no, continue search
 48571                              <1> 	;and	cx, cx
 48572 0000CFDA 20C9                <1> 	and	cl, cl
 48573                              <1> 		; tst r3 / one gets here if there are no children 
 48574                              <1> 		       ; / or children that are still active
 48575                              <1> 	; 30/10/2013
 48576 0000CFDC 750B                <1> 	jnz	short syswait_4
 48577                              <1> 	;jz	error
 48578                              <1> 		; beq error1 / there are no children, error
 48579 0000CFDE 890D[1C010300]      <1> 	mov	[u.r0], ecx ; 0
 48580 0000CFE4 E9E9FCFFFF          <1> 	jmp	error
 48581                              <1> syswait_4:
 48582 0000CFE9 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
 48583                              <1> 		; movb u.uno,r1 / there are children so put 
 48584                              <1> 			      ; / parent process number in r1
 48585 0000CFEF FE83[5F000300]      <1> 	inc	byte [ebx+p.stat-1] ; 2, SWAIT, 05/02/2014
 48586                              <1> 		; incb p.stat-1(r1) / it is waiting for 
 48587                              <1> 				  ; / other children to die
 48588                              <1> 	; 04/11/2013
 48589 0000CFF5 E8613B0000          <1> 	call	swap
 48590                              <1> 		; jsr r0,swap / swap it out, because it's waiting
 48591 0000CFFA EB88                <1> 	jmp	syswait_0
 48592                              <1> 		; br syswait / wait on next process
 48593                              <1> 
 48594                              <1> sysfork: ; < create a new process >
 48595                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 48596                              <1> 	; 02/01/2017 (TRDOS 386 modification)
 48597                              <1> 	; 04/09/2015 - 18/05/2015
 48598                              <1> 	; 28/08/2015 - 01/09/2015 - 02/09/2015
 48599                              <1> 	; 09/05/2015 - 10/05/2015 - 14/05/2015
 48600                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 - Beginning)
 48601                              <1> 	; 24/05/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 48602                              <1> 	;
 48603                              <1> 	; 'sysfork' creates a new process. This process is referred
 48604                              <1> 	; to as the child process. This new process core image is
 48605                              <1> 	; a copy of that of the caller of 'sysfork'. The only
 48606                              <1> 	; distinction is the return location and the fact that (u.r0)
 48607                              <1> 	; in the old process (parent) contains the process id (p.pid)
 48608                              <1> 	; of the new process (child). This id is used by 'syswait'.
 48609                              <1> 	; 'sysfork' works in the following manner: 	
 48610                              <1> 	;    1) The process status table (p.stat) is searched to find
 48611                              <1> 	;	a process number that is unused. If none are found
 48612                              <1> 	;	an error occurs.
 48613                              <1> 	;    2) when one is found, it becomes the child process number
 48614                              <1> 	;	and it's status (p.stat) is set to active.
 48615                              <1> 	;    3) If the parent had a control tty, the interrupt 
 48616                              <1> 	;	character in that tty buffer is cleared.
 48617                              <1> 	;    4) The child process is put on the lowest priority run 
 48618                              <1> 	;	queue via 'putlu'.
 48619                              <1> 	;    5) A new process name is gotten from 'mpid' (actually 
 48620                              <1> 	;	it is a unique number) and is put in the child's unique
 48621                              <1> 	;	identifier; process id (p.pid).
 48622                              <1> 	;    6) The process name of the parent is then obtained and
 48623                              <1> 	;	placed in the unique identifier of the parent process
 48624                              <1> 	;	name is then put in 'u.r0'.	
 48625                              <1> 	;    7) The child process is then written out on disk by
 48626                              <1> 	;	'wswap',i.e., the parent process is copied onto disk
 48627                              <1> 	;	and the child is born. (The child process is written 
 48628                              <1> 	;	out on disk/drum with 'u.uno' being the child process
 48629                              <1> 	;	number.)
 48630                              <1> 	;    8) The parent process number is then restored to 'u.uno'.
 48631                              <1> 	;    9) The child process name is put in 'u.r0'.
 48632                              <1> 	;   10) The pc on the stack sp + 18 is incremented by 2 to
 48633                              <1> 	;	create the return address for the parent process.
 48634                              <1> 	;   11) The 'u.fp' list as then searched to see what files
 48635                              <1> 	;	the parent has opened. For each file the parent has
 48636                              <1> 	;	opened, the corresponding 'fsp' entry must be updated
 48637                              <1> 	;	to indicate that the child process also has opened
 48638                              <1> 	;	the file. A branch to 'sysret' is then made.	 			 				
 48639                              <1> 	;
 48640                              <1> 	; Calling sequence:
 48641                              <1> 	;	from shell ?
 48642                              <1> 	; Arguments:
 48643                              <1> 	;	-
 48644                              <1> 	; Inputs: -
 48645                              <1> 	; Outputs: *u.r0 - child process name
 48646                              <1> 	; ...............................................................
 48647                              <1> 	;	
 48648                              <1> 	; Retro UNIX 8086 v1 modification: 
 48649                              <1> 	;	AX = r0 = PID (>0) (at the return of 'sysfork')
 48650                              <1> 	;	= process id of child a parent process returns
 48651                              <1> 	;	= process id of parent when a child process returns
 48652                              <1> 	;
 48653                              <1> 	;       In original UNIX v1, sysfork is called and returns as
 48654                              <1> 	;	in following manner: (with an example: c library, fork)
 48655                              <1> 	;	
 48656                              <1> 	;	1:
 48657                              <1> 	;		sys	fork
 48658                              <1> 	;			br 1f  / child process returns here
 48659                              <1> 	;		bes	2f     / parent process returns here
 48660                              <1> 	;		/ pid of new process in r0
 48661                              <1> 	;		rts	pc
 48662                              <1> 	;	2: / parent process condionally branches here
 48663                              <1> 	;		mov	$-1,r0 / pid = -1 means error return
 48664                              <1> 	;		rts	pc
 48665                              <1> 	;
 48666                              <1> 	;	1: / child process brances here
 48667                              <1> 	;		clr	r0   / pid = 0 in child process
 48668                              <1> 	;		rts	pc
 48669                              <1> 	;
 48670                              <1> 	;	In UNIX v7x86 (386) by Robert Nordier (1999)
 48671                              <1> 	;		// pid = fork();
 48672                              <1> 	;		//
 48673                              <1> 	;		// pid == 0 in child process; 
 48674                              <1> 	;		// pid == -1 means error return
 48675                              <1> 	;		// in child, 
 48676                              <1> 	;		//	parents id is in par_uid if needed
 48677                              <1> 	;		
 48678                              <1> 	;		_fork:
 48679                              <1> 	;			mov	$.fork,eax
 48680                              <1> 	;			int	$0x30
 48681                              <1> 	;			jmp	1f
 48682                              <1> 	;			jnc	2f
 48683                              <1> 	;			jmp	cerror
 48684                              <1> 	;		1:
 48685                              <1> 	;			mov	eax,_par_uid
 48686                              <1> 	;			xor	eax,eax
 48687                              <1> 	;		2:
 48688                              <1> 	;			ret
 48689                              <1> 	;
 48690                              <1> 	;	In Retro UNIX 8086 v1,
 48691                              <1> 	;	'sysfork' returns in following manner:
 48692                              <1> 	;	
 48693                              <1> 	;		mov	ax, sys_fork
 48694                              <1> 	;		mov	bx, offset @f ; routine for child
 48695                              <1> 	;		int	20h
 48696                              <1> 	;		jc	error
 48697                              <1> 	;		
 48698                              <1> 	;	; Routine for parent process here (just after 'jc')
 48699                              <1> 	;		mov	word ptr [pid_of_child], ax
 48700                              <1> 	;		jmp	next_routine_for_parent	
 48701                              <1> 	;
 48702                              <1> 	;	@@: ; routine for child process here				
 48703                              <1> 	;		....	
 48704                              <1> 	;	NOTE: 'sysfork' returns to specified offset
 48705                              <1> 	;	       for child process by using BX input.
 48706                              <1> 	;	      (at first, parent process will return then 
 48707                              <1> 	;	      child process will return -after swapped in-
 48708                              <1> 	;	      'syswait' is needed in parent process
 48709                              <1> 	;	      if return from child process will be waited for.)
 48710                              <1> 	;	  				
 48711                              <1> 	
 48712                              <1> ; / create a new process
 48713                              <1> 	; EBX = return address for child process 
 48714                              <1> 	     ; (Retro UNIX 8086 v1 modification !)
 48715 0000CFFC 31F6                <1> 	xor 	esi, esi
 48716                              <1> 		; clr r1
 48717                              <1> sysfork_1: ; 1: / search p.stat table for unused process number
 48718 0000CFFE 46                  <1> 	inc	esi
 48719                              <1> 		; inc r1
 48720 0000CFFF 80BE[5F000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE, 05/02/2014
 48721                              <1> 		; tstb p.stat-1(r1) / is process active, unused, dead
 48722 0000D006 760B                <1> 	jna	short sysfork_2	
 48723                              <1> 		; beq 1f / it's unused so branch
 48724 0000D008 6683FE10            <1> 	cmp	si, nproc
 48725                              <1> 		; cmp r1,$nproc / all processes checked
 48726 0000D00C 72F0                <1> 	jb	short sysfork_1
 48727                              <1> 		; blt 1b / no, branch back
 48728                              <1> 	;
 48729                              <1> 	; Retro UNIX 8086 v1. modification:
 48730                              <1> 	;	Parent process returns from 'sysfork' to address 
 48731                              <1> 	;	which is just after 'sysfork' system call in parent
 48732                              <1> 	;	process. Child process returns to address which is put
 48733                              <1> 	;	in BX register by parent process for 'sysfork'. 
 48734                              <1> 	;
 48735                              <1> 		; add $2,18.(sp) / add 2 to pc when trap occured, points
 48736                              <1> 		             ; / to old process return
 48737                              <1> 		; br error1 / no room for a new process
 48738                              <1> sysfork_err:
 48739 0000D00E E9BFFCFFFF          <1> 	jmp	error
 48740                              <1> sysfork_2: ; 1:
 48741 0000D013 E88386FFFF          <1> 	call	allocate_page
 48742                              <1> 	;jc	error
 48743                              <1> 	; 23/07/2022
 48744 0000D018 72F4                <1> 	jc	short sysfork_err
 48745 0000D01A 50                  <1> 	push	eax   ; UPAGE (user structure page) address
 48746                              <1> 	; Retro UNIX 386 v1 modification!
 48747 0000D01B E87488FFFF          <1> 	call	duplicate_page_dir
 48748                              <1> 		; EAX = New page directory 
 48749 0000D020 730B                <1> 	jnc	short sysfork_3
 48750 0000D022 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
 48751 0000D023 E83B88FFFF          <1> 	call 	deallocate_page
 48752 0000D028 E9A5FCFFFF          <1> 	jmp	error
 48753                              <1> sysfork_3:
 48754                              <1> 	; Retro UNIX 386 v1 modification !
 48755 0000D02D 56                  <1> 	push	esi
 48756 0000D02E E8B63B0000          <1> 	call	wswap ; save current user (u) structure, user registers
 48757                              <1> 		      ; and interrupt return components (for IRET)
 48758 0000D033 8705[74010300]      <1> 	xchg	eax, [u.pgdir] ; page directory of the child process
 48759 0000D039 A3[78010300]        <1> 	mov	[u.ppgdir], eax ; page directory of the parent process
 48760 0000D03E 5E                  <1> 	pop	esi
 48761 0000D03F 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
 48762                              <1> 		; [u.usp] = esp
 48763 0000D040 89F7                <1> 	mov	edi, esi
 48764                              <1> 	;shl	di, 2
 48765                              <1> 	; 23/07/2022
 48766 0000D042 C1E702              <1> 	shl	edi, 2
 48767 0000D045 8987[6C000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
 48768 0000D04B A3[70010300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
 48769                              <1> 	; 28/08/2015
 48770 0000D050 0FB605[6D010300]    <1> 	movzx	eax, byte [u.uno] ; parent process number
 48771                              <1> 		; movb u.uno,-(sp) / save parent process number
 48772 0000D057 89C7                <1> 	mov	edi, eax
 48773 0000D059 50                  <1>         push	eax ; ** 
 48774 0000D05A 8A87[3F000300]      <1> 	mov     al, [edi+p.ttyc-1] ; console tty (parent)
 48775                              <1> 	; 18/09/2015
 48776                              <1> 	;;mov	[esi+p.ttyc-1], al ; set child's console tty
 48777                              <1> 	;;mov	[esi+p.waitc-1], ah ; 0 ; reset child's wait channel
 48778                              <1> 	;mov    [esi+p.ttyc-1], ax ; al - set child's console tty
 48779                              <1> 				   ; ah - reset child's wait channel	
 48780                              <1> 	; 23/07/2022
 48781 0000D060 8886[3F000300]      <1> 	mov	[esi+p.ttyc-1], al ; set child's console tty
 48782 0000D066 89F0                <1> 	mov	eax, esi
 48783 0000D068 A2[6D010300]        <1> 	mov	[u.uno], al ; child process number
 48784                              <1> 		;movb r1,u.uno / set child process number to r1
 48785 0000D06D FE86[5F000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN, 05/02/2014
 48786                              <1> 		; incb p.stat-1(r1) / set p.stat entry for child 
 48787                              <1> 				; / process to active status
 48788                              <1> 		; mov u.ttyp,r2 / put pointer to parent process' 
 48789                              <1> 			      ; / control tty buffer in r2
 48790                              <1>                 ; beq 2f / branch, if no such tty assigned
 48791                              <1> 		; clrb 6(r2) / clear interrupt character in tty buffer
 48792                              <1> 	; 2:
 48793 0000D073 53                  <1> 	push	ebx  ; * return address for the child process
 48794                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
 48795                              <1> 	; (Retro UNIX 8086 v1 modification!)
 48796                              <1> 		; mov $runq+4,r2
 48797 0000D074 BB[0C010300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017  
 48798 0000D079 E8DB3B0000          <1> 	call	putlu
 48799                              <1>  		; jsr r0,putlu / put child process on lowest priority 
 48800                              <1> 			   ; / run queue
 48801                              <1> 	; 23/07/2022
 48802 0000D07E D1E6                <1> 	shl	esi, 1
 48803                              <1> 	;shl	si, 1
 48804                              <1> 		; asl r1 / multiply r1 by 2 to get index 
 48805                              <1> 		       ; / into p.pid table
 48806 0000D080 66FF05[04010300]    <1> 	inc	word [mpid]
 48807                              <1> 		; inc mpid / increment m.pid; get a new process name
 48808 0000D087 66A1[04010300]      <1> 	mov	ax, [mpid]
 48809 0000D08D 668986[FEFF0200]    <1> 	mov	[esi+p.pid-2], ax
 48810                              <1> 		;mov mpid,p.pid-2(r1) / put new process name 
 48811                              <1> 				    ; / in child process' name slot
 48812 0000D094 5A                  <1> 	pop	edx  ; * return address for the child process
 48813                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
 48814 0000D095 5B                  <1>   	pop	ebx  ; **
 48815                              <1> 	;mov	ebx, [esp] ; ** parent process number
 48816                              <1> 		; movb (sp),r2 / put parent process number in r2
 48817                              <1> 	; 23/07/2022
 48818 0000D096 D1E3                <1> 	shl	ebx, 1
 48819                              <1> 	;shl 	bx, 1
 48820                              <1> 		;asl r2 / multiply by 2 to get index into below tables
 48821                              <1> 	;movzx eax, word [ebx+p.pid-2]
 48822 0000D098 668B83[FEFF0200]    <1> 	mov	ax, [ebx+p.pid-2]
 48823                              <1> 		; mov p.pid-2(r2),r2 / get process name of parent
 48824                              <1> 				   ; / process
 48825 0000D09F 668986[1E000300]    <1> 	mov	[esi+p.ppid-2], ax
 48826                              <1> 		; mov r2,p.ppid-2(r1) / put parent process name 
 48827                              <1> 			  ; / in parent process slot for child
 48828 0000D0A6 A3[1C010300]        <1> 	mov	[u.r0], eax	
 48829                              <1> 		; mov r2,*u.r0 / put parent process name on stack 
 48830                              <1> 			     ; / at location where r0 was saved
 48831 0000D0AB 8B2D[14010300]      <1> 	mov 	ebp, [u.sp] ; points to return address (EIP for IRET)
 48832 0000D0B1 895500              <1> 	mov	[ebp], edx ; *, CS:EIP -> EIP
 48833                              <1> 			   ; * return address for the child process
 48834                              <1> 		; mov $sysret1,-(sp) /
 48835                              <1> 		; mov sp,u.usp / contents of sp at the time when 
 48836                              <1> 			      ; / user is swapped out
 48837                              <1> 		; mov $sstack,sp / point sp to swapping stack space
 48838                              <1> 	; 04/09/2015 - 01/09/2015
 48839                              <1> 	; [u.usp] = esp
 48840 0000D0B4 68[F2CC0000]        <1> 	push	sysret ; ***
 48841 0000D0B9 8925[18010300]      <1> 	mov	[u.usp], esp ; points to 'sysret' address (***)
 48842                              <1> 			     ; (for child process)	
 48843 0000D0BF 31C0                <1> 	xor 	eax, eax
 48844 0000D0C1 66A3[50010300]      <1> 	mov 	[u.ttyp], ax ; 0
 48845                              <1> 	;
 48846 0000D0C7 E81D3B0000          <1> 	call	wswap ; Retro UNIX 8086 v1 modification !
 48847                              <1> 		; jsr r0,wswap / put child process out on drum
 48848                              <1> 		; jsr r0,unpack / unpack user stack
 48849                              <1> 		; mov u.usp,sp / restore user stack pointer
 48850                              <1> 		; tst (sp)+ / bump stack pointer
 48851                              <1> 	; Retro UNIX 386 v1 modification !
 48852 0000D0CC 58                  <1> 	pop	eax ; ***
 48853                              <1> 	;shl	bx, 1
 48854                              <1> 	; 23/07/2022
 48855 0000D0CD D1E3                <1> 	shl	ebx, 1
 48856 0000D0CF 8B83[6C000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address ; 14/05/2015
 48857 0000D0D5 E8473B0000          <1> 	call	rswap ; restore parent process 'u' structure, 
 48858                              <1> 		      ; registers and return address (for IRET)
 48859                              <1> 		;movb (sp)+,u.uno / put parent process number in u.uno
 48860 0000D0DA 0FB705[04010300]    <1>         movzx   eax, word [mpid]
 48861 0000D0E1 A3[1C010300]        <1> 	mov	[u.r0], eax
 48862                              <1> 		; mov mpid,*u.r0 / put child process name on stack 
 48863                              <1> 			       ; / where r0 was saved
 48864                              <1> 		; add $2,18.(sp) / add 2 to pc on stack; gives parent
 48865                              <1> 			          ; / process return
 48866                              <1> 	;xor	ebx, ebx
 48867 0000D0E6 31F6                <1> 	xor     esi, esi
 48868                              <1> 		;clr r1
 48869                              <1> sysfork_4: ; 1: / search u.fp list to find the files 
 48870                              <1> 	      ; / opened by the parent process
 48871                              <1> 	; 01/09/2015
 48872                              <1> 	;xor	bh, bh
 48873                              <1> 	;mov 	bl, [esi+u.fp]
 48874 0000D0E8 8A86[26010300]      <1> 	mov 	al, [esi+u.fp]
 48875                              <1> 		; movb u.fp(r1),r2 / get an open file for this process
 48876                              <1>         ;or	bl, bl
 48877 0000D0EE 08C0                <1> 	or	al, al
 48878 0000D0F0 7406                <1> 	jz	short sysfork_5	
 48879                              <1> 		; beq 2f / file has not been opened by parent, 
 48880                              <1> 		       ; / so branch
 48881                              <1> 	;mov	ah, 10 ; Retro UNIX 386 v1 fsp structure size = 10 bytes
 48882                              <1> 	;mul	ah
 48883                              <1> 	; 23/07/2022
 48884                              <1> 	; Retro UNIX 386 v2 & TRDOS 386 v2.0.5 fsp struc size = 16 bytes
 48885                              <1> 	;mov	ebx, eax 	
 48886                              <1> 	;shl	ebx, 4 ; * 16
 48887                              <1> 	;inc	byte [ebx+fsp-10]
 48888                              <1> 
 48889                              <1> 	; 23/07/2022 (BugFix)
 48890 0000D0F2 FE80[1C850100]      <1> 	inc	byte [OF_OPENCOUNT+eax] 
 48891                              <1> 
 48892                              <1> 	;;movzx	ebx, ax
 48893                              <1> 	;mov	bx, ax
 48894                              <1> 	;shl	bx, 3
 48895                              <1> 		; asl r2 / multiply by 8
 48896                              <1>        		; asl r2 / to get index into fsp table
 48897                              <1>        		; asl r2
 48898                              <1>   	;inc	byte [ebx+fsp-2]
 48899                              <1> 		; incb fsp-2(r2) / increment number of processes
 48900                              <1> 			     ; / using file, because child will now be
 48901                              <1> 			     ; / using this file
 48902                              <1> sysfork_5: ; 2:
 48903 0000D0F8 46                  <1>         inc     esi
 48904                              <1> 		; inc r1 / get next open file
 48905                              <1> 	; 23/07/2022
 48906 0000D0F9 6683FE20            <1> 	cmp	si, OPENFILES ; = 10
 48907                              <1> 	;cmp	si, 10
 48908                              <1> 		; cmp r1,$10. / 10. files is the maximum number which
 48909                              <1> 			    ; / can be opened
 48910 0000D0FD 72E9                <1> 	jb	short sysfork_4	
 48911                              <1> 		; blt 1b / check next entry
 48912 0000D0FF E9EEFBFFFF          <1> 	jmp	sysret
 48913                              <1> 		; br sysret1
 48914                              <1> 
 48915                              <1> syscreat: ; < create file >
 48916                              <1> 	; 08/08/2022
 48917                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 48918                              <1> 	; 13/11/2017
 48919                              <1> 	; 27/10/2016
 48920                              <1> 	; 25/10/2016 - 26/10/2016
 48921                              <1> 	; 15/10/2016 - 16/10/2016 - 17/10/2016
 48922                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
 48923                              <1> 	;	     -derived from INT_21H.ASM-
 48924                              <1> 	;            ("loc_INT21h_create_file")
 48925                              <1>         ; 	10/07/2011 (12/03/2011)
 48926                              <1>         ;	INT 21h Function AH = 3Ch
 48927                              <1>         ;	Create File
 48928                              <1>         ;	INPUT
 48929                              <1>         ;	   CX = Attributes
 48930                              <1>         ;          DS:DX= Address of zero terminaned path name
 48931                              <1>         ;
 48932                              <1> 	; 27/12/2015 (Retro UNIX 386 v1.1)
 48933                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
 48934                              <1> 	; 27/05/2013 (Retro UNIX 8086 v1)
 48935                              <1> 	;
 48936                              <1> 	; 'syscreat' called with two arguments; name and mode.
 48937                              <1> 	; u.namep points to name of the file and mode is put
 48938                              <1> 	; on the stack. 'namei' is called to get i-number of the file.		
 48939                              <1> 	; If the file aready exists, it's mode and owner remain 
 48940                              <1> 	; unchanged, but it is truncated to zero length. If the file
 48941                              <1> 	; did not exist, an i-node is created with the new mode via
 48942                              <1> 	; 'maknod' whether or not the file already existed, it is
 48943                              <1> 	; open for writing. The fsp table is then searched for a free
 48944                              <1> 	; entry. When a free entry is found, proper data is placed
 48945                              <1> 	; in it and the number of this entry is put in the u.fp list.
 48946                              <1> 	; The index to the u.fp (also know as the file descriptor)
 48947                              <1> 	; is put in the user's r0. 			
 48948                              <1> 	;
 48949                              <1> 	; Calling sequence:
 48950                              <1> 	;	syscreate; name; mode
 48951                              <1> 	; Arguments:
 48952                              <1> 	;	name - name of the file to be created
 48953                              <1> 	;	mode - mode of the file to be created
 48954                              <1> 	; Inputs: (arguments)
 48955                              <1> 	; Outputs: *u.r0 - index to u.fp list 
 48956                              <1> 	;		   (the file descriptor of new file)
 48957                              <1> 	; ...............................................................
 48958                              <1> 	;				
 48959                              <1> 	; Retro UNIX 8086 v1 modification: 
 48960                              <1> 	;       'syscreate' system call has two arguments; so,
 48961                              <1> 	;	* 1st argument, name is pointed to by BX register
 48962                              <1> 	;	* 2nd argument, mode is in CX register
 48963                              <1> 	;
 48964                              <1> 	;	AX register (will be restored via 'u.r0') will return
 48965                              <1> 	;	to the user with the file descriptor/number 
 48966                              <1> 	;	(index to u.fp list).
 48967                              <1> 	;
 48968                              <1> 	;call	arg2
 48969                              <1> 	; * name - 'u.namep' points to address of file/path name
 48970                              <1> 	;          in the user's program segment ('u.segmnt')
 48971                              <1> 	;          with offset in BX register (as sysopen argument 1).
 48972                              <1> 	; * mode - sysopen argument 2 is in CX register 
 48973                              <1> 	;          which is on top of stack.
 48974                              <1> 	;
 48975                              <1> 	; TRDOS 386 (10/10/2016)
 48976                              <1> 	;	
 48977                              <1>         ; INPUT ->
 48978                              <1>         ;	   CL = File Attributes
 48979                              <1> 	;     	      bit 0 (1) - Read only file (R)
 48980                              <1> 	;             bit 1 (1) - Hidden file (H)
 48981                              <1>         ;             bit 2 (1) - System file (R)
 48982                              <1> 	;             bit 3 (1) - Volume label/name (V)
 48983                              <1>         ;             bit 4 (1) - Subdirectory (D)
 48984                              <1> 	;	      bit 5 (1) - File has been archived (A)	 	
 48985                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
 48986                              <1> 	;	
 48987                              <1> 	; OUTPUT ->
 48988                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
 48989                              <1> 	;          cf = 1 -> Error code in AL
 48990                              <1> 	;
 48991                              <1> 	; Modified Registers: EAX (at the return of system call)
 48992                              <1> 	;  
 48993                              <1> 	; Note: If the file is existing and it has not any one
 48994                              <1> 	;	of S,H,R,V,D attributes, it will be truncated 
 48995                              <1> 	;	to zero length; otherwise, access error will be 
 48996                              <1> 	;	returned. 
 48997                              <1> 
 48998                              <1> sysmkdir_0:
 48999 0000D104 F6C108              <1> 	test	cl, 08h ; Volume name 
 49000 0000D107 740A                <1> 	jz	short syscreat_0
 49001                              <1> 
 49002                              <1> 	; Volume name or long name creation
 49003                              <1> 	; is not permitted (in TRDOS 386)!
 49004 0000D109 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
 49005 0000D10E E9CE000000          <1>         jmp	sysopen_dev_err ; 08/08/2022
 49006                              <1> syscreat_0:
 49007                              <1>         ;mov	[u.namep], ebx
 49008 0000D113 51                  <1> 	push	ecx
 49009 0000D114 89DE                <1> 	mov	esi, ebx
 49010                              <1> 	; file name is forced, change directory as temporary
 49011                              <1> 	;mov	ax, 1
 49012                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 49013                              <1> 	;call	set_working_path 
 49014 0000D116 E824500000          <1> 	call	set_working_path_x ; 17/10/2016	
 49015                              <1> 	;jc	short syscreat_err
 49016                              <1> 	; 23/07/2022
 49017 0000D11B 7305                <1> 	jnc	short syscreat_3
 49018 0000D11D E9D8000000          <1> 	jmp	syscreat_err
 49019                              <1> 
 49020                              <1> syscreat_3:
 49021                              <1> 	; 16/10/2016
 49022 0000D122 803D[33840100]00    <1> 	cmp	byte [SWP_inv_fname], 0
 49023 0000D129 776C                <1> 	ja	short  syscreat_inv_fname ; invalid file name !
 49024                              <1> 
 49025                              <1> 	; Here, we have a valid path and also a valid file name
 49026                              <1> 	; (Working dir has been changed if the path
 49027                              <1> 	;  -file name string- had contained a dir name.)
 49028                              <1> 
 49029 0000D12B 6631C0              <1> 	xor	ax, ax 
 49030                              <1> 	;mov	esi, FindFile_Name
 49031 0000D12E E8DEB8FFFF          <1> 	call	find_first_file
 49032 0000D133 59                  <1> 	pop	ecx
 49033                              <1> 		; ESI = Directory Entry (FindFile_DirEntry) Location
 49034                              <1> 		; EDI = Directory Buffer Directory Entry Location
 49035                              <1> 		; EAX = File Size
 49036                              <1> 		;  BL = Attributes of The File/Directory
 49037                              <1> 		;  BH = Long Name Yes/No Status (>0 is YES)
 49038                              <1> 		;  DX > 0 : Ambiguous filename chars are used
 49039 0000D134 7269                <1> 	jc	short syscreat_1 ; file not found (the good!) 
 49040                              <1> 				 ; or another error (the bad!) 
 49041                              <1> 
 49042                              <1> 	; (& the uggly!) truncate file to zero length before open
 49043                              <1> 
 49044                              <1> 	;'*' and '?' already checked at 'set_working_path' stage
 49045                              <1> 	;and	dx, dx
 49046                              <1> 	;jnz	short sysmkdir_err ; permission denied 
 49047                              <1> 				   ; invalid filename chars
 49048                              <1> 
 49049                              <1> 	;test	cl, 10h ; subdirectory ?
 49050                              <1> 	;jnz	short sysmkdir_err	
 49051                              <1> 
 49052                              <1> 	; BL = File Attributes:	
 49053                              <1> 	;     	      bit 0 (1) - Read only file (R)
 49054                              <1> 	;             bit 1 (1) - Hidden file (H)
 49055                              <1>         ;             bit 2 (1) - System file (R)
 49056                              <1> 	;             bit 3 (1) - Volume label/name (V)
 49057                              <1>         ;             bit 4 (1) - Subdirectory (D)
 49058                              <1> 	;	      bit 5 (1) - File has been archived	 	
 49059                              <1> 
 49060                              <1> 	; * existing directory must not be truncated
 49061                              <1> 	;   (we don't know it is empty or not, at this stage) 
 49062                              <1> 	; * existing volume name (or a long name) can not be
 49063                              <1> 	;   re-created or truncated by 'syscreat' 	
 49064                              <1> 	; * A file with S, H, R attributes must not be truncated
 49065                              <1> 	;   (change attributes to normal, if you need truncate it)
 49066                              <1> 
 49067 0000D136 F6C31F              <1> 	test	bl, 00011111b  ; check attributes of existing file
 49068 0000D139 754E                <1> 	jnz	short sysmkdir_err
 49069                              <1> 
 49070                              <1> 	;; normal file, OK to continue...
 49071                              <1> 
 49072                              <1> 	; ESI = FindFile_DirEntry
 49073 0000D13B 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
 49074 0000D13F C1E010              <1> 	shl	eax, 16 ; 13/11/2017
 49075 0000D142 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
 49076                              <1> 	; EAX = First cluster to be truncated/unlinked
 49077 0000D146 57                  <1> 	push	edi
 49078 0000D147 51                  <1> 	push	ecx
 49079 0000D148 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 49080 0000D14D 29C9                <1> 	sub	ecx, ecx
 49081 0000D14F 8A2D[42780100]      <1> 	mov	ch, [Current_Drv]
 49082 0000D155 01CE                <1> 	add	esi, ecx
 49083                              <1> 	; ESI = Logical dos drive description table address
 49084 0000D157 E8DEF7FFFF          <1> 	call	truncate_cluster_chain
 49085 0000D15C 59                  <1> 	pop	ecx
 49086 0000D15D 5F                  <1> 	pop	edi
 49087 0000D15E 7230                <1> 	jc	short syscreate_truncate_err
 49088                              <1> 
 49089                              <1> 	; 26/10/2016
 49090                              <1> 	; EDI = Directory entry address in directory buffer
 49091                              <1> 	; Update directory entry
 49092 0000D160 E819DDFFFF          <1> 	call	convert_current_date_time
 49093                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 49094                              <1>         ; 	    AX = Time in dos dir entry format	
 49095 0000D165 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
 49096 0000D169 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
 49097 0000D16D 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
 49098 0000D171 31C0                <1> 	xor	eax, eax ; file size = 0 
 49099 0000D173 89471C              <1> 	mov	[edi+DirEntry_FileSize], eax ; 0
 49100 0000D176 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; data changed sign	
 49101 0000D17D BE[34810100]        <1> 	mov	esi, FindFile_DirEntry
 49102 0000D182 B201                <1> 	mov	dl, 1 ; open file for writing
 49103 0000D184 E9AB000000          <1> 	jmp	sysopen_2 ; 08/08/2022
 49104                              <1> 
 49105                              <1> sysmkdir_err:
 49106                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
 49107 0000D189 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
 49108 0000D18E EB74                <1>         jmp	short sysopen_err
 49109                              <1> 
 49110                              <1> syscreate_truncate_err:
 49111 0000D190 B812000000          <1> 	mov	eax, ERR_DRV_WRITE ; 18 ; 'disk write error !'
 49112 0000D195 EB6D                <1>         jmp	short sysopen_err
 49113                              <1> 
 49114                              <1> syscreat_inv_fname:  ; invalid file name chars 
 49115                              <1> 	; 16/10/2016
 49116 0000D197 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26 ; invalid file name chars 
 49117 0000D19C 59                  <1> 	pop	ecx
 49118 0000D19D EB65                <1> 	jmp	short sysopen_err
 49119                              <1> 
 49120                              <1> syscreat_1:
 49121                              <1> 	; Error code in EAX
 49122 0000D19F 3C02                <1>         cmp	al, 02h ; 'File not found' error
 49123 0000D1A1 7561                <1>         jne	short sysopen_err
 49124                              <1> 
 49125 0000D1A3 F6C110              <1> 	test	cl, 10h ; Directory
 49126                              <1> 	;jnz	sysmkdir_2
 49127                              <1> 	; 23/07/2022
 49128 0000D1A6 7405                <1> 	jz	short syscreat_2
 49129 0000D1A8 E992010000          <1> 	jmp	sysmkdir_2
 49130                              <1> 
 49131                              <1> syscreat_2:
 49132 0000D1AD BE[24810100]        <1> 	mov	esi, FindFile_Name 
 49133                              <1>         ;xor	edx, edx
 49134 0000D1B2 31C0                <1>         xor	eax, eax ; File Size  = 0
 49135 0000D1B4 31DB                <1> 	xor	ebx, ebx
 49136 0000D1B6 4B                  <1> 	dec 	ebx ; FFFFFFFFh -> create empty file 
 49137                              <1> 	            ;              (only for FAT fs) 
 49138                              <1> 	; CL = File Attributes
 49139 0000D1B7 E897ECFFFF          <1> 	call	create_file
 49140 0000D1BC 7246                <1> 	jc	short sysopen_err
 49141                              <1> 		; EAX = New file's first cluster
 49142                              <1> 		; ESI = Logical Dos Drv Descr. Table Addr.
 49143                              <1> 		; EBX = offset CreateFile_Size
 49144                              <1> 		; ECX = Sectors per cluster (<256) 
 49145                              <1> 		; EDX = Directory entry index/number (<65536)
 49146                              <1> 	; 26/10/2016
 49147                              <1> 	;mov	esi, Directory_Buffer
 49148                              <1> 	;shl	dx, 5 ; *32
 49149                              <1> 	;add	esi, edx
 49150                              <1> 	;; esi = directory entry address in directory buffer
 49151                              <1> 
 49152                              <1> 	; Here, directory entry has been created but last
 49153                              <1> 	; modification date & time of the parent dir has not
 49154                              <1> 	; been updated, yet! 
 49155                              <1> 	; (Note: Directory and FAT buffers have been updated...)
 49156                              <1>  	
 49157 0000D1BE E8E8DDFFFF          <1> 	call	update_parent_dir_lmdt ; now, it is OK too!
 49158                              <1> 
 49159                              <1> 	; 25/10/2016
 49160 0000D1C3 66B80018            <1> 	mov	ax, 1800h
 49161 0000D1C7 BE[24810100]        <1> 	mov	esi, FindFile_Name
 49162 0000D1CC E840B8FFFF          <1> 	call	find_first_file
 49163 0000D1D1 7231                <1> 	jc	short sysopen_err
 49164                              <1> 
 49165                              <1> 	; Only possible error after here is 
 49166                              <1> 	; "too many open files !" error.
 49167                              <1> 	;
 49168                              <1> 	; If "syscreat" will return with that error,
 49169                              <1> 	; (the file has been created but it could not be opened)
 49170                              <1> 	; the user must retry to open this file again
 49171                              <1> 	; or must close another file before using 
 49172                              <1> 	; "sysopen" system call.
 49173                              <1> 
 49174 0000D1D3 B201                <1> 	mov	dl, 1 ; open file for writing
 49175                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 49176                              <1> 	; EAX = File Size (= 0)
 49177 0000D1D5 EB5D                <1> 	jmp	short sysopen_2
 49178                              <1> 
 49179                              <1> sysopen: ;<open file>
 49180                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 49181                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 49182                              <1> 	;	(temporary modifications)
 49183                              <1> 	; 26/10/2016
 49184                              <1> 	; 24/10/2016
 49185                              <1> 	; 17/10/2016
 49186                              <1> 	; 15/10/2016
 49187                              <1> 	; 06/10/2016, 07/10/2016, 08/10/2016
 49188                              <1> 	; 05/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49189                              <1> 	;	     -derived from INT_21H.ASM-
 49190                              <1> 	;            ("loc_INT21h_open_file")
 49191                              <1>         ; 	26/02/2011 
 49192                              <1>         ;	INT 21h Function AH = 3Dh
 49193                              <1>         ;	Open File
 49194                              <1>         ;	INPUT
 49195                              <1>         ;	   AL= File Access Value
 49196                              <1> 	;     	     0- Open for reading
 49197                              <1> 	;            1- Open for writing
 49198                              <1>         ;            2- Open for reading and writing
 49199                              <1>         ;          DS:DX= Pointer to filename (ASCIIZ)
 49200                              <1>         ;
 49201                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
 49202                              <1> 	; 22/05/2013 - 27/05/2013 (Retro UNIX 8086 v1)
 49203                              <1> 	;
 49204                              <1> 	; 'sysopen' opens a file in following manner:
 49205                              <1> 	;    1) The second argument in a sysopen says whether to
 49206                              <1> 	;	open the file ro read (0) or write (>0).
 49207                              <1> 	;    2) I-node of the particular file is obtained via 'namei'.
 49208                              <1> 	;    3) The file is opened by 'iopen'.
 49209                              <1> 	;    4) Next housekeeping is performed on the fsp table
 49210                              <1> 	;	and the user's open file list - u.fp.
 49211                              <1> 	;	a) u.fp and fsp are scanned for the next available slot.
 49212                              <1> 	;	b) An entry for the file is created in the fsp table.
 49213                              <1> 	;	c) The number of this entry is put on u.fp list.
 49214                              <1> 	;	d) The file descriptor index to u.fp list is pointed
 49215                              <1> 	;	   to by u.r0.
 49216                              <1> 	;
 49217                              <1> 	; Calling sequence:
 49218                              <1> 	;	sysopen; name; mode
 49219                              <1> 	; Arguments:
 49220                              <1> 	;	name - file name or path name
 49221                              <1> 	;	mode - 0 to open for reading
 49222                              <1> 	;	       1 to open for writing
 49223                              <1> 	; Inputs: (arguments)
 49224                              <1> 	; Outputs: *u.r0 - index to u.fp list (the file descriptor)
 49225                              <1> 	;		  is put into r0's location on the stack.	
 49226                              <1> 	; ...............................................................
 49227                              <1> 	;				
 49228                              <1> 	; Retro UNIX 8086 v1 modification: 
 49229                              <1> 	;       'sysopen' system call has two arguments; so,
 49230                              <1> 	;	* 1st argument, name is pointed to by BX register
 49231                              <1> 	;	* 2nd argument, mode is in CX register
 49232                              <1> 	;
 49233                              <1> 	;	AX register (will be restored via 'u.r0') will return
 49234                              <1> 	;	to the user with the file descriptor/number 
 49235                              <1> 	;	(index to u.fp list).
 49236                              <1> 	;
 49237                              <1> 	;call	arg2
 49238                              <1> 	; * name - 'u.namep' points to address of file/path name
 49239                              <1> 	;          in the user's program segment ('u.segmnt')
 49240                              <1> 	;          with offset in BX register (as sysopen argument 1).
 49241                              <1> 	; * mode - sysopen argument 2 is in CX register 
 49242                              <1> 	;          which is on top of stack.
 49243                              <1> 	;
 49244                              <1> 	; jsr r0,arg2 / get sys args into u.namep and on stack
 49245                              <1> 	;
 49246                              <1>        	; system call registers: ebx, ecx (through 'sysenter')
 49247                              <1> 	;
 49248                              <1> 	; TRDOS 386 (05/10/2016)
 49249                              <1> 	;	
 49250                              <1>         ; INPUT ->
 49251                              <1>         ;	   CL = File Access Value (Open Mode)
 49252                              <1> 	;     	      0 - Open file for reading
 49253                              <1> 	;             1 - Open file for writing
 49254                              <1>         ;             2 - Open device for reading
 49255                              <1> 	;	      3 - Open device for writing
 49256                              <1>         ;          EBX = Pointer to filename/devicename (ASCIIZ)
 49257                              <1> 	; OUTPUT ->
 49258                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
 49259                              <1> 	;          cf = 1 -> Error code in AL
 49260                              <1> 	;
 49261                              <1> 	; Modified Registers: EAX (at the return of system call)
 49262                              <1> 	;  
 49263                              <1> 
 49264 0000D1D7 80F901              <1> 	cmp	cl, 1 ; read file (0), write file (1)
 49265 0000D1DA 7614                <1> 	jna	short sysopen_0
 49266                              <1> 
 49267                              <1> 	; 17/04/2021 (temporary)
 49268                              <1> 	;cmp	cl, 3
 49269                              <1> 	;jna	sysopen_device
 49270                              <1> 
 49271                              <1> 	; Invalid access code
 49272 0000D1DC B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
 49273                              <1> 	;jmp	sysopen_dev_err
 49274                              <1> 
 49275                              <1> sysopen_dev_err:
 49276 0000D1E1 A3[1C010300]        <1> 	mov	[u.r0], eax
 49277 0000D1E6 A3[84010300]        <1> 	mov	[u.error], eax
 49278 0000D1EB E9E2FAFFFF          <1> 	jmp	error
 49279                              <1> 
 49280                              <1> sysopen_0:
 49281                              <1> 	;mov	[u.namep], ebx
 49282 0000D1F0 51                  <1> 	push	ecx
 49283 0000D1F1 89DE                <1> 	mov	esi, ebx
 49284                              <1> 	; file name is forced, change directory as temporary
 49285                              <1> 	;mov	ax, 1
 49286                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 49287                              <1> 	;call	set_working_path 
 49288 0000D1F3 E8474F0000          <1> 	call	set_working_path_x ; 17/10/2016	
 49289 0000D1F8 731E                <1> 	jnc	short sysopen_1
 49290                              <1> 
 49291                              <1> syscreat_err: ; ecx = file attributes (for 'syscreat')
 49292 0000D1FA 59                  <1> 	pop	ecx ; open mode  
 49293 0000D1FB 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 49294 0000D1FD 7505                <1> 	jnz	short sysopen_err
 49295                              <1> 	; eax = 0
 49296 0000D1FF B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 49297                              <1> sysopen_err:
 49298 0000D204 A3[1C010300]        <1> 	mov	[u.r0], eax
 49299 0000D209 A3[84010300]        <1> 	mov	[u.error], eax
 49300 0000D20E E801500000          <1> 	call 	reset_working_path
 49301 0000D213 E9BAFAFFFF          <1> 	jmp	error
 49302                              <1> 
 49303                              <1> sysopen_1:
 49304                              <1> 	;mov	esi, FindFile_Name
 49305 0000D218 66B80018            <1>         mov	ax, 1800h ; Only files 
 49306 0000D21C E8F0B7FFFF          <1> 	call	find_first_file
 49307 0000D221 5A                  <1> 	pop	edx
 49308 0000D222 72E0                <1> 	jc	short sysopen_err ; eax = 2 (File not found !)
 49309                              <1> 
 49310                              <1> 	; check_open_file_attr_access_code
 49311                              <1> 
 49312 0000D224 F6C307              <1>         test	bl, 7  ; system, hidden, readonly 
 49313 0000D227 740B                <1>         jz	short sysopen_2
 49314                              <1> 
 49315 0000D229 20D2                <1> 	and	dl, dl ; 0 = read mode
 49316 0000D22B 7407                <1> 	jz	short sysopen_2
 49317                              <1> 
 49318                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
 49319 0000D22D B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
 49320 0000D232 EBD0                <1>         jmp	short sysopen_err
 49321                              <1> 
 49322                              <1> sysopen_2:
 49323                              <1> 	; esi = Directory Entry (FindFile_DirEntry) Location
 49324 0000D234 89F3                <1> 	mov	ebx, esi
 49325 0000D236 31F6                <1>         xor     esi, esi ; 0
 49326 0000D238 31FF                <1>         xor     edi, edi ; 0
 49327                              <1> sysopen_3: ; scan the list of entries in fsp table
 49328 0000D23A 80BE[26010300]00    <1>         cmp     byte [esi+u.fp], 0
 49329 0000D241 760F                <1>         jna     short sysopen_4 ; empty slot
 49330 0000D243 6646                <1>         inc     si
 49331 0000D245 6683FE0A            <1>         cmp     si, 10
 49332 0000D249 72EF                <1> 	jb	short sysopen_3
 49333                              <1> toomanyf:
 49334 0000D24B B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
 49335 0000D250 EBB2                <1> 	jmp	short sysopen_err
 49336                              <1> 
 49337                              <1> sysopen_4: 
 49338 0000D252 80BF[DC840100]00    <1>         cmp     byte [edi+OF_MODE], 0 ; Scan open files table 
 49339 0000D259 760A                <1> 	jna     short sysopen_5
 49340 0000D25B 6647                <1> 	inc	di
 49341 0000D25D 6683FF20            <1> 	cmp     di, OPENFILES ; max. number of open files (sytem)
 49342 0000D261 72EF                <1> 	jb	short sysopen_4
 49343 0000D263 EBE6                <1> 	jmp	short toomanyf
 49344                              <1> 
 49345                              <1> sysopen_5:
 49346 0000D265 FEC2                <1> 	inc	dl
 49347 0000D267 8897[DC840100]      <1>         mov     [edi+OF_MODE], dl
 49348 0000D26D 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 49349 0000D273 8897[BC840100]      <1>         mov     [edi+OF_DRIVE], dl ; Logical DOS drive number
 49350                              <1> 	;shl	di, 2 ; *4 (dword offset)
 49351                              <1> 	; 23/07/2022
 49352 0000D279 C1E702              <1> 	shl	edi, 2
 49353                              <1> 
 49354 0000D27C 8987[BC850100]      <1> 	mov	[edi+OF_SIZE], eax ; File size in bytes
 49355                              <1> 
 49356 0000D282 668B4314            <1>         mov 	ax, [ebx+DirEntry_FstClusHI]
 49357 0000D286 C1E010              <1> 	shl	eax, 16
 49358 0000D289 668B431A            <1> 	mov 	ax, [ebx+DirEntry_FstClusLO]
 49359 0000D28D 8987[3C840100]      <1> 	mov     [edi+OF_FCLUSTER], eax ; First cluster
 49360 0000D293 8987[BC870100]      <1> 	mov     [edi+OF_CCLUSTER], eax ; Current cluster
 49361                              <1> 
 49362 0000D299 31DB                <1>         xor	ebx, ebx
 49363 0000D29B 899F[3C850100]      <1>         mov     [edi+OF_POINTER], ebx ; offset pointer (0)
 49364 0000D2A1 899F[3C880100]      <1>         mov     [edi+OF_CCINDEX], ebx ; cluster index (0)
 49365                              <1> 
 49366 0000D2A7 A1[54810100]        <1> 	mov	eax, [FindFile_DirFirstCluster]
 49367 0000D2AC 8987[3C860100]      <1> 	mov	[edi+OF_DIRFCLUSTER], eax
 49368                              <1> 
 49369 0000D2B2 A1[58810100]        <1> 	mov	eax, [FindFile_DirCluster]
 49370 0000D2B7 8987[BC860100]      <1> 	mov	[edi+OF_DIRCLUSTER], eax
 49371                              <1> 
 49372                              <1> 	; Get (& Save) Volume ID 
 49373                              <1> 	; Important for files of removable drives
 49374                              <1> 	; (In order to check the drive has same volume/disk)
 49375 0000D2BD 88D7                <1> 	mov	bh, dl
 49376 0000D2BF 81C300010900        <1>         add	ebx, Logical_DOSDisks
 49377 0000D2C5 8A4303              <1>         mov	al, [ebx+LD_FATType]
 49378 0000D2C8 3C01                <1>         cmp	al, 1
 49379 0000D2CA 7209                <1>         jb	short sysopen_6_fs
 49380 0000D2CC 3C02                <1>         cmp	al, 2
 49381 0000D2CE 770A                <1>         ja	short sysopen_6_fat32
 49382                              <1> sysopen_6_fat:
 49383 0000D2D0 8B432D              <1>         mov	eax, [ebx+LD_BPB+VolumeID]
 49384 0000D2D3 EB08                <1>         jmp	short sysopen_7
 49385                              <1> sysopen_6_fs:
 49386 0000D2D5 8B4328              <1>         mov	eax, [ebx+LD_FS_VolumeSerial]
 49387 0000D2D8 EB03                <1>         jmp	short sysopen_7
 49388                              <1> sysopen_6_fat32:
 49389 0000D2DA 8B4349              <1>         mov	eax, [ebx+LD_BPB+FAT32_VolID]
 49390                              <1> sysopen_7:
 49391 0000D2DD A3[38780100]        <1>         mov	[Current_VolSerial], eax
 49392                              <1> 
 49393 0000D2E2 8987[3C870100]      <1> 	mov	[edi+OF_VOLUMEID], eax
 49394                              <1> 
 49395                              <1> 	; 24/10/2016
 49396                              <1> 	;shr	di, 1 ; 4/2, word offset
 49397                              <1> 	; 23/07/2022
 49398 0000D2E8 D1EF                <1> 	shr	edi, 1
 49399 0000D2EA 668B1D[5C810100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
 49400 0000D2F1 66899F[BC880100]    <1> 	mov	[edi+OF_DIRENTRY], bx
 49401                              <1> 
 49402 0000D2F8 31D2                <1> 	xor	edx, edx
 49403                              <1> 	;;shr	di, 2 ; /4 (byte offset)
 49404                              <1> 	;shr	di, 1 ; 2/2, byte offset
 49405                              <1> 	; 23/07/2022
 49406 0000D2FA D1EF                <1> 	shr	edi, 1
 49407 0000D2FC 8897[1C850100]      <1> 	mov	byte [edi+OF_OPENCOUNT], dl ; 0
 49408 0000D302 8897[FC840100]      <1> 	mov	byte [edi+OF_STATUS], dl ; 0
 49409                              <1> 
 49410 0000D308 89FB                <1> 	mov	ebx, edi
 49411 0000D30A FEC3                <1> 	inc	bl
 49412                              <1> 
 49413 0000D30C 889E[26010300]      <1>         mov     [esi+u.fp], bl ; Open File Entry Number
 49414 0000D312 8935[1C010300]      <1> 	mov     [u.r0], esi ; move index to u.fp list 
 49415                              <1> 			    ; into eax on stack
 49416                              <1> 
 49417 0000D318 E8F74E0000          <1>         call 	reset_working_path
 49418                              <1>         
 49419 0000D31D E9D0F9FFFF          <1> 	jmp	sysret
 49420                              <1> 
 49421                              <1> 
 49422                              <1> ; fsp table (original UNIX v1)
 49423                              <1> ;
 49424                              <1> ;Entry
 49425                              <1> ;          15                                      0
 49426                              <1> ;  1     |---|---------------------------------------|
 49427                              <1> ;        |r/w|       i-number of open file           |
 49428                              <1> ;        |---|---------------------------------------| 
 49429                              <1> ;        |               device number               |
 49430                              <1> ;        |-------------------------------------------|
 49431                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
 49432                              <1> ;        |-------------------------------------------| 
 49433                              <1> ;        |  flag that says    | number of processes  |
 49434                              <1> ;        |   file deleted     | that have file open  |
 49435                              <1> ;        |-------------------------------------------| 
 49436                              <1> ;  2     |                                           |
 49437                              <1> ;        |-------------------------------------------| 
 49438                              <1> ;        |                                           |
 49439                              <1> ;        |-------------------------------------------|
 49440                              <1> ;        |                                           |
 49441                              <1> ;        |-------------------------------------------|
 49442                              <1> ;        |                                           |
 49443                              <1> ;        |-------------------------------------------| 
 49444                              <1> ;  3     |                                           | 
 49445                              <1> ;        |                                           |  
 49446                              <1> ;
 49447                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
 49448                              <1> 
 49449                              <1> ; 27/03/2020 - Retro UNIX 386 v2 - FSP (OPEN FILES) TABLE 
 49450                              <1> 
 49451                              <1> ;Entry
 49452                              <1> ;         15                    7                   0
 49453                              <1> ;  1     |-------------------------------------------|
 49454                              <1> ;        |   	     i-number of open file           |
 49455                              <1> ;        |-------------------------------------------| 
 49456                              <1> ;        |        high word of 32 bit i-number       |
 49457                              <1> ;        |-------------------------------------------|
 49458                              <1> ;        | open mode & status  |   device number     |
 49459                              <1> ;        |-------------------------------------------|
 49460                              <1> ;        |    reserved byte    |     open count      |
 49461                              <1> ;        |-------------------------------------------| 
 49462                              <1> ;        | offset pointer, i.e., r/w pointer to file |
 49463                              <1> ;        |-------------------------------------------|
 49464                              <1> ;        |   64 bit file offset pointer (bit 16-31)  | 
 49465                              <1> ;        |-------------------------------------------|
 49466                              <1> ;        |   64 bit file offset pointer (bit 32-47)  | 
 49467                              <1> ;        |-------------------------------------------|
 49468                              <1> ;        |   64 bit file offset pointer (bit 48-63)  | 
 49469                              <1> ;        |-------------------------------------------|
 49470                              <1> ;  2     |                                           |
 49471                              <1> ;        |-------------------------------------------| 
 49472                              <1> ;        |                                           |
 49473                              <1> ;        |-------------------------------------------|
 49474                              <1> ;        |                                           |
 49475                              <1> ;        |-------------------------------------------|
 49476                              <1> ;        |                                           |
 49477                              <1> ;        |-------------------------------------------| 
 49478                              <1> ;        |                                           | 
 49479                              <1> 
 49480                              <1> ; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 49481                              <1> ; OPENFILES equ 10 (sysdefs.s)
 49482                              <1> ;; 06/10/2016
 49483                              <1> ;; Open File Parameters (trdoskx.s)
 49484                              <1> ;OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
 49485                              <1> ;OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
 49486                              <1> ;OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
 49487                              <1> ;OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
 49488                              <1> ;OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
 49489                              <1> ;OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
 49490                              <1> ;OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
 49491                              <1> ;OF_DIRFCLUSTER: resd OPENFILES  ; Directory First Clusters of open files
 49492                              <1> ;OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
 49493                              <1> ;OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
 49494                              <1> ;OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
 49495                              <1> ;OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
 49496                              <1> ;; 24/10/2016
 49497                              <1> ;OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster
 49498                              <1> 
 49499                              <1> ; 17/04/2021
 49500                              <1> ; ('sysopen_device' procedure is disabled as temporary)
 49501                              <1> 
 49502                              <1> ;sysopen_device:
 49503                              <1> ;	; 15/10/2016
 49504                              <1> ;	; 08/10/2016
 49505                              <1> ;	; 07/10/2016 (TRDOS 386 = TRDOS v2.0)
 49506                              <1> ;	push	ecx ; open mode
 49507                              <1> ;	mov	ebp, esp
 49508                              <1> ;	mov	ecx, 16 ; transfer length = 16 bytes 
 49509                              <1> ;	sub	esp, ecx
 49510                              <1> ;	mov	edi, esp ; destination address 
 49511                              <1> ;	mov 	esi, ebx ; dev name in user's memory space
 49512                              <1> ;	call	transfer_from_user_buffer
 49513                              <1> ;	jnc	short sysopen_dev_0
 49514                              <1> ;	; eax = ERR_OUT_OF_MEMORY = 4 = ERR_MINOR_IM
 49515                              <1> ;	pop	ecx
 49516                              <1> ;sysopen_dev_err:
 49517                              <1> ;	mov	[u.r0], eax
 49518                              <1> ;	mov	[u.error], eax
 49519                              <1> ;	jmp	error
 49520                              <1> ;sysopen_dev_0:
 49521                              <1> ;	mov	esi, edi ; Device name addr (max. 16 bytes, ASCIIZ) 
 49522                              <1> ;			 ; for example: "tty, TTY, /dev/tty"
 49523                              <1> ;	call	get_device_number
 49524                              <1> ;	mov	esp, ebp
 49525                              <1> ;	pop	ecx
 49526                              <1> ;	jnc	short sysopen_dev_1
 49527                              <1> ;	mov	eax, ERR_INV_DEV_NAME ; 24 ; 'invalid device name !'
 49528                              <1> ;	jmp	short sysopen_dev_err
 49529                              <1> ;sysopen_dev_1:
 49530                              <1> ;	; eax = Device Number (AL)
 49531                              <1> ;	;  cl = Open mode (2 = device read, 3 = device write)
 49532                              <1> ;       xor     ebx, ebx ; 0
 49533                              <1> ;sysopen_dev_2: ; scan the list of entries
 49534                              <1> ;       cmp     [ebx+u.fp], bl ; 0
 49535                              <1> ;       jna     short sysopen_dev_3 ; empty slot
 49536                              <1> ;       inc     bl
 49537                              <1> ;       cmp     bl, 10
 49538                              <1> ;	jb	short sysopen_dev_2
 49539                              <1> ;	;
 49540                              <1> ;	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
 49541                              <1> ;	jmp	short sysopen_dev_err
 49542                              <1> ;sysopen_dev_3:
 49543                              <1> ;	mov 	[u.r0], ebx ; File/Device index/handle/descriptor
 49544                              <1> ;	; eax = device number (entry offset)
 49545                              <1> ;	mov	ch, [eax+DEV_ACCESS] ; bit 0 = accessable by users
 49546                              <1> ;				     ; bit 1 = read access perm
 49547                              <1> ;				     ; bit 2 = write access perm
 49548                              <1> ;				     ; bit 3 = IOCTL permit to users
 49549                              <1> ;				     ; bit 4 = block device if set
 49550                              <1> ;				     ; bit 5 = 16 bit or 1024 byte
 49551                              <1> ;				     ; bit 6 = 32 bit or 2048 byte
 49552                              <1> ;				     ; bit 7 = installable device drv
 49553                              <1> ;	test 	ch, 1 ; accessable by normal users (except root)
 49554                              <1> ;	jnz	short sysopen_dev_4 ; yes, permission has been given
 49555                              <1> ;	cmp	byte [u.uid], 0 ; root?
 49556                              <1> ;	jna	short sysopen_dev_4 ; superuser can open all devices
 49557                              <1> ;sysopen_dev_perm_err:
 49558                              <1> ;	mov	eax, ERR_DEV_ACCESS  ; 11 = 'permission denied !'
 49559                              <1> ;	jmp	short sysopen_dev_err
 49560                              <1> ;sysopen_dev_4:
 49561                              <1> ;	shr	ch, 1 ; result: 1 = read, 2 = write, 3 = r & w 
 49562                              <1> ;	dec	cl  ; result: 1 = read, 2 = write
 49563                              <1> ;	test	cl, ch
 49564                              <1> ;	jz	short sysopen_dev_perm_err 
 49565                              <1> ;
 49566                              <1> ;	shl	ch, 1 ; bit 0 = 0
 49567                              <1> ;	; eax = device number (entry offset)
 49568                              <1> ;	call	device_open
 49569                              <1> ;	jc	short sysopen_dev_perm_err 
 49570                              <1> ;
 49571                              <1> ;	; eax = device number (entry offset)
 49572                              <1> ;	or	al, 80h ; set device bit (set bit 7 to 1)
 49573                              <1> ;	mov	ebx, [u.r0]
 49574                              <1> ;	mov	[ebx+u.fp], al	; bit 7 (=1) points to device	
 49575                              <1> ;	
 49576                              <1> ;	jmp	sysret
 49577                              <1> 
 49578                              <1> sysmkdir: ; < make directory >
 49579                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5 
 49580                              <1> 	; 15/10/2016
 49581                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49582                              <1> 	;	     -derived from INT_21H.ASM-
 49583                              <1> 	;            ("loc_INT21h_create_file")
 49584                              <1>         ; 	10/07/2011 (12/03/2011)
 49585                              <1>         ;	INT 21h Function AH = 3Ch
 49586                              <1>         ;	Create File
 49587                              <1>         ;	INPUT
 49588                              <1>         ;	   CX = Attributes
 49589                              <1>         ;          DS:DX= Address of zero terminaned path name
 49590                              <1>         ;
 49591                              <1>         ;
 49592                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
 49593                              <1> 	; 27/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
 49594                              <1> 	;
 49595                              <1> 	; 'sysmkdir' creates an empty directory whose name is
 49596                              <1> 	; pointed to by arg 1. The mode of the directory is arg 2.	
 49597                              <1> 	; The special entries '.' and '..' are not present.
 49598                              <1> 	; Errors are indicated if the directory already exists or		
 49599                              <1> 	; user is not the super user. 
 49600                              <1> 	;
 49601                              <1> 	; Calling sequence:
 49602                              <1> 	;	sysmkdir; name; mode
 49603                              <1> 	; Arguments:
 49604                              <1> 	;	name - points to the name of the directory
 49605                              <1> 	;	mode - mode of the directory
 49606                              <1> 	; Inputs: (arguments)
 49607                              <1> 	; Outputs: -
 49608                              <1> 	;    (sets 'directory' flag to 1; 
 49609                              <1> 	;    'set user id on execution' and 'executable' flags to 0)
 49610                              <1> 	; ...............................................................
 49611                              <1> 	;				
 49612                              <1> 	; Retro UNIX 8086 v1 modification: 
 49613                              <1> 	;       'sysmkdir' system call has two arguments; so,
 49614                              <1> 	;	* 1st argument, name is pointed to by BX register
 49615                              <1> 	;	* 2nd argument, mode is in CX register
 49616                              <1> 	;
 49617                              <1> 	; TRDOS 386 (10/10/2016)
 49618                              <1> 	;	
 49619                              <1>         ; INPUT ->
 49620                              <1>         ;	   CL = Directory Attributes
 49621                              <1> 	;     	      bit 0 (1) - Read only file/dir (R)
 49622                              <1> 	;             bit 1 (1) - Hidden file/dir (H)
 49623                              <1>         ;             bit 2 (1) - System file/dir (R)
 49624                              <1> 	;             bit 3 (1) - Volume label/name (V)
 49625                              <1>         ;             bit 4 (1) - Subdirectory (D)
 49626                              <1> 	;	      bit 5 (1) - File/Dir has been archived (A)
 49627                              <1> 	;	   CX = 0 -> create normal directory	 	
 49628                              <1>         ;          EBX = Pointer to directory name (ASCIIZ) -path-
 49629                              <1> 	;	
 49630                              <1> 	; OUTPUT ->
 49631                              <1> 	;          eax = First cluster of the new directory
 49632                              <1> 	;          cf = 1 -> Error code in AL
 49633                              <1> 	;
 49634                              <1> 	; Modified Registers: EAX (at the return of system call)
 49635                              <1> 	;  
 49636                              <1> 	; Note: If the file or directory is existing
 49637                              <1> 	;	an access error will be returned. 
 49638                              <1> 
 49639 0000D322 6621C9              <1> 	and	cx, cx ; if cx = 0 -> create a normal subdir
 49640 0000D325 7414                <1> 	jz	short sysmkdir_1
 49641                              <1> 
 49642 0000D327 F6C110              <1> 	test	cl, 10h ; if dir flags set, also use other flags
 49643                              <1> 	;jnz	sysmkdir_0 ; jump to head of 'syscreat'
 49644                              <1> 	; 23/07/2022
 49645 0000D32A 7405                <1> 	jz	short sysmkdir_invf
 49646                              <1> sysmkdir_3:
 49647 0000D32C E9D3FDFFFF          <1> 	jmp	sysmkdir_0
 49648                              <1> 
 49649                              <1> sysmkdir_invf:
 49650                              <1> 	; CX has wrong flags
 49651 0000D331 B817000000          <1> 	mov 	eax, ERR_INV_FLAGS
 49652 0000D336 E9A6FEFFFF          <1> 	jmp	sysopen_dev_err
 49653                              <1> 
 49654                              <1> sysmkdir_1:
 49655 0000D33B B110                <1> 	mov	cl, 10h ; set subdir flag and reset other flags
 49656                              <1> 	;jmp	sysmkdir_0
 49657                              <1> 	; 23/07/2022
 49658 0000D33D EBED                <1> 	jmp	short sysmkdir_3 ; jump to head of 'syscreat'
 49659                              <1> sysmkdir_2: 
 49660                              <1> 	; jump from 'syscreat' ; from 'syscreat_1'
 49661                              <1> 	;  CL = Directory attributes/flags  
 49662 0000D33F BE[24810100]        <1> 	mov	esi, FindFile_Name 
 49663 0000D344 E882D8FFFF          <1> 	call	make_sub_directory
 49664                              <1> 	;jc	sysopen_err       ; NOTE: Old type (TRDOS 8086)
 49665                              <1> 				  ; error codes must be modified
 49666                              <1> 				  ; for next TRDOS 386 versions
 49667                              <1> 				  ; (10/10/2016)
 49668                              <1> 				  ; Old (MSDOS type)
 49669                              <1> 				  ; error codes (2011):
 49670                              <1> 				  ;  2 = file not found
 49671                              <1> 				  ;  3 = directory not found
 49672                              <1> 				  ;  5 = access denied
 49673                              <1> 				  ; 12 = no more files
 49674                              <1> 			          ; 19 = disk write protected   
 49675                              <1> 				  ; 39 = insufficient disk space
 49676                              <1> 				  ; 'sysdefs.s' ; 10/10/2016  	
 49677                              <1> 	; 23/07/2022
 49678 0000D349 7305                <1> 	jnc	short sysmkdir_4
 49679 0000D34B E9B4FEFFFF          <1> 	jmp	sysopen_err
 49680                              <1> 
 49681                              <1> sysmkdir_4:	
 49682 0000D350 A3[1C010300]        <1> 	mov	[u.r0], eax ; New sub dir's first cluster
 49683 0000D355 E8BA4E0000          <1>         call 	reset_working_path
 49684 0000D35A E993F9FFFF          <1> 	jmp	sysret	
 49685                              <1> 
 49686                              <1> sysclose: ;<close file>
 49687                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 49688                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49689                              <1> 	;
 49690                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
 49691                              <1> 	; 22/05/2013 - 26/05/2013 (Retro UNIX 8086 v1)
 49692                              <1> 	;
 49693                              <1> 	; 'sysclose', given a file descriptor in 'u.r0', closes the
 49694                              <1> 	; associated file. The file descriptor (index to 'u.fp' list)
 49695                              <1> 	; is put in r1 and 'fclose' is called.
 49696                              <1> 	;
 49697                              <1> 	; Calling sequence:
 49698                              <1> 	;	sysclose
 49699                              <1> 	; Arguments:
 49700                              <1> 	;	-  
 49701                              <1> 	; Inputs: *u.r0 - file descriptor
 49702                              <1> 	; Outputs: -
 49703                              <1> 	; ...............................................................
 49704                              <1> 	;				
 49705                              <1> 	; Retro UNIX 8086 v1 modification:
 49706                              <1> 	;	 The user/application program puts file descriptor
 49707                              <1> 	;        in BX register as 'sysclose' system call argument.
 49708                              <1> 	; 	 (argument transfer method 1)
 49709                              <1> 
 49710                              <1> 	; TRDOS 386 (06/10/2016)
 49711                              <1> 	;	
 49712                              <1>         ; INPUT ->
 49713                              <1>         ;	   EBX = File Handle/Number (file index) (AL)
 49714                              <1> 	; OUTPUT ->
 49715                              <1> 	;          cf = 0 -> EAX = 0
 49716                              <1> 	;          cf = 1 -> Error code in EAX (ERR_FILE_NOT_OPEN)
 49717                              <1> 	;
 49718                              <1> 	; Modified Registers: EAX (at the return of system call)
 49719                              <1> 	;  
 49720                              <1> 
 49721 0000D35F 89D8                <1> 	mov 	eax, ebx
 49722 0000D361 31DB                <1> 	xor	ebx, ebx	
 49723 0000D363 891D[1C010300]      <1> 	mov	[u.r0], ebx ; 0  ; return value of EAX
 49724 0000D369 E831310000          <1> 	call 	fclose
 49725                              <1> 	;jnc	sysret
 49726                              <1> 	; 23/07/2022
 49727 0000D36E 7205                <1> 	jc	short sysclose_err
 49728 0000D370 E97DF9FFFF          <1> 	jmp	sysret
 49729                              <1> sysclose_err:
 49730 0000D375 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
 49731 0000D37A A3[84010300]        <1> 	mov	[u.error], eax ;
 49732 0000D37F A3[1C010300]        <1> 	mov	[u.r0], eax ; ! invalid handle !
 49733 0000D384 E949F9FFFF          <1> 	jmp	error
 49734                              <1> 
 49735                              <1> sysread: ; < read from file >
 49736                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49737                              <1> 	;	     -derived from INT_21H.ASM-
 49738                              <1> 	;            ("loc_INT21h_read_file")
 49739                              <1>         ; 	13/03/2011 (05/03/2011)
 49740                              <1>         ;	INT 21h Function AH = 3Fh
 49741                              <1>         ;	Read from a File
 49742                              <1>         ;	INPUT
 49743                              <1> 	;	   BX = File Handle
 49744                              <1>         ;	   CX = Number of bytes to read
 49745                              <1>         ;          DS:DX= Buffer address
 49746                              <1>         ;
 49747                              <1> 	; Note: TRDOS 386 'sysread' has been derived from 
 49748                              <1> 	;	Retro UNIX 386 v1 'sysread', except a few 
 49749                              <1> 	;	code modifications.
 49750                              <1> 	;
 49751                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
 49752                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 49753                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
 49754                              <1> 	;
 49755                              <1> 	; 'sysread' is given a buffer to read into and the number of
 49756                              <1> 	; characters to be read. If finds the file from the file
 49757                              <1> 	; descriptor located in *u.r0 (r0). This file descriptor
 49758                              <1> 	; is returned from a successful open call (sysopen).
 49759                              <1> 	; The i-number of file is obtained via 'rw1' and the data
 49760                              <1> 	; is read into core via 'readi'.
 49761                              <1> 	;
 49762                              <1> 	; Calling sequence:
 49763                              <1> 	;	sysread; buffer; nchars
 49764                              <1> 	; Arguments:
 49765                              <1> 	;	buffer - location of contiguous bytes where 
 49766                              <1> 	;		 input will be placed.
 49767                              <1> 	;	nchars - number of bytes or characters to be read.
 49768                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
 49769                              <1> 	; Outputs: *u.r0 - number of bytes read.	
 49770                              <1> 	; ...............................................................
 49771                              <1> 	;				
 49772                              <1> 	; Retro UNIX 8086 v1 modification: 
 49773                              <1> 	;       'sysread' system call has three arguments; so,
 49774                              <1> 	;	* 1st argument, file descriptor is in BX register
 49775                              <1> 	;	* 2nd argument, buffer address/offset in CX register
 49776                              <1> 	;	* 3rd argument, number of bytes is in DX register
 49777                              <1> 	;
 49778                              <1> 	;	AX register (will be restored via 'u.r0') will return
 49779                              <1> 	;	to the user with number of bytes read. 
 49780                              <1> 	;
 49781                              <1> 	; TRDOS 386 (05/10/2016)
 49782                              <1> 	;	
 49783                              <1>         ; INPUT ->
 49784                              <1>         ;	   EBX = File handle (descriptor/index)
 49785                              <1> 	;	   ECX = Buffer address		
 49786                              <1>         ;          EDX = Number of bytes
 49787                              <1> 	; OUTPUT ->
 49788                              <1> 	;          EAX = Number of bytes have been read
 49789                              <1> 	;          cf = 1 -> Error code in AL
 49790                              <1> 	;
 49791                              <1> 	; Modified Registers: EAX (at the return of system call)
 49792                              <1> 	; 
 49793                              <1> 
 49794                              <1> 	; EBX = File descriptor
 49795 0000D389 E85F310000          <1> 	call	getf1 
 49796 0000D38E 7273                <1> 	jc	short device_read ; read data from device
 49797                              <1> 	; EAX = First cluster of the file
 49798                              <1> 
 49799 0000D390 E83F000000          <1> 	call	rw1
 49800 0000D395 730A                <1> 	jnc	short sysread_0
 49801                              <1> 
 49802 0000D397 A3[1C010300]        <1> 	mov	[u.r0], eax ; error code
 49803 0000D39C E931F9FFFF          <1> 	jmp	error
 49804                              <1> 	 
 49805                              <1> sysread_0:
 49806 0000D3A1 E8CC340000          <1> 	call	readi
 49807 0000D3A6 EB1D                <1> 	jmp	short rw0
 49808                              <1> 
 49809                              <1> syswrite: ; < write to file >
 49810                              <1> 	; 23/10/2016
 49811                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49812                              <1> 	;	     -derived from INT_21H.ASM-
 49813                              <1> 	;            ("loc_INT21h_write_file")
 49814                              <1>         ; 	13/03/2011 (05/03/2011)
 49815                              <1>         ;	INT 21h Function AH = 40h
 49816                              <1>         ;	Write to a File
 49817                              <1>         ;	INPUT
 49818                              <1> 	;	   BX = File Handle
 49819                              <1>         ;	   CX = Number of bytes to write
 49820                              <1>         ;          DS:DX= Buffer address
 49821                              <1>         ;
 49822                              <1> 	; Note: TRDOS 386 'sysrwrite' has been derived from 
 49823                              <1> 	;	Retro UNIX 386 v1 'syswrite', except a few 
 49824                              <1> 	;	code modifications.
 49825                              <1> 	;
 49826                              <1> 
 49827                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
 49828                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 49829                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
 49830                              <1> 	;
 49831                              <1> 	; 'syswrite' is given a buffer to write onto an output file
 49832                              <1> 	; and the number of characters to write. If finds the file
 49833                              <1> 	; from the file descriptor located in *u.r0 (r0). This file 
 49834                              <1> 	; descriptor is returned from a successful open or create call
 49835                              <1> 	; (sysopen or syscreat). The i-number of file is obtained via
 49836                              <1> 	; 'rw1' and buffer is written on the output file via 'write'.
 49837                              <1> 	;
 49838                              <1> 	; Calling sequence:
 49839                              <1> 	;	syswrite; buffer; nchars
 49840                              <1> 	; Arguments:
 49841                              <1> 	;	buffer - location of contiguous bytes to be writtten.
 49842                              <1> 	;	nchars - number of characters to be written.
 49843                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
 49844                              <1> 	; Outputs: *u.r0 - number of bytes written.	
 49845                              <1> 	; ...............................................................
 49846                              <1> 	;				
 49847                              <1> 	; Retro UNIX 8086 v1 modification: 
 49848                              <1> 	;       'syswrite' system call has three arguments; so,
 49849                              <1> 	;	* 1st argument, file descriptor is in BX register
 49850                              <1> 	;	* 2nd argument, buffer address/offset in CX register
 49851                              <1> 	;	* 3rd argument, number of bytes is in DX register
 49852                              <1> 	;
 49853                              <1> 	;	AX register (will be restored via 'u.r0') will return
 49854                              <1> 	;	to the user with number of bytes written. 
 49855                              <1> 	;
 49856                              <1> 	; INPUT ->
 49857                              <1>         ;	   EBX = File handle (descriptor/index)
 49858                              <1> 	;	   ECX = Buffer address		
 49859                              <1>         ;          EDX = Number of bytes
 49860                              <1> 	; OUTPUT ->
 49861                              <1> 	;          EAX = Number of bytes have been written
 49862                              <1> 	;          cf = 1 -> Error code in AL
 49863                              <1> 	;
 49864                              <1> 	; Modified Registers: EAX (at the return of system call)
 49865                              <1> 	;  
 49866                              <1> 
 49867                              <1> 	; EBX = File descriptor
 49868 0000D3A8 E840310000          <1> 	call	getf1 
 49869 0000D3AD 7254                <1> 	jc	short device_write ; write data to device
 49870                              <1> 	; EAX = First cluster of the file
 49871                              <1> 	; EBX = File number  (Open file number) ; 23/10/2016
 49872                              <1> 
 49873 0000D3AF E820000000          <1> 	call	rw1
 49874 0000D3B4 730A                <1> 	jnc	short syswrite_0
 49875 0000D3B6 A3[1C010300]        <1> 	mov	[u.r0], eax ; error code
 49876 0000D3BB E912F9FFFF          <1> 	jmp	error
 49877                              <1> 	 
 49878                              <1> syswrite_0:
 49879 0000D3C0 E8C73B0000          <1> 	call	writei
 49880                              <1> rw0: ; 1:
 49881 0000D3C5 A1[48010300]        <1>         mov	eax, [u.nread]
 49882 0000D3CA A3[1C010300]        <1> 	mov	[u.r0], eax
 49883 0000D3CF E91EF9FFFF          <1> 	jmp	sysret
 49884                              <1> rw1:	
 49885                              <1> 	; 17/04/2021 (TRDOS 386 v2.0.4)
 49886                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
 49887                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
 49888                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 49889                              <1> 	; 23/05/2013 - 24/05/2013 (Retro UNIX 8086 v1)
 49890                              <1> 	; System call registers: ebx, ecx, edx (through 'sysenter')
 49891                              <1> 	;
 49892                              <1> 	; EBX = File descriptor
 49893                              <1> 	;call	getf1 ; calling point in 'getf' from 'rw1'
 49894                              <1> 	;jc	short device_rw ; read/write data from/to device
 49895                              <1> 	; EAX = First cluster of the file
 49896                              <1> 
 49897 0000D3D4 83F802              <1> 	cmp 	eax, 2
 49898 0000D3D7 7217                <1> 	jb	short rw2
 49899                              <1> 	;
 49900 0000D3D9 890D[40010300]      <1> 	mov	[u.base], ecx 	; buffer address/offset 
 49901                              <1> 				;(in the user's virtual memory space)
 49902 0000D3DF 8915[44010300]      <1> 	mov	[u.count], edx 
 49903                              <1> 
 49904 0000D3E5 C705[84010300]0000- <1>         mov	dword [u.error], 0 ; reset the last error code
 49905 0000D3ED 0000                <1>
 49906 0000D3EF C3                  <1> 	retn
 49907                              <1> rw2:
 49908 0000D3F0 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
 49909                              <1> 	;mov	dword [u.error], eax
 49910                              <1> 	;retn
 49911                              <1> 	; 17/04/2021
 49912 0000D3F5 EB06                <1> 	jmp	short rw4
 49913                              <1> rw3: 
 49914 0000D3F7 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS ; permission denied !
 49915 0000D3FC F9                  <1> 	stc
 49916                              <1> rw4:	; 17/04/2021
 49917 0000D3FD A3[84010300]        <1> 	mov	dword [u.error], eax
 49918 0000D402 C3                  <1> 	retn
 49919                              <1> 
 49920                              <1> 	; 17/04/2021 (temporary)
 49921                              <1> device_write:
 49922                              <1> device_read:
 49923                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 49924                              <1> 	;	(temporary modifications)
 49925                              <1> 	;
 49926                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
 49927                              <1> 	; cl = DEV_OPENMODE ; open mode
 49928                              <1> 	; ch = DEV_ACCESS   ; access flags   
 49929                              <1> 	; al = DEV_DRIVER   ; device number (eax)
 49930                              <1> 
 49931                              <1> 	; 17/04/2021 (temporary)
 49932 0000D403 EBEB                <1> 	jmp	short rw2 ; file not open
 49933                              <1> 
 49934                              <1> ;	test	cl, 1 ; 1 = read, 2 = write, 3 = read&write
 49935                              <1> ;	jz	short rw3
 49936                              <1> ;
 49937                              <1> ;	mov	ebx, eax
 49938                              <1> ;	shl	bx, 2 ; *4
 49939                              <1> ;
 49940                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
 49941                              <1> ;	jz	short d_read_2 ; Kernel device
 49942                              <1> ;	; installable device
 49943                              <1> ;d_read_1:
 49944                              <1> ;       jmp	dword [ebx+IDEV_RADDR-4]
 49945                              <1> ;d_read_2:
 49946                              <1> ;	jmp	dword [ebx+KDEV_RADDR-4]
 49947                              <1> 
 49948                              <1> ;device_write:
 49949                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 49950                              <1> 	;	(temporary modifications)
 49951                              <1> 	;
 49952                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
 49953                              <1> 	; cl = DEV_OPENMODE ; open mode
 49954                              <1> 	; ch = DEV_ACCESS   ; access flags   
 49955                              <1> 	; al = DEV_DRIVER   ; device number (eax)
 49956                              <1> 
 49957                              <1> 	; 17/04/2021 (temporary)
 49958                              <1> 	;jmp	short rw2 ; file not open
 49959                              <1> 
 49960                              <1> ;	test	cl, 2 ; 1 = read, 2 = write, 3 = read&write
 49961                              <1> ;	jz	short rw3	
 49962                              <1> ;
 49963                              <1> ;	mov	ebx, eax
 49964                              <1> ;	shl	bx, 2 ; *4
 49965                              <1> ;
 49966                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
 49967                              <1> ;	jz	short d_write_2 ; Kernel device
 49968                              <1> ;	; installable device
 49969                              <1> ;d_write_1:
 49970                              <1> ;       jmp	dword [ebx+IDEV_WADDR-4]
 49971                              <1> ;d_write_2:
 49972                              <1> ;	jmp	dword [ebx+KDEV_WADDR-4]
 49973                              <1> 
 49974                              <1> systimer:
 49975                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 49976                              <1> 	; 02/01/2017
 49977                              <1> 	; 21/12/2016
 49978                              <1> 	; 19/12/2016
 49979                              <1> 	; 10/12/2016 (callback)
 49980                              <1> 	; 10/06/2016
 49981                              <1> 	; 07/06/2016
 49982                              <1> 	; 06/06/2016
 49983                              <1> 	; 21/05/2016
 49984                              <1> 	; 19/05/2016
 49985                              <1> 	; 18/05/2016 - TRDOS 386 (TRDOS v2.0)
 49986                              <1> 	; (TRDOS 386 feature only!)
 49987                              <1> 	;
 49988                              <1> 	; (start or stop timer event(s))	
 49989                              <1> 	;
 49990                              <1> 	; INPUT ->
 49991                              <1> 	;	BL = Signal return byte (response byte)
 49992                              <1> 	;	     (Any requested value between 0 and 255)
 49993                              <1> 	;	     (Kernel will put it at the requested address)
 49994                              <1> 	;	BH = Time count unit
 49995                              <1> 	;	     0 = Stop timer event
 49996                              <1> 	;	     1 = 18.2 ticks per second
 49997                              <1> 	;	     2 = 10 milliseconds
 49998                              <1> 	;	     3 = 1 second (for real time clock interrupt)
 49999                              <1> 	;	     4 = time/tick count in current time count unit
 50000                              <1> 	;	    // 10/12/2016
 50001                              <1> 	;	    80h = Stop timer event (callback method)
 50002                              <1> 	;	    81h = 18.2 ticks per second, callback method
 50003                              <1> 	;	    82h = 10 milliseconds, callback method
 50004                              <1> 	;	    83h = 1 second (for RTC int), callback method
 50005                              <1> 	;	    84h = current time count unit, callback method
 50006                              <1> 	;
 50007                              <1> 	;	    Note: Only 03h or 83h will set real time clock
 50008                              <1> 	;		  (RTC) events (Others are for PIT events)!
 50009                              <1> 	;	
 50010                              <1> 	;	NOTE: If callback (user service) method is used,
 50011                              <1> 	;	    EDX will point to the return address (of service
 50012                              <1> 	;	    procedure) in user's space instead of signal 
 50013                              <1> 	;	    response byte address. (TRDOS 386 kernel will
 50014                              <1> 	;	    direct the cpu to that address -in user's space-
 50015                              <1> 	;	    at the return of system call or interrupt 
 50016                              <1> 	;	    just after the adjusted count/time is elapsed.)
 50017                              <1> 	;	    User's sevice routine must be ended with a
 50018                              <1> 	;	    'iret'. Normal return addresses from system 
 50019                              <1> 	;	    calls or and interrupts will be kept same except
 50020                              <1> 	;	    the timer returns.
 50021                              <1>      	;
 50022                              <1> 	;	BH = 0 -> Stop timer event
 50023                              <1> 	;	BL = Timer event number (1 to 255) if BH = 0
 50024                              <1> 	;	     If BL = 0, all timer events (which are belongs
 50025                              <1> 	;	      to running process) will be stopped
 50026                              <1> 	;	ECX = Time/Tick count (depending on time count unit)
 50027                              <1> 	;	EDX = Signal return (Response) byte address
 50028                              <1> 	;	      (virtual address in user's memory space)
 50029                              <1> 	; OUTPUT ->
 50030                              <1> 	;	AL = Timer event number	(1 to 255) (max. value = 16)
 50031                              <1> 	;	IF BH Input = 0 & CF = 0 & AL = 0 -> 
 50032                              <1> 	;	     timer event(s) has/have been stopped/finished
 50033                              <1> 	;	CF = 1 & AL = 0 -> no timer setting space to set
 50034                              <1> 	;	CF = 1 & AL > 0 -> timer count unit is not usable
 50035                              <1> 	;
 50036                              <1> 	;	NOTE: To modify a time count for a user function,
 50037                              <1> 	;	      at first, current timer event must be stopped
 50038                              <1> 	;	      then a new timer event (which is related with
 50039                              <1> 	;	      same user function) must be started.
 50040                              <1> 	;		
 50041                              <1> 	;	      Signal return (response) byte may be used for 
 50042                              <1> 	;	      several purposes. Kernel will put this value 
 50043                              <1> 	;	      to requested address during timer interrupt,
 50044                              <1> 	;	      program/user can check this value to understand
 50045                              <1> 	;	      which event has been occurred and what is changed.
 50046                              <1> 	;	      (Multi timer events can share same signal address)
 50047                              <1> 	;	
 50048                              <1> 	;	NOTE: If the process is running while the time count
 50049                              <1> 	;	      is reached, kernel will put signal return (response)
 50050                              <1> 	;	      byte value at requested address during timer
 50051                              <1> 	;	      interrupt and the process will continue to run.
 50052                              <1> 	;	      Program/process must call (jump to) it's timer event
 50053                              <1> 	;	      function as required, for checking the timer event
 50054                              <1> 	;	      status via signal return (response) byte address. 
 50055                              <1> 	;
 50056                              <1> 	;	      If the process is not running (waiting or sleeping
 50057                              <1> 	;	      or released) while the time count is reached,
 50058                              <1> 	;	      it is restarted from where it left, to ensure
 50059                              <1> 	;	      proper multi media (video, audio, clock, timer)
 50060                              <1> 	;	      functionality.
 50061                              <1> 	;
 50062                              <1> 	;	      (It is better to use 'syswait' or 'syssleep',
 50063                              <1> 	;	      or 'sysrele' system call just after the timer
 50064                              <1> 	;	      function. Otherwise, timer events may block other
 50065                              <1> 	;	      processes which are not using timer events.)  	 		 			 		 	
 50066                              <1> 	;	     	      		 			
 50067                              <1> 	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
 50068                              <1> 	;       Owner:	        resb 1 ; 0 = free
 50069                              <1> 	;		  	       ;>0 = process number (u.uno)
 50070                              <1> 	;	Calback:	resb 1 ; 1 = callback, 0 = response byte
 50071                              <1> 	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
 50072                              <1> 	;		   	       ; 1 = Real Time Clock interrupt 
 50073                              <1> 	;	Response:       resb 1 ; 0 to 255, signal return value
 50074                              <1> 	;	Count Limit:	resd 1 ; count of ticks (total/set)
 50075                              <1> 	;	Current Count: 	resd 1 ; count of ticks (current)
 50076                              <1> 	;	Response Addr:  resd 1 ; response byte (pointer) address
 50077                              <1> 	;
 50078                              <1> 
 50079                              <1> 	; 19/12/2016 (timer callback)
 50080 0000D405 C605[14890100]00    <1> 	mov	byte [tcallback], 0 
 50081 0000D40C C605[15890100]00    <1> 	mov	byte [trtc], 0
 50082 0000D413 C705[8C010300]0000- <1> 	mov	dword [u.tcb], 0 ; this is not necessary...
 50083 0000D41B 0000                <1>
 50084                              <1> 
 50085 0000D41D 80FF80              <1> 	cmp	bh, 80h
 50086 0000D420 7224                <1> 	jb	short systimer_cb2
 50087 0000D422 7704                <1> 	ja	short systimer_cb0
 50088                              <1> 
 50089 0000D424 31D2                <1> 	xor	edx, edx ; 0, reset callback address
 50090 0000D426 EB0B                <1> 	jmp	short systimer_cb1
 50091                              <1> 
 50092                              <1> systimer_cb0:
 50093 0000D428 80FF84              <1> 	cmp	bh, 84h	
 50094 0000D42B 7764                <1> 	ja	short systimer_5 ;  undefined, error
 50095                              <1> 
 50096                              <1> 	;mov	byte [tcallback], 1 ; 19/12/2016
 50097 0000D42D FE05[14890100]      <1> 	inc	byte [tcallback]
 50098                              <1> 
 50099                              <1> systimer_cb1:
 50100 0000D433 0FB635[6D010300]    <1> 	movzx	esi, byte [u.uno] ; process number
 50101                              <1> 	;shl	si, 2	
 50102                              <1> 	; 23/07/2022
 50103 0000D43A C1E602              <1> 	shl	esi, 2
 50104 0000D43D 8996[BC000300]      <1> 	mov	[esi+p.tcb-4], edx ; set process timer callback address
 50105                              <1> 				   ; (overwrite prev value if it is set!)
 50106 0000D443 80E77F              <1> 	and	bh, 7Fh
 50107                              <1> 
 50108                              <1> systimer_cb2:
 50109 0000D446 80FF02              <1> 	cmp	bh, 2
 50110 0000D449 7446                <1>         je      short systimer_5  ; only 18.2 ticks per second is usable
 50111                              <1> 				  ; 10 milliseconds (100 Hertz) timer 
 50112                              <1> 				  ; will be set later (18/05/2016)
 50113 0000D44B 774C                <1>         ja      short systimer_6 
 50114                              <1> 
 50115 0000D44D 20FF                <1> 	and	bh, bh
 50116                              <1> 	;jz	systimer_9        ; stop timer event(s)
 50117                              <1> 	; 23/07/2022
 50118 0000D44F 7505                <1> 	jnz	short systimer_19
 50119 0000D451 E9BA000000          <1> 	jmp	systimer_9
 50120                              <1> 
 50121                              <1> 	; bh = 1 (timer interrupt, 18.2 Hz, IBM PC/AT ROMBIOS default)
 50122                              <1> 
 50123                              <1> systimer_19:
 50124 0000D456 B00A                <1> 	mov	al, 10 ; (*)
 50125                              <1> 
 50126                              <1> systimer_0:
 50127 0000D458 B710                <1> 	mov	bh, 16
 50128                              <1> 	;
 50129 0000D45A 383D[0F840100]      <1> 	cmp	[timer_events], bh ; 16 ; 07/06/2016
 50130 0000D460 7319                <1> 	jnb 	short systimer_3  ; max. 16 timer events
 50131                              <1> 	;
 50132 0000D462 50                  <1> 	push	eax ; (*)
 50133                              <1> 
 50134 0000D463 BF[2C020300]        <1> 	mov	edi, timer_set  ; beginning address of timer events
 50135                              <1> 				; setting space
 50136 0000D468 30C0                <1> 	xor	al, al ; 0
 50137                              <1> systimer_1:
 50138 0000D46A FEC0                <1> 	inc	al
 50139 0000D46C 803F00              <1> 	cmp	byte [edi], 0 	; is it free space ?
 50140 0000D46F 7639                <1> 	jna	short systimer_7 ; yes
 50141 0000D471 FECF                <1> 	dec	bh
 50142 0000D473 7405                <1> 	jz	short systimer_2
 50143 0000D475 83C710              <1> 	add	edi, 16
 50144 0000D478 EBF0                <1> 	jmp	short  systimer_1 ; next event space
 50145                              <1> 
 50146                              <1> systimer_2:
 50147 0000D47A 58                  <1> 	pop	eax ; (*) discard
 50148                              <1> systimer_3:
 50149 0000D47B C605[1C010300]00    <1> 	mov	byte [u.r0], 0
 50150                              <1> systimer_4:
 50151 0000D482 C705[84010300]1B00- <1>         mov     dword [u.error], ERR_MISC
 50152 0000D48A 0000                <1>
 50153                              <1>                                 ; one of miscellaneous/other errors
 50154 0000D48C E941F8FFFF          <1> 	jmp	error ; cf -> 1
 50155                              <1> 
 50156                              <1> systimer_5:
 50157 0000D491 883D[1C010300]      <1> 	mov	[u.r0], bh ; Time count unit (=2 or >3)
 50158 0000D497 EBE9                <1> 	jmp	short systimer_4 ; 07/06/2016
 50159                              <1> 
 50160                              <1> systimer_6:
 50161 0000D499 80FF04              <1> 	cmp	bh, 4
 50162 0000D49C 77F3                <1>         ja      short systimer_5  ; undefined time count unit
 50163                              <1> 	;jb	short systimer_16	
 50164                              <1> 
 50165                              <1> 	;mov	al, 1	; default (use current timer unit)
 50166                              <1> 			; countdown value is in ECX ! 
 50167                              <1> 			; max. value of ecx = 4294967296/10
 50168                              <1>         ;jmp    short systimer_0
 50169                              <1> 	;jmp	short systimer_19	
 50170 0000D49E 74B6                <1> 	je	short systimer_19
 50171                              <1> 
 50172                              <1> systimer_16:
 50173                              <1> 	; bh = 3
 50174                              <1> 	; timer event via real time clock interrupt
 50175                              <1> 	; interrupt/update frequency: 1 Hz (1 tick per second)
 50176                              <1> 	
 50177 0000D4A0 B0B6                <1> 	mov	al, 182 ; (*) ; 18.2 * 10
 50178 0000D4A2 FE05[15890100]      <1> 	inc	byte [trtc] ; timer event via real time clock
 50179 0000D4A8 EBAE                <1>         jmp     short systimer_0
 50180                              <1> 
 50181                              <1> systimer_7:
 50182 0000D4AA A2[1C010300]        <1> 	mov	[u.r0], al ; timer event number
 50183                              <1> 	;
 50184                              <1> 	; edi = address of empty timer event area
 50185 0000D4AF A0[6D010300]        <1> 	mov	al, [u.uno]
 50186 0000D4B4 FA                  <1> 	cli 	; disable interrupts 
 50187 0000D4B5 AA                  <1> 	stosb	; process number
 50188 0000D4B6 A0[14890100]        <1> 	mov	al, [tcallback] ; timer callback flag
 50189 0000D4BB AA                  <1> 	stosb 	; 1= callback method, 0= signal response byte method
 50190 0000D4BC A0[15890100]        <1> 	mov	al, [trtc] ; timer interrupt type
 50191 0000D4C1 AA                  <1> 	stosb	; 1= real time clock, 0= programmable interval timer
 50192 0000D4C2 88D8                <1> 	mov	al, bl ; Signal return (Response) value
 50193 0000D4C4 AA                  <1> 	stosb   ; response byte
 50194 0000D4C5 58                  <1> 	pop	eax ; (*) ; 10 or 182
 50195 0000D4C6 89D3                <1> 	mov	ebx, edx ; virtual address for response/signal byte
 50196 0000D4C8 F7E1                <1> 	mul	ecx
 50197                              <1> 	; (eax = 10 * count of 18.2 Hz timer ticks)
 50198                              <1> 	; (count down step = 10)
 50199 0000D4CA AB                  <1> 	stosd  ; count limit (reset value)
 50200 0000D4CB AB                  <1> 	stosd  ; current count value
 50201                              <1> 
 50202                              <1> 	; 19/12/2016
 50203 0000D4CC 803D[14890100]00    <1> 	cmp	byte [tcallback], 0 ; timer callback method ?
 50204 0000D4D3 7604                <1> 	jna	short systimer_17 ; no	
 50205 0000D4D5 89D8                <1> 	mov	eax, ebx ; virtual address for callback routine 
 50206 0000D4D7 EB0D                <1> 	jmp	short systimer_18
 50207                              <1> 
 50208                              <1> systimer_17: ; signal response byte method
 50209                              <1> 	; ebx = virtual address
 50210                              <1> 	; [u.pgdir] = page directory's physical address
 50211                              <1> 	; 20/02/2017
 50212 0000D4D9 FE05[16890100]      <1> 	inc	 byte [no_page_swap] ; 1 
 50213                              <1> 			; Do not add this page to swap queue
 50214                              <1> 			; and remove it from swap queue if it is
 50215                              <1> 			; on the queue.
 50216 0000D4DF E8A485FFFF          <1> 	call	get_physical_addr
 50217 0000D4E4 721A                <1> 	jc	short systimer_8 ; 07/06/2016
 50218                              <1> 	; eax = physical address of the virtual address in user's space
 50219                              <1> systimer_18:
 50220 0000D4E6 AB                  <1> 	stosd	; response addr (physical) or callback addr (virtual)
 50221 0000D4E7 FE05[0F840100]      <1> 	inc	byte [timer_events] ; 07/06/201
 50222                              <1> 	; 02/01/2017
 50223 0000D4ED 0FB605[6D010300]    <1> 	movzx	eax, byte [u.uno]
 50224 0000D4F4 FE80[AF000300]      <1> 	inc	byte [eax+p.timer-1]	
 50225                              <1> 	;
 50226 0000D4FA FB                  <1> 	sti 	; enable interrupts
 50227 0000D4FB E9F2F7FFFF          <1> 	jmp	sysret
 50228                              <1> 
 50229                              <1> systimer_8:
 50230                              <1> 	; 10/06/2016
 50231                              <1> 	; 07/06/2016
 50232 0000D500 28C0                <1> 	sub	al, al ; 0
 50233 0000D502 8847F4              <1> 	mov	[edi-12], al ; clear process number (free timer event)
 50234                              <1> 	;mov	dword [edi], eax ; 0
 50235 0000D505 FB                  <1> 	sti
 50236 0000D506 A2[1C010300]        <1> 	mov	[u.r0], al ; 0
 50237 0000D50B E9C2F7FFFF          <1> 	jmp	error
 50238                              <1> 
 50239                              <1> systimer_9:
 50240                              <1> 	; 10/06/2016
 50241                              <1> 	; 07/06/2016
 50242 0000D510 28C0                <1> 	sub	al, al
 50243 0000D512 A2[1C010300]        <1> 	mov	byte [u.r0], al ; 0
 50244 0000D517 3805[0F840100]      <1> 	cmp     byte [timer_events], al ;  0
 50245 0000D51D 7631                <1> 	jna	short systimer_12
 50246                              <1> 
 50247                              <1> 	; Note: ecx and edx are undefined here
 50248                              <1> 	;	(for stop timer function)
 50249                              <1> 
 50250 0000D51F BE[2C020300]        <1> 	mov	esi, timer_set  ; beginning address of timer events
 50251                              <1> 				; setting space	 
 50252 0000D524 A0[6D010300]        <1> 	mov	al, [u.uno]
 50253                              <1> 	
 50254 0000D529 B710                <1> 	mov	bh, 16
 50255                              <1> 
 50256 0000D52B 08DB                <1> 	or	bl, bl
 50257 0000D52D 7544                <1> 	jnz	short systimer_15
 50258                              <1> 
 50259                              <1> 	; clear timer event areas belong to current process
 50260                              <1> 	; (for stopping all timer events belong to current process) 
 50261 0000D52F FA                  <1> 	cli 	; disable interrupts
 50262                              <1> systimer_10:
 50263                              <1> 	; 10/06/2016
 50264                              <1> 	; 07/06/2016 	
 50265 0000D530 8A26                <1> 	mov	ah, [esi]
 50266 0000D532 08E4                <1> 	or	ah, ah ; 0 ?
 50267 0000D534 7411                <1> 	jz	short systimer_11
 50268 0000D536 38C4                <1> 	cmp	ah, al ; is the process number (owner) same ?
 50269 0000D538 750D                <1>         jne     short systimer_11 ; no
 50270                              <1> 
 50271                              <1> 	;mov	byte [esi], 0
 50272 0000D53A 66C7060000          <1> 	mov	word [esi], 0 ; clear
 50273                              <1> 	;mov	dword [esi+12], 0 ; clear
 50274                              <1> 
 50275 0000D53F FE0D[0F840100]      <1> 	dec	byte [timer_events]
 50276 0000D545 7409                <1> 	jz	short systimer_12
 50277                              <1> 
 50278                              <1> systimer_11:
 50279 0000D547 FECF                <1> 	dec	bh
 50280 0000D549 7405                <1> 	jz	short systimer_12
 50281 0000D54B 83C610              <1> 	add	esi, 16
 50282 0000D54E EBE0                <1> 	jmp	short systimer_10
 50283                              <1> 
 50284                              <1> systimer_12:
 50285 0000D550 0FB635[6D010300]    <1> 	movzx	esi, byte [u.uno]
 50286 0000D557 08DB                <1> 	or	bl, bl ; all timer events or one timer event ?
 50287 0000D559 740C                <1> 	jz	short systimer_13
 50288 0000D55B 8A9E[AF000300]      <1> 	mov	bl, [esi+p.timer-1]
 50289 0000D561 20DB                <1> 	and	bl, bl	; previous number of timer events for the process
 50290 0000D563 7408                <1> 	jz	short systimer_14
 50291 0000D565 FECB                <1> 	dec	bl  ; previous number of timer events for the process - 1
 50292                              <1> systimer_13:
 50293 0000D567 889E[AF000300]      <1> 	mov	[esi+p.timer-1], bl ; 0 ; no timer events for process
 50294                              <1> systimer_14:
 50295 0000D56D FB                  <1> 	sti	; enable interrupts
 50296 0000D56E E97FF7FFFF          <1> 	jmp	sysret
 50297                              <1> 
 50298                              <1> systimer_15:
 50299 0000D573 38FB                <1> 	cmp	bl, bh ; 16
 50300                              <1>         ;ja	systimer_4      ; max. 16 timer events !
 50301                              <1> 	; 23/07/2022
 50302 0000D575 7605                <1> 	jna	short systimer_21
 50303                              <1> systimer_20:
 50304 0000D577 E906FFFFFF          <1> 	jmp	systimer_4
 50305                              <1> systimer_21:	; 23/07/2022
 50306 0000D57C 88DA                <1> 	mov	dl, bl
 50307 0000D57E FECA                <1> 	dec	dl  ; 16 -> 15 ... 1 -> 0 
 50308 0000D580 C0E204              <1> 	shl	dl, 4 ; * 16
 50309 0000D583 0FB6FA              <1> 	movzx	edi, dl
 50310 0000D586 01F7                <1> 	add	edi, esi ; timer_set 
 50311                              <1> 	
 50312 0000D588 3A07                <1> 	cmp	al, [edi] ; process number
 50313                              <1>         ;jne	systimer_4
 50314                              <1> 	; 23/07/2022
 50315 0000D58A 75EB                <1> 	jne	short systimer_20 ; jmp systimer_4
 50316                              <1> 	
 50317                              <1> 	; same process ID
 50318 0000D58C FA                  <1> 	cli	; disable interrupts
 50319                              <1>  	; 10/06/2016 ; 02/01/2017
 50320                              <1> 	;mov	byte [edi], 0 
 50321 0000D58D 66C7070000          <1> 	mov	word [edi], 0 ; clear
 50322                              <1> 	;mov	dword [edi+12], 0 ; clear
 50323 0000D592 FE0D[0F840100]      <1> 	dec	byte [timer_events]
 50324 0000D598 EBB6                <1> 	jmp	short systimer_12
 50325                              <1> 
 50326                              <1> sysvideo: ; VIDEO DATA TRANSFER FUNCTIONS
 50327                              <1> 	; 11/08/2022
 50328                              <1> 	; 08/08/2022
 50329                              <1> 	; 23/07/2022 (TRDOS 386 v2.0.5)
 50330                              <1> 	; 06/03/2021
 50331                              <1> 	; 02/03/2021
 50332                              <1> 	; 28/02/2021
 50333                              <1> 	; 27/02/2021
 50334                              <1> 	; 26/02/2021
 50335                              <1> 	; 25/02/2021
 50336                              <1> 	; 21/02/2021, 22/02/2021, 23/02/2021
 50337                              <1> 	; 15/02/2021, 16/02/2021, 18/02/2021
 50338                              <1> 	; 10/02/2021, 11/02/2021, 12/02/2021
 50339                              <1> 	; 07/02/2021, 08/02/2021
 50340                              <1> 	; 01/02/2021, 02/02/2021, 05/02/2021
 50341                              <1> 	; 29/01/2021, 30/01/2021, 31/01/2021
 50342                              <1> 	; 23/01/2021, 24/01/2021, 28/01/2021
 50343                              <1> 	; 18/01/2021, 19/01/2021, 22/01/2021
 50344                              <1> 	; 04/01/2021, 10/01/2021, 11/01/2021
 50345                              <1> 	; 01/01/2021, 02/01/2021, 03/01/2021
 50346                              <1> 	; 28/12/2020, 29/12/2020, 30/12/2020
 50347                              <1> 	; 25/12/2020, 26/12/2020
 50348                              <1> 	; 21/12/2020, 23/12/2020
 50349                              <1> 	; 12/12/2020, 14/12/2020
 50350                              <1> 	; 10/12/2020, 11/12/2020
 50351                              <1> 	; 03/12/2020, 04/12/2020
 50352                              <1> 	; 22/11/2020, 23/11/2020
 50353                              <1> 	; 21/11/2020 (TRDOS 386 v2.0.3)
 50354                              <1> 	; 12/05/2017
 50355                              <1> 	; 11/07/2016
 50356                              <1> 	; 13/06/2016
 50357                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 50358                              <1> 	;
 50359                              <1> 	; VIDEO DATA TRANSFER FUNCTIONS:
 50360                              <1> 	;
 50361                              <1> 	; Inputs:
 50362                              <1> 	;		; 07/02/2021
 50363                              <1> 	;	BH = 0 = VIDEO BIOS Mode 3, tty/text mode data transfers
 50364                              <1> 	;	     BL = 
 50365                              <1> 	;		Bits 0&1, Transfer direction
 50366                              <1> 	;	     	 	0 - System to system
 50367                              <1> 	;			1 - User to system
 50368                              <1> 	;			2 - System to user
 50369                              <1> 	;			3 - Exhange (Swap) - 28/01/2021
 50370                              <1> 	;		Bits 2, Transfer Type
 50371                              <1> 	;			0 - Display page (complete) transfer
 50372                              <1> 	;	     		1 - Display page window (col,row) transfer
 50373                              <1> 	;		; 28/01/2021
 50374                              <1> 	;		Bits 3..7 - Reserved, undefined (must be 0)
 50375                              <1> 	;	        ; 28/01/2021	
 50376                              <1> 	;	     /// BL = 0 -> System to system (display page) transfer
 50377                              <1> 	;		 CL = Source page (0FFh = current video page)
 50378                              <1> 	;		 DL = Destination page (0FFh = current video page)
 50379                              <1> 	;		 (Note: Nothing to do if src & dest are same page)
 50380                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
 50381                              <1> 	;		 ECX = User's buffer address
 50382                              <1> 	;		 DL = Video page (0FFh = current video page)
 50383                              <1> 	;	     /// BL = 3 -> exchange (swap) display page ; 28/01/2021
 50384                              <1> 	;		 ECX = User's buffer address
 50385                              <1> 	;		 DL = Video page (0FFh = current video page)
 50386                              <1> 	;		 EDI = Swap address in user's memory (must be > 0)
 50387                              <1> 	;	     /// BL = 5&6&7 -> user to system, system to user transfer 
 50388                              <1> 	;		(system window is in current/active display page)
 50389                              <1> 	;		 ESI = User's buffer address
 50390                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
 50391                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
 50392                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
 50393                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
 50394                              <1>         ;                If BL = 5 or BL bit 0 & bit 1 are 1 ; 28/01/2021
 50395                              <1> 	;		 EDI = Swap address (in user's memory space)
 50396                              <1> 	;		 (If swap address > 0, previous content of the window
 50397                              <1> 	;		 will be saved into swap area in user's memory space)
 50398                              <1> 	;	     /// BL = 4 -> system to system transfer
 50399                              <1> 	;		 ESI = System's source buffer (video page) address
 50400                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
 50401                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
 50402                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
 50403                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
 50404                              <1> 	;		 EDI = System's destination buffer (video page) addr
 50405                              <1> 	;
 50406                              <1> 	;		; 06/02/2021
 50407                              <1> 	;		; 05/02/2021
 50408                              <1> 	;		; 01/02/2021, 02/02/2021
 50409                              <1> 	;		; 30/01/2021, 31/02/2021
 50410                              <1> 	;		; 29/01/2021 (major modification)
 50411                              <1> 	;		; 23/11/2020 (major modification)
 50412                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
 50413                              <1> 	;	BH = 1 = VGA Graphics (0A0000h) data transfers
 50414                              <1> 	;		BL bit 7
 50415                              <1> 	;		   resolution (screen width) option
 50416                              <1> 	;		   0 = 320 pixels
 50417                              <1> 	;		   1 = 640 pixels
 50418                              <1> 	;		.. followings are same with SVGA transfer function
 50419                              <1> 	;		BL bit 6
 50420                              <1> 	;		   direction option
 50421                              <1> 	;		   0 = user to system (video memory)
 50422                              <1> 	;		   1 = system to user
 50423                              <1> 	;		BL bit 5
 50424                              <1> 	;		   masked/direct (non-masked) operations
 50425                              <1> 	;		   1 = masked, 0 = non-masked (direct)
 50426                              <1> 	;		BL bit 4
 50427                              <1> 	;		   page/window option
 50428                              <1> 	;		   1 = window, 0 = display page (screen)
 50429                              <1> 	;		BL bit 0 to 3 (pixel operation types)
 50430                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
 50431                              <1> 	;		   1 = Change (New, Fill) color
 50432                              <1> 	;		   2 = Add color
 50433                              <1> 	;		   3 = Sub color
 50434                              <1> 	;		   4 = OR color
 50435                              <1> 	;		   5 = AND color
 50436                              <1> 	;		   6 = XOR color
 50437                              <1> 	;		   7 = NOT color
 50438                              <1> 	;		   8 = NEG color
 50439                              <1> 	;		   9 = INC color
 50440                              <1> 	;		  10 = DEC color
 50441                              <1> 	;		  11 = Mix (Average) colors
 50442                              <1> 	;		  12 = Replace pixel colors
 50443                              <1> 	;		  13 = Copy pixel block(s)
 50444                              <1> 	;		  14 = Write line(s)
 50445                              <1> 	;		  15 = Write character (font)
 50446                              <1> 	;
 50447                              <1> 	;	   Input Registers for pixel operations:
 50448                              <1> 	;		 Same with LFB data transfer function below
 50449                              <1> 	;
 50450                              <1> 	;		; 25/02/2021		
 50451                              <1> 	;		; 05/02/2021, 06/02/2021
 50452                              <1> 	;		; 01/02/2021, 02/02/2021
 50453                              <1> 	;		; 30/01/2021, 31/02/2021
 50454                              <1> 	; 		; 29/01/2021 (major modification)
 50455                              <1> 	;		; 23/11/2020 (major modification)
 50456                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
 50457                              <1> 	;	BH = 2 = Super VGA, LINEAR FRAME BUFFER data transfers
 50458                              <1> 	;		BL bit 7
 50459                              <1> 	;		   unused (invalid), must be 0
 50460                              <1> 	;		BL bit 6
 50461                              <1> 	;		   direction option
 50462                              <1> 	;		   0 = user to system (video memory)
 50463                              <1> 	;		   1 = system to user
 50464                              <1> 	;		BL bit 5
 50465                              <1> 	;		   masked/direct (non-masked) operations
 50466                              <1> 	;		   1 = masked, 0 = non-masked (direct)
 50467                              <1> 	;		BL bit 4
 50468                              <1> 	;		   page/window option
 50469                              <1> 	;		   1 = window, 0 = display page (screen)
 50470                              <1> 	;		BL bit 0 to 3 (pixel operation types)
 50471                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
 50472                              <1> 	;		   1 = Change (New, Fill) color
 50473                              <1> 	;		   2 = Add color
 50474                              <1> 	;		   3 = Sub color
 50475                              <1> 	;		   4 = OR color
 50476                              <1> 	;		   5 = AND color
 50477                              <1> 	;		   6 = XOR color
 50478                              <1> 	;		   7 = NOT color
 50479                              <1> 	;		   8 = NEG color
 50480                              <1> 	;		   9 = INC color
 50481                              <1> 	;		  10 = DEC color
 50482                              <1> 	;		  11 = Mix (Average) colors
 50483                              <1> 	;		  12 = Replace pixel colors
 50484                              <1> 	;		  13 = Copy pixel block(s)
 50485                              <1> 	;		  14 = Write line(s)
 50486                              <1> 	;		  15 = Write character (font)
 50487                              <1> 	;
 50488                              <1> 	;	   Note: If HW of EBX > 0, it is VESA VBE mode number
 50489                              <1> 	;		 otherwise, function will be applied
 50490                              <1> 	;		 to current (VESA VBE) video mode.
 50491                              <1> 	;		
 50492                              <1> 	;	   Input Registers for pixel operations:
 50493                              <1> 	;		-- user to system & system to system --
 50494                              <1> 	;		-- (BL = 0 to 0Fh) -- non-masked, screen --
 50495                              <1> 	;		-- (BL = 10h to 1Fh) -- non-masked, window --
 50496                              <1> 	;		-- (BL = 20h to 2Fh) -- masked, screen --
 50497                              <1> 	;		-- (BL = 30h to 3Fh) -- masked, window --
 50498                              <1> 	;		(*) window, (**) masked (***) sys to sys
 50499                              <1> 	;		for BL bit 0 to 3
 50500                              <1> 	;		00h: COPY PIXELS
 50501                              <1> 	;		  If BL bit 4 = 0 ; 21/02/2021
 50502                              <1> 	;		     full screen copy	
 50503                              <1>    	;		     ECX & EDX will not be used
 50504                              <1> 	;		    (user buffer must fit to display page)	  	
 50505                              <1> 	;		  If BL bit 4 = 1 ; 21/02/2021		
 50506                              <1> 	;		    ECX = start position (row, column) (*)
 50507                              <1> 	;			  (HW = row, CX = column)
 50508                              <1> 	;		    EDX = size (rows, colums) (*)
 50509                              <1> 	;			  (HW = rows, DX = columns)
 50510                              <1> 	;		          (0 -> invalid)
 50511                              <1> 	;		          (1 -> horizontal or vertical line)
 50512                              <1> 	;		    ESI = user's buffer address
 50513                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
 50514                              <1> 	;			  (this color will be excluded)
 50515                              <1> 	;		01h: CHANGE PIXEL COLORS
 50516                              <1> 	;		02h: ADD PIXEL COLORS
 50517                              <1> 	;		03h: SUB PIXEL COLORS
 50518                              <1> 	;		04h: OR PIXEL COLORS
 50519                              <1> 	;		05h: AND PIXEL COLORS
 50520                              <1> 	;		06h: XOR PIXEL COLORS
 50521                              <1> 	;		0Bh: MIX PIXEL COLORS
 50522                              <1> 	;		     CL = color (8 bit, 256 colors)
 50523                              <1> 	;		    ECX = color (16 bit and true colors)
 50524                              <1> 	;		    EDX = start position (row, column) (*)
 50525                              <1> 	;			 (HW = row, DX = column)
 50526                              <1> 	;		    ESI = size (rows, colums) (*)
 50527                              <1> 	;			  (HW = rows, SI = columns)
 50528                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
 50529                              <1> 	;			  (this color will be excluded)
 50530                              <1> 	;		07h: NOT PIXEL COLORS
 50531                              <1> 	;		08h: NEG PIXEL COLORS
 50532                              <1> 	;		09h: INC PIXEL COLORS
 50533                              <1> 	;		0Ah: DEC PIXEL COLORS
 50534                              <1> 	;		    ECX = start position (row, column) (*)
 50535                              <1> 	;			  (HW = row, CX = column)
 50536                              <1> 	;		    EDX = size (rows, colums) (*)
 50537                              <1> 	;			  (HW = rows, DX = columns)
 50538                              <1> 	;		          (0 -> invalid)
 50539                              <1> 	;		          (1 -> horizontal or vertical line)
 50540                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
 50541                              <1> 	;			  (this color will be excluded)
 50542                              <1> 	;		0Ch: REPLACE PIXEL COLORS
 50543                              <1> 	;		     CL = current color (8 bit, 256 colors)
 50544                              <1> 	;		    ECX = current color (16 bit and true colors)
 50545                              <1> 	;		     DL = new color (8 bit, 256 colors)
 50546                              <1> 	;		    EDX = new color (16 bit and true colors)
 50547                              <1> 	;		    ESI = start position (row, column) (*)
 50548                              <1> 	;			  (HW = row, SI = column)
 50549                              <1> 	;		    EDI = size (rows, colums) (*)
 50550                              <1> 	;			  (HW = rows, DI = columns)
 50551                              <1> 	;		0Dh: COPY PIXEL BLOCK(S) -full screen-
 50552                              <1> 	;		   -If BL bit 5 is 0-
 50553                              <1> 	;		    ECX = start position (row, column) (*)
 50554                              <1> 	;			  (HW = row, CX = column)
 50555                              <1> 	;		    EDX = size (rows, colums) (*)
 50556                              <1> 	;			  (HW = rows, DX = columns)
 50557                              <1> 	;		          (0 -> invalid)
 50558                              <1> 	;		          (1 -> horizontal or vertical line)
 50559                              <1> 	;		    ESI = destination (row, column) (***)
 50560                              <1> 	;		   -If BL bit 5 is 1-
 50561                              <1> 	;	               CL = color (8 bit, 256 colors)
 50562                              <1> 	;		      ECX = color (16 bit and true colors)
 50563                              <1> 	;	   	      EDX = count of blocks (not bytes)
 50564                              <1> 	;			    (limit: 2048 blocks)
 50565                              <1> 	;		      ESI = user's buffer address 
 50566                              <1> 	;			  contains 64 bits block data
 50567                              <1> 	;			  BLOCK ADDRESS - (row, col), dword
 50568                              <1> 	;			  (first 32 bits)
 50569                              <1> 	;			  BLOCK SIZE - (rows, cols), dword
 50570                              <1> 	;			  (second 32 bits)
 50571                              <1> 	;		; 10/02/2021
 50572                              <1> 	;		0Eh: WRITE LINE(s) -full screen- 
 50573                              <1> 	;		   -If BL bit 5 is 0-	
 50574                              <1> 	; 		    CL = color (8 bit, 256 colors)
 50575                              <1> 	; 		   ECX = color (16 bit and true colors)
 50576                              <1> 	; 		    DX = low 12 bits - size (length)
 50577                              <1> 	;			 high 4 bits - direction or type
 50578                              <1> 	;			     0 - Horizontal line
 50579                              <1> 	;			     1 - Vertical line
 50580                              <1> 	;			   > 1 - undefined, invalid
 50581                              <1> 	; 		   ESI = start position (row, column)
 50582                              <1> 	;			 (HW = row, SI = column)
 50583                              <1> 	;		   -If BL bit 5 is 1-
 50584                              <1> 	;		     CL = color (8 bit, 256 colors)
 50585                              <1> 	;		    ECX = color (16 bit and true colors)
 50586                              <1> 	;		     DX = number of lines (in user buffer)
 50587                              <1> 	;			   (limit: 2048 lines)	
 50588                              <1> 	;		    ESI = user's buffer
 50589                              <1> 	;		          contains 64 bit data for lines
 50590                              <1> 	;			   START POINT: 32 bit (row, col)
 50591                              <1> 	;			   LENGTH: 32 bit
 50592                              <1> 	;			   high 16 bits - 0
 50593                              <1> 	;			   bit 0-11 - length
 50594                              <1> 	;			   bit 12-15 - type (length)
 50595                              <1> 	;		0Fh: WRITE CHARACTER (FONT)
 50596                              <1> 	;		     CL = char's color (8 bit, 256 colors)
 50597                              <1> 	;		    ECX = char's color (16 bit and true colors)
 50598                              <1> 	;		     DL = Character's ASCII code
 50599                              <1> 	;		     DH bit 0 -> font height
 50600                              <1> 	;			  0 -> 8x16 character font
 50601                              <1> 	;			  1 -> 8x8 character font
 50602                              <1> 	;		     DH bit 1 & 2 -> scale	
 50603                              <1> 	;			  0 = 1/1 (8 pixels per char row)
 50604                              <1> 	;			  1 = 2/1 (16 pixels per char row)
 50605                              <1> 	;			  2 = 3/1 (24 pixels per char row)
 50606                              <1> 	;			  3 = 4/1 (32 pixels per char row) 
 50607                              <1> 	;		     DH bit 6 -> [ufont] option (1 = use [ufont])
 50608                              <1> 	;		     If DH bit 7 = 1
 50609                              <1> 	;			 USER FONT (from user buffer)
 50610                              <1> 	;			    DL = 0 -> 8x8 (width: 1 byte per row)
 50611                              <1> 	;			    DL = 1 -> 8x16
 50612                              <1> 	;			    DL = 2 -> 16x16 (width: 2 bytes)
 50613                              <1> 	;			    DL = 3 -> 16x32
 50614                              <1> 	;			    DL = 4 -> 24x24 (width: 3 bytes)
 50615                              <1> 	;			    DL = 5 -> 24x48
 50616                              <1> 	;			    DL = 6 -> 32x32 (width: 4 bytes)
 50617                              <1> 	;			    DL = 7 -> 32x64
 50618                              <1> 	;			    DL > 7 -> invalid (unused)
 50619                              <1> 	;			 EDI = user's font buffer address
 50620                              <1> 	;			    (NOTE: byte order is as row0,row1,row2..)
 50621                              <1> 	; 		    ESI = start position (row, column) (*)
 50622                              <1> 	;			     (HW = row, SI = column)
 50623                              <1> 	;
 50624                              <1> 	;		-- system to user --
 50625                              <1> 	;		   BL (bit 0 to 7) 
 50626                              <1> 	;	 	40h: COPY PIXELS (full screen, display page)
 50627                              <1> 	;		    EDI = user's buffer address
 50628                              <1> 	;		41h: COPY PIXELS (window)
 50629                              <1> 	;		    ECX = start position (row, column) (*)
 50630                              <1> 	;			  (HW = row, CX = column)
 50631                              <1> 	;		    EDX = size (rows, colums) (*)
 50632                              <1> 	;			  (HW = rows, DX = columns)
 50633                              <1> 	;		          (<=1 -> horizontal or vertical line)
 50634                              <1> 	;		    EDI = user's buffer address
 50635                              <1> 	;
 50636                              <1> 	;		Example: (29/01/2021)
 50637                              <1> 	;		    ecx = 00400064h (start at row 64, column 100) 
 50638                              <1> 	;		    edx = 00320048h (size: 50 rows, 72 columns)
 50639                              <1> 	;				    (end at row 114, column 172)
 50640                              <1> 	;		    If video memory starts at 0A0000h
 50641                              <1> 	;		    and if resolution is 320x200 (256 colors) ..
 50642                              <1> 	;		    window start offset: (64*320)+100 = 20580
 50643                              <1> 	;		    window size: 16072 bytes (pixels) 
 50644                              <1> 	;		    window end offset: 20580+16072 = 36652
 50645                              <1> 	;		    window start address: 0A0000h+564h = 0A5064h
 50646                              <1> 	; Outputs:
 50647                              <1> 	;	EAX = transfer/byte count
 50648                              <1> 	;
 50649                              <1> 	;	NOTE: If the source or destination address passes out of
 50650                              <1> 	;	video pages (display memory limits), data will not be transferred
 50651                              <1> 	;	and EAX will return as 0.
 50652                              <1> 	;
 50653                              <1> 	; 08/02/2021
 50654                              <1> 	; 07/02/2021	
 50655                              <1> 	; 04/01/2021
 50656                              <1> 	; PIXEL READ/WRITE (in current/active video mode)
 50657                              <1> 	;
 50658                              <1> 	;	BH = 3 = Read/Write pixel(s) -for all graphics modes-
 50659                              <1> 	;	     BL = 
 50660                              <1> 	;		0 = Read pixel
 50661                              <1> 	;		1 = Write pixel
 50662                              <1> 	;	     	2 = swap pixel colors
 50663                              <1> 	;		3 = mix pixel colors
 50664                              <1> 	;	     29/01/2021	
 50665                              <1> 	;		4 = read pixels from user defined positions 
 50666                              <1> 	;		5 = write single color pixels to user defined positions
 50667                              <1> 	;		6 = write multi color pixels to user defined positions 
 50668                              <1> 	; 
 50669                              <1> 	;	      > 6 = invalid/unimplemented	
 50670                              <1> 	;	
 50671                              <1> 	;	     .. for BL = 0 to 5		
 50672                              <1> 	;	     CL = color for writing pixel(s) or
 50673                              <1>  	;	     ECX = color for writing pixel(s) in true color modes
 50674                              <1> 	;
 50675                              <1> 	;	     EDX = Offset from start of video memory (0A0000h)
 50676                              <1> 	;		   or start of linear frame buffer
 50677                              <1> 	;
 50678                              <1> 	;	     07/02/2021	
 50679                              <1> 	;	     .. for BL = 4
 50680                              <1> 	;	     EDI = user's destination buffer address for pixel colors 	
 50681                              <1> 	;	     29/01/2021
 50682                              <1> 	;	     .. for BL = 4 & 5		
 50683                              <1> 	;	     ESI = user's source buffer address for BL = 4 & 5
 50684                              <1> 	;	     (buffer contains dword offset positions for pixels)
 50685                              <1> 	;	     EDX = number of pixels
 50686                              <1> 	;	     .. for BL = 6	 		
 50687                              <1> 	;	     ESI = user's buffer address for BL = 6
 50688                              <1> 	;	     (buffer contains dword offset position and dword color
 50689                              <1> 	;	      value for each pixel)
 50690                              <1> 	;	     EDX = number of pixels  
 50691                              <1> 	;	
 50692                              <1> 	; Note:
 50693                              <1> 	;	Pixel read/write will be performed in current video mode. 
 50694                              <1> 	;	If [CRT_MODE] < 0FFh, 0A0000h will be used 
 50695                              <1> 	;	   as video memory and limit will be 65536
 50696                              <1> 	;	   (new/mix pixel color will be in CL)  	
 50697                              <1> 	;	if [CRT_MODE] = 0FFh (VESA VBE video mode)
 50698                              <1> 	;	   LFB base address will be used as video memory
 50699                              <1> 	;	   and limit will be video page size
 50700                              <1> 	;	   (new/mix pixel color will be in CL)  
 50701                              <1> 	;
 50702                              <1> 	; Outputs:
 50703                              <1> 	;	EAX = pixel color (according to BL and ECX input)
 50704                              <1> 	;	EAX = 0 (pixel color is 0 or there is an error)
 50705                              <1> 	;	     (BL will return as 0FFh if there is an error)
 50706                              <1> 	;	; 29/01/2021 	
 50707                              <1> 	;	EAX = number of pixels (for BL input = 4&5&6)
 50708                              <1> 	;
 50709                              <1> 	; DIRECT (STANDARD VGA/CGA) DISPLAY MEMORY ACCESS FUNCTIONS:
 50710                              <1> 	;
 50711                              <1> 	;	BH = 4 = CGA direct video memory (0B8000h, 32K) access
 50712                              <1> 	;		Page directory & page tables of the user's
 50713                              <1> 	;		program will be updated to direct access to
 50714                              <1> 	;		0B8000h (32K) video (CGA, color) memory; if
 50715                              <1> 	;		there is not a permission conflict or lock!  
 50716                              <1> 	;	        (User's program/process will have permission to
 50717                              <1> 	;		access locked display memory if the owner is
 50718                              <1> 	;		it's parent.)
 50719                              <1>         ;
 50720                              <1> 	;	    Screen width = 320	
 50721                              <1> 	;
 50722                              <1> 	;	BH = 5 = VGA direct video memory (0A0000h, 64K) access
 50723                              <1> 	;		Page directory & page tables of the user's
 50724                              <1> 	;		program will be updated to direct access to
 50725                              <1> 	;		0A0000h (64K) video (VGA) memory; if there is not
 50726                              <1> 	;		a permission conflict or lock!  
 50727                              <1> 	;	        (User's program/process will have permission to
 50728                              <1> 	;		access locked display memory if the owner is
 50729                              <1> 	;		it's parent.)
 50730                              <1> 	;	
 50731                              <1> 	;	    ; 23/11/2020		
 50732                              <1> 	;	    Screen width options = 320, 640, 800 
 50733                              <1> 	;			
 50734                              <1> 	; Outputs:
 50735                              <1> 	;	EAX = Display memory address for direct access
 50736                              <1> 	;	      0A0000h for VGA, 0B8000h for CGA	
 50737                              <1> 	;	(Display memory size: 32K for CGA, 64K for VGA)
 50738                              <1> 	; 	EAX = 0 if display page access permission has been denied.
 50739                              <1> 	;	      (Locked!) 	
 50740                              <1> 	;	      	 	
 50741                              <1> 	; LINEAR FRAME BUFFER ACCESS FUNCTIONS:
 50742                              <1> 	;
 50743                              <1> 	;	BH = 6 = Linear Frame Buffer direct video memory access
 50744                              <1> 	;
 50745                              <1> 	;		Page directory & page tables of the user's
 50746                              <1> 	;		program will be updated to direct access to
 50747                              <1> 	;		the configured LFB (Linear Frame Buffer) address,
 50748                              <1> 	;		if there is not a permission conflict or lock!  
 50749                              <1> 	;	        (User's program/process will have permission to
 50750                              <1> 	;		access locked display memory if the owner is
 50751                              <1> 	;		it's parent.)
 50752                              <1> 	;
 50753                              <1> 	;	   ; 10/12/2020
 50754                              <1> 	;	   BL = 0FFh -> Direct LFB access for current video mode
 50755                              <1> 	;	   BL = XXh < 0FFh -> Direct LFB access
 50756                              <1> 	; 			      for VESA video mode 1XXh	
 50757                              <1> 	;		
 50758                              <1> 	;		Return: EAX = Linear Frame Buffer address
 50759                              <1> 	;			(EAX = 0 -> error)
 50760                              <1> 	;		     If EAX > 0
 50761                              <1> 	;			EDX = Frame Buffer Size in bytes
 50762                              <1> 	;		         BH = Requested Video Mode - 100h
 50763                              <1> 	;		              (VESA VBE video modes)	
 50764                              <1> 	;		         BL = bits per pixel
 50765                              <1> 	;			      8 = 256 colors, 8
 50766                              <1> 	;		             16 = 65536 colors, 5-6(G)-5 
 50767                              <1> 	;		             24 = RGB, 16M colors, 8-8-8
 50768                              <1> 	;		             32 = RGB + alpha bytes, 8-8-8-8
 50769                              <1> 	;		     If BH = 0FFh
 50770                              <1> 	;		        BL = VGA/CGA video mode (also EAX = 0)
 50771                              <1> 	;
 50772                              <1> 	;		** Function will return with EAX = 0 if the mode
 50773                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
 50774                              <1> 	;
 50775                              <1> 	;		ECX = Pixel resolution
 50776                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
 50777                              <1> 	;		      High 16 bits of ECX = Height 
 50778                              <1> 	;
 50779                              <1> 	; 	23/11/2020
 50780                              <1> 	; ***	GET VIDEO MODE & LINEAR FRAME BUFFER INFO   
 50781                              <1> 	;	(This function -7- also is used for VGA and CGA modes)
 50782                              <1> 	; 	
 50783                              <1> 	;	BH = 7 = Get Linear Frame Buffer info
 50784                              <1> 	;
 50785                              <1> 	;	   ; 22/01/2021	
 50786                              <1> 	;	   ; 10/12/2020
 50787                              <1> 	;	   BL = any -not used- (22/01/2021)
 50788                              <1> 	;	
 50789                              <1> 	;		Return:
 50790                              <1> 	;		EAX = Frame Buffer Address (0 = is not in use)
 50791                              <1> 	;		EDX = Frame Buffer Size in bytes
 50792                              <1> 	;		 BH = Current Video Mode - 100h  ; 22/01/2021
 50793                              <1> 	;		     (VESA VBE video modes)	
 50794                              <1> 	;		 BL = bits per pixel
 50795                              <1> 	;			8 = 256 colors, 8
 50796                              <1> 	;		       16 = 65536 colors, 5-6(G)-5 
 50797                              <1> 	;		       24 = RGB, 16M colors, 8-8-8
 50798                              <1> 	;		       32 = RGB + alpha bytes, 8-8-8-8
 50799                              <1> 	;		If BH = 0FFh
 50800                              <1> 	;		   BL = VGA/CGA video mode (also EAX = 0)
 50801                              <1> 	;
 50802                              <1> 	;		Note:	
 50803                              <1> 	;		Alpha byte will be used as virtual color index.
 50804                              <1> 	;		(32 bit pixel colors.. byte 0,1,2 rgb and 3 alpha)
 50805                              <1> 	;
 50806                              <1> 	;		** Function will return with EAX = 0 if the mode
 50807                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
 50808                              <1> 	;
 50809                              <1> 	;		ECX = Pixel resolution
 50810                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
 50811                              <1> 	;		      High 16 bits of ECX = Height  
 50812                              <1> 	;
 50813                              <1> 	;	NOTE: Each process will have it's own frame buffer
 50814                              <1> 	;	      address and resolution parameters in 'u' area.
 50815                              <1> 	;	      Then, if the current frame buffer & resolution
 50816                              <1> 	;	      is different, frame buffer r/w functions
 50817                              <1> 	;	      will use scale factor to convert process's
 50818                              <1>         ;             pixel coordinates to actual screen coordinates.
 50819                              <1> 	;	      resolution -> dimensional scale
 50820                              <1> 	;	      color size -> color scale
 50821                              <1> 	;	     * RGB (TRUE) colors to 256 colors conversion:
 50822                              <1>         ;             TRUE Colors -> 8,8,8 (R,G,B; byte 0 is R)
 50823                              <1> 	;	      256 colors -> 2,2,2,2 (R,G,B,L; bit 0&1 is R)
 50824                              <1> 	; 		  bit 6&7 -> luminosity base level (0,1,2,3)
 50825                              <1> 	;		  bit 4&5 -> blue level (0,1,2,3)
 50826                              <1> 	;		  bit 2%3 -> green level (0,1,2,3)
 50827                              <1> 	;		  bit 0&1 -> red level (0,1,2,3)
 50828                              <1> 	;	      Example: total red level : luminosity + red level
 50829                              <1> 	;	      Luminosity base level: 0 -> 16
 50830                              <1> 	;		 		     1 -> 32
 50831                              <1> 	;				     2 -> 64
 50832                              <1> 	;				     3 -> 128
 50833                              <1> 	;	      Color level:	
 50834                              <1> 	;				    0 -> 0
 50835                              <1> 	;				    1 -> luminosity level
 50836                              <1> 	;				    2 -> luminosity level + 64
 50837                              <1> 	;				    3 -> 255
 50838                              <1> 	;	     Luminosity base level = min (R,G,B)
 50839                              <1> 	;			if it is <16, it will be set to 16
 50840                              <1> 	;	     Color levels: Color values are fixed to (nearest) 
 50841                              <1> 	;		   one of all possible set level (step) values
 50842                              <1> 	;		   (according to luminosity base level); then
 50843                              <1> 	;		   color levels are set to R-L, G-L, B-L.
 50844                              <1> 	;	 For example: If luminosity base level is 32
 50845                              <1> 	;		  all possible set values are 0, 32, 96, 255.
 50846                              <1> 	;
 50847                              <1> 	;	    * RGB (TRUE) colors to 16 colors conversion:
 50848                              <1> 	;	    16 colors: R,B,G,L bits (4 bits)
 50849                              <1> 	;	    	   If any one of R,G,B >= 128 L = 1	
 50850                              <1>  	;		   If max. value of (R,G,B) >= 32, it is 1
 50851                              <1> 	;		      else all color bits (R&G&B&L) are 0
 50852                              <1> 	;		   If the second value >= max. value / 2
 50853                              <1> 	;		      it is 1
 50854                              <1> 	;		   If the third value >= max. value / 2
 50855                              <1> 	;		      it is 1
 50856                              <1> 	;	    Example: R = 132, G = 64, B = 78
 50857                              <1> 	;		     L = 1, R = 1
 50858                              <1> 	;		     G < 66 --> G = 0
 50859                              <1> 	;		     B >= 66 --> B = 1
 50860                              <1> 	;
 50861                              <1> 	; 10/12/2020
 50862                              <1> 	; SET VIDEO MODE (& RETURN LFB INFO for VESA VBE VIDEO MODES)
 50863                              <1> 	;	
 50864                              <1> 	;	BH = 8 = Set Video Mode
 50865                              <1> 	;		
 50866                              <1> 	;		BL = Requested Video Mode (method)
 50867                              <1> 	;		If BL = 0FFh
 50868                              <1> 	;		   CX = VESA VBE Video Mode
 50869                              <1> 	;		   ; 11/12/2020
 50870                              <1> 	;		   If EDX > 0 -> LFB INFO (user) buffer addr
 50871                              <1> 	;		If BL < 0FFh, it is VGA/CGA video mode and
 50872                              <1> 	;			CX & EDX will not be used
 50873                              <1> 	;
 50874                              <1> 	;	    NOTE: The last VESA VBE video mode is 11Bh but
 50875                              <1> 	;	    TRDOS 386 will permit to set video mode upto 11Fh.
 50876                              <1> 	;	    Above 11Fh, from 140h to 1FEh, it will be accepted
 50877                              <1> 	;	    as Bochs/Plex86 emulator video mode and it will be
 50878                              <1> 	;	    used only if [vbe3] = 2 and detected
 50879                              <1> 	;	    video bios is BOCHS/PLEX86/QEMU/VIRTUALBOX vbios.
 50880                              <1> 	;	 	  	 		 	
 50881                              <1> 	; Outputs:
 50882                              <1> 	;	EAX = Requested (Proper) video mode number + 1
 50883                              <1> 	;	      ("dec eax" by user will give requested video mode),
 50884                              <1> 	;
 50885                              <1> 	;	If BL input is 0FFh
 50886                              <1> 	;	   EDX = LFBINFO table/structure (in user's buffer addr)
 50887                              <1> 	;	   EDX = 0 -> Invalid LFBINFO (do not use it)
 50888                              <1> 	;
 50889                              <1> 	;	EAX = 0 -> Error (but EDX will not be changed)
 50890                              <1> 	;
 50891                              <1> 	; 03/12/2020
 50892                              <1> 	; VESA VBE3 VIDEO BIOS (32 bit) PROTECTED MODE INTERFACE SETTINGS
 50893                              <1> 	;	
 50894                              <1> 	;	BH = 9 = set/get VBE3 Protected Mode Interface parameters
 50895                              <1> 	;		
 50896                              <1> 	;		BL = 0 - Disable protected mode interface
 50897                              <1> 	;			([pmi32] = 0)
 50898                              <1> 	;		 	Return: AL = 1	
 50899                              <1> 	;		BL = 1 - Enable protected mode Interface
 50900                              <1> 	;			([pmi32] = 1)
 50901                              <1> 	;			Return: AL = 2
 50902                              <1> 	;		BL = 2 - Get protected mode interface status
 50903                              <1> 	;			Return: AL = [pmi32] + 1 (AL = 1 or 2)
 50904                              <1> 	;
 50905                              <1> 	;		If [vbe3] <> 3 --> AL = 0
 50906                              <1> 	;
 50907                              <1> 	;		; 17/01/2021
 50908                              <1> 	;		BL = 3 - Disable/Cancel restore permission to user
 50909                              <1> 	;			Return: AL = 1 (if disabled) or 0
 50910                              <1> 	;		BL = 4 - Enable/Give restore permission to user
 50911                              <1> 	;			Return: AL = 2 (if enabled) or 0
 50912                              <1> 	;		BL = 5 - Get video state save/restore status
 50913                              <1> 	;			 (permission status)
 50914                              <1> 	;		        Return: AL = Status (enabled = 1)
 50915                              <1> 	;				; 22/01/2021
 50916                              <1> 	;				AH = state options ([srvso])
 50917                              <1> 	;		BL = 6 - Return VESA VBE number/status
 50918                              <1> 	;		        Return: AX = status
 50919                              <1> 	;			      if AH =  2, AL > 0 : Emulator
 50920                              <1> 	;				 AH =  3, VESA VBE3 video bios
 50921                              <1> 	;		; 28/02/2021 	 
 50922                              <1> 	;		BL = 7 - Set true color mode as 32bpp (default)
 50923                              <1> 	;			Return: AX = 32 (if VBE3) 
 50924                              <1> 	;		NOTE: Initial/default value is 32bpp for vbe3.
 50925                              <1> 	;			Return: AX = 0 -> error 	 
 50926                              <1> 	;		BL = 8 - Set true color mode as 24bpp (default)
 50927                              <1> 	;			Return: AX = 24
 50928                              <1> 	;			;Return: AX = 0 -> error 
 50929                              <1> 	;		BL = 9 - Return default/current true color mode
 50930                              <1> 	;			Return: AX = 32 (32 bpp)
 50931                              <1> 	;			Return: AX = 24 (24 bpp)
 50932                              <1> 	;			Return: AX = 0 -> error (not VESA bios)
 50933                              <1> 	;		 
 50934                              <1> 	;		BL > 9 : not implemented (28/02/2021)
 50935                              <1> 	;
 50936                              <1> 	;	; 19/01/2021 ([u.uid] check)	
 50937                              <1> 	;	Note: Enabling/Disabling are done by root ([u.uid] = 0)
 50938                              <1> 	;	      while [multi_tasking] = 0.
 50939                              <1> 	;
 50940                              <1>     	; 23/12/2020
 50941                              <1> 	; VIDEO MEMORY MAPPING:
 50942                              <1> 	;	BH = 10 = Map video memory to user's buffer
 50943                              <1> 	;
 50944                              <1> 	;	   BL = 0 : CGA memory (0B8000h) map (32K)
 50945                              <1> 	;	   BL = 1 : VGA memory (0A0000h) map (64K)
 50946                              <1> 	;	   BL = 2 : SVGA memory (LFB) map to user's buffer
 50947                              <1> 	;
 50948                              <1> 	;	ECX = User's buffer addr (low 12 bits will be cleared)
 50949                              <1> 	;	EDX = Buffer size in bytes (if BL = 2)
 50950                              <1> 	;		(will be trimmed if LFB size < EDX)
 50951                              <1> 	; Return:				
 50952                              <1>         ;	EAX = physical address of video memory (buffer)
 50953                              <1> 	;	EBX = mapped (actual) size of video memory (bytes)
 50954                              <1> 	;	ECX = virtual start address of user's video buffer 
 50955                              <1> 	;	EDX is same with EDX input
 50956                              <1> 	;
 50957                              <1> 	;	(Note: Memory page boundaries will be applied 
 50958                              <1> 	;	 to buffer size and buff start addr by rounding down.
 50959                              <1> 	;	 Rounded size & address values must not be zero.) 
 50960                              <1> 	;	-Normally, it is expected to request mapping by using
 50961                              <1> 	;	 correct buffer size of current or desired video mode-
 50962                              <1> 	;
 50963                              <1> 	;	EAX = 0 -> error ! memory can not mapped to user
 50964                              <1> 	;
 50965                              <1> 	; 04/01/2021
 50966                              <1> 	; SET/READ COLOR PALETTE (set/read DAC color registers)
 50967                              <1> 	;	((256 colors (8bpp) VGA/CGA video hardware feature))
 50968                              <1> 	;
 50969                              <1> 	;	BH = 11 = Set/Read DAC color registers
 50970                              <1> 	;
 50971                              <1> 	;	   (BL<4 Original method for std VGA video hardware)
 50972                              <1> 	;	   BL = 0 : Read all DAC color registers (256 colors)
 50973                              <1> 	;	       (6 bit colors, in RGB order)
 50974                              <1> 	;	   BL = 1 : Set all DAC color registers (256 colors)
 50975                              <1> 	;	       (6 bit colors, in RGB order)
 50976                              <1> 	;	   BL = 2 : Read single DAC color register
 50977                              <1> 	;	       (6 bit color, in RGB order)
 50978                              <1> 	;		((EAX will return with color value))
 50979                              <1> 	;		CL = DAC color register (index)
 50980                              <1> 	;	   BL = 3 : Set/Write single DAC color register
 50981                              <1> 	;	       (6 bit color, in RGB order, bit 6&7 are 0)
 50982                              <1> 	;		ECX byte 0 - DAC color register
 50983                              <1> 	;		ECX byte 1 - Red (6 bit)
 50984                              <1> 	;		ECX byte 2 - Green (6 bit)
 50985                              <1> 	;		ECX byte 3 - Blue (6 bit)
 50986                              <1> 	;	   (BL>3 Alternative method for BMP files etc.)	
 50987                              <1> 	;	   BL = 4 : Read all DAC color registers (256 colors)
 50988                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
 50989                              <1> 	;	   BL = 5 : Set all DAC color registers (256 colors)
 50990                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
 50991                              <1> 	;	   BL = 6 : Read single DAC color register
 50992                              <1> 	;	       (8 bit color, in BGR order, bit 0&1 is 0)
 50993                              <1> 	;		((EAX will return with color value))
 50994                              <1> 	;		CL = DAC color register (index)
 50995                              <1> 	;	   BL = 7 : Set/Write single DAC color register
 50996                              <1> 	;	       (8 bit color, bit 0&1 are 0)
 50997                              <1> 	;		ECX byte 0 - DAC color register
 50998                              <1> 	;		ECX byte 1 - Blue (8 bit)
 50999                              <1> 	;		ECX byte 2 - Green (8 bit)
 51000                              <1> 	;		ECX byte 3 - Red (8 bit)
 51001                              <1> 	;
 51002                              <1> 	;	  BL > 7 : invalid (not implemented)
 51003                              <1> 	;
 51004                              <1> 	;   if BL bit 2 is 1, 6 bit colors converted to 8 bit colors
 51005                              <1> 	;	(low two bits of color bytes will be 0)
 51006                              <1> 	;     ((color byte 00111111b will be converted to 11111100b))
 51007                              <1> 	;	and RGB byte order will be 
 51008                              <1> 	;		byte 0 - Blue (low 2 bits are 0)
 51009                              <1> 	;		byte 1 - Green (low 2 bits are 0)
 51010                              <1> 	;		byte 2 - Red (low 2 bits are 0)
 51011                              <1> 	;		byte 3 - pad (or zero byte)
 51012                              <1> 	;	and 256 colors buffer size must be 256*4 = 1024 bytes
 51013                              <1> 	;   if BL bit 2 is 0, 6 bit colors will be used directly
 51014                              <1> 	;	  (high two bits of 8 bit color bytes will be 0)
 51015                              <1> 	;     ((dac color 111111b will be converted to 00111111b))
 51016                              <1> 	;		byte 0 - Red (high 2 bits are 0)
 51017                              <1> 	;		byte 1 - Green (high 2 bits are 0)
 51018                              <1> 	;		byte 2 - Blue (high 2 bits are 0)
 51019                              <1> 	;	and 256 colors buffer size must be 256*3 = 768 bytes
 51020                              <1> 	;
 51021                              <1> 	;	ECX = User's buffer addr (256*3 = 768 bytes) or
 51022                              <1> 	;	      Color 
 51023                              <1> 	;
 51024                              <1> 	; Return:				
 51025                              <1>         ;	EAX = buffer size (for BL input = 0,1,4,5)
 51026                              <1> 	;	      or color value (for BL input = 2,3,6,7)
 51027                              <1> 	;
 51028                              <1> 	; 10/01/2021
 51029                              <1> 	; SET/READ FONT DATA
 51030                              <1> 	;
 51031                              <1> 	;	BH = 12 = Set/Read Character Font Data
 51032                              <1> 	;
 51033                              <1> 	;	   BL = 0 : Disable system font overwrite
 51034                              <1> 	;	   BL = 1 : Enable system font overwrite
 51035                              <1> 	;	   BL = 2 : Read system font 8x8
 51036                              <1> 	;	   BL = 3 : Read system font 8x14
 51037                              <1> 	;	   BL = 4 : Read system font 8x16
 51038                              <1> 	;	   BL = 5 : Read user defined font 8x8
 51039                              <1> 	;	   BL = 6 : Read user defined font 8x16
 51040                              <1> 	;	   BL = 7 : Write system font 8x8
 51041                              <1> 	;	   BL = 8 : Write system font 8x14
 51042                              <1> 	;	   BL = 9 : Write system font 8x16
 51043                              <1> 	;	   BL = 10 : Write user defined font 8x8
 51044                              <1> 	;	   BL = 11 : Write user defined font 8x16
 51045                              <1> 	;
 51046                              <1> 	;	  BL > 11 : invalid (not implemented)
 51047                              <1> 	;
 51048                              <1> 	;	For BL = 1 to 11
 51049                              <1> 	;	   ECX = number of characters (<= 256)
 51050                              <1> 	;	   EDX = first character (ascii code in DL)
 51051                              <1> 	;	   ESI = user's buffer address
 51052                              <1> 	;
 51053                              <1> 	; Return:				
 51054                              <1>         ;	EAX = number of characters (ecx input)
 51055                              <1> 	;	EAX = 0 -> error
 51056                              <1> 	;	(EAX = 256 for BL = 0 and 1 if successful)
 51057                              <1> 	;	
 51058                              <1> 	; Note: system font overwrite permission will be
 51059                              <1> 	;       given if [multi_tasking] = 0 
 51060                              <1> 	;	and [u.uid] = 0 (BL = 1) ; 19/01/2021
 51061                              <1> 	;       and if [ufont] bit 7 is 1 (BL = 7,8,9)
 51062                              <1> 	;
 51063                              <1> 	; 18/01/2021
 51064                              <1> 	; SAVE/RESTORE STANDARD VGA VIDEO STATE
 51065                              <1> 	;
 51066                              <1> 	;	BH = 13 = Save/Restore std VGA video state
 51067                              <1> 	;
 51068                              <1> 	;	   BL = 0 : Save VGA state (without DAC regs)
 51069                              <1> 	;		Return: EAX = VideoStateID (>0)
 51070                              <1> 	;			EAX = 0 (failed!)
 51071                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
 51072                              <1> 	;	   BL = 1 : Restore VGA state (without DAC regs)
 51073                              <1> 	;		ECX = VideoStateID (to be verified)
 51074                              <1> 	;	        Return: EAX = Restore size (>0)
 51075                              <1> 	;	   BL = 2 : Save VGA state (complete)
 51076                              <1> 	;		Return: EAX = VideoStateID (>0)
 51077                              <1> 	;			EAX = 0 (failed!)
 51078                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3) 
 51079                              <1> 	;	   BL = 3 : Restore VGA state (complete)
 51080                              <1> 	;		ECX = VideoStateID (to be verified)
 51081                              <1> 	;	        Return: EAX = Restore size (>0)
 51082                              <1> 	;
 51083                              <1> 	;	* Above options are for saving
 51084                              <1> 	;	*       video state to system memory
 51085                              <1> 	;	*	(location: VBE3VIDEOSTATE, 2048 bytes)
 51086                              <1> 	;	
 51087                              <1> 	;	   BL = 4 : Save VGA state (without DAC regs)
 51088                              <1> 	;		ECX = buffer address  
 51089                              <1> 	;		Return: EAX = transfer count
 51090                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
 51091                              <1> 	;		ECX = buffer address  
 51092                              <1> 	;	   BL = 5 : Restore VGA state (without DAC regs)
 51093                              <1> 	;		ECX = buffer address  
 51094                              <1> 	;	        Return: EAX = transfer count
 51095                              <1> 	;	   BL = 6 : Save VGA state (complete)
 51096                              <1> 	;		ECX = buffer address  
 51097                              <1> 	;		Return: EAX = transfer count
 51098                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3)
 51099                              <1> 	;	   BL = 7 : Restore VGA state (complete)
 51100                              <1> 	;		ECX = buffer address  
 51101                              <1> 	;	        Return: EAX = transfer count
 51102                              <1> 	;
 51103                              <1> 	;	* Above options are for saving
 51104                              <1> 	;	*       video state to user's buffer
 51105                              <1> 	;	*	(buffer size: 110 bytes or 882 bytes)
 51106                              <1> 	;
 51107                              <1> 	;	  BL > 7 : invalid (not implemented)
 51108                              <1> 	;
 51109                              <1> 	; 18/01/2021
 51110                              <1> 	; SAVE/RESTORE SUPER VGA (VESA VBE 2/3) VIDEO STATE
 51111                              <1> 	;
 51112                              <1> 	;	BH = 14 = Save/Restore SVGA video state
 51113                              <1> 	;
 51114                              <1> 	;	   BL = options
 51115                              <1> 	;		bit 0 - Save (0) or Restore (1)	
 51116                              <1> 	;		bit 1 - controller hardware state
 51117                              <1> 	;		bit 2 - BIOS data state
 51118                              <1> 	;		bit 3 - DAC state
 51119                              <1> 	;		bit 4 - (extended) Register state
 51120                              <1> 	;		bit 5 - system (0) or user (1) memory
 51121                              <1> 	;		bit 6 - verify without transfer
 51122                              <1> 	;		bit 7 - not used (must be 0)
 51123                              <1> 	;			
 51124                              <1> 	;	     if bit 0 = 0 and bit 5 = 0
 51125                              <1> 	;		Return:	EAX = VideoStateID (>0)	
 51126                              <1> 	;	     if bit 0 = 1
 51127                              <1> 	;		ECX = VideoStateID (bit 5 = 0)
 51128                              <1> 	;		Return: EAX = restore (transfer) size
 51129                              <1> 	;	     if bit 5 = 1
 51130                              <1> 	;		ECX = Buffer address
 51131                              <1> 	;		Return: EAX = transfer count (size)
 51132                              <1> 	;
 51133                              <1> 	;	     ECX = Buffer address or VideoStateID
 51134                              <1> 	;
 51135                              <1> 	;	  BL > 127 : invalid (not implemented)
 51136                              <1> 	;
 51137                              <1> 	;  Note: Required buffer size may be > 2048 bytes
 51138                              <1> 	;	 (function fails when buff size > 2048 bytes)
 51139                              <1> 	;	 proper option must be used
 51140                              <1> 	;
 51141                              <1> 	; 18/01/2021
 51142                              <1> 	; READ VESA EDID (EXTENDED DISPLAY IDENTIFICATION DATA)
 51143                              <1> 	;
 51144                              <1> 	;	BH = 15 = Read VESA EDID for connected monitor  
 51145                              <1> 	;		  (copy EDID to user)	
 51146                              <1> 	;
 51147                              <1> 	;	   BL = any
 51148                              <1> 	;
 51149                              <1> 	;	Input:
 51150                              <1> 	;	    ECX = user's (EDID) buffer address 
 51151                              <1> 	;		 (buffer size: 128 bytes)
 51152                              <1> 	;	Output:
 51153                              <1> 	;	    EAX = 128 (EDID size)
 51154                              <1> 	;	    or EAX = 0 -> Error!
 51155                              <1> 	;	       (EDID not ready or buffer addr error)	
 51156                              <1> 	;
 51157                              <1>  	
 51158                              <1> 	; 16/05/2016
 51159 0000D59A 31C0                <1> 	xor	eax, eax
 51160 0000D59C A3[1C010300]        <1> 	mov	[u.r0], eax
 51161 0000D5A1 20FF                <1> 	and	bh, bh
 51162                              <1> 	;jnz	sysvideo_13 ; 11/07/2016
 51163                              <1> 	; 23/07/2022
 51164 0000D5A3 7405                <1> 	jz	short sysvideo_40
 51165 0000D5A5 E974020000          <1> 	jmp	sysvideo_13
 51166                              <1> 
 51167                              <1> sysvideo_40:	; 23/07/2022
 51168                              <1> 	;; 21/11/2020 (TRDOS 386 v2.0.3)
 51169                              <1> 	;; tty/text mode transfers are only for video mode 3
 51170                              <1> 
 51171                              <1> 	; 22/11/2020
 51172                              <1> 	;cmp	byte [CRT_MODE], 3 ; 80x25 text, 16 colors
 51173                              <1> 	;jne	sysret ; invalid (nothing to do), [u.r0] = 0	
 51174                              <1> 	
 51175                              <1> 	; 23/11/2020
 51176                              <1> 	; bit 7,6,5,4 of BL are reserved and it must be 0
 51177                              <1> 	;	 	 for current 'sysvideo' version
 51178                              <1> 	;test	bl, 0F0h
 51179                              <1> 	;;jnz	sysret ; invalid (undefined) ! 
 51180                              <1> 	;; 28/01/2021
 51181                              <1> 	;jnz	short sysvideo_1_2 ; invalid (undefined) !
 51182                              <1> 	; 28/01/2021
 51183 0000D5AA 80FB07              <1> 	cmp	bl, 7
 51184 0000D5AD 776E                <1> 	ja	short sysvideo_1_2 ; invalid (undefined) !	
 51185                              <1> 
 51186                              <1> 	; Video mode 0, 80*25 text mode, CGA 16 colors  
 51187                              <1> 	; [CRT_MODE] = 3
 51188                              <1> 	;mov	bh, bl
 51189                              <1> 	;shr	bh, 2 ; 4..7 -> 1, 8..11 -> 2, 12..15 -> 3
 51190                              <1> 	;; 21/11/2020
 51191                              <1> 	;;and	bh, bh
 51192                              <1>         ;jnz	sysvideo_4  ; Display page window transfer etc.
 51193                              <1> 
 51194                              <1> 	; 28/01/2021
 51195 0000D5AF F6C304              <1> 	test	bl, 4 ; bit 2
 51196                              <1> 	;jnz	sysvideo_4 ; Display page window transfer
 51197                              <1> 	; 23/07/2022
 51198 0000D5B2 7405                <1> 	jz	short sysvideo_41
 51199 0000D5B4 E9A1000000          <1> 	jmp	sysvideo_4
 51200                              <1> sysvideo_41:	; 23/07/2022
 51201                              <1> 	; Display page (complete) transfer
 51202 0000D5B9 80FA07              <1> 	cmp	dl, 7
 51203                              <1> 	;jnz	sysret ; invalid (nothing to do), [u.r0] = 0
 51204 0000D5BC 760A                <1> 	jna	short sysvideo_0 ; 28/01/2021	
 51205 0000D5BE FEC2                <1> 	inc	dl ; 0FFh -> 0 ("use current video page")
 51206 0000D5C0 755B                <1> 	jnz	short sysvideo_1_2  ; invalid
 51207                              <1> 	; dl = 0 -> use current current page
 51208 0000D5C2 8A15[AE770100]      <1> 	mov	dl, [ACTIVE_PAGE]
 51209                              <1> sysvideo_0:
 51210                              <1> 	; 28/01/2021 
 51211 0000D5C8 80FB03              <1> 	cmp	bl, 3
 51212 0000D5CB 7206                <1> 	jb	short sysvideo_0_0
 51213 0000D5CD 09FF                <1> 	or	edi, edi
 51214 0000D5CF 744C                <1> 	jz	short sysvideo_1_2  ; invalid
 51215 0000D5D1 89FE                <1> 	mov	esi, edi ; save swap/exchange buffer addr
 51216                              <1> 	; ecx = user buffer for new video page content
 51217                              <1> 	; esi = user (swap) buffer for saving current video page  
 51218                              <1> sysvideo_0_0:
 51219 0000D5D3 BF00800B00          <1> 	mov	edi, 0B8000h
 51220                              <1> 	; dl = display page number, destination
 51221 0000D5D8 66B80010            <1> 	mov	ax, 4096 ; 21/11/2020
 51222 0000D5DC 20D2                <1> 	and	dl, dl
 51223 0000D5DE 7408                <1> 	jz	short sysvideo_1
 51224                              <1> 	; 07/02/2021
 51225 0000D5E0 88D6                <1> 	mov	dh, dl
 51226                              <1> sysvideo_0_1:
 51227                              <1> 	; page length = 4096 bytes (but page content is 80*25*2 bytes)
 51228 0000D5E2 01C7                <1> 	add	edi, eax ; 21//11/2020 ([CRT_LEN] = 1000h for mode 3)
 51229 0000D5E4 FECE                <1> 	dec	dh
 51230 0000D5E6 75FA                <1> 	jnz	short sysvideo_0_1
 51231                              <1> sysvideo_1:	
 51232 0000D5E8 80E303              <1> 	and	bl, 3
 51233 0000D5EB 7535                <1> 	jnz	short sysvideo_2 ; user to system display page transfer
 51234                              <1> 	; system to system video page (content) transfer
 51235                              <1> 	; cl = display page number, source
 51236 0000D5ED 80F907              <1> 	cmp	cl, 7
 51237                              <1> 	;ja	sysret ; invalid (nothing to do), [u.r0] = 0
 51238 0000D5F0 760A                <1> 	jna	short sysvideo_1_0
 51239 0000D5F2 FEC1                <1> 	inc	cl ; 0FFh -> 0 ("use current video page")
 51240 0000D5F4 7527                <1> 	jnz	short sysvideo_1_2  ; invalid
 51241 0000D5F6 8A0D[AE770100]      <1> 	mov	cl, [ACTIVE_PAGE]
 51242                              <1> sysvideo_1_0:
 51243                              <1> 	; 28/01/2021
 51244 0000D5FC 38D1                <1> 	cmp	cl, dl
 51245 0000D5FE 741D                <1> 	je	short sysvideo_1_2  ; same video page !
 51246                              <1> 
 51247                              <1> 	; system to system video/display page transfer (mode 0)
 51248                              <1> 	; 21/11/2020
 51249                              <1> 	;mov	esi, 0B8000h
 51250                              <1> 	;movzx	eax, cl
 51251                              <1> 	;mov	edx, 4096 ; [CRT_LEN] = 1000h for video mode 3
 51252                              <1> 	;mov	ecx, edx
 51253                              <1> 	;mul	edx
 51254                              <1> 	;add	esi, eax
 51255                              <1> 	; 28/01/2021
 51256                              <1> 	;movzx	esi, cl
 51257                              <1> 	;shl	si, 12 ; * 4096
 51258                              <1> 	;add	esi, 0B8000h 
 51259                              <1> 	
 51260                              <1> 	; 28/01/2021
 51261 0000D600 A3[1C010300]        <1> 	mov	[u.r0], eax ; 4096
 51262 0000D605 BE00800B00          <1> 	mov	esi, 0B8000h
 51263 0000D60A 08C9                <1> 	or	cl, cl
 51264 0000D60C 7409                <1> 	jz	short sysvideo_1_1
 51265                              <1> 	; 07/02/2021
 51266                              <1> 	;mov	al, cl ; display/video page
 51267                              <1> 	;xor	ah, ah
 51268                              <1> 	;shl	ax, 12 ; * 4096
 51269                              <1> 	; 23/07/2022
 51270 0000D60E 30C0                <1>  	xor	al, al
 51271                              <1> 	;xor	eax, eax
 51272 0000D610 88CC                <1> 	mov	ah, cl ; CL * 256
 51273 0000D612 C1E004              <1> 	shl	eax, 4 ; * 16 = CL * 4096
 51274 0000D615 01C6                <1> 	add	esi, eax
 51275                              <1> sysvideo_1_1:
 51276                              <1> 	; 21/11/2020
 51277                              <1> 	;;mov	ecx, 4096
 51278                              <1> 	;mov	ecx, eax ; 4096
 51279                              <1> 	;;mov	[u.r0], ecx ; 4096 bytes
 51280                              <1> 	; 28/01/2021	
 51281                              <1> 	;mov	[u.r0], cx
 51282 0000D617 31C9                <1> 	xor	ecx, ecx
 51283 0000D619 B504                <1> 	mov	ch, 4 ; mov ecx, 1024
 51284                              <1> 	;shr	cx, 2 ; / 4
 51285 0000D61B F3A5                <1> 	rep	movsd
 51286                              <1> sysvideo_1_2:
 51287 0000D61D E9D0F6FFFF          <1> 	jmp	sysret
 51288                              <1> sysvideo_2:  
 51289 0000D622 80FB02              <1> 	cmp	bl, 2
 51290                              <1>         ;ja	sysret; invalid (user to user), [u.r0] = 0
 51291                              <1> 	; 28/01/2021
 51292 0000D625 7226                <1> 	jb	short sysvideo_3 ; user to system
 51293 0000D627 7404                <1> 	je	short sysvideo_2_0 ; system to user
 51294                              <1> 	; bl = 3
 51295 0000D629 89CA                <1> 	mov	edx, ecx ; save user's buffer addr
 51296 0000D62B 89F1                <1> 	mov	ecx, esi ; save swap address
 51297                              <1> sysvideo_2_0:
 51298                              <1> 	; bl = 2 (or bl = 3, stage 1)
 51299                              <1> 	; system to user video/display page transfer (mode 0)
 51300 0000D62D 89FE                <1> 	mov	esi, edi
 51301 0000D62F 89CF                <1> 	mov	edi, ecx ; user buffer ; 28/01/2021
 51302                              <1> 	; 21/11/2020
 51303 0000D631 89C1                <1> 	mov	ecx, eax ; 4096
 51304 0000D633 E8F5360000          <1> 	call	transfer_to_user_buffer ; fast transfer
 51305                              <1> 	;jc	sysret ; [u.r0] = 0
 51306 0000D638 72E3                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
 51307                              <1> 	; 28/01/2021
 51308 0000D63A 80FB03              <1> 	cmp	bl, 3
 51309 0000D63D 7408                <1> 	je	short sysvideo_2_2
 51310                              <1> sysvideo_2_1:
 51311                              <1> 	; 21/11/2020
 51312 0000D63F 890D[1C010300]      <1> 	mov	[u.r0], ecx
 51313                              <1> 	;;mov	[u.r0], cx
 51314                              <1> 	;jmp	sysret
 51315 0000D645 EBD6                <1> 	jmp	short sysvideo_1_2
 51316                              <1> 
 51317                              <1> sysvideo_2_2:
 51318                              <1> 	; bl = 3 (exchange/swap) complete display page
 51319                              <1> 	; esi = video page start address
 51320                              <1> 	; edx = user's buffer address
 51321                              <1> 	
 51322                              <1> 	;mov	ecx, 4096
 51323 0000D647 89F7                <1> 	mov	edi, esi ; video page start address
 51324 0000D649 89D6                <1> 	mov	esi, edx ; user's (new page) buffer address
 51325 0000D64B EB04                <1> 	jmp	short sysvideo_2_3
 51326                              <1> sysvideo_3: 
 51327                              <1> 	; bl = 1 (or bl = 3, stage 2)
 51328                              <1> 	; user to system video/display page transfer (mode 0)	
 51329 0000D64D 89CE                <1> 	mov	esi, ecx ; user buffer
 51330                              <1> 	; edi = video page address
 51331                              <1> 	; 21/11/2020
 51332 0000D64F 89C1                <1> 	mov	ecx, eax ; 4096
 51333                              <1> sysvideo_2_3:
 51334 0000D651 E821370000          <1> 	call	transfer_from_user_buffer ; fast transfer
 51335                              <1> 	;jc	sysret ; [u.r0] = 0
 51336 0000D656 72C5                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
 51337 0000D658 EBE5                <1> 	jmp	short sysvideo_2_1
 51338                              <1> 
 51339                              <1> 	; 21/11/2020
 51340                              <1> 	;mov	[u.r0], ecx
 51341                              <1> 	;;mov	[u.r0], cx
 51342                              <1> 	;;jmp	sysret
 51343                              <1> 	;jmp	short sysvideo_1_2 ; 28/01/2021
 51344                              <1> 
 51345                              <1> sysvideo_4:
 51346                              <1> 	; 23/07/2022
 51347                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
 51348                              <1> 
 51349                              <1> 	; Display page window transfer etc.
 51350 0000D65A 80E303              <1> 	and	bl, 3
 51351                              <1>         ;jnz	sysvideo_9 ; user to system or system to user
 51352                              <1> 	; 23/07/2022
 51353 0000D65D 7405                <1> 	jz	short sysvideo_4_0
 51354 0000D65F E9E3000000          <1> 	jmp	sysvideo_9
 51355                              <1> sysvideo_4_0:
 51356                              <1> 	; 21/11/2020
 51357                              <1> 	; system to system video/display page window transfer (mode 0)
 51358 0000D664 81FE00800B00        <1> 	cmp	esi, 0B8000h	; source buffer address (system)
 51359                              <1> 	;jb	sysret
 51360                              <1> 	; 23/07/2022
 51361 0000D66A 7245                <1> 	jb	short sysvideo_4_3  ; jmp sysret
 51362 0000D66C 81FE00000C00        <1> 	cmp	esi, 0B8000h+(4096*8)
 51363                              <1> 	; 23/07/2022
 51364                              <1> 	;jnb	sysret
 51365 0000D672 733D                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
 51366 0000D674 81FF00800B00        <1> 	cmp	edi, 0B8000h	; destination buffer address (system)	
 51367                              <1> 	;jb	sysret
 51368                              <1> 	; 23/07/2022
 51369 0000D67A 7235                <1> 	jb	short sysvideo_4_3  ; jmp sysret
 51370 0000D67C 81FF00000C00        <1>         cmp     edi, 0B8000h+(4096*8)
 51371                              <1> 	; 23/07/2022
 51372                              <1> 	;jnb	sysret
 51373 0000D682 732D                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
 51374                              <1> 	;
 51375 0000D684 51                  <1> 	push	ecx ; X1 and Y1 position - top left column, row
 51376 0000D685 0FB7C1              <1> 	movzx	eax, cx ; top left column
 51377                              <1> 	; 21/11/2020
 51378 0000D688 C1E910              <1> 	shr	ecx, 16 ; top row
 51379 0000D68B 740E                <1> 	jz	short sysvideo_4_1 ; bypass following code
 51380 0000D68D 52                  <1> 	push	edx ; X2 and Y2 position - bottom right column, row
 51381 0000D68E 50                  <1> 	push	eax
 51382 0000D68F 66B8A000            <1> 	mov	ax, 80*2 ; 80 colums, 160 bytes per row
 51383 0000D693 F7E1                <1> 	mul	ecx
 51384                              <1> 		; eax = offset for start row number 
 51385 0000D695 01C6                <1> 	add	esi, eax
 51386 0000D697 01C7                <1> 	add	edi, eax
 51387 0000D699 58                  <1> 	pop	eax
 51388 0000D69A 5A                  <1> 	pop	edx
 51389                              <1> sysvideo_4_1:
 51390                              <1> 	;shl	ax, 1 ; * 2 ; convert start column number to offset
 51391                              <1> 	; 23/07/2022
 51392 0000D69B D1E0                <1> 	shl	eax, 1
 51393 0000D69D 7404                <1> 	jz	short sysvideo_4_2	
 51394 0000D69F 01C6                <1> 	add	esi, eax
 51395 0000D6A1 01C7                <1> 	add	edi, eax
 51396                              <1> 		; esi = source page window start offset
 51397                              <1> 		; edi = destination page window start offset
 51398                              <1> sysvideo_4_2:
 51399 0000D6A3 59                  <1> 	pop	ecx
 51400                              <1> 	;mov	eax, 0B8000h+(80*25*2*8)
 51401                              <1> 	; 21/11/2020
 51402 0000D6A4 B800000C00          <1> 	mov	eax, 0B8000h+(4096*8)
 51403 0000D6A9 39C6                <1> 	cmp	esi, eax
 51404                              <1> 	;jnb	sysret ; out of video page
 51405                              <1> 	; 23/07/2022
 51406 0000D6AB 7304                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
 51407 0000D6AD 39C6                <1> 	cmp	esi, eax
 51408                              <1> 	;jnb	sysret  ;out of video page
 51409                              <1> 	; 23/07/2022
 51410 0000D6AF 7205                <1> 	jb	short sysvideo_4_4
 51411                              <1> sysvideo_4_3:
 51412 0000D6B1 E93CF6FFFF          <1> 	jmp	sysret
 51413                              <1> sysvideo_4_4:
 51414 0000D6B6 56                  <1> 	push	esi ; ****
 51415 0000D6B7 57                  <1> 	push	edi ; ***
 51416 0000D6B8 52                  <1> 	push	edx ; **
 51417 0000D6B9 51                  <1> 	push	ecx ; *
 51418 0000D6BA C1E910              <1> 	shr	ecx, 16 ; top row
 51419 0000D6BD C1EA10              <1> 	shr	edx, 16 ; bottom row
 51420                              <1> 	; 21/11/2020
 51421                              <1> 	;cmp	ecx, 24 ; max. 25 rows
 51422 0000D6C0 6683F918            <1> 	cmp	cx, 24
 51423 0000D6C4 7778                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
 51424                              <1> 	;cmp	edx, 24 ; max. 25 rows
 51425 0000D6C6 6683FA18            <1> 	cmp	dx, 24
 51426 0000D6CA 7772                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0		
 51427 0000D6CC 28CA                <1> 	sub	dl, cl ; end >= start
 51428 0000D6CE 726E                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
 51429                              <1> 	; 21/11/2020
 51430 0000D6D0 89D3                <1> 	mov	ebx, edx ; row count - 1
 51431 0000D6D2 7415                <1> 	jz	short sysvideo_4_5
 51432 0000D6D4 50                  <1> 	push	eax ; *****
 51433 0000D6D5 B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
 51434 0000D6DA F7E3                <1> 	mul	ebx ; 21/11/2020
 51435                              <1> 		; eax = window end offset 
 51436                              <1> 		; (for the last row, before adding column bytes)
 51437 0000D6DC 01C6                <1> 	add	esi, eax
 51438 0000D6DE 01C7                <1> 	add	edi, eax
 51439 0000D6E0 58                  <1> 	pop	eax ; ***** ; mode 3 video memory end (0C000h)
 51440 0000D6E1 39C6                <1> 	cmp	esi, eax
 51441                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
 51442 0000D6E3 7359                <1> 	jnb	short sysvideo_6 ; 21/11/2020
 51443 0000D6E5 39C7                <1> 	cmp	edi, eax
 51444                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
 51445 0000D6E7 7355                <1> 	jnb	short sysvideo_6 ; 21/11/2020
 51446                              <1> sysvideo_4_5:
 51447 0000D6E9 59                  <1> 	pop	ecx ; *
 51448 0000D6EA 5A                  <1> 	pop	edx ; **
 51449 0000D6EB 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
 51450 0000D6F1 81E2FFFF0000        <1> 	and	edx, 0FFFFh
 51451                              <1> 	; 21/11/2020
 51452                              <1> 	;cmp	ecx, 79 ; max. 80 columns
 51453 0000D6F7 6683F94F            <1> 	cmp	cx, 79
 51454 0000D6FB 7743                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
 51455                              <1> 	;cmp	edx, 79 ; max. 80 columns
 51456 0000D6FD 6683FA4F            <1> 	cmp	dx, 79 
 51457 0000D701 773D                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
 51458 0000D703 28CA                <1> 	sub	dl, cl
 51459 0000D705 7639                <1> 	jna	short sysvideo_7 ; invalid, [u.r0] = 0
 51460                              <1> 	; 21/11/2020
 51461 0000D707 740E                <1> 	jz	short sysvideo_4_6 
 51462                              <1> 	; edx = column count (width) - 1
 51463 0000D709 D0E2                <1> 	shl	dl, 1 ; * 2 ; byte offset (in end row)
 51464 0000D70B 01D6                <1> 	add	esi, edx
 51465 0000D70D 01D7                <1> 	add	edi, edx
 51466                              <1> 		; esi = source page window end offset
 51467                              <1> 		; edi = destination page window end offset
 51468 0000D70F 39C6                <1> 	cmp	esi, eax ; video memory end
 51469                              <1> 	;ja	short sysvideo_7
 51470 0000D711 732D                <1> 	jnb	short sysvideo_7 ; 21/11/2020
 51471 0000D713 39C7                <1> 	cmp	edi, eax ; video memory end
 51472                              <1> 	;ja	short sysvideo_7
 51473 0000D715 7329                <1> 	jnb	short sysvideo_7 ; 21/11/2020
 51474                              <1> sysvideo_4_6:
 51475 0000D717 5F                  <1> 	pop	edi ; ***
 51476 0000D718 5E                  <1> 	pop	esi ; ****
 51477 0000D719 FEC3                <1> 	inc	bl ; row count - 1 -> row count	
 51478 0000D71B FEC2                <1> 	inc	dl ; column count
 51479 0000D71D 88D7                <1> 	mov	bh, dl
 51480 0000D71F D0E2                <1> 	shl	dl, 1 ; convert column count to byte offset
 51481                              <1> 	; 21/11/2020
 51482                              <1> 	; esi = source page window start offset
 51483                              <1> 	; edi = destination page window start offset
 51484 0000D721 B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
 51485                              <1> 	; Note: 160 bytes per row (even if move count < 160)
 51486                              <1> sysvideo_5:	
 51487 0000D726 88F9                <1> 	mov	cl, bh ; move/transfer -word- count per row
 51488 0000D728 0115[1C010300]      <1> 	add	[u.r0], edx ; transfer count in bytes
 51489 0000D72E F366A5              <1> 	rep	movsw
 51490 0000D731 01C6                <1> 	add	esi, eax ; + 160 bytes to next row
 51491 0000D733 01C7                <1> 	add	edi, eax ; + 160 bytes to next row
 51492 0000D735 FECB                <1> 	dec	bl ; remain count of rows
 51493 0000D737 75ED                <1> 	jnz	short sysvideo_5
 51494 0000D739 E9B4F5FFFF          <1> 	jmp	sysret
 51495                              <1> 
 51496                              <1> sysvideo_6:
 51497 0000D73E 59                  <1> 	pop	ecx ; *
 51498 0000D73F 5A                  <1> 	pop	edx ; **
 51499                              <1> sysvideo_7:	
 51500 0000D740 5F                  <1> 	pop	edi ; ***
 51501 0000D741 5E                  <1> 	pop	esi ; ****
 51502                              <1> sysvideo_8:
 51503 0000D742 E9ABF5FFFF          <1> 	jmp	sysret
 51504                              <1> 
 51505                              <1> sysvideo_9:
 51506                              <1> 	; user to system or system to user window transfer
 51507                              <1> 	; 28/01/2021 (bl = 3 -> swap/exchange)
 51508                              <1> 	;cmp	bl, 2
 51509                              <1> 	;;ja	sysret	; user to user transfer is invalid
 51510                              <1> 	;		; [u.r0] = 0
 51511                              <1> 	;ja	short sysvideo_8 ; 26/12/2020
 51512                              <1> 
 51513                              <1> 	; 28/01/2021
 51514 0000D747 80FB02              <1> 	cmp	bl, 2
 51515 0000D74A 7604                <1> 	jna	short sysvideo_9_8 
 51516                              <1> 
 51517                              <1> 	; swap/ exchange video memory and user mem windows
 51518                              <1> 	; edi = swap address in user's memory space
 51519 0000D74C 21FF                <1> 	and	edi, edi
 51520 0000D74E 74F2                <1> 	jz	short sysvideo_8 ; invalid ; 28/01/2021
 51521                              <1>  
 51522                              <1> sysvideo_9_8:		
 51523 0000D750 56                  <1> 	push	esi ; ****
 51524 0000D751 57                  <1> 	push	edi ; ***
 51525 0000D752 52                  <1> 	push	edx ; **
 51526 0000D753 51                  <1> 	push	ecx ; *
 51527                              <1> 
 51528 0000D754 C1E910              <1> 	shr	ecx, 16 ; top row
 51529 0000D757 C1EA10              <1> 	shr	edx, 16 ; bottom row
 51530                              <1> 	
 51531                              <1> 	; 21/11/2020
 51532                              <1> 	;cmp	ecx, 24 ; max. 25 rows
 51533 0000D75A 6683F918            <1> 	cmp	cx, 24
 51534 0000D75E 77DE                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
 51535                              <1> 	;cmp	edx, 24 ; max. 25 rows
 51536 0000D760 6683FA18            <1> 	cmp	dx, 24
 51537 0000D764 77D8                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0	
 51538 0000D766 28CA                <1> 	sub	dl, cl
 51539 0000D768 72D4                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
 51540                              <1> 
 51541                              <1> 	;mov	ch, cl ; top row
 51542                              <1> 	;mov	cl, [ACTIVE_PAGE]
 51543                              <1> 
 51544                              <1> 	;mov	edi, 80*25*2 ; 4000
 51545                              <1> 	; 21/11/2020
 51546                              <1> 	;mov	edi, 4096 ; [CRT_LEN = 4096 for video mode 3 
 51547                              <1> 	;shl	edi, cl  ; ! wrong for page 2 to page 7 !
 51548                              <1> 	;;add	edi, 0B8000h - 80*25*2
 51549                              <1> 	;add	edi, 0B8000h - 1000h ; - 4096
 51550                              <1> 	
 51551                              <1> 	; 21/11/2020
 51552                              <1> 	;xor	eax, eax
 51553                              <1> 	;mov	edi, 0B8000h
 51554                              <1> 	;and	cl, cl ; is video page = 0 ?
 51555                              <1> 	;jz	short sysvideo_9_1 ; yes
 51556                              <1> 	; eax = 0
 51557                              <1> 
 51558                              <1> ;sysvideo_9_0:
 51559                              <1> 	;add	ax, 4096
 51560                              <1> 	;dec	cl
 51561                              <1> 	;jnz	short sysvideo_9_0
 51562                              <1> 	;add	edi, eax
 51563                              <1> 	;	; edi = video page start address
 51564                              <1> 
 51565                              <1> 	; 21/11/2020
 51566 0000D76A BF00800B00          <1> 	mov	edi, 0B8000h
 51567 0000D76F 803D[AE770100]00    <1> 	cmp	byte [ACTIVE_PAGE], 0
 51568 0000D776 760C                <1> 	jna	short sysvideo_9_1
 51569                              <1> stsvideo_9_0:
 51570 0000D778 B010                <1> 	mov	al, 16 ; 4096/256
 51571 0000D77A F625[AE770100]      <1> 	mul	byte [ACTIVE_PAGE] 
 51572 0000D780 86E0                <1> 	xchg	ah, al ; * 256
 51573 0000D782 01C7                <1> 	add	edi, eax
 51574                              <1> 		; edi = video page start address
 51575                              <1> sysvideo_9_1:
 51576                              <1> 	; bl = transfer direction 
 51577                              <1> 	;     (1 = from user, 2 = to user)
 51578                              <1> 	;     (3 = swap) ; 28/01/2021
 51579 0000D784 88D7                <1> 	mov	bh, dl ; row count - 1
 51580                              <1> 	;mov	dl, ch ; top row
 51581                              <1> 	; 21/11/2020
 51582 0000D786 08C9                <1> 	or	cl, cl ; top row number
 51583 0000D788 7408                <1> 	jz	short sysvideo_9_2
 51584                              <1> 
 51585                              <1> 	;mov	eax, 80*2
 51586 0000D78A 66B8A000            <1> 	mov	ax, 80*2 ; 160, bytes per row
 51587 0000D78E F7E1                <1> 	mul	ecx ; 22/11/2020
 51588 0000D790 01C7                <1> 	add	edi, eax
 51589                              <1> 		; edi = window start address for top row
 51590                              <1> sysvideo_9_2:
 51591 0000D792 59                  <1> 	pop	ecx ; *
 51592 0000D793 5A                  <1> 	pop	edx ; **
 51593 0000D794 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
 51594 0000D79A 81E2FFFF0000        <1> 	and	edx, 0FFFFh
 51595                              <1> 	; 21/11/2020
 51596                              <1> 	;cmp	ecx, 79 ; max. 80 columns
 51597 0000D7A0 6683F94F            <1> 	cmp	cx, 79
 51598 0000D7A4 779A                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
 51599                              <1> 	;cmp	edx, 79 ; max. 80 columns
 51600 0000D7A6 6683FA4F            <1> 	cmp	dx, 79
 51601 0000D7AA 7794                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
 51602                              <1> 	
 51603 0000D7AC 28CA                <1> 	sub	dl, cl
 51604 0000D7AE 7290                <1> 	jc	short sysvideo_7 ; invalid, [u.r0] = 0
 51605                              <1> 	
 51606 0000D7B0 08C9                <1> 	or	cl, cl ; left column 
 51607 0000D7B2 7404                <1> 	jz	short sysvideo_9_3 ; 0
 51608                              <1> 
 51609                              <1> 	; 21/11/2020
 51610 0000D7B4 D0E1                <1> 	shl	cl, 1  ; column * 2
 51611 0000D7B6 01CF                <1> 	add	edi, ecx
 51612                              <1> 		; edi = window start addr for top left column
 51613                              <1> sysvideo_9_3:
 51614 0000D7B8 88D1                <1> 	mov	cl, dl
 51615 0000D7BA FEC1                <1> 	inc	cl ; column count
 51616 0000D7BC D0E1                <1> 	shl	cl, 1 ; column count * 2
 51617                              <1> 		; ecx = transfer count per row
 51618                              <1> 
 51619 0000D7BE 58                  <1> 	pop	eax ; *** (swap address)
 51620 0000D7BF 5E                  <1> 	pop	esi ; ****
 51621                              <1> 
 51622 0000D7C0 FEC7                <1> 	inc	bh  ; row count	
 51623                              <1> 	
 51624                              <1> 	;mov	edx, 80*2
 51625 0000D7C2 B2A0                <1> 	mov	dl, 80*2  ; bytes per row
 51626                              <1> 	;
 51627                              <1> 	;cmp	bl, 1 ; transfer direction
 51628                              <1> 	;ja	short sysvideo_11 ; system to user transfer
 51629                              <1> 	; 28/01/2021
 51630 0000D7C4 F6C301              <1> 	test	bl, 1
 51631 0000D7C7 7439                <1> 	jz	short sysvideo_11 ; system to user transfer
 51632                              <1> 
 51633                              <1> 	; user to system video/display page window transfer (mode 0)	
 51634 0000D7C9 21C0                <1> 	and	eax, eax ; swap address
 51635 0000D7CB 741B                <1> 	jz	short sysvideo_10 ; no window swap
 51636                              <1> sysvideo_9_7: ; 28/01/2021
 51637                              <1> 	; save previous window content in user's buffer (swap address)
 51638 0000D7CD 56                  <1> 	push	esi ; user buffer
 51639 0000D7CE 57                  <1> 	push	edi ; beginning address of the window
 51640                              <1> 	; 21/11/2020
 51641 0000D7CF 53                  <1> 	push	ebx ; save bh
 51642 0000D7D0 89FE                <1> 	mov	esi, edi
 51643 0000D7D2 89C7                <1> 	mov	edi, eax
 51644                              <1> sysvideo_9_4:
 51645 0000D7D4 E854350000          <1> 	call	transfer_to_user_buffer ; fast transfer
 51646 0000D7D9 7208                <1> 	jc	short sysvideo_9_5
 51647                              <1> 	; ecx = actual transfer count (must be same with input)
 51648 0000D7DB 01D6                <1> 	add	esi, edx ; next row address of (video page) window 
 51649 0000D7DD 01CF                <1> 	add	edi, ecx ; next row address of user's window
 51650                              <1> 		; Note: ecx may be less than row length of video page
 51651                              <1> 		; user's window uses offset according to window width
 51652 0000D7DF FECF                <1> 	dec	bh
 51653 0000D7E1 75F1                <1> 	jnz	short sysvideo_9_4 ; repeat for next row
 51654                              <1> sysvideo_9_5:
 51655 0000D7E3 5B                  <1> 	pop	ebx ; restore bh
 51656 0000D7E4 5F                  <1> 	pop	edi
 51657 0000D7E5 5E                  <1> 	pop	esi
 51658                              <1> 	;jnc	short sysvideo_10
 51659 0000D7E6 7215                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
 51660                              <1> ;sysvideo_9_6:
 51661                              <1> ;	jmp	sysret ; [u.r0] = 0
 51662                              <1> 
 51663                              <1> sysvideo_10:
 51664                              <1> 	; user to system video/display page window transfer (mode 0)	
 51665                              <1> 	; esi =	user buffer
 51666 0000D7E8 E88A350000          <1> 	call	transfer_from_user_buffer ; fast transfer
 51667                              <1> 	;jc	sysret
 51668 0000D7ED 720E                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
 51669                              <1> 	; ecx = actual transfer count (must be same with input)
 51670 0000D7EF 010D[1C010300]      <1> 	add	[u.r0], ecx ; actual transfer count
 51671 0000D7F5 01D7                <1> 	add	edi, edx ; next row address of (video page) window 
 51672 0000D7F7 01CE                <1> 	add	esi, ecx ; next row address of user's window
 51673                              <1> 		; Note: ecx may be less than row length of video page
 51674                              <1> 		; user's window uses offset according to window width
 51675 0000D7F9 FECF                <1> 	dec	bh
 51676 0000D7FB 75EB                <1> 	jnz	short sysvideo_10 ; repeat for next row
 51677                              <1> 	;jmp	sysret
 51678                              <1> sysvideo_9_6:
 51679 0000D7FD E9F0F4FFFF          <1> 	jmp	sysret
 51680                              <1> 	
 51681                              <1> sysvideo_11:
 51682                              <1> 	; system to user video/display page window transfer (mode 0)
 51683 0000D802 87FE                <1> 	xchg	edi, esi
 51684                              <1> sysvideo_12:
 51685                              <1> 	; esi = beginning addr of the (screen, video page) window
 51686                              <1> 	; edi =	user's buffer	
 51687 0000D804 E824350000          <1> 	call	transfer_to_user_buffer ; fast transfer
 51688                              <1> 	;jc	sysret
 51689                              <1> 	; 23/07/2022
 51690 0000D809 72F2                <1> 	jc	short sysvideo_9_6 ; jmp sysret	
 51691                              <1> 
 51692                              <1> 	; ecx = actual transfer count (must be same with input)
 51693 0000D80B 010D[1C010300]      <1> 	add	[u.r0], ecx
 51694 0000D811 01D6                <1> 	add	esi, edx ; next row (edx = 160)
 51695 0000D813 01CF                <1> 	add	edi, ecx ; next row of the user's window 
 51696                              <1> 			 ; (ecx <= 160)
 51697 0000D815 FECF                <1> 	dec	bh
 51698 0000D817 75EB                <1> 	jnz	short sysvideo_12
 51699                              <1> sysvideo_12_0:
 51700 0000D819 E9D4F4FFFF          <1> 	jmp	sysret
 51701                              <1> 
 51702                              <1> sysvideo_13:
 51703                              <1> 	; 28/12/2020
 51704 0000D81E 80FF01              <1> 	cmp	bh, 1
 51705 0000D821 7752                <1>         ja      short sysvideo_15 ; 23/11/2020
 51706                              <1> 
 51707                              <1> 	; 25/02/2021
 51708                              <1> 	; 12/02/2021
 51709                              <1> 	; 29/01/2021, 31/01/2021
 51710                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
 51711                              <1> 	; (major modification, from mode 13h to all VGA modes,
 51712                              <1> 	;  except super VGA modes and liner frame buffer method)
 51713                              <1> 
 51714                              <1> 	; BH = 1 = VGA Graphics mode (0A0000h) data transfers
 51715                              <1> 
 51716                              <1> 	; 29/01/2021
 51717 0000D823 66B84001            <1> 	mov	ax, 320	; 320 pixels
 51718 0000D827 F6C380              <1> 	test	bl, 80h	; bit 7 (screen width, 640 pixels)		
 51719 0000D82A 7407                <1> 	jz	short sysvideo_13_0
 51720                              <1> 	;shl	ax, 1	; 640 pixels
 51721                              <1> 	; 23/07/2022
 51722 0000D82C D1E0                <1> 	shl	eax, 1
 51723                              <1> 	;
 51724 0000D82E 80E37F              <1> 	and	bl, 7Fh
 51725 0000D831 7405                <1> 	jz	short sysvideo_14
 51726                              <1> sysvideo_13_0:
 51727                              <1> 	; 29/01/2021
 51728 0000D833 80FB41              <1> 	cmp	bl, 41h
 51729 0000D836 77E1                <1> 	ja	short sysvideo_12_0 ; invalid (unknown) sub function
 51730                              <1> sysvideo_14:
 51731 0000D838 66A3[3A100300]      <1> 	mov	[v_width], ax	; save screen width
 51732 0000D83E C705[3E100300]0000- <1> 	mov	dword [v_mem], 0A0000h  ; save video memory address
 51733 0000D846 0A00                <1>
 51734 0000D848 C705[42100300]0000- <1> 	mov	dword [v_siz], 65536	; save video memory size
 51735 0000D850 0100                <1>
 51736 0000D852 C705[4A100300]0000- <1> 	mov	dword [v_end], 0B0000h	; save end of video page
 51737 0000D85A 0B00                <1>
 51738 0000D85C B708                <1> 	mov	bh, 8
 51739 0000D85E 883D[3D100300]      <1> 	mov	[v_bpp], bh ; 8	; bits per pixel (256 colors)
 51740 0000D864 881D[3C100300]      <1> 	mov	[v_ops], bl	; VGA data transfer options
 51741                              <1> 	;mov	[maskbuff], edi ; 25/02/2021 
 51742 0000D86A 893D[4E100300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
 51743                              <1> 			; save mask color or bitmask buffer address
 51744 0000D870 E9BE000000          <1> 	jmp	sysvideo_15_7
 51745                              <1> 
 51746                              <1> sysvideo_15:
 51747                              <1> 	; 23/07/2022
 51748                              <1> 	; 28/12/2020
 51749 0000D875 80FF02              <1> 	cmp	bh, 2
 51750                              <1>         ;ja	sysvideo_16
 51751                              <1> 	; 23/07/2022
 51752 0000D878 7605                <1> 	jna	short sysvideo_15_17
 51753 0000D87A E9ED1E0000          <1> 	jmp	sysvideo_16
 51754                              <1> sysvideo_15_17:	; 23/07/2022
 51755                              <1> 	; 25/02/2021
 51756                              <1> 	; 12/02/2021
 51757                              <1> 	; 30/01/2021 - 31/01/2021
 51758                              <1> 	; 01/01/2021 - 29/01/2021
 51759                              <1> 	; 26/12/2020 - 27/12/2020
 51760                              <1> 	; 25/12/2020 (TRDOS 386 v2.0.3)
 51761                              <1> 	;
 51762                              <1> 	; BH = 2 = SVGA (VESA VBE) Graphics mode (LFB) data transfers
 51763                              <1> 
 51764                              <1> 	; 25/12/2020
 51765                              <1> 	; resolution table entry will be saved into EBP register
 51766                              <1> 
 51767 0000D87F 803D[3F090000]02    <1> 	cmp	byte [vbe3], 2 ; VESA VBE 3 video bios 
 51768                              <1> 			  ; or BOCHS/QEMU/VIRTUALBOX emu video bios
 51769 0000D886 724E                <1> 	jb	short sysvideo_15_4 ; no, nothing to do !
 51770 0000D888 770B                <1> 	ja	short sysvideo_15_0 ; yes
 51771                              <1> 
 51772                              <1> 	; Only Bochs/Plex86 (emu) vbe2 video bios is usable in pmid
 51773                              <1> 	; (if [vbe3] = 2) 
 51774 0000D88A A0[40090000]        <1> 	mov	al, [vbe2bios] ; Bochs vbios sign is from C0h to C5h
 51775 0000D88F 24F0                <1> 	and	al, 0F0h
 51776 0000D891 3CC0                <1> 	cmp	al, 0C0h
 51777 0000D893 7541                <1> 	jne	short sysvideo_15_4 ; unknown (vbe2) video bios
 51778                              <1> sysvideo_15_0:
 51779                              <1> 	; 29/01/2021
 51780 0000D895 80FB41              <1> 	cmp	bl, 41h
 51781 0000D898 773C                <1> 	ja	short sysvideo_15_4 ; invalid (unknown) sub function
 51782                              <1> 	; 29/01/2021
 51783 0000D89A 881D[3C100300]      <1> 	mov	[v_ops], bl	; SVGA data transfer options
 51784                              <1> 
 51785 0000D8A0 89D8                <1> 	mov	eax, ebx ; hw of ebx is vesa vbe video mode
 51786 0000D8A2 C1E810              <1> 	shr	eax, 16 ; ax = vesa vbe video mode
 51787 0000D8A5 7513                <1> 	jnz	short sysvideo_15_2 
 51788                              <1> 	; ax = 0
 51789                              <1> 
 51790                              <1> 	; check & use current video mode
 51791 0000D8A7 803D[9E660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; extended (SVGA) mode ?
 51792 0000D8AE 7526                <1> 	jne	short sysvideo_15_4 ; no
 51793                              <1> sysvideo_15_1:
 51794                              <1> 	; use current vbe (svga) video mode
 51795 0000D8B0 66A1[D20F0300]      <1> 	mov	ax, [video_mode] ; extended (SVGA, VESA VBE) mode
 51796 0000D8B6 6625FF01            <1> 	and	ax, 1FFh ; vesa vbe video mode: 1XXh
 51797                              <1> sysvideo_15_2:
 51798                              <1> 	; 29/01/2021
 51799                              <1> 	;mov	[maskbuff], edi ; 25/02/2021
 51800 0000D8BA 893D[4E100300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
 51801                              <1> 			; save mask color or bitmask buffer address
 51802 0000D8C0 BD[2A6A0000]        <1> 	mov	ebp, b_vbe_modes ; vbe mode table (in 'vidata.s')
 51803                              <1> sysvideo_15_3:
 51804 0000D8C5 663B4500            <1> 	cmp	ax, [ebp]
 51805 0000D8C9 7410                <1> 	je	short sysvideo_15_5
 51806 0000D8CB 83C508              <1> 	add	ebp, 8 ; vbe mode table entry size
 51807 0000D8CE 81FD[EA6A0000]      <1> 	cmp	ebp, end_of_b_vbe_modes
 51808 0000D8D4 72EF                <1>  	jb	short sysvideo_15_3	
 51809                              <1> sysvideo_15_4:
 51810                              <1> 	; desired video mode is not a valid (implemented)
 51811                              <1> 	;	  extended (VESA VBE, SVGA) video mode
 51812                              <1> 	;
 51813                              <1> 	; nothing to do !
 51814                              <1> 
 51815                              <1>  	; [u.r0] = 0  ; return value of EAX
 51816 0000D8D6 E917F4FFFF          <1>  	jmp	sysret
 51817                              <1> 
 51818                              <1> sysvideo_15_5:
 51819                              <1> 	; get LFB address
 51820 0000D8DB A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 51821 0000D8E0 09C0                <1> 	or	eax, eax
 51822 0000D8E2 7509                <1> 	jnz	short sysvideo_15_6
 51823 0000D8E4 66A1[CC0E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB addr 
 51824                              <1> 				   ; (for vbe mode 118h)
 51825 0000D8EA C1E010              <1> 	shl	eax, 16
 51826                              <1> 	; 27/12/2020
 51827                              <1> 	;jz	short sysvideo_15_4
 51828                              <1> sysvideo_15_6:
 51829                              <1> 	; 29/01/2021
 51830 0000D8ED A3[3E100300]        <1> 	mov	[v_mem], eax ; save video memory address
 51831                              <1> 	
 51832                              <1> 	; 27/12/2020
 51833                              <1> 	; 26/12/2020
 51834 0000D8F2 8B4502              <1> 	mov	eax, [ebp+2] ; width, height
 51835                              <1> 	; 29/01/2021
 51836 0000D8F5 66A3[3A100300]      <1> 	mov	[v_width], ax ; save screen width
 51837                              <1> 	; 28/12/2020
 51838 0000D8FB 8A7D06              <1> 	mov	bh, [ebp+6] ; bpp
 51839                              <1> 	; 28/02/2021
 51840                              <1> 	; check default truecolor bpp value and use
 51841                              <1> 	; 32bpp instead of 24bpp if the default value
 51842                              <1> 	; has been set to 32bpp.
 51843 0000D8FE 80FF18              <1> 	cmp	bh, 24
 51844 0000D901 750B                <1> 	jne	short sysvideo_15_16
 51845 0000D903 803D[43740100]20    <1> 	cmp	byte [truecolor], 32
 51846                              <1> 		; Default truecolor bpp value,
 51847                              <1> 		; it is 32 for VBE3 video bios
 51848                              <1> 		; (it can be set to 32 or 24)
 51849 0000D90A 7502                <1> 	jne	short sysvideo_15_16 ; not VBE3 !
 51850                              <1> 				; or it is set to 24  	
 51851 0000D90C B720                <1> 	mov	bh, 32
 51852                              <1> 	; 28/02/2021
 51853                              <1> sysvideo_15_16:
 51854                              <1> 	; 29/01/2021
 51855 0000D90E 883D[3D100300]      <1> 	mov	[v_bpp], bh ; bits per pixel
 51856                              <1> 
 51857 0000D914 52                  <1> 	push	edx ; *
 51858 0000D915 0FB7D0              <1> 	movzx	edx, ax  ; width
 51859 0000D918 C1E810              <1> 	shr	eax, 16  ; height
 51860 0000D91B F7E2                <1> 	mul	edx
 51861                              <1> 	; eax = linear frame buffer size (pixels)
 51862                              <1> 	; 29/01/2021
 51863 0000D91D A3[42100300]        <1> 	mov	[v_siz], eax ; save video page size
 51864 0000D922 E8FD000000          <1> 	call	pixels_to_byte_count
 51865 0000D927 0305[3E100300]      <1> 	add	eax, [v_mem]
 51866 0000D92D A3[4A100300]        <1> 	mov	[v_end], eax ; save end of video page 
 51867 0000D932 5A                  <1> 	pop	edx ; *
 51868                              <1> 
 51869                              <1> 	; bh = bits per pixel
 51870                              <1> 	; (bh will not be used after here, 29/01/2021)
 51871                              <1> 
 51872                              <1> 	; bl = pixel operations & options
 51873                              <1> 	; ecx, edx, esi, edi input parameters
 51874                              <1> 	; [maskcolor] = edi input ; 25/02/2021
 51875                              <1> 
 51876                              <1> sysvideo_15_7:
 51877                              <1> 	; 29/01/2021
 51878                              <1> 	;test	byte [v_ops], 40h  ; system to user ?
 51879 0000D933 F6C340              <1> 	test	bl, 40h
 51880 0000D936 7517                <1> 	jnz	short sysvideo_15_9
 51881                              <1> 
 51882 0000D938 31C0                <1> 	xor	eax, eax
 51883 0000D93A 88D8                <1> 	mov	al, bl
 51884 0000D93C BB[62DA0000]        <1> 	mov	ebx, pixel_ops
 51885 0000D941 240F                <1> 	and	al, 0Fh ; isolate 16 pixel operations
 51886 0000D943 C0E002              <1> 	shl	al, 2 ; * 4 for dword table pointers 
 51887 0000D946 01C3                <1> 	add	ebx, eax
 51888                              <1> 
 51889                              <1> 	; ebx = subroutine address
 51890                              <1> 
 51891                              <1> 	; ecx, edx, esi, edi input parameters
 51892                              <1> 	; [maskbuff] = edi input
 51893                              <1> 	; [maskcolor] = edi input ; 25/02/2021
 51894                              <1> 
 51895 0000D948 FF13                <1> 	call	[ebx]		
 51896                              <1> sysvideo_15_8:
 51897 0000D94A E9A3F3FFFF          <1> 	jmp	sysret
 51898                              <1> 
 51899                              <1> sysvideo_15_9:
 51900                              <1> 	; system to user display page or window copy
 51901                              <1> 	;test	byte [v_ops], 1 ; window copy ?
 51902 0000D94F F6C301              <1> 	test	bl, 1	
 51903 0000D952 7521                <1> 	jnz	short sysvideo_15_10
 51904                              <1> 
 51905                              <1> 	; display page (full screen copy)
 51906 0000D954 8B35[3E100300]      <1> 	mov	esi, [v_mem] ; LFB start address
 51907 0000D95A A1[42100300]        <1> 	mov	eax, [v_siz]
 51908 0000D95F E8C0000000          <1> 	call	pixels_to_byte_count
 51909 0000D964 89C1                <1> 	mov	ecx, eax ; transfer count in bytes
 51910                              <1> 	;edi = user's buffer address
 51911 0000D966 E8C2330000          <1> 	call	transfer_to_user_buffer
 51912 0000D96B 72DD                <1> 	jc	short sysvideo_15_8	
 51913 0000D96D 890D[1C010300]      <1> 	mov	[u.r0], ecx
 51914 0000D973 EBD5                <1> 	jmp	short sysvideo_15_8
 51915                              <1> 
 51916                              <1> sysvideo_15_10:
 51917 0000D975 E820000000          <1> 	call	sysvideo_15_12 ; window preparations
 51918 0000D97A 72CE                <1> 	jc	short sysvideo_15_8
 51919                              <1> 
 51920 0000D97C 8B35[46100300]      <1> 	mov	esi, [v_str]
 51921                              <1> sysvideo_15_11:
 51922                              <1> 	; esi = window's current row address (video mem)
 51923                              <1> 	; edi = current row (virtual) addr in user's buff
 51924                              <1> 	; ecx = transfer count per row
 51925 0000D982 E8A6330000          <1> 	call	transfer_to_user_buffer
 51926 0000D987 72C1                <1> 	jc	short sysvideo_15_8
 51927 0000D989 010D[1C010300]      <1>  	add	[u.r0], ecx
 51928 0000D98F 4B                  <1> 	dec	ebx
 51929 0000D990 74B8                <1> 	jz	short sysvideo_15_8 ; ok.
 51930                              <1> 	; next row
 51931 0000D992 01CF                <1> 	add	edi, ecx ; next row in user's buffer
 51932 0000D994 01D6                <1> 	add	esi, edx ; next row of window (system)
 51933 0000D996 EBEA                <1> 	jmp	short sysvideo_15_11
 51934                              <1> 
 51935                              <1> sysvideo_15_14:
 51936 0000D998 F9                  <1> 	stc	 ; error !
 51937                              <1> sysvideo_15_15:
 51938 0000D999 C3                  <1> 	retn
 51939                              <1> 
 51940                              <1> sysvideo_15_12:
 51941                              <1> 	; 30/01/2021
 51942                              <1> 	; 29/01/2021
 51943                              <1> 	; Window address preparations for window copy
 51944 0000D99A 6621D2              <1> 	and	dx, dx
 51945 0000D99D 74F9                <1> 	jz	short sysvideo_15_14 ; invalid (zero columns)
 51946                              <1> 	;test	edx, 0FFFF0000h
 51947                              <1> 	;jz	short sysvideo_15_14 ; invalid (zero rows)
 51948 0000D99F 81FA00000100        <1> 	cmp	edx, 65536
 51949 0000D9A5 72F2                <1> 	jb	short sysvideo_15_15 ; invalid (zero rows)
 51950 0000D9A7 89C8                <1> 	mov	eax, ecx ; start position (row, column)
 51951 0000D9A9 E899000000          <1> 	call	calc_pixel_offset
 51952 0000D9AE 3B05[42100300]      <1> 	cmp	eax, [v_siz]
 51953 0000D9B4 73E2                <1> 	jnb	short sysvideo_15_14 ; out of display page
 51954                              <1> 				; nothing to do
 51955 0000D9B6 E869000000          <1> 	call	pixels_to_byte_count
 51956 0000D9BB 0305[3E100300]      <1> 	add	eax, [v_mem]
 51957 0000D9C1 A3[46100300]        <1> 	mov	[v_str], eax ; window start address
 51958                              <1> 			     ; (addr of top left corner)
 51959                              <1> 	; check column limit
 51960 0000D9C6 89C8                <1> 	mov	eax, ecx
 51961 0000D9C8 6601D0              <1> 	add	ax, dx  ; add columns to start column
 51962 0000D9CB 72CC                <1> 	jc	short sysvideo_15_15 ; cf = 1
 51963 0000D9CD 663B05[3A100300]    <1> 	cmp	ax, [v_width]
 51964 0000D9D4 77C2                <1> 	ja	short sysvideo_15_14
 51965                              <1> 
 51966 0000D9D6 89D0                <1> 	mov	eax, edx ; size
 51967 0000D9D8 2D00000100          <1> 	sub	eax, 65536 ; row count -> 0 based row #
 51968 0000D9DD E865000000          <1> 	call	calc_pixel_offset
 51969 0000D9E2 3B05[42100300]      <1> 	cmp	eax, [v_siz] ; video (display) page size
 51970 0000D9E8 77AE                <1> 	ja	short sysvideo_15_14 ; out of display page
 51971                              <1> 				; nothing to do
 51972 0000D9EA E835000000          <1> 	call	pixels_to_byte_count
 51973 0000D9EF 0305[46100300]      <1> 	add	eax, [v_str] ; window start address
 51974 0000D9F5 3B05[4A100300]      <1> 	cmp	eax, [v_end] ; window end address (+1)
 51975                              <1> 			 ; (addr of bottom right corner +1)	
 51976 0000D9FB 779B                <1> 	ja	short sysvideo_15_14 ; out of display page
 51977                              <1> 				; nothing to do
 51978 0000D9FD 89D3                <1> 	mov	ebx, edx
 51979 0000D9FF C1EB10              <1> 	shr	ebx, 16 
 51980                              <1> 	; ebx = row count
 51981 0000DA02 81E2FFFF0000        <1> 	and	edx, 0FFFFh
 51982                              <1> 	; edx = transfer count per row (from user's buffer)
 51983                              <1> 	;	(in pixels, window width)
 51984 0000DA08 89D0                <1> 	mov	eax, edx
 51985 0000DA0A A3[52100300]        <1> 	mov	[pixcount], eax ; 27/02/2021
 51986 0000DA0F E810000000          <1> 	call	pixels_to_byte_count
 51987 0000DA14 89C1                <1> 	mov	ecx, eax
 51988                              <1> 	; ecx = transfer count per row (from user's buffer)
 51989                              <1> 	;	(in bytes, window width)
 51990 0000DA16 66A1[3A100300]      <1> 	mov	ax, [v_width]
 51991 0000DA1C E803000000          <1> 	call	pixels_to_byte_count
 51992 0000DA21 89C2                <1> 	mov	edx, eax
 51993                              <1> 	; edx = byte count per row
 51994 0000DA23 C3                  <1> 	retn ; cf = 0
 51995                              <1> 
 51996                              <1> pixels_to_byte_count:
 51997                              <1> 	; 29/01/2021
 51998                              <1> 	; INPUT:
 51999                              <1> 	;   eax = pixel count
 52000                              <1> 	; OUTPUT:
 52001                              <1> 	;   eax = byte count
 52002                              <1> 	;
 52003 0000DA24 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8
 52004 0000DA2B 7619                <1> 	jna	short pixtobc_3 ; 8 bit colors
 52005 0000DA2D 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24
 52006 0000DA34 720A                <1> 	jb	short pixtobc_1 ; 16 bit colors
 52007 0000DA36 770B                <1> 	ja	short pixtobc_2 ; 32 bit colors
 52008                              <1> 	; 24 bit pixels
 52009                              <1> 	; eax = eax * 3
 52010                              <1> 	;push	edx
 52011                              <1> 	;mov	edx, eax
 52012                              <1> 	;shl	eax, 1
 52013                              <1> 	;add	eax, edx
 52014                              <1> 	;pop	edx
 52015 0000DA38 50                  <1> 	push	eax
 52016 0000DA39 D1E0                <1> 	shl	eax, 1
 52017 0000DA3B 010424              <1> 	add	[esp], eax
 52018 0000DA3E 58                  <1> 	pop	eax
 52019 0000DA3F C3                  <1> 	retn		
 52020                              <1> pixtobc_1:
 52021                              <1> 	; 32 bit pixels
 52022                              <1> 	; eax = eax * 2
 52023 0000DA40 D1E0                <1> 	shl	eax, 1
 52024 0000DA42 C3                  <1> 	retn
 52025                              <1> pixtobc_2:
 52026                              <1> 	; 16 bit pixels
 52027                              <1> 	; eax = eax * 4
 52028 0000DA43 C1E002              <1> 	shl	eax, 2
 52029                              <1> pixtobc_3:
 52030 0000DA46 C3                  <1> 	retn
 52031                              <1> 
 52032                              <1> calc_pixel_offset:
 52033                              <1> 	; 29/01/2021
 52034                              <1> 	; INPUT:
 52035                              <1> 	;   eax = pixel position (row, column)
 52036                              <1> 	; OUTPUT:
 52037                              <1> 	;   eax = pixel offset (linear address)
 52038                              <1> 	;
 52039 0000DA47 52                  <1> 	push	edx
 52040 0000DA48 50                  <1> 	push	eax
 52041 0000DA49 C1E810              <1> 	shr	eax, 16
 52042 0000DA4C 7409                <1> 	jz	short cpixo_0
 52043                              <1> 	; eax = row 
 52044 0000DA4E 0FB715[3A100300]    <1> 	movzx	edx, word [v_width]
 52045 0000DA55 F7E2                <1> 	mul	edx
 52046                              <1> cpixo_0:
 52047                              <1> 	; eax = row * screen width
 52048 0000DA57 5A                  <1> 	pop	edx
 52049 0000DA58 81E2FFFF0000        <1> 	and	edx, 0FFFFh
 52050                              <1> 	; edx = column
 52051 0000DA5E 01D0                <1> 	add	eax, edx
 52052                              <1> 	; eax = (row * screen width) + column		
 52053 0000DA60 5A                  <1> 	pop	edx
 52054 0000DA61 C3                  <1> 	retn
 52055                              <1> 
 52056                              <1> 	; 02/02/2021
 52057                              <1> 	; 29/01/2021
 52058                              <1> pixel_ops:
 52059 0000DA62 [A2DA0000]          <1> 	dd	pix_op_cpy ; copy pixels (user to system)
 52060 0000DA66 [EDDF0000]          <1> 	dd	pix_op_new ; change (new, fill) color
 52061 0000DA6A [0ADB0000]          <1> 	dd	pix_op_add ; add color (up to 0FFh)
 52062 0000DA6E [BCDB0000]          <1> 	dd	pix_op_sub ; sub color (down to 0)
 52063 0000DA72 [D7DD0000]          <1> 	dd	pix_op_orc ; or color
 52064 0000DA76 [89DE0000]          <1> 	dd	pix_op_and ; and color
 52065 0000DA7A [3BDF0000]          <1> 	dd	pix_op_xor ; xor color
 52066 0000DA7E [B1E00000]          <1> 	dd	pix_op_not ; not color
 52067 0000DA82 [5BE10000]          <1> 	dd	pix_op_neg ; neg color
 52068 0000DA86 [05E20000]          <1> 	dd	pix_op_inc ; inc color
 52069 0000DA8A [AFE20000]          <1> 	dd	pix_op_dec ; dec color
 52070 0000DA8E [6EDC0000]          <1> 	dd	pix_op_mix ; mix color
 52071 0000DA92 [35DD0000]          <1> 	dd	pix_op_rpl ; replace color
 52072 0000DA96 [59E30000]          <1> 	dd	pix_op_blk ; copy pixel block(s) (sys)
 52073 0000DA9A [07E40000]          <1> 	dd	pix_op_lin ; write line(s)
 52074 0000DA9E [EAE70000]          <1> 	dd	pix_op_chr ; write character (font)
 52075                              <1> 
 52076                              <1> pix_op_cpy:
 52077                              <1> 	; 21/02/2021
 52078                              <1> 	; 06/02/2021
 52079                              <1> 	; 30/01/2021
 52080                              <1> 	; COPY PIXELS
 52081                              <1> 	;
 52082                              <1> 	; INPUT:
 52083                              <1> 	;  If bit 4 of BL or [v_ops] = 1 -window copy-
 52084                              <1> 	;  ECX = start position (row, column)
 52085                              <1> 	;        (HW = row, CX = column)
 52086                              <1> 	;  EDX = size (rows, colums)
 52087                              <1> 	;        (HW = rows, DX = columns)
 52088                              <1> 	;	 (0 -> invalid 	
 52089                              <1> 	;        (1 -> horizontal or vertical line)
 52090                              <1> 	;  If bit 4 of BL or [v_ops] = 0 -full screen-
 52091                              <1> 	;     ECX and EDX will not be used
 52092                              <1>   	;  ESI = user's buffer address
 52093                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52094                              <1> 	;
 52095                              <1> 	; OUTPUT:
 52096                              <1> 	; 	[u.r0] will be > 0 if succesful
 52097                              <1> 
 52098 0000DAA2 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52099 0000DAA9 752E                <1> 	jnz	short pix_op_cpy_w ; window
 52100                              <1> 
 52101 0000DAAB 8B3D[3E100300]      <1> 	mov	edi, [v_mem] ; 21/02/2021
 52102                              <1> 	
 52103                              <1> 	; Copy user's buffer content do display page
 52104                              <1> 	; (full screen copy)
 52105 0000DAB1 A1[42100300]        <1> 	mov	eax, [v_siz] ; video page size
 52106 0000DAB6 E869FFFFFF          <1> 	call	pixels_to_byte_count
 52107 0000DABB 89C1                <1> 	mov	ecx, eax ; transfer count
 52108                              <1> 	; esi = user's buffer address (virtual)
 52109 0000DABD F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
 52110 0000DAC4 7405                <1> 	jz	short pix_op_cpy_0 ; no	
 52111 0000DAC6 E96F0F0000          <1> 	jmp	m_pix_op_cpy ; copy pixels except mask color
 52112                              <1> pix_op_cpy_0:
 52113                              <1> 	; esi = user buffer for full screen copy
 52114                              <1> 	; edi = start of video memory 
 52115                              <1> 	;	(start of display page)
 52116                              <1> 	; ecx = byte count (display page size in bytes)
 52117 0000DACB E8A7320000          <1> 	call	transfer_from_user_buffer
 52118 0000DAD0 7206                <1> 	jc	short pix_op_cpy_1
 52119 0000DAD2 890D[1C010300]      <1> 	mov	[u.r0], ecx
 52120                              <1> pix_op_cpy_1:
 52121 0000DAD8 C3                  <1> 	retn	; 06/02/2021
 52122                              <1> 
 52123                              <1> pix_op_cpy_w:
 52124 0000DAD9 E8BCFEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52125 0000DADE 72F8                <1> 	jc	short pix_op_cpy_1
 52126                              <1> 	; ecx = bytes per row (to be applied)
 52127                              <1> 	; edx = screen width in bytes
 52128                              <1> 	; ebx = row count
 52129 0000DAE0 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52130 0000DAE6 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
 52131 0000DAED 7405                <1> 	jz	short pix_op_cpy_w_0 ; no
 52132 0000DAEF E909100000          <1> 	jmp	m_pix_op_cpy_w ; window copy except mask color
 52133                              <1> pix_op_cpy_w_0:
 52134                              <1> 	; esi = current row (virtual) addr in user's buff
 52135                              <1> 	; edi = window's current row address (video mem)
 52136                              <1> 	; ecx = transfer count per row
 52137 0000DAF4 E87E320000          <1> 	call	transfer_from_user_buffer
 52138 0000DAF9 72DD                <1> 	jc	short pix_op_cpy_1
 52139 0000DAFB 010D[1C010300]      <1>  	add	[u.r0], ecx
 52140 0000DB01 4B                  <1> 	dec	ebx
 52141 0000DB02 74D4                <1> 	jz	short pix_op_cpy_1 ; ok.
 52142                              <1> 	; next row
 52143 0000DB04 01CE                <1> 	add	esi, ecx ; next row in user's buffer
 52144 0000DB06 01D7                <1> 	add	edi, edx ; next row of window (system)
 52145 0000DB08 EBEA                <1> 	jmp	short pix_op_cpy_w_0
 52146                              <1> 
 52147                              <1> pix_op_add:
 52148                              <1> 	; 31/01/2021
 52149                              <1> 	; 30/01/2021
 52150                              <1> 	; ADD COLOR
 52151                              <1> 	;
 52152                              <1> 	; INPUT:
 52153                              <1> 	;   CL = color (8 bit, 256 colors)
 52154                              <1> 	;  ECX = color (16 bit and true colors)
 52155                              <1> 	;  EDX = start position (row, column)
 52156                              <1> 	;        (HW = row, DX = column)
 52157                              <1> 	;  ESI = size (rows, colums)
 52158                              <1> 	;        (HW = rows, SI = columns)
 52159                              <1> 	;
 52160                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52161                              <1> 	;
 52162                              <1> 	; OUTPUT:
 52163                              <1> 	; 	[u.r0] will be > 0 if succesful
 52164                              <1> 	
 52165 0000DB0A F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52166 0000DB11 7555                <1> 	jnz	short pix_op_add_w ; window
 52167                              <1> 	
 52168 0000DB13 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52169 0000DB19 89FE                <1> 	mov	esi, edi
 52170                              <1> 	; ecx = color (CL, CX, ECX)
 52171 0000DB1B 89C8                <1> 	mov	eax, ecx
 52172 0000DB1D 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52173                              <1> 
 52174 0000DB23 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
 52175 0000DB2A 7405                <1> 	jz	short pix_op_add_0 ; no
 52176 0000DB2C E9CB100000          <1> 	jmp	m_pix_op_add ; add color except mask color
 52177                              <1> pix_op_add_0:
 52178 0000DB31 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52179 0000DB38 7707                <1> 	ja	short pix_op_add_1
 52180                              <1> 
 52181                              <1> 	; 256 colors (8bpp)
 52182 0000DB3A E84C0A0000          <1> 	call	pix_op_add_8
 52183 0000DB3F EB1E                <1> 	jmp	short pix_op_add_4	
 52184                              <1> 			
 52185                              <1> pix_op_add_1:
 52186 0000DB41 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52187 0000DB48 7710                <1> 	ja	short pix_op_add_3 ; 32bpp	
 52188 0000DB4A 7207                <1> 	jb	short pix_op_add_2 ; 16bpp
 52189                              <1> 	
 52190                              <1> 	; 24 bit true colors
 52191 0000DB4C E85A0A0000          <1> 	call	pix_op_add_24
 52192 0000DB51 EB0C                <1> 	jmp	short pix_op_add_4
 52193                              <1> 
 52194                              <1> 	; 65536 colors (16bpp)
 52195                              <1> pix_op_add_2:
 52196 0000DB53 E8410A0000          <1> 	call	pix_op_add_16
 52197 0000DB58 EB05                <1> 	jmp	short pix_op_add_4
 52198                              <1> 
 52199                              <1> 	; 32 bit true colors
 52200                              <1> pix_op_add_3:
 52201 0000DB5A E86C0A0000          <1> 	call	pix_op_add_32
 52202                              <1> pix_op_add_4:
 52203 0000DB5F 29F7                <1> 	sub	edi, esi
 52204 0000DB61 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52205                              <1> pix_op_add_5:
 52206 0000DB67 C3                  <1> 	retn		
 52207                              <1> 
 52208                              <1> pix_op_add_w:
 52209                              <1> 	; 31/01/2021
 52210 0000DB68 51                  <1> 	push	ecx ; * ; color
 52211 0000DB69 89D1                <1> 	mov	ecx, edx ; win start pos
 52212 0000DB6B 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52213 0000DB6D E828FEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52214 0000DB72 58                  <1> 	pop	eax ; * ; color
 52215 0000DB73 72F2                <1> 	jc	short pix_op_add_5
 52216                              <1> 
 52217 0000DB75 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
 52218 0000DB7C 7405                <1> 	jz	short pix_op_add_w_0 ; no
 52219 0000DB7E E927110000          <1> 	jmp	m_pix_op_add_w 
 52220                              <1> 			; window add color except mask color
 52221                              <1> pix_op_add_w_0:
 52222                              <1> 	; ecx = bytes per row (to be applied)
 52223                              <1> 	; edx = screen width in bytes
 52224                              <1> 	; ebx = row count
 52225                              <1> 	; eax = color
 52226                              <1> 
 52227 0000DB83 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52228 0000DB89 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52229 0000DB90 7707                <1> 	ja	short pix_op_add_w_1
 52230                              <1> 
 52231                              <1> 	; 256 colors (8bpp)
 52232 0000DB92 BD[8BE50000]        <1> 	mov	ebp, pix_op_add_8
 52233 0000DB97 EB1E                <1> 	jmp	short pix_op_add_w_4
 52234                              <1> 			
 52235                              <1> pix_op_add_w_1:
 52236 0000DB99 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52237 0000DBA0 7710                <1> 	ja	short pix_op_add_w_3 ; 32bpp
 52238 0000DBA2 7207                <1> 	jb	short pix_op_add_w_2 ; 16bpp
 52239                              <1> 
 52240                              <1> 	; 24 bit true colors
 52241 0000DBA4 BD[ABE50000]        <1> 	mov	ebp, pix_op_add_24
 52242 0000DBA9 EB0C                <1> 	jmp	short pix_op_add_w_4
 52243                              <1> 
 52244                              <1> 	; 65536 colors (16bpp)
 52245                              <1> pix_op_add_w_2:
 52246 0000DBAB BD[99E50000]        <1> 	mov	ebp, pix_op_add_16
 52247 0000DBB0 EB05                <1> 	jmp	short pix_op_add_w_4
 52248                              <1> 
 52249                              <1> 	; 32 bit true colors
 52250                              <1> pix_op_add_w_3:
 52251 0000DBB2 BD[CBE50000]        <1> 	mov	ebp, pix_op_add_32
 52252                              <1> pix_op_add_w_4:
 52253 0000DBB7 E95F010000          <1> 	jmp	pix_op_add_w_x
 52254                              <1> 
 52255                              <1> pix_op_sub:
 52256                              <1> 	; 31/01/2021
 52257                              <1> 	; SUB COLOR
 52258                              <1> 	;
 52259                              <1> 	; INPUT:
 52260                              <1> 	;   CL = color (8 bit, 256 colors)
 52261                              <1> 	;  ECX = color (16 bit and true colors)
 52262                              <1> 	;  EDX = start position (row, column)
 52263                              <1> 	;        (HW = row, DX = column)
 52264                              <1> 	;  ESI = size (rows, colums)
 52265                              <1> 	;        (HW = rows, SI = columns)
 52266                              <1> 	;
 52267                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52268                              <1> 	;
 52269                              <1> 	; OUTPUT:
 52270                              <1> 	; 	[u.r0] will be > 0 if succesful
 52271                              <1> 	
 52272 0000DBBC F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52273 0000DBC3 7555                <1> 	jnz	short pix_op_sub_w ; window
 52274                              <1> 	
 52275 0000DBC5 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52276 0000DBCB 89FE                <1> 	mov	esi, edi
 52277                              <1> 	; ecx = color (CL, CX, ECX)
 52278 0000DBCD 89C8                <1> 	mov	eax, ecx
 52279 0000DBCF 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52280                              <1> 
 52281 0000DBD5 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
 52282 0000DBDC 7405                <1> 	jz	short pix_op_sub_0 ; no
 52283 0000DBDE E9FA100000          <1> 	jmp	m_pix_op_sub ; sub color except mask color
 52284                              <1> pix_op_sub_0:
 52285 0000DBE3 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52286 0000DBEA 7707                <1> 	ja	short pix_op_sub_1
 52287                              <1> 
 52288                              <1> 	; 256 colors (8bpp)
 52289 0000DBEC E8E9090000          <1> 	call	pix_op_sub_8
 52290 0000DBF1 EB1E                <1> 	jmp	short pix_op_sub_4	
 52291                              <1> 			
 52292                              <1> pix_op_sub_1:
 52293 0000DBF3 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52294 0000DBFA 7710                <1> 	ja	short pix_op_sub_3 ; 32bpp	
 52295 0000DBFC 7207                <1> 	jb	short pix_op_sub_2 ; 16bpp
 52296                              <1> 	
 52297                              <1> 	; 24 bit true colors
 52298 0000DBFE E8FA090000          <1> 	call	pix_op_sub_24
 52299 0000DC03 EB0C                <1> 	jmp	short pix_op_sub_4
 52300                              <1> 
 52301                              <1> 	; 65536 colors (16bpp)
 52302                              <1> pix_op_sub_2:
 52303 0000DC05 E8E0090000          <1> 	call	pix_op_sub_16
 52304 0000DC0A EB05                <1> 	jmp	short pix_op_sub_4
 52305                              <1> 
 52306                              <1> 	; 32 bit true colors
 52307                              <1> pix_op_sub_3:
 52308 0000DC0C E8060A0000          <1> 	call	pix_op_sub_32
 52309                              <1> pix_op_sub_4:
 52310 0000DC11 29F7                <1> 	sub	edi, esi
 52311 0000DC13 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52312                              <1> pix_op_sub_5:
 52313 0000DC19 C3                  <1> 	retn		
 52314                              <1> 
 52315                              <1> pix_op_sub_w:
 52316                              <1> 	; 31/01/2021
 52317 0000DC1A 51                  <1> 	push	ecx ; * ; color
 52318 0000DC1B 89D1                <1> 	mov	ecx, edx ; win start pos
 52319 0000DC1D 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52320 0000DC1F E876FDFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52321 0000DC24 58                  <1> 	pop	eax ; * ; color
 52322 0000DC25 72F2                <1> 	jc	short pix_op_sub_5
 52323                              <1> 
 52324 0000DC27 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
 52325 0000DC2E 7405                <1> 	jz	short pix_op_sub_w_0 ; no
 52326 0000DC30 E94B110000          <1> 	jmp	m_pix_op_sub_w 
 52327                              <1> 			; window sub color except mask color
 52328                              <1> pix_op_sub_w_0:
 52329                              <1> 	; ecx = bytes per row (to be applied)
 52330                              <1> 	; edx = screen width in bytes
 52331                              <1> 	; ebx = row count
 52332                              <1> 	; eax = color
 52333                              <1> 
 52334 0000DC35 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52335 0000DC3B 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52336 0000DC42 7707                <1> 	ja	short pix_op_sub_w_1
 52337                              <1> 
 52338                              <1> 	; 256 colors (8bpp)
 52339 0000DC44 BD[DAE50000]        <1> 	mov	ebp, pix_op_sub_8
 52340 0000DC49 EB1E                <1> 	jmp	short pix_op_sub_w_4
 52341                              <1> 			
 52342                              <1> pix_op_sub_w_1:
 52343 0000DC4B 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52344 0000DC52 7710                <1> 	ja	short pix_op_sub_w_3 ; 32bpp
 52345 0000DC54 7207                <1> 	jb	short pix_op_sub_w_2 ; 16bpp
 52346                              <1> 
 52347                              <1> 	; 24 bit true colors
 52348 0000DC56 BD[FDE50000]        <1> 	mov	ebp, pix_op_sub_24
 52349 0000DC5B EB0C                <1> 	jmp	short pix_op_sub_w_4
 52350                              <1> 
 52351                              <1> 	; 65536 colors (16bpp)
 52352                              <1> pix_op_sub_w_2:
 52353 0000DC5D BD[EAE50000]        <1> 	mov	ebp, pix_op_sub_16
 52354 0000DC62 EB05                <1> 	jmp	short pix_op_sub_w_4
 52355                              <1> 
 52356                              <1> 	; 32 bit true colors
 52357                              <1> pix_op_sub_w_3:
 52358 0000DC64 BD[17E60000]        <1> 	mov	ebp, pix_op_sub_32
 52359                              <1> pix_op_sub_w_4:
 52360 0000DC69 E9AD000000          <1> 	jmp	pix_op_sub_w_x
 52361                              <1> 
 52362                              <1> pix_op_mix:
 52363                              <1> 	; 31/01/2021
 52364                              <1> 	; MIX COLOR
 52365                              <1> 	;
 52366                              <1> 	; INPUT:
 52367                              <1> 	;   CL = color (8 bit, 256 colors)
 52368                              <1> 	;  ECX = color (16 bit and true colors)
 52369                              <1> 	;  EDX = start position (row, column)
 52370                              <1> 	;        (HW = row, DX = column)
 52371                              <1> 	;  ESI = size (rows, colums)
 52372                              <1> 	;        (HW = rows, SI = columns)
 52373                              <1> 	;
 52374                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52375                              <1> 	;
 52376                              <1> 	; OUTPUT:
 52377                              <1> 	; 	[u.r0] will be > 0 if succesful
 52378                              <1> 	
 52379 0000DC6E F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52380 0000DC75 7555                <1> 	jnz	short pix_op_mix_w ; window
 52381                              <1> 	
 52382 0000DC77 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52383 0000DC7D 89FE                <1> 	mov	esi, edi
 52384                              <1> 	; ecx = color (CL, CX, ECX)
 52385 0000DC7F 89C8                <1> 	mov	eax, ecx
 52386 0000DC81 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52387                              <1> 
 52388 0000DC87 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
 52389 0000DC8E 7405                <1> 	jz	short pix_op_mix_0 ; no
 52390 0000DC90 E91E110000          <1> 	jmp	m_pix_op_mix ; mix colors except mask color
 52391                              <1> pix_op_mix_0:
 52392 0000DC95 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52393 0000DC9C 7707                <1> 	ja	short pix_op_mix_1
 52394                              <1> 
 52395                              <1> 	; 256 colors (8bpp)
 52396 0000DC9E E8F3090000          <1> 	call	pix_op_mix_8
 52397 0000DCA3 EB1E                <1> 	jmp	short pix_op_mix_4	
 52398                              <1> 			
 52399                              <1> pix_op_mix_1:
 52400 0000DCA5 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52401 0000DCAC 7710                <1> 	ja	short pix_op_mix_3 ; 32bpp	
 52402 0000DCAE 7207                <1> 	jb	short pix_op_mix_2 ; 16bpp
 52403                              <1> 	
 52404                              <1> 	; 24 bit true colors
 52405 0000DCB0 E8FC090000          <1> 	call	pix_op_mix_24
 52406 0000DCB5 EB0C                <1> 	jmp	short pix_op_mix_4
 52407                              <1> 
 52408                              <1> 	; 65536 colors (16bpp)
 52409                              <1> pix_op_mix_2:
 52410 0000DCB7 E8E6090000          <1> 	call	pix_op_mix_16
 52411 0000DCBC EB05                <1> 	jmp	short pix_op_mix_4
 52412                              <1> 
 52413                              <1> 	; 32 bit true colors
 52414                              <1> pix_op_mix_3:
 52415 0000DCBE E80A0A0000          <1> 	call	pix_op_mix_32
 52416                              <1> pix_op_mix_4:
 52417 0000DCC3 29F7                <1> 	sub	edi, esi
 52418 0000DCC5 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52419                              <1> pix_op_mix_5:
 52420 0000DCCB C3                  <1> 	retn		
 52421                              <1> 
 52422                              <1> pix_op_mix_w:
 52423                              <1> 	; 31/01/2021
 52424 0000DCCC 51                  <1> 	push	ecx ; * ; color
 52425 0000DCCD 89D1                <1> 	mov	ecx, edx ; win start pos
 52426 0000DCCF 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52427 0000DCD1 E8C4FCFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52428 0000DCD6 58                  <1> 	pop	eax ; * ; color
 52429 0000DCD7 72F2                <1> 	jc	short pix_op_mix_5
 52430                              <1> 
 52431 0000DCD9 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
 52432 0000DCE0 7405                <1> 	jz	short pix_op_mix_w_0 ; no
 52433 0000DCE2 E969110000          <1> 	jmp	m_pix_op_mix_w 
 52434                              <1> 			; window mix colors except mask color
 52435                              <1> pix_op_mix_w_0:
 52436                              <1> 	; ecx = bytes per row (to be applied)
 52437                              <1> 	; edx = screen width in bytes
 52438                              <1> 	; ebx = row count
 52439                              <1> 	; eax = color
 52440                              <1> 
 52441 0000DCE7 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52442 0000DCED 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52443 0000DCF4 7707                <1> 	ja	short pix_op_mix_w_1
 52444                              <1> 
 52445                              <1> 	; 256 colors (8bpp)
 52446 0000DCF6 BD[96E60000]        <1> 	mov	ebp, pix_op_mix_8
 52447 0000DCFB EB1E                <1> 	jmp	short pix_op_mix_w_x
 52448                              <1> 			
 52449                              <1> pix_op_mix_w_1:
 52450 0000DCFD 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52451 0000DD04 7710                <1> 	ja	short pix_op_mix_w_3 ; 32bpp
 52452 0000DD06 7207                <1> 	jb	short pix_op_mix_w_2 ; 16bpp
 52453                              <1> 
 52454                              <1> 	; 24 bit true colors
 52455 0000DD08 BD[B1E60000]        <1> 	mov	ebp, pix_op_mix_24
 52456 0000DD0D EB0C                <1> 	jmp	short pix_op_mix_w_x
 52457                              <1> 
 52458                              <1> 	; 65536 colors (16bpp)
 52459                              <1> pix_op_mix_w_2:
 52460 0000DD0F BD[A2E60000]        <1> 	mov	ebp, pix_op_mix_16
 52461 0000DD14 EB05                <1> 	jmp	short pix_op_mix_w_x
 52462                              <1> 
 52463                              <1> 	; 32 bit true colors
 52464                              <1> pix_op_mix_w_3:
 52465 0000DD16 BD[CDE60000]        <1> 	mov	ebp, pix_op_mix_32
 52466                              <1> 	;jmp	short pix_op_mix_w_x
 52467                              <1> 
 52468                              <1> pix_op_mix_w_x:
 52469                              <1> pix_op_add_w_x:
 52470                              <1> pix_op_sub_w_x:
 52471                              <1> pix_op_rpl_w_x:
 52472                              <1> pix_op_orc_w_x:
 52473                              <1> pix_op_and_w_x:
 52474                              <1> pix_op_xor_w_x:
 52475                              <1> 	; 27/02/2021
 52476                              <1> 	; 31/01/2021
 52477                              <1> 	; ecx = bytes per row (to be applied)
 52478                              <1> 	; edx = windows (screen) width in bytes
 52479                              <1> 	; ebx = row count
 52480                              <1> 	; eax = color
 52481                              <1> 	; ebp = pixel operation subroutine address
 52482 0000DD1B 52                  <1> 	push	edx
 52483 0000DD1C 51                  <1> 	push	ecx
 52484 0000DD1D 57                  <1> 	push	edi
 52485 0000DD1E 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
 52486 0000DD24 FFD5                <1> 	call	ebp ; call pixel-row operation
 52487 0000DD26 5F                  <1> 	pop	edi
 52488 0000DD27 59                  <1> 	pop	ecx ; bytes per row
 52489 0000DD28 010D[1C010300]      <1> 	add	[u.r0], ecx
 52490 0000DD2E 5A                  <1> 	pop	edx
 52491 0000DD2F 01D7                <1> 	add	edi, edx ; next row
 52492 0000DD31 4B                  <1> 	dec	ebx
 52493 0000DD32 75E7                <1> 	jnz	short pix_op_mix_w_x
 52494 0000DD34 C3                  <1> 	retn
 52495                              <1> 
 52496                              <1> pix_op_rpl:
 52497                              <1> 	; 01/02/2021
 52498                              <1> 	; REPLACE COLOR
 52499                              <1> 	;
 52500                              <1> 	; INPUT:
 52501                              <1> 	;   CL = old/current color (8 bit, 256 colors)
 52502                              <1> 	;  ECX = old/current color (16 bit and true colors)
 52503                              <1> 	;   DL = new color (8 bit, 256 colors)
 52504                              <1> 	;  EDX = new color (16 bit and true colors)
 52505                              <1> 	;  ESI = start position (row, column)
 52506                              <1> 	;        (HW = row, DX = column)
 52507                              <1> 	;  EDI = size (rows, colums)
 52508                              <1> 	;        (HW = rows, SI = columns)
 52509                              <1> 	; OUTPUT:
 52510                              <1> 	; 	[u.r0] will be > 0 if succesful
 52511                              <1> 	
 52512 0000DD35 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52513 0000DD3C 754D                <1> 	jnz	short pix_op_rpl_w ; window
 52514                              <1> 	
 52515 0000DD3E 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52516 0000DD44 89FE                <1> 	mov	esi, edi
 52517                              <1> 	; ecx = old color (CL, CX, ECX) -to be replaced with-
 52518                              <1> 	; edx = new color (CL, CX, ECX) -new one-
 52519 0000DD46 89D0                <1> 	mov	eax, edx ; new color
 52520 0000DD48 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; old color
 52521 0000DD4E 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52522                              <1> pix_op_rpl_0:
 52523 0000DD54 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52524 0000DD5B 7707                <1> 	ja	short pix_op_rpl_1
 52525                              <1> 
 52526                              <1> 	; 256 colors (8bpp)
 52527 0000DD5D E82F0A0000          <1> 	call	pix_op_rpl_8
 52528 0000DD62 EB1E                <1> 	jmp	short pix_op_rpl_4
 52529                              <1> 			
 52530                              <1> pix_op_rpl_1:
 52531 0000DD64 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52532 0000DD6B 7710                <1> 	ja	short pix_op_rpl_3 ; 32bpp	
 52533 0000DD6D 7207                <1> 	jb	short pix_op_rpl_2 ; 16bpp
 52534                              <1> 
 52535                              <1> 	; 24 bit true colors
 52536 0000DD6F E8400A0000          <1> 	call	pix_op_rpl_24
 52537 0000DD74 EB0C                <1> 	jmp	short pix_op_rpl_4
 52538                              <1> 
 52539                              <1> 	; 65536 colors (16bpp)
 52540                              <1> pix_op_rpl_2:
 52541 0000DD76 E8260A0000          <1> 	call	pix_op_rpl_16
 52542 0000DD7B EB05                <1> 	jmp	short pix_op_rpl_4
 52543                              <1> 
 52544                              <1> 	; 32 bit true colors	
 52545                              <1> pix_op_rpl_3:
 52546 0000DD7D E8540A0000          <1> 	call	pix_op_rpl_32
 52547                              <1> pix_op_rpl_4:
 52548 0000DD82 29F7                <1> 	sub	edi, esi
 52549 0000DD84 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52550                              <1> pix_op_rpl_5:
 52551 0000DD8A C3                  <1> 	retn
 52552                              <1> 
 52553                              <1> pix_op_rpl_w:
 52554                              <1> 	; 01/02/2021
 52555 0000DD8B 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; old color
 52556 0000DD91 52                  <1> 	push	edx ; * ; new color
 52557 0000DD92 89F1                <1> 	mov	ecx, esi ; win start pos
 52558 0000DD94 89FA                <1> 	mov	edx, edi ; size (rows, cols)
 52559 0000DD96 E8FFFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52560 0000DD9B 58                  <1> 	pop	eax ; * ; new color
 52561 0000DD9C 72EC                <1> 	jc	short pix_op_rpl_5
 52562                              <1> 
 52563                              <1> 	; replace window color
 52564                              <1> pix_op_rpl_w_0:
 52565                              <1> 	; ecx = bytes per row (to be applied)
 52566                              <1> 	; edx = screen width in bytes
 52567                              <1> 	; ebx = row count
 52568                              <1> 	; eax = new color
 52569                              <1> 	; [maskcolor] = old color
 52570                              <1>  
 52571 0000DD9E 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52572                              <1> 
 52573 0000DDA4 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52574 0000DDAB 7707                <1> 	ja	short pix_op_rpl_w_1
 52575                              <1> 
 52576                              <1> 	; 256 colors (8bpp)
 52577 0000DDAD BD[91E70000]        <1> 	mov	ebp, pix_op_rpl_8
 52578 0000DDB2 EB1E                <1> 	jmp	short pix_op_rpl_w_4
 52579                              <1> 			
 52580                              <1> pix_op_rpl_w_1:
 52581 0000DDB4 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52582 0000DDBB 7710                <1> 	ja	short pix_op_rpl_w_3 ; 32bpp
 52583 0000DDBD 7207                <1> 	jb	short pix_op_rpl_w_2 ; 16bpp
 52584                              <1> 
 52585                              <1> 	; 24 bit true colors
 52586 0000DDBF BD[B4E70000]        <1> 	mov	ebp, pix_op_rpl_24
 52587 0000DDC4 EB0C                <1> 	jmp	short pix_op_rpl_w_4
 52588                              <1> 
 52589                              <1> 	; 65536 colors (16bpp)
 52590                              <1> pix_op_rpl_w_2:
 52591 0000DDC6 BD[A1E70000]        <1> 	mov	ebp, pix_op_rpl_16
 52592 0000DDCB EB05                <1> 	jmp	short pix_op_rpl_w_4
 52593                              <1> 
 52594                              <1> 	; 32 bit true colors
 52595                              <1> pix_op_rpl_w_3:
 52596 0000DDCD BD[D6E70000]        <1> 	mov	ebp, pix_op_rpl_32
 52597                              <1> pix_op_rpl_w_4:
 52598 0000DDD2 E944FFFFFF          <1> 	jmp	pix_op_rpl_w_x
 52599                              <1> 
 52600                              <1> pix_op_orc:
 52601                              <1> 	; 31/01/2021
 52602                              <1> 	; OR COLOR
 52603                              <1> 	;
 52604                              <1> 	; INPUT:
 52605                              <1> 	;   CL = color (8 bit, 256 colors)
 52606                              <1> 	;  ECX = color (16 bit and true colors)
 52607                              <1> 	;  EDX = start position (row, column)
 52608                              <1> 	;        (HW = row, DX = column)
 52609                              <1> 	;  ESI = size (rows, colums)
 52610                              <1> 	;        (HW = rows, SI = columns)
 52611                              <1> 	;
 52612                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52613                              <1> 	;
 52614                              <1> 	; OUTPUT:
 52615                              <1> 	; 	[u.r0] will be > 0 if succesful
 52616                              <1> 	
 52617 0000DDD7 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52618 0000DDDE 7555                <1> 	jnz	short pix_op_or_w ; window
 52619                              <1> 	
 52620 0000DDE0 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52621 0000DDE6 89FE                <1> 	mov	esi, edi
 52622                              <1> 	; ecx = color (CL, CX, ECX)
 52623 0000DDE8 89C8                <1> 	mov	eax, ecx
 52624 0000DDEA 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52625                              <1> 
 52626 0000DDF0 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
 52627 0000DDF7 7405                <1> 	jz	short pix_op_or_0 ; no
 52628 0000DDF9 E945110000          <1> 	jmp	m_pix_op_or ; 'or' color except mask color
 52629                              <1> pix_op_or_0:
 52630 0000DDFE 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52631 0000DE05 7707                <1> 	ja	short pix_op_or_1
 52632                              <1> 
 52633                              <1> 	; 256 colors (8bpp)
 52634 0000DE07 E81B080000          <1> 	call	pix_op_or_8
 52635 0000DE0C EB1E                <1> 	jmp	short pix_op_or_4	
 52636                              <1> 			
 52637                              <1> pix_op_or_1:
 52638 0000DE0E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52639 0000DE15 7710                <1> 	ja	short pix_op_or_3 ; 32bpp	
 52640 0000DE17 7207                <1> 	jb	short pix_op_or_2 ; 16bpp
 52641                              <1> 	
 52642                              <1> 	; 24 bit true colors
 52643 0000DE19 E817080000          <1> 	call	pix_op_or_24
 52644 0000DE1E EB0C                <1> 	jmp	short pix_op_or_4
 52645                              <1> 
 52646                              <1> 	; 65536 colors (16bpp)
 52647                              <1> pix_op_or_2:
 52648 0000DE20 E808080000          <1> 	call	pix_op_or_16
 52649 0000DE25 EB05                <1> 	jmp	short pix_op_or_4
 52650                              <1> 
 52651                              <1> 	; 32 bit true colors
 52652                              <1> pix_op_or_3:
 52653 0000DE27 E818080000          <1> 	call	pix_op_or_32
 52654                              <1> pix_op_or_4:
 52655 0000DE2C 29F7                <1> 	sub	edi, esi
 52656 0000DE2E 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52657                              <1> pix_op_or_5:
 52658 0000DE34 C3                  <1> 	retn		
 52659                              <1> 
 52660                              <1> pix_op_or_w:
 52661                              <1> 	; 31/01/2021
 52662 0000DE35 51                  <1> 	push	ecx ; * ; color
 52663 0000DE36 89D1                <1> 	mov	ecx, edx ; win start pos
 52664 0000DE38 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52665 0000DE3A E85BFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52666 0000DE3F 58                  <1> 	pop	eax ; * ; color
 52667 0000DE40 72F2                <1> 	jc	short pix_op_or_5
 52668                              <1> 
 52669 0000DE42 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
 52670 0000DE49 7405                <1> 	jz	short pix_op_or_w_0 ; no
 52671 0000DE4B E980110000          <1> 	jmp	m_pix_op_or_w 
 52672                              <1> 			; window 'or' color except mask color
 52673                              <1> pix_op_or_w_0:
 52674                              <1> 	; ecx = bytes per row (to be applied)
 52675                              <1> 	; edx = screen width in bytes
 52676                              <1> 	; ebx = row count
 52677                              <1> 	; eax = color
 52678                              <1> 
 52679 0000DE50 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52680 0000DE56 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52681 0000DE5D 7707                <1> 	ja	short pix_op_or_w_1
 52682                              <1> 
 52683                              <1> 	; 256 colors (8bpp)
 52684 0000DE5F BD[27E60000]        <1> 	mov	ebp, pix_op_or_8
 52685 0000DE64 EB1E                <1> 	jmp	short pix_op_or_w_4
 52686                              <1> 			
 52687                              <1> pix_op_or_w_1:
 52688 0000DE66 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52689 0000DE6D 7710                <1> 	ja	short pix_op_or_w_3 ; 32bpp
 52690 0000DE6F 7207                <1> 	jb	short pix_op_or_w_2 ; 16bpp
 52691                              <1> 
 52692                              <1> 	; 24 bit true colors
 52693 0000DE71 BD[35E60000]        <1> 	mov	ebp, pix_op_or_24
 52694 0000DE76 EB0C                <1> 	jmp	short pix_op_or_w_4
 52695                              <1> 
 52696                              <1> 	; 65536 colors (16bpp)
 52697                              <1> pix_op_or_w_2:
 52698 0000DE78 BD[2DE60000]        <1> 	mov	ebp, pix_op_or_16
 52699 0000DE7D EB05                <1> 	jmp	short pix_op_or_w_4
 52700                              <1> 
 52701                              <1> 	; 32 bit true colors
 52702                              <1> pix_op_or_w_3:
 52703 0000DE7F BD[44E60000]        <1> 	mov	ebp, pix_op_or_32
 52704                              <1> pix_op_or_w_4:
 52705 0000DE84 E992FEFFFF          <1> 	jmp	pix_op_orc_w_x
 52706                              <1> 
 52707                              <1> pix_op_and:
 52708                              <1> 	; 31/01/2021
 52709                              <1> 	; AND COLOR
 52710                              <1> 	;
 52711                              <1> 	; INPUT:
 52712                              <1> 	;   CL = color (8 bit, 256 colors)
 52713                              <1> 	;  ECX = color (16 bit and true colors)
 52714                              <1> 	;  EDX = start position (row, column)
 52715                              <1> 	;        (HW = row, DX = column)
 52716                              <1> 	;  ESI = size (rows, colums)
 52717                              <1> 	;        (HW = rows, SI = columns)
 52718                              <1> 	;
 52719                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52720                              <1> 	;
 52721                              <1> 	; OUTPUT:
 52722                              <1> 	; 	[u.r0] will be > 0 if succesful
 52723                              <1> 	
 52724 0000DE89 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52725 0000DE90 7555                <1> 	jnz	short pix_op_and_w ; window
 52726                              <1> 	
 52727 0000DE92 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52728 0000DE98 89FE                <1> 	mov	esi, edi
 52729                              <1> 	; ecx = color (CL, CX, ECX)
 52730 0000DE9A 89C8                <1> 	mov	eax, ecx
 52731 0000DE9C 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52732                              <1> 
 52733 0000DEA2 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
 52734 0000DEA9 7405                <1> 	jz	short pix_op_and_0 ; no
 52735 0000DEAB E9D30F0000          <1> 	jmp	m_pix_op_and ; 'and' color except mask color
 52736                              <1> pix_op_and_0:
 52737 0000DEB0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52738 0000DEB7 7707                <1> 	ja	short pix_op_and_1
 52739                              <1> 
 52740                              <1> 	; 256 colors (8bpp)
 52741 0000DEB9 E88E070000          <1> 	call	pix_op_and_8
 52742 0000DEBE EB1E                <1> 	jmp	short pix_op_and_4	
 52743                              <1> 			
 52744                              <1> pix_op_and_1:
 52745 0000DEC0 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52746 0000DEC7 7710                <1> 	ja	short pix_op_and_3 ; 32bpp	
 52747 0000DEC9 7207                <1> 	jb	short pix_op_and_2 ; 16bpp
 52748                              <1> 	
 52749                              <1> 	; 24 bit true colors
 52750 0000DECB E88A070000          <1> 	call	pix_op_and_24
 52751 0000DED0 EB0C                <1> 	jmp	short pix_op_and_4
 52752                              <1> 
 52753                              <1> 	; 65536 colors (16bpp)
 52754                              <1> pix_op_and_2:
 52755 0000DED2 E87B070000          <1> 	call	pix_op_and_16
 52756 0000DED7 EB05                <1> 	jmp	short pix_op_and_4
 52757                              <1> 
 52758                              <1> 	; 32 bit true colors
 52759                              <1> pix_op_and_3:
 52760 0000DED9 E88B070000          <1> 	call	pix_op_and_32
 52761                              <1> pix_op_and_4:
 52762 0000DEDE 29F7                <1> 	sub	edi, esi
 52763 0000DEE0 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52764                              <1> pix_op_and_5:
 52765 0000DEE6 C3                  <1> 	retn		
 52766                              <1> 
 52767                              <1> pix_op_and_w:
 52768                              <1> 	; 31/01/2021
 52769 0000DEE7 51                  <1> 	push	ecx ; * ; color
 52770 0000DEE8 89D1                <1> 	mov	ecx, edx ; win start pos
 52771 0000DEEA 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52772 0000DEEC E8A9FAFFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52773 0000DEF1 58                  <1> 	pop	eax ; * ; color
 52774 0000DEF2 72F2                <1> 	jc	short pix_op_and_5
 52775                              <1> 
 52776 0000DEF4 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
 52777 0000DEFB 7405                <1> 	jz	short pix_op_and_w_0 ; no
 52778 0000DEFD E90E100000          <1> 	jmp	m_pix_op_and_w 
 52779                              <1> 			; window 'and' color except mask color
 52780                              <1> pix_op_and_w_0:
 52781                              <1> 	; ecx = bytes per row (to be applied)
 52782                              <1> 	; edx = screen width in bytes
 52783                              <1> 	; ebx = row count
 52784                              <1> 	; eax = color
 52785                              <1> 
 52786 0000DF02 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52787 0000DF08 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52788 0000DF0F 7707                <1> 	ja	short pix_op_and_w_1
 52789                              <1> 
 52790                              <1> 	; 256 colors (8bpp)
 52791 0000DF11 BD[4CE60000]        <1> 	mov	ebp, pix_op_and_8
 52792 0000DF16 EB1E                <1> 	jmp	short pix_op_and_w_4
 52793                              <1> 			
 52794                              <1> pix_op_and_w_1:
 52795 0000DF18 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52796 0000DF1F 7710                <1> 	ja	short pix_op_and_w_3 ; 32bpp
 52797 0000DF21 7207                <1> 	jb	short pix_op_and_w_2 ; 16bpp
 52798                              <1> 
 52799                              <1> 	; 24 bit true colors
 52800 0000DF23 BD[5AE60000]        <1> 	mov	ebp, pix_op_and_24
 52801 0000DF28 EB0C                <1> 	jmp	short pix_op_and_w_4
 52802                              <1> 
 52803                              <1> 	; 65536 colors (16bpp)
 52804                              <1> pix_op_and_w_2:
 52805 0000DF2A BD[52E60000]        <1> 	mov	ebp, pix_op_and_16
 52806 0000DF2F EB05                <1> 	jmp	short pix_op_and_w_4
 52807                              <1> 
 52808                              <1> 	; 32 bit true colors
 52809                              <1> pix_op_and_w_3:
 52810 0000DF31 BD[69E60000]        <1> 	mov	ebp, pix_op_and_32
 52811                              <1> pix_op_and_w_4:
 52812 0000DF36 E9E0FDFFFF          <1> 	jmp	pix_op_and_w_x
 52813                              <1> 
 52814                              <1> pix_op_xor:
 52815                              <1> 	; 31/01/2021
 52816                              <1> 	; XOR COLOR
 52817                              <1> 	;
 52818                              <1> 	; INPUT:
 52819                              <1> 	;   CL = color (8 bit, 256 colors)
 52820                              <1> 	;  ECX = color (16 bit and true colors)
 52821                              <1> 	;  EDX = start position (row, column)
 52822                              <1> 	;        (HW = row, DX = column)
 52823                              <1> 	;  ESI = size (rows, colums)
 52824                              <1> 	;        (HW = rows, SI = columns)
 52825                              <1> 	;
 52826                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52827                              <1> 	;
 52828                              <1> 	; OUTPUT:
 52829                              <1> 	; 	[u.r0] will be > 0 if succesful
 52830                              <1> 	
 52831 0000DF3B F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52832 0000DF42 7555                <1> 	jnz	short pix_op_xor_w ; window
 52833                              <1> 	
 52834 0000DF44 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52835 0000DF4A 89FE                <1> 	mov	esi, edi
 52836                              <1> 	; ecx = color (CL, CX, ECX)
 52837 0000DF4C 89C8                <1> 	mov	eax, ecx
 52838 0000DF4E 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52839                              <1> 
 52840 0000DF54 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
 52841 0000DF5B 7405                <1> 	jz	short pix_op_xor_0 ; no
 52842 0000DF5D E9A1100000          <1> 	jmp	m_pix_op_xor ; 'xor' color except mask color
 52843                              <1> pix_op_xor_0:
 52844 0000DF62 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52845 0000DF69 7707                <1> 	ja	short pix_op_xor_1
 52846                              <1> 
 52847                              <1> 	; 256 colors (8bpp)
 52848 0000DF6B E801070000          <1> 	call	pix_op_xor_8
 52849 0000DF70 EB1E                <1> 	jmp	short pix_op_xor_4	
 52850                              <1> 			
 52851                              <1> pix_op_xor_1:
 52852 0000DF72 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52853 0000DF79 7710                <1> 	ja	short pix_op_xor_3 ; 32bpp	
 52854 0000DF7B 7207                <1> 	jb	short pix_op_xor_2 ; 16bpp
 52855                              <1> 	
 52856                              <1> 	; 24 bit true colors
 52857 0000DF7D E8FD060000          <1> 	call	pix_op_xor_24
 52858 0000DF82 EB0C                <1> 	jmp	short pix_op_xor_4
 52859                              <1> 
 52860                              <1> 	; 65536 colors (16bpp)
 52861                              <1> pix_op_xor_2:
 52862 0000DF84 E8EE060000          <1> 	call	pix_op_xor_16
 52863 0000DF89 EB05                <1> 	jmp	short pix_op_xor_4
 52864                              <1> 
 52865                              <1> 	; 32 bit true colors
 52866                              <1> pix_op_xor_3:
 52867 0000DF8B E8FE060000          <1> 	call	pix_op_xor_32
 52868                              <1> pix_op_xor_4:
 52869 0000DF90 29F7                <1> 	sub	edi, esi
 52870 0000DF92 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52871                              <1> pix_op_xor_5:
 52872 0000DF98 C3                  <1> 	retn		
 52873                              <1> 
 52874                              <1> pix_op_xor_w:
 52875                              <1> 	; 31/01/2021
 52876 0000DF99 51                  <1> 	push	ecx ; * ; color
 52877 0000DF9A 89D1                <1> 	mov	ecx, edx ; win start pos
 52878 0000DF9C 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52879 0000DF9E E8F7F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52880 0000DFA3 58                  <1> 	pop	eax ; * ; color
 52881 0000DFA4 72F2                <1> 	jc	short pix_op_xor_5
 52882                              <1> 
 52883 0000DFA6 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
 52884 0000DFAD 7405                <1> 	jz	short pix_op_xor_w_0 ; no
 52885 0000DFAF E9DC100000          <1> 	jmp	m_pix_op_xor_w 
 52886                              <1> 			; window 'xor' color except mask color
 52887                              <1> pix_op_xor_w_0:
 52888                              <1> 	; ecx = bytes per row (to be applied)
 52889                              <1> 	; edx = screen width in bytes
 52890                              <1> 	; ebx = row count
 52891                              <1> 	; eax = color
 52892                              <1> 
 52893 0000DFB4 8B3D[46100300]      <1> 	mov	edi, [v_str]
 52894 0000DFBA 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52895 0000DFC1 7707                <1> 	ja	short pix_op_xor_w_1
 52896                              <1> 
 52897                              <1> 	; 256 colors (8bpp)
 52898 0000DFC3 BD[71E60000]        <1> 	mov	ebp, pix_op_xor_8
 52899 0000DFC8 EB1E                <1> 	jmp	short pix_op_xor_w_4
 52900                              <1> 			
 52901                              <1> pix_op_xor_w_1:
 52902 0000DFCA 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52903 0000DFD1 7710                <1> 	ja	short pix_op_xor_w_3 ; 32bpp
 52904 0000DFD3 7207                <1> 	jb	short pix_op_xor_w_2 ; 16bpp
 52905                              <1> 
 52906                              <1> 	; 24 bit true colors
 52907 0000DFD5 BD[7FE60000]        <1> 	mov	ebp, pix_op_xor_24
 52908 0000DFDA EB0C                <1> 	jmp	short pix_op_xor_w_4
 52909                              <1> 
 52910                              <1> 	; 65536 colors (16bpp)
 52911                              <1> pix_op_xor_w_2:
 52912 0000DFDC BD[77E60000]        <1> 	mov	ebp, pix_op_xor_16
 52913 0000DFE1 EB05                <1> 	jmp	short pix_op_xor_w_4
 52914                              <1> 
 52915                              <1> 	; 32 bit true colors
 52916                              <1> pix_op_xor_w_3:
 52917 0000DFE3 BD[8EE60000]        <1> 	mov	ebp, pix_op_xor_32
 52918                              <1> pix_op_xor_w_4:
 52919 0000DFE8 E92EFDFFFF          <1> 	jmp	pix_op_xor_w_x
 52920                              <1> 
 52921                              <1> pix_op_new:
 52922                              <1> 	; 31/01/2021
 52923                              <1> 	; 30/01/2021
 52924                              <1> 	; CHANGE COLOR
 52925                              <1> 	;
 52926                              <1> 	; INPUT:
 52927                              <1> 	;   CL = color (8 bit, 256 colors)
 52928                              <1> 	;  ECX = color (16 bit and true colors)
 52929                              <1> 	;  EDX = start position (row, column)
 52930                              <1> 	;        (HW = row, DX = column)
 52931                              <1> 	;  ESI = size (rows, colums)
 52932                              <1> 	;        (HW = rows, SI = columns)
 52933                              <1> 	;
 52934                              <1> 	;  [maskcolor] = mask color (to be excluded)
 52935                              <1> 	;
 52936                              <1> 	; OUTPUT:
 52937                              <1> 	; 	[u.r0] will be > 0 if succesful
 52938                              <1> 	
 52939 0000DFED F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 52940 0000DFF4 7554                <1> 	jnz	short pix_op_new_w ; window
 52941                              <1> 	
 52942 0000DFF6 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 52943 0000DFFC 89FE                <1> 	mov	esi, edi
 52944                              <1> 	; ecx = color (CL, CX, ECX)
 52945 0000DFFE 89C8                <1> 	mov	eax, ecx
 52946 0000E000 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 52947                              <1> 
 52948 0000E006 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
 52949 0000E00D 7405                <1> 	jz	short pix_op_new_0 ; no
 52950 0000E00F E90A0B0000          <1> 	jmp	m_pix_op_new ; change color except mask color
 52951                              <1> pix_op_new_0:
 52952 0000E014 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 52953 0000E01B 7706                <1> 	ja	short pix_op_new_2
 52954                              <1> 
 52955                              <1> 	; 256 colors (8bpp)
 52956                              <1> pix_op_new_1:
 52957 0000E01D 88C4                <1> 	mov	ah, al
 52958 0000E01F D1E9                <1> 	shr	ecx, 1	
 52959 0000E021 EB12                <1> 	jmp	short pix_op_new_3
 52960                              <1> 			
 52961                              <1> pix_op_new_2:
 52962 0000E023 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 52963 0000E02A 7713                <1> 	ja	short pix_op_new_4 ; 32bpp	
 52964 0000E02C 7207                <1> 	jb	short pix_op_new_3 ; 16bpp
 52965                              <1> 
 52966                              <1> 	; 31/01/2021
 52967                              <1> 	
 52968                              <1> 	; 24 bit true colors
 52969 0000E02E E849050000          <1> 	call	pix_op_new_24
 52970                              <1> 
 52971 0000E033 EB0C                <1> 	jmp	short pix_op_new_5
 52972                              <1> 
 52973                              <1> 	; 65536 colors (16bpp)
 52974                              <1> pix_op_new_3:
 52975 0000E035 89C2                <1> 	mov	edx, eax
 52976 0000E037 C1E010              <1> 	shl	eax, 16
 52977 0000E03A 6689D0              <1> 	mov	ax, dx
 52978 0000E03D D1E9                <1> 	shr	ecx, 1 ; dword counts
 52979                              <1> 	; 32 bit true colors	
 52980                              <1> pix_op_new_4:
 52981 0000E03F F3AB                <1> 	rep	stosd
 52982                              <1> pix_op_new_5:
 52983 0000E041 29F7                <1> 	sub	edi, esi
 52984 0000E043 893D[1C010300]      <1> 	mov	[u.r0], edi	
 52985                              <1> pix_op_new_6:
 52986 0000E049 C3                  <1> 	retn		
 52987                              <1> 
 52988                              <1> pix_op_new_w:
 52989                              <1> 	; 31/01/2021
 52990                              <1> 	; 30/01/2021
 52991 0000E04A 51                  <1> 	push	ecx ; * ; color
 52992 0000E04B 89D1                <1> 	mov	ecx, edx ; win start pos
 52993 0000E04D 89F2                <1> 	mov	edx, esi ; size (rows, cols)
 52994 0000E04F E846F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 52995 0000E054 58                  <1> 	pop	eax ; * ; color
 52996 0000E055 72F2                <1> 	jc	short pix_op_new_6
 52997                              <1> 
 52998 0000E057 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
 52999 0000E05E 7405                <1> 	jz	short pix_op_new_w_0 ; no
 53000 0000E060 E9470B0000          <1> 	jmp	m_pix_op_new_w 
 53001                              <1> 			; window chg color except mask color
 53002                              <1> pix_op_new_w_0:
 53003                              <1> 	; ecx = bytes per row (to be applied)
 53004                              <1> 	; edx = screen width in bytes
 53005                              <1> 	; ebx = row count
 53006                              <1> 	; eax = color
 53007                              <1> 
 53008 0000E065 8B3D[46100300]      <1> 	mov	edi, [v_str]
 53009                              <1> 
 53010 0000E06B 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53011 0000E072 7707                <1> 	ja	short pix_op_new_w_1
 53012                              <1> 
 53013                              <1> 	; 256 colors (8bpp)
 53014 0000E074 BD[75E50000]        <1> 	mov	ebp, pix_op_new_8
 53015 0000E079 EB1E                <1> 	jmp	short pix_op_new_w_x
 53016                              <1> 			
 53017                              <1> pix_op_new_w_1:
 53018 0000E07B 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53019 0000E082 7710                <1> 	ja	short pix_op_new_w_3 ; 32bpp
 53020 0000E084 7207                <1> 	jb	short pix_op_new_w_2 ; 16bpp
 53021                              <1> 
 53022                              <1> 	; 24 bit true colors
 53023 0000E086 BD[7CE50000]        <1> 	mov	ebp, pix_op_new_24
 53024 0000E08B EB0C                <1> 	jmp	short pix_op_new_w_x
 53025                              <1> 
 53026                              <1> 	; 65536 colors (16bpp)
 53027                              <1> pix_op_new_w_2:
 53028 0000E08D BD[78E50000]        <1> 	mov	ebp, pix_op_new_16
 53029 0000E092 EB05                <1> 	jmp	short pix_op_new_w_x
 53030                              <1> 
 53031                              <1> 	; 32 bit true colors
 53032                              <1> pix_op_new_w_3:
 53033 0000E094 BD[88E50000]        <1> 	mov	ebp, pix_op_new_32
 53034                              <1> 	;jmp	short pix_op_new_w_x
 53035                              <1> 
 53036                              <1> pix_op_new_w_x:
 53037                              <1> pix_op_not_w_x:
 53038                              <1> pix_op_neg_w_x:
 53039                              <1> pix_op_inc_w_x:
 53040                              <1> pix_op_dec_w_x:
 53041                              <1> 	; 27/02/2021
 53042                              <1> 	; 01/02/2021
 53043                              <1> 	; 31/01/2021
 53044                              <1> 	; ecx = bytes per row (to be applied)
 53045                              <1> 	; edx = windows (screen) width in bytes
 53046                              <1> 	; ebx = row count
 53047                              <1> 	; eax = color
 53048                              <1> 	; ebp = pixel operation subroutine address
 53049                              <1> 	;push	edx ; 01/02/2021
 53050 0000E099 51                  <1> 	push	ecx
 53051 0000E09A 57                  <1> 	push	edi
 53052 0000E09B 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
 53053 0000E0A1 FFD5                <1> 	call	ebp ; call pixel-row operation
 53054 0000E0A3 5F                  <1> 	pop	edi
 53055 0000E0A4 59                  <1> 	pop	ecx ; bytes per row
 53056 0000E0A5 010D[1C010300]      <1> 	add	[u.r0], ecx
 53057                              <1> 	;pop	edx ; 01/02/2021
 53058 0000E0AB 01D7                <1> 	add	edi, edx ; next row
 53059 0000E0AD 4B                  <1> 	dec	ebx
 53060 0000E0AE 75E9                <1> 	jnz	short pix_op_new_w_x
 53061 0000E0B0 C3                  <1> 	retn
 53062                              <1> 
 53063                              <1> pix_op_not:
 53064                              <1> 	; 31/01/2021
 53065                              <1> 	; NOT COLOR
 53066                              <1> 	;
 53067                              <1> 	; INPUT:
 53068                              <1> 	;  ECX = start position (row, column)
 53069                              <1> 	;        (HW = row, CX = column)
 53070                              <1> 	;  EDX = size (rows, colums)
 53071                              <1> 	;        (HW = rows, DX = columns)
 53072                              <1> 	;	 (0 -> invalid 	
 53073                              <1> 	;        (1 -> horizontal or vertical line)
 53074                              <1> 	;  [maskcolor] = mask color (to be excluded)
 53075                              <1> 	;
 53076                              <1> 	; OUTPUT:
 53077                              <1> 	; 	[u.r0] will be > 0 if succesful
 53078                              <1> 	
 53079 0000E0B1 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 53080 0000E0B8 7553                <1> 	jnz	short pix_op_not_w ; window
 53081                              <1> 	
 53082 0000E0BA 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 53083 0000E0C0 89FE                <1> 	mov	esi, edi
 53084 0000E0C2 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 53085                              <1> 
 53086 0000E0C8 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
 53087 0000E0CF 7405                <1> 	jz	short pix_op_not_0 ; no
 53088 0000E0D1 E9ED0F0000          <1> 	jmp	m_pix_op_not ; 'not' color except mask color
 53089                              <1> pix_op_not_0:
 53090 0000E0D6 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53091 0000E0DD 7707                <1> 	ja	short pix_op_not_1
 53092                              <1> 
 53093                              <1> 	; 256 colors (8bpp)
 53094 0000E0DF E8F5050000          <1> 	call	pix_op_not_8
 53095 0000E0E4 EB1E                <1> 	jmp	short pix_op_not_4
 53096                              <1> 			
 53097                              <1> pix_op_not_1:
 53098 0000E0E6 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53099 0000E0ED 7710                <1> 	ja	short pix_op_not_3 ; 32bpp	
 53100 0000E0EF 7207                <1> 	jb	short pix_op_not_2 ; 16bpp
 53101                              <1> 
 53102                              <1> 	; 24 bit true colors
 53103 0000E0F1 E8F1050000          <1> 	call	pix_op_not_24
 53104 0000E0F6 EB0C                <1> 	jmp	short pix_op_not_4
 53105                              <1> 
 53106                              <1> 	; 65536 colors (16bpp)
 53107                              <1> pix_op_not_2:
 53108 0000E0F8 E8E2050000          <1> 	call	pix_op_not_16
 53109 0000E0FD EB05                <1> 	jmp	short pix_op_not_4
 53110                              <1> 
 53111                              <1> 	; 32 bit true colors	
 53112                              <1> pix_op_not_3:
 53113 0000E0FF E8EE050000          <1> 	call	pix_op_not_32
 53114                              <1> pix_op_not_4:
 53115 0000E104 29F7                <1> 	sub	edi, esi
 53116 0000E106 893D[1C010300]      <1> 	mov	[u.r0], edi	
 53117                              <1> pix_op_not_5:
 53118 0000E10C C3                  <1> 	retn
 53119                              <1> 
 53120                              <1> pix_op_not_w:
 53121                              <1> 	; 31/01/2021
 53122                              <1> 	; ecx = win start pos (row, column)
 53123                              <1> 	; edx = size (rows, columns)
 53124 0000E10D E888F8FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 53125 0000E112 72F8                <1> 	jc	short pix_op_not_5
 53126                              <1> 
 53127 0000E114 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
 53128 0000E11B 7405                <1> 	jz	short pix_op_not_w_0 ; no
 53129 0000E11D E926100000          <1> 	jmp	m_pix_op_not_w 
 53130                              <1> 			; window 'not' color except mask color
 53131                              <1> pix_op_not_w_0:
 53132                              <1> 	; ecx = bytes per row (to be applied)
 53133                              <1> 	; edx = screen width in bytes
 53134                              <1> 	; ebx = row count
 53135                              <1> 
 53136 0000E122 8B3D[46100300]      <1> 	mov	edi, [v_str]
 53137                              <1> 
 53138 0000E128 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53139 0000E12F 7707                <1> 	ja	short pix_op_not_w_1
 53140                              <1> 
 53141                              <1> 	; 256 colors (8bpp)
 53142 0000E131 BD[D9E60000]        <1> 	mov	ebp, pix_op_not_8
 53143 0000E136 EB1E                <1> 	jmp	short pix_op_not_w_4
 53144                              <1> 			
 53145                              <1> pix_op_not_w_1:
 53146 0000E138 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53147 0000E13F 7710                <1> 	ja	short pix_op_not_w_3 ; 32bpp
 53148 0000E141 7207                <1> 	jb	short pix_op_not_w_2 ; 16bpp
 53149                              <1> 
 53150                              <1> 	; 24 bit true colors
 53151 0000E143 BD[E7E60000]        <1> 	mov	ebp, pix_op_not_24
 53152 0000E148 EB0C                <1> 	jmp	short pix_op_not_w_4
 53153                              <1> 
 53154                              <1> 	; 65536 colors (16bpp)
 53155                              <1> pix_op_not_w_2:
 53156 0000E14A BD[DFE60000]        <1> 	mov	ebp, pix_op_not_16
 53157 0000E14F EB05                <1> 	jmp	short pix_op_not_w_4
 53158                              <1> 
 53159                              <1> 	; 32 bit true colors
 53160                              <1> pix_op_not_w_3:
 53161 0000E151 BD[F2E60000]        <1> 	mov	ebp, pix_op_not_32
 53162                              <1> pix_op_not_w_4:
 53163 0000E156 E93EFFFFFF          <1> 	jmp	pix_op_not_w_x
 53164                              <1> 
 53165                              <1> pix_op_neg:
 53166                              <1> 	; 31/01/2021
 53167                              <1> 	; NEGATE COLOR
 53168                              <1> 	;
 53169                              <1> 	; INPUT:
 53170                              <1> 	;  ECX = start position (row, column)
 53171                              <1> 	;        (HW = row, CX = column)
 53172                              <1> 	;  EDX = size (rows, colums)
 53173                              <1> 	;        (HW = rows, DX = columns)
 53174                              <1> 	;	 (0 -> invalid 	
 53175                              <1> 	;        (1 -> horizontal or vertical line)
 53176                              <1> 	;  [maskcolor] = mask color (to be excluded)
 53177                              <1> 	;
 53178                              <1> 	; OUTPUT:
 53179                              <1> 	; 	[u.r0] will be > 0 if succesful
 53180                              <1> 	
 53181 0000E15B F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 53182 0000E162 7553                <1> 	jnz	short pix_op_neg_w ; window
 53183                              <1> 	
 53184 0000E164 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 53185 0000E16A 89FE                <1> 	mov	esi, edi
 53186 0000E16C 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 53187                              <1> 
 53188 0000E172 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
 53189 0000E179 7405                <1> 	jz	short pix_op_neg_0 ; no
 53190 0000E17B E9FB0F0000          <1> 	jmp	m_pix_op_neg ; 'neg' color except mask color
 53191                              <1> pix_op_neg_0:
 53192 0000E180 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53193 0000E187 7707                <1> 	ja	short pix_op_neg_1
 53194                              <1> 
 53195                              <1> 	; 256 colors (8bpp)
 53196 0000E189 E86C050000          <1> 	call	pix_op_neg_8
 53197 0000E18E EB1E                <1> 	jmp	short pix_op_neg_4
 53198                              <1> 			
 53199                              <1> pix_op_neg_1:
 53200 0000E190 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53201 0000E197 7710                <1> 	ja	short pix_op_neg_3 ; 32bpp	
 53202 0000E199 7207                <1> 	jb	short pix_op_neg_2 ; 16bpp
 53203                              <1> 
 53204                              <1> 	; 24 bit true colors
 53205 0000E19B E868050000          <1> 	call	pix_op_neg_24
 53206 0000E1A0 EB0C                <1> 	jmp	short pix_op_neg_4
 53207                              <1> 
 53208                              <1> 	; 65536 colors (16bpp)
 53209                              <1> pix_op_neg_2:
 53210 0000E1A2 E859050000          <1> 	call	pix_op_neg_16
 53211 0000E1A7 EB05                <1> 	jmp	short pix_op_neg_4
 53212                              <1> 
 53213                              <1> 	; 32 bit true colors	
 53214                              <1> pix_op_neg_3:
 53215 0000E1A9 E86C050000          <1> 	call	pix_op_neg_32
 53216                              <1> pix_op_neg_4:
 53217 0000E1AE 29F7                <1> 	sub	edi, esi
 53218 0000E1B0 893D[1C010300]      <1> 	mov	[u.r0], edi	
 53219                              <1> pix_op_neg_5:
 53220 0000E1B6 C3                  <1> 	retn
 53221                              <1> 
 53222                              <1> pix_op_neg_w:
 53223                              <1> 	; 31/01/2021
 53224                              <1> 	; ecx = win start pos (row, column)
 53225                              <1> 	; edx = size (rows, columns)
 53226 0000E1B7 E8DEF7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 53227 0000E1BC 72F8                <1> 	jc	short pix_op_neg_5
 53228                              <1> 
 53229 0000E1BE F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
 53230 0000E1C5 7405                <1> 	jz	short pix_op_neg_w_0 ; no
 53231 0000E1C7 E934100000          <1> 	jmp	m_pix_op_neg_w 
 53232                              <1> 			; window 'neg' color except mask color
 53233                              <1> pix_op_neg_w_0:
 53234                              <1> 	; ecx = bytes per row (to be applied)
 53235                              <1> 	; edx = screen width in bytes
 53236                              <1> 	; ebx = row count
 53237                              <1> 
 53238 0000E1CC 8B3D[46100300]      <1> 	mov	edi, [v_str]
 53239                              <1> 
 53240 0000E1D2 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53241 0000E1D9 7707                <1> 	ja	short pix_op_neg_w_1
 53242                              <1> 
 53243                              <1> 	; 256 colors (8bpp)
 53244 0000E1DB BD[FAE60000]        <1> 	mov	ebp, pix_op_neg_8
 53245 0000E1E0 EB1E                <1> 	jmp	short pix_op_neg_w_4
 53246                              <1> 			
 53247                              <1> pix_op_neg_w_1:
 53248 0000E1E2 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53249 0000E1E9 7710                <1> 	ja	short pix_op_neg_w_3 ; 32bpp
 53250 0000E1EB 7207                <1> 	jb	short pix_op_neg_w_2 ; 16bpp
 53251                              <1> 
 53252                              <1> 	; 24 bit true colors
 53253 0000E1ED BD[08E70000]        <1> 	mov	ebp, pix_op_neg_24
 53254 0000E1F2 EB0C                <1> 	jmp	short pix_op_neg_w_4
 53255                              <1> 
 53256                              <1> 	; 65536 colors (16bpp)
 53257                              <1> pix_op_neg_w_2:
 53258 0000E1F4 BD[00E70000]        <1> 	mov	ebp, pix_op_neg_16
 53259 0000E1F9 EB05                <1> 	jmp	short pix_op_neg_w_4
 53260                              <1> 
 53261                              <1> 	; 32 bit true colors
 53262                              <1> pix_op_neg_w_3:
 53263 0000E1FB BD[1AE70000]        <1> 	mov	ebp, pix_op_neg_32
 53264                              <1> pix_op_neg_w_4:
 53265 0000E200 E994FEFFFF          <1> 	jmp	pix_op_neg_w_x
 53266                              <1> 
 53267                              <1> pix_op_inc:
 53268                              <1> 	; 31/01/2021
 53269                              <1> 	; INCREASE COLOR
 53270                              <1> 	;
 53271                              <1> 	; INPUT:
 53272                              <1> 	;  ECX = start position (row, column)
 53273                              <1> 	;        (HW = row, CX = column)
 53274                              <1> 	;  EDX = size (rows, colums)
 53275                              <1> 	;        (HW = rows, DX = columns)
 53276                              <1> 	;	 (0 -> invalid 	
 53277                              <1> 	;        (1 -> horizontal or vertical line)
 53278                              <1> 	;  [maskcolor] = mask color (to be excluded)
 53279                              <1> 	;
 53280                              <1> 	; OUTPUT:
 53281                              <1> 	; 	[u.r0] will be > 0 if succesful
 53282                              <1> 	
 53283 0000E205 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 53284 0000E20C 7553                <1> 	jnz	short pix_op_inc_w ; window
 53285                              <1> 	
 53286 0000E20E 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 53287 0000E214 89FE                <1> 	mov	esi, edi
 53288 0000E216 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 53289                              <1> 
 53290 0000E21C F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
 53291 0000E223 7405                <1> 	jz	short pix_op_inc_0 ; no
 53292 0000E225 E909100000          <1> 	jmp	m_pix_op_inc ; 'inc' color except mask color
 53293                              <1> pix_op_inc_0:
 53294 0000E22A 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53295 0000E231 7707                <1> 	ja	short pix_op_inc_1
 53296                              <1> 
 53297                              <1> 	; 256 colors (8bpp)
 53298 0000E233 E8EA040000          <1> 	call	pix_op_inc_8
 53299 0000E238 EB1E                <1> 	jmp	short pix_op_inc_4
 53300                              <1> 			
 53301                              <1> pix_op_inc_1:
 53302 0000E23A 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53303 0000E241 7710                <1> 	ja	short pix_op_inc_3 ; 32bpp	
 53304 0000E243 7207                <1> 	jb	short pix_op_inc_2 ; 16bpp
 53305                              <1> 
 53306                              <1> 	; 24 bit true colors
 53307 0000E245 E8EF040000          <1> 	call	pix_op_inc_24
 53308 0000E24A EB0C                <1> 	jmp	short pix_op_inc_4
 53309                              <1> 
 53310                              <1> 	; 65536 colors (16bpp)
 53311                              <1> pix_op_inc_2:
 53312 0000E24C E8DB040000          <1> 	call	pix_op_inc_16
 53313 0000E251 EB05                <1> 	jmp	short pix_op_inc_4
 53314                              <1> 
 53315                              <1> 	; 32 bit true colors	
 53316                              <1> pix_op_inc_3:
 53317 0000E253 E8F5040000          <1> 	call	pix_op_inc_32
 53318                              <1> pix_op_inc_4:
 53319 0000E258 29F7                <1> 	sub	edi, esi
 53320 0000E25A 893D[1C010300]      <1> 	mov	[u.r0], edi	
 53321                              <1> pix_op_inc_5:
 53322 0000E260 C3                  <1> 	retn			
 53323                              <1> 
 53324                              <1> pix_op_inc_w:
 53325                              <1> 	; 31/01/2021
 53326                              <1> 	; ecx = win start pos (row, column)
 53327                              <1> 	; edx = size (rows, columns)
 53328 0000E261 E834F7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 53329 0000E266 72F8                <1> 	jc	short pix_op_inc_5
 53330                              <1> 
 53331 0000E268 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
 53332 0000E26F 7405                <1> 	jz	short pix_op_inc_w_0 ; no
 53333 0000E271 E956100000          <1> 	jmp	m_pix_op_inc_w 
 53334                              <1> 			; window 'inc' color except mask color
 53335                              <1> pix_op_inc_w_0:
 53336                              <1> 	; ecx = bytes per row (to be applied)
 53337                              <1> 	; edx = screen width in bytes
 53338                              <1> 	; ebx = row count
 53339                              <1> 
 53340 0000E276 8B3D[46100300]      <1> 	mov	edi, [v_str]
 53341                              <1> 
 53342 0000E27C 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53343 0000E283 7707                <1> 	ja	short pix_op_inc_w_1
 53344                              <1> 
 53345                              <1> 	; 256 colors (8bpp)
 53346 0000E285 BD[22E70000]        <1> 	mov	ebp, pix_op_inc_8
 53347 0000E28A EB1E                <1> 	jmp	short pix_op_inc_w_4
 53348                              <1> 			
 53349                              <1> pix_op_inc_w_1:
 53350 0000E28C 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53351 0000E293 7710                <1> 	ja	short pix_op_inc_w_3 ; 32bpp
 53352 0000E295 7207                <1> 	jb	short pix_op_inc_w_2 ; 16bpp
 53353                              <1> 
 53354                              <1> 	; 24 bit true colors
 53355 0000E297 BD[39E70000]        <1> 	mov	ebp, pix_op_inc_24
 53356 0000E29C EB0C                <1> 	jmp	short pix_op_inc_w_4
 53357                              <1> 
 53358                              <1> 	; 65536 colors (16bpp)
 53359                              <1> pix_op_inc_w_2:
 53360 0000E29E BD[2CE70000]        <1> 	mov	ebp, pix_op_inc_16
 53361 0000E2A3 EB05                <1> 	jmp	short pix_op_inc_w_4
 53362                              <1> 
 53363                              <1> 	; 32 bit true colors
 53364                              <1> pix_op_inc_w_3:
 53365 0000E2A5 BD[4DE70000]        <1> 	mov	ebp, pix_op_inc_32
 53366                              <1> pix_op_inc_w_4:
 53367 0000E2AA E9EAFDFFFF          <1> 	jmp	pix_op_inc_w_x
 53368                              <1> 
 53369                              <1> pix_op_dec:
 53370                              <1> 	; 31/01/2021
 53371                              <1> 	; DECREASE COLOR
 53372                              <1> 	;
 53373                              <1> 	; INPUT:
 53374                              <1> 	;  ECX = start position (row, column)
 53375                              <1> 	;        (HW = row, CX = column)
 53376                              <1> 	;  EDX = size (rows, colums)
 53377                              <1> 	;        (HW = rows, DX = columns)
 53378                              <1> 	;	 (0 -> invalid 	
 53379                              <1> 	;        (1 -> horizontal or vertical line)
 53380                              <1> 	;  [maskcolor] = mask color (to be excluded)
 53381                              <1> 	;
 53382                              <1> 	; OUTPUT:
 53383                              <1> 	; 	[u.r0] will be > 0 if succesful
 53384                              <1> 	
 53385 0000E2AF F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
 53386 0000E2B6 7553                <1> 	jnz	short pix_op_dec_w ; window
 53387                              <1> 	
 53388 0000E2B8 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 53389 0000E2BE 89FE                <1> 	mov	esi, edi
 53390 0000E2C0 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
 53391                              <1> 
 53392 0000E2C6 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
 53393 0000E2CD 7405                <1> 	jz	short pix_op_dec_0 ; no
 53394 0000E2CF E92B100000          <1> 	jmp	m_pix_op_dec ; 'dec' color except mask color
 53395                              <1> pix_op_dec_0:
 53396 0000E2D4 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53397 0000E2DB 7707                <1> 	ja	short pix_op_dec_1
 53398                              <1> 
 53399                              <1> 	; 256 colors (8bpp)
 53400 0000E2DD E877040000          <1> 	call	pix_op_dec_8
 53401 0000E2E2 EB1E                <1> 	jmp	short pix_op_dec_4
 53402                              <1> 			
 53403                              <1> pix_op_dec_1:
 53404 0000E2E4 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53405 0000E2EB 7710                <1> 	ja	short pix_op_dec_3 ; 32bpp	
 53406 0000E2ED 7207                <1> 	jb	short pix_op_dec_2 ; 16bpp
 53407                              <1> 
 53408                              <1> 	; 24 bit true colors
 53409 0000E2EF E87C040000          <1> 	call	pix_op_dec_24
 53410 0000E2F4 EB0C                <1> 	jmp	short pix_op_dec_4
 53411                              <1> 
 53412                              <1> 	; 65536 colors (16bpp)
 53413                              <1> pix_op_dec_2:
 53414 0000E2F6 E868040000          <1> 	call	pix_op_dec_16
 53415 0000E2FB EB05                <1> 	jmp	short pix_op_dec_4
 53416                              <1> 
 53417                              <1> 	; 32 bit true colors	
 53418                              <1> pix_op_dec_3:
 53419 0000E2FD E881040000          <1> 	call	pix_op_dec_32
 53420                              <1> pix_op_dec_4:
 53421 0000E302 29F7                <1> 	sub	edi, esi
 53422 0000E304 893D[1C010300]      <1> 	mov	[u.r0], edi	
 53423                              <1> pix_op_dec_5:
 53424 0000E30A C3                  <1> 	retn			
 53425                              <1> 
 53426                              <1> pix_op_dec_w:
 53427                              <1> 	; 31/01/2021
 53428                              <1> 	; ecx = win start pos (row, column)
 53429                              <1> 	; edx = size (rows, columns)
 53430 0000E30B E88AF6FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 53431 0000E310 72F8                <1> 	jc	short pix_op_dec_5
 53432                              <1> 
 53433 0000E312 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
 53434 0000E319 7405                <1> 	jz	short pix_op_dec_w_0 ; no
 53435 0000E31B E973100000          <1> 	jmp	m_pix_op_dec_w 
 53436                              <1> 			; window 'dec' color except mask color
 53437                              <1> pix_op_dec_w_0:
 53438                              <1> 	; ecx = bytes per row (to be applied)
 53439                              <1> 	; edx = screen width in bytes
 53440                              <1> 	; ebx = row count
 53441                              <1> 
 53442 0000E320 8B3D[46100300]      <1> 	mov	edi, [v_str]
 53443                              <1> 
 53444 0000E326 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53445 0000E32D 7707                <1> 	ja	short pix_op_dec_w_1
 53446                              <1> 
 53447                              <1> 	; 256 colors (8bpp)
 53448 0000E32F BD[59E70000]        <1> 	mov	ebp, pix_op_dec_8
 53449 0000E334 EB1E                <1> 	jmp	short pix_op_dec_w_4
 53450                              <1> 			
 53451                              <1> pix_op_dec_w_1:
 53452 0000E336 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53453 0000E33D 7710                <1> 	ja	short pix_op_dec_w_3 ; 32bpp
 53454 0000E33F 7207                <1> 	jb	short pix_op_dec_w_2 ; 16bpp
 53455                              <1> 
 53456                              <1> 	; 24 bit true colors
 53457 0000E341 BD[70E70000]        <1> 	mov	ebp, pix_op_dec_24
 53458 0000E346 EB0C                <1> 	jmp	short pix_op_dec_w_4
 53459                              <1> 
 53460                              <1> 	; 65536 colors (16bpp)
 53461                              <1> pix_op_dec_w_2:
 53462 0000E348 BD[63E70000]        <1> 	mov	ebp, pix_op_dec_16
 53463 0000E34D EB05                <1> 	jmp	short pix_op_dec_w_4
 53464                              <1> 
 53465                              <1> 	; 32 bit true colors
 53466                              <1> pix_op_dec_w_3:
 53467 0000E34F BD[83E70000]        <1> 	mov	ebp, pix_op_dec_32
 53468                              <1> pix_op_dec_w_4:
 53469 0000E354 E940FDFFFF          <1> 	jmp	pix_op_dec_w_x
 53470                              <1> 
 53471                              <1> pix_op_blk:
 53472                              <1> 	; 11/08/2022 (TRDOS 386 Kernel v2.0.5)
 53473                              <1> 	; 23/01/2021
 53474                              <1> 	; 22/02/2021
 53475                              <1> 	; 02/02/2021
 53476                              <1> 	; COPY PIXEL BLOCK -system to system-
 53477                              <1> 	; WRITE PIXEL BLOCKS -user to system-
 53478                              <1> 	;
 53479                              <1> 	; INPUT:
 53480                              <1> 	;   -If BL bit 5 is 0-	
 53481                              <1> 	;    ECX = start position (row, column) (*)
 53482                              <1> 	;    (HW = row, CX = column)
 53483                              <1> 	;    EDX = size (rows, colums) (*)
 53484                              <1> 	;    (HW = rows, DX = columns)
 53485                              <1> 	;         (0 -> invalid)
 53486                              <1> 	;         (1 -> horizontal or vertical line)
 53487                              <1> 	;    ESI = destination (row, column) (***)
 53488                              <1> 	;   -If BL bit 5 is 1-	
 53489                              <1> 	;     CL = color (8 bit, 256 colors)
 53490                              <1> 	;    ECX = color (16 bit and true colors)
 53491                              <1> 	;    EDX = count of blocks (not bytes)
 53492                              <1> 	;	 (limit: 2048 blocks/windows)	  	
 53493                              <1> 	;    ESI = user's buffer address 
 53494                              <1> 	;	  contains 64 bit block data
 53495                              <1> 	;	  BLOCK ADDRESS - (row, col), dword
 53496                              <1> 	;	  (first 32 bits)
 53497                              <1> 	;	  BLOCK SIZE - (rows, cols), dword
 53498                              <1> 	;	  (second 32 bits)
 53499                              <1> 	; OUTPUT:
 53500                              <1> 	; 	[u.r0] will be > 0 if succesful
 53501                              <1> 
 53502                              <1> 	; Window option ([v_ops] bit 4) will be ignored  	
 53503                              <1> 	; (Function is used for display page coordinates)
 53504                              <1> 
 53505 0000E359 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
 53506 0000E360 755A                <1> 	jnz	short pix_op_blk_u ; blocks from user's buffer
 53507                              <1> 
 53508 0000E362 89F0                <1> 	mov	eax, esi ; destination position (row, col)
 53509 0000E364 E8DEF6FFFF          <1> 	call	calc_pixel_offset
 53510 0000E369 3B05[42100300]      <1> 	cmp	eax, [v_siz]
 53511 0000E36F 734A                <1> 	jnb	short pix_op_blk_retn ; out of display page
 53512 0000E371 89C6                <1> 	mov	esi, eax
 53513 0000E373 E8ACF6FFFF          <1> 	call	pixels_to_byte_count
 53514 0000E378 89C7                <1> 	mov	edi, eax
 53515 0000E37A 89D0                <1> 	mov	eax, edx  ; size
 53516 0000E37C E8C6F6FFFF          <1> 	call	calc_pixel_offset
 53517                              <1> 	; 22/02/2021
 53518 0000E381 3B05[42100300]      <1> 	cmp	eax, [v_siz]
 53519 0000E387 7732                <1> 	ja	short pix_op_blk_retn ; out of display page
 53520 0000E389 01C6                <1> 	add	esi, eax
 53521 0000E38B 3B35[42100300]      <1> 	cmp	esi, [v_siz]
 53522 0000E391 7728                <1> 	ja	short pix_op_blk_retn ; out of display page
 53523                              <1> 
 53524 0000E393 033D[3E100300]      <1> 	add	edi, [v_mem] ; destination address
 53525                              <1> 	
 53526                              <1> 	; 23/01/2021
 53527                              <1> 	;call	pixels_to_byte_count
 53528                              <1> 	;add	edi, eax
 53529                              <1> 	;jc	short pix_op_blk_retn ; out of display page
 53530                              <1> 	;cmp	edi, [v_end]
 53531                              <1> 	;ja	short pix_op_blk_retn ; out of display page
 53532                              <1> 	;sub	edi, eax
 53533                              <1> 
 53534 0000E399 E8FCF5FFFF          <1> 	call	sysvideo_15_12 ; window preparations
 53535 0000E39E 721B                <1> 	jc	short pix_op_blk_retn ; something wrong !?
 53536                              <1> 	; ecx = bytes per row (to be applied)
 53537                              <1> 	; edx = screen width in bytes
 53538                              <1> 	; ebx = row count
 53539                              <1> 
 53540 0000E3A0 8B35[46100300]      <1> 	mov	esi, [v_str] ; source address
 53541                              <1> 
 53542                              <1> 	; Note:
 53543                              <1> 	; ecx & edx are already adjusted for pixel sizes
 53544                              <1> 	; so, following code is proper all pixel sizes
 53545                              <1> 
 53546 0000E3A6 29CA                <1> 	sub	edx, ecx ; screen width - window width
 53547                              <1> pix_op_blk_0:
 53548 0000E3A8 89C8                <1> 	mov	eax, ecx
 53549 0000E3AA 0105[1C010300]      <1> 	add	[u.r0], eax
 53550 0000E3B0 F3A4                <1> 	rep	movsb
 53551 0000E3B2 89C1                <1> 	mov	ecx, eax	
 53552 0000E3B4 01D6                <1> 	add	esi, edx ; next row
 53553 0000E3B6 01D7                <1> 	add	edi, edx ; next row
 53554 0000E3B8 4B                  <1> 	dec	ebx
 53555 0000E3B9 75ED                <1> 	jnz	short pix_op_blk_0
 53556                              <1> pix_op_blk_retn:
 53557 0000E3BB C3                  <1> 	retn
 53558                              <1> 
 53559                              <1> pix_op_blk_u:
 53560                              <1> 	; fill blocks (windows) with desired color
 53561                              <1> 	; according to block definitions in user's buffer
 53562 0000E3BC 81FA00080000        <1> 	cmp	edx, 2048
 53563 0000E3C2 7605                <1> 	jna	short pix_op_blk_u_0
 53564                              <1> 	; Maximum 2048 blocks
 53565 0000E3C4 BA00080000          <1> 	mov	edx, 2048
 53566                              <1> pix_op_blk_u_0:
 53567 0000E3C9 8025[3C100300]DF    <1> 	and	byte [v_ops], ~20h ; clear masked bit
 53568 0000E3D0 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save pixel color
 53569                              <1> 	; 22/02/2021
 53570                              <1> 	;mov	ebp, edx ; save blocks count
 53571                              <1> 	;push	ebp
 53572                              <1> pix_op_blk_u_next:
 53573 0000E3D6 52                  <1> 	push	edx
 53574                              <1> 	;mov	ecx, 8
 53575                              <1> 	; 11/08/2022
 53576 0000E3D7 29C9                <1> 	sub	ecx, ecx
 53577 0000E3D9 B108                <1> 	mov	cl, 8
 53578 0000E3DB BF[56100300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
 53579                              <1> 	; esi = user's buffer address
 53580 0000E3E0 E892290000          <1> 	call	transfer_from_user_buffer
 53581 0000E3E5 72D4                <1> 	jc	short pix_op_blk_retn
 53582 0000E3E7 01CE                <1> 	add	esi, ecx ; 22/02/2021
 53583 0000E3E9 56                  <1> 	push	esi
 53584 0000E3EA 8B15[56100300]      <1> 	mov	edx, [buffer8] ; block start pos (row,col)
 53585 0000E3F0 8B35[5A100300]      <1> 	mov	esi, [buffer8+4] ; block size (rows,cols)
 53586 0000E3F6 8B0D[4E100300]      <1> 	mov	ecx, [maskcolor]
 53587 0000E3FC E849FCFFFF          <1> 	call	pix_op_new_w ; new (change) color (window)
 53588 0000E401 5E                  <1> 	pop	esi
 53589                              <1> 	;pop	ebp
 53590                              <1> 	;dec	ebp
 53591 0000E402 5A                  <1> 	pop	edx
 53592 0000E403 4A                  <1> 	dec	edx
 53593 0000E404 75D0                <1> 	jnz	short pix_op_blk_u_next
 53594 0000E406 C3                  <1> 	retn
 53595                              <1> 
 53596                              <1> pix_op_lin:
 53597                              <1> 	; 11/08/2022
 53598                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 53599                              <1> 	; 12/02/2021
 53600                              <1> 	; 11/02/2021
 53601                              <1> 	; 10/02/2021
 53602                              <1> 	; 05/02/2021
 53603                              <1> 	; 02/02/2021
 53604                              <1> 	; WRITE LINE -direct-
 53605                              <1> 	; WRITE LINE(S) -via user's buffer-
 53606                              <1> 	;
 53607                              <1> 	; INPUT:
 53608                              <1> 	;   -If BL bit 5 is 0-	
 53609                              <1> 	;     CL = color (8 bit, 256 colors)
 53610                              <1> 	;    ECX = color (16 bit and true colors)
 53611                              <1> 	;     DX = low 12 bits - size (length)
 53612                              <1> 	;	   high 4 bits - direction or type
 53613                              <1> 	;	     0 - Horizontal line
 53614                              <1> 	;	     1 - Vertical line
 53615                              <1> 	;	   > 1 - undefined, invalid
 53616                              <1> 	;    ESI = start position (row, column)
 53617                              <1> 	;	  (HW = row, SI = column)
 53618                              <1> 	;   -If BL bit 5 is 1-
 53619                              <1> 	;     CL = color (8 bit, 256 colors)
 53620                              <1> 	;    ECX = color (16 bit and true colors)
 53621                              <1> 	;     DX = number of lines (in user buffer)
 53622                              <1> 	;	   (limit: 2048 lines)	
 53623                              <1> 	;    ESI = user's buffer
 53624                              <1> 	;          contains 64 bit data for lines
 53625                              <1> 	;	   START POINT: 32 bit (row, col)
 53626                              <1> 	;	   LENGTH: 32 bit
 53627                              <1> 	;		   high 16 bits - 0
 53628                              <1> 	;		   bit 0-11 - length
 53629                              <1> 	;	   	   bit 12-15 - type (length)
 53630                              <1> 	; OUTPUT:
 53631                              <1> 	; 	[u.r0] will be > 0 if succesful
 53632                              <1> 
 53633                              <1> 	; Window option ([v_ops] bit 4) will be ignored
 53634                              <1> 	; (Function is used for display page coordinates)
 53635                              <1> 
 53636                              <1> 	; 10/02/2021
 53637 0000E407 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
 53638 0000E40E 7444                <1> 	jz	short pix_op_lin_vh ; direct (v/h lines) 
 53639                              <1> 
 53640                              <1> 	; lines from user's buffer
 53641                              <1> pix_op_lin_u:
 53642                              <1> 	; draw lines with desired color
 53643                              <1> 	; according to line definitions in user's buffer
 53644 0000E410 81FA00080000        <1> 	cmp	edx, 2048
 53645 0000E416 7605                <1> 	jna	short pix_op_lin_u_0
 53646                              <1> 	; Maximum 2048 lines
 53647 0000E418 BA00080000          <1> 	mov	edx, 2048
 53648                              <1> pix_op_lin_u_0:
 53649 0000E41D 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save pixel color
 53650 0000E423 89D5                <1> 	mov	ebp, edx ; save line count
 53651                              <1> pix_op_lin_u_next:
 53652                              <1> 	;mov	ecx, 8
 53653                              <1> 	; 11/08/2022
 53654 0000E425 29C9                <1> 	sub	ecx, ecx
 53655 0000E427 B108                <1> 	mov	cl, 8
 53656 0000E429 BF[56100300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
 53657                              <1> 	; esi = user's buffer address
 53658 0000E42E E844290000          <1> 	call	transfer_from_user_buffer
 53659 0000E433 721E                <1> 	jc	short pix_op_lin_retn
 53660 0000E435 01CE                <1> 	add	esi, ecx ; 11/02/2021
 53661 0000E437 56                  <1> 	push	esi
 53662 0000E438 8B35[56100300]      <1> 	mov	esi, [buffer8] ; line start pos (row,col)
 53663 0000E43E 8B15[5A100300]      <1> 	mov	edx, [buffer8+4] ; line length
 53664 0000E444 8B0D[4E100300]      <1> 	mov	ecx, [maskcolor]
 53665 0000E44A E805000000          <1> 	call	pix_op_lin_vh ; new (change) color (window)
 53666 0000E44F 5E                  <1> 	pop	esi
 53667 0000E450 4D                  <1> 	dec	ebp
 53668 0000E451 75D2                <1> 	jnz	short pix_op_lin_u_next
 53669                              <1> pix_op_lin_retn:
 53670 0000E453 C3                  <1> 	retn
 53671                              <1> 
 53672                              <1> pix_op_lin_vh:
 53673 0000E454 81FA38140000        <1> 	cmp	edx, 1438h ; 1920*1080 (780hx438h) limit
 53674 0000E45A 7762                <1> 	ja	short pix_op_lin_err1 ; invalid type 
 53675                              <1> 			    	; (for current version)
 53676 0000E45C 66F7C2FF0F          <1> 	test	dx, 0FFFh
 53677 0000E461 745B                <1> 	jz	short pix_op_lin_err1 ; zero length!
 53678                              <1> 
 53679 0000E463 89F0                <1> 	mov	eax, esi ; start point (row, col)
 53680 0000E465 E8DDF5FFFF          <1> 	call	calc_pixel_offset
 53681 0000E46A 3B05[42100300]      <1> 	cmp	eax, [v_siz]
 53682 0000E470 734C                <1> 	jnb	short pix_op_lin_err1 ; out of display page!
 53683 0000E472 E8ADF5FFFF          <1> 	call	pixels_to_byte_count
 53684 0000E477 89C7                <1> 	mov	edi, eax ; start point offset
 53685 0000E479 033D[3E100300]      <1> 	add	edi, [v_mem] ; LFB start address
 53686 0000E47F 89C8                <1> 	mov	eax, ecx ; color
 53687                              <1> 
 53688 0000E481 F6C610              <1> 	test	dh, 10h
 53689                              <1> 	;jz	pix_op_lin_h ; Horizontal line
 53690                              <1> 	; 23/07/2022
 53691 0000E484 7505                <1> 	jnz	short pix_op_lin_v
 53692 0000E486 E98A000000          <1> 	jmp	pix_op_lin_h
 53693                              <1> 
 53694                              <1> pix_op_lin_v:
 53695                              <1> 	; Vertical line
 53696 0000E48B 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
 53697 0000E48E 51                  <1> 	push	ecx ; color
 53698 0000E48F 89D1                <1> 	mov	ecx, edx
 53699 0000E491 0FB705[3A100300]    <1> 	movzx	eax, word [v_width]
 53700 0000E498 89C3                <1> 	mov	ebx, eax
 53701                              <1> 	; 12/02/2021
 53702 0000E49A F7E2                <1> 	mul	edx ; rows * [v_width]
 53703 0000E49C 01F8                <1> 	add	eax, edi
 53704 0000E49E 3B05[4A100300]      <1> 	cmp	eax, [v_end]
 53705 0000E4A4 58                  <1> 	pop	eax ; color
 53706 0000E4A5 7717                <1> 	ja	short pix_op_lin_err1 ; out of display page
 53707                              <1> 	; ecx = rows	
 53708 0000E4A7 89CA                <1> 	mov	edx, ecx
 53709                              <1> 
 53710 0000E4A9 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53711 0000E4B0 770D                <1> 	ja	short pix_op_lin_v_2
 53712                              <1> 	; 256 colors (1 byte per pixel)
 53713 0000E4B2 010D[1C010300]      <1> 	add	[u.r0], ecx ; byte count
 53714                              <1> pix_op_lin_v_1:
 53715 0000E4B8 8807                <1> 	mov	[edi], al
 53716 0000E4BA 01DF                <1> 	add	edi, ebx  ; next row	
 53717 0000E4BC E2FA                <1> 	loop	pix_op_lin_v_1
 53718                              <1> pix_op_lin_err1:
 53719 0000E4BE C3                  <1> 	retn
 53720                              <1> 
 53721                              <1> pix_op_lin_v_2:
 53722 0000E4BF 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53723 0000E4C6 773A                <1> 	ja	short pix_op_lin_v_6 ; 32bpp
 53724 0000E4C8 7226                <1> 	jb	short pix_op_lin_v_4 ; 16bpp
 53725                              <1> 	
 53726                              <1> 	; 24 bit true colors
 53727                              <1> 	; * 3
 53728 0000E4CA 53                  <1> 	push	ebx ; screen width in pixels
 53729 0000E4CB D1E3                <1> 	shl	ebx, 1
 53730 0000E4CD 011C24              <1> 	add	[esp], ebx
 53731 0000E4D0 5B                  <1> 	pop	ebx ; screen width in bytes
 53732 0000E4D1 010D[1C010300]      <1> 	add	[u.r0], ecx
 53733 0000E4D7 D1E2                <1> 	shl	edx, 1
 53734 0000E4D9 0115[1C010300]      <1> 	add	[u.r0], edx ; byte count
 53735                              <1> pix_op_lin_v_3:
 53736 0000E4DF 668907              <1> 	mov	[edi], ax
 53737 0000E4E2 C1C810              <1> 	ror	eax, 16
 53738 0000E4E5 884702              <1> 	mov	[edi+2], al	
 53739 0000E4E8 C1C010              <1> 	rol	eax, 16
 53740 0000E4EB 01DF                <1> 	add	edi, ebx  ; next row	
 53741 0000E4ED E2F0                <1> 	loop	pix_op_lin_v_3
 53742 0000E4EF C3                  <1> 	retn
 53743                              <1> 
 53744                              <1> pix_op_lin_v_4:
 53745                              <1> 	; 16 bit (65536) colors
 53746 0000E4F0 D1E3                <1> 	shl	ebx, 1
 53747 0000E4F2 D1E2                <1> 	shl	edx, 1
 53748 0000E4F4 0115[1C010300]      <1> 	add	[u.r0], edx
 53749                              <1> pix_op_lin_v_5:
 53750 0000E4FA 668907              <1> 	mov	[edi], ax
 53751 0000E4FD 01DF                <1> 	add	edi, ebx  ; next row	
 53752 0000E4FF E2F9                <1> 	loop	pix_op_lin_v_5
 53753 0000E501 C3                  <1> 	retn
 53754                              <1> 
 53755                              <1> pix_op_lin_v_6:
 53756                              <1> 	; 32 bit true colors
 53757 0000E502 C1E302              <1> 	shl	ebx, 2
 53758 0000E505 C1E202              <1> 	shl	edx, 2
 53759 0000E508 0115[1C010300]      <1> 	add	[u.r0], edx ; byte count
 53760                              <1> pix_op_lin_v_7:
 53761 0000E50E 8907                <1> 	mov	[edi], eax
 53762 0000E510 01DF                <1> 	add	edi, ebx  ; next row	
 53763 0000E512 E2FA                <1> 	loop	pix_op_lin_v_7
 53764 0000E514 C3                  <1> 	retn		
 53765                              <1> 
 53766                              <1> pix_op_lin_h:
 53767                              <1> 	; Horizontal line
 53768 0000E515 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
 53769 0000E518 89D1                <1>   	mov	ecx, edx
 53770 0000E51A 6601D6              <1> 	add	si, dx ; start column + columns
 53771 0000E51D 663B35[3A100300]    <1> 	cmp	si, [v_width] ; screen width
 53772 0000E524 7711                <1> 	ja	short pix_op_lin_err2 ; out of columns limit
 53773                              <1> 
 53774 0000E526 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 53775 0000E52D 7709                <1> 	ja	short pix_op_lin_h_1
 53776                              <1> 	; 256 colors (1 byte per pixel)
 53777 0000E52F 010D[1C010300]      <1> 	add	[u.r0], ecx
 53778 0000E535 F3AA                <1> 	rep	stosb
 53779                              <1> pix_op_lin_err2:
 53780 0000E537 C3                  <1> 	retn
 53781                              <1> 
 53782                              <1> pix_op_lin_h_1:
 53783 0000E538 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 53784 0000E53F 7728                <1> 	ja	short pix_op_lin_h_4 ; 32bpp
 53785 0000E541 721A                <1> 	jb	short pix_op_lin_h_3 ; 16bpp
 53786                              <1> 	
 53787                              <1> 	; 24 bit true colors
 53788                              <1> 	; * 3
 53789 0000E543 0115[1C010300]      <1> 	add	[u.r0], edx
 53790 0000E549 D1E2                <1> 	shl	edx, 1
 53791 0000E54B 0115[1C010300]      <1> 	add	[u.r0], edx
 53792                              <1> pix_op_lin_h_2:
 53793 0000E551 66AB                <1> 	stosw
 53794 0000E553 C1C810              <1> 	ror	eax, 16
 53795 0000E556 AA                  <1> 	stosb	
 53796 0000E557 C1C010              <1> 	rol	eax, 16
 53797 0000E55A E2F5                <1> 	loop	pix_op_lin_h_2
 53798 0000E55C C3                  <1> 	retn
 53799                              <1> 
 53800                              <1> pix_op_lin_h_3:
 53801                              <1> 	; 16 bit (65536) colors
 53802 0000E55D D1E2                <1> 	shl	edx, 1
 53803 0000E55F 0115[1C010300]      <1> 	add	[u.r0], edx
 53804 0000E565 F366AB              <1> 	rep	stosw
 53805 0000E568 C3                  <1> 	retn
 53806                              <1> 
 53807                              <1> pix_op_lin_h_4:
 53808                              <1> 	; 32 bit true colors
 53809 0000E569 C1E202              <1> 	shl	edx, 2
 53810 0000E56C 0115[1C010300]      <1> 	add	[u.r0], edx
 53811 0000E572 F3AB                <1> 	rep	stosd
 53812 0000E574 C3                  <1> 	retn
 53813                              <1> 
 53814                              <1> pix_op_new_8:
 53815                              <1> 	; 8 bit colors (256 colors)
 53816                              <1> 	; CHANGE PIXEL COLOR
 53817                              <1> 	; ecx = pixel count per row
 53818                              <1> 	;  al = color
 53819                              <1> 	; edi = start pixel address 
 53820                              <1> 
 53821 0000E575 F3AA                <1> 	rep	stosb
 53822 0000E577 C3                  <1> 	retn
 53823                              <1> 
 53824                              <1> pix_op_new_16:
 53825                              <1> 	; 16 bit colors (65536 colors)
 53826                              <1> 	; CHANGE PIXEL COLOR
 53827                              <1> 	; ecx = pixel count per row
 53828                              <1> 	;  ax = color
 53829                              <1> 	; edi = start pixel address 
 53830                              <1> 
 53831 0000E578 F366AB              <1> 	rep	stosw
 53832 0000E57B C3                  <1> 	retn
 53833                              <1> 
 53834                              <1> pix_op_new_24:
 53835                              <1> 	; 24 bit true colors
 53836                              <1> 	; CHANGE PIXEL COLOR
 53837                              <1> 	; ecx = pixel count per row
 53838                              <1> 	; eax = color
 53839                              <1> 	; edi = start pixel address 
 53840                              <1> 
 53841 0000E57C 66AB                <1> 	stosw
 53842 0000E57E C1C810              <1> 	ror	eax, 16	
 53843 0000E581 AA                  <1> 	stosb
 53844 0000E582 C1C010              <1> 	rol	eax, 16
 53845 0000E585 E2F5                <1> 	loop	pix_op_new_24
 53846 0000E587 C3                  <1> 	retn
 53847                              <1> 
 53848                              <1> pix_op_new_32:
 53849                              <1> 	; 32 bit true colors
 53850                              <1> 	; CHANGE PIXEL COLOR
 53851                              <1> 	; ecx = pixel count per row
 53852                              <1> 	; eax = color
 53853                              <1> 	; edi = start pixel address 
 53854                              <1> 
 53855 0000E588 F3AB                <1> 	rep	stosd
 53856 0000E58A C3                  <1> 	retn
 53857                              <1> 
 53858                              <1> pix_op_add_8:
 53859                              <1> 	; 8 bit colors (256 colors)
 53860                              <1> 	; ADD PIXEL COLOR
 53861                              <1> 	; ecx = pixel count per row
 53862                              <1> 	;  al = color
 53863                              <1> 	; edi = start pixel address 
 53864                              <1> 
 53865 0000E58B 88C4                <1> 	mov	ah, al
 53866                              <1> pix_op_add_8_0:
 53867 0000E58D 0207                <1> 	add	al, [edi]
 53868 0000E58F 7302                <1> 	jnc	short pix_op_add_8_1
 53869 0000E591 B0FF                <1> 	mov	al, 0FFh ; Max. value	
 53870                              <1> pix_op_add_8_1:
 53871 0000E593 AA                  <1> 	stosb
 53872 0000E594 88E0                <1> 	mov	al, ah
 53873 0000E596 E2F5                <1> 	loop	pix_op_add_8_0
 53874 0000E598 C3                  <1> 	retn
 53875                              <1> 
 53876                              <1> pix_op_add_16:
 53877                              <1> 	; 16 bit colors (65536 colors)
 53878                              <1> 	; ADD PIXEL COLOR
 53879                              <1> 	; ecx = pixel count per row
 53880                              <1> 	;  ax = color
 53881                              <1> 	; edi = start pixel address 
 53882                              <1> 
 53883 0000E599 89C2                <1> 	mov	edx, eax
 53884                              <1> pix_op_add_16_0:
 53885 0000E59B 660307              <1> 	add	ax, [edi]
 53886 0000E59E 7304                <1> 	jnc	short pix_op_add_16_1
 53887 0000E5A0 66B8FFFF            <1> 	mov	ax, 0FFFFh ; Max. value	
 53888                              <1> pix_op_add_16_1:
 53889 0000E5A4 66AB                <1> 	stosw
 53890 0000E5A6 89D0                <1> 	mov	eax, edx
 53891 0000E5A8 E2F1                <1> 	loop	pix_op_add_16_0
 53892 0000E5AA C3                  <1> 	retn
 53893                              <1> 
 53894                              <1> pix_op_add_24:
 53895                              <1> 	; 24 bit true colors
 53896                              <1> 	; ADD PIXEL COLOR
 53897                              <1> 	; ecx = pixel count per row
 53898                              <1> 	; eax = color
 53899                              <1> 	; edi = start pixel address 
 53900                              <1> 
 53901 0000E5AB 53                  <1> 	push	ebx
 53902 0000E5AC BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
 53903                              <1> 	;and	eax, ebx ; 0FFFFFFh
 53904 0000E5B1 89C2                <1> 	mov	edx, eax
 53905                              <1> pix_op_add_24_0:
 53906 0000E5B3 8B07                <1> 	mov	eax, [edi]
 53907 0000E5B5 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
 53908 0000E5B7 01D0                <1> 	add	eax, edx
 53909 0000E5B9 39D8                <1> 	cmp	eax, ebx
 53910 0000E5BB 7602                <1> 	jna	short pix_op_add_24_1
 53911 0000E5BD 89D8                <1> 	mov	eax, ebx ; 0FFFFFFh  ; Max. value
 53912                              <1> pix_op_add_24_1: 
 53913 0000E5BF 66AB                <1> 	stosw
 53914 0000E5C1 C1E810              <1> 	shr	eax, 16
 53915 0000E5C4 AA                  <1> 	stosb
 53916 0000E5C5 E2EC                <1> 	loop	pix_op_add_24_0
 53917 0000E5C7 89D0                <1> 	mov	eax, edx
 53918 0000E5C9 5B                  <1> 	pop	ebx
 53919 0000E5CA C3                  <1> 	retn
 53920                              <1> 
 53921                              <1> pix_op_add_32:
 53922                              <1> 	; 32 bit true colors
 53923                              <1> 	; ADD PIXEL COLOR
 53924                              <1> 	; ecx = pixel count per row
 53925                              <1> 	; eax = color
 53926                              <1> 	; edi = start pixel address 
 53927                              <1> 
 53928 0000E5CB 89C2                <1> 	mov	edx, eax
 53929                              <1> pix_op_add_32_0:
 53930 0000E5CD 0307                <1> 	add	eax, [edi]
 53931 0000E5CF 7303                <1> 	jnc	short pix_op_add_32_1
 53932                              <1> 	;mov	eax, 0FFFFFFFFh ; Max. value
 53933 0000E5D1 29C0                <1> 	sub	eax, eax
 53934 0000E5D3 48                  <1> 	dec	eax	
 53935                              <1> pix_op_add_32_1:
 53936 0000E5D4 AB                  <1> 	stosd
 53937 0000E5D5 89D0                <1> 	mov	eax, edx
 53938 0000E5D7 E2F4                <1> 	loop	pix_op_add_32_0
 53939 0000E5D9 C3                  <1> 	retn
 53940                              <1> 
 53941                              <1> pix_op_sub_8:
 53942                              <1> 	; 8 bit colors (256 colors)
 53943                              <1> 	; SUBTRACT PIXEL COLOR
 53944                              <1> 	; ecx = pixel count per row
 53945                              <1> 	;  al = color
 53946                              <1> 	; edi = start pixel address 
 53947                              <1> 
 53948 0000E5DA 88C4                <1> 	mov	ah, al
 53949                              <1> pix_op_sub_8_0:
 53950 0000E5DC 8A07                <1> 	mov	al, [edi]
 53951 0000E5DE 28E0                <1> 	sub	al, ah
 53952 0000E5E0 7302                <1> 	jnb	short pix_op_sub_8_1
 53953 0000E5E2 30C0                <1> 	xor	al, al ; 0 ; Min. value	
 53954                              <1> pix_op_sub_8_1:
 53955 0000E5E4 AA                  <1> 	stosb
 53956 0000E5E5 E2F5                <1> 	loop	pix_op_sub_8_0
 53957 0000E5E7 88E0                <1> 	mov	al, ah
 53958 0000E5E9 C3                  <1> 	retn
 53959                              <1> 
 53960                              <1> pix_op_sub_16:
 53961                              <1> 	; 16 bit colors (65536 colors)
 53962                              <1> 	; SUBTRACT PIXEL COLOR
 53963                              <1> 	; ecx = pixel count per row
 53964                              <1> 	;  ax = color
 53965                              <1> 	; edi = start pixel address 
 53966                              <1> 
 53967 0000E5EA 89C2                <1> 	mov	edx, eax
 53968                              <1> pix_op_sub_16_0:
 53969 0000E5EC 668B07              <1> 	mov	ax, [edi]
 53970 0000E5EF 6629D0              <1> 	sub	ax, dx
 53971 0000E5F2 7302                <1> 	jnb	short pix_op_sub_16_1
 53972 0000E5F4 31C0                <1> 	xor	eax, eax ; 0 ; Min. value	
 53973                              <1> pix_op_sub_16_1:
 53974 0000E5F6 66AB                <1> 	stosw
 53975 0000E5F8 E2F2                <1> 	loop	pix_op_sub_16_0
 53976 0000E5FA 89D0                <1> 	mov	eax, edx
 53977 0000E5FC C3                  <1> 	retn
 53978                              <1> 
 53979                              <1> pix_op_sub_24:
 53980                              <1> 	; 24 bit true colors
 53981                              <1> 	; SUBTRACT PIXEL COLOR
 53982                              <1> 	; ecx = pixel count per row
 53983                              <1> 	; eax = color
 53984                              <1> 	; edi = start pixel address 
 53985                              <1> 
 53986                              <1> 	;and	eax, 0FFFFFFh
 53987 0000E5FD 89C2                <1> 	mov	edx, eax
 53988                              <1> pix_op_sub_24_0:
 53989 0000E5FF 8B07                <1> 	mov	eax, [edi]
 53990                              <1> 	; 27/02/2021
 53991 0000E601 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 53992 0000E606 29D0                <1> 	sub	eax, edx
 53993 0000E608 7302                <1> 	jnb	short pix_op_sub_24_1
 53994 0000E60A 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
 53995                              <1> pix_op_sub_24_1: 
 53996 0000E60C 66AB                <1> 	stosw
 53997 0000E60E C1E810              <1> 	shr	eax, 16
 53998 0000E611 AA                  <1> 	stosb
 53999 0000E612 E2EB                <1> 	loop	pix_op_sub_24_0
 54000 0000E614 89D0                <1> 	mov	eax, edx
 54001 0000E616 C3                  <1> 	retn
 54002                              <1> 
 54003                              <1> pix_op_sub_32:
 54004                              <1> 	; 32 bit true colors
 54005                              <1> 	; SUBTRACT PIXEL COLOR
 54006                              <1> 	; ecx = pixel count per row
 54007                              <1> 	; eax = color
 54008                              <1> 	; edi = start pixel address 
 54009                              <1> 
 54010 0000E617 89C2                <1> 	mov	edx, eax
 54011                              <1> pix_op_sub_32_0:
 54012 0000E619 8B07                <1> 	mov	eax, [edi]
 54013 0000E61B 29D0                <1> 	sub	eax, edx
 54014 0000E61D 7302                <1> 	jnb	short pix_op_sub_32_1
 54015 0000E61F 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
 54016                              <1> pix_op_sub_32_1:
 54017 0000E621 AB                  <1> 	stosd
 54018 0000E622 E2F5                <1> 	loop	pix_op_sub_32_0
 54019 0000E624 89D0                <1> 	mov	eax, edx
 54020 0000E626 C3                  <1> 	retn
 54021                              <1> 
 54022                              <1> pix_op_or_8:
 54023                              <1> 	; 8 bit colors (256 colors)
 54024                              <1> 	; OR PIXEL COLOR
 54025                              <1> 	; ecx = pixel count per row
 54026                              <1> 	;  al = color
 54027                              <1> 	; edi = start pixel address 
 54028                              <1> 
 54029                              <1> pix_op_or_8_0:
 54030 0000E627 0807                <1> 	or	[edi], al
 54031 0000E629 47                  <1> 	inc	edi
 54032 0000E62A E2FB                <1> 	loop	pix_op_or_8_0
 54033 0000E62C C3                  <1> 	retn
 54034                              <1> 
 54035                              <1> pix_op_or_16:
 54036                              <1> 	; 16 bit colors (65536 colors)
 54037                              <1> 	; OR PIXEL COLOR
 54038                              <1> 	; ecx = pixel count per row
 54039                              <1> 	;  ax = color
 54040                              <1> 	; edi = start pixel address 
 54041                              <1> 
 54042                              <1> pix_op_or_16_0:
 54043 0000E62D 660907              <1> 	or	[edi], ax
 54044 0000E630 47                  <1> 	inc	edi
 54045 0000E631 47                  <1> 	inc	edi
 54046 0000E632 E2F9                <1> 	loop	pix_op_or_16_0
 54047 0000E634 C3                  <1> 	retn
 54048                              <1> 
 54049                              <1> pix_op_or_24:
 54050                              <1> 	; 24 bit true colors
 54051                              <1> 	; OR PIXEL COLOR
 54052                              <1> 	; ecx = pixel count per row
 54053                              <1> 	; eax = color
 54054                              <1> 	; edi = start pixel address 
 54055                              <1> 
 54056 0000E635 89C2                <1> 	mov	edx, eax
 54057                              <1> pix_op_or_24_0:
 54058 0000E637 0B07                <1> 	or	eax, [edi]
 54059 0000E639 66AB                <1> 	stosw
 54060 0000E63B C1E810              <1> 	shr	eax, 16
 54061 0000E63E AA                  <1> 	stosb	
 54062 0000E63F 89D0                <1> 	mov	eax, edx
 54063 0000E641 E2F4                <1> 	loop	pix_op_or_24_0
 54064 0000E643 C3                  <1> 	retn
 54065                              <1> 
 54066                              <1> pix_op_or_32:
 54067                              <1> 	; 32 bit true colors
 54068                              <1> 	; OR PIXEL COLOR
 54069                              <1> 	; ecx = pixel count per row
 54070                              <1> 	; eax = color
 54071                              <1> 	; edi = start pixel address 
 54072                              <1> 
 54073                              <1> 	;mov	edx, eax
 54074                              <1> pix_op_or_32_0:
 54075                              <1> 	;or	eax, [edi]
 54076                              <1> 	;stosd
 54077                              <1> 	;mov	eax, edx
 54078 0000E644 0907                <1> 	or	[edi], eax
 54079 0000E646 83C704              <1> 	add	edi, 4
 54080 0000E649 E2F9                <1> 	loop	pix_op_or_32_0
 54081 0000E64B C3                  <1> 	retn
 54082                              <1> 
 54083                              <1> pix_op_and_8:
 54084                              <1> 	; 8 bit colors (256 colors)
 54085                              <1> 	; AND PIXEL COLOR
 54086                              <1> 	; ecx = pixel count per row
 54087                              <1> 	;  al = color
 54088                              <1> 	; edi = start pixel address 
 54089                              <1> 
 54090                              <1> pix_op_and_8_0:
 54091 0000E64C 2007                <1> 	and	[edi], al
 54092 0000E64E 47                  <1> 	inc	edi
 54093 0000E64F E2FB                <1> 	loop	pix_op_and_8_0
 54094 0000E651 C3                  <1> 	retn
 54095                              <1> 
 54096                              <1> pix_op_and_16:
 54097                              <1> 	; 16 bit colors (65536 colors)
 54098                              <1> 	; AND PIXEL COLOR
 54099                              <1> 	; ecx = pixel count per row
 54100                              <1> 	;  ax = color
 54101                              <1> 	; edi = start pixel address 
 54102                              <1> 
 54103                              <1> pix_op_and_16_0:
 54104 0000E652 662107              <1> 	and	[edi], ax
 54105 0000E655 47                  <1> 	inc	edi
 54106 0000E656 47                  <1> 	inc	edi
 54107 0000E657 E2F9                <1> 	loop	pix_op_and_16_0
 54108 0000E659 C3                  <1> 	retn
 54109                              <1> 
 54110                              <1> pix_op_and_24:
 54111                              <1> 	; 24 bit true colors
 54112                              <1> 	; AND PIXEL COLOR
 54113                              <1> 	; ecx = pixel count per row
 54114                              <1> 	; eax = color
 54115                              <1> 	; edi = start pixel address 
 54116                              <1> 
 54117 0000E65A 89C2                <1> 	mov	edx, eax
 54118                              <1> pix_op_and_24_0:
 54119 0000E65C 2307                <1> 	and	eax, [edi]
 54120 0000E65E 66AB                <1> 	stosw
 54121 0000E660 C1E810              <1> 	shr	eax, 16
 54122 0000E663 AA                  <1> 	stosb	
 54123 0000E664 89D0                <1> 	mov	eax, edx
 54124 0000E666 E2F4                <1> 	loop	pix_op_and_24_0
 54125 0000E668 C3                  <1> 	retn
 54126                              <1> 
 54127                              <1> pix_op_and_32:
 54128                              <1> 	; 32 bit true colors
 54129                              <1> 	; AND PIXEL COLOR
 54130                              <1> 	; ecx = pixel count per row
 54131                              <1> 	; eax = color
 54132                              <1> 	; edi = start pixel address 
 54133                              <1> 
 54134                              <1> 	;mov	edx, eax
 54135                              <1> pix_op_and_32_0:
 54136                              <1> 	;and	eax, [edi]
 54137                              <1> 	;stosd
 54138                              <1> 	;mov	eax, edx
 54139 0000E669 2107                <1> 	and	[edi], eax
 54140 0000E66B 83C704              <1> 	add	edi, 4
 54141 0000E66E E2F9                <1> 	loop	pix_op_and_32_0
 54142 0000E670 C3                  <1> 	retn
 54143                              <1> 
 54144                              <1> pix_op_xor_8:
 54145                              <1> 	; 8 bit colors (256 colors)
 54146                              <1> 	; XOR PIXEL COLOR
 54147                              <1> 	; ecx = pixel count per row
 54148                              <1> 	;  al = color
 54149                              <1> 	; edi = start pixel address 
 54150                              <1> 
 54151                              <1> pix_op_xor_8_0:
 54152 0000E671 3007                <1> 	xor	[edi], al
 54153 0000E673 47                  <1> 	inc	edi
 54154 0000E674 E2FB                <1> 	loop	pix_op_xor_8_0
 54155 0000E676 C3                  <1> 	retn
 54156                              <1> 
 54157                              <1> pix_op_xor_16:
 54158                              <1> 	; 16 bit colors (65536 colors)
 54159                              <1> 	; XOR PIXEL COLOR
 54160                              <1> 	; ecx = pixel count per row
 54161                              <1> 	;  ax = color
 54162                              <1> 	; edi = start pixel address 
 54163                              <1> 
 54164                              <1> pix_op_xor_16_0:
 54165 0000E677 663107              <1> 	xor	[edi], ax
 54166 0000E67A 47                  <1> 	inc	edi
 54167 0000E67B 47                  <1> 	inc	edi
 54168 0000E67C E2F9                <1> 	loop	pix_op_xor_16_0
 54169 0000E67E C3                  <1> 	retn
 54170                              <1> 
 54171                              <1> pix_op_xor_24:
 54172                              <1> 	; 24 bit true colors
 54173                              <1> 	; XOR PIXEL COLOR
 54174                              <1> 	; ecx = pixel count per row
 54175                              <1> 	; eax = color
 54176                              <1> 	; edi = start pixel address 
 54177                              <1> 
 54178 0000E67F 89C2                <1> 	mov	edx, eax
 54179                              <1> pix_op_xor_24_0:
 54180 0000E681 3307                <1> 	xor	eax, [edi]
 54181 0000E683 66AB                <1> 	stosw
 54182 0000E685 C1E810              <1> 	shr	eax, 16
 54183 0000E688 AA                  <1> 	stosb	
 54184 0000E689 89D0                <1> 	mov	eax, edx
 54185 0000E68B E2F4                <1> 	loop	pix_op_xor_24_0
 54186 0000E68D C3                  <1> 	retn
 54187                              <1> 
 54188                              <1> pix_op_xor_32:
 54189                              <1> 	; 32 bit true colors
 54190                              <1> 	; XOR PIXEL COLOR
 54191                              <1> 	; ecx = pixel count per row
 54192                              <1> 	; eax = color
 54193                              <1> 	; edi = start pixel address 
 54194                              <1> 
 54195                              <1> 	;mov	edx, eax
 54196                              <1> pix_op_xor_32_0:
 54197                              <1> 	;xor	eax, [edi]
 54198                              <1> 	;stosd
 54199                              <1> 	;mov	eax, edx
 54200 0000E68E 3107                <1> 	xor	[edi], eax
 54201 0000E690 83C704              <1> 	add	edi, 4
 54202 0000E693 E2F9                <1> 	loop	pix_op_xor_32_0
 54203 0000E695 C3                  <1> 	retn
 54204                              <1> 
 54205                              <1> pix_op_mix_8:
 54206                              <1> 	; 8 bit colors (256 colors)
 54207                              <1> 	; MIX (AVERAGE) PIXEL COLORS
 54208                              <1> 	; ecx = pixel count per row
 54209                              <1> 	;  al = color
 54210                              <1> 	; edi = start pixel address 
 54211                              <1> 
 54212 0000E696 88C4                <1> 	mov	ah, al
 54213                              <1> pix_op_mix_8_0:
 54214 0000E698 0207                <1> 	add	al, [edi]
 54215 0000E69A D0D8                <1> 	rcr	al, 1
 54216 0000E69C AA                  <1> 	stosb
 54217 0000E69D 88E0                <1> 	mov	al, ah
 54218 0000E69F E2F7                <1> 	loop	pix_op_mix_8_0
 54219 0000E6A1 C3                  <1> 	retn
 54220                              <1> 
 54221                              <1> pix_op_mix_16:
 54222                              <1> 	; 16 bit colors (65536 colors)
 54223                              <1> 	; MIX (AVERAGE) PIXEL COLORS
 54224                              <1> 	; ecx = pixel count per row
 54225                              <1> 	;  ax = color
 54226                              <1> 	; edi = start pixel address 
 54227                              <1> 
 54228 0000E6A2 89C2                <1> 	mov	edx, eax
 54229                              <1> pix_op_mix_16_0:
 54230 0000E6A4 660307              <1> 	add	ax, [edi]
 54231 0000E6A7 66D1D8              <1> 	rcr	ax, 1
 54232 0000E6AA 66AB                <1> 	stosw
 54233 0000E6AC 89D0                <1> 	mov	eax, edx
 54234 0000E6AE E2F4                <1> 	loop	pix_op_mix_16_0
 54235 0000E6B0 C3                  <1> 	retn
 54236                              <1> 
 54237                              <1> pix_op_mix_24:
 54238                              <1> 	; 24 bit true colors
 54239                              <1> 	; MIX (AVERAGE) PIXEL COLORS
 54240                              <1> 	; ecx = pixel count per row
 54241                              <1> 	; eax = color
 54242                              <1> 	; edi = start pixel address 
 54243                              <1> 
 54244 0000E6B1 53                  <1> 	push	ebx
 54245 0000E6B2 BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
 54246                              <1> 	;and	eax, ebx ; 0FFFFFFh
 54247 0000E6B7 89C2                <1> 	mov	edx, eax
 54248                              <1> pix_op_mix_24_0:
 54249 0000E6B9 8B07                <1> 	mov	eax, [edi]
 54250 0000E6BB 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
 54251 0000E6BD 01D0                <1> 	add	eax, edx
 54252 0000E6BF D1E8                <1> 	shr	eax, 1
 54253                              <1> 	;rcr	eax, 1
 54254 0000E6C1 66AB                <1> 	stosw
 54255 0000E6C3 C1E810              <1> 	shr	eax, 16
 54256 0000E6C6 AA                  <1> 	stosb
 54257 0000E6C7 E2F0                <1> 	loop	pix_op_mix_24_0
 54258 0000E6C9 89D0                <1> 	mov	eax, edx
 54259 0000E6CB 5B                  <1> 	pop	ebx
 54260 0000E6CC C3                  <1> 	retn
 54261                              <1> 
 54262                              <1> pix_op_mix_32:
 54263                              <1> 	; 32 bit true colors
 54264                              <1> 	; MIX (AVERAGE) PIXEL COLORS
 54265                              <1> 	; ecx = pixel count per row
 54266                              <1> 	; eax = color
 54267                              <1> 	; edi = start pixel address 
 54268                              <1> 
 54269 0000E6CD 89C2                <1> 	mov	edx, eax
 54270                              <1> pix_op_mix_32_0:
 54271 0000E6CF 0307                <1> 	add	eax, [edi]
 54272 0000E6D1 D1D8                <1> 	rcr	eax, 1	
 54273 0000E6D3 AB                  <1> 	stosd
 54274 0000E6D4 89D0                <1> 	mov	eax, edx
 54275 0000E6D6 E2F7                <1> 	loop	pix_op_mix_32_0
 54276 0000E6D8 C3                  <1> 	retn
 54277                              <1> 
 54278                              <1> pix_op_not_8:
 54279                              <1> 	; 8 bit colors (256 colors)
 54280                              <1> 	; NOT PIXEL COLOR
 54281                              <1> 	; ecx = pixel count per row
 54282                              <1> 	; edi = start pixel address 
 54283                              <1> 
 54284                              <1> pix_op_not_8_0:
 54285 0000E6D9 F617                <1> 	not	byte [edi]
 54286 0000E6DB 47                  <1> 	inc	edi
 54287 0000E6DC E2FB                <1> 	loop	pix_op_not_8_0
 54288 0000E6DE C3                  <1> 	retn
 54289                              <1> 
 54290                              <1> pix_op_not_16:
 54291                              <1> 	; 16 bit colors (65536 colors)
 54292                              <1> 	; NOT PIXEL COLOR
 54293                              <1> 	; ecx = pixel count per row
 54294                              <1> 	; edi = start pixel address 
 54295                              <1> 
 54296                              <1> pix_op_not_16_0:
 54297 0000E6DF 66F717              <1> 	not	word [edi]
 54298 0000E6E2 47                  <1> 	inc	edi
 54299 0000E6E3 47                  <1> 	inc	edi
 54300 0000E6E4 E2F9                <1> 	loop	pix_op_not_16_0
 54301 0000E6E6 C3                  <1> 	retn
 54302                              <1> 
 54303                              <1> pix_op_not_24:
 54304                              <1> 	; 24 bit true colors
 54305                              <1> 	; NOT PIXEL COLOR
 54306                              <1> 	; ecx = pixel count per row
 54307                              <1> 	; edi = start pixel address 
 54308                              <1> 
 54309                              <1> pix_op_not_24_0:
 54310 0000E6E7 66F717              <1> 	not	word [edi]
 54311 0000E6EA 47                  <1> 	inc	edi
 54312 0000E6EB 47                  <1> 	inc	edi
 54313 0000E6EC F617                <1> 	not	byte [edi]
 54314 0000E6EE 47                  <1> 	inc	edi
 54315 0000E6EF E2F6                <1> 	loop	pix_op_not_24_0
 54316 0000E6F1 C3                  <1> 	retn
 54317                              <1> 
 54318                              <1> pix_op_not_32:
 54319                              <1> 	; 32 bit true colors
 54320                              <1> 	; NOT PIXEL COLOR
 54321                              <1> 	; ecx = pixel count per row
 54322                              <1> 	; eax = color
 54323                              <1> 	; edi = start pixel address 
 54324                              <1> pix_op_not_32_0:
 54325 0000E6F2 F717                <1> 	not	dword [edi]
 54326 0000E6F4 83C704              <1> 	add	edi, 4
 54327 0000E6F7 E2F9                <1> 	loop	pix_op_not_32_0
 54328 0000E6F9 C3                  <1> 	retn
 54329                              <1> 
 54330                              <1> pix_op_neg_8:
 54331                              <1> 	; 8 bit colors (256 colors)
 54332                              <1> 	; NEG PIXEL COLOR
 54333                              <1> 	; ecx = pixel count per row
 54334                              <1> 	; edi = start pixel address 
 54335                              <1> 
 54336                              <1> pix_op_neg_8_0:
 54337 0000E6FA F61F                <1> 	neg	byte [edi]
 54338 0000E6FC 47                  <1> 	inc	edi
 54339 0000E6FD E2FB                <1> 	loop	pix_op_neg_8_0
 54340 0000E6FF C3                  <1> 	retn
 54341                              <1> 
 54342                              <1> pix_op_neg_16:
 54343                              <1> 	; 16 bit colors (65536 colors)
 54344                              <1> 	; NEG PIXEL COLOR
 54345                              <1> 	; ecx = pixel count per row
 54346                              <1> 	; edi = start pixel address 
 54347                              <1> 
 54348                              <1> pix_op_neg_16_0:
 54349 0000E700 66F71F              <1> 	neg	word [edi]
 54350 0000E703 47                  <1> 	inc	edi
 54351 0000E704 47                  <1> 	inc	edi
 54352 0000E705 E2F9                <1> 	loop	pix_op_neg_16_0
 54353 0000E707 C3                  <1> 	retn
 54354                              <1> 
 54355                              <1> pix_op_neg_24:
 54356                              <1> 	; 24 bit true colors
 54357                              <1> 	; NEG PIXEL COLOR
 54358                              <1> 	; ecx = pixel count per row
 54359                              <1> 	; edi = start pixel address 
 54360                              <1> 
 54361                              <1> pix_op_neg_24_0:
 54362 0000E708 8B07                <1> 	mov	eax, [edi]
 54363 0000E70A 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 54364 0000E70F F7D8                <1> 	neg	eax
 54365 0000E711 66AB                <1> 	stosw
 54366 0000E713 C1E810              <1> 	shr	eax, 16
 54367 0000E716 AA                  <1> 	stosb
 54368 0000E717 E2EF                <1> 	loop	pix_op_neg_24_0
 54369 0000E719 C3                  <1> 	retn
 54370                              <1> 
 54371                              <1> pix_op_neg_32:
 54372                              <1> 	; 32 bit true colors
 54373                              <1> 	; NEG PIXEL COLOR
 54374                              <1> 	; ecx = pixel count per row
 54375                              <1> 	; eax = color
 54376                              <1> 	; edi = start pixel address 
 54377                              <1> pix_op_neg_32_0:
 54378 0000E71A F71F                <1> 	neg	dword [edi]
 54379 0000E71C 83C704              <1> 	add	edi, 4
 54380 0000E71F E2F9                <1> 	loop	pix_op_neg_32_0
 54381 0000E721 C3                  <1> 	retn
 54382                              <1> 
 54383                              <1> pix_op_inc_8:
 54384                              <1> 	; 8 bit colors (256 colors)
 54385                              <1> 	; INCREASE PIXEL COLOR
 54386                              <1> 	; ecx = pixel count per row
 54387                              <1> 	; edi = start pixel address 
 54388                              <1> 
 54389                              <1> pix_op_inc_8_0:
 54390 0000E722 FE07                <1> 	inc	byte [edi]
 54391 0000E724 7502                <1> 	jnz	short pix_op_inc_8_1
 54392                              <1> 	;mov	[edi], 0FFh ; Max. value	
 54393 0000E726 FE0F                <1> 	dec	byte [edi]
 54394                              <1> pix_op_inc_8_1:
 54395 0000E728 47                  <1> 	inc	edi
 54396 0000E729 E2F7                <1> 	loop	pix_op_inc_8_0
 54397 0000E72B C3                  <1> 	retn
 54398                              <1> 
 54399                              <1> pix_op_inc_16:
 54400                              <1> 	; 16 bit colors (65536 colors)
 54401                              <1> 	; INCREASE PIXEL COLOR
 54402                              <1> 	; ecx = pixel count per row
 54403                              <1> 	; edi = start pixel address 
 54404                              <1> 
 54405                              <1> pix_op_inc_16_0:
 54406 0000E72C 66FF07              <1> 	inc	word [edi]
 54407 0000E72F 7503                <1> 	jnz	short pix_op_inc_16_1
 54408                              <1> 	;mov	word [edi], 0FFFFh ; Max. value
 54409 0000E731 66FF0F              <1> 	dec	word [edi]
 54410                              <1> pix_op_inc_16_1:
 54411 0000E734 47                  <1> 	inc	edi
 54412 0000E735 47                  <1> 	inc	edi
 54413 0000E736 E2F4                <1> 	loop	pix_op_inc_16_0
 54414 0000E738 C3                  <1> 	retn
 54415                              <1> 
 54416                              <1> pix_op_inc_24:
 54417                              <1> 	; 24 bit true colors
 54418                              <1> 	; INCREASE PIXEL COLOR
 54419                              <1> 	; ecx = pixel count per row
 54420                              <1> 	; edi = start pixel address 
 54421                              <1> 
 54422                              <1> pix_op_inc_24_0:
 54423 0000E739 8B07                <1> 	mov	eax, [edi]
 54424 0000E73B 40                  <1> 	inc	eax
 54425 0000E73C 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 54426 0000E741 7501                <1> 	jnz	short pix_op_inc_24_1
 54427                              <1> 	;mov	eax, 0FFFFFFh  ; Max. value
 54428 0000E743 48                  <1> 	dec	eax ; 0FFFFFFFFh
 54429                              <1> pix_op_inc_24_1: 
 54430 0000E744 66AB                <1> 	stosw
 54431 0000E746 C1E810              <1> 	shr	eax, 16
 54432 0000E749 AA                  <1> 	stosb
 54433 0000E74A E2ED                <1> 	loop	pix_op_inc_24_0
 54434 0000E74C C3                  <1> 	retn
 54435                              <1> 
 54436                              <1> pix_op_inc_32:
 54437                              <1> 	; 32 bit true colors
 54438                              <1> 	; INCREASE PIXEL COLOR
 54439                              <1> 	; ecx = pixel count per row
 54440                              <1> 	; edi = start pixel address 
 54441                              <1> 
 54442                              <1> pix_op_inc_32_0:
 54443 0000E74D FF07                <1> 	inc	dword [edi]
 54444 0000E74F 7502                <1> 	jnz	short pix_op_inc_32_1
 54445                              <1> 	;mov	dword [edi], 0FFFFFFFFh ; Max. value
 54446 0000E751 FF0F                <1> 	dec	dword [edi]
 54447                              <1> pix_op_inc_32_1:
 54448 0000E753 83C704              <1> 	add	edi, 4
 54449 0000E756 E2F5                <1> 	loop	pix_op_inc_32_0
 54450 0000E758 C3                  <1> 	retn
 54451                              <1> 
 54452                              <1> pix_op_dec_8:
 54453                              <1> 	; 8 bit colors (256 colors)
 54454                              <1> 	; DECREASE PIXEL COLOR
 54455                              <1> 	; ecx = pixel count per row
 54456                              <1> 	; edi = start pixel address 
 54457                              <1> 
 54458                              <1> pix_op_dec_8_0:
 54459 0000E759 FE0F                <1> 	dec	byte [edi]
 54460 0000E75B 7902                <1> 	jns	short pix_op_dec_8_1
 54461 0000E75D FE07                <1> 	inc	byte [edi] ; 0 ; Min. value	
 54462                              <1> pix_op_dec_8_1:
 54463 0000E75F 47                  <1> 	inc	edi
 54464 0000E760 E2F7                <1> 	loop	pix_op_dec_8_0
 54465 0000E762 C3                  <1> 	retn
 54466                              <1> 
 54467                              <1> pix_op_dec_16:
 54468                              <1> 	; 16 bit colors (65536 colors)
 54469                              <1> 	; DECREASE PIXEL COLOR
 54470                              <1> 	; ecx = pixel count per row
 54471                              <1> 	; edi = start pixel address 
 54472                              <1> 
 54473                              <1> pix_op_dec_16_0:
 54474 0000E763 66FF0F              <1> 	dec	word [edi]
 54475 0000E766 7903                <1> 	jns	short pix_op_dec_16_1
 54476 0000E768 66FF07              <1> 	inc	word [edi] ; 0 ; Min. value	
 54477                              <1> pix_op_dec_16_1:
 54478 0000E76B 47                  <1> 	inc edi
 54479 0000E76C 47                  <1> 	inc edi
 54480 0000E76D E2F4                <1> 	loop	pix_op_dec_16_0
 54481 0000E76F C3                  <1> 	retn
 54482                              <1> 
 54483                              <1> pix_op_dec_24:
 54484                              <1> 	; 24 bit true colors
 54485                              <1> 	; DECREASE PIXEL COLOR
 54486                              <1> 	; ecx = pixel count per row
 54487                              <1> 	; edi = start pixel address 
 54488                              <1> 
 54489                              <1> pix_op_dec_24_0:
 54490 0000E770 8B07                <1> 	mov	eax, [edi]
 54491 0000E772 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 54492 0000E777 7401                <1> 	jz	short pix_op_dec_24_1
 54493                              <1> 			; 0 ; Min. value
 54494 0000E779 48                  <1> 	dec	eax
 54495                              <1> pix_op_dec_24_1:
 54496 0000E77A 66AB                <1> 	stosw
 54497 0000E77C C1E810              <1> 	shr	eax, 16
 54498 0000E77F AA                  <1> 	stosb
 54499 0000E780 E2B7                <1> 	loop	pix_op_inc_24_0
 54500 0000E782 C3                  <1> 	retn
 54501                              <1> 
 54502                              <1> pix_op_dec_32:
 54503                              <1> 	; 32 bit true colors
 54504                              <1> 	; DECREASE PIXEL COLOR
 54505                              <1> 	; ecx = pixel count per row
 54506                              <1> 	; edi = start pixel address 
 54507                              <1> 
 54508                              <1> pix_op_dec_32_0:
 54509 0000E783 FF0F                <1> 	dec	dword [edi]
 54510 0000E785 7902                <1> 	jns	short pix_op_dec_32_1
 54511 0000E787 FF07                <1> 	inc	dword [edi] ; 0 ; Min. value
 54512                              <1> pix_op_dec_32_1:
 54513 0000E789 83C704              <1> 	add	edi, 4
 54514 0000E78C E2F5                <1> 	loop	pix_op_dec_32_0
 54515 0000E78E 89D0                <1> 	mov	eax, edx
 54516 0000E790 C3                  <1> 	retn
 54517                              <1> 
 54518                              <1> pix_op_rpl_8:
 54519                              <1> 	; 8 bit colors (256 colors)
 54520                              <1> 	; REPLACE PIXEL COLORS
 54521                              <1> 	; ecx = pixel count per row
 54522                              <1> 	;  al = new color
 54523                              <1> 	; byte [maskcolor] = old color
 54524                              <1> 	; edi = start pixel address
 54525                              <1> 
 54526 0000E791 8A25[4E100300]      <1> 	mov	ah, [maskcolor]
 54527                              <1> pix_op_rpl_8_0:
 54528 0000E797 3A27                <1> 	cmp	ah, [edi]
 54529 0000E799 7502                <1> 	jne	short pix_op_rpl_8_1
 54530 0000E79B 8807                <1> 	mov	[edi], al
 54531                              <1> pix_op_rpl_8_1:
 54532 0000E79D 47                  <1> 	inc	edi
 54533 0000E79E E2F7                <1> 	loop	pix_op_rpl_8_0
 54534 0000E7A0 C3                  <1> 	retn
 54535                              <1> 
 54536                              <1> pix_op_rpl_16:
 54537                              <1> 	; 16 bit colors (65536 colors)
 54538                              <1> 	; REPLACE PIXEL COLORS
 54539                              <1> 	; ecx = pixel count per row
 54540                              <1> 	;  ax = new color
 54541                              <1> 	; word [maskcolor] = old color
 54542                              <1> 	; edi = start pixel address
 54543                              <1> 
 54544 0000E7A1 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
 54545                              <1> pix_op_rpl_16_0:
 54546 0000E7A7 663B17              <1> 	cmp	dx, [edi]
 54547 0000E7AA 7503                <1> 	jne	short pix_op_rpl_16_1
 54548 0000E7AC 668907              <1> 	mov	[edi], ax
 54549                              <1> pix_op_rpl_16_1:
 54550 0000E7AF 47                  <1> 	inc	edi
 54551 0000E7B0 47                  <1> 	inc	edi
 54552 0000E7B1 E2F4                <1> 	loop	pix_op_rpl_16_0
 54553 0000E7B3 C3                  <1> 	retn
 54554                              <1> 
 54555                              <1> pix_op_rpl_24:
 54556                              <1> 	; 24 bit true colors
 54557                              <1> 	; REPLACE PIXEL COLORS
 54558                              <1> 	; ecx = pixel count per row
 54559                              <1> 	; eax = new color
 54560                              <1> 	; [maskcolor] = old color
 54561                              <1> 	; edi = start pixel address
 54562                              <1> 
 54563                              <1> pix_op_rpl_24_0:
 54564 0000E7B4 8B17                <1> 	mov	edx, [edi]
 54565 0000E7B6 81E2FFFFFF00        <1> 	and	edx, 0FFFFFFh
 54566 0000E7BC 3B15[4E100300]      <1> 	cmp	edx, [maskcolor]
 54567 0000E7C2 7406                <1> 	je	short pix_op_rpl_24_1
 54568 0000E7C4 83C703              <1> 	add	edi, 3
 54569 0000E7C7 E2EB                <1> 	loop	pix_op_rpl_24_0
 54570 0000E7C9 C3                  <1> 	retn
 54571                              <1> pix_op_rpl_24_1: 
 54572 0000E7CA AA                  <1> 	stosb
 54573 0000E7CB C1C808              <1> 	ror	eax, 8
 54574 0000E7CE 66AB                <1> 	stosw
 54575 0000E7D0 C1C008              <1> 	rol	eax, 8
 54576 0000E7D3 E2DF                <1> 	loop	pix_op_rpl_24_0
 54577 0000E7D5 C3                  <1> 	retn
 54578                              <1> 
 54579                              <1> pix_op_rpl_32:
 54580                              <1> 	; 32 bit true colors
 54581                              <1> 	; REPLACE PIXEL COLORS
 54582                              <1> 	; ecx = pixel count per row
 54583                              <1> 	; eax = new color
 54584                              <1> 	; [maskcolor] = old color
 54585                              <1> 	; edi = start pixel address
 54586                              <1> 
 54587 0000E7D6 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
 54588                              <1> pix_op_rpl_32_0:
 54589 0000E7DC 3B17                <1> 	cmp	edx, [edi]
 54590 0000E7DE 7504                <1> 	jne	short pix_op_rpl_32_2
 54591 0000E7E0 AB                  <1> 	stosd
 54592 0000E7E1 E2F9                <1> 	loop	pix_op_rpl_32_0
 54593 0000E7E3 C3                  <1> 	retn	
 54594                              <1> pix_op_rpl_32_2:
 54595 0000E7E4 83C704              <1> 	add	edi, 4
 54596 0000E7E7 E2F3                <1> 	loop	pix_op_rpl_32_0
 54597 0000E7E9 C3                  <1> 	retn
 54598                              <1> 
 54599                              <1> pix_op_chr:
 54600                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 54601                              <1> 	; 15/02/2021
 54602                              <1> 	; 05/02/2021
 54603                              <1> 	; WRITE CHARACTER (FONT)
 54604                              <1> 	; 05/01/2021 ([ufont])
 54605                              <1> 	; 01/01/2021
 54606                              <1> 	;     CL = char's color (8 bit, 256 colors)
 54607                              <1> 	;    ECX = char's color (16 bit and true colors)
 54608                              <1> 	;     DL = Character's ASCII code
 54609                              <1> 	;     DH bit 0 -> font height
 54610                              <1> 	;	  0 -> 8x16 character font
 54611                              <1> 	;	  1 -> 8x8 character font
 54612                              <1> 	;     DH bit 1 & 2 -> scale	
 54613                              <1> 	;	  0 = 1/1 (8 pixels per char row)
 54614                              <1> 	;	  1 = 2/1 (16 pixels per char row)
 54615                              <1> 	;	  2 = 3/1 (24 pixels per char row)
 54616                              <1> 	;	  3 = 4/1 (32 pixels per char row) 
 54617                              <1> 	;     DH bit 6 -> [ufont] option (1 = use [ufont])
 54618                              <1> 	;     If DH bit 7 = 1
 54619                              <1> 	;	 USER FONT (from user buffer)
 54620                              <1> 	;	    DL = 0 -> 8x8 (width: 1 byte per row)
 54621                              <1> 	;	    DL = 1 -> 8x16
 54622                              <1> 	;	    DL = 2 -> 16x16 (width: 2 bytes)
 54623                              <1> 	;	    DL = 3 -> 16x32
 54624                              <1> 	;	    DL = 4 -> 24x24 (width: 3 bytes)
 54625                              <1> 	;	    DL = 5 -> 24x48
 54626                              <1> 	;	    DL = 6 -> 32x32 (width: 4 bytes)
 54627                              <1> 	;	    DL = 7 -> 32x64
 54628                              <1> 	;	    DL > 7 -> invalid (unused)
 54629                              <1> 	;	 EDI = user's font buffer address
 54630                              <1> 	;	    (NOTE: byte order is as row0,row1,row2..)
 54631                              <1> 	;     ESI = start position (row, column) (*)
 54632                              <1> 	;	     (HW = row, SI = column)
 54633                              <1> 
 54634 0000E7EA 89F0                <1> 	mov	eax, esi ; start position
 54635 0000E7EC E856F2FFFF          <1> 	call	calc_pixel_offset
 54636 0000E7F1 3B05[42100300]      <1> 	cmp	eax, [v_siz]
 54637 0000E7F7 736D                <1> 	jnb	short pix_op_chr_err ; out of display page!
 54638 0000E7F9 E826F2FFFF          <1> 	call	pixels_to_byte_count
 54639                              <1> 	; eax = font start offset
 54640 0000E7FE 0305[3E100300]      <1> 	add	eax, [v_mem] ; LFB start address
 54641 0000E804 A3[46100300]        <1> 	mov	[v_str], eax ; font start address 
 54642                              <1> 
 54643 0000E809 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save char's color
 54644                              <1> 
 54645 0000E80F 8835[3C100300]      <1> 	mov	[v_ops], dh
 54646                              <1> 
 54647 0000E815 81E6FFFF0000        <1> 	and	esi, 0FFFFh
 54648 0000E81B 8935[56100300]      <1> 	mov	[buffer8], esi ; start column
 54649                              <1> 
 54650 0000E821 31DB                <1> 	xor	ebx, ebx ; 0
 54651 0000E823 31C0                <1> 	xor	eax, eax ; 15/02/2021
 54652                              <1> 
 54653 0000E825 F6C680              <1> 	test	dh, 80h
 54654 0000E828 7577                <1> 	jnz	short pix_op_chr_u ; user font
 54655                              <1> 
 54656 0000E82A 80E63F              <1> 	and	dh, 3Fh ; clear bit 6, [UFONT] option bit
 54657 0000E82D 7409                <1> 	jz	short pix_op_chr_0
 54658                              <1> 
 54659 0000E82F 80FE07              <1> 	cmp	dh, 7
 54660 0000E832 7732                <1> 	ja	short pix_op_chr_err
 54661                              <1> 			 ; invalid (undefined) option 
 54662 0000E834 88F4                <1> 	mov	ah, dh
 54663 0000E836 D0EC                <1> 	shr	ah, 1
 54664                              <1> 	; ah = 0 to 3, scale
 54665                              <1> 	;jmp	short pix_op_chr_font_pixels
 54666                              <1> 
 54667                              <1> pix_op_chr_font_pixels:
 54668                              <1> 	; 05/02/2021
 54669                              <1> 	; write scaled font to buffer
 54670                              <1> 
 54671                              <1> 	; DL = ASCII code of character
 54672                              <1> 	; AH = scale
 54673                              <1> 	; EDI = buffer address (kernel)
 54674                              <1> 
 54675                              <1> pix_op_chr_0:
 54676 0000E838 88D3                <1> 	mov	bl, dl ; 15/02/2021
 54677 0000E83A 31C9                <1> 	xor	ecx, ecx
 54678 0000E83C B610                <1> 	mov	dh, 16
 54679 0000E83E F605[3C100300]01    <1> 	test	byte [v_ops], 1 ; 8x8 font ?
 54680 0000E845 7428                <1> 	jz	short pix_op_chr_2 ; 8x16 font 
 54681 0000E847 B608                <1> 	mov	dh, 8
 54682 0000E849 C1E303              <1> 	shl	ebx, 3 ; * 8
 54683 0000E84C F605[3C100300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
 54684 0000E853 7412                <1> 	jz	short pix_op_chr_1  ; no
 54685                              <1> 	; test 8x8 user font is ready flag
 54686 0000E855 F605[32100300]01    <1> 	test	byte [ufont], 1
 54687 0000E85C 7409                <1> 	jz	short pix_op_chr_1 ; no
 54688 0000E85E 81C300500900        <1> 	add	ebx, VGAFONT8USER
 54689 0000E864 EB2C                <1> 	jmp	short pix_op_chr_fpos_0
 54690                              <1> pix_op_chr_err:
 54691 0000E866 C3                  <1> 	retn
 54692                              <1> pix_op_chr_1:
 54693 0000E867 81C3[104E0100]      <1> 	add	ebx, vgafont8 ; system font (8x8)
 54694 0000E86D EB23                <1> 	jmp	short pix_op_chr_fpos_0
 54695                              <1> pix_op_chr_2:
 54696 0000E86F C1E304              <1> 	shl	ebx, 4 ; * 16
 54697 0000E872 F605[3C100300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
 54698 0000E879 7411                <1> 	jz	short pix_op_chr_3  ; no
 54699                              <1> 	; test 8x16 user font is ready flag
 54700 0000E87B F605[32100300]02    <1> 	test	byte [ufont], 2
 54701 0000E882 7408                <1> 	jz	short pix_op_chr_3 ; no
 54702 0000E884 81C300400900        <1> 	add	ebx, VGAFONT16USER
 54703 0000E88A EB06                <1> 	jmp	short pix_op_chr_fpos_0
 54704                              <1> pix_op_chr_3:
 54705 0000E88C 81C3[10640100]      <1> 	add	ebx, vgafont16 ; system font (8x16)
 54706                              <1> pix_op_chr_fpos_0:
 54707 0000E892 20E4                <1> 	and	ah, ah
 54708 0000E894 754A                <1> 	jnz	short pix_op_chr_fpos_1 ; scale > 1 
 54709                              <1> 	; no scale (scale = 1)
 54710 0000E896 89DE                <1> 	mov	esi, ebx ; 15/02/2021
 54711 0000E898 88F1                <1> 	mov	cl, dh ; rows/height (16 or 8)	
 54712 0000E89A B608                <1> 	mov	dh, 8  ; columns/width
 54713 0000E89C E9CB000000          <1> 	jmp	pix_op_chr_f2p
 54714                              <1> pix_op_chr_u:
 54715                              <1> 	; write user defined font 
 54716 0000E8A1 80FE80              <1> 	cmp	dh, 80h
 54717 0000E8A4 75C0                <1> 	jne	short pix_op_chr_err
 54718 0000E8A6 80FA07              <1> 	cmp	dl, 7
 54719 0000E8A9 77BB                <1> 	ja	short pix_op_chr_err
 54720                              <1> 
 54721                              <1> 	; 16/02/2021
 54722 0000E8AB 89FE                <1> 	mov	esi, edi ; user's font buffer
 54723                              <1> 	
 54724                              <1> 	;xor	eax, eax
 54725                              <1> 	; eax = 0 ; 15/02/2021	
 54726 0000E8AD 88D4                <1> 	mov	ah, dl
 54727 0000E8AF D0EC                <1> 	shr	ah, 1
 54728 0000E8B1 FEC4                <1> 	inc	ah	
 54729                              <1> 	; ah =  1 to 4
 54730 0000E8B3 88E0                <1> 	mov	al, ah
 54731 0000E8B5 C0E003              <1> 	shl	al, 3 ; * 8
 54732                              <1> 	; al = 8,16,24,32
 54733 0000E8B8 88C3                <1> 	mov	bl, al
 54734 0000E8BA 88C7                <1> 	mov	bh, al
 54735 0000E8BC F6E4                <1> 	mul	ah
 54736                              <1> 	; ax = 8,32,72,128 bytes 
 54737 0000E8BE F6C201              <1> 	test	dl, 1
 54738 0000E8C1 7404                <1> 	jz	short pix_op_chr_u_0
 54739                              <1> 	;shl	ax, 1 ; *2
 54740                              <1> 	; 23/07/2022
 54741 0000E8C3 D1E0                <1> 	shl	eax, 1
 54742                              <1> 	; ax = 16,32,144,256 bytes
 54743 0000E8C5 D0E7                <1> 	shl	bh, 1
 54744                              <1> pix_op_chr_u_0:
 54745                              <1> 	; eax = byte count
 54746 0000E8C7 89C1                <1> 	mov	ecx, eax
 54747 0000E8C9 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 54748                              <1> 	; esi = user buffer
 54749 0000E8CE E8A4240000          <1> 	call	transfer_from_user_buffer
 54750 0000E8D3 7291                <1> 	jc	short pix_op_chr_err
 54751                              <1> 
 54752 0000E8D5 88F9                <1> 	mov	cl, bh ; rows/height
 54753 0000E8D7 88DE                <1> 	mov	dh, bl ; columns (width)
 54754 0000E8D9 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 54755 0000E8DB E98C000000          <1> 	jmp	pix_op_chr_f2p
 54756                              <1> 
 54757                              <1> pix_op_chr_fpos_1:
 54758                              <1> 	; 18/02/2021
 54759                              <1> 	; scale > 1
 54760 0000E8E0 88F5                <1> 	mov	ch, dh ; 16 or 8
 54761 0000E8E2 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 54762 0000E8E7 89FE                <1> 	mov	esi, edi
 54763 0000E8E9 FECC                <1> 	dec	ah
 54764 0000E8EB 7522                <1> 	jnz	short pix_op_chr_fpos_5 ; scale > 2
 54765                              <1> 	; scale = 2
 54766                              <1> pix_op_chr_fpos_2:	
 54767 0000E8ED B108                <1> 	mov	cl, 8
 54768 0000E8EF 8A13                <1> 	mov	dl, [ebx]
 54769                              <1> pix_op_chr_fpos_3:
 54770                              <1> 	;shl 	ax, 2
 54771                              <1> 	; 23/07/2022
 54772 0000E8F1 C1E002              <1> 	shl	eax, 2
 54773 0000E8F4 D0E2                <1> 	shl	dl, 1
 54774 0000E8F6 7302                <1> 	jnc	short pix_op_chr_fpos_4
 54775 0000E8F8 0C03                <1> 	or	al, 3
 54776                              <1> pix_op_chr_fpos_4:
 54777 0000E8FA FEC9                <1> 	dec	cl
 54778 0000E8FC 75F3                <1> 	jnz	short pix_op_chr_fpos_3
 54779 0000E8FE 66AB                <1> 	stosw
 54780                              <1> 	; 18/02/2021
 54781 0000E900 66AB                <1> 	stosw
 54782 0000E902 43                  <1> 	inc	ebx
 54783 0000E903 FECD                <1> 	dec	ch
 54784 0000E905 75E6                <1> 	jnz	short pix_op_chr_fpos_2
 54785                              <1> 	; scale = 2
 54786 0000E907 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 54787 0000E909 D0E1                <1> 	shl	cl, 1  ; 32 or 16 rows
 54788 0000E90B B610                <1> 	mov	dh, 16 ; columns (width)
 54789 0000E90D EB5D                <1> 	jmp	short pix_op_chr_f2p
 54790                              <1> pix_op_chr_fpos_5:
 54791 0000E90F FECC                <1> 	dec	ah
 54792 0000E911 7538                <1> 	jnz	short pix_op_chr_fpos_9 ; scale = 4
 54793                              <1> 	; scale = 3
 54794                              <1> pix_op_chr_fpos_6:	
 54795 0000E913 B108                <1> 	mov	cl, 8
 54796 0000E915 8A13                <1> 	mov	dl, [ebx]
 54797                              <1> pix_op_chr_fpos_7:
 54798 0000E917 C1E003              <1> 	shl 	eax, 3
 54799 0000E91A D0E2                <1> 	shl	dl, 1 ; 18/02/2021
 54800 0000E91C 7302                <1> 	jnc	short pix_op_chr_fpos_8
 54801 0000E91E 0C07                <1> 	or	al, 7
 54802                              <1> pix_op_chr_fpos_8:
 54803 0000E920 FEC9                <1> 	dec	cl
 54804 0000E922 75F3                <1> 	jnz	short pix_op_chr_fpos_7
 54805 0000E924 66AB                <1> 	stosw
 54806                              <1> 	; 18/02/2021
 54807 0000E926 C1C810              <1> 	ror	eax, 16
 54808 0000E929 AA                  <1> 	stosb
 54809 0000E92A C1C010              <1> 	rol	eax, 16
 54810 0000E92D 66AB                <1> 	stosw
 54811 0000E92F C1C810              <1> 	ror	eax, 16
 54812 0000E932 AA                  <1> 	stosb	
 54813 0000E933 C1C010              <1> 	rol	eax, 16
 54814 0000E936 66AB                <1> 	stosw
 54815 0000E938 C1E810              <1> 	shr	eax, 16 ; 27/02/2021
 54816 0000E93B AA                  <1> 	stosb
 54817 0000E93C 43                  <1> 	inc	ebx
 54818                              <1> 	; 18/02/2021
 54819 0000E93D FECD                <1> 	dec	ch
 54820 0000E93F 75D2                <1> 	jnz	short pix_op_chr_fpos_6
 54821                              <1> 	; scale = 3
 54822 0000E941 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 54823 0000E943 D0E1                <1> 	shl	cl, 1 
 54824 0000E945 00F1                <1> 	add	cl, dh ; 48 or 24 rows
 54825 0000E947 B618                <1> 	mov	dh, 24 ; columns (width)
 54826 0000E949 EB21                <1> 	jmp	short pix_op_chr_f2p
 54827                              <1> 
 54828                              <1> pix_op_chr_fpos_9:
 54829                              <1> 	; scale = 4
 54830 0000E94B B108                <1> 	mov	cl, 8
 54831 0000E94D 8A13                <1> 	mov	dl, [ebx]
 54832                              <1> pix_op_chr_fpos_10:
 54833                              <1> 	; 18/02/2021
 54834 0000E94F C1E004              <1> 	shl 	eax, 4
 54835 0000E952 D0E2                <1> 	shl	dl, 1 ; 18/02/2021
 54836 0000E954 7302                <1> 	jnc	short pix_op_chr_fpos_11
 54837 0000E956 0C0F                <1> 	or	al, 0Fh ; or al, 15
 54838                              <1> pix_op_chr_fpos_11:
 54839 0000E958 FEC9                <1> 	dec	cl
 54840 0000E95A 75F3                <1> 	jnz	short pix_op_chr_fpos_10
 54841 0000E95C AB                  <1> 	stosd
 54842                              <1> 	; 18/02/2021
 54843 0000E95D AB                  <1> 	stosd
 54844 0000E95E AB                  <1> 	stosd
 54845 0000E95F AB                  <1> 	stosd
 54846 0000E960 43                  <1> 	inc	ebx
 54847 0000E961 FECD                <1> 	dec	ch
 54848 0000E963 75E6                <1> 	jnz	short pix_op_chr_fpos_9
 54849                              <1> 	; scale = 4
 54850 0000E965 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
 54851 0000E967 C0E102              <1> 	shl	cl, 2 ; 64 or 32 rows
 54852 0000E96A B620                <1> 	mov	dh, 32 ; columns (width)
 54853                              <1> 	;jmp	short pix_op_chr_f2p
 54854                              <1>  	
 54855                              <1> pix_op_chr_f2p:
 54856                              <1> 	; write font pixels
 54857 0000E96C 8B3D[46100300]      <1> 	mov	edi, [v_str]
 54858                              <1> 	; 15/02/2021
 54859                              <1> pix_op_chr_f2p_next:
 54860 0000E972 80FE08              <1> 	cmp	dh, 8
 54861 0000E975 7706                <1> 	ja	short pix_op_chr_f2p_24
 54862                              <1> pix_op_chr_f2p_8:
 54863 0000E977 AC                  <1> 	lodsb
 54864 0000E978 C1E018              <1> 	shl	eax, 24 ; 15/02/2021
 54865 0000E97B EB16                <1> 	jmp	short pix_op_chr_f2p_0
 54866                              <1> pix_op_chr_f2p_24:
 54867 0000E97D 80FE18              <1> 	cmp	dh, 24
 54868 0000E980 7710                <1> 	ja	short pix_op_chr_f2p_32
 54869 0000E982 7207                <1> 	jb	short pix_op_chr_f2p_16	
 54870                              <1> 	; 27/02/2021
 54871                              <1> 	;mov	eax, [esi]
 54872 0000E984 AD                  <1> 	lodsd
 54873 0000E985 C1E008              <1> 	shl	eax, 8
 54874                              <1> 	;add	esi, 3
 54875 0000E988 4E                  <1> 	dec	esi
 54876 0000E989 EB08                <1> 	jmp	short pix_op_chr_f2p_0
 54877                              <1> pix_op_chr_f2p_16:
 54878 0000E98B 66AD                <1> 	lodsw
 54879 0000E98D C1E010              <1> 	shl	eax, 16 ; 15/02/2021
 54880 0000E990 EB01                <1> 	jmp	short pix_op_chr_f2p_0
 54881                              <1> pix_op_chr_f2p_32:
 54882 0000E992 AD                  <1> 	lodsd
 54883                              <1> pix_op_chr_f2p_0:
 54884                              <1> 	; EAX = font row (8,16,24,32 pixels)
 54885                              <1> 	;	(bits are shifted to left)
 54886                              <1> 	; CL = rows
 54887                              <1> 	; DH = bits per row (8,16,24,32)
 54888 0000E993 8B1D[56100300]      <1> 	mov	ebx, [buffer8] ; start column
 54889 0000E999 57                  <1> 	push	edi ; *
 54890 0000E99A 52                  <1> 	push	edx ; **
 54891                              <1> pix_op_chr_f2p_1:
 54892 0000E99B E82E000000          <1> 	call	pix_op_chr_w_pixel
 54893                              <1> pix_op_chr_f2p_2:
 54894 0000E9A0 663B1D[3A100300]    <1> 	cmp	bx, [v_width] ; current column
 54895 0000E9A7 7304                <1> 	jnb	short pix_op_chr_f2p_3
 54896 0000E9A9 FECE                <1> 	dec	dh
 54897 0000E9AB 75EE                <1> 	jnz	short pix_op_chr_f2p_1 ; next bit
 54898                              <1> pix_op_chr_f2p_3:
 54899                              <1> 	;mov	ebx, [buffer8]
 54900 0000E9AD 5A                  <1> 	pop	edx ; **
 54901 0000E9AE 58                  <1> 	pop	eax ; *
 54902 0000E9AF 3B3D[4A100300]      <1> 	cmp	edi, [v_end]
 54903 0000E9B5 7316                <1> 	jnb	short pix_op_chr_f2p_4
 54904 0000E9B7 FEC9                <1> 	dec	cl
 54905 0000E9B9 7412                <1> 	jz	short pix_op_chr_f2p_4
 54906                              <1> 	; 27/02/2021
 54907 0000E9BB 89C7                <1> 	mov	edi, eax
 54908 0000E9BD 0FB705[3A100300]    <1> 	movzx	eax, word [v_width]
 54909 0000E9C4 E85BF0FFFF          <1> 	call	pixels_to_byte_count
 54910 0000E9C9 01C7                <1> 	add	edi, eax ; next position
 54911 0000E9CB EBA5                <1> 	jmp	short pix_op_chr_f2p_next
 54912                              <1> pix_op_chr_f2p_4:
 54913 0000E9CD C3                  <1> 	retn
 54914                              <1> 
 54915                              <1> pix_op_chr_w_pixel:
 54916                              <1> 	; 15/02/2021
 54917 0000E9CE 89C5                <1> 	mov	ebp, eax
 54918 0000E9D0 A1[4E100300]        <1> 	mov	eax, [maskcolor]
 54919 0000E9D5 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 54920 0000E9DC 7711                <1> 	ja	short pix_op_chr_wp_2
 54921                              <1> 	; 256 colors (1 byte per pixel)
 54922 0000E9DE D1E5                <1> 	shl	ebp, 1
 54923 0000E9E0 7302                <1> 	jnc	short pix_op_chr_wp_0
 54924 0000E9E2 8807                <1> 	mov	[edi], al
 54925                              <1> pix_op_chr_wp_0:
 54926 0000E9E4 47                  <1> 	inc	edi
 54927 0000E9E5 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 54928                              <1> pix_op_chr_wp_1:
 54929 0000E9EB 43                  <1> 	inc	ebx
 54930 0000E9EC 89E8                <1> 	mov	eax, ebp
 54931 0000E9EE C3                  <1> 	retn
 54932                              <1> pix_op_chr_wp_2:
 54933 0000E9EF 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 54934 0000E9F6 772E                <1> 	ja	short pix_op_chr_wp_6 ; 32bpp
 54935 0000E9F8 721C                <1> 	jb	short pix_op_chr_wp_4 ; 16bpp
 54936                              <1> 	; 24 bit true colors
 54937                              <1> 	; * 3
 54938 0000E9FA D1E5                <1> 	shl	ebp, 1
 54939 0000E9FC 7309                <1> 	jnc	short pix_op_chr_wp_3
 54940 0000E9FE 668907              <1> 	mov	[edi], ax
 54941 0000EA01 C1E810              <1> 	shr	eax, 16
 54942 0000EA04 884702              <1> 	mov	[edi+2], al
 54943                              <1> pix_op_chr_wp_3:
 54944 0000EA07 B803000000          <1> 	mov	eax, 3 ; 27/02/2021 
 54945 0000EA0C 01C7                <1> 	add	edi, eax  ; add edi, 3
 54946 0000EA0E 0105[1C010300]      <1> 	add	[u.r0], eax ; +3
 54947                              <1> 	
 54948 0000EA14 EBD5                <1> 	jmp	short pix_op_chr_wp_1
 54949                              <1> 
 54950                              <1> pix_op_chr_wp_4:
 54951                              <1> 	; 16 bit (65536) colors
 54952 0000EA16 D1E5                <1> 	shl	ebp, 1
 54953 0000EA18 7303                <1> 	jnc	short pix_op_chr_wp_5
 54954 0000EA1A 668907              <1> 	mov	[edi], ax
 54955                              <1> pix_op_chr_wp_5:
 54956 0000EA1D 47                  <1> 	inc	edi
 54957 0000EA1E FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1 
 54958 0000EA24 EBBE                <1> 	jmp	short pix_op_chr_wp_0
 54959                              <1> 
 54960                              <1> pix_op_chr_wp_6:
 54961                              <1> 	; 32 bit true colors
 54962 0000EA26 D1E5                <1> 	shl	ebp, 1
 54963 0000EA28 7302                <1> 	jnc	short pix_op_chr_wp_7
 54964 0000EA2A 8907                <1> 	mov	[edi], eax
 54965                              <1> pix_op_chr_wp_7:
 54966 0000EA2C 31C0                <1> 	xor	eax, eax
 54967 0000EA2E B004                <1> 	mov	al, 4
 54968 0000EA30 01C7                <1> 	add	edi, eax ; add edi, 4
 54969 0000EA32 0105[1C010300]      <1> 	add	[u.r0], eax ; +4
 54970 0000EA38 EBB1                <1> 	jmp	short pix_op_chr_wp_1
 54971                              <1> 
 54972                              <1> m_pix_op_cpy:
 54973                              <1> 	; 26/02/2021
 54974                              <1> 	; 06/02/2021
 54975                              <1> 	; MASKED COPY PIXELS (full screen)
 54976                              <1> 	;
 54977                              <1> 	; jump from pix_op_cpy
 54978                              <1> 	;
 54979                              <1> 	; INPUT:
 54980                              <1> 	;   ecx = transfer count (bytes)
 54981                              <1> 	;   edi = [v_mem] = start address of LFB 
 54982                              <1> 	;   esi = user's buffer address (virtual)
 54983                              <1> 	;
 54984                              <1> 	; OUTPUT:
 54985                              <1> 	;   [u.r0] will be > 0 if succesful
 54986                              <1> 
 54987                              <1> 	; Full screen masked copy
 54988                              <1> 
 54989                              <1> 	; Modified regs: eax, ebx, edx, esi, edi, ecx
 54990                              <1> 
 54991                              <1> m_pix_op_cpy_0:
 54992                              <1> 	;push	ebx ; *** ; 26/02/2021
 54993 0000EA3A 57                  <1> 	push	edi ; **
 54994 0000EA3B 51                  <1> 	push	ecx ; *
 54995 0000EA3C 81F9F8070000        <1> 	cmp	ecx, 2040 ; (3*680) ; 26/02/2021
 54996 0000EA42 7605                <1> 	jna	short m_pix_op_cpy_1
 54997 0000EA44 B9F8070000          <1> 	mov	ecx, 2040
 54998                              <1> m_pix_op_cpy_1:
 54999 0000EA49 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; temporary buff
 55000 0000EA4E E824230000          <1> 	call	transfer_from_user_buffer
 55001 0000EA53 726C                <1> 	jc	short m_pix_op_cpy_3
 55002 0000EA55 01CE                <1> 	add	esi, ecx
 55003 0000EA57 89F5                <1> 	mov	ebp, esi  ; save user's buffer address
 55004 0000EA59 89FE                <1> 	mov	esi, edi
 55005 0000EA5B 89CB                <1> 	mov	ebx, ecx
 55006 0000EA5D 59                  <1> 	pop	ecx ; *
 55007 0000EA5E 29D9                <1> 	sub	ecx, ebx
 55008 0000EA60 5F                  <1> 	pop	edi ; **
 55009 0000EA61 31D2                <1> 	xor	edx, edx ; 26/02/2021
 55010 0000EA63 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8
 55011 0000EA6A 7435                <1> 	je	short m_pix_op_cpy_1_8
 55012 0000EA6C 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24
 55013 0000EA73 776D                <1> 	ja	short m_pix_op_cpy_1_32
 55014 0000EA75 724D                <1> 	jb	short m_pix_op_cpy_1_16
 55015                              <1> m_pix_op_cpy_1_24:
 55016                              <1> 	; 24 bit masked copy
 55017                              <1> 	;mov	edx, 3
 55018 0000EA77 B203                <1> 	mov	dl, 3 ; 26/02/2021
 55019                              <1> m_pix_op_cpy_1_24_0:
 55020 0000EA79 66AD                <1> 	lodsw
 55021 0000EA7B C1E010              <1> 	shl	eax, 16
 55022 0000EA7E AC                  <1> 	lodsb
 55023 0000EA7F C1C010              <1> 	rol	eax, 16
 55024 0000EA82 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55025 0000EA88 740F                <1> 	je	short m_pix_op_cpy_1_24_1 ; exclude
 55026 0000EA8A 668907              <1> 	mov	[edi], ax
 55027 0000EA8D C1E810              <1> 	shr	eax, 16
 55028 0000EA90 884702              <1> 	mov	[edi+2], al
 55029 0000EA93 0115[1C010300]      <1> 	add	[u.r0], edx ; +3
 55030                              <1> m_pix_op_cpy_1_24_1:
 55031 0000EA99 01D7                <1> 	add	edi, edx ; +3
 55032 0000EA9B 29D3                <1> 	sub	ebx, edx ; sub ebx, 3
 55033 0000EA9D 77DA                <1> 	ja	short m_pix_op_cpy_1_24_0
 55034 0000EA9F EB15                <1>  	jmp	short m_pix_op_cpy_2
 55035                              <1> 
 55036                              <1> m_pix_op_cpy_1_8:
 55037                              <1> 	; 8 bit masked copy
 55038 0000EAA1 AC                  <1> 	lodsb
 55039 0000EAA2 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55040 0000EAA8 7408                <1> 	je	short m_pix_op_cpy_1_8_1 ; exclude
 55041 0000EAAA 8807                <1> 	mov	[edi], al
 55042 0000EAAC FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55043                              <1> m_pix_op_cpy_1_8_1:
 55044 0000EAB2 47                  <1> 	inc	edi ; +1
 55045 0000EAB3 4B                  <1> 	dec	ebx 	
 55046 0000EAB4 75EB                <1> 	jnz	short m_pix_op_cpy_1_8
 55047                              <1> m_pix_op_cpy_2:
 55048 0000EAB6 89EE                <1> 	mov	esi, ebp ; restore user's buffer addr
 55049 0000EAB8 09C9                <1> 	or	ecx, ecx
 55050                              <1> 	; 26/02/2021
 55051 0000EABA 7407                <1> 	jz	short m_pix_of_cpy_4
 55052 0000EABC E979FFFFFF          <1> 	jmp	m_pix_op_cpy_0
 55053                              <1> m_pix_op_cpy_3:
 55054 0000EAC1 59                  <1> 	pop	ecx ; *
 55055 0000EAC2 5F                  <1> 	pop	edi ; **
 55056                              <1> m_pix_of_cpy_4:
 55057                              <1> 	;pop	ebx ; *** ; 26/02/2021 
 55058 0000EAC3 C3                  <1> 	retn
 55059                              <1> 
 55060                              <1> m_pix_op_cpy_1_16:
 55061                              <1> 	; 16 bit masked copy
 55062                              <1> 	;mov	edx, 2
 55063 0000EAC4 B202                <1> 	mov	dl, 2 ; 26/02/2021
 55064                              <1> m_pix_op_cpy_1_16_0:
 55065 0000EAC6 66AD                <1> 	lodsw
 55066 0000EAC8 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55067 0000EACF 7409                <1> 	je	short m_pix_op_cpy_1_16_1 ; exclude
 55068 0000EAD1 668907              <1> 	mov	[edi], ax
 55069 0000EAD4 0115[1C010300]      <1> 	add	[u.r0], edx ; +2
 55070                              <1> m_pix_op_cpy_1_16_1:
 55071 0000EADA 01D7                <1> 	add	edi, edx ; +2
 55072 0000EADC 29D3                <1> 	sub	ebx, edx ; sub ebx, 2
 55073 0000EADE 77E6                <1> 	ja	short m_pix_op_cpy_1_16_0
 55074 0000EAE0 EBD4                <1>  	jmp	short m_pix_op_cpy_2
 55075                              <1> 
 55076                              <1> m_pix_op_cpy_1_32:
 55077                              <1> 	; 32 bit masked copy
 55078                              <1> 	;mov	edx, 4
 55079 0000EAE2 B204                <1> 	mov	dl, 4 ; 26/02/2021
 55080                              <1> m_pix_op_cpy_1_32_0:
 55081 0000EAE4 AD                  <1> 	lodsd
 55082 0000EAE5 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55083 0000EAEB 7408                <1> 	je	short m_pix_op_cpy_1_32_1 ; exclude
 55084 0000EAED 8907                <1> 	mov	[edi], eax
 55085 0000EAEF 0115[1C010300]      <1> 	add	[u.r0], edx ; +4
 55086                              <1> m_pix_op_cpy_1_32_1:
 55087 0000EAF5 01D7                <1> 	add	edi, edx ; +4
 55088 0000EAF7 29D3                <1> 	sub	ebx, edx ; sub ebx, 4
 55089 0000EAF9 77E9                <1> 	ja	short m_pix_op_cpy_1_32_0
 55090 0000EAFB EBB9                <1>  	jmp	short m_pix_op_cpy_2
 55091                              <1> 	
 55092                              <1> m_pix_op_cpy_w:
 55093                              <1> 	; 26/02/2021
 55094                              <1> 	; 06/02/2021
 55095                              <1> 	; MASKED COPY PIXELS (window)
 55096                              <1> 	;
 55097                              <1> 	; jump from pix_op_cpy_w
 55098                              <1> 	;
 55099                              <1> 	; INPUT:
 55100                              <1> 	;   ecx = bytes per row (to be applied)
 55101                              <1> 	;   edx = screen width in bytes
 55102                              <1> 	;   ebx = row count
 55103                              <1> 	;   esi = user's buffer address
 55104                              <1> 	;   [v_str] = window start address
 55105                              <1> 	;
 55106                              <1> 	; OUTPUT:
 55107                              <1> 	;   [u.r0] will be > 0 if succesful
 55108                              <1> 
 55109                              <1> 	; Window masked copy
 55110                              <1> 
 55111                              <1> m_pix_op_cpy_w_0:
 55112 0000EAFD 8B3D[46100300]      <1> 	mov	edi, [v_str]
 55113                              <1> m_pix_op_cpy_w_1:
 55114 0000EB03 57                  <1> 	push	edi
 55115 0000EB04 56                  <1> 	push	esi
 55116 0000EB05 53                  <1> 	push	ebx
 55117 0000EB06 52                  <1> 	push	edx
 55118 0000EB07 51                  <1> 	push	ecx
 55119 0000EB08 E82DFFFFFF          <1> 	call	m_pix_op_cpy ; 26/02/2021
 55120 0000EB0D 59                  <1> 	pop	ecx
 55121 0000EB0E 5A                  <1> 	pop	edx
 55122 0000EB0F 5B                  <1> 	pop	ebx
 55123 0000EB10 5E                  <1> 	pop	esi
 55124 0000EB11 5F                  <1> 	pop	edi
 55125 0000EB12 7209                <1> 	jc	short m_pix_op_cpy_w_2
 55126 0000EB14 4B                  <1> 	dec	ebx
 55127 0000EB15 7406                <1> 	jz	short m_pix_op_cpy_w_2 ; ok.
 55128                              <1> 	; next row
 55129 0000EB17 01CE                <1> 	add	esi, ecx ; next row in user's buffer
 55130 0000EB19 01D7                <1> 	add	edi, edx ; next row of window (system)
 55131 0000EB1B EBE6                <1> 	jmp	short m_pix_op_cpy_w_1
 55132                              <1> m_pix_op_cpy_w_2:
 55133 0000EB1D C3                  <1> 	retn
 55134                              <1> 
 55135                              <1> m_pix_op_new:
 55136                              <1> 	; 06/02/2021
 55137                              <1> 	; CHANGE COLOR (MASKED, full screen)
 55138                              <1> 	;
 55139                              <1> 	; jump from pix_op_new
 55140                              <1> 	;
 55141                              <1> 	; INPUT:
 55142                              <1> 	;   eax = color (AL, AX, EAX)
 55143                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55144                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55145                              <1> 	;
 55146                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55147                              <1> 	;
 55148                              <1> 	; OUTPUT:
 55149                              <1> 	; 	[u.r0] will be > 0 if succesful
 55150                              <1> 	
 55151                              <1> 	; Full screen
 55152                              <1> m_pix_op_new_0:
 55153 0000EB1E 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55154 0000EB25 7717                <1> 	ja	short m_pix_op_new_1
 55155                              <1> 	; 256 colors (8bpp)
 55156                              <1> 	;jmp	short m_pix_op_new_8
 55157                              <1> m_pix_op_new_8:
 55158                              <1> 	; 8 bit colors (256 colors)
 55159 0000EB27 88C2                <1> 	mov	dl, al ; new color
 55160                              <1> m_pix_op_new_8_0:
 55161 0000EB29 AC                  <1> 	lodsb 
 55162 0000EB2A 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55163 0000EB30 7408                <1> 	je	short m_pix_op_new_8_1 ; exclude
 55164 0000EB32 8817                <1> 	mov	[edi], dl
 55165 0000EB34 FF05[1C010300]      <1> 	inc	dword [u.r0]
 55166                              <1> m_pix_op_new_8_1:
 55167 0000EB3A 47                  <1> 	inc	edi
 55168 0000EB3B E2EC                <1> 	loop	m_pix_op_new_8_0
 55169 0000EB3D C3                  <1> 	retn
 55170                              <1> m_pix_op_new_1:
 55171 0000EB3E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55172 0000EB45 774B                <1> 	ja	short m_pix_op_new_3 ; 32bpp	
 55173 0000EB47 722C                <1> 	jb	short m_pix_op_new_2 ; 16bpp
 55174                              <1> 	; 24 bit true colors
 55175                              <1> 	;jmp	short m_pix_op_new_24
 55176                              <1> m_pix_op_new_24:
 55177                              <1> 	; 24 bit true colors
 55178 0000EB49 89C2                <1> 	mov	edx, eax ; new color
 55179                              <1> m_pix_op_new_24_0:
 55180 0000EB4B 66AD                <1> 	lodsw
 55181 0000EB4D C1E010              <1> 	shl	eax, 16
 55182 0000EB50 AC                  <1> 	lodsb
 55183 0000EB51 C1C010              <1> 	rol	eax, 16	
 55184 0000EB54 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55185 0000EB5A 7413                <1> 	je	short m_pix_op_new_24_1 ; exclude
 55186 0000EB5C 668917              <1> 	mov	[edi], dx
 55187 0000EB5F C1CA10              <1> 	ror	edx, 16
 55188 0000EB62 885702              <1> 	mov	[edi+2], dl
 55189 0000EB65 C1C210              <1> 	rol	edx, 16
 55190 0000EB68 8305[1C010300]03    <1> 	add	dword [u.r0], 3
 55191                              <1> m_pix_op_new_24_1:
 55192 0000EB6F 83C703              <1> 	add	edi, 3
 55193 0000EB72 E2D7                <1> 	loop	m_pix_op_new_24_0
 55194 0000EB74 C3                  <1> 	retn
 55195                              <1> 	; 65536 colors (16bpp)
 55196                              <1> m_pix_op_new_2:
 55197                              <1> 	;jmp	short m_pix_op_new_16
 55198                              <1> m_pix_op_new_16:
 55199                              <1> 	; 16 bit colors (65536 colors)
 55200 0000EB75 89C2                <1> 	mov	edx, eax ; new color
 55201                              <1> m_pix_op_new_16_0:
 55202 0000EB77 66AD                <1> 	lodsw
 55203 0000EB79 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55204 0000EB80 740A                <1> 	je	short m_pix_op_new_16_1 ; exclude
 55205 0000EB82 668917              <1> 	mov	[edi], dx
 55206 0000EB85 8305[1C010300]02    <1> 	add	dword [u.r0], 2
 55207                              <1> m_pix_op_new_16_1:
 55208 0000EB8C 83C702              <1> 	add	edi, 2
 55209 0000EB8F E2E6                <1> 	loop	m_pix_op_new_16_0
 55210 0000EB91 C3                  <1> 	retn
 55211                              <1> m_pix_op_new_3:
 55212                              <1> 	; 32 bit true colors
 55213                              <1> 	;jmp	short m_pix_op_new_32
 55214                              <1> m_pix_op_new_32:
 55215                              <1> 	; 32 bit true colors
 55216 0000EB92 89C2                <1> 	mov	edx, eax ; new color
 55217                              <1> m_pix_op_new_32_0:
 55218 0000EB94 AD                  <1> 	lodsd 
 55219 0000EB95 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55220 0000EB9B 7409                <1> 	je	short m_pix_op_new_32_1 ; exclude
 55221 0000EB9D 8917                <1> 	mov	[edi], edx
 55222 0000EB9F 8305[1C010300]04    <1> 	add	dword [u.r0], 4
 55223                              <1> m_pix_op_new_32_1:
 55224 0000EBA6 83C704              <1> 	add	edi, 4
 55225 0000EBA9 E2E9                <1> 	loop	m_pix_op_new_32_0
 55226 0000EBAB C3                  <1> 	retn
 55227                              <1> 
 55228                              <1> m_pix_op_new_w:
 55229                              <1> 	; 06/02/2021
 55230                              <1> 	; CHANGE COLOR (MASKED, window)
 55231                              <1> 	;
 55232                              <1> 	; jump from pix_op_new_w
 55233                              <1> 	;
 55234                              <1> 	; INPUT:
 55235                              <1> 	;   ecx = bytes per row (to be applied)
 55236                              <1> 	;   edx = screen width in bytes
 55237                              <1> 	;   ebx = row count
 55238                              <1> 	;   eax = color
 55239                              <1> 	;
 55240                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55241                              <1> 	;
 55242                              <1> 	; OUTPUT:
 55243                              <1> 	; 	[u.r0] will be > 0 if succesful
 55244                              <1> 
 55245                              <1> 	; Window
 55246                              <1> 	;mov	edi, [v_str] ; LFB start address
 55247                              <1> 	;mov	esi, edi 
 55248                              <1> 
 55249 0000EBAC 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55250 0000EBB3 7707                <1> 	ja	short m_pix_op_new_w_1
 55251                              <1> 
 55252                              <1> 	; 256 colors (8bpp)
 55253 0000EBB5 BD[27EB0000]        <1> 	mov	ebp, m_pix_op_new_8
 55254 0000EBBA EB1E                <1> 	jmp	short m_pix_op_new_w_x
 55255                              <1> 			
 55256                              <1> m_pix_op_new_w_1:
 55257 0000EBBC 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55258 0000EBC3 7710                <1> 	ja	short m_pix_op_new_w_3 ; 32bpp
 55259 0000EBC5 7207                <1> 	jb	short m_pix_op_new_w_2 ; 16bpp
 55260                              <1> 
 55261                              <1> 	; 24 bit true colors
 55262 0000EBC7 BD[49EB0000]        <1> 	mov	ebp, m_pix_op_new_24
 55263 0000EBCC EB0C                <1> 	jmp	short m_pix_op_new_w_x
 55264                              <1> 
 55265                              <1> 	; 65536 colors (16bpp)
 55266                              <1> m_pix_op_new_w_2:
 55267 0000EBCE BD[75EB0000]        <1> 	mov	ebp, m_pix_op_new_16
 55268 0000EBD3 EB05                <1> 	jmp	short m_pix_op_new_w_x
 55269                              <1> 
 55270                              <1> 	; 32 bit true colors
 55271                              <1> m_pix_op_new_w_3:
 55272 0000EBD5 BD[92EB0000]        <1> 	mov	ebp, m_pix_op_new_32
 55273                              <1> 	;jmp	short m_pix_op_new_w_x
 55274                              <1> 
 55275                              <1> m_pix_op_new_w_x:
 55276                              <1> m_pix_op_add_w_x:
 55277                              <1> m_pix_op_sub_w_x:
 55278                              <1> m_pix_op_mix_w_x:
 55279                              <1> m_pix_op_and_w_x:
 55280                              <1> m_pix_op_orc_w_x:
 55281                              <1> m_pix_op_xor_w_x:
 55282                              <1> m_pix_op_not_w_x:
 55283                              <1> m_pix_op_neg_w_x:
 55284                              <1> m_pix_op_inc_w_x:
 55285                              <1> m_pix_op_dec_w_x:
 55286                              <1> 	; 27/02/2021
 55287                              <1> 	; 26/02/2021
 55288                              <1> 	; 06/02/2021
 55289                              <1> 	; ecx = bytes per row (to be applied)
 55290                              <1> 	; edx = windows (screen) width in bytes
 55291                              <1> 	; ebx = row count
 55292                              <1> 	; eax = color
 55293                              <1> 	; ebp = pixel operation subroutine address
 55294                              <1> 	; edi = esi = window start address
 55295                              <1> 
 55296 0000EBDA 8B3D[46100300]      <1> 	mov	edi, [v_str] ; LFB start address
 55297 0000EBE0 89FE                <1> 	mov	esi, edi
 55298                              <1> m_pix_op_w_x_next:
 55299 0000EBE2 52                  <1> 	push	edx
 55300 0000EBE3 51                  <1> 	push	ecx
 55301 0000EBE4 56                  <1> 	push	esi
 55302 0000EBE5 57                  <1> 	push	edi
 55303 0000EBE6 50                  <1> 	push	eax ; 26/02/2021
 55304 0000EBE7 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021  
 55305 0000EBED FFD5                <1> 	call	ebp ; call masked pixel-row operation
 55306 0000EBEF 58                  <1> 	pop	eax ; 26/02/2021
 55307 0000EBF0 5F                  <1> 	pop	edi
 55308 0000EBF1 5E                  <1> 	pop	esi
 55309 0000EBF2 59                  <1> 	pop	ecx
 55310 0000EBF3 5A                  <1> 	pop	edx
 55311 0000EBF4 01D6                <1> 	add	esi, edx ; next row
 55312 0000EBF6 01D7                <1> 	add	edi, edx ; next row
 55313 0000EBF8 4B                  <1> 	dec	ebx
 55314 0000EBF9 75E7                <1> 	jnz	short m_pix_op_w_x_next
 55315 0000EBFB C3                  <1> 	retn
 55316                              <1> 
 55317                              <1> m_pix_op_add:
 55318                              <1> 	; 06/02/2021
 55319                              <1> 	; ADD COLOR (MASKED, full screen)
 55320                              <1> 	;
 55321                              <1> 	; jump from pix_op_add
 55322                              <1> 	;
 55323                              <1> 	; INPUT:
 55324                              <1> 	;   eax = color (AL, AX, EAX)
 55325                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55326                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55327                              <1> 	;
 55328                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55329                              <1> 	;
 55330                              <1> 	; OUTPUT:
 55331                              <1> 	; 	[u.r0] will be > 0 if succesful
 55332                              <1> 	
 55333                              <1> 	; Full screen
 55334                              <1> m_pix_op_add_0:
 55335 0000EBFC 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55336 0000EC03 771C                <1> 	ja	short m_pix_op_add_1
 55337                              <1> 	; 256 colors (8bpp)
 55338                              <1> 	;jmp	short m_pix_op_add_8
 55339                              <1> m_pix_op_add_8:
 55340                              <1> 	; 8 bit colors (256 colors)
 55341 0000EC05 88C2                <1> 	mov	dl, al ; new color
 55342                              <1> m_pix_op_add_8_0:
 55343 0000EC07 AC                  <1> 	lodsb 
 55344 0000EC08 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55345 0000EC0E 740D                <1> 	je	short m_pix_op_add_8_1 ; exclude
 55346 0000EC10 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55347 0000EC16 0017                <1> 	add	[edi], dl
 55348 0000EC18 7303                <1> 	jnc	short m_pix_op_add_8_1
 55349 0000EC1A C607FF              <1> 	mov	byte [edi], 0FFh 
 55350                              <1> m_pix_op_add_8_1:
 55351 0000EC1D 47                  <1> 	inc	edi
 55352 0000EC1E E2E7                <1> 	loop	m_pix_op_add_8_0
 55353 0000EC20 C3                  <1> 	retn
 55354                              <1> m_pix_op_add_1:
 55355 0000EC21 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55356 0000EC28 775E                <1> 	ja	short m_pix_op_add_3 ; 32bpp	
 55357 0000EC2A 7238                <1> 	jb	short m_pix_op_add_2 ; 16bpp
 55358                              <1> 	; 24 bit true colors
 55359                              <1> 	;jmp	short m_pix_op_add_24
 55360                              <1> m_pix_op_add_24:
 55361                              <1> 	; 24 bit true colors
 55362 0000EC2C 89C2                <1> 	mov	edx, eax ; new color
 55363 0000EC2E 81CA000000FF        <1> 	or	edx, 0FF000000h
 55364                              <1> m_pix_op_add_24_0:
 55365 0000EC34 66AD                <1> 	lodsw
 55366 0000EC36 C1E010              <1> 	shl	eax, 16
 55367 0000EC39 AC                  <1> 	lodsb
 55368 0000EC3A C1C010              <1> 	rol	eax, 16	
 55369 0000EC3D 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55370 0000EC43 7419                <1> 	je	short m_pix_op_add_24_2 ; exclude
 55371 0000EC45 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 55372 0000EC4C 01D0                <1> 	add	eax, edx
 55373 0000EC4E 7305                <1> 	jnc	short m_pix_op_add_24_1
 55374 0000EC50 B8FFFFFF00          <1> 	mov	eax, 0FFFFFFh
 55375                              <1> m_pix_op_add_24_1:	
 55376 0000EC55 668907              <1> 	mov	[edi], ax
 55377 0000EC58 C1E810              <1> 	shr	eax, 16
 55378 0000EC5B 884702              <1> 	mov	[edi+2], al
 55379                              <1> m_pix_op_add_24_2:
 55380 0000EC5E 83C703              <1> 	add	edi, 3 ; +3
 55381 0000EC61 E2D1                <1> 	loop	m_pix_op_add_24_0
 55382 0000EC63 C3                  <1> 	retn
 55383                              <1> 	; 65536 colors (16bpp)
 55384                              <1> m_pix_op_add_2:
 55385                              <1> 	;jmp	short m_pix_op_add_16
 55386                              <1> m_pix_op_add_16:
 55387                              <1> 	; 16 bit colors (65536 colors)
 55388 0000EC64 89C2                <1> 	mov	edx, eax ; new color
 55389                              <1> m_pix_op_add_16_0:
 55390 0000EC66 66AD                <1> 	lodsw
 55391 0000EC68 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55392 0000EC6F 7411                <1> 	je	short m_pix_op_add_16_1 ; exclude
 55393 0000EC71 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 55394 0000EC78 660117              <1> 	add	[edi], dx
 55395 0000EC7B 7305                <1> 	jnc	short m_pix_op_add_16_1
 55396 0000EC7D 66C707FFFF          <1> 	mov	word [edi], 0FFFFh
 55397                              <1> m_pix_op_add_16_1:
 55398 0000EC82 83C702              <1> 	add	edi, 2 ; +2
 55399 0000EC85 E2DF                <1> 	loop	m_pix_op_add_16_0
 55400 0000EC87 C3                  <1> 	retn
 55401                              <1> m_pix_op_add_3:
 55402                              <1> 	; 32 bit true colors
 55403                              <1> 	;jmp	short m_pix_op_add_32
 55404                              <1> m_pix_op_add_32:
 55405                              <1> 	; 32 bit true colors
 55406 0000EC88 89C2                <1> 	mov	edx, eax ; new color
 55407                              <1> m_pix_op_add_32_0:
 55408 0000EC8A AD                  <1> 	lodsd 
 55409 0000EC8B 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55410 0000EC91 7411                <1> 	je	short m_pix_op_add_32_1 ; exclude
 55411 0000EC93 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 55412 0000EC9A 0117                <1> 	add	[edi], edx
 55413 0000EC9C 7306                <1> 	jnc	short m_pix_op_add_32_1
 55414 0000EC9E C707FFFFFFFF        <1> 	mov	dword [edi], 0FFFFFFFFh
 55415                              <1> m_pix_op_add_32_1:
 55416 0000ECA4 83C704              <1> 	add	edi, 4 ; +4
 55417 0000ECA7 E2E1                <1> 	loop	m_pix_op_add_32_0
 55418 0000ECA9 C3                  <1> 	retn
 55419                              <1> 
 55420                              <1> m_pix_op_add_w:
 55421                              <1> 	; 06/02/2021
 55422                              <1> 	; ADD COLOR (MASKED, window)
 55423                              <1> 	;
 55424                              <1> 	; jump from pix_op_add_w
 55425                              <1> 	;
 55426                              <1> 	; INPUT:
 55427                              <1> 	;   ecx = bytes per row (to be applied)
 55428                              <1> 	;   edx = screen width in bytes
 55429                              <1> 	;   ebx = row count
 55430                              <1> 	;   eax = color
 55431                              <1> 	;
 55432                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55433                              <1> 	;
 55434                              <1> 	; OUTPUT:
 55435                              <1> 	; 	[u.r0] will be > 0 if succesful
 55436                              <1> 
 55437                              <1> 	; window
 55438                              <1> 	;mov	edi, [v_str] ; LFB start address
 55439                              <1> 	;mov	esi, edi 
 55440                              <1> 
 55441 0000ECAA 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55442 0000ECB1 7707                <1> 	ja	short m_pix_op_add_w_1
 55443                              <1> 
 55444                              <1> 	; 256 colors (8bpp)
 55445 0000ECB3 BD[05EC0000]        <1> 	mov	ebp, m_pix_op_add_8
 55446 0000ECB8 EB1E                <1> 	jmp	short m_pix_op_add_w_4
 55447                              <1> 			
 55448                              <1> m_pix_op_add_w_1:
 55449 0000ECBA 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55450 0000ECC1 7710                <1> 	ja	short m_pix_op_add_w_3 ; 32bpp
 55451 0000ECC3 7207                <1> 	jb	short m_pix_op_add_w_2 ; 16bpp
 55452                              <1> 
 55453                              <1> 	; 24 bit true colors
 55454 0000ECC5 BD[2CEC0000]        <1> 	mov	ebp, m_pix_op_add_24
 55455 0000ECCA EB0C                <1> 	jmp	short m_pix_op_add_w_4
 55456                              <1> 
 55457                              <1> 	; 65536 colors (16bpp)
 55458                              <1> m_pix_op_add_w_2:
 55459 0000ECCC BD[64EC0000]        <1> 	mov	ebp, m_pix_op_add_16
 55460 0000ECD1 EB05                <1> 	jmp	short m_pix_op_add_w_4
 55461                              <1> 
 55462                              <1> 	; 32 bit true colors
 55463                              <1> m_pix_op_add_w_3:
 55464 0000ECD3 BD[88EC0000]        <1> 	mov	ebp, m_pix_op_add_32
 55465                              <1> m_pix_op_add_w_4:
 55466 0000ECD8 E9FDFEFFFF          <1> 	jmp	m_pix_op_add_w_x
 55467                              <1> 
 55468                              <1> m_pix_op_sub:
 55469                              <1> 	; 02/03/2021
 55470                              <1> 	; 06/02/2021
 55471                              <1> 	; SUBTRACT COLOR (MASKED, full screen)
 55472                              <1> 	;
 55473                              <1> 	; jump from pix_op_sub
 55474                              <1> 	;
 55475                              <1> 	; INPUT:
 55476                              <1> 	;   eax = color (AL, AX, EAX)
 55477                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55478                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55479                              <1> 	;
 55480                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55481                              <1> 	;
 55482                              <1> 	; OUTPUT:
 55483                              <1> 	; 	[u.r0] will be > 0 if succesful
 55484                              <1> 	
 55485                              <1> 	; Full screen
 55486                              <1> m_pix_op_sub_0:
 55487 0000ECDD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55488 0000ECE4 771C                <1> 	ja	short m_pix_op_sub_1
 55489                              <1> 	; 256 colors (8bpp)
 55490                              <1> 	;jmp	short m_pix_op_sub_8
 55491                              <1> m_pix_op_sub_8:
 55492                              <1> 	; 8 bit colors (256 colors)
 55493 0000ECE6 88C2                <1> 	mov	dl, al ; new color
 55494                              <1> m_pix_op_sub_8_0:
 55495 0000ECE8 AC                  <1> 	lodsb 
 55496 0000ECE9 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55497 0000ECEF 740D                <1> 	je	short m_pix_op_sub_8_1 ; exclude
 55498 0000ECF1 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55499 0000ECF7 2817                <1> 	sub	[edi], dl
 55500 0000ECF9 7303                <1> 	jnb	short m_pix_op_sub_8_1
 55501 0000ECFB C60700              <1> 	mov	byte [edi], 0 
 55502                              <1> m_pix_op_sub_8_1:
 55503 0000ECFE 47                  <1> 	inc	edi
 55504 0000ECFF E2E7                <1> 	loop	m_pix_op_sub_8_0
 55505 0000ED01 C3                  <1> 	retn
 55506                              <1> m_pix_op_sub_1:
 55507 0000ED02 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55508 0000ED09 7755                <1> 	ja	short m_pix_op_sub_3 ; 32bpp	
 55509 0000ED0B 722F                <1> 	jb	short m_pix_op_sub_2 ; 16bpp
 55510                              <1> 	; 24 bit true colors
 55511                              <1> 	;jmp	short m_pix_op_sub_24
 55512                              <1> m_pix_op_sub_24:
 55513                              <1> 	; 24 bit true colors
 55514 0000ED0D 89C2                <1> 	mov	edx, eax ; new color
 55515                              <1> 	; 02/03/2021
 55516                              <1> m_pix_op_sub_24_0:
 55517 0000ED0F 66AD                <1> 	lodsw
 55518 0000ED11 C1E010              <1> 	shl	eax, 16
 55519 0000ED14 AC                  <1> 	lodsb
 55520 0000ED15 C1C010              <1> 	rol	eax, 16	
 55521 0000ED18 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55522 0000ED1E 7416                <1> 	je	short m_pix_op_sub_24_2 ; exclude
 55523 0000ED20 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 55524 0000ED27 29D0                <1> 	sub	eax, edx
 55525 0000ED29 7302                <1> 	jnb	short m_pix_op_sub_24_1
 55526 0000ED2B 31C0                <1> 	xor	eax, eax ; 0
 55527                              <1> m_pix_op_sub_24_1:	
 55528 0000ED2D 668907              <1> 	mov	[edi], ax
 55529 0000ED30 C1E810              <1> 	shr	eax, 16
 55530 0000ED33 884702              <1> 	mov	[edi+2], al
 55531                              <1> m_pix_op_sub_24_2:
 55532 0000ED36 83C703              <1> 	add	edi, 3 ; +3
 55533 0000ED39 E2D4                <1> 	loop	m_pix_op_sub_24_0
 55534 0000ED3B C3                  <1> 	retn
 55535                              <1> 	; 65536 colors (16bpp)
 55536                              <1> m_pix_op_sub_2:
 55537                              <1> 	;jmp	short m_pix_op_sub_16
 55538                              <1> m_pix_op_sub_16:
 55539                              <1> 	; 16 bit colors (65536 colors)
 55540 0000ED3C 89C2                <1> 	mov	edx, eax ; new color
 55541                              <1> m_pix_op_sub_16_0:
 55542 0000ED3E 66AD                <1> 	lodsw
 55543 0000ED40 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55544 0000ED47 7411                <1> 	je	short m_pix_op_sub_16_1 ; exclude
 55545 0000ED49 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 55546 0000ED50 662917              <1> 	sub	[edi], dx
 55547 0000ED53 7305                <1> 	jnb	short m_pix_op_sub_16_1
 55548 0000ED55 31C0                <1> 	xor	eax, eax
 55549 0000ED57 668907              <1> 	mov	[edi], ax ; 0
 55550                              <1> m_pix_op_sub_16_1:
 55551 0000ED5A 83C702              <1> 	add	edi, 2 ; +2
 55552 0000ED5D E2DF                <1> 	loop	m_pix_op_sub_16_0
 55553 0000ED5F C3                  <1> 	retn
 55554                              <1> m_pix_op_sub_3:
 55555                              <1> 	; 32 bit true colors
 55556                              <1> 	;jmp	short m_pix_op_sub_32
 55557                              <1> m_pix_op_sub_32:
 55558                              <1> 	; 32 bit true colors
 55559 0000ED60 89C2                <1> 	mov	edx, eax ; new color
 55560                              <1> m_pix_op_sub_32_0:
 55561 0000ED62 AD                  <1> 	lodsd 
 55562 0000ED63 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55563 0000ED69 740F                <1> 	je	short m_pix_op_sub_32_1 ; exclude
 55564 0000ED6B 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 55565 0000ED72 2917                <1> 	sub	[edi], edx
 55566 0000ED74 7304                <1> 	jnb	short m_pix_op_sub_32_1
 55567 0000ED76 31C0                <1> 	xor	eax, eax
 55568 0000ED78 8907                <1> 	mov	[edi], eax ; 0
 55569                              <1> m_pix_op_sub_32_1:
 55570 0000ED7A 83C704              <1> 	add	edi, 4 ; +4
 55571 0000ED7D E2E3                <1> 	loop	m_pix_op_sub_32_0
 55572 0000ED7F C3                  <1> 	retn
 55573                              <1> 
 55574                              <1> m_pix_op_sub_w:
 55575                              <1> 	; 06/02/2021
 55576                              <1> 	; SUBTRACT COLOR (MASKED, window)
 55577                              <1> 	;
 55578                              <1> 	; jump from pix_op_sub_w
 55579                              <1> 	;
 55580                              <1> 	; INPUT:
 55581                              <1> 	;   ecx = bytes per row (to be applied)
 55582                              <1> 	;   edx = screen width in bytes
 55583                              <1> 	;   ebx = row count
 55584                              <1> 	;   eax = color
 55585                              <1> 	;
 55586                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55587                              <1> 	;
 55588                              <1> 	; OUTPUT:
 55589                              <1> 	; 	[u.r0] will be > 0 if succesful
 55590                              <1> 
 55591                              <1> 	; window
 55592                              <1> 	;mov	edi, [v_str] ; LFB start address
 55593                              <1> 	;mov	esi, edi 
 55594                              <1> 
 55595 0000ED80 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55596 0000ED87 7707                <1> 	ja	short m_pix_op_sub_w_1
 55597                              <1> 
 55598                              <1> 	; 256 colors (8bpp)
 55599 0000ED89 BD[E6EC0000]        <1> 	mov	ebp, m_pix_op_sub_8
 55600 0000ED8E EB1E                <1> 	jmp	short m_pix_op_sub_w_4
 55601                              <1> 			
 55602                              <1> m_pix_op_sub_w_1:
 55603 0000ED90 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55604 0000ED97 7710                <1> 	ja	short m_pix_op_sub_w_3 ; 32bpp
 55605 0000ED99 7207                <1> 	jb	short m_pix_op_sub_w_2 ; 16bpp
 55606                              <1> 
 55607                              <1> 	; 24 bit true colors
 55608 0000ED9B BD[0DED0000]        <1> 	mov	ebp, m_pix_op_sub_24
 55609 0000EDA0 EB0C                <1> 	jmp	short m_pix_op_sub_w_4
 55610                              <1> 
 55611                              <1> 	; 65536 colors (16bpp)
 55612                              <1> m_pix_op_sub_w_2:
 55613 0000EDA2 BD[3CED0000]        <1> 	mov	ebp, m_pix_op_sub_16
 55614 0000EDA7 EB05                <1> 	jmp	short m_pix_op_sub_w_4
 55615                              <1> 
 55616                              <1> 	; 32 bit true colors
 55617                              <1> m_pix_op_sub_w_3:
 55618 0000EDA9 BD[60ED0000]        <1> 	mov	ebp, m_pix_op_sub_32
 55619                              <1> m_pix_op_sub_w_4:
 55620 0000EDAE E927FEFFFF          <1> 	jmp	m_pix_op_sub_w_x
 55621                              <1> 
 55622                              <1> m_pix_op_mix:
 55623                              <1> 	; 25/02/2021
 55624                              <1> 	; 06/02/2021
 55625                              <1> 	; MIX COLOR (MASKED, full screen)
 55626                              <1> 	;
 55627                              <1> 	; jump from pix_op_mix
 55628                              <1> 	;
 55629                              <1> 	; INPUT:
 55630                              <1> 	;   eax = color (AL, AX, EAX)
 55631                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55632                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55633                              <1> 	;
 55634                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55635                              <1> 	;
 55636                              <1> 	; OUTPUT:
 55637                              <1> 	; 	[u.r0] will be > 0 if succesful
 55638                              <1> 	
 55639                              <1> 	; Full screen
 55640                              <1> m_pix_op_mix_0:
 55641 0000EDB3 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55642 0000EDBA 771B                <1> 	ja	short m_pix_op_mix_1
 55643                              <1> 	; 256 colors (8bpp)
 55644                              <1> 	;jmp	short m_pix_op_mix_8
 55645                              <1> m_pix_op_mix_8:
 55646                              <1> 	; 8 bit colors (256 colors)
 55647 0000EDBC 88C2                <1> 	mov	dl, al ; new (mixing) color
 55648                              <1> m_pix_op_mix_8_0:
 55649 0000EDBE AC                  <1> 	lodsb 
 55650 0000EDBF 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55651 0000EDC5 740C                <1> 	je	short m_pix_op_mix_8_1 ; exclude
 55652 0000EDC7 00D0                <1> 	add	al, dl ; 25/02/2021
 55653 0000EDC9 D0D8                <1> 	rcr	al, 1	
 55654 0000EDCB 8807                <1> 	mov	[edi], al
 55655 0000EDCD FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55656                              <1> m_pix_op_mix_8_1:
 55657 0000EDD3 47                  <1> 	inc	edi
 55658 0000EDD4 E2E8                <1> 	loop	m_pix_op_mix_8_0
 55659 0000EDD6 C3                  <1> 	retn
 55660                              <1> m_pix_op_mix_1:
 55661 0000EDD7 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55662 0000EDDE 7752                <1> 	ja	short m_pix_op_mix_3 ; 32bpp	
 55663 0000EDE0 722D                <1> 	jb	short m_pix_op_mix_2 ; 16bpp
 55664                              <1> 	; 24 bit true colors
 55665                              <1> 	;jmp	short m_pix_op_mix_24
 55666                              <1> m_pix_op_mix_24:
 55667                              <1> 	; 24 bit true colors
 55668 0000EDE2 89C2                <1> 	mov	edx, eax ; new color
 55669                              <1> 	;and	edx, 0FFFFFFh
 55670                              <1> m_pix_op_mix_24_0:
 55671 0000EDE4 66AD                <1> 	lodsw
 55672 0000EDE6 C1E010              <1> 	shl	eax, 16
 55673 0000EDE9 AC                  <1> 	lodsb
 55674 0000EDEA C1C010              <1> 	rol	eax, 16	
 55675 0000EDED 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55676 0000EDF3 7414                <1> 	je	short m_pix_op_mix_24_1 ; exclude
 55677 0000EDF5 01D0                <1> 	add	eax, edx
 55678 0000EDF7 D1E8                <1> 	shr	eax, 1
 55679 0000EDF9 668907              <1> 	mov	[edi], ax
 55680 0000EDFC C1E810              <1> 	shr	eax, 16
 55681 0000EDFF 884702              <1> 	mov	[edi+2], al
 55682 0000EE02 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 55683                              <1> m_pix_op_mix_24_1:
 55684 0000EE09 83C703              <1> 	add	edi, 3 ; +3
 55685 0000EE0C E2D6                <1> 	loop	m_pix_op_mix_24_0
 55686 0000EE0E C3                  <1> 	retn
 55687                              <1> 	; 65536 colors (16bpp)
 55688                              <1> m_pix_op_mix_2:
 55689                              <1> 	;jmp	short m_pix_op_mix_16
 55690                              <1> m_pix_op_mix_16:
 55691                              <1> 	; 16 bit colors (65536 colors)
 55692 0000EE0F 89C2                <1> 	mov	edx, eax ; new color
 55693                              <1> 	;and	edx, 0FFFFh
 55694                              <1> m_pix_op_mix_16_0:
 55695 0000EE11 66AD                <1> 	lodsw
 55696 0000EE13 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55697 0000EE1A 7410                <1> 	je	short m_pix_op_mix_16_1 ; exclude
 55698 0000EE1C 6601D0              <1> 	add	ax, dx
 55699 0000EE1F 66D1D8              <1> 	rcr	ax, 1
 55700 0000EE22 668907              <1> 	mov	[edi], ax
 55701 0000EE25 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 55702                              <1> m_pix_op_mix_16_1:
 55703 0000EE2C 83C702              <1> 	add	edi, 2 ; +2
 55704 0000EE2F E2E0                <1> 	loop	m_pix_op_mix_16_0
 55705 0000EE31 C3                  <1> 	retn
 55706                              <1> m_pix_op_mix_3:
 55707                              <1> 	; 32 bit true colors
 55708                              <1> 	;jmp	short m_pix_op_mix_32
 55709                              <1> m_pix_op_mix_32:
 55710                              <1> 	; 32 bit true colors
 55711 0000EE32 89C2                <1> 	mov	edx, eax ; new color
 55712                              <1> m_pix_op_mix_32_0:
 55713 0000EE34 AD                  <1> 	lodsd 
 55714 0000EE35 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55715 0000EE3B 740D                <1> 	je	short m_pix_op_mix_32_1 ; exclude
 55716 0000EE3D 01D0                <1> 	add	eax, edx
 55717                              <1> 	; 02/03/2021
 55718 0000EE3F D1D8                <1> 	rcr	eax, 1
 55719 0000EE41 8907                <1> 	mov	[edi], eax	
 55720 0000EE43 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 55721                              <1> m_pix_op_mix_32_1:
 55722 0000EE4A 83C704              <1> 	add	edi, 4 ; +4
 55723 0000EE4D E2E5                <1> 	loop	m_pix_op_mix_32_0
 55724 0000EE4F C3                  <1> 	retn
 55725                              <1> 
 55726                              <1> m_pix_op_mix_w:
 55727                              <1> 	; 06/02/2021
 55728                              <1> 	; MIX COLOR (MASKED, window)
 55729                              <1> 	;
 55730                              <1> 	; jump from pix_op_mix_w
 55731                              <1> 	;
 55732                              <1> 	; INPUT:
 55733                              <1> 	;   ecx = bytes per row (to be applied)
 55734                              <1> 	;   edx = screen width in bytes
 55735                              <1> 	;   ebx = row count
 55736                              <1> 	;   eax = color
 55737                              <1> 	;
 55738                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55739                              <1> 	;
 55740                              <1> 	; OUTPUT:
 55741                              <1> 	; 	[u.r0] will be > 0 if succesful
 55742                              <1> 
 55743                              <1> 	; window
 55744                              <1> 	;mov	edi, [v_str] ; LFB start address
 55745                              <1> 	;mov	esi, edi 
 55746                              <1> 
 55747 0000EE50 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55748 0000EE57 7707                <1> 	ja	short m_pix_op_mix_w_1
 55749                              <1> 
 55750                              <1> 	; 256 colors (8bpp)
 55751 0000EE59 BD[BCED0000]        <1> 	mov	ebp, m_pix_op_mix_8
 55752 0000EE5E EB1E                <1> 	jmp	short m_pix_op_mix_w_4
 55753                              <1> 			
 55754                              <1> m_pix_op_mix_w_1:
 55755 0000EE60 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55756 0000EE67 7710                <1> 	ja	short m_pix_op_mix_w_3 ; 32bpp
 55757 0000EE69 7207                <1> 	jb	short m_pix_op_mix_w_2 ; 16bpp
 55758                              <1> 
 55759                              <1> 	; 24 bit true colors
 55760 0000EE6B BD[E2ED0000]        <1> 	mov	ebp, m_pix_op_mix_24
 55761 0000EE70 EB0C                <1> 	jmp	short m_pix_op_mix_w_4
 55762                              <1> 
 55763                              <1> 	; 65536 colors (16bpp)
 55764                              <1> m_pix_op_mix_w_2:
 55765 0000EE72 BD[0FEE0000]        <1> 	mov	ebp, m_pix_op_mix_16
 55766 0000EE77 EB05                <1> 	jmp	short m_pix_op_mix_w_4
 55767                              <1> 
 55768                              <1> 	; 32 bit true colors
 55769                              <1> m_pix_op_mix_w_3:
 55770 0000EE79 BD[32EE0000]        <1> 	mov	ebp, m_pix_op_mix_32
 55771                              <1> m_pix_op_mix_w_4:
 55772 0000EE7E E957FDFFFF          <1> 	jmp	m_pix_op_mix_w_x
 55773                              <1> 
 55774                              <1> m_pix_op_and:
 55775                              <1> 	; 06/02/2021
 55776                              <1> 	; AND COLOR (MASKED, full screen)
 55777                              <1> 	;
 55778                              <1> 	; jump from pix_op_and
 55779                              <1> 	;
 55780                              <1> 	; INPUT:
 55781                              <1> 	;   eax = color (AL, AX, EAX)
 55782                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55783                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55784                              <1> 	;
 55785                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55786                              <1> 	;
 55787                              <1> 	; OUTPUT:
 55788                              <1> 	; 	[u.r0] will be > 0 if succesful
 55789                              <1> 	
 55790                              <1> 	; Full screen
 55791                              <1> m_pix_op_and_0:
 55792 0000EE83 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55793 0000EE8A 7717                <1> 	ja	short m_pix_op_and_1
 55794                              <1> 	; 256 colors (8bpp)
 55795                              <1> 	;jmp	short m_pix_op_and_8
 55796                              <1> m_pix_op_and_8:
 55797                              <1> 	; 8 bit colors (256 colors)
 55798 0000EE8C 88C2                <1> 	mov	dl, al ; new color
 55799                              <1> m_pix_op_and_8_0:
 55800 0000EE8E AC                  <1> 	lodsb 
 55801 0000EE8F 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55802 0000EE95 7408                <1> 	je	short m_pix_op_and_8_1 ; exclude
 55803 0000EE97 2017                <1> 	and	[edi], dl
 55804 0000EE99 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55805                              <1> m_pix_op_and_8_1:
 55806 0000EE9F 47                  <1> 	inc	edi
 55807 0000EEA0 E2EC                <1> 	loop	m_pix_op_and_8_0
 55808 0000EEA2 C3                  <1> 	retn
 55809                              <1> m_pix_op_and_1:
 55810 0000EEA3 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55811 0000EEAA 774A                <1> 	ja	short m_pix_op_and_3 ; 32bpp	
 55812 0000EEAC 722B                <1> 	jb	short m_pix_op_and_2 ; 16bpp
 55813                              <1> 	; 24 bit true colors
 55814                              <1> 	;jmp	short m_pix_op_and_24
 55815                              <1> m_pix_op_and_24:
 55816                              <1> 	; 24 bit true colors
 55817 0000EEAE 89C2                <1> 	mov	edx, eax ; new color
 55818                              <1> 	;and	edx, 0FFFFFFh
 55819                              <1> m_pix_op_and_24_0:
 55820 0000EEB0 66AD                <1> 	lodsw
 55821 0000EEB2 C1E010              <1> 	shl	eax, 16
 55822 0000EEB5 AC                  <1> 	lodsb
 55823 0000EEB6 C1C010              <1> 	rol	eax, 16	
 55824 0000EEB9 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55825 0000EEBF 7412                <1> 	je	short m_pix_op_and_24_1 ; exclude
 55826 0000EEC1 21D0                <1> 	and	eax, edx
 55827 0000EEC3 668907              <1> 	mov	[edi], ax
 55828 0000EEC6 C1E810              <1> 	shr	eax, 16
 55829 0000EEC9 884702              <1> 	mov	[edi+2], al
 55830 0000EECC 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 55831                              <1> m_pix_op_and_24_1:
 55832 0000EED3 83C703              <1> 	add	edi, 3 ; +3
 55833 0000EED6 E2D8                <1> 	loop	m_pix_op_and_24_0
 55834 0000EED8 C3                  <1> 	retn
 55835                              <1> 	; 65536 colors (16bpp)
 55836                              <1> m_pix_op_and_2:
 55837                              <1> 	;jmp	short m_pix_op_and_16
 55838                              <1> m_pix_op_and_16:
 55839                              <1> 	; 16 bit colors (65536 colors)
 55840 0000EED9 89C2                <1> 	mov	edx, eax ; new color
 55841                              <1> 	;and	edx, 0FFFFh
 55842                              <1> m_pix_op_and_16_0:
 55843 0000EEDB 66AD                <1> 	lodsw
 55844 0000EEDD 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55845 0000EEE4 740A                <1> 	je	short m_pix_op_and_16_1 ; exclude
 55846 0000EEE6 662117              <1> 	and	[edi], dx
 55847 0000EEE9 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 55848                              <1> m_pix_op_and_16_1:
 55849 0000EEF0 83C702              <1> 	add	edi, 2 ; +2
 55850 0000EEF3 E2E6                <1> 	loop	m_pix_op_and_16_0
 55851 0000EEF5 C3                  <1> 	retn
 55852                              <1> m_pix_op_and_3:
 55853                              <1> 	; 32 bit true colors
 55854                              <1> 	;jmp	short m_pix_op_and_32
 55855                              <1> m_pix_op_and_32:
 55856                              <1> 	; 32 bit true colors
 55857 0000EEF6 89C2                <1> 	mov	edx, eax ; new color
 55858                              <1> m_pix_op_and_32_0:
 55859 0000EEF8 AD                  <1> 	lodsd 
 55860 0000EEF9 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55861 0000EEFF 7409                <1> 	je	short m_pix_op_and_32_1 ; exclude
 55862 0000EF01 2117                <1> 	and	[edi], edx ; 25/02/2021	
 55863 0000EF03 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 55864                              <1> m_pix_op_and_32_1:
 55865 0000EF0A 83C704              <1> 	add	edi, 4 ; +4
 55866 0000EF0D E2E9                <1> 	loop	m_pix_op_and_32_0
 55867 0000EF0F C3                  <1> 	retn
 55868                              <1> 
 55869                              <1> m_pix_op_and_w:
 55870                              <1> 	; 06/02/2021
 55871                              <1> 	; AND COLOR (MASKED, window)
 55872                              <1> 	;
 55873                              <1> 	; jump from pix_op_and_w
 55874                              <1> 	;
 55875                              <1> 	; INPUT:
 55876                              <1> 	;   ecx = bytes per row (to be applied)
 55877                              <1> 	;   edx = screen width in bytes
 55878                              <1> 	;   ebx = row count
 55879                              <1> 	;   eax = color
 55880                              <1> 	;
 55881                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55882                              <1> 	;
 55883                              <1> 	; OUTPUT:
 55884                              <1> 	; 	[u.r0] will be > 0 if succesful
 55885                              <1> 
 55886                              <1> 	; window
 55887                              <1> 	;mov	edi, [v_str] ; LFB start address
 55888                              <1> 	;mov	esi, edi 
 55889                              <1> 
 55890 0000EF10 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55891 0000EF17 7707                <1> 	ja	short m_pix_op_and_w_1
 55892                              <1> 
 55893                              <1> 	; 256 colors (8bpp)
 55894 0000EF19 BD[8CEE0000]        <1> 	mov	ebp, m_pix_op_and_8
 55895 0000EF1E EB1E                <1> 	jmp	short m_pix_op_and_w_4
 55896                              <1> 			
 55897                              <1> m_pix_op_and_w_1:
 55898 0000EF20 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55899 0000EF27 7710                <1> 	ja	short m_pix_op_and_w_3 ; 32bpp
 55900 0000EF29 7207                <1> 	jb	short m_pix_op_and_w_2 ; 16bpp
 55901                              <1> 
 55902                              <1> 	; 24 bit true colors
 55903 0000EF2B BD[AEEE0000]        <1> 	mov	ebp, m_pix_op_and_24
 55904 0000EF30 EB0C                <1> 	jmp	short m_pix_op_and_w_4
 55905                              <1> 
 55906                              <1> 	; 65536 colors (16bpp)
 55907                              <1> m_pix_op_and_w_2:
 55908 0000EF32 BD[D9EE0000]        <1> 	mov	ebp, m_pix_op_and_16
 55909 0000EF37 EB05                <1> 	jmp	short m_pix_op_and_w_4
 55910                              <1> 
 55911                              <1> 	; 32 bit true colors
 55912                              <1> m_pix_op_and_w_3:
 55913 0000EF39 BD[F6EE0000]        <1> 	mov	ebp, m_pix_op_and_32
 55914                              <1> m_pix_op_and_w_4:
 55915 0000EF3E E997FCFFFF          <1> 	jmp	m_pix_op_and_w_x
 55916                              <1> 
 55917                              <1> m_pix_op_or:
 55918                              <1> 	; 06/02/2021
 55919                              <1> 	; OR COLOR (MASKED, full screen)
 55920                              <1> 	;
 55921                              <1> 	; jump from pix_op_orc
 55922                              <1> 	;
 55923                              <1> 	; INPUT:
 55924                              <1> 	;   eax = color (AL, AX, EAX)
 55925                              <1> 	;   ecx = [v_siz] ; display page pixel count
 55926                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 55927                              <1> 	;
 55928                              <1> 	;   [maskcolor] = mask color (to be excluded)
 55929                              <1> 	;
 55930                              <1> 	; OUTPUT:
 55931                              <1> 	; 	[u.r0] will be > 0 if succesful
 55932                              <1> 	
 55933                              <1> 	; Full screen
 55934                              <1> m_pix_op_or_0:
 55935 0000EF43 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 55936 0000EF4A 7717                <1> 	ja	short m_pix_op_or_1
 55937                              <1> 	; 256 colors (8bpp)
 55938                              <1> 	;jmp	short m_pix_op_or_8
 55939                              <1> m_pix_op_or_8:
 55940                              <1> 	; 8 bit colors (256 colors)
 55941 0000EF4C 88C2                <1> 	mov	dl, al ; new color
 55942                              <1> m_pix_op_or_8_0:
 55943 0000EF4E AC                  <1> 	lodsb 
 55944 0000EF4F 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 55945 0000EF55 7408                <1> 	je	short m_pix_op_or_8_1 ; exclude
 55946 0000EF57 0817                <1> 	or	[edi], dl
 55947 0000EF59 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 55948                              <1> m_pix_op_or_8_1:
 55949 0000EF5F 47                  <1> 	inc	edi
 55950 0000EF60 E2EC                <1> 	loop	m_pix_op_or_8_0
 55951 0000EF62 C3                  <1> 	retn
 55952                              <1> m_pix_op_or_1:
 55953 0000EF63 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 55954 0000EF6A 774A                <1> 	ja	short m_pix_op_or_3 ; 32bpp	
 55955 0000EF6C 722B                <1> 	jb	short m_pix_op_or_2 ; 16bpp
 55956                              <1> 	; 24 bit true colors
 55957                              <1> 	;jmp	short m_pix_op_or_24
 55958                              <1> m_pix_op_or_24:
 55959                              <1> 	; 24 bit true colors
 55960 0000EF6E 89C2                <1> 	mov	edx, eax ; new color
 55961                              <1> 	;and	edx, 0FFFFFFh
 55962                              <1> m_pix_op_or_24_0:
 55963 0000EF70 66AD                <1> 	lodsw
 55964 0000EF72 C1E010              <1> 	shl	eax, 16
 55965 0000EF75 AC                  <1> 	lodsb
 55966 0000EF76 C1C010              <1> 	rol	eax, 16	
 55967 0000EF79 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 55968 0000EF7F 7412                <1> 	je	short m_pix_op_or_24_1 ; exclude
 55969 0000EF81 09D0                <1> 	or	eax, edx
 55970 0000EF83 668907              <1> 	mov	[edi], ax
 55971 0000EF86 C1E810              <1> 	shr	eax, 16
 55972 0000EF89 884702              <1> 	mov	[edi+2], al
 55973 0000EF8C 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 55974                              <1> m_pix_op_or_24_1:
 55975 0000EF93 83C703              <1> 	add	edi, 3 ; +3
 55976 0000EF96 E2D8                <1> 	loop	m_pix_op_or_24_0
 55977 0000EF98 C3                  <1> 	retn
 55978                              <1> 	; 65536 colors (16bpp)
 55979                              <1> m_pix_op_or_2:
 55980                              <1> 	;jmp	short m_pix_op_or_16
 55981                              <1> m_pix_op_or_16:
 55982                              <1> 	; 16 bit colors (65536 colors)
 55983 0000EF99 89C2                <1> 	mov	edx, eax ; new color
 55984                              <1> 	;and	edx, 0FFFFh
 55985                              <1> m_pix_op_or_16_0:
 55986 0000EF9B 66AD                <1> 	lodsw
 55987 0000EF9D 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 55988 0000EFA4 740A                <1> 	je	short m_pix_op_or_16_1 ; exclude
 55989 0000EFA6 660917              <1> 	or	[edi], dx
 55990 0000EFA9 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 55991                              <1> m_pix_op_or_16_1:
 55992 0000EFB0 83C702              <1> 	add	edi, 2 ; +2
 55993 0000EFB3 E2E6                <1> 	loop	m_pix_op_or_16_0
 55994 0000EFB5 C3                  <1> 	retn
 55995                              <1> m_pix_op_or_3:
 55996                              <1> 	; 32 bit true colors
 55997                              <1> 	;jmp	short m_pix_op_or_32
 55998                              <1> m_pix_op_or_32:
 55999                              <1> 	; 32 bit true colors
 56000 0000EFB6 89C2                <1> 	mov	edx, eax ; new color
 56001                              <1> m_pix_op_or_32_0:
 56002 0000EFB8 AD                  <1> 	lodsd 
 56003 0000EFB9 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56004 0000EFBF 7409                <1> 	je	short m_pix_op_or_32_1 ; exclude
 56005 0000EFC1 0917                <1> 	or	[edi], edx ; 25/02/2021	
 56006 0000EFC3 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56007                              <1> m_pix_op_or_32_1:
 56008 0000EFCA 83C704              <1> 	add	edi, 4 ; +4
 56009 0000EFCD E2E9                <1> 	loop	m_pix_op_or_32_0
 56010 0000EFCF C3                  <1> 	retn
 56011                              <1> 
 56012                              <1> m_pix_op_or_w:
 56013                              <1> 	; 06/02/2021
 56014                              <1> 	; MIX COLOR (MASKED, window)
 56015                              <1> 	;
 56016                              <1> 	; jump from pix_op_or_w
 56017                              <1> 	;
 56018                              <1> 	; INPUT:
 56019                              <1> 	;   ecx = bytes per row (to be applied)
 56020                              <1> 	;   edx = screen width in bytes
 56021                              <1> 	;   ebx = row count
 56022                              <1> 	;   eax = color
 56023                              <1> 	;
 56024                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56025                              <1> 	;
 56026                              <1> 	; OUTPUT:
 56027                              <1> 	; 	[u.r0] will be > 0 if succesful
 56028                              <1> 
 56029                              <1> 	; window
 56030                              <1> 	;mov	edi, [v_str] ; LFB start address
 56031                              <1> 	;mov	esi, edi 
 56032                              <1> 
 56033 0000EFD0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56034 0000EFD7 7707                <1> 	ja	short m_pix_op_or_w_1
 56035                              <1> 
 56036                              <1> 	; 256 colors (8bpp)
 56037 0000EFD9 BD[4CEF0000]        <1> 	mov	ebp, m_pix_op_or_8
 56038 0000EFDE EB1E                <1> 	jmp	short m_pix_op_or_w_4
 56039                              <1> 			
 56040                              <1> m_pix_op_or_w_1:
 56041 0000EFE0 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56042 0000EFE7 7710                <1> 	ja	short m_pix_op_or_w_3 ; 32bpp
 56043 0000EFE9 7207                <1> 	jb	short m_pix_op_or_w_2 ; 16bpp
 56044                              <1> 
 56045                              <1> 	; 24 bit true colors
 56046 0000EFEB BD[6EEF0000]        <1> 	mov	ebp, m_pix_op_or_24
 56047 0000EFF0 EB0C                <1> 	jmp	short m_pix_op_or_w_4
 56048                              <1> 
 56049                              <1> 	; 65536 colors (16bpp)
 56050                              <1> m_pix_op_or_w_2:
 56051 0000EFF2 BD[99EF0000]        <1> 	mov	ebp, m_pix_op_or_16
 56052 0000EFF7 EB05                <1> 	jmp	short m_pix_op_or_w_4
 56053                              <1> 
 56054                              <1> 	; 32 bit true colors
 56055                              <1> m_pix_op_or_w_3:
 56056 0000EFF9 BD[B6EF0000]        <1> 	mov	ebp, m_pix_op_or_32
 56057                              <1> m_pix_op_or_w_4:
 56058 0000EFFE E9D7FBFFFF          <1> 	jmp	m_pix_op_orc_w_x
 56059                              <1> 
 56060                              <1> m_pix_op_xor:
 56061                              <1> 	; 06/02/2021
 56062                              <1> 	; XOR COLOR (MASKED, full screen)
 56063                              <1> 	;
 56064                              <1> 	; jump from pix_op_xor
 56065                              <1> 	;
 56066                              <1> 	; INPUT:
 56067                              <1> 	;   eax = color (AL, AX, EAX)
 56068                              <1> 	;   ecx = [v_siz] ; display page pixel count
 56069                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 56070                              <1> 	;
 56071                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56072                              <1> 	;
 56073                              <1> 	; OUTPUT:
 56074                              <1> 	; 	[u.r0] will be > 0 if succesful
 56075                              <1> 	
 56076                              <1> 	; Full screen
 56077                              <1> m_pix_op_xor_0:
 56078 0000F003 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56079 0000F00A 7717                <1> 	ja	short m_pix_op_xor_1
 56080                              <1> 	; 256 colors (8bpp)
 56081                              <1> 	;jmp	short m_pix_op_xor_8
 56082                              <1> m_pix_op_xor_8:
 56083                              <1> 	; 8 bit colors (256 colors)
 56084 0000F00C 88C2                <1> 	mov	dl, al ; new color
 56085                              <1> m_pix_op_xor_8_0:
 56086 0000F00E AC                  <1> 	lodsb 
 56087 0000F00F 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 56088 0000F015 7408                <1> 	je	short m_pix_op_xor_8_1 ; exclude
 56089 0000F017 3017                <1> 	xor	[edi], dl
 56090 0000F019 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 56091                              <1> m_pix_op_xor_8_1:
 56092 0000F01F 47                  <1> 	inc	edi
 56093 0000F020 E2EC                <1> 	loop	m_pix_op_xor_8_0
 56094 0000F022 C3                  <1> 	retn
 56095                              <1> m_pix_op_xor_1:
 56096 0000F023 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56097 0000F02A 774A                <1> 	ja	short m_pix_op_xor_3 ; 32bpp	
 56098 0000F02C 722B                <1> 	jb	short m_pix_op_xor_2 ; 16bpp
 56099                              <1> 	; 24 bit true colors
 56100                              <1> 	;jmp	short m_pix_op_xor_24
 56101                              <1> m_pix_op_xor_24:
 56102                              <1> 	; 24 bit true colors
 56103 0000F02E 89C2                <1> 	mov	edx, eax ; new color
 56104                              <1> 	;and	edx, 0FFFFFFh
 56105                              <1> m_pix_op_xor_24_0:
 56106 0000F030 66AD                <1> 	lodsw
 56107 0000F032 C1E010              <1> 	shl	eax, 16
 56108 0000F035 AC                  <1> 	lodsb
 56109 0000F036 C1C010              <1> 	rol	eax, 16	
 56110 0000F039 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56111 0000F03F 7412                <1> 	je	short m_pix_op_xor_24_1 ; exclude
 56112 0000F041 31D0                <1> 	xor	eax, edx
 56113 0000F043 668907              <1> 	mov	[edi], ax
 56114 0000F046 C1E810              <1> 	shr	eax, 16
 56115 0000F049 884702              <1> 	mov	[edi+2], al
 56116 0000F04C 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 56117                              <1> m_pix_op_xor_24_1:
 56118 0000F053 83C703              <1> 	add	edi, 3 ; +3
 56119 0000F056 E2D8                <1> 	loop	m_pix_op_xor_24_0
 56120 0000F058 C3                  <1> 	retn
 56121                              <1> 	; 65536 colors (16bpp)
 56122                              <1> m_pix_op_xor_2:
 56123                              <1> 	;jmp	short m_pix_op_xor_16
 56124                              <1> m_pix_op_xor_16:
 56125                              <1> 	; 16 bit colors (65536 colors)
 56126 0000F059 89C2                <1> 	mov	edx, eax ; new color
 56127                              <1> 	;and	edx, 0FFFFh
 56128                              <1> m_pix_op_xor_16_0:
 56129 0000F05B 66AD                <1> 	lodsw
 56130 0000F05D 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 56131 0000F064 740A                <1> 	je	short m_pix_op_xor_16_1 ; exclude
 56132 0000F066 663117              <1> 	xor	[edi], dx
 56133 0000F069 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 56134                              <1> m_pix_op_xor_16_1:
 56135 0000F070 83C702              <1> 	add	edi, 2 ; +2
 56136 0000F073 E2E6                <1> 	loop	m_pix_op_xor_16_0
 56137 0000F075 C3                  <1> 	retn
 56138                              <1> m_pix_op_xor_3:
 56139                              <1> 	; 32 bit true colors
 56140                              <1> 	;jmp	short m_pix_op_xor_32
 56141                              <1> m_pix_op_xor_32:
 56142                              <1> 	; 32 bit true colors
 56143 0000F076 89C2                <1> 	mov	edx, eax ; new color
 56144                              <1> m_pix_op_xor_32_0:
 56145 0000F078 AD                  <1> 	lodsd 
 56146 0000F079 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56147 0000F07F 7409                <1> 	je	short m_pix_op_xor_32_1 ; exclude
 56148 0000F081 3117                <1> 	xor	[edi], edx ; 25/02/2021	
 56149 0000F083 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56150                              <1> m_pix_op_xor_32_1:
 56151 0000F08A 83C704              <1> 	add	edi, 4 ; +4
 56152 0000F08D E2E9                <1> 	loop	m_pix_op_xor_32_0
 56153 0000F08F C3                  <1> 	retn
 56154                              <1> 
 56155                              <1> m_pix_op_xor_w:
 56156                              <1> 	; 06/02/2021
 56157                              <1> 	; XOR COLOR (MASKED, window)
 56158                              <1> 	;
 56159                              <1> 	; jump from pix_op_xor_w
 56160                              <1> 	;
 56161                              <1> 	; INPUT:
 56162                              <1> 	;   ecx = bytes per row (to be applied)
 56163                              <1> 	;   edx = screen width in bytes
 56164                              <1> 	;   ebx = row count
 56165                              <1> 	;   eax = color
 56166                              <1> 	;
 56167                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56168                              <1> 	;
 56169                              <1> 	; OUTPUT:
 56170                              <1> 	; 	[u.r0] will be > 0 if succesful
 56171                              <1> 
 56172                              <1> 	; window
 56173                              <1> 	;mov	edi, [v_str] ; LFB start address
 56174                              <1> 	;mov	esi, edi 
 56175                              <1> 
 56176 0000F090 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56177 0000F097 7707                <1> 	ja	short m_pix_op_xor_w_1
 56178                              <1> 
 56179                              <1> 	; 256 colors (8bpp)
 56180 0000F099 BD[0CF00000]        <1> 	mov	ebp, m_pix_op_xor_8
 56181 0000F09E EB1E                <1> 	jmp	short m_pix_op_xor_w_4
 56182                              <1> 			
 56183                              <1> m_pix_op_xor_w_1:
 56184 0000F0A0 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56185 0000F0A7 7710                <1> 	ja	short m_pix_op_xor_w_3 ; 32bpp
 56186 0000F0A9 7207                <1> 	jb	short m_pix_op_xor_w_2 ; 16bpp
 56187                              <1> 
 56188                              <1> 	; 24 bit true colors
 56189 0000F0AB BD[2EF00000]        <1> 	mov	ebp, m_pix_op_xor_24
 56190 0000F0B0 EB0C                <1> 	jmp	short m_pix_op_xor_w_4
 56191                              <1> 
 56192                              <1> 	; 65536 colors (16bpp)
 56193                              <1> m_pix_op_xor_w_2:
 56194 0000F0B2 BD[59F00000]        <1> 	mov	ebp, m_pix_op_xor_16
 56195 0000F0B7 EB05                <1> 	jmp	short m_pix_op_xor_w_4
 56196                              <1> 
 56197                              <1> 	; 32 bit true colors
 56198                              <1> m_pix_op_xor_w_3:
 56199 0000F0B9 BD[76F00000]        <1> 	mov	ebp, m_pix_op_xor_32
 56200                              <1> m_pix_op_xor_w_4:
 56201 0000F0BE E917FBFFFF          <1> 	jmp	m_pix_op_xor_w_x
 56202                              <1> 
 56203                              <1> m_pix_op_not:
 56204                              <1> 	; 06/02/2021
 56205                              <1> 	; NOT COLOR (MASKED, full screen)
 56206                              <1> 	;
 56207                              <1> 	; jump from pix_op_not
 56208                              <1> 	;
 56209                              <1> 	; INPUT:
 56210                              <1> 	;   ecx = [v_siz] ; display page pixel count
 56211                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 56212                              <1> 	;
 56213                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56214                              <1> 	;
 56215                              <1> 	; OUTPUT:
 56216                              <1> 	; 	[u.r0] will be > 0 if succesful
 56217                              <1> 	
 56218                              <1> 	; Full screen
 56219                              <1> m_pix_op_not_0:
 56220 0000F0C3 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56221 0000F0CA 7715                <1> 	ja	short m_pix_op_not_1
 56222                              <1> 	; 256 colors (8bpp)
 56223                              <1> 	;jmp	short m_pix_op_not_8
 56224                              <1> m_pix_op_not_8:
 56225                              <1> 	; 8 bit colors (256 colors)
 56226 0000F0CC AC                  <1> 	lodsb 
 56227 0000F0CD 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 56228 0000F0D3 7408                <1> 	je	short m_pix_op_not_8_1 ; exclude
 56229 0000F0D5 F617                <1> 	not	byte [edi]
 56230 0000F0D7 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 56231                              <1> m_pix_op_not_8_1:
 56232 0000F0DD 47                  <1> 	inc	edi
 56233 0000F0DE E2EC                <1> 	loop	m_pix_op_not_8
 56234 0000F0E0 C3                  <1> 	retn
 56235                              <1> m_pix_op_not_1:
 56236 0000F0E1 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56237 0000F0E8 7746                <1> 	ja	short m_pix_op_not_3 ; 32bpp	
 56238 0000F0EA 7229                <1> 	jb	short m_pix_op_not_2 ; 16bpp
 56239                              <1> 	; 24 bit true colors
 56240                              <1> 	;jmp	short m_pix_op_not_24
 56241                              <1> m_pix_op_not_24:
 56242                              <1> 	; 24 bit true colors
 56243 0000F0EC 66AD                <1> 	lodsw
 56244 0000F0EE C1E010              <1> 	shl	eax, 16
 56245 0000F0F1 AC                  <1> 	lodsb
 56246 0000F0F2 C1C010              <1> 	rol	eax, 16	
 56247 0000F0F5 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56248 0000F0FB 7412                <1> 	je	short m_pix_op_not_24_1 ; exclude
 56249 0000F0FD F7D0                <1> 	not	eax
 56250 0000F0FF 668907              <1> 	mov	[edi], ax
 56251 0000F102 C1E810              <1> 	shr	eax, 16
 56252 0000F105 884702              <1> 	mov	[edi+2], al
 56253 0000F108 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 56254                              <1> m_pix_op_not_24_1:
 56255 0000F10F 83C703              <1> 	add	edi, 3 ; +3
 56256 0000F112 E2D8                <1> 	loop	m_pix_op_not_24
 56257 0000F114 C3                  <1> 	retn
 56258                              <1> 	; 65536 colors (16bpp)
 56259                              <1> m_pix_op_not_2:
 56260                              <1> 	;jmp	short m_pix_op_not_16
 56261                              <1> m_pix_op_not_16:
 56262                              <1> 	; 16 bit colors (65536 colors)
 56263 0000F115 66AD                <1> 	lodsw
 56264 0000F117 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 56265 0000F11E 740A                <1> 	je	short m_pix_op_not_16_1 ; exclude
 56266 0000F120 66F717              <1> 	not	word [edi]
 56267 0000F123 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 56268                              <1> m_pix_op_not_16_1:
 56269 0000F12A 83C702              <1> 	add	edi, 2 ; +2
 56270 0000F12D E2E6                <1> 	loop	m_pix_op_not_16
 56271 0000F12F C3                  <1> 	retn
 56272                              <1> m_pix_op_not_3:
 56273                              <1> 	; 32 bit true colors
 56274                              <1> 	;jmp	short m_pix_op_not_32
 56275                              <1> m_pix_op_not_32:
 56276                              <1> 	; 32 bit true colors
 56277 0000F130 AD                  <1> 	lodsd 
 56278 0000F131 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56279 0000F137 7409                <1> 	je	short m_pix_op_not_32_1 ; exclude
 56280 0000F139 F717                <1> 	not	dword [edi]	
 56281 0000F13B 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56282                              <1> m_pix_op_not_32_1:
 56283 0000F142 83C704              <1> 	add	edi, 4 ; +4
 56284 0000F145 E2E9                <1> 	loop	m_pix_op_not_32
 56285 0000F147 C3                  <1> 	retn
 56286                              <1> 
 56287                              <1> m_pix_op_not_w:
 56288                              <1> 	; 06/02/2021
 56289                              <1> 	; NOT COLOR (MASKED, window)
 56290                              <1> 	;
 56291                              <1> 	; jump from pix_op_not_w
 56292                              <1> 	;
 56293                              <1> 	; INPUT:
 56294                              <1> 	;   ecx = bytes per row (to be applied)
 56295                              <1> 	;   edx = screen width in bytes
 56296                              <1> 	;   ebx = row count
 56297                              <1> 	;
 56298                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56299                              <1> 	;
 56300                              <1> 	; OUTPUT:
 56301                              <1> 	; 	[u.r0] will be > 0 if succesful
 56302                              <1> 
 56303                              <1> 	; window
 56304                              <1> 	;mov	edi, [v_str] ; LFB start address
 56305                              <1> 	;mov	esi, edi 
 56306                              <1> 
 56307 0000F148 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56308 0000F14F 7707                <1> 	ja	short m_pix_op_not_w_1
 56309                              <1> 
 56310                              <1> 	; 256 colors (8bpp)
 56311 0000F151 BD[CCF00000]        <1> 	mov	ebp, m_pix_op_not_8
 56312 0000F156 EB1E                <1> 	jmp	short m_pix_op_not_w_4
 56313                              <1> 			
 56314                              <1> m_pix_op_not_w_1:
 56315 0000F158 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56316 0000F15F 7710                <1> 	ja	short m_pix_op_not_w_3 ; 32bpp
 56317 0000F161 7207                <1> 	jb	short m_pix_op_not_w_2 ; 16bpp
 56318                              <1> 
 56319                              <1> 	; 24 bit true colors
 56320 0000F163 BD[ECF00000]        <1> 	mov	ebp, m_pix_op_not_24
 56321 0000F168 EB0C                <1> 	jmp	short m_pix_op_not_w_4
 56322                              <1> 
 56323                              <1> 	; 65536 colors (16bpp)
 56324                              <1> m_pix_op_not_w_2:
 56325 0000F16A BD[15F10000]        <1> 	mov	ebp, m_pix_op_not_16
 56326 0000F16F EB05                <1> 	jmp	short m_pix_op_not_w_4
 56327                              <1> 
 56328                              <1> 	; 32 bit true colors
 56329                              <1> m_pix_op_not_w_3:
 56330 0000F171 BD[30F10000]        <1> 	mov	ebp, m_pix_op_not_32
 56331                              <1> m_pix_op_not_w_4:
 56332 0000F176 E95FFAFFFF          <1> 	jmp	m_pix_op_not_w_x
 56333                              <1> 
 56334                              <1> m_pix_op_neg:
 56335                              <1> 	; 06/02/2021
 56336                              <1> 	; NEGATIVE COLOR (MASKED, full screen)
 56337                              <1> 	;
 56338                              <1> 	; jump from pix_op_neg
 56339                              <1> 	;
 56340                              <1> 	; INPUT:
 56341                              <1> 	;   ecx = [v_siz] ; display page pixel count
 56342                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 56343                              <1> 	;
 56344                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56345                              <1> 	;
 56346                              <1> 	; OUTPUT:
 56347                              <1> 	; 	[u.r0] will be > 0 if succesful
 56348                              <1> 	
 56349                              <1> 	; Full screen
 56350                              <1> m_pix_op_neg_0:
 56351 0000F17B 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56352 0000F182 7715                <1> 	ja	short m_pix_op_neg_1
 56353                              <1> 	; 256 colors (8bpp)
 56354                              <1> 	;jmp	short m_pix_op_neg_8
 56355                              <1> m_pix_op_neg_8:
 56356                              <1> 	; 8 bit colors (256 colors)
 56357 0000F184 AC                  <1> 	lodsb 
 56358 0000F185 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 56359 0000F18B 7408                <1> 	je	short m_pix_op_neg_8_1 ; exclude
 56360 0000F18D F61F                <1> 	neg	byte [edi]
 56361 0000F18F FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 56362                              <1> m_pix_op_neg_8_1:
 56363 0000F195 47                  <1> 	inc	edi
 56364 0000F196 E2EC                <1> 	loop	m_pix_op_neg_8
 56365 0000F198 C3                  <1> 	retn
 56366                              <1> m_pix_op_neg_1:
 56367 0000F199 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56368 0000F1A0 7746                <1> 	ja	short m_pix_op_neg_3 ; 32bpp	
 56369 0000F1A2 7229                <1> 	jb	short m_pix_op_neg_2 ; 16bpp
 56370                              <1> 	; 24 bit true colors
 56371                              <1> 	;jmp	short m_pix_op_neg_24
 56372                              <1> m_pix_op_neg_24:
 56373                              <1> 	; 24 bit true colors
 56374 0000F1A4 66AD                <1> 	lodsw
 56375 0000F1A6 C1E010              <1> 	shl	eax, 16
 56376 0000F1A9 AC                  <1> 	lodsb
 56377 0000F1AA C1C010              <1> 	rol	eax, 16	
 56378 0000F1AD 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56379 0000F1B3 7412                <1> 	je	short m_pix_op_neg_24_1 ; exclude
 56380 0000F1B5 F7D8                <1> 	neg	eax
 56381 0000F1B7 668907              <1> 	mov	[edi], ax
 56382 0000F1BA C1E810              <1> 	shr	eax, 16
 56383 0000F1BD 884702              <1> 	mov	[edi+2], al
 56384 0000F1C0 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 56385                              <1> m_pix_op_neg_24_1:
 56386 0000F1C7 83C703              <1> 	add	edi, 3 ; +3
 56387 0000F1CA E2D8                <1> 	loop	m_pix_op_neg_24
 56388 0000F1CC C3                  <1> 	retn
 56389                              <1> 	; 65536 colors (16bpp)
 56390                              <1> m_pix_op_neg_2:
 56391                              <1> 	;jmp	short m_pix_op_neg_16
 56392                              <1> m_pix_op_neg_16:
 56393                              <1> 	; 16 bit colors (65536 colors)
 56394 0000F1CD 66AD                <1> 	lodsw
 56395 0000F1CF 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 56396 0000F1D6 740A                <1> 	je	short m_pix_op_neg_16_1 ; exclude
 56397 0000F1D8 66F71F              <1> 	neg	word [edi]
 56398 0000F1DB 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 56399                              <1> m_pix_op_neg_16_1:
 56400 0000F1E2 83C702              <1> 	add	edi, 2 ; +2
 56401 0000F1E5 E2E6                <1> 	loop	m_pix_op_neg_16
 56402 0000F1E7 C3                  <1> 	retn
 56403                              <1> m_pix_op_neg_3:
 56404                              <1> 	; 32 bit true colors
 56405                              <1> 	;jmp	short m_pix_op_neg_32
 56406                              <1> m_pix_op_neg_32:
 56407                              <1> 	; 32 bit true colors
 56408 0000F1E8 AD                  <1> 	lodsd 
 56409 0000F1E9 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56410 0000F1EF 7409                <1> 	je	short m_pix_op_neg_32_1 ; exclude
 56411 0000F1F1 F71F                <1> 	neg	dword [edi]	
 56412 0000F1F3 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56413                              <1> m_pix_op_neg_32_1:
 56414 0000F1FA 83C704              <1> 	add	edi, 4 ; +4
 56415 0000F1FD E2E9                <1> 	loop	m_pix_op_neg_32
 56416 0000F1FF C3                  <1> 	retn
 56417                              <1> 
 56418                              <1> m_pix_op_neg_w:
 56419                              <1> 	; 06/02/2021
 56420                              <1> 	; NEGATIVE COLOR (MASKED, window)
 56421                              <1> 	;
 56422                              <1> 	; jump from pix_op_neg_w
 56423                              <1> 	;
 56424                              <1> 	; INPUT:
 56425                              <1> 	;   ecx = bytes per row (to be applied)
 56426                              <1> 	;   edx = screen width in bytes
 56427                              <1> 	;   ebx = row count
 56428                              <1> 	;
 56429                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56430                              <1> 	;
 56431                              <1> 	; OUTPUT:
 56432                              <1> 	; 	[u.r0] will be > 0 if succesful
 56433                              <1> 
 56434                              <1> 	; window
 56435                              <1> 	;mov	edi, [v_str] ; LFB start address
 56436                              <1> 	;mov	esi, edi 
 56437                              <1> 
 56438 0000F200 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56439 0000F207 7707                <1> 	ja	short m_pix_op_neg_w_1
 56440                              <1> 
 56441                              <1> 	; 256 colors (8bpp)
 56442 0000F209 BD[84F10000]        <1> 	mov	ebp, m_pix_op_neg_8
 56443 0000F20E EB1E                <1> 	jmp	short m_pix_op_neg_w_4
 56444                              <1> 			
 56445                              <1> m_pix_op_neg_w_1:
 56446 0000F210 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56447 0000F217 7710                <1> 	ja	short m_pix_op_neg_w_3 ; 32bpp
 56448 0000F219 7207                <1> 	jb	short m_pix_op_neg_w_2 ; 16bpp
 56449                              <1> 
 56450                              <1> 	; 24 bit true colors
 56451 0000F21B BD[A4F10000]        <1> 	mov	ebp, m_pix_op_neg_24
 56452 0000F220 EB0C                <1> 	jmp	short m_pix_op_neg_w_4
 56453                              <1> 
 56454                              <1> 	; 65536 colors (16bpp)
 56455                              <1> m_pix_op_neg_w_2:
 56456 0000F222 BD[CDF10000]        <1> 	mov	ebp, m_pix_op_neg_16
 56457 0000F227 EB05                <1> 	jmp	short m_pix_op_neg_w_4
 56458                              <1> 
 56459                              <1> 	; 32 bit true colors
 56460                              <1> m_pix_op_neg_w_3:
 56461 0000F229 BD[E8F10000]        <1> 	mov	ebp, m_pix_op_neg_32
 56462                              <1> m_pix_op_neg_w_4:
 56463 0000F22E E9A7F9FFFF          <1> 	jmp	m_pix_op_neg_w_x
 56464                              <1> 
 56465                              <1> m_pix_op_inc:
 56466                              <1> 	; 06/02/2021
 56467                              <1> 	; INCREASE COLOR (MASKED, full screen)
 56468                              <1> 	;
 56469                              <1> 	; jump from pix_op_inc
 56470                              <1> 	;
 56471                              <1> 	; INPUT:
 56472                              <1> 	;   ecx = [v_siz] ; display page pixel count
 56473                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 56474                              <1> 	;
 56475                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56476                              <1> 	;
 56477                              <1> 	; OUTPUT:
 56478                              <1> 	; 	[u.r0] will be > 0 if succesful
 56479                              <1> 	
 56480                              <1> 	; Full screen
 56481                              <1> m_pix_op_inc_0:
 56482 0000F233 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56483 0000F23A 7719                <1> 	ja	short m_pix_op_inc_1
 56484                              <1> 	; 256 colors (8bpp)
 56485                              <1> 	;jmp	short m_pix_op_inc_8
 56486                              <1> m_pix_op_inc_8:
 56487                              <1> 	; 8 bit colors (256 colors)
 56488 0000F23C AC                  <1> 	lodsb 
 56489 0000F23D 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 56490 0000F243 740C                <1> 	je	short m_pix_op_inc_8_1 ; exclude
 56491 0000F245 FE07                <1> 	inc	byte [edi]
 56492 0000F247 7502                <1> 	jnz	short m_pix_op_inc_8_0
 56493 0000F249 FE0F                <1> 	dec	byte [edi]
 56494                              <1> m_pix_op_inc_8_0:
 56495 0000F24B FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 56496                              <1> m_pix_op_inc_8_1:
 56497 0000F251 47                  <1> 	inc	edi
 56498 0000F252 E2E8                <1> 	loop	m_pix_op_inc_8
 56499 0000F254 C3                  <1> 	retn
 56500                              <1> m_pix_op_inc_1:
 56501 0000F255 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56502 0000F25C 7752                <1> 	ja	short m_pix_op_inc_3 ; 32bpp	
 56503 0000F25E 7230                <1> 	jb	short m_pix_op_inc_2 ; 16bpp
 56504                              <1> 	; 24 bit true colors
 56505                              <1> 	;jmp	short m_pix_op_inc_24
 56506                              <1> m_pix_op_inc_24:
 56507                              <1> 	; 24 bit true colors
 56508 0000F260 66AD                <1> 	lodsw
 56509 0000F262 C1E010              <1> 	shl	eax, 16
 56510 0000F265 AC                  <1> 	lodsb
 56511 0000F266 C1C010              <1> 	rol	eax, 16	
 56512 0000F269 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56513 0000F26F 7419                <1> 	je	short m_pix_op_inc_24_1 ; exclude
 56514 0000F271 40                  <1> 	inc	eax
 56515 0000F272 3DFFFFFF00          <1> 	cmp	eax, 0FFFFFFh
 56516 0000F277 7601                <1> 	jna	short m_pix_op_inc_24_0
 56517 0000F279 48                  <1> 	dec	eax 
 56518                              <1> m_pix_op_inc_24_0:
 56519 0000F27A 668907              <1> 	mov	[edi], ax
 56520 0000F27D C1E810              <1> 	shr	eax, 16
 56521 0000F280 884702              <1> 	mov	[edi+2], al
 56522 0000F283 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 56523                              <1> m_pix_op_inc_24_1:
 56524 0000F28A 83C703              <1> 	add	edi, 3 ; +3
 56525 0000F28D E2D1                <1> 	loop	m_pix_op_inc_24
 56526 0000F28F C3                  <1> 	retn
 56527                              <1> 	; 65536 colors (16bpp)
 56528                              <1> m_pix_op_inc_2:
 56529                              <1> 	;jmp	short m_pix_op_inc_16
 56530                              <1> m_pix_op_inc_16:
 56531                              <1> 	; 16 bit colors (65536 colors)
 56532 0000F290 66AD                <1> 	lodsw
 56533 0000F292 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 56534 0000F299 740F                <1> 	je	short m_pix_op_inc_16_1 ; exclude
 56535 0000F29B 66FF07              <1> 	inc	word [edi]
 56536 0000F29E 7503                <1> 	jnz	short m_pix_op_inc_16_0
 56537 0000F2A0 66FF0F              <1> 	dec	word [edi]
 56538                              <1> m_pix_op_inc_16_0:
 56539 0000F2A3 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 56540                              <1> m_pix_op_inc_16_1:
 56541 0000F2AA 83C702              <1> 	add	edi, 2 ; +2
 56542 0000F2AD E2E1                <1> 	loop	m_pix_op_inc_16
 56543 0000F2AF C3                  <1> 	retn
 56544                              <1> m_pix_op_inc_3:
 56545                              <1> 	; 32 bit true colors
 56546                              <1> 	;jmp	short m_pix_op_inc_32
 56547                              <1> m_pix_op_inc_32:
 56548                              <1> 	; 32 bit true colors
 56549 0000F2B0 AD                  <1> 	lodsd 
 56550 0000F2B1 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56551 0000F2B7 740D                <1> 	je	short m_pix_op_inc_32_1 ; exclude
 56552 0000F2B9 FF07                <1> 	inc	dword [edi]
 56553 0000F2BB 7502                <1> 	jnz	short m_pix_op_inc_32_0
 56554 0000F2BD FF0F                <1> 	dec	dword [edi]
 56555                              <1> m_pix_op_inc_32_0:	
 56556 0000F2BF 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56557                              <1> m_pix_op_inc_32_1:
 56558 0000F2C6 83C704              <1> 	add	edi, 4 ; +4
 56559 0000F2C9 E2E5                <1> 	loop	m_pix_op_inc_32
 56560 0000F2CB C3                  <1> 	retn
 56561                              <1> 
 56562                              <1> m_pix_op_inc_w:
 56563                              <1> 	; 06/02/2021
 56564                              <1> 	; INCREASE COLOR (MASKED, window)
 56565                              <1> 	;
 56566                              <1> 	; jump from pix_op_inc_w
 56567                              <1> 	;
 56568                              <1> 	; INPUT:
 56569                              <1> 	;   ecx = bytes per row (to be applied)
 56570                              <1> 	;   edx = screen width in bytes
 56571                              <1> 	;   ebx = row count
 56572                              <1> 	;
 56573                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56574                              <1> 	;
 56575                              <1> 	; OUTPUT:
 56576                              <1> 	; 	[u.r0] will be > 0 if succesful
 56577                              <1> 
 56578                              <1> 	; window
 56579                              <1> 	;mov	edi, [v_str] ; LFB start address
 56580                              <1> 	;mov	esi, edi 
 56581                              <1> 
 56582 0000F2CC 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56583 0000F2D3 7707                <1> 	ja	short m_pix_op_inc_w_1
 56584                              <1> 
 56585                              <1> 	; 256 colors (8bpp)
 56586 0000F2D5 BD[3CF20000]        <1> 	mov	ebp, m_pix_op_inc_8
 56587 0000F2DA EB1E                <1> 	jmp	short m_pix_op_inc_w_4
 56588                              <1> 			
 56589                              <1> m_pix_op_inc_w_1:
 56590 0000F2DC 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56591 0000F2E3 7710                <1> 	ja	short m_pix_op_inc_w_3 ; 32bpp
 56592 0000F2E5 7207                <1> 	jb	short m_pix_op_inc_w_2 ; 16bpp
 56593                              <1> 
 56594                              <1> 	; 24 bit true colors
 56595 0000F2E7 BD[60F20000]        <1> 	mov	ebp, m_pix_op_inc_24
 56596 0000F2EC EB0C                <1> 	jmp	short m_pix_op_inc_w_4
 56597                              <1> 
 56598                              <1> 	; 65536 colors (16bpp)
 56599                              <1> m_pix_op_inc_w_2:
 56600 0000F2EE BD[90F20000]        <1> 	mov	ebp, m_pix_op_inc_16
 56601 0000F2F3 EB05                <1> 	jmp	short m_pix_op_inc_w_4
 56602                              <1> 
 56603                              <1> 	; 32 bit true colors
 56604                              <1> m_pix_op_inc_w_3:
 56605 0000F2F5 BD[B0F20000]        <1> 	mov	ebp, m_pix_op_inc_32
 56606                              <1> m_pix_op_inc_w_4:
 56607 0000F2FA E9DBF8FFFF          <1> 	jmp	m_pix_op_inc_w_x
 56608                              <1> 
 56609                              <1> m_pix_op_dec:
 56610                              <1> 	; 06/02/2021
 56611                              <1> 	; DECREASE COLOR (MASKED, full screen)
 56612                              <1> 	;
 56613                              <1> 	; jump from pix_op_dec
 56614                              <1> 	;
 56615                              <1> 	; INPUT:
 56616                              <1> 	;   ecx = [v_siz] ; display page pixel count
 56617                              <1> 	;   esi = edi = [v_mem] ; LFB start address
 56618                              <1> 	;
 56619                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56620                              <1> 	;
 56621                              <1> 	; OUTPUT:
 56622                              <1> 	; 	[u.r0] will be > 0 if succesful
 56623                              <1> 	
 56624                              <1> 	; Full screen
 56625                              <1> m_pix_op_dec_0:
 56626 0000F2FF 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56627 0000F306 7719                <1> 	ja	short m_pix_op_dec_1
 56628                              <1> 	; 256 colors (8bpp)
 56629                              <1> 	;jmp	short m_pix_op_dec_8
 56630                              <1> m_pix_op_dec_8:
 56631                              <1> 	; 8 bit colors (256 colors)
 56632 0000F308 AC                  <1> 	lodsb 
 56633 0000F309 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
 56634 0000F30F 740C                <1> 	je	short m_pix_op_dec_8_1 ; exclude
 56635 0000F311 FE0F                <1> 	dec	byte [edi]
 56636 0000F313 7902                <1> 	jns	short m_pix_op_dec_8_0
 56637 0000F315 FE07                <1> 	inc	byte [edi]
 56638                              <1> m_pix_op_dec_8_0:
 56639 0000F317 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
 56640                              <1> m_pix_op_dec_8_1:
 56641 0000F31D 47                  <1> 	inc	edi
 56642 0000F31E E2E8                <1> 	loop	m_pix_op_dec_8
 56643 0000F320 C3                  <1> 	retn
 56644                              <1> m_pix_op_dec_1:
 56645 0000F321 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56646 0000F328 774D                <1> 	ja	short m_pix_op_dec_3 ; 32bpp	
 56647 0000F32A 722B                <1> 	jb	short m_pix_op_dec_2 ; 16bpp
 56648                              <1> 	; 24 bit true colors
 56649                              <1> 	;jmp	short m_pix_op_dec_24
 56650                              <1> m_pix_op_dec_24:
 56651                              <1> 	; 24 bit true colors
 56652 0000F32C 66AD                <1> 	lodsw
 56653 0000F32E C1E010              <1> 	shl	eax, 16
 56654 0000F331 AC                  <1> 	lodsb
 56655 0000F332 C1C010              <1> 	rol	eax, 16	
 56656 0000F335 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56657 0000F33B 7414                <1> 	je	short m_pix_op_dec_24_1 ; exclude
 56658 0000F33D 48                  <1> 	dec	eax
 56659 0000F33E 7901                <1> 	jns	short m_pix_op_dec_24_0
 56660 0000F340 40                  <1> 	inc	eax 
 56661                              <1> m_pix_op_dec_24_0:
 56662 0000F341 668907              <1> 	mov	[edi], ax
 56663 0000F344 C1E810              <1> 	shr	eax, 16
 56664 0000F347 884702              <1> 	mov	[edi+2], al
 56665 0000F34A 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
 56666                              <1> m_pix_op_dec_24_1:
 56667 0000F351 83C703              <1> 	add	edi, 3 ; +3
 56668 0000F354 E2D6                <1> 	loop	m_pix_op_dec_24
 56669 0000F356 C3                  <1> 	retn
 56670                              <1> 	; 65536 colors (16bpp)
 56671                              <1> m_pix_op_dec_2:
 56672                              <1> 	;jmp	short m_pix_op_dec_16
 56673                              <1> m_pix_op_dec_16:
 56674                              <1> 	; 16 bit colors (65536 colors)
 56675 0000F357 66AD                <1> 	lodsw
 56676 0000F359 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
 56677 0000F360 740F                <1> 	je	short m_pix_op_dec_16_1 ; exclude
 56678 0000F362 66FF0F              <1> 	dec	word [edi]
 56679 0000F365 7903                <1> 	jns	short m_pix_op_dec_16_0
 56680 0000F367 66FF07              <1> 	inc	word [edi]
 56681                              <1> m_pix_op_dec_16_0:
 56682 0000F36A 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
 56683                              <1> m_pix_op_dec_16_1:
 56684 0000F371 83C702              <1> 	add	edi, 2 ; +2
 56685 0000F374 E2E1                <1> 	loop	m_pix_op_dec_16
 56686 0000F376 C3                  <1> 	retn
 56687                              <1> m_pix_op_dec_3:
 56688                              <1> 	; 32 bit true colors
 56689                              <1> 	;jmp	short m_pix_op_dec_32
 56690                              <1> m_pix_op_dec_32:
 56691                              <1> 	; 32 bit true colors
 56692 0000F377 AD                  <1> 	lodsd 
 56693 0000F378 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
 56694 0000F37E 740D                <1> 	je	short m_pix_op_dec_32_1 ; exclude
 56695 0000F380 FF0F                <1> 	dec	dword [edi]
 56696 0000F382 7902                <1> 	jns	short m_pix_op_dec_32_0
 56697 0000F384 FF07                <1> 	inc	dword [edi]
 56698                              <1> m_pix_op_dec_32_0:	
 56699 0000F386 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
 56700                              <1> m_pix_op_dec_32_1:
 56701 0000F38D 83C704              <1> 	add	edi, 4 ; +4
 56702 0000F390 E2E5                <1> 	loop	m_pix_op_dec_32
 56703 0000F392 C3                  <1> 	retn
 56704                              <1> 
 56705                              <1> m_pix_op_dec_w:
 56706                              <1> 	; 06/02/2021
 56707                              <1> 	; DECREASE COLOR (MASKED, window)
 56708                              <1> 	;
 56709                              <1> 	; jump from pix_op_dec_w
 56710                              <1> 	;
 56711                              <1> 	; INPUT:
 56712                              <1> 	;   ecx = bytes per row (to be applied)
 56713                              <1> 	;   edx = screen width in bytes
 56714                              <1> 	;   ebx = row count
 56715                              <1> 	;
 56716                              <1> 	;   [maskcolor] = mask color (to be excluded)
 56717                              <1> 	;
 56718                              <1> 	; OUTPUT:
 56719                              <1> 	; 	[u.r0] will be > 0 if succesful
 56720                              <1> 
 56721                              <1> 	; window
 56722                              <1> 	;mov	edi, [v_str] ; LFB start address
 56723                              <1> 	;mov	esi, edi 
 56724                              <1> 
 56725 0000F393 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 56726 0000F39A 7707                <1> 	ja	short m_pix_op_dec_w_1
 56727                              <1> 
 56728                              <1> 	; 256 colors (8bpp)
 56729 0000F39C BD[08F30000]        <1> 	mov	ebp, m_pix_op_dec_8
 56730 0000F3A1 EB1E                <1> 	jmp	short m_pix_op_dec_w_4
 56731                              <1> 			
 56732                              <1> m_pix_op_dec_w_1:
 56733 0000F3A3 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 56734 0000F3AA 7710                <1> 	ja	short m_pix_op_dec_w_3 ; 32bpp
 56735 0000F3AC 7207                <1> 	jb	short m_pix_op_dec_w_2 ; 16bpp
 56736                              <1> 
 56737                              <1> 	; 24 bit true colors
 56738 0000F3AE BD[2CF30000]        <1> 	mov	ebp, m_pix_op_dec_24
 56739 0000F3B3 EB0C                <1> 	jmp	short m_pix_op_dec_w_4
 56740                              <1> 
 56741                              <1> 	; 65536 colors (16bpp)
 56742                              <1> m_pix_op_dec_w_2:
 56743 0000F3B5 BD[57F30000]        <1> 	mov	ebp, m_pix_op_dec_16
 56744 0000F3BA EB05                <1> 	jmp	short m_pix_op_dec_w_4
 56745                              <1> 
 56746                              <1> 	; 32 bit true colors
 56747                              <1> m_pix_op_dec_w_3:
 56748 0000F3BC BD[77F30000]        <1> 	mov	ebp, m_pix_op_dec_32
 56749                              <1> m_pix_op_dec_w_4:
 56750 0000F3C1 E914F8FFFF          <1> 	jmp	m_pix_op_dec_w_x
 56751                              <1> 
 56752                              <1> sysvideo_39:
 56753                              <1> 	; 15/02/2021
 56754                              <1> 	; 07/02/2021, 08/02/2021
 56755                              <1> 	; 03/01/2021, 04/01/2021
 56756                              <1> 	; 23/11/2020
 56757                              <1> 	; BH = 3
 56758                              <1> 	; PIXEL READ/WRITE
 56759                              <1> 	
 56760                              <1> 	; 07/02/2021
 56761                              <1> 	; 04/01/2021 (TRDOS 386 v2.0.3)
 56762 0000F3C6 80FB03              <1> 	cmp	bl, 3
 56763 0000F3C9 761A                <1> 	jna	short sysvideo_39_1
 56764                              <1> 	; 07/02/2021
 56765 0000F3CB 80FB06              <1> 	cmp	bl, 6
 56766 0000F3CE 7705                <1> 	ja	short sysvideo_39_0
 56767 0000F3D0 E91A010000          <1> 	jmp	sysvideo_39_31
 56768                              <1> sysvideo_39_0:
 56769                              <1> 	; error
 56770 0000F3D5 B3FF                <1> 	mov	bl, 0FFh
 56771 0000F3D7 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 56772 0000F3DD 895D10              <1> 	mov	[ebp+16], ebx ; EBX
 56773 0000F3E0 E90DD9FFFF          <1> 	jmp	sysret
 56774                              <1> sysvideo_39_1:
 56775 0000F3E5 803D[9E660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh
 56776 0000F3EC 7312                <1> 	jnb	short sysvideo_39_2 ; SVGA (VESA VBE) video mode
 56777                              <1> 
 56778                              <1> 	; Std VGA or CGA mode
 56779 0000F3EE 81C200000A00        <1> 	add	edx, 0A0000h
 56780 0000F3F4 72DF                <1> 	jc	short sysvideo_39_0
 56781 0000F3F6 81FAFFFF0A00        <1> 	cmp	edx, 0AFFFFh
 56782 0000F3FC 77D7                <1> 	ja	short sysvideo_39_0
 56783 0000F3FE EB1E                <1> 	jmp	short sysvideo_39_3 ; 8bpp
 56784                              <1> 
 56785                              <1> sysvideo_39_2:
 56786                              <1> 	; use current vbe (svga) video mode
 56787                              <1> 
 56788                              <1> 	; get LFB address
 56789 0000F400 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 56790 0000F405 09C0                <1> 	or	eax, eax
 56791 0000F407 74CC                <1> 	jz	short sysvideo_39_0
 56792 0000F409 3B15[E40F0300]      <1> 	cmp	edx, [LFB_SIZE] 
 56793 0000F40F 73C4                <1> 	jnb	short sysvideo_39_0
 56794                              <1> 
 56795 0000F411 01C2                <1> 	add	edx, eax
 56796                              <1> 	;jc	short sysvideo_39_0
 56797                              <1> 
 56798                              <1> 	; Pixel read/write in VESA VBE (2/3) video mode
 56799                              <1> 	; Video memory at Linear Frame Buffer base address
 56800                              <1> 
 56801 0000F413 8A3D[EC0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
 56802                              <1> 
 56803 0000F419 80FF08              <1> 	cmp	bh, 8 ; 8bpp
 56804 0000F41C 775D                <1> 	ja	short sysvideo_39_17
 56805                              <1> 
 56806                              <1> 	; 8 bits per pixel
 56807                              <1> sysvideo_39_3:
 56808 0000F41E 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 56809 0000F421 7406                <1> 	je	short sysvideo_39_5
 56810 0000F423 7712                <1> 	ja	short sysvideo_39_8
 56811                              <1> sysvideo_39_4:
 56812                              <1> 	; read pixel (8bpp)
 56813 0000F425 8A02                <1> 	mov	al, [edx]
 56814                              <1> 	;mov	[u.r0], al
 56815                              <1> 	;jmp	sysret
 56816 0000F427 EB04                <1> 	jmp	short sysvideo_39_7
 56817                              <1> sysvideo_39_5:
 56818                              <1> 	; write pixel (8bpp)
 56819 0000F429 88C8                <1> 	mov	al, cl
 56820                              <1> sysvideo_39_6:
 56821 0000F42B 8802                <1> 	mov	[edx], al
 56822                              <1> sysvideo_39_7:
 56823 0000F42D A2[1C010300]        <1> 	mov	[u.r0], al
 56824 0000F432 E9BBD8FFFF          <1> 	jmp	sysret
 56825                              <1> sysvideo_39_8:
 56826 0000F437 80FB03              <1> 	cmp	bl, 3 ; mix
 56827 0000F43A 7208                <1> 	jb	short sysvideo_39_9
 56828                              <1> 	; mix  pixel colors (8bpp)
 56829 0000F43C 8A02                <1> 	mov	al, [edx]
 56830 0000F43E 00C8                <1> 	add	al, cl
 56831 0000F440 D0D8                <1> 	rcr	al, 1
 56832 0000F442 EBE7                <1> 	jmp	short sysvideo_39_6
 56833                              <1> sysvideo_39_9:
 56834                              <1> 	 ; swap pixel colors (8bpp)
 56835 0000F444 88C8                <1> 	mov	al, cl
 56836 0000F446 8602                <1> 	xchg	[edx], al
 56837 0000F448 EBE3                <1> 	jmp	short sysvideo_39_7
 56838                              <1> 
 56839                              <1> 	; 16 bits per pixel
 56840                              <1> sysvideo_39_10:
 56841 0000F44A 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 56842 0000F44D 7406                <1> 	je	short sysvideo_39_12
 56843 0000F44F 7714                <1> 	ja	short sysvideo_39_15
 56844                              <1> sysvideo_39_11:
 56845                              <1> 	; read pixel (16bpp)
 56846 0000F451 8B02                <1> 	mov	eax, [edx]
 56847                              <1> 	;mov	[u.r0], ax
 56848                              <1> 	;jmp	sysret
 56849 0000F453 EB05                <1> 	jmp	short sysvideo_39_14
 56850                              <1> sysvideo_39_12:
 56851                              <1> 	; write pixel (16bpp)
 56852 0000F455 89C8                <1> 	mov	eax, ecx
 56853                              <1> sysvideo_39_13:
 56854 0000F457 668902              <1> 	mov	[edx], ax
 56855                              <1> sysvideo_39_14:
 56856 0000F45A 66A3[1C010300]      <1> 	mov	[u.r0], ax
 56857 0000F460 E98DD8FFFF          <1> 	jmp	sysret
 56858                              <1> sysvideo_39_15:
 56859 0000F465 80FB03              <1> 	cmp	bl, 3 ; mix
 56860 0000F468 720A                <1> 	jb	short sysvideo_39_16
 56861                              <1> 	; mix  pixel colors (16bpp)
 56862 0000F46A 8B02                <1> 	mov	eax, [edx]
 56863 0000F46C 6601C8              <1> 	add	ax, cx
 56864 0000F46F 66D1D8              <1> 	rcr	ax, 1
 56865 0000F472 EBE3                <1> 	jmp	short sysvideo_39_13
 56866                              <1> sysvideo_39_16:
 56867                              <1> 	 ; swap pixel colors (16bpp)
 56868 0000F474 89C8                <1> 	mov	eax, ecx
 56869 0000F476 668702              <1> 	xchg	[edx], ax
 56870 0000F479 EBDF                <1> 	jmp	short sysvideo_39_14
 56871                              <1> sysvideo_39_17:
 56872 0000F47B 80FF18              <1> 	cmp	bh, 24
 56873 0000F47E 7743                <1> 	ja	short sysvideo_39_24
 56874 0000F480 72C8                <1> 	jb	short sysvideo_39_10  
 56875                              <1> 	
 56876                              <1> 	; 24 bits per pixel
 56877 0000F482 81E1FFFFFF00        <1> 	and	ecx, 0FFFFFFh
 56878 0000F488 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 56879 0000F48B 7406                <1> 	je	short sysvideo_39_19
 56880 0000F48D 7712                <1> 	ja	short sysvideo_39_22
 56881                              <1> sysvideo_39_18:
 56882                              <1> 	; read pixel (24bpp)
 56883 0000F48F 8B02                <1> 	mov	eax, [edx]
 56884                              <1> 	;and	eax, 0FFFFFFh
 56885                              <1> 	;mov	[u.r0], eax
 56886                              <1> 	;jmp	sysret
 56887 0000F491 EB04                <1> 	jmp	short sysvideo_39_21
 56888                              <1> sysvideo_39_19:
 56889                              <1> 	; write pixel (24bpp)
 56890 0000F493 89C8                <1> 	mov	eax, ecx
 56891                              <1> sysvideo_39_20:
 56892                              <1> 	;and	eax, 0FFFFFFh
 56893 0000F495 8902                <1> 	mov	[edx], eax
 56894                              <1> sysvideo_39_21:
 56895 0000F497 A3[1C010300]        <1> 	mov	[u.r0], eax
 56896 0000F49C E951D8FFFF          <1> 	jmp	sysret
 56897                              <1> sysvideo_39_22:
 56898 0000F4A1 80FB03              <1> 	cmp	bl, 3 ; mix
 56899 0000F4A4 720D                <1> 	jb	short sysvideo_39_23
 56900                              <1> 	; mix  pixel colors (24bpp)
 56901 0000F4A6 8B02                <1> 	mov	eax, [edx]
 56902 0000F4A8 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 56903                              <1> 	;and	ecx, 0FFFFFFh
 56904 0000F4AD 01C8                <1> 	add	eax, ecx
 56905 0000F4AF D1D8                <1> 	rcr	eax, 1
 56906 0000F4B1 EBE2                <1> 	jmp	short sysvideo_39_20
 56907                              <1> sysvideo_39_23:
 56908                              <1> 	 ; swap pixel colors (24bpp)
 56909 0000F4B3 89C8                <1> 	mov	eax, ecx
 56910                              <1> 	;and	eax, 0FFFFFFh
 56911 0000F4B5 668702              <1> 	xchg	[edx], ax
 56912 0000F4B8 C1C810              <1> 	ror	eax, 16
 56913 0000F4BB 884202              <1> 	mov	[edx+2], al	
 56914 0000F4BE C1C010              <1> 	rol	eax, 16
 56915 0000F4C1 EBD4                <1> 	jmp	short sysvideo_39_21
 56916                              <1> 
 56917                              <1> 	; 32 bits per pixel
 56918                              <1> sysvideo_39_24:
 56919 0000F4C3 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
 56920 0000F4C6 7406                <1> 	je	short sysvideo_39_26
 56921 0000F4C8 7712                <1> 	ja	short sysvideo_39_29
 56922                              <1> sysvideo_39_25:
 56923                              <1> 	; read pixel (32bpp)
 56924 0000F4CA 8B02                <1> 	mov	eax, [edx]
 56925                              <1> 	;mov	[u.r0], eax
 56926                              <1> 	;jmp	sysret
 56927 0000F4CC EB04                <1> 	jmp	short sysvideo_39_28
 56928                              <1> sysvideo_39_26:
 56929                              <1> 	; write pixel (32bpp)
 56930 0000F4CE 89C8                <1> 	mov	eax, ecx
 56931                              <1> sysvideo_39_27:
 56932 0000F4D0 8902                <1> 	mov	[edx], eax
 56933                              <1> sysvideo_39_28:
 56934 0000F4D2 A3[1C010300]        <1> 	mov	[u.r0], eax
 56935 0000F4D7 E916D8FFFF          <1> 	jmp	sysret
 56936                              <1> sysvideo_39_29:
 56937 0000F4DC 80FB03              <1> 	cmp	bl, 3 ; mix
 56938 0000F4DF 7208                <1> 	jb	short sysvideo_39_30
 56939                              <1> 	; mix  pixel colors (32bpp)
 56940 0000F4E1 8B02                <1> 	mov	eax, [edx]
 56941 0000F4E3 01C8                <1> 	add	eax, ecx
 56942 0000F4E5 D1D8                <1> 	rcr	eax, 1
 56943 0000F4E7 EBE7                <1> 	jmp	short sysvideo_39_27
 56944                              <1> sysvideo_39_30:
 56945                              <1> 	 ; swap pixel colors (32bpp)
 56946 0000F4E9 89C8                <1> 	mov	eax, ecx
 56947 0000F4EB 8702                <1> 	xchg	[edx], eax
 56948 0000F4ED EBE3                <1> 	jmp	short sysvideo_39_28
 56949                              <1> 
 56950                              <1> sysvideo_39_31:
 56951                              <1> 	; 06/03/2021
 56952                              <1> 	; 08/02/2021
 56953                              <1> 	; 07/02/2021
 56954                              <1> 	; BL = 4 -> read pixels from user defined positions
 56955                              <1> 	; BL = 5 -> write single color pixels to user defined pos.
 56956                              <1> 	; BL = 6 -> write multi color pixels to user defined pos.
 56957                              <1> 	; ECX = color (CL, CX, ECX)
 56958                              <1> 	; EDX = number of pixels
 56959                              <1> 	; ESI = user buffer contains dword pixel positions
 56960                              <1> 	;	 (and dword colors for BL input = 6)
 56961                              <1> 	; EDI = user's pixel color buff (destination) for BL = 4
 56962                              <1> 
 56963 0000F4EF 890D[4E100300]      <1> 	mov	[maskcolor], ecx
 56964 0000F4F5 89D5                <1> 	mov	ebp, edx ; number of pixels    
 56965 0000F4F7 803D[9E660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; SVGA flag
 56966 0000F4FE 7317                <1> 	jnb	short sysvideo_39_33 ; SVGA (VESA VBE mode)
 56967                              <1> 	; Standard VGA mode
 56968 0000F500 B900000100          <1> 	mov	ecx, 65536 ; Video page size (maximum)
 56969 0000F505 39CA                <1> 	cmp	edx, ecx
 56970 0000F507 7709                <1> 	ja	short sysvideo_39_32 ; abnormal value !
 56971 0000F509 B800000A00          <1> 	mov	eax, 0A0000h ; Video page start address
 56972 0000F50E B708                <1> 	mov	bh, 8  ; 8 bits per pixel (256 colors)
 56973 0000F510 EB35                <1> 	jmp	short sysvideo_39_34
 56974                              <1> sysvideo_39_32:
 56975                              <1> 	; nonsense! (edx has abnormal value)
 56976 0000F512 E9DBD7FFFF          <1> 	jmp	sysret	
 56977                              <1> sysvideo_39_33:
 56978                              <1> 	; 06/03/2021
 56979 0000F517 8A3D[EC0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
 56980 0000F51D 80FF08              <1> 	cmp	bh, 8
 56981 0000F520 7412                <1> 	je	short sysvideo_39_81 ; 8bpp
 56982 0000F522 89D0                <1> 	mov	eax, edx
 56983 0000F524 80FF10              <1> 	cmp	bh, 16
 56984 0000F527 7409                <1> 	je	short sysvideo_39_80 ; 16bpp
 56985 0000F529 D1E2                <1> 	shl	edx, 1
 56986 0000F52B 80FF20              <1> 	cmp	bh, 32
 56987 0000F52E 7502                <1> 	jne	short sysvideo_39_80 ; 24bpp
 56988 0000F530 D1E0                <1> 	shl	eax, 1
 56989                              <1> sysvideo_39_80:	
 56990 0000F532 01C2                <1> 	add	edx, eax
 56991                              <1> 	; edx = number of bytes
 56992                              <1> sysvideo_39_81:
 56993                              <1> 	; get LFB address
 56994 0000F534 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 56995 0000F539 09C0                <1> 	or	eax, eax
 56996 0000F53B 74D5                <1> 	jz	short sysvideo_39_32 ; LFB is not ready !
 56997 0000F53D 8B0D[E40F0300]      <1> 	mov	ecx, [LFB_SIZE]
 56998 0000F543 39CA                <1> 	cmp	edx, ecx 
 56999 0000F545 77CB                <1> 	ja	short sysvideo_39_32 ; abnormal value !
 57000                              <1> 
 57001                              <1> 	; 02/03/2021
 57002                              <1> 	; 08/02/2021
 57003                              <1> 	;mov	ebp, edx ; pixel count  
 57004                              <1> 	;shl	ebp, 2 ; byte count (pixel pos: 4 bytes)
 57005                              <1> 
 57006                              <1> 	; 06/03/2021
 57007                              <1> 	; bits per pixel (pixel color size)
 57008                              <1> 	;mov	bh, [LFB_Info+LFBINFO.bpp]	
 57009                              <1> sysvideo_39_34:
 57010 0000F547 C1E502              <1> 	shl	ebp, 2 ; 15/02/2021 (byte count)	
 57011 0000F54A A3[3E100300]        <1> 	mov	[v_mem], eax ; Save video page start address
 57012 0000F54F 88DE                <1> 	mov	dh, bl ; sub function
 57013                              <1> 	; 06/03/2021
 57014 0000F551 883D[3D100300]      <1> 	mov	[v_bpp], bh ; bits per pixel (color size)
 57015                              <1> 	;mov	ebx, [LFB_SIZE]
 57016 0000F557 89CB                <1> 	mov	ebx, ecx ; [LFB_SIZE]
 57017                              <1> 
 57018 0000F559 B900080000          <1> 	mov	ecx, 2048
 57019 0000F55E 39CD                <1> 	cmp	ebp, ecx
 57020 0000F560 7302                <1> 	jnb	short sysvideo_39_35 	
 57021 0000F562 89E9                <1> 	mov	ecx, ebp ; fix to requested byte count	
 57022                              <1> sysvideo_39_35:
 57023 0000F564 80FE04              <1> 	cmp	dh, 4 ; 08/02/2021
 57024                              <1> 	;cmp	bl, 4 ; read pixels from user defined positions 
 57025 0000F567 7605                <1> 	jna	short sysvideo_39_36
 57026 0000F569 E9B2000000          <1> 	jmp	sysvideo_39_52
 57027                              <1> 	; 08/02/2021
 57028                              <1> 	;mov	[buffer8], edi  ; user's destination buff addr
 57029                              <1> sysvideo_39_36:
 57030                              <1> 	; 08/02/2021
 57031                              <1> 	; read pixel positions 
 57032                              <1> 	; as defined in user's source buffer 
 57033 0000F56E 893D[56100300]      <1> 	mov	[buffer8], edi  ; user's destination buff addr
 57034 0000F574 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 57035                              <1> 					  ; 2028 byte data
 57036                              <1> 	; esi = user's source buffer for pixel positions
 57037                              <1> 	; ecx = byte count
 57038 0000F579 E8F9170000          <1> 	call	transfer_from_user_buffer
 57039 0000F57E 7292                <1> 	jc	short sysvideo_39_32 ; error
 57040                              <1> 	; ecx  = transfer count (bytes)
 57041                              <1> 
 57042 0000F580 57                  <1> 	push	edi ; *
 57043 0000F581 56                  <1> 	push	esi ; **
 57044 0000F582 51                  <1> 	push	ecx ; ***
 57045                              <1> 
 57046 0000F583 89FE                <1> 	mov	esi, edi ; kernel buffer
 57047 0000F585 8B15[3E100300]      <1> 	mov	edx, [v_mem] ; video memory
 57048 0000F58B C1E902              <1> 	shr	ecx, 2 ; pixel count (within buffer capacity)
 57049                              <1> 
 57050 0000F58E 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 57051 0000F595 7753                <1> 	ja	short sysvideo_39_49
 57052                              <1> sysvideo_39_37:
 57053                              <1> 	; 8bpp
 57054 0000F597 AD                  <1> 	lodsd
 57055 0000F598 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 57056 0000F59A 7309                <1> 	jnb	short sysvideo_39_39
 57057 0000F59C 0FB60402            <1> 	movzx	eax, byte [edx+eax]
 57058                              <1> sysvideo_39_38:
 57059 0000F5A0 AB                  <1> 	stosd
 57060 0000F5A1 E2F4                <1> 	loop	sysvideo_39_37
 57061 0000F5A3 EB49                <1> 	jmp	short sysvideo_39_50
 57062                              <1> sysvideo_39_39:
 57063                              <1> 	; write black color for improper positions
 57064 0000F5A5 31C0                <1> 	xor	eax, eax
 57065 0000F5A7 EBF7                <1> 	jmp	short sysvideo_39_38
 57066                              <1> sysvideo_39_40:
 57067 0000F5A9 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 57068 0000F5B0 772A                <1> 	ja	short sysvideo_39_47 ; 32bpp
 57069 0000F5B2 7216                <1> 	jb	short sysvideo_39_44 ; 16bpp
 57070                              <1> sysvideo_39_41: 
 57071                              <1> 	; 24bpp
 57072 0000F5B4 AD                  <1> 	lodsd
 57073 0000F5B5 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 57074 0000F5B7 730D                <1> 	jnb	short sysvideo_39_43
 57075 0000F5B9 8B0402              <1> 	mov	eax, [edx+eax]
 57076 0000F5BC 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
 57077                              <1> sysvideo_39_42:
 57078 0000F5C1 AB                  <1> 	stosd
 57079 0000F5C2 E2F0                <1> 	loop	sysvideo_39_41
 57080 0000F5C4 EB28                <1> 	jmp	short sysvideo_39_50
 57081                              <1> sysvideo_39_43:
 57082                              <1> 	; write black color for improper positions
 57083 0000F5C6 31C0                <1> 	xor	eax, eax
 57084 0000F5C8 EBF7                <1> 	jmp	short sysvideo_39_42
 57085                              <1> sysvideo_39_44:
 57086                              <1> 	; 16bpp
 57087 0000F5CA AD                  <1> 	lodsd
 57088 0000F5CB 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 57089 0000F5CD 7309                <1> 	jnb	short sysvideo_39_46
 57090 0000F5CF 0FB70402            <1> 	movzx	eax, word [edx+eax]
 57091                              <1> sysvideo_39_45:
 57092 0000F5D3 AB                  <1> 	stosd
 57093 0000F5D4 E2F4                <1> 	loop	sysvideo_39_44
 57094 0000F5D6 EB16                <1> 	jmp	short sysvideo_39_50
 57095                              <1> sysvideo_39_46:
 57096                              <1> 	; write black color for improper positions
 57097 0000F5D8 31C0                <1> 	xor	eax, eax
 57098 0000F5DA EBF7                <1> 	jmp	short sysvideo_39_45
 57099                              <1> sysvideo_39_47:
 57100                              <1> 	; 32bpp
 57101 0000F5DC AD                  <1> 	lodsd
 57102 0000F5DD 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
 57103 0000F5DF 7309                <1> 	jnb	short sysvideo_39_49
 57104 0000F5E1 0FB70402            <1> 	movzx	eax, word [edx+eax]
 57105                              <1> sysvideo_39_48:
 57106 0000F5E5 AB                  <1> 	stosd
 57107 0000F5E6 E2F4                <1> 	loop	sysvideo_39_47
 57108 0000F5E8 EB04                <1> 	jmp	short sysvideo_39_50
 57109                              <1> sysvideo_39_49:
 57110                              <1> 	; write black color for improper positions
 57111 0000F5EA 31C0                <1> 	xor	eax, eax
 57112 0000F5EC EBF7                <1> 	jmp	short sysvideo_39_48
 57113                              <1> sysvideo_39_50:
 57114 0000F5EE 59                  <1> 	pop	ecx ; transfer count in bytes
 57115 0000F5EF 5E                  <1> 	pop	esi ; ** ; kernel buffer
 57116                              <1>  	;mov	esi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 57117                              <1> 					  ; 2048 byte data
 57118 0000F5F0 8B3D[56100300]      <1> 	mov	edi, [buffer8]
 57119                              <1> 	; edi = user's destination buffer for pixel colors
 57120                              <1> 	; ecx = byte count
 57121 0000F5F6 E832170000          <1> 	call	transfer_to_user_buffer
 57122 0000F5FB 5E                  <1> 	pop	esi ; *
 57123 0000F5FC 7266                <1> 	jc	short sysvideo_39_56 ; error
 57124                              <1> 	; ecx  = transfer count (bytes)
 57125 0000F5FE 89C8                <1> 	mov	eax, ecx
 57126 0000F600 C1E802              <1> 	shr	eax, 2
 57127 0000F603 0105[1C010300]      <1> 	add	[u.r0], eax ; transfer count (in pixels)
 57128                              <1> 		
 57129 0000F609 29CD                <1> 	sub	ebp, ecx
 57130 0000F60B 7657                <1> 	jna	short sysvideo_39_56 ; completed/finished
 57131 0000F60D 01CE                <1> 	add	esi, ecx ; next position in source buffer
 57132                              <1> 	;add	[buffer8], ecx ; next pos in destination buff
 57133 0000F60F 01CF                <1> 	add	edi, ecx
 57134 0000F611 66B90008            <1> 	mov	cx, 2048 ; new count, limit: kernel buff size
 57135 0000F615 39CD                <1> 	cmp	ebp, ecx ; remain >= limit ?
 57136 0000F617 7302                <1> 	jnb	short sysvideo_39_51 ; yes
 57137 0000F619 89E9                <1> 	mov	ecx, ebp ; fix byte count to remain bytes
 57138                              <1> sysvideo_39_51:
 57139 0000F61B E94EFFFFFF          <1> 	jmp	sysvideo_39_36 
 57140                              <1> 
 57141                              <1> sysvideo_39_52:
 57142 0000F620 80FE05              <1> 	cmp	dh, 5 ; 08/02/2021
 57143                              <1> 	;cmp	bl, 5 ; write pixels to user defined positions 
 57144 0000F623 7605                <1> 	jna	short sysvideo_39_53
 57145 0000F625 E9A1000000          <1> 	jmp	sysvideo_39_66
 57146                              <1> sysvideo_39_53:
 57147                              <1> 	; single color pixel writing
 57148 0000F62A BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 57149                              <1> 					  ; 2028 byte data
 57150                              <1> 	; esi = user's source buffer for pixel positions
 57151                              <1> 	; ecx = byte count
 57152 0000F62F E843170000          <1> 	call	transfer_from_user_buffer
 57153 0000F634 722E                <1> 	jc	short sysvideo_39_56 ; error
 57154                              <1> 	; ecx = transfer count (bytes)
 57155                              <1> 
 57156                              <1> 	; write pixels by using (user) defined positions
 57157                              <1> 	; ecx = byte count (1,2,3,4 times pixel count)	
 57158                              <1> 	; edi = system buffer address
 57159                              <1> 
 57160 0000F636 56                  <1> 	push	esi ; *
 57161 0000F637 51                  <1> 	push	ecx ; **
 57162                              <1> 
 57163 0000F638 89FE                <1> 	mov	esi, edi
 57164 0000F63A 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 57165                              <1> 
 57166                              <1> 	; 08/02/2021
 57167 0000F640 C1E902              <1> 	shr	ecx, 2 ; pixel count
 57168 0000F643 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
 57169                              <1> 	;mov	ebx, [v_siz]
 57170                              <1> 
 57171 0000F649 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 57172 0000F650 7717                <1> 	ja	short sysvideo_39_57
 57173                              <1> sysvideo_39_54:
 57174                              <1> 	; 8bpp
 57175 0000F652 AD                  <1> 	lodsd
 57176 0000F653 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 57177 0000F655 7309                <1> 	jnb	short sysvideo_39_55
 57178 0000F657 881407              <1> 	mov	[edi+eax], dl
 57179                              <1> 	; 06/03/2021
 57180 0000F65A FF05[1C010300]      <1> 	inc	dword [u.r0]
 57181                              <1> sysvideo_39_55:
 57182 0000F660 E2F0                <1> 	loop	sysvideo_39_54
 57183 0000F662 EB50                <1> 	jmp	short sysvideo_39_64
 57184                              <1> sysvideo_39_56:
 57185 0000F664 E989D6FFFF          <1> 	jmp	sysret
 57186                              <1> sysvideo_39_57:
 57187 0000F669 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 57188 0000F670 7732                <1> 	ja	short sysvideo_39_62 ; 32bpp
 57189 0000F672 721D                <1> 	jb	short sysvideo_39_60 ; 16bpp
 57190                              <1> sysvideo_39_58: 
 57191                              <1> 	; 24bpp
 57192 0000F674 AD                  <1> 	lodsd
 57193 0000F675 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 57194 0000F677 7314                <1> 	jnb	short sysvideo_39_59
 57195 0000F679 881407              <1> 	mov	[edi+eax], dl
 57196 0000F67C 40                  <1> 	inc	eax
 57197 0000F67D C1CA08              <1> 	ror	edx, 8
 57198 0000F680 66891407            <1> 	mov	[edi+eax], dx
 57199 0000F684 C1C208              <1> 	rol	edx, 8
 57200 0000F687 FF05[1C010300]      <1> 	inc	dword [u.r0]
 57201                              <1> sysvideo_39_59:
 57202 0000F68D E2E5                <1> 	loop	sysvideo_39_58
 57203 0000F68F EB23                <1> 	jmp	short sysvideo_39_64
 57204                              <1> sysvideo_39_60:
 57205                              <1> 	; 16bpp
 57206 0000F691 AD                  <1> 	lodsd
 57207 0000F692 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 57208 0000F694 730A                <1> 	jnb	short sysvideo_39_61
 57209 0000F696 66891407            <1> 	mov	[edi+eax], dx
 57210 0000F69A FF05[1C010300]      <1> 	inc	dword [u.r0]
 57211                              <1> sysvideo_39_61:	
 57212 0000F6A0 E2EF                <1> 	loop	sysvideo_39_60
 57213 0000F6A2 EB10                <1> 	jmp	short sysvideo_39_64	
 57214                              <1> sysvideo_39_62:
 57215                              <1> 	; 32bpp
 57216 0000F6A4 AD                  <1> 	lodsd
 57217 0000F6A5 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
 57218 0000F6A7 7309                <1> 	jnb	short sysvideo_39_63
 57219 0000F6A9 891407              <1> 	mov	[edi+eax], edx
 57220 0000F6AC FF05[1C010300]      <1> 	inc	dword [u.r0]
 57221                              <1> sysvideo_39_63:	
 57222 0000F6B2 E2F0                <1> 	loop	sysvideo_39_62
 57223                              <1> sysvideo_39_64:
 57224 0000F6B4 59                  <1> 	pop	ecx ; **
 57225 0000F6B5 5E                  <1> 	pop	esi ; *	
 57226 0000F6B6 29CD                <1> 	sub	ebp, ecx
 57227 0000F6B8 76AA                <1> 	jna	short sysvideo_39_56
 57228 0000F6BA 01CE                <1> 	add	esi, ecx
 57229 0000F6BC 66B90008            <1> 	mov	cx, 2048
 57230 0000F6C0 39CD                <1> 	cmp	ebp, ecx
 57231 0000F6C2 7302                <1> 	jnb	short sysvideo_39_65
 57232 0000F6C4 89E9                <1> 	mov	ecx, ebp
 57233                              <1> sysvideo_39_65:
 57234 0000F6C6 E95FFFFFFF          <1> 	jmp	sysvideo_39_53
 57235                              <1> 
 57236                              <1> sysvideo_39_66:
 57237                              <1> 	; 15/02/2021
 57238 0000F6CB D1E5                <1> 	shl	ebp, 1 ; 8 bytes per pixel (position&color)
 57239                              <1> sysvideo_39_67: 	
 57240 0000F6CD 66B90008            <1> 	mov	cx, 2048
 57241 0000F6D1 39CD                <1> 	cmp	ebp, ecx
 57242 0000F6D3 7302                <1> 	jnb	short sysvideo_39_68
 57243 0000F6D5 89E9                <1> 	mov	ecx, ebp
 57244                              <1> sysvideo_39_68:
 57245                              <1> 	; multi colors pixel writing
 57246 0000F6D7 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
 57247                              <1> 					  ; 2048 byte data
 57248                              <1> 	; esi = user's source buffer for pixel positions
 57249                              <1> 	; ecx = byte count
 57250 0000F6DC E896160000          <1> 	call	transfer_from_user_buffer
 57251 0000F6E1 7281                <1> 	jc	short sysvideo_39_56 ; error
 57252                              <1> 	; ecx  = transfer count
 57253                              <1> 	
 57254                              <1> 	; write pixels & colors as defined in user buffer 
 57255                              <1> 	; ecx = byte count (2,4,6,8 times pixel count)	
 57256                              <1> 	; edi = system buffer address
 57257                              <1> 
 57258 0000F6E3 56                  <1> 	push	esi ; **
 57259 0000F6E4 51                  <1> 	push	ecx ; *
 57260                              <1> 
 57261 0000F6E5 89FE                <1> 	mov	esi, edi
 57262 0000F6E7 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
 57263                              <1> 
 57264                              <1> 	; 08/02/2021
 57265 0000F6ED C1E903              <1> 	shr	ecx, 3 ; pixel count
 57266                              <1> 
 57267                              <1> 	;mov	ebx, [v_siz]
 57268                              <1> 
 57269 0000F6F0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
 57270 0000F6F7 7715                <1> 	ja	short sysvideo_39_71
 57271                              <1> sysvideo_39_69:
 57272                              <1> 	; 8bpp
 57273 0000F6F9 AD                  <1> 	lodsd	; position
 57274 0000F6FA 89C2                <1> 	mov	edx, eax
 57275 0000F6FC AD                  <1> 	lodsd	; color
 57276 0000F6FD 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 57277 0000F6FF 7309                <1> 	jnb	short sysvideo_39_70
 57278 0000F701 880417              <1> 	mov	[edi+edx], al
 57279                              <1> 	; 06/03/2021
 57280 0000F704 FF05[1C010300]      <1> 	inc	dword [u.r0]
 57281                              <1> sysvideo_39_70:
 57282 0000F70A E2ED                <1> 	loop	sysvideo_39_69
 57283 0000F70C EB51                <1> 	jmp	short sysvideo_39_78
 57284                              <1> sysvideo_39_71:
 57285 0000F70E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
 57286 0000F715 7735                <1> 	ja	short sysvideo_39_76 ; 32bpp
 57287 0000F717 721D                <1> 	jb	short sysvideo_39_74 ; 16bpp
 57288                              <1> sysvideo_39_72:
 57289                              <1> 	; 24bpp 
 57290 0000F719 AD                  <1> 	lodsd	; position
 57291 0000F71A 89C2                <1> 	mov	edx, eax
 57292 0000F71C AD                  <1> 	lodsd	; color
 57293 0000F71D 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 57294 0000F71F 7311                <1> 	jnb	short sysvideo_39_73
 57295 0000F721 880417              <1> 	mov	[edi+edx], al
 57296 0000F724 42                  <1> 	inc	edx
 57297 0000F725 C1E808              <1> 	shr	eax, 8
 57298 0000F728 66890417            <1> 	mov	[edi+edx], ax
 57299 0000F72C FF05[1C010300]      <1> 	inc	dword [u.r0]
 57300                              <1> sysvideo_39_73:	
 57301 0000F732 E2E5                <1> 	loop	sysvideo_39_72
 57302 0000F734 EB29                <1> 	jmp	short sysvideo_39_78
 57303                              <1> sysvideo_39_74:
 57304                              <1> 	; 16bpp
 57305 0000F736 AD                  <1> 	lodsd	; position
 57306 0000F737 89C2                <1> 	mov	edx, eax
 57307 0000F739 AD                  <1> 	lodsd	; color
 57308 0000F73A 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 57309 0000F73C 730A                <1> 	jnb	short sysvideo_39_75
 57310 0000F73E 66890417            <1> 	mov	[edi+edx], ax
 57311 0000F742 FF05[1C010300]      <1> 	inc	dword [u.r0]
 57312                              <1> sysvideo_39_75:	
 57313 0000F748 E2EC                <1> 	loop	sysvideo_39_74
 57314 0000F74A EB13                <1> 	jmp	short sysvideo_39_78
 57315                              <1> sysvideo_39_76:
 57316                              <1> 	; 32bpp
 57317 0000F74C AD                  <1> 	lodsd	; position
 57318 0000F74D 89C2                <1> 	mov	edx, eax
 57319 0000F74F AD                  <1> 	lodsd	; color
 57320 0000F750 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
 57321 0000F752 7309                <1> 	jnb	short sysvideo_39_77
 57322 0000F754 890417              <1> 	mov	[edi+edx], eax
 57323 0000F757 FF05[1C010300]      <1> 	inc	dword [u.r0]
 57324                              <1> sysvideo_39_77:	
 57325 0000F75D E2ED                <1> 	loop	sysvideo_39_76
 57326                              <1> sysvideo_39_78:
 57327 0000F75F 59                  <1> 	pop	ecx ; *
 57328 0000F760 5E                  <1> 	pop	esi ; **	
 57329                              <1> 
 57330 0000F761 29CD                <1> 	sub	ebp, ecx
 57331 0000F763 762A                <1> 	jna	short sysvideo_39_79
 57332 0000F765 01CE                <1> 	add	esi, ecx
 57333 0000F767 E961FFFFFF          <1> 	jmp	sysvideo_39_67
 57334                              <1> ;sysvideo_39_79:
 57335                              <1> ;	jmp	sysret
 57336                              <1> 		
 57337                              <1> sysvideo_16:
 57338                              <1> 	; 11/08/2022
 57339                              <1> 	; 23/07/2022
 57340                              <1> 	; 06/03/2021
 57341                              <1> 	; 23/11/2020
 57342 0000F76C 80FF04              <1> 	cmp	bh, 4
 57343                              <1> 	;jb	sysvideo_39 ; bh = 3, pixel r/w
 57344                              <1> 	;ja	short sysvideo_17
 57345                              <1> 	; 23/07/2022
 57346 0000F76F 7407                <1> 	je	short sysvideo_16_0
 57347 0000F771 7721                <1> 	ja	short sysvideo_17
 57348 0000F773 E94EFCFFFF          <1> 	jmp	sysvideo_39
 57349                              <1> sysvideo_16_0:	
 57350                              <1> 	; BH = 4
 57351                              <1> 	; Direct User Access for CGA video memory.
 57352                              <1> 	; Setup user's page tables for direct access to 0B8000h.
 57353                              <1> 	;
 57354                              <1> 	; Permission checks are not implemented yet !
 57355                              <1> 	; (11/07/2016)
 57356                              <1> 
 57357 0000F778 B800800B00          <1> 	mov	eax, 0B8000h
 57358                              <1> 	;mov	ecx, 8 ; 8 pages (8*4K=32K)
 57359                              <1> 	; 11/08/2022
 57360 0000F77D 31C9                <1> 	xor	ecx, ecx
 57361 0000F77F B108                <1> 	mov	cl, 8
 57362 0000F781 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
 57363 0000F783 E8B266FFFF          <1> 	call	direct_memory_access	
 57364                              <1> 	;jc	sysret
 57365 0000F788 7205                <1> 	jc	short sysvideo_39_79 ; 06/03/2021
 57366                              <1> 	; eax = 0B8000h if there is not an error
 57367 0000F78A A3[1C010300]        <1> 	mov	[u.r0], eax
 57368                              <1> sysvideo_39_79: ; 08/01/2021
 57369 0000F78F E95ED5FFFF          <1> 	jmp	sysret
 57370                              <1> 
 57371                              <1> sysvideo_17:
 57372                              <1> 	; 23/07/2022
 57373                              <1> 	; 23/12/2020
 57374                              <1> 	; 11/12/2020
 57375                              <1> 	; 10/12/2020
 57376                              <1> 	; 23/11/2020
 57377 0000F794 80FF06              <1> 	cmp	bh, 6
 57378 0000F797 7424                <1> 	je	short sysvideo_17_0 ; 23/07/2022
 57379 0000F799 7205                <1> 	jb	short sysvideo_18 ; 23/07/2022
 57380 0000F79B E95E010000          <1> 	jmp	sysvideo_20 ; ja
 57381                              <1> 
 57382                              <1> 	; 23/07/2022
 57383                              <1> sysvideo_18:
 57384                              <1> 	; BH = 5
 57385                              <1> 	; Direct User Access for VGA video memory.
 57386                              <1> 	; Setup user's page tables for direct access to 0A0000h.
 57387                              <1> 	;
 57388                              <1> 	; Permission checks are not implemented yet !
 57389                              <1> 	; (11/07/2016)
 57390                              <1> 
 57391 0000F7A0 B800000A00          <1> 	mov	eax, 0A0000h
 57392 0000F7A5 B910000000          <1> 	mov	ecx, 16 ; 16 pages (16*4K=64K)
 57393 0000F7AA 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
 57394 0000F7AC E88966FFFF          <1> 	call	direct_memory_access	
 57395                              <1> 	;jc	sysret
 57396                              <1> 	; 23/07/2022
 57397 0000F7B1 7205                <1> 	jc	short sysvideo_18_0
 57398                              <1> 	; eax = 0A0000h if there is not an error
 57399 0000F7B3 A3[1C010300]        <1> 	mov	[u.r0], eax
 57400                              <1> sysvideo_18_0:
 57401 0000F7B8 E935D5FFFF          <1> 	jmp	sysret
 57402                              <1> 
 57403                              <1> sysvideo_17_0:
 57404                              <1> 	; BH = 6
 57405                              <1> 	; Direct User Access to Linear Frame Buffer.
 57406                              <1> 	; Setup user's page tables for direct access to LFB.
 57407                              <1> 	;
 57408                              <1> 	; Permission checks are not implemented yet !
 57409                              <1> 	; (10/12/2020)
 57410                              <1> 
 57411 0000F7BD 80FBFF              <1> 	cmp	bl, 0FFh ; current video mode
 57412 0000F7C0 722C                <1> 	jb	short sysvideo_17_2 ; for desired video mode
 57413                              <1> 
 57414 0000F7C2 381D[9E660000]      <1> 	cmp	[CRT_MODE], bl ; VESA VBE video mode ?
 57415 0000F7C8 750E                <1> 	jne	short sysvideo_17_1
 57416 0000F7CA 668B0D[D20F0300]    <1> 	mov	cx, [video_mode]
 57417 0000F7D1 6681E1FF01          <1> 	and	cx, 1FFh
 57418 0000F7D6 EB29                <1> 	jmp	short sysvideo_17_3
 57419                              <1> sysvideo_17_1:
 57420                              <1> 	; 11/12/2020
 57421 0000F7D8 88DF                <1> 	mov	bh, bl ; 0FFh
 57422 0000F7DA 8A1D[9E660000]      <1> 	mov	bl, [CRT_MODE] ; VGA/CGA video mode
 57423 0000F7E0 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 57424                              <1> 	; 23/12/2020
 57425 0000F7E6 895D10              <1> 	mov	[ebp+16], ebx ; return to user with EBX value 
 57426 0000F7E9 E904D5FFFF          <1> 	jmp	sysret ; return to user with EAX = 0
 57427                              <1> sysvideo_17_2:
 57428                              <1> 	; bl = VESA video mode - 100h
 57429 0000F7EE B701                <1> 	mov	bh, 1 ; bx = 1XXh
 57430 0000F7F0 53                  <1> 	push	ebx ; requested vesa video mode
 57431 0000F7F1 E80042FFFF          <1> 	call	vbe_biosfn_return_current_mode
 57432 0000F7F6 59                  <1> 	pop	ecx ; requested vesa video mode
 57433 0000F7F7 6681E3FF01          <1> 	and	bx, 1FFh
 57434 0000F7FC 6639D9              <1> 	cmp	cx, bx
 57435 0000F7FF 7564                <1> 	jne	short sysvideo_17_8
 57436                              <1> sysvideo_17_3:
 57437 0000F801 663B0D[DE0F0300]    <1> 	cmp	cx, [LFB_Info+LFBINFO.mode]
 57438 0000F808 755B                <1> 	jne	short sysvideo_17_8
 57439                              <1> sysvideo_17_4:
 57440                              <1> 	; 11/12/2020
 57441 0000F80A A1[E00F0300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
 57442                              <1> 	; 21/12/2020
 57443 0000F80F 09C0                <1> 	or	eax, eax
 57444 0000F811 744D                <1> 	jz	short sysvideo_17_7
 57445                              <1> 	;
 57446 0000F813 8B0D[E40F0300]      <1> 	mov	ecx, [LFB_Info+LFBINFO.LFB_size] ; buff size
 57447 0000F819 89C3                <1> 	mov 	ebx, eax ; user's address = physical address
 57448                              <1> 	;push	ebx
 57449 0000F81B 51                  <1> 	push	ecx
 57450                              <1> 	; 21/12/2020
 57451 0000F81C 81C1FF0F0000        <1> 	add	ecx, 4095  ; PAGESIZE - 1
 57452                              <1> 	; 14/12/2020
 57453 0000F822 C1E90C              <1> 	shr	ecx, 12  ; convert bytes to pages
 57454 0000F825 E81066FFFF          <1> 	call	direct_memory_access
 57455 0000F82A 5A                  <1> 	pop	edx  ; linear frame buffer size in bytes
 57456                              <1> 	;pop	eax  ; linear frame buffer address (physical)
 57457 0000F82B 7233                <1> 	jc	short sysvideo_17_7 ; [u.r0] = eax = 0
 57458                              <1> sysvideo_17_5:
 57459 0000F82D 668B0D[EA0F0300]    <1> 	mov	cx, [LFB_Info+LFBINFO.Y_res] ; screen height
 57460 0000F834 C1E110              <1> 	shl	ecx, 16
 57461 0000F837 668B0D[E80F0300]    <1> 	mov	cx,  [LFB_Info+LFBINFO.X_res] ; screen width
 57462 0000F83E 31DB                <1> 	xor	ebx, ebx
 57463 0000F840 8A1D[EC0F0300]      <1> 	mov	bl, [LFB_Info+LFBINFO.bpp] ; bits per pixel
 57464 0000F846 8A3D[DE0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.mode] ; XX part of 1XXh
 57465                              <1> sysvideo_26_4: ; 23/12/2020	
 57466 0000F84C 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 57467 0000F852 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
 57468 0000F855 895D10              <1> 	mov	[ebp+16], ebx ; EBX
 57469 0000F858 894D18              <1> 	mov	[ebp+24], ecx ; ECX
 57470                              <1> sysvideo_17_6:
 57471 0000F85B A3[1C010300]        <1> 	mov	[u.r0], eax ; LFB address
 57472                              <1> sysvideo_17_7:
 57473 0000F860 E98DD4FFFF          <1> 	jmp	sysret 
 57474                              <1> sysvideo_17_8:
 57475                              <1> 	; cx = mode
 57476                              <1> 	; 21/12/2020
 57477 0000F865 80CD40              <1> 	or	ch, 40h  ; Linear frame buffer flag	
 57478 0000F868 E8AC3FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
 57479 0000F86D 72F1                <1> 	jc	short sysvideo_17_7
 57480 0000F86F EB99                <1> 	jmp	short sysvideo_17_4
 57481                              <1> 	
 57482                              <1> sysvideo_19:	
 57483                              <1> 	; 23/07/2022
 57484                              <1> 	; 22/01/2021
 57485                              <1> 	; 12/12/2020
 57486                              <1> 	; 11/12/2020
 57487                              <1> 	; 23/11/2020
 57488                              <1> 	; BH = 7
 57489                              <1> 	; Get (Super/Extended VGA) mode
 57490                              <1> 	; and Linear Frame Buffer info.
 57491                              <1> 	
 57492                              <1> 	; 22/01/2021
 57493 0000F871 B3FF                <1> 	mov	bl, 0FFh
 57494                              <1> 	; 11/12/2020
 57495                              <1> 	;cmp	byte [CRT_MODE], 0FFh ; (extended mode?)
 57496                              <1> 	; 22/01/2021
 57497 0000F873 381D[9E660000]      <1> 	cmp	[CRT_MODE], bl  ; 0FFh
 57498                              <1> 	;jb	short sysvideo_17_1 ; not a VESA VBE mode
 57499                              <1> 	; 23/07/2022
 57500                              <1> 	; 12/12/2020
 57501 0000F879 7305                <1> 	jnb	short sysvideo_19_0
 57502                              <1> 	; 23/07/2022
 57503 0000F87B E958FFFFFF          <1> 	jmp	sysvideo_17_1
 57504                              <1> 
 57505                              <1> sysvideo_19_0:
 57506 0000F880 E87141FFFF          <1> 	call	vbe_biosfn_return_current_mode
 57507 0000F885 6681E3FF01          <1> 	and	bx, 1FFh
 57508 0000F88A 663B1D[DE0F0300]    <1> 	cmp	bx, [LFB_Info+LFBINFO.mode]
 57509 0000F891 750D                <1> 	jne	short sysvideo_19_2
 57510                              <1> sysvideo_19_1:
 57511 0000F893 A1[E00F0300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
 57512 0000F898 8B15[E40F0300]      <1> 	mov	edx, [LFB_Info+LFBINFO.LFB_size]
 57513 0000F89E EB8D                <1> 	jmp	sysvideo_17_5
 57514                              <1> sysvideo_19_2:
 57515 0000F8A0 E8743FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
 57516 0000F8A5 73EC                <1> 	jnc	short sysvideo_19_1
 57517 0000F8A7 E946D4FFFF          <1> 	jmp	sysret
 57518                              <1> 
 57519                              <1> sysvideo_20_1:
 57520                              <1> 	; cx = vesa video mode
 57521 0000F8AC 6689C8              <1> 	mov	ax, cx
 57522 0000F8AF 663D0001            <1> 	cmp	ax, 100h
 57523 0000F8B3 725C                <1> 	jb	short sysvideo_20_0 ; VGA/CGA mode
 57524 0000F8B5 663DFF01            <1> 	cmp	ax, 1FFh
 57525                              <1> 	;ja	short sysvideo_20_4 ; not valid
 57526 0000F8B9 773E                <1> 	ja	short sysvideo_20_3
 57527 0000F8BB 50                  <1> 	push	eax
 57528 0000F8BC 6689C3              <1> 	mov	bx, ax
 57529 0000F8BF 66B8024F            <1> 	mov	ax, 4F02h
 57530                              <1> 
 57531                              <1> 	; simulate _int10h (int 31h) for func 4F02h
 57532                              <1> 	;pushfd
 57533                              <1> 	;push	cs
 57534                              <1> 	;push	sysvideo_20_1_retn 
 57535                              <1> 	;push	es ; *
 57536                              <1> 	;push	ds ; **	; SAVE WORK AND PARAMETER REGISTERS
 57537                              <1> 	;jmp	VBE_func
 57538                              <1> ;sysvideo_20_1_retn:	
 57539                              <1> 	
 57540 0000F8C3 E80E1EFFFF          <1> 	call	_int10h ; simulate int 10h (int 31h)
 57541                              <1> 
 57542 0000F8C8 6683F84F            <1> 	cmp	ax, 004Fh
 57543 0000F8CC 58                  <1> 	pop	eax
 57544 0000F8CD 752A                <1> 	jne	short sysvideo_20_3 ; error
 57545                              <1> 	;pop	eax
 57546 0000F8CF 40                  <1> 	inc	eax
 57547 0000F8D0 A3[1C010300]        <1> 	mov	[u.r0], eax ; video mode + 1
 57548 0000F8D5 09D2                <1> 	or	edx, edx ; is LFBINFO requested by user ?	
 57549                              <1> 	;jz	short sysvideo_20_4
 57550 0000F8D7 7420                <1> 	jz	short sysvideo_20_3 ; no
 57551                              <1> 
 57552                              <1> 	; 11/12/2020
 57553                              <1> 	; Check LFBINFO table/structure
 57554                              <1> 	; (it is set by vbe2 'vbe_biosfn_set_mode'
 57555                              <1> 	; but if vbe3 vbios pmi is in use,
 57556                              <1> 	; it will not set LFBINFO table)
 57557                              <1> 
 57558 0000F8D9 52                  <1> 	push	edx
 57559 0000F8DA 48                  <1> 	dec	eax  ; video mode
 57560 0000F8DB BE[DE0F0300]        <1> 	mov	esi, LFB_Info
 57561 0000F8E0 663B06              <1> 	cmp	ax, [esi+LFBINFO.mode]
 57562 0000F8E3 7407                <1> 	je	short sysvideo_20_2
 57563                              <1> 
 57564 0000F8E5 E82F3FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
 57565                              <1> 	;jnc	short sysvideo_20_2
 57566 0000F8EA 723B                <1> 	jc	short sysvideo_20_4 ; edx = 0	
 57567                              <1> 
 57568                              <1> 	;; clear LFBINFO table for invalidating	
 57569                              <1> 	;mov	ecx, LFBINFO.size ; 16
 57570                              <1> 	;mov	edi, esi ; LFB_Info table address
 57571                              <1> 	;xor	eax, eax
 57572                              <1> 	;rep	stosb
 57573                              <1> 
 57574                              <1> sysvideo_20_2:
 57575                              <1> 	;pop	ecx
 57576                              <1> 	;mov	edi, ecx ; user buffer
 57577 0000F8EC 5F                  <1> 	pop	edi
 57578 0000F8ED B910000000          <1> 	mov	ecx, LFBINFO.size ; 16
 57579 0000F8F2 E836140000          <1> 	call	transfer_to_user_buffer ; fast transfer
 57580 0000F8F7 722F                <1> 	jc	short sysvideo_20_5
 57581                              <1> 	
 57582                              <1> 	;jmp	sysret
 57583                              <1> sysvideo_20_3:	
 57584                              <1> 	;pop	eax ; [u.r0] = 0		
 57585                              <1> ;sysvideo_20_4:
 57586 0000F8F9 E9F4D3FFFF          <1> 	jmp	sysret
 57587                              <1> 
 57588                              <1> 	; 23/07/2022
 57589                              <1> sysvideo_20:
 57590                              <1> 	; 11/12/2020
 57591                              <1> 	; 23/11/2020
 57592 0000F8FE 80FF08              <1> 	cmp	bh, 8
 57593                              <1> 	; 08/08/2022
 57594                              <1> 	;jb	short sysvideo_19 ; video mode & lfb info
 57595 0000F901 7407                <1> 	je	short sysvideo_20_6
 57596                              <1> 	; 23/07/2022
 57597 0000F903 7733                <1> 	ja	short sysvideo_21 ; 12/12/2020
 57598                              <1> 	; 08/08/2022 - jb
 57599 0000F905 E967FFFFFF          <1> 	jmp	sysvideo_19 
 57600                              <1> sysvideo_20_6:
 57601                              <1> 	; BH = 8
 57602                              <1> 	; Set (Super/Extended VGA) mode & return LFB info
 57603                              <1> 
 57604                              <1> 	; 11/12/2020
 57605 0000F90A 80FBFF              <1> 	cmp	bl, 0FFh  ; CGA/VGA mode ?
 57606 0000F90D 739D                <1> 	jnb	short sysvideo_20_1
 57607                              <1> 
 57608                              <1> 	;xor	ah, ah
 57609 0000F90F 88D8                <1> 	mov	al, bl
 57610                              <1> sysvideo_20_0:
 57611 0000F911 E8C01DFFFF          <1> 	call	_int10h  ; uses vbe3 pmi32 option
 57612 0000F916 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
 57613 0000F919 74DE                <1> 	je	short sysvideo_20_3 ; error
 57614                              <1> 	
 57615                              <1> 	; 11/12/2020
 57616                              <1> 	; alternative (it does not use vbe3 pmi32)
 57617                              <1> 	;push	eax
 57618                              <1> 	;call	_set_mode
 57619                              <1> 	;pop	eax
 57620                              <1> 	;jc	short sysvideo_20_3
 57621                              <1> 	
 57622                              <1> 	;inc	eax
 57623 0000F91B FEC0                <1> 	inc	al
 57624                              <1> 	;mov	[u.r0], ax ; video mode + 1	
 57625 0000F91D A2[1C010300]        <1> 	mov	[u.r0], al
 57626 0000F922 E9CBD3FFFF          <1> 	jmp	sysret
 57627                              <1> 
 57628                              <1> sysvideo_20_4:
 57629 0000F927 5A                  <1> 	pop	edx
 57630                              <1> sysvideo_20_5:
 57631 0000F928 31D2                <1> 	xor	edx, edx ; 0
 57632                              <1> 	; edx = 0 -> invalid LFBINFO data
 57633 0000F92A 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 57634 0000F930 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
 57635 0000F933 E9BAD3FFFF          <1> 	jmp	sysret
 57636                              <1> 
 57637                              <1> sysvideo_21:
 57638                              <1> 	; 23/07/2022
 57639                              <1> 	; 04/01/2021
 57640                              <1> 	; 03/12/2020
 57641 0000F938 80FF0A              <1> 	cmp	bh, 10
 57642                              <1> 	;jb	sysvideo_22 ; VESA VBE3 pmi parms
 57643                              <1> 	; 23/07/2022
 57644 0000F93B 723F                <1> 	jb	short sysvideo_21_19
 57645                              <1> 	; 23/12/2020
 57646                              <1> 	;je	sysvideo_26 ; Video memory mapping	
 57647                              <1> 	; 23/07/2022
 57648 0000F93D 7442                <1> 	je	short sysvideo_21_20
 57649                              <1> 	
 57650                              <1> 	; 04/01/2020
 57651 0000F93F 80FF0B              <1> 	cmp	bh, 11
 57652                              <1> 	;ja	sysvideo_27
 57653                              <1> 	; 23/07/2022
 57654 0000F942 7742                <1> 	ja	short sysvideo_21_21
 57655                              <1> 		
 57656                              <1> 	; BH = 11
 57657                              <1> 	; set/read DAC color registers (for 8bpp)
 57658                              <1> 	
 57659 0000F944 80FB04              <1> 	cmp	bl, 4
 57660                              <1> 	;jnb	sysvideo_21_7	; BMP file type palette
 57661                              <1> 				; handling
 57662                              <1> 	; 23/07/2022
 57663                              <1> 	;jnb	short sysvideo_21_7
 57664                              <1> 	; 08/08/2022
 57665 0000F947 7205                <1> 	jb	short sysvideo_21_18
 57666 0000F949 E989000000          <1> 	jmp	sysvideo_21_7
 57667                              <1> sysvideo_21_18:	
 57668 0000F94E F6C301              <1> 	test	bl, 1
 57669 0000F951 7563                <1> 	jnz	short sysvideo_21_4 ; set/write DAC colors
 57670                              <1> 		
 57671                              <1> 	; Read DAC color register or all DAC color registers
 57672 0000F953 F6C302              <1> 	test	bl, 2  ; read single DAC color register
 57673 0000F956 7433                <1> 	jz	short sysvideo_21_2 ; read all DAC color regs	
 57674                              <1> 
 57675                              <1> 	; read single DAC color register
 57676                              <1> 	; CL = DAC color register (index)
 57677                              <1>  	
 57678 0000F958 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 57679 0000F95C 88C8                <1> 	mov	al, cl	; DAC color register
 57680 0000F95E 31C9                <1> 	xor	ecx, ecx ; (this may not be necessary)
 57681 0000F960 EE                  <1> 	out	dx, al
 57682                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57683 0000F961 B2C9                <1> 	mov	dl, 0C9h
 57684 0000F963 EC                  <1> 	in	al, dx
 57685 0000F964 88C4                <1> 	mov	ah, al	; red
 57686 0000F966 EC                  <1> 	in	al, dx
 57687 0000F967 88C1                <1> 	mov	cl, al	; green
 57688 0000F969 EC                  <1> 	in	al, dx
 57689 0000F96A 88C5                <1> 	mov	ch, al	; blue
 57690 0000F96C C1E108              <1> 	shl	ecx, 8
 57691 0000F96F 88E1                <1> 	mov	cl, ah	; red	
 57692                              <1> 	; CL = Red, CH = Green, byte 3 = Blue, byte 4 = 0
 57693                              <1> sysvideo_21_0:
 57694 0000F971 890D[1C010300]      <1> 	mov	[u.r0], ecx
 57695                              <1> sysvideo_21_1:
 57696 0000F977 E976D3FFFF          <1> 	jmp	sysret
 57697                              <1> sysvideo_21_19:
 57698                              <1> 	; 23/07/2022
 57699 0000F97C E97A010000          <1> 	jmp	sysvideo_22
 57700                              <1> sysvideo_21_20:
 57701                              <1> 	; 23/07/2022
 57702 0000F981 E930020000          <1> 	jmp	sysvideo_26
 57703                              <1> sysvideo_21_21:
 57704                              <1> 	; 23/07/2022
 57705 0000F986 E9B6020000          <1> 	jmp	sysvideo_27
 57706                              <1> sysvideo_21_2:
 57707                              <1> 	; read all DAC color registers
 57708 0000F98B 89CB                <1> 	mov	ebx, ecx ; user's buffer address
 57709 0000F98D BF00600900          <1> 	mov	edi, VBE3STACKADDR
 57710 0000F992 89FE                <1> 	mov	esi, edi
 57711                              <1> 	;mov	ecx, 768 ; 256*3
 57712                              <1> 	; 08/08/2022
 57713 0000F994 29C9                <1> 	sub	ecx, ecx
 57714 0000F996 B503                <1> 	mov	ch, 3
 57715                              <1> 	; ecx = 768 = 300h
 57716                              <1> 	;push	ecx
 57717 0000F998 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 57718 0000F99C 28C0                <1> 	sub	al, al ; 0
 57719 0000F99E EE                  <1> 	out	dx, al
 57720                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57721 0000F99F B2C9                <1> 	mov	dl, 0C9h
 57722                              <1> sysvideo_21_3:
 57723 0000F9A1 EC                  <1> 	in	al, dx
 57724 0000F9A2 AA                  <1> 	stosb
 57725 0000F9A3 EC                  <1> 	in	al, dx
 57726 0000F9A4 AA                  <1> 	stosb
 57727 0000F9A5 EC                  <1> 	in	al, dx
 57728 0000F9A6 AA                  <1> 	stosb
 57729 0000F9A7 E2F8                <1> 	loop	sysvideo_21_3
 57730                              <1> 	;pop	ecx
 57731                              <1> 	; 18/08/2022
 57732 0000F9A9 B503                <1> 	mov	ch, 3
 57733                              <1> 	; ecx = 768 = 300h
 57734                              <1> 
 57735 0000F9AB 89DF                <1> 	mov	edi, ebx ; user's buffer address
 57736                              <1> 	;mov	esi, VBE3STACKADDR
 57737                              <1> 	;mov	ecx, 256*3 = 768
 57738 0000F9AD E87B130000          <1> 	call	transfer_to_user_buffer
 57739 0000F9B2 72C3                <1> 	jc	short sysvideo_21_1
 57740                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 57741 0000F9B4 EBBB                <1> 	jmp	short sysvideo_21_0
 57742                              <1> 
 57743                              <1> sysvideo_21_4:
 57744                              <1> 	; Set/Write DAC color register or all registers
 57745 0000F9B6 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 57746 0000F9B9 7456                <1> 	jz	short sysvideo_21_5 ; set all DAC color regs
 57747                              <1> 
 57748                              <1> 	; set single DAC color register
 57749                              <1> 	; CL = DAC color register (index)
 57750                              <1> 	; (byte 1 = Red, byte 2 = Green, byte 3 = Blue) 
 57751                              <1> 
 57752 0000F9BB 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 57753 0000F9BF 89C8                <1> 	mov	eax, ecx ; DAC color register (index)
 57754 0000F9C1 C1E910              <1> 	shr	ecx, 16  ; CL = green, AH = Red
 57755 0000F9C4 EE                  <1> 	out	dx, al
 57756                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57757 0000F9C5 FEC2                <1> 	inc	dl
 57758 0000F9C7 88E0                <1> 	mov	al, ah	; Red
 57759 0000F9C9 EE                  <1> 	out	dx, al
 57760 0000F9CA 88C8                <1> 	mov	al, cl	; Green
 57761 0000F9CC EE                  <1> 	out	dx, al
 57762 0000F9CD 88E8                <1> 	mov	al, ch	; Blue
 57763 0000F9CF EE                  <1> 	out	dx, al	
 57764                              <1> 	;rol	ecx, 8
 57765 0000F9D0 C1E108              <1> 	shl	ecx, 8	; 21/02/2021
 57766 0000F9D3 88E1                <1> 	mov	cl, ah	; Red
 57767                              <1> 		; ecx = 00BBGGRRh	
 57768 0000F9D5 EB9A                <1> 	jmp	short sysvideo_21_0
 57769                              <1> 
 57770                              <1> 	; 23/07/2022
 57771                              <1> sysvideo_21_7:	
 57772                              <1> 	; BMP file type palette handling	
 57773                              <1> 	
 57774 0000F9D7 F6C301              <1> 	test	bl, 1
 57775                              <1> 	;jnz	short sysvideo_21_12 ; set/write DAC colors
 57776                              <1> 	; 08/08/2022
 57777 0000F9DA 7405                <1> 	jz	short sysvideo_21_16
 57778 0000F9DC E9A3000000          <1> 	jmp	sysvideo_21_12
 57779                              <1> 
 57780                              <1> sysvideo_21_16:		
 57781                              <1> 	; Read DAC color register or all DAC color registers
 57782 0000F9E1 F6C302              <1> 	test	bl, 2  ; read single DAC color register
 57783 0000F9E4 7460                <1> 	jz	short sysvideo_21_10 ; read all DAC color regs	
 57784                              <1> 
 57785                              <1> 	; read single DAC color register
 57786                              <1> 	; CL = DAC color register (index)
 57787                              <1>  	
 57788 0000F9E6 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 57789 0000F9EA 88C8                <1> 	mov	al, cl	; DAC color register
 57790 0000F9EC 31C9                <1> 	xor	ecx, ecx
 57791 0000F9EE EE                  <1> 	out	dx, al
 57792                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57793 0000F9EF B2C9                <1> 	mov	dl, 0C9h
 57794 0000F9F1 EC                  <1> 	in	al, dx
 57795 0000F9F2 C0E002              <1> 	shl	al, 2
 57796 0000F9F5 88C5                <1> 	mov	ch, al	; red
 57797 0000F9F7 EC                  <1> 	in	al, dx
 57798 0000F9F8 C0E002              <1> 	shl	al, 2
 57799 0000F9FB 88C1                <1> 	mov	cl, al	; green
 57800 0000F9FD EC                  <1> 	in	al, dx
 57801 0000F9FE C0E002              <1> 	shl	al, 2
 57802                              <1> 	; 21/02/2021
 57803 0000FA01 C1E108              <1> 	shl	ecx, 8
 57804 0000FA04 88C1                <1> 	mov	cl, al	; blue
 57805                              <1> 	; CL = Blue, CH = Green, byte 3 = Red, byte 4 = 0
 57806                              <1> sysvideo_21_8:
 57807 0000FA06 890D[1C010300]      <1> 	mov	[u.r0], ecx
 57808                              <1> sysvideo_21_9:
 57809 0000FA0C E9E1D2FFFF          <1> 	jmp	sysret
 57810                              <1> 
 57811                              <1> sysvideo_21_5:
 57812                              <1> 	; write/set all DAC color registers
 57813 0000FA11 89CE                <1> 	mov	esi, ecx ; user's buffer address
 57814 0000FA13 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 57815 0000FA18 89FB                <1> 	mov	ebx, edi
 57816 0000FA1A B900030000          <1> 	mov	ecx, 768 ; 256*3
 57817 0000FA1F E853130000          <1> 	call	transfer_from_user_buffer
 57818                              <1> 	;jc	short sysvideo_21_1
 57819                              <1> 	; 08/08/2022
 57820 0000FA24 7305                <1> 	jnc	short sysvideo_21_17
 57821 0000FA26 E94CFFFFFF          <1> 	jmp	sysvideo_21_1
 57822                              <1> sysvideo_21_17:
 57823 0000FA2B 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 57824                              <1> 
 57825 0000FA31 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 57826 0000FA33 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 57827 0000FA37 28C0                <1> 	sub	al, al ; 0
 57828 0000FA39 EE                  <1> 	out	dx, al
 57829                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57830 0000FA3A FEC2                <1> 	inc	dl
 57831                              <1> sysvideo_21_6:
 57832 0000FA3C AC                  <1> 	lodsb
 57833 0000FA3D EE                  <1> 	out	dx, al
 57834 0000FA3E AC                  <1> 	lodsb
 57835 0000FA3F EE                  <1> 	out	dx, al
 57836 0000FA40 AC                  <1> 	lodsb
 57837 0000FA41 EE                  <1> 	out	dx, al
 57838 0000FA42 E2F8                <1> 	loop	sysvideo_21_6
 57839 0000FA44 EBC6                <1> 	jmp	short sysvideo_21_9
 57840                              <1> 
 57841                              <1> sysvideo_21_10:
 57842                              <1> 	; read all DAC color registers
 57843 0000FA46 89CD                <1> 	mov	ebp, ecx ; user's buffer address
 57844 0000FA48 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 57845 0000FA4D 89FE                <1> 	mov	esi, edi
 57846 0000FA4F B900040000          <1> 	mov	ecx, 1024 ; 256*4
 57847 0000FA54 51                  <1> 	push	ecx
 57848 0000FA55 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 57849 0000FA59 28C0                <1> 	sub	al, al ; 0
 57850 0000FA5B EE                  <1> 	out	dx, al
 57851                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57852 0000FA5C B2C9                <1> 	mov	dl, 0C9h
 57853                              <1> sysvideo_21_11:
 57854 0000FA5E 31DB                <1> 	xor	ebx, ebx
 57855 0000FA60 EC                  <1> 	in	al, dx	; Red
 57856 0000FA61 C0E002              <1> 	shl	al, 2
 57857 0000FA64 88C7                <1> 	mov	bh, al
 57858 0000FA66 EC                  <1> 	in	al, dx	; Green
 57859 0000FA67 C0E002              <1> 	shl	al, 2
 57860 0000FA6A 88C3                <1> 	mov	bl, al
 57861 0000FA6C EC                  <1> 	in	al, dx	; Blue
 57862 0000FA6D C0E002              <1> 	shl	al, 2
 57863 0000FA70 C1E308              <1> 	shl	ebx, 8
 57864 0000FA73 89D8                <1> 	mov	eax, ebx ; 00RRGGBBh
 57865 0000FA75 AB                  <1> 	stosd	
 57866 0000FA76 E2E6                <1> 	loop	sysvideo_21_11
 57867 0000FA78 59                  <1> 	pop	ecx
 57868                              <1> 
 57869 0000FA79 89EF                <1> 	mov	edi, ebp ; user's buffer address
 57870                              <1> 	;mov	esi, VBE3STACKADDR
 57871                              <1> 	;mov	ecx, 1024 = 4*256
 57872 0000FA7B E8AD120000          <1> 	call	transfer_to_user_buffer
 57873 0000FA80 728A                <1> 	jc	short sysvideo_21_9
 57874                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 57875 0000FA82 EB82                <1> 	jmp	short sysvideo_21_8
 57876                              <1> 
 57877                              <1> sysvideo_21_12:
 57878                              <1> 	; Set/Write DAC color register or all registers
 57879 0000FA84 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 57880 0000FA87 742A                <1> 	jz	short sysvideo_21_13 ; set all DAC color regs
 57881                              <1> 
 57882                              <1> 	; set single DAC color register
 57883                              <1> 	; CL = DAC color register (index)
 57884                              <1> 	; (byte 1 = Blue, byte 2 = Green, byte 3 = Red) 
 57885                              <1> 
 57886 0000FA89 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 57887 0000FA8D 88C8                <1> 	mov	al, cl	; DAC color register (index)
 57888 0000FA8F 88EC                <1> 	mov	ah, ch	; Blue 
 57889 0000FA91 C1E910              <1> 	shr	ecx, 16
 57890 0000FA94 EE                  <1> 	out	dx, al
 57891                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57892 0000FA95 FEC2                <1> 	inc	dl
 57893 0000FA97 88E8                <1> 	mov	al, ch	; Red
 57894 0000FA99 C0E802              <1> 	shr	al, 2
 57895 0000FA9C EE                  <1> 	out	dx, al
 57896 0000FA9D 88C8                <1> 	mov	al, cl	; Green
 57897 0000FA9F C0E802              <1> 	shr	al, 2
 57898 0000FAA2 EE                  <1> 	out	dx, al
 57899 0000FAA3 88E0                <1> 	mov	al, ah	; Blue
 57900 0000FAA5 C0E802              <1> 	shr	al, 2
 57901 0000FAA8 EE                  <1> 	out	dx, al	
 57902                              <1> 	;rol	ecx, 8
 57903 0000FAA9 C1E108              <1> 	shl	ecx, 8 ; 21/02/2021 
 57904 0000FAAC 88E1                <1> 	mov	cl, ah
 57905 0000FAAE E953FFFFFF          <1> 	jmp	sysvideo_21_8 ; 08/08/2022
 57906                              <1> 
 57907                              <1> sysvideo_21_13:
 57908                              <1> 	; write/set all DAC color registers
 57909 0000FAB3 89CE                <1> 	mov	esi, ecx ; user's buffer address
 57910 0000FAB5 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 57911 0000FABA 89FB                <1> 	mov	ebx, edi
 57912 0000FABC B900040000          <1> 	mov	ecx, 1024 ; 256*4
 57913 0000FAC1 E8B1120000          <1> 	call	transfer_from_user_buffer
 57914 0000FAC6 722E                <1> 	jc	short sysvideo_21_15
 57915 0000FAC8 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 57916                              <1> 
 57917 0000FACE 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 57918 0000FAD0 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 57919 0000FAD4 28C0                <1> 	sub	al, al ; 0
 57920 0000FAD6 EE                  <1> 	out	dx, al
 57921                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 57922 0000FAD7 FEC2                <1> 	inc	dl
 57923                              <1> sysvideo_21_14:
 57924 0000FAD9 AD                  <1> 	lodsd
 57925                              <1> 	; byte 0 = Blue, byte 1 = Green, byte 2 = Red
 57926                              <1> 	; 21/02/2021
 57927 0000FADA 89C3                <1> 	mov	ebx, eax ; BL = Blue, BH = Green
 57928 0000FADC C1CB08              <1> 	ror	ebx, 8 ; BL = Green, BH = Red
 57929 0000FADF 88F8                <1> 	mov	al, bh
 57930 0000FAE1 C0E802              <1> 	shr	al, 2
 57931 0000FAE4 EE                  <1> 	out	dx, al ; Red
 57932 0000FAE5 88D8                <1> 	mov	al, bl
 57933 0000FAE7 C0E802              <1> 	shr	al, 2	
 57934 0000FAEA EE                  <1> 	out	dx, al ; Green
 57935 0000FAEB C1C308              <1> 	rol	ebx, 8 ; BL = Blue
 57936 0000FAEE 88D8                <1> 	mov	al, bl
 57937 0000FAF0 C0E802              <1> 	shr	al, 2
 57938 0000FAF3 EE                  <1> 	out	dx, al ; Blue 
 57939 0000FAF4 E2E3                <1> 	loop	sysvideo_21_14
 57940                              <1> sysvideo_21_15:
 57941 0000FAF6 E9F7D1FFFF          <1> 	jmp	sysret
 57942                              <1> 
 57943                              <1> sysvideo_22:
 57944                              <1> 	; 28/02/2021
 57945                              <1> 	; 22/01/2021
 57946                              <1> 	; 17/01/2021
 57947                              <1> 	; 04/12/2020
 57948                              <1> 	; 03/12/2020
 57949                              <1> 	; BH = 9
 57950                              <1> 	; Set/Get VESA VBE3 protected mode interface params
 57951                              <1> 
 57952                              <1> 	; 22/01/2021
 57953                              <1> 	;cmp	byte [vbe3], 3
 57954                              <1> 	;jne	short sysvideo_25 ; not applicable if
 57955                              <1> 				; vbe3 compatible video bios
 57956                              <1> 				; is not detected by kernel	
 57957 0000FAFB 80FB02              <1> 	cmp	bl, 2
 57958                              <1> 	;ja	short sysvideo_25 ; bl > 2 not implemented
 57959                              <1> 	; 17/01/2021
 57960 0000FAFE 7716                <1> 	ja	short sysvideo_22_0 ; srvs flag sub function
 57961                              <1> 	;jb	short sysvideo_23
 57962                              <1> 
 57963                              <1> 	; 21/01/2021
 57964 0000FB00 803D[3F090000]03    <1> 	cmp	byte [vbe3], 3
 57965                              <1> 	;jne	short sysvideo_25 ; not applicable if
 57966                              <1> 				; vbe3 compatible video bios
 57967                              <1> 				; is not detected by kernel
 57968 0000FB07 75ED                <1> 	jne	short sysvideo_21_15 ; 28/02/2021
 57969                              <1> 	
 57970 0000FB09 80FB01              <1> 	cmp	bl, 1
 57971 0000FB0C 7673                <1> 	jna	short sysvideo_23
 57972                              <1> 
 57973 0000FB0E 8A1D[D00F0300]      <1> 	mov	bl, [pmi32] ; Video bios 32 bit PMI functions
 57974 0000FB14 EB78                <1> 	jmp	short sysvideo_24
 57975                              <1> 
 57976                              <1> sysvideo_22_0:
 57977                              <1> 	; 17/01/2021
 57978                              <1> 	; save/restore video state user permission
 57979 0000FB16 80FB05              <1> 	cmp	bl, 5
 57980 0000FB19 771E                <1> 	ja	short sysvideo_22_2
 57981 0000FB1B 7208                <1> 	jb	short sysvideo_22_1
 57982                              <1> 	; get srvs flag value/status
 57983 0000FB1D 8A1D[34100300]      <1> 	mov	bl, [srvsf] ; 0 = disabled, 1 = enabled
 57984 0000FB23 EB2C                <1> 	jmp	short sysvideo_22_3
 57985                              <1> 
 57986                              <1> sysvideo_22_1:
 57987                              <1> 	; permission (root and multi tasking) check
 57988 0000FB25 E836000000          <1> 	call	sysvideo_22_4
 57989 0000FB2A 736A                <1> 	jnc	short sysvideo_25 ; not permitted !
 57990                              <1> 	; cf = 1
 57991 0000FB2C 80EB03              <1> 	sub	bl, 3 ; disable = 0, enable = 1
 57992                              <1> 	; 22/01/2021
 57993 0000FB2F 881D[34100300]      <1> 	mov	[srvsf], bl
 57994 0000FB35 FEC3                <1> 	inc	bl ; 1 = disabled, 2 = enabled
 57995 0000FB37 EB18                <1> 	jmp	short sysvideo_22_3
 57996                              <1> 
 57997                              <1> sysvideo_22_2:
 57998 0000FB39 80FB06              <1> 	cmp	bl, 6
 57999                              <1> 	;ja	short sysvideo_25 ; invalid/unimplemented
 58000                              <1> 	; 28/02/2021
 58001 0000FB3C 7733                <1> 	ja	short sysvideo_22_6
 58002                              <1> 	; get VESA VBE number/status
 58003 0000FB3E 8A25[3F090000]      <1> 	mov	ah, [vbe3] ; vbe3 = 3, vbe2 = 2, others = 0
 58004 0000FB44 A0[40090000]        <1> 	mov	al, [vbe2bios] ; bochs/qemu/vbox emulator status
 58005 0000FB49 66A3[1C010300]      <1> 	mov	[u.r0], ax
 58006 0000FB4F EB45                <1> 	jmp	short sysvideo_25
 58007                              <1> 
 58008                              <1> sysvideo_22_3:
 58009                              <1> 	; 22/01/2021
 58010 0000FB51 8A3D[35100300]      <1> 	mov	bh, [srvso] ; state options (> 80h -> svga)
 58011 0000FB57 66891D[1C010300]    <1> 	mov	[u.r0], bx ; function result is return value 
 58012 0000FB5E EB36                <1> 	jmp	short sysvideo_25 
 58013                              <1> 
 58014                              <1> sysvideo_22_4:
 58015                              <1> 	; 17/01/2021 - permission will be given by root only
 58016 0000FB60 803D[0E840100]00    <1> 	cmp	byte [multi_tasking], 0 ; in single user mode
 58017 0000FB67 7707                <1> 	ja	short sysvideo_22_5
 58018                              <1> 	; 19/01/2021
 58019 0000FB69 803D[6E010300]01    <1>  	cmp	byte [u.uid], 1 ; ([u.uid] = 0 -> root)
 58020                              <1> sysvideo_22_5:
 58021                              <1> 	; [multi_tasking] = 0 & [u.uid] = 0 -> CF = 1
 58022                              <1> 	; otherwise -> CF = 0 
 58023 0000FB70 C3                  <1> 	retn
 58024                              <1> 
 58025                              <1> sysvideo_22_6:
 58026                              <1> 	; 28/02/2021
 58027 0000FB71 80FB09              <1> 	cmp	bl, 9
 58028 0000FB74 7720                <1> 	ja	short sysvideo_25 ; invalid/unimplemented
 58029 0000FB76 7436                <1> 	je	short sysvideo_22_9
 58030 0000FB78 80FB08              <1> 	cmp	bl, 8
 58031 0000FB7B 721E                <1> 	jb	short sysvideo_22_7
 58032                              <1> 
 58033                              <1> 	; BL = 8
 58034                              <1> 	; Set default true color bpp to 24
 58035                              <1> 
 58036 0000FB7D B318                <1> 	mov	bl, 24
 58037                              <1> 	;mov	[truecolor], al	; 24bpp (RRGGBBh)
 58038                              <1> 	;mov	[u.r0], al
 58039                              <1> 	;jmp	short sysvideo_25
 58040 0000FB7F EB25                <1> 	jmp	short sysvideo_22_8
 58041                              <1> 
 58042                              <1> sysvideo_23:
 58043                              <1> 	; 17/01/2021
 58044                              <1> 	; permission (root and multi tasking) check
 58045 0000FB81 E8DAFFFFFF          <1> 	call	sysvideo_22_4
 58046 0000FB86 730E                <1> 	jnc	short sysvideo_25 ; not permitted !
 58047                              <1> 
 58048 0000FB88 881D[D00F0300]      <1> 	mov	[pmi32], bl ; 1 = enabled, 0 = disabled 
 58049                              <1> sysvideo_24:
 58050 0000FB8E FEC3                <1> 	inc	bl
 58051                              <1> sysvideo_22_10:	; 28/02/2021
 58052 0000FB90 881D[1C010300]      <1> 	mov	[u.r0], bl ; function result is return value 
 58053                              <1> sysvideo_25:
 58054 0000FB96 E957D1FFFF          <1> 	jmp	sysret
 58055                              <1> 
 58056                              <1> sysvideo_22_7:
 58057                              <1> 	; BL = 7
 58058                              <1> 	; Set default true color bpp to 32
 58059                              <1> 	; (it will set if [VBE3]=3)
 58060                              <1> 
 58061                              <1> 	; Note: This sub function is used to set 24bpp
 58062                              <1> 	; VESA VBE video modes to 32bpp.. because,
 58063                              <1> 	; old hardware uses 24 bpp but new video hardware
 58064                              <1> 	; uses 32bpp for same VESA VBE truecolor modes.
 58065                              <1> 	; (For example: VBE mode 112h is 640*480, 24bpp but
 58066                              <1> 	; new hardware uses/apply it as 640*480, 32bpp.)  	
 58067                              <1> 	; So, TRDOS 386 v2.0.3 kernel will check [truecolor]
 58068                              <1> 	; status is 32 bpp or not and it will change 24bpp
 58069                              <1> 	; to 32bpp if default [truecolor] value is 32, for
 58070                              <1> 	; same video mode number.
 58071                              <1> 
 58072 0000FB9B 803D[3F090000]03    <1> 	cmp	byte [vbe3], 3
 58073 0000FBA2 75F2                <1> 	jne	short sysvideo_25 ; Only applicable 
 58074                              <1> 				  ; for VBE3 video hardware!
 58075 0000FBA4 B320                <1> 	mov	bl, 32
 58076                              <1> sysvideo_22_8:
 58077 0000FBA6 881D[43740100]      <1> 	mov	[truecolor], bl	; 32bpp (00RRGGBBh)
 58078                              <1> 	;mov	[u.r0], bl
 58079                              <1> 	;jmp	short sysvideo_25
 58080 0000FBAC EBE2                <1> 	jmp	short sysvideo_22_10
 58081                              <1> 
 58082                              <1> sysvideo_22_9:
 58083                              <1> 	; BL = 9
 58084                              <1> 	; Return default true color bpp
 58085 0000FBAE 8A1D[43740100]      <1> 	mov	bl, [truecolor]
 58086 0000FBB4 EBDA                <1> 	jmp	short sysvideo_22_10
 58087                              <1> ;sysvideo_22_10:
 58088                              <1> 	;mov	[u.r0], bl
 58089                              <1> 	;jmp	sysret
 58090                              <1> 
 58091                              <1> sysvideo_26:
 58092                              <1> 	; 23/12/2020
 58093                              <1> 	; BH = 10
 58094                              <1> 	; Map video memory to user's buffer
 58095                              <1> 	; (multiuser/owner r/w permisions are ignored
 58096                              <1> 	;  for current TRDOS 386 version !)
 58097                              <1> 
 58098 0000FBB6 6681E100F0          <1> 	and	cx, ~4095  ; clear low 12 bits
 58099 0000FBBB 09C9                <1> 	or	ecx, ecx ; start address of user's buffer
 58100 0000FBBD 74D7                <1> 	jz	short sysvideo_25 ; error !
 58101                              <1> 	
 58102 0000FBBF 80FB01              <1> 	cmp	bl, 1  ; VGA memory mapping ?
 58103 0000FBC2 740E                <1> 	je	short sysvideo_26_1
 58104 0000FBC4 7718                <1> 	ja	short sysvideo_26_2
 58105                              <1> sysvideo_26_0:
 58106                              <1> 	; BL = 0 : CGA memory (0B8000h) map (32K)
 58107 0000FBC6 B800800B00          <1> 	mov	eax, 0B8000h	
 58108 0000FBCB BB00800000          <1> 	mov	ebx, 32768
 58109 0000FBD0 EB37                <1> 	jmp	short sysvideo_26_3
 58110                              <1> sysvideo_26_1:
 58111                              <1> 	; BL = 1 : VGA memory (0A0000h) map (64K)
 58112 0000FBD2 B800000A00          <1> 	mov	eax, 0A0000h	
 58113 0000FBD7 BB00000100          <1> 	mov	ebx, 65536
 58114 0000FBDC EB2B                <1> 	jmp	short sysvideo_26_3
 58115                              <1> sysvideo_26_2:
 58116                              <1> 	; BL = 2 : SVGA memory (LFB) map to user's buffer
 58117 0000FBDE 803D[3F090000]02    <1> 	cmp	byte [vbe3], 2  ; VESA VBE 2/3 vbios ready ?
 58118 0000FBE5 72AF                <1> 	jb	short sysvideo_25  ; no, error !
 58119 0000FBE7 6681E200F0          <1> 	and	dx, ~4095 ; clear low 12 bits
 58120 0000FBEC 09D2                <1> 	or	edx, edx  ; buffer size in bytes	
 58121 0000FBEE 74A6                <1> 	jz	short sysvideo_25  ; error
 58122 0000FBF0 89D3                <1> 	mov	ebx, edx
 58123 0000FBF2 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 58124 0000FBF7 21C0                <1> 	and	eax, eax
 58125 0000FBF9 7425                <1> 	jz	short sysvideo_26_5
 58126                              <1> 				; (LFB parms are not set yet)
 58127 0000FBFB 3B1D[E40F0300]      <1> 	cmp	ebx, [LFB_SIZE] ; [LFB_Info+LFBINFO.LFB_size]
 58128 0000FC01 7606                <1> 	jna	short sysvideo_26_3
 58129 0000FC03 8B1D[E40F0300]      <1> 	mov	ebx, [LFB_SIZE]
 58130                              <1> sysvideo_26_3: 
 58131 0000FC09 52                  <1> 	push	edx
 58132 0000FC0A 53                  <1> 	push	ebx	; buffer size in bytes
 58133 0000FC0B 51                  <1> 	push	ecx	; user's buffer address
 58134 0000FC0C 87D9                <1> 	xchg	ebx, ecx
 58135 0000FC0E C1E90C              <1> 	shr	ecx, 12 ; convert buffer size to page count
 58136 0000FC11 E82462FFFF          <1> 	call	direct_memory_access
 58137 0000FC16 59                  <1> 	pop	ecx	; user's buffer address
 58138 0000FC17 5B                  <1> 	pop	ebx	; buffer size
 58139 0000FC18 5A                  <1> 	pop	edx
 58140                              <1> 	;jc	short sysvideo_25 ; error !
 58141                              <1> 				  ; [u.r0] = 0
 58142                              <1> 	; 28/02/2021
 58143 0000FC19 7235                <1> 	jc	short sysvideo_27_0 ; error !	
 58144                              <1> 
 58145                              <1> ;sysvideo_26_4:
 58146                              <1> 	;mov	ebp, [u.usp] ; ebp points to user's registers
 58147                              <1> 	;mov	[ebp+20], edx ; return to user with EDX value 
 58148                              <1> 	;mov	[ebp+16], ebx ; EBX
 58149                              <1> 	;mov	[ebp+24], ecx ; ECX
 58150                              <1> 	; eax = physical address of video memory (LFB)
 58151                              <1> 	;mov	[u.r0], eax
 58152                              <1> 	;jmp	sysret
 58153 0000FC1B E92CFCFFFF          <1> 	jmp	sysvideo_26_4
 58154                              <1> 
 58155                              <1> sysvideo_26_5:
 58156 0000FC20 66A1[CC0E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB for mode 118h
 58157                              <1> 	; ah must be 0C0h or 0D0h or E0h
 58158                              <1> 	; others are nonsence !?
 58159 0000FC26 08E4                <1>  	or	ah, ah
 58160                              <1> 	;jz	short sysvideo_25 ; invalid lfb addr or
 58161                              <1> 			  	; it is not a vbe2 -bochs emu- 
 58162                              <1> 			  	; or vbe3 -real- video bios
 58163                              <1> 	; 28/02/2021
 58164 0000FC28 7426                <1> 	jz	short sysvideo_27_0 ; invalid LFB address
 58165                              <1>  
 58166 0000FC2A 80FCF0              <1> 	cmp	ah, 0F0h  
 58167                              <1> 	;jnb	short sysvideo_25 ; nonsence !?
 58168                              <1> 	; 28/02/2021
 58169 0000FC2D 7321                <1> 	jnb	short sysvideo_27_0 ; nonsence !?
 58170                              <1> 
 58171 0000FC2F C1E010              <1> 	shl	eax, 16
 58172                              <1> 	;jz	short sysvideo_25 ; eax = 0 
 58173                              <1> 
 58174 0000FC32 81FB00907E00        <1> 	cmp	ebx, 1920*1080*4 ; maximum value of possible
 58175                              <1> 				 ; buffer sizes
 58176 0000FC38 76CF                <1> 	jna	short sysvideo_26_3  ; buffer size is proper
 58177                              <1> 	; resize buffer to fit 4GB limit
 58178 0000FC3A BB00907E00          <1> 	mov	ebx, 1920*1080*4
 58179 0000FC3F EBC8                <1> 	jmp	short sysvideo_26_3
 58180                              <1> 
 58181                              <1> sysvideo_27:
 58182                              <1> 	; 23/07/2022
 58183                              <1> 	; 16/02/2021
 58184                              <1> 	; 18/01/2021
 58185 0000FC41 80FF0C              <1> 	cmp	bh, 12
 58186                              <1> 	;ja	sysvideo_28 ; 19/01/2021
 58187                              <1> 	; 23/07/2022
 58188 0000FC44 7605                <1> 	jna	short sysvideo_27_24
 58189 0000FC46 E970010000          <1> 	jmp	sysvideo_28
 58190                              <1> 
 58191                              <1> sysvideo_27_24:	; 23/07/2022
 58192                              <1> 	; BH = 12
 58193                              <1> 	; Font sub functions.
 58194                              <1> 	; 12/02/2021
 58195                              <1> 	; 11/01/2021
 58196                              <1> 	; 10/01/2021
 58197                              <1> 	;   BL = 0 : Disable system font overwrite
 58198                              <1> 	;   BL = 1 : Enable system font overwrite
 58199                              <1> 	;   BL = 2 : Read system font 8x8
 58200                              <1> 	;   BL = 3 : Read system font 8x14
 58201                              <1> 	;   BL = 4 : Read system font 8x16
 58202                              <1> 	;   BL = 5 : Read user defined font 8x8
 58203                              <1> 	;   BL = 6 : Read user defined font 8x16
 58204                              <1> 	;   BL = 7 : Write system font 8x8
 58205                              <1> 	;   BL = 8 : Write system font 8x14
 58206                              <1> 	;   BL = 9 : Write system font 8x16
 58207                              <1> 	;   BL = 10 : Write user defined font 8x8
 58208                              <1> 	;   BL = 11 : Write user defined font 8x16
 58209                              <1> 	;
 58210                              <1> 	;  BL > 11 : invalid (not implemented)
 58211                              <1> 	;
 58212                              <1> 	; For BL = 1 to 11
 58213                              <1> 	;   ECX = number of characters (<= 256)
 58214                              <1> 	;   EDX = first character (ascii code in DL)
 58215                              <1> 	;   ESI = user's buffer address
 58216                              <1> 	;
 58217                              <1> 	; Return: EAX = character count 
 58218                              <1> 
 58219 0000FC4B 80FB0B              <1> 	cmp	bl, 11
 58220 0000FC4E 7605                <1> 	jna	short sysvideo_27_1
 58221                              <1> sysvideo_27_0:
 58222 0000FC50 E99DD0FFFF          <1> 	jmp	sysret ; not implemented yet !		
 58223                              <1> sysvideo_27_1:
 58224 0000FC55 66B80001            <1> 	mov	ax, 256
 58225 0000FC59 08DB                <1> 	or	bl, bl
 58226 0000FC5B 750E                <1>  	jnz	short sysvideo_27_3
 58227                              <1> 	
 58228                              <1> 	; bl = 0
 58229                              <1> 	; disable system font overwrite 
 58230                              <1> 
 58231 0000FC5D 8025[32100300]7F    <1> 	and	byte [ufont], 7Fh ; clear bit 7
 58232                              <1> sysvideo_27_2:
 58233                              <1> 	;mov	word [u.r0], 256  ; > 0 -> successful
 58234 0000FC64 A3[1C010300]        <1> 	mov	[u.r0], eax ; 256
 58235 0000FC69 EBE5                <1> 	jmp	short sysvideo_27_0
 58236                              <1> sysvideo_27_3:
 58237 0000FC6B 80FB01              <1> 	cmp	bl, 1
 58238 0000FC6E 7710                <1> 	ja	short sysvideo_27_4
 58239                              <1> 
 58240                              <1> 	; bl = 1
 58241                              <1> 	; enable system font overwrite 
 58242                              <1> 	;	if [multi_tasking]= 0 and [u.uid] = 0
 58243                              <1> 
 58244                              <1> 	;cmp	byte [multi_tasking], 0 
 58245                              <1> 	;			; multi tasking enabled ?
 58246                              <1> 	;ja	short sysvideo_27_0 ; yes
 58247                              <1> 	;; 19/01/2021 
 58248                              <1> 	;; system maintenance or single user mode
 58249                              <1> 	;cmp	byte [u.uid], 0  ; root ?
 58250                              <1> 	;ja	short sysvideo_27_0 ; no
 58251                              <1> 
 58252                              <1> 	; 19/01/2021
 58253                              <1> 	; multi tasking & root check
 58254 0000FC70 E8EBFEFFFF          <1> 	call	sysvideo_22_4
 58255 0000FC75 73D9                <1> 	jnc	short sysvideo_27_0 ; not permitted
 58256                              <1> 
 58257                              <1> 	; [multi_tasking]= 0 and [u.uid] = 0
 58258                              <1> 
 58259 0000FC77 800D[32100300]80    <1> 	or	byte [ufont], 80h ; set bit 7
 58260                              <1> 		
 58261 0000FC7E EBE4                <1>  	jmp	short sysvideo_27_2
 58262                              <1> 
 58263                              <1> sysvideo_27_4:
 58264 0000FC80 09C9                <1> 	or	ecx, ecx
 58265 0000FC82 74CC                <1> 	jz	short sysvideo_27_0
 58266 0000FC84 21D2                <1> 	and	edx, edx
 58267 0000FC86 7410                <1> 	jz	short sysvideo_27_4_0
 58268                              <1> 	;mov	ax, 256
 58269 0000FC88 39C1                <1> 	cmp	ecx, eax ; 256
 58270 0000FC8A 77C4                <1> 	ja	short sysvideo_27_0
 58271 0000FC8C 48                  <1> 	dec	eax
 58272 0000FC8D 39C2                <1> 	cmp	edx, eax ; 255
 58273 0000FC8F 77BF                <1> 	ja	short sysvideo_27_0
 58274 0000FC91 40                  <1> 	inc	eax
 58275 0000FC92 29D0                <1> 	sub	eax, edx ; 256 - DX
 58276 0000FC94 39C8                <1> 	cmp	eax, ecx
 58277 0000FC96 72B8                <1> 	jb	short sysvideo_27_0
 58278                              <1> 
 58279                              <1> sysvideo_27_4_0:
 58280 0000FC98 89F5                <1> 	mov	ebp, esi
 58281                              <1> 
 58282 0000FC9A 80FB06              <1> 	cmp	bl, 6
 58283 0000FC9D 7768                <1> 	ja	short sysvideo_27_13
 58284 0000FC9F 7210                <1> 	jb	short sysvideo_27_5
 58285                              <1> 	; bl = 6
 58286 0000FCA1 F605[32100300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 58287 0000FCA8 74A6                <1> 	jz	short sysvideo_27_0
 58288                              <1> 	; read 8x16 user defined font
 58289 0000FCAA BE00400900          <1> 	mov	esi, VGAFONT16USER
 58290 0000FCAF EB0C                <1> 	jmp	short sysvideo_27_6
 58291                              <1> sysvideo_27_5:
 58292 0000FCB1 80FB04              <1> 	cmp	bl, 4
 58293 0000FCB4 7239                <1> 	jb	short sysvideo_27_11
 58294 0000FCB6 7721                <1> 	ja	short sysvideo_27_9
 58295                              <1> 	; bl = 4
 58296                              <1> 	; read 8x16 system font
 58297 0000FCB8 BE[10640100]        <1> 	mov	esi, vgafont16
 58298                              <1> sysvideo_27_6:
 58299                              <1> 	; read 8x16 font
 58300                              <1> 	;shl	dx, 4 ; * 16
 58301                              <1> 	;shl	cx, 4 ; * 16 ; 16 bytes per char
 58302                              <1> 	; 23/07/2022
 58303 0000FCBD C1E204              <1> 	shl	edx, 4 ; * 16
 58304 0000FCC0 C1E104              <1> 	shl	ecx, 4 ; * 16
 58305                              <1> sysvideo_27_7:
 58306 0000FCC3 89EF                <1> 	mov	edi, ebp
 58307                              <1> 	;add	edi, edx ; 16/02/2021
 58308 0000FCC5 01D6                <1> 	add	esi, edx
 58309                              <1> 	; ecx = byte count
 58310                              <1> 	; esi = source (in system memory)
 58311                              <1> 	; edi = destination (in user memory)
 58312 0000FCC7 E861100000          <1> 	call	transfer_to_user_buffer
 58313 0000FCCC 7206                <1> 	jc	short sysvideo_27_8
 58314 0000FCCE 890D[1C010300]      <1> 	mov	[u.r0], ecx	
 58315                              <1> sysvideo_27_8:
 58316 0000FCD4 E919D0FFFF          <1> 	jmp	sysret
 58317                              <1> sysvideo_27_9:
 58318                              <1> 	; bl = 5
 58319 0000FCD9 F605[32100300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 58320 0000FCE0 74F2                <1> 	jz	short sysvideo_27_8
 58321                              <1> 	; read 8x8 user defined font
 58322 0000FCE2 BE00500900          <1> 	mov	esi, VGAFONT8USER
 58323                              <1> sysvideo_27_10:
 58324                              <1> 	; read 8x8 font
 58325                              <1> 	;shl	dx, 3 ; * 8
 58326                              <1> 	;shl	cx, 3 ; * 8 ; 8 bytes per char
 58327                              <1> 	; 23/07/2022
 58328 0000FCE7 C1E203              <1> 	shl	edx, 3 ; * 8
 58329 0000FCEA C1E103              <1> 	shl	ecx, 3 ; * 8
 58330 0000FCED EBD4                <1> 	jmp	short sysvideo_27_7
 58331                              <1> 
 58332                              <1> sysvideo_27_11:
 58333 0000FCEF 80FB03              <1> 	cmp	bl, 3  ; 8x14 system font
 58334 0000FCF2 720C                <1> 	jb	short sysvideo_27_12 ; 8x8 system font
 58335                              <1> 	; bl = 3
 58336                              <1> 	; read 8x14 system font 
 58337                              <1> 	;mov	al, 14
 58338                              <1> 	;mul	dl
 58339                              <1> 	;mov	dx, ax
 58340                              <1> 	;push	edx
 58341                              <1> 	;mov	ax, 14
 58342                              <1> 	;mul	cx
 58343                              <1> 	;mov	cx, ax
 58344                              <1> 	;pop	edx
 58345 0000FCF4 E8A5000000          <1> 	call	sysvideo_27_14
 58346 0000FCF9 BE[10560100]        <1> 	mov	esi, vgafont14
 58347 0000FCFE EBC3                <1> 	jmp	short sysvideo_27_7	
 58348                              <1> 	
 58349                              <1> sysvideo_27_12:
 58350                              <1> 	; bl = 2
 58351                              <1> 	; read 8x8 system font 
 58352 0000FD00 BE[104E0100]        <1> 	mov	esi, vgafont8
 58353 0000FD05 EBE0                <1> 	jmp	short sysvideo_27_10
 58354                              <1> 
 58355                              <1> sysvideo_27_13:
 58356                              <1> 	; overwrite font
 58357 0000FD07 80FB0A              <1> 	cmp	bl, 10
 58358 0000FD0A 776E                <1> 	ja	short sysvideo_27_22 ; 8x16 user font
 58359 0000FD0C 7224                <1> 	jb	short sysvideo_27_15
 58360                              <1> 	; bl = 10
 58361 0000FD0E BF00500900          <1> 	mov	edi, VGAFONT8USER
 58362 0000FD13 F605[32100300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 58363 0000FD1A 7556                <1> 	jnz	short sysvideo_27_21 ; yes
 58364 0000FD1C 08ED                <1> 	or	ch, ch ; cx = 256
 58365                              <1> 	;jnz	short sysvideo_27_21 ; 256 chars
 58366 0000FD1E 7406                <1> 	jz	short sysvideo_27_13_0
 58367 0000FD20 66B90008            <1> 	mov	cx, 8*256
 58368 0000FD24 EB35                <1> 	jmp	short sysvideo_27_18_0
 58369                              <1> sysvideo_27_13_0:
 58370                              <1> 	; copy system font to user font before overwrite
 58371 0000FD26 BE[104E0100]        <1> 	mov	esi, vgafont8
 58372                              <1> 	;push	edi
 58373                              <1> 	;push	ecx
 58374                              <1> 	;mov	cl, 64
 58375                              <1> 	;rep	movsd
 58376                              <1> 	;pop	ecx
 58377                              <1> 	;pop	edi
 58378                              <1> 	;mov	esi, ebp ; user's font buffer
 58379 0000FD2B E880000000          <1> 	call	sysvideo_27_23
 58380 0000FD30 EB40                <1> 	jmp	short sysvideo_27_21
 58381                              <1> 
 58382                              <1> sysvideo_27_15:
 58383                              <1> 	; check system font overwrite permission
 58384 0000FD32 F605[32100300]80    <1> 	test	byte [ufont], 80h
 58385 0000FD39 7499                <1> 	jz	short sysvideo_27_8
 58386                              <1> 
 58387 0000FD3B 80FB08              <1> 	cmp	bl, 8
 58388 0000FD3E 773A                <1> 	ja	short sysvideo_27_22 ; 8x16 system font
 58389 0000FD40 722B                <1> 	jb	short sysvideo_27_20 ; 8x8 system font
 58390                              <1> 	; bl = 8
 58391                              <1> 	; overwrite 8x14 system font 
 58392                              <1> 	;mov	al, 14
 58393                              <1> 	;mul	dl
 58394                              <1> 	;mov	dx, ax
 58395                              <1> 	;push	edx
 58396                              <1> 	;mov	ax, 14
 58397                              <1> 	;mul	cx
 58398                              <1> 	;mov	cx, ax
 58399                              <1> 	;pop	edx
 58400 0000FD42 E857000000          <1> 	call	sysvideo_27_14
 58401 0000FD47 BF[10560100]        <1> 	mov	edi, vgafont14
 58402 0000FD4C EB0B                <1> 	jmp	short sysvideo_27_18
 58403                              <1> sysvideo_27_16:
 58404                              <1> 	; bl = 9
 58405                              <1> 	; overwrite 8x16 system font
 58406 0000FD4E BF[10640100]        <1> 	mov	edi, vgafont16
 58407                              <1> sysvideo_27_17:
 58408                              <1> 	; overwrite 8x16 font
 58409                              <1> 	;shl	dx, 4 ; * 16
 58410                              <1> 	;shl	cx, 4 ; * 16 ; 16 bytes per char
 58411                              <1> 	; 23/07/2022
 58412 0000FD53 C1E204              <1> 	shl	edx, 4 ; * 16
 58413 0000FD56 C1E104              <1> 	shl	ecx, 4 ; * 16
 58414                              <1> sysvideo_27_18:
 58415 0000FD59 01D7                <1> 	add	edi, edx
 58416                              <1> 	;add	esi, edx ; 16/02/2021
 58417                              <1> sysvideo_27_18_0:
 58418                              <1> 	; ecx = byte count
 58419                              <1> 	; esi = source (in user memory)
 58420                              <1> 	; edi = destination (in system memory)
 58421 0000FD5B E817100000          <1> 	call	transfer_from_user_buffer
 58422 0000FD60 7206                <1> 	jc	short sysvideo_27_19
 58423 0000FD62 890D[1C010300]      <1> 	mov	[u.r0], ecx	
 58424                              <1> sysvideo_27_19:
 58425 0000FD68 E985CFFFFF          <1> 	jmp	sysret
 58426                              <1> sysvideo_27_20:
 58427                              <1> 	; bl = 7
 58428                              <1> 	; overwrite 8x8 system font
 58429 0000FD6D BF[104E0100]        <1> 	mov	edi, vgafont8
 58430                              <1> sysvideo_27_21:
 58431                              <1> 	; overwrite 8x8 font
 58432                              <1> 	;shl	dx, 3 ; * 8
 58433                              <1> 	;shl	cx, 3 ; * 8 ; 8 bytes per char
 58434                              <1> 	; 23/07/2022
 58435 0000FD72 C1E203              <1> 	shl	edx, 3 ; * 8
 58436 0000FD75 C1E103              <1> 	shl	ecx, 3 ; * 8
 58437 0000FD78 EBDF                <1> 	jmp	short sysvideo_27_18
 58438                              <1> sysvideo_27_22:
 58439                              <1> 	; bl = 11
 58440                              <1> 	; overwrite 8x16 user defined font
 58441 0000FD7A BF00400900          <1> 	mov	edi, VGAFONT16USER
 58442 0000FD7F F605[32100300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 58443 0000FD86 75CB                <1> 	jnz	short sysvideo_27_17 ; yes
 58444 0000FD88 08ED                <1> 	or	ch, ch ; cx = 256
 58445                              <1> 	;jnz	short sysvideo_27_17 ; 256 chars
 58446 0000FD8A 7406                <1> 	jz	short sysvideo_27_22_0
 58447 0000FD8C 66B90010            <1> 	mov	cx, 16*256
 58448 0000FD90 EBC9                <1> 	jmp	short sysvideo_27_18_0
 58449                              <1> sysvideo_27_22_0:
 58450                              <1> 	; copy system font to user font before overwrite
 58451 0000FD92 BE[10640100]        <1> 	mov	esi, vgafont16
 58452                              <1> 	;push	edi
 58453                              <1> 	;push	ecx
 58454                              <1> 	;mov	cl, 64
 58455                              <1> 	;rep	movsd
 58456                              <1> 	;pop	ecx
 58457                              <1> 	;pop	edi
 58458                              <1> 	;mov	esi, ebp ; user's font buffer
 58459 0000FD97 E814000000          <1> 	call	sysvideo_27_23
 58460 0000FD9C EBB5                <1> 	jmp	short sysvideo_27_17
 58461                              <1> 
 58462                              <1> sysvideo_27_14:
 58463                              <1> 	; 16/02/2021
 58464 0000FD9E 52                  <1> 	push	edx
 58465 0000FD9F 66B80E00            <1> 	mov	ax, 14	
 58466 0000FDA3 66F7E1              <1> 	mul	cx
 58467 0000FDA6 89C1                <1> 	mov	ecx, eax
 58468 0000FDA8 5A                  <1> 	pop	edx
 58469 0000FDA9 B00E                <1> 	mov	al, 14
 58470 0000FDAB F6E2                <1> 	mul	dl
 58471 0000FDAD 89C2                <1> 	mov	edx, eax
 58472 0000FDAF C3                  <1> 	retn
 58473                              <1> 
 58474                              <1> 	;mov	al, 14
 58475                              <1> 	;mul	dl
 58476                              <1> 	;mov	dx, ax
 58477                              <1> 	;push	edx
 58478                              <1> 	;; 12/02/2021
 58479                              <1> 	;mov	ax, 14
 58480                              <1> 	;;mov	eax, 14
 58481                              <1> 	;;mul	cx
 58482                              <1> 	;mul	ecx
 58483                              <1> 	;;mov	cx, ax
 58484                              <1> 	;mov	ecx, eax
 58485                              <1> 	;pop	edx
 58486                              <1> 	;retn	
 58487                              <1> 
 58488                              <1> sysvideo_27_23:
 58489 0000FDB0 57                  <1> 	push	edi
 58490 0000FDB1 51                  <1> 	push	ecx
 58491 0000FDB2 B140                <1> 	mov	cl, 64
 58492 0000FDB4 F3A5                <1> 	rep	movsd
 58493 0000FDB6 59                  <1> 	pop	ecx
 58494 0000FDB7 5F                  <1> 	pop	edi
 58495 0000FDB8 89EE                <1> 	mov	esi, ebp ; user's font buffer
 58496 0000FDBA C3                  <1> 	retn
 58497                              <1> 
 58498                              <1> sysvideo_28:
 58499                              <1> 	; 23/07/2022
 58500                              <1> 	; 24/01/2021
 58501                              <1> 	; 23/01/2021
 58502                              <1> 	; 18/01/2021
 58503 0000FDBB 80FF0E              <1> 	cmp	bh, 14
 58504                              <1> 	;jb	sysvideo_29
 58505                              <1> 	; 23/07/2022
 58506 0000FDBE 7222                <1> 	jb	short sysvideo_28_29
 58507                              <1> 	;ja	sysvideo_30
 58508                              <1> 	; 23/07/2022
 58509 0000FDC0 7725                <1> 	ja	short sysvideo_28_30
 58510                              <1> 
 58511                              <1> 	; BH = 14
 58512                              <1> 	; Save/Restore Super VGA video state
 58513                              <1> 	
 58514                              <1> 	; BL = options
 58515                              <1> 	;	bit 0 - Save (0) or Restore (1)	
 58516                              <1> 	;	bit 1 - controller hardware state
 58517                              <1> 	;	bit 2 - BIOS data state
 58518                              <1> 	;	bit 3 - DAC state
 58519                              <1> 	;	bit 4 - (extended) Register state
 58520                              <1> 	;	bit 5 - system (0) or user (1) memory
 58521                              <1> 	;	bit 6 - verify without transfer
 58522                              <1> 	;	bit 7 - not used (must be 0)
 58523                              <1> 
 58524                              <1> 	; ECX = Buffer address or VideoStateID
 58525                              <1> 
 58526 0000FDC2 803D[3F090000]02    <1> 	cmp	byte [vbe3], 2 ;  VESA VBE2 or VBE3 ?
 58527 0000FDC9 7721                <1> 	ja	short sysvideo_28_0 ; yes
 58528 0000FDCB 7210                <1> 	jb	short sysvideo_28_16 ; not a SVGA sys !
 58529                              <1> 
 58530                              <1> 	; == VBE2 ==
 58531                              <1> 	; Check Bochs/Qemu/VirtualBox PC emulator
 58532                              <1> 	; (vbe2 is usable only for emulator's vbios)
 58533 0000FDCD 8A25[40090000]      <1> 	mov	ah, [vbe2bios]
 58534 0000FDD3 80FCC0              <1> 	cmp	ah, 0C0h	
 58535 0000FDD6 7205                <1> 	jb	short sysvideo_28_16 ; unknown vbios !
 58536 0000FDD8 80FCC5              <1> 	cmp	ah, 0C5h
 58537 0000FDDB 760F                <1> 	jna	short sysvideo_28_0
 58538                              <1> 		; Use kernel's vbios functions (video.s)
 58539                              <1> sysvideo_28_16:
 58540                              <1> 	; unknown vbios !
 58541 0000FDDD E910CFFFFF          <1> 	jmp	sysret
 58542                              <1> 
 58543                              <1> sysvideo_28_29:
 58544                              <1> 	; 23/07/2022
 58545 0000FDE2 E955010000          <1> 	jmp	sysvideo_29
 58546                              <1> sysvideo_28_30:
 58547                              <1> 	; 23/07/2022
 58548 0000FDE7 E935020000          <1> 	jmp	sysvideo_30	
 58549                              <1> 
 58550                              <1> sysvideo_28_0:
 58551 0000FDEC 80FB7F              <1> 	cmp	bl, 7Fh
 58552 0000FDEF 77EC                <1> 	ja	short sysvideo_28_16 ; unknown options
 58553                              <1> 
 58554 0000FDF1 88DA                <1> 	mov	dl, bl
 58555 0000FDF3 80E21F              <1> 	and	dl, 1Fh 
 58556 0000FDF6 D0EA                <1> 	shr	dl, 1
 58557 0000FDF8 74E3                <1> 	jz	short sysvideo_28_16 ; invalid !
 58558                              <1> 	; DL = VBE Function 4F04h Save/Restore options 	
 58559                              <1> 	;  bit 0 : controller hardware state
 58560                              <1> 	;  bit 1 : BIOS data state
 58561                              <1> 	;  bit 2 : DAC state
 58562                              <1> 	;  bit 3 : (extended) Register state
 58563                              <1> 	
 58564 0000FDFA F6C320              <1> 	test	bl, 32 ; bit 5
 58565                              <1> 	;jnz	sysvideo_28_7 ; user buffer
 58566                              <1> 	; 23/07/2022
 58567 0000FDFD 7405                <1> 	jz	short sysvideo_28_17
 58568 0000FDFF E9B1000000          <1> 	jmp	sysvideo_28_7
 58569                              <1> 
 58570                              <1> sysvideo_28_17:	 ; 23/07/2022
 58571                              <1> 	; source or destination is kernel/system buffer
 58572                              <1> 
 58573 0000FE04 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 58574 0000FE0B 76D0                <1> 	jna	short sysvideo_28_16 ; not permitted
 58575                              <1> 
 58576 0000FE0D F6C301              <1> 	test	bl, 1
 58577 0000FE10 743A                <1> 	jz	short sysvideo_28_4 ; Save
 58578                              <1> 
 58579                              <1> 	; Restore
 58580 0000FE12 3B0D[36100300]      <1> 	cmp	ecx, [VideoStateID]
 58581 0000FE18 75C3                <1> 	jne	short sysvideo_28_16 ; not correct ID !
 58582                              <1> 		
 58583 0000FE1A 0FB6CA              <1> 	movzx	ecx, dl
 58584 0000FE1D 80CA80              <1> 	or	dl, 80h
 58585 0000FE20 3A15[35100300]      <1> 	cmp	dl, [srvso]
 58586 0000FE26 75B5                <1> 	jne	short sysvideo_28_16 ; not correct !
 58587                              <1> 
 58588 0000FE28 88DA                <1> 	mov	dl, bl
 58589                              <1> 
 58590                              <1> 	; ecx = cl = options
 58591 0000FE2A E88B3CFFFF          <1> 	call	vbe_srs_gbs
 58592                              <1> 	; ebx = state buffer size (data size)
 58593                              <1> 
 58594 0000FE2F 891D[1C010300]      <1> 	mov	[u.r0], ebx
 58595                              <1> 
 58596 0000FE35 F6C240              <1> 	test	dl, 64 ; verify without transfer
 58597 0000FE38 75A3                <1> 	jnz	short sysvideo_28_16 ; yes
 58598                              <1> 
 58599 0000FE3A BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE	
 58600 0000FE3F BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 58601 0000FE44 87CB                <1> 	xchg	ecx, ebx
 58602 0000FE46 F3A4                <1> 	rep	movsb
 58603                              <1> 	
 58604 0000FE48 88D9                <1> 	mov	cl, bl
 58605                              <1> 
 58606                              <1> 	; 23/01/2021
 58607 0000FE4A EB44                <1> 	jmp	short sysvideo_28_10
 58608                              <1> 
 58609                              <1> sysvideo_28_4:
 58610 0000FE4C 53                  <1> 	push	ebx	
 58611                              <1> 	; 24/01/2021
 58612 0000FE4D 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 58613 0000FE4F 881D[35100300]      <1> 	mov	[srvso], bl ; 0 ; invalidate
 58614 0000FE55 891D[36100300]      <1> 	mov	[VideoStateID], ebx ; 0 ; invalidate
 58615 0000FE5B 0FB6CA              <1> 	movzx	ecx, dl ; options
 58616 0000FE5E B201                <1> 	mov	dl, 1 ; save state		
 58617 0000FE60 E890000000          <1> 	call	sysvideo_28_11 ; 23/01/2021
 58618                              <1> 	; Note: VBE3 BIOS data save option will be
 58619                              <1> 	;	disabled.. ; 24/01/2021
 58620 0000FE65 89CA                <1> 	mov	edx, ecx ; state (save) options
 58621 0000FE67 5B                  <1> 	pop	ebx
 58622                              <1> 	
 58623 0000FE68 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 58624 0000FE6C 7536                <1> 	jne	short sysvideo_28_3 ; no !
 58625                              <1> 
 58626 0000FE6E F6C340              <1> 	test	bl, 64 ; verify without transfer
 58627 0000FE71 7536                <1> 	jnz	short sysvideo_28_6 ; yes
 58628                              <1> 
 58629                              <1> 	; ecx = cl = options
 58630 0000FE73 E8423CFFFF          <1> 	call	vbe_srs_gbs
 58631                              <1> 	; ebx = state buffer size (data size)
 58632                              <1> 
 58633 0000FE78 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 58634 0000FE7D BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE	
 58635 0000FE82 89D9                <1> 	mov	ecx, ebx
 58636 0000FE84 F3A4                <1> 	rep	movsb
 58637                              <1> 
 58638 0000FE86 88D1                <1> 	mov	cl, dl
 58639 0000FE88 80C980              <1> 	or	cl, 80h ; SVGA (VESA VBE) flag
 58640                              <1> 	;mov	[srvso], dl
 58641                              <1> 
 58642 0000FE8B E908010000          <1> 	jmp	sysvideo_28_15
 58643                              <1> 
 58644                              <1> 	; 23/01/2021
 58645                              <1> sysvideo_28_10:
 58646                              <1> 	; CL = VESA VBE3 Save/Restore options
 58647                              <1> 
 58648 0000FE90 B202                <1> 	mov	dl, 2 ; restore state
 58649                              <1> 
 58650 0000FE92 E85C000000          <1> 	call	sysvideo_28_1
 58651                              <1> 
 58652 0000FE97 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 58653 0000FE9B 7407                <1> 	je	short sysvideo_28_3
 58654                              <1> 	;jmp	short sysvideo_28_9 
 58655                              <1> 
 58656                              <1> sysvideo_28_9:
 58657                              <1> 	; return zero size (error) to user
 58658 0000FE9D 29C0                <1> 	sub	eax, eax
 58659                              <1> sysvideo_28_5:
 58660 0000FE9F A3[1C010300]        <1> 	mov	[u.r0], eax
 58661                              <1> sysvideo_28_3:
 58662 0000FEA4 E949CEFFFF          <1> 	jmp	sysret
 58663                              <1> 
 58664                              <1> sysvideo_28_6:
 58665                              <1> 	; use timer ticks as VideoStateID
 58666 0000FEA9 A1[00780100]        <1> 	mov	eax, [TIMER_LH]
 58667 0000FEAE 09C0                <1> 	or 	eax, eax
 58668 0000FEB0 75ED                <1> 	jnz	short sysvideo_28_5
 58669 0000FEB2 40                  <1> 	inc	eax
 58670 0000FEB3 EBEA                <1> 	jmp	short sysvideo_28_5
 58671                              <1> 
 58672                              <1> sysvideo_28_7:
 58673                              <1> 	; save/restore to/from user buffer
 58674                              <1> 
 58675                              <1> 	; 23/01/2021
 58676 0000FEB5 89CE                <1> 	mov	esi, ecx ; user's vstate buffer
 58677 0000FEB7 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 58678                              <1> 
 58679 0000FEBC 0FB6CA              <1> 	movzx	ecx, dl ; VESA VBE func 4F04h options
 58680                              <1> 
 58681                              <1> 	; source or destination is user buffer
 58682 0000FEBF F6C301              <1> 	test	bl, 1
 58683 0000FEC2 7444                <1> 	jz	short sysvideo_28_12  ; Save
 58684                              <1> 
 58685                              <1> 	; Restore
 58686 0000FEC4 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 58687 0000FECB 766A                <1> 	jna	short sysvideo_28_14 ; not permitted
 58688                              <1> 
 58689 0000FECD 88DA                <1> 	mov	dl, bl ; 'sysvideo' options
 58690                              <1> 
 58691                              <1> 	; ecx = cl = options
 58692 0000FECF E8E63BFFFF          <1> 	call	vbe_srs_gbs
 58693                              <1> 	; ebx = state buffer size (data size)
 58694                              <1> 
 58695 0000FED4 891D[1C010300]      <1> 	mov	[u.r0], ebx ; transfer count
 58696                              <1> 
 58697 0000FEDA F6C240              <1> 	test	dl, 64 ; verify without transfer
 58698 0000FEDD 7558                <1> 	jnz	short sysvideo_28_14 ; yes
 58699                              <1>  
 58700 0000FEDF 6681FB0008          <1> 	cmp	bx, 2048
 58701 0000FEE4 73B7                <1> 	jnb	short sysvideo_28_9 ; invalid
 58702                              <1> 
 58703 0000FEE6 87CB                <1> 	xchg	ecx, ebx
 58704                              <1> 	; esi = user buffer
 58705                              <1> 	; edi = VBE3SAVERESTOREBLOCK
 58706                              <1> 
 58707 0000FEE8 E88A0E0000          <1> 	call	transfer_from_user_buffer
 58708 0000FEED 72AE                <1> 	jc	short sysvideo_28_9 ; error 
 58709                              <1> 
 58710 0000FEEF 89D9                <1> 	mov	ecx, ebx ; Function 4F04h options
 58711 0000FEF1 EB9D                <1> 	jmp	short sysvideo_28_10 ; 23/01/2021
 58712                              <1> 
 58713                              <1> sysvideo_28_1:
 58714 0000FEF3 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 58715                              <1> sysvideo_28_11:
 58716                              <1> 	; 24/01/2021
 58717 0000FEF5 803D[3F090000]03    <1> 	cmp	byte [vbe3], 3
 58718 0000FEFC 7405                <1> 	je	short sysvideo_28_2
 58719                              <1> 
 58720                              <1> 	; VESA VBE2 (BOCHS/QEMU/VBOX) video bios
 58721 0000FEFE E9203BFFFF          <1> 	jmp	_vbe_biosfn_save_restore_state
 58722                              <1> sysvideo_28_2:
 58723                              <1> 	;24/01/2021
 58724                              <1> 	;mov	eax, 4F04h  ; Save/Restore vstate
 58725                              <1> 	; VESA VBE3 video bios
 58726 0000FF03 E9961AFFFF          <1> 	jmp	_vbe3_pmfn_save_restore_state
 58727                              <1> 	
 58728                              <1> sysvideo_28_12:
 58729                              <1> 	; Save
 58730                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 58731                              <1> 
 58732                              <1> 	;movzx	ecx, dl ; options
 58733 0000FF08 56                  <1> 	push	esi
 58734 0000FF09 53                  <1> 	push	ebx
 58735                              <1> 	; 23/01/2021
 58736 0000FF0A B201                <1> 	mov	dl, 1 ; save state
 58737 0000FF0C E8E2FFFFFF          <1> 	call	sysvideo_28_1
 58738 0000FF11 5A                  <1> 	pop	edx ; 'sysvideo' options
 58739 0000FF12 5F                  <1> 	pop	edi ; user's video state buffer
 58740                              <1> 
 58741 0000FF13 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 58742 0000FF17 751E                <1> 	jne	short sysvideo_28_14 ; no !
 58743                              <1> 
 58744                              <1> 	; ecx = cl = options
 58745 0000FF19 E89C3BFFFF          <1> 	call	vbe_srs_gbs
 58746                              <1> 	; ebx = state buffer size (data size)
 58747                              <1> 
 58748 0000FF1E 89D9                <1> 	mov	ecx, ebx ; transfer count
 58749                              <1> 
 58750 0000FF20 F6C240              <1> 	test	dl, 64 ; verify without transfer
 58751 0000FF23 750C                <1> 	jnz	short sysvideo_28_13 ; yes
 58752                              <1> 		
 58753                              <1> 	;mov	edi, esi
 58754 0000FF25 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 58755 0000FF2A E8FE0D0000          <1> 	call	transfer_to_user_buffer
 58756 0000FF2F 7206                <1> 	jc	short sysvideo_28_14
 58757                              <1> sysvideo_28_13:
 58758 0000FF31 890D[1C010300]      <1> 	mov	[u.r0], ecx
 58759                              <1> sysvideo_28_14:
 58760 0000FF37 E9B6CDFFFF          <1> 	jmp	sysret
 58761                              <1> 
 58762                              <1> sysvideo_29:
 58763                              <1> 	; 18/01/2021
 58764                              <1> 	; BH = 13
 58765                              <1> 	; Save/Restore std VGA video state
 58766                              <1> 
 58767                              <1> 	; bl = 0..3
 58768                              <1> 	;	save to or restore from
 58769                              <1> 	;	system buffer, VBE3VIDEOSTATE
 58770                              <1> 	;	ECX = VideoStateID for restoring	
 58771                              <1> 	; bl = 4..7
 58772                              <1> 	;	save to or restore from
 58773                              <1> 	;	user buffer pointed by ECX
 58774                              <1> 		   	
 58775 0000FF3C 80FB03              <1> 	cmp	bl, 3
 58776 0000FF3F 7776                <1> 	ja	short sysvideo_29_6
 58777                              <1> 
 58778                              <1> 	; source or destination is kernel/system buffer
 58779                              <1> 
 58780 0000FF41 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 58781 0000FF48 7668                <1> 	jna	short sysvideo_29_5 ; not permitted
 58782                              <1> 
 58783 0000FF4A F6C301              <1> 	test	bl, 1
 58784 0000FF4D 7437                <1> 	jz	short sysvideo_29_2  ; Save
 58785                              <1> 
 58786                              <1> 	; Restore
 58787 0000FF4F 3B0D[36100300]      <1> 	cmp	ecx, [VideoStateID]
 58788 0000FF55 755B                <1> 	jne	short sysvideo_29_5 ; not correct ID !
 58789 0000FF57 80FB01              <1> 	cmp	bl, 1
 58790 0000FF5A 7709                <1> 	ja	short sysvideo_29_0
 58791                              <1> 	; bl = 1
 58792 0000FF5C BB6E000000          <1> 	mov	ebx, 110 
 58793 0000FF61 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 58794 0000FF63 EB07                <1> 	jmp	short sysvideo_29_1
 58795                              <1> sysvideo_29_0:
 58796                              <1>  	; bl  = 3
 58797 0000FF65 BB72030000          <1> 	mov	ebx, 882 
 58798 0000FF6A B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 58799                              <1> sysvideo_29_1:
 58800 0000FF6C 3A0D[35100300]      <1> 	cmp	cl, [srvso]
 58801 0000FF72 753E                <1> 	jne	short sysvideo_29_5 ; not correct !
 58802                              <1> 
 58803 0000FF74 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE ; 22/01/2021
 58804 0000FF79 E8D03CFFFF          <1> 	call	biosfn_restore_video_state
 58805 0000FF7E 891D[1C010300]      <1> 	mov	[u.r0], ebx ; video state size (bytes)
 58806                              <1> 	;jmp	sysret
 58807 0000FF84 EB2C                <1> 	jmp	short sysvideo_29_5	
 58808                              <1> sysvideo_29_2:
 58809                              <1> 	;mov	esi, ecx
 58810 0000FF86 BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE
 58811                              <1> 	
 58812 0000FF8B B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 58813 0000FF8D 08DB                <1> 	or	bl, bl
 58814 0000FF8F 7502                <1> 	jnz	short sysvideo_29_3 ; bl = 2
 58815                              <1> 	; bl = 0 
 58816 0000FF91 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 58817                              <1> sysvideo_29_3:
 58818 0000FF93 E84E3BFFFF          <1> 	call	biosfn_save_video_state
 58819                              <1> sysvideo_28_15:
 58820                              <1> 	; use timer ticks as VideoStateID
 58821 0000FF98 A1[00780100]        <1> 	mov	eax, [TIMER_LH]
 58822 0000FF9D 21C0                <1> 	and 	eax, eax
 58823 0000FF9F 7501                <1> 	jnz	short sysvideo_29_4
 58824 0000FFA1 40                  <1> 	inc	eax
 58825                              <1> sysvideo_29_4:
 58826 0000FFA2 880D[35100300]      <1> 	mov	[srvso], cl
 58827 0000FFA8 A3[36100300]        <1> 	mov	[VideoStateID], eax
 58828 0000FFAD A3[1C010300]        <1> 	mov	[u.r0], eax
 58829                              <1> sysvideo_29_5:
 58830 0000FFB2 E93BCDFFFF          <1> 	jmp	sysret
 58831                              <1> 
 58832                              <1> sysvideo_29_6:
 58833 0000FFB7 80FB07              <1> 	cmp	bl, 7
 58834 0000FFBA 77F6                <1> 	ja	short sysvideo_29_5 ; invalid sub function 
 58835                              <1> 
 58836 0000FFBC 89CE                <1> 	mov	esi, ecx
 58837 0000FFBE BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 58838                              <1> 
 58839                              <1> 	; source or destination is user buffer
 58840 0000FFC3 F6C301              <1> 	test	bl, 1
 58841 0000FFC6 7434                <1> 	jz	short sysvideo_29_9  ; Save
 58842                              <1> 
 58843                              <1> 	; Restore
 58844 0000FFC8 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 58845 0000FFCF 76E1                <1> 	jna	short sysvideo_29_5 ; not permitted
 58846                              <1> 	
 58847                              <1> 	;mov	esi, ecx
 58848                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 58849                              <1> 	
 58850 0000FFD1 80FB07              <1> 	cmp	bl, 7
 58851 0000FFD4 7409                <1> 	je	short sysvideo_29_7
 58852                              <1> 	; bl = 5 
 58853 0000FFD6 B303                <1> 	mov	bl, 3
 58854 0000FFD8 B96E000000          <1> 	mov	ecx, 110
 58855 0000FFDD EB05                <1> 	jmp	short sysvideo_29_8
 58856                              <1> sysvideo_29_7:
 58857                              <1> 	; bl = 7
 58858 0000FFDF B972030000          <1> 	mov	ecx, 882
 58859                              <1> sysvideo_29_8:
 58860 0000FFE4 E88E0D0000          <1> 	call	transfer_from_user_buffer
 58861 0000FFE9 72C7                <1> 	jc	short sysvideo_29_5
 58862 0000FFEB 890D[1C010300]      <1> 	mov	[u.r0], ecx
 58863 0000FFF1 88D9                <1> 	mov	cl, bl ; mov cl,7 (mov cl,3)
 58864 0000FFF3 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 58865                              <1> 	; cl = 3 or 7  	
 58866 0000FFF5 E8543CFFFF          <1> 	call	biosfn_restore_video_state
 58867 0000FFFA EBB6                <1> 	jmp	sysvideo_29_5
 58868                              <1> 	;jmp	sysret
 58869                              <1> sysvideo_29_9:
 58870                              <1> 	; Save
 58871                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 58872                              <1> 
 58873 0000FFFC 80FB06              <1> 	cmp	bl, 6
 58874 0000FFFF 7409                <1> 	je	short sysvideo_29_10
 58875                              <1> 	; bl = 4
 58876 00010001 BB6E000000          <1> 	mov	ebx, 110
 58877 00010006 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 58878 00010008 EB07                <1> 	jmp	short sysvideo_29_11
 58879                              <1> sysvideo_29_10:
 58880                              <1> 	; bl = 6
 58881 0001000A BB72030000          <1> 	mov	ebx, 882
 58882 0001000F B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 58883                              <1> sysvideo_29_11:
 58884 00010011 E8D03AFFFF          <1> 	call	biosfn_save_video_state
 58885                              <1> 
 58886 00010016 89D9                <1> 	mov	ecx, ebx ; transfer count
 58887 00010018 89F7                <1> 	mov	edi, esi
 58888 0001001A BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 58889                              <1> 
 58890                              <1> 	;call	transfer_to_user_buffer
 58891                              <1> 	;jc	short sysvideo_29_5
 58892                              <1> 	;mov	[u.r0], ecx ; transfer count
 58893                              <1> 	;;jmp	sysret
 58894                              <1> 	;jmp	short sysvideo_29_5
 58895                              <1>  
 58896 0001001F EB1A                <1> 	jmp	short sysvideo_29_12
 58897                              <1> 
 58898                              <1> sysvideo_30:	 
 58899 00010021 80FF0F              <1> 	cmp	bh, 15
 58900 00010024 7722                <1> 	ja	short sysvideo_31 ; invalid function
 58901                              <1> 	
 58902                              <1> 	; BH = 15
 58903                              <1> 	; Copy VESA EDID to user's buffer
 58904                              <1> 	
 58905 00010026 803D[57410000]4F    <1> 	cmp	byte [edid], 4Fh
 58906 0001002D 7519                <1> 	jne	short sysvideo_31 ; not ready ! 
 58907                              <1> 
 58908                              <1> 	;and	ecx, ecx
 58909                              <1> 	;jz	short sysvideo_31
 58910                              <1> 
 58911                              <1> 	; ecx = user's buffer address
 58912 0001002F 89CF                <1> 	mov	edi, ecx
 58913 00010031 BE[500F0300]        <1> 	mov	esi, edid_info
 58914 00010036 B980000000          <1> 	mov	ecx, 128 ; 128 bytes
 58915                              <1> sysvideo_29_12:
 58916 0001003B E8ED0C0000          <1> 	call	transfer_to_user_buffer
 58917 00010040 7206                <1> 	jc	short sysvideo_31
 58918                              <1> 
 58919 00010042 890D[1C010300]      <1> 	mov	[u.r0], ecx ; EDID size, 128 bytes
 58920                              <1> sysvideo_31:
 58921 00010048 E9A5CCFFFF          <1> 	jmp	sysret
 58922                              <1> 
 58923                              <1> mkdir:
 58924                              <1> 	; 04/12/2015 (14 byte directory names)
 58925                              <1> 	; 12/10/2015
 58926                              <1> 	; 17/06/2015 (Retro UNIX 386 v1 - Beginning)
 58927                              <1> 	; 29/04/2013 - 01/08/2013 (Retro UNIX 8086 v1)
 58928                              <1> 	;
 58929                              <1> 	; 'mkdir' makes a directory entry from the name pointed to
 58930                              <1> 	; by u.namep into the current directory.
 58931                              <1> 	;
 58932                              <1> 	; INPUTS ->
 58933                              <1> 	;    u.namep - points to a file name 
 58934                              <1> 	;	           that is about to be a directory entry.
 58935                              <1> 	;    ii - current directory's i-number.	
 58936                              <1> 	; OUTPUTS ->
 58937                              <1> 	;    u.dirbuf+2 - u.dirbuf+10 - contains file name. 
 58938                              <1> 	;    u.off - points to entry to be filled 
 58939                              <1> 	;	     in the current directory		
 58940                              <1> 	;    u.base - points to start of u.dirbuf.
 58941                              <1> 	;    r1 - contains i-number of current directory 
 58942                              <1> 	;	
 58943                              <1> 	; ((AX = R1)) output
 58944                              <1> 	;
 58945                              <1> 	;    (Retro UNIX Prototype : 11/11/2012, UNIXCOPY.ASM)
 58946                              <1>         ;    ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI, EBP))  
 58947                              <1> 	;
 58948                              <1> 
 58949                              <1> 	; 17/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
 58950 0001004D 31C0                <1> 	xor 	eax, eax
 58951 0001004F BF[56010300]        <1> 	mov     edi, u.dirbuf+2
 58952 00010054 89FE                <1> 	mov	esi, edi
 58953 00010056 AB                  <1> 	stosd
 58954 00010057 AB                  <1> 	stosd
 58955                              <1> 	; 04/12/2015 (14 byte directory names)
 58956 00010058 AB                  <1> 	stosd
 58957 00010059 66AB                <1> 	stosw
 58958                              <1> 		; jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this
 58959 0001005B 89F7                <1> 	mov	edi, esi ; offset to u.dirbuf
 58960                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 58961                              <1> 	;mov 	ebp, [u.namep]
 58962 0001005D E8CE040000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
 58963                              <1> 		; esi = physical address (page start + offset)
 58964                              <1> 		; ecx = byte count in the page (1 - 4096)
 58965                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 58966                              <1> 		; mov u.namep,r2 / r2 points to name of directory entry
 58967                              <1> 		; mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2
 58968                              <1> mkdir_1: ; 1: 
 58969 00010062 45                  <1> 	inc	ebp ; 12/10/2015
 58970                              <1> 	;
 58971                              <1> 	; / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10
 58972                              <1> 	 ; 01/08/2013
 58973 00010063 AC                  <1> 	lodsb
 58974                              <1> 		; movb (r2)+,r1 / move character in name to r1
 58975 00010064 20C0                <1> 	and 	al, al
 58976 00010066 7427                <1> 	jz 	short mkdir_3 	  
 58977                              <1> 		; beq 1f / if null, done
 58978 00010068 3C2F                <1> 	cmp	al, '/'
 58979                              <1> 		; cmp r1,$'/ / is it a "/"?
 58980 0001006A 7414                <1> 	je	short mkdir_err
 58981                              <1> 	;je	error
 58982                              <1> 		; beq error9 / yes, error
 58983                              <1> 	; 12/10/2015
 58984 0001006C 6649                <1> 	dec	cx
 58985 0001006E 7505                <1> 	jnz	short mkdir_2
 58986                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 58987 00010070 E8C1040000          <1> 	call	trans_addr_nm ; convert virtual address to physical
 58988                              <1> 		; esi = physical address (page start + offset)
 58989                              <1> 		; ecx = byte count in the page
 58990                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 58991                              <1> mkdir_2:
 58992 00010075 81FF[64010300]      <1> 	cmp     edi, u.dirbuf+16 ; ; 04/12/2015 (10 -> 16) 
 58993                              <1> 		; cmp r3,$u.dirbuf+10. / have we reached the last slot for
 58994                              <1> 				     ; / a char?
 58995 0001007B 74E5                <1> 	je	short mkdir_1
 58996                              <1> 		; beq 1b / yes, go back
 58997 0001007D AA                  <1> 	stosb
 58998                              <1> 		; movb r1,(r3)+ / no, put the char in the u.dirbuf
 58999 0001007E EBE2                <1> 	jmp 	short mkdir_1
 59000                              <1> 		; br 1b / get next char
 59001                              <1> mkdir_err:
 59002                              <1> 	; 17/06/2015
 59003 00010080 C705[84010300]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
 59004 00010088 0000                <1>
 59005 0001008A E943CCFFFF          <1> 	jmp	error
 59006                              <1> 
 59007                              <1> mkdir_3: ; 1:
 59008 0001008F A1[34010300]        <1> 	mov	eax, [u.dirp]
 59009 00010094 A3[3C010300]        <1> 	mov	[u.off], eax
 59010                              <1> 		; mov u.dirp,u.off / pointer to empty current directory
 59011                              <1> 				 ; / slot to u.off
 59012                              <1> wdir: ; 29/04/2013
 59013 00010099 C705[40010300]-     <1>         mov     dword [u.base], u.dirbuf
 59014 0001009F [54010300]          <1>
 59015                              <1> 		; mov $u.dirbuf,u.base / u.base points to created file name
 59016 000100A3 C705[44010300]1000- <1>         mov     dword [u.count], 16 ; 04/12/2015 (10 -> 16) 
 59017 000100AB 0000                <1>
 59018                              <1> 		; mov $10.,u.count / u.count = 10
 59019 000100AD 66A1[20020300]      <1> 	mov	ax, [ii] 
 59020                              <1> 		; mov ii,r1 / r1 has i-number of current directory
 59021 000100B3 B201                <1> 	mov	dl, 1 ; owner flag mask ; RETRO UNIX 8086 v1 modification !
 59022 000100B5 E85F1C0000          <1> 	call 	access
 59023                              <1> 		; jsr r0,access; 1 / get i-node and set its file up 
 59024                              <1> 				 ; / for writing
 59025                              <1> 	; AX = i-number of current directory
 59026                              <1> 	; 01/08/2013
 59027 000100BA FE05[82010300]      <1> 	inc     byte [u.kcall] ; the caller is 'mkdir' sign	
 59028 000100C0 E8C70E0000          <1> 	call	writei
 59029                              <1> 		; jsr r0,writei / write into directory
 59030 000100C5 C3                  <1> 	retn	
 59031                              <1> 		; rts r0
 59032                              <1> 
 59033                              <1> sysexec:
 59034                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59035                              <1> 	; 06/02/2022 - Retro UNIX 386 v1.2
 59036                              <1> 	; 18/11/2017
 59037                              <1> 	; 14/11/2017
 59038                              <1> 	; 13/11/2017
 59039                              <1> 	; 24/10/2016 - 04/01/2017
 59040                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 59041                              <1> 	; 23/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 59042                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 59043                              <1> 	;
 59044                              <1> 	; 'sysexec' initiates execution of a file whose path name if
 59045                              <1> 	; pointed to by 'name' in the sysexec call. 
 59046                              <1> 	; 'sysexec' performs the following operations:
 59047                              <1> 	;    1. obtains i-number of file to be executed via 'namei'.
 59048                              <1> 	;    2. obtains i-node of file to be exceuted via 'iget'.
 59049                              <1> 	;    3. sets trap vectors to system routines.
 59050                              <1> 	;    4. loads arguments to be passed to executing file into
 59051                              <1> 	;	highest locations of user's core
 59052                              <1> 	;    5. puts pointers to arguments in locations immediately
 59053                              <1> 	;	following arguments.
 59054                              <1> 	;    6.	saves number of arguments in next location.
 59055                              <1> 	;    7. initializes user's stack area so that all registers
 59056                              <1> 	;	will be zeroed and the PS is cleared and the PC set
 59057                              <1> 	;	to core when 'sysret' restores registers 
 59058                              <1> 	;	and does an rti.
 59059                              <1> 	;    8. initializes u.r0 and u.sp
 59060                              <1> 	;    9. zeros user's core down to u.r0
 59061                              <1> 	;   10.	reads executable file from storage device into core
 59062                              <1> 	;	starting at location 'core'.
 59063                              <1> 	;   11.	sets u.break to point to end of user's code with
 59064                              <1> 	;	data area appended.
 59065                              <1> 	;   12.	calls 'sysret' which returns control at location
 59066                              <1> 	;	'core' via 'rti' instruction.
 59067                              <1> 	;
 59068                              <1> 	; Calling sequence:
 59069                              <1> 	;	sysexec; namep; argp
 59070                              <1> 	; Arguments:
 59071                              <1> 	;	namep - points to pathname of file to be executed
 59072                              <1> 	;	argp  - address of table of argument pointers
 59073                              <1> 	;	argp1... argpn - table of argument pointers
 59074                              <1> 	;	argp1:<...0> ... argpn:<...0> - argument strings
 59075                              <1> 	; Inputs: (arguments)
 59076                              <1> 	; Outputs: -	
 59077                              <1> 	; ...............................................................
 59078                              <1> 	;
 59079                              <1> 	; Retro UNIX 386 v1 modification: 
 59080                              <1> 	;	User application runs in it's own virtual space 
 59081                              <1> 	;	which is izolated from kernel memory (and other
 59082                              <1> 	;	memory pages) via 80386	paging in ring 3 
 59083                              <1> 	;	privilige mode. Virtual start address is always 0.
 59084                              <1> 	;	User's core memory starts at linear address 400000h
 59085                              <1> 	;	(the end of the 1st 4MB).
 59086                              <1> 	;
 59087                              <1> 	; Retro UNIX 8086 v1 modification: 
 59088                              <1> 	;	user/application segment and system/kernel segment
 59089                              <1> 	;	are different and sysenter/sysret/sysrele routines
 59090                              <1> 	;	are different (user's registers are saved to 
 59091                              <1> 	;	and then restored from system's stack.)
 59092                              <1> 	;
 59093                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
 59094                              <1> 	;	      arguments which were in these registers;
 59095                              <1> 	;	      but, it returns by putting the 1st argument
 59096                              <1> 	;	      in 'u.namep' and the 2nd argument
 59097                              <1> 	;	      on top of stack. (1st argument is offset of the
 59098                              <1> 	;	      file/path name in the user's program segment.)
 59099                              <1> 	
 59100                              <1> 	;call	arg2
 59101                              <1> 	; * name - 'u.namep' points to address of file/path name
 59102                              <1> 	;          in the user's program segment ('u.segmnt')
 59103                              <1> 	;          with offset in BX register (as sysopen argument 1).
 59104                              <1> 	; * argp - sysexec argument 2 is in CX register 
 59105                              <1> 	;          which is on top of stack.
 59106                              <1> 	;
 59107                              <1> 		; jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack
 59108                              <1> 
 59109                              <1> 	; 23/06/2015 (32 bit modifications)
 59110                              <1> 
 59111                              <1> 	;; 13/11/2017
 59112                              <1> 	;;mov	[u.namep], ebx ; argument 1
 59113                              <1>         ; 18/10/2015
 59114 000100C6 890D[18020300]      <1> 	mov     [argv], ecx  ; * ; argument 2
 59115                              <1> 
 59116                              <1> 	; 13/11/2017
 59117 000100CC 89DE                <1> 	mov	esi, ebx
 59118 000100CE E86C200000          <1> 	call	set_working_path_x
 59119 000100D3 7319                <1> 	jnc	short sysexec_0
 59120                              <1> 
 59121                              <1> 	;; 'bad command or file name'
 59122                              <1> 	;mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 59123                              <1> 	
 59124                              <1> 	; 'file not found !' error
 59125 000100D5 B802000000          <1> 	mov	eax, ERR_NOT_FOUND ; 02h ; TRDOS 8086
 59126                              <1> sysexec_not_found_err:
 59127                              <1> sysexec_access_error:
 59128                              <1> sysexec_ext_error:
 59129 000100DA A3[1C010300]        <1> 	mov	[u.r0], eax
 59130 000100DF A3[84010300]        <1> 	mov	[u.error], eax
 59131 000100E4 E82B210000          <1> 	call 	reset_working_path
 59132 000100E9 E9E4CBFFFF          <1> 	jmp	error
 59133                              <1> 
 59134                              <1> sysexec_0:
 59135                              <1> 	; 13/11/2017
 59136                              <1> 	;mov	esi, FindFile_Name
 59137 000100EE 66B80018            <1>         mov	ax, 1800h ; Only files 
 59138 000100F2 E81A89FFFF          <1> 	call	find_first_file
 59139 000100F7 72E1                <1> 	jc	short sysexec_not_found_err ; eax = 2
 59140                              <1> 
 59141                              <1> 	; check_ file attributes
 59142                              <1> 	; (attribute bits = 00ADVSHR) ; 18h = Directory+Volume
 59143                              <1> 	; BL = Attributes byte
 59144                              <1> 	
 59145 000100F9 F6C306              <1>         test	bl, 6  ; system file or hidden file (S+H) 
 59146                              <1> 	;jz	short sysexec_0ext
 59147 000100FC 7417                <1> 	jz	short sysexec_1 ; yes
 59148                              <1> 
 59149                              <1> 	; 13/11/2017 
 59150                              <1> 	; /// TRDOS386 permission check for multiuser mode ///
 59151                              <1> 	; SYSTEM file or HIDDEN file !!
 59152                              <1> 	; (Only super user has permission to run this file.)
 59153                              <1> 	
 59154                              <1> 	; ([u.uid]=0 for super user or root in multiuser mode)
 59155                              <1> 	; ([u.uid]=0 for any users in singleuser mode) 
 59156 000100FE 803D[6E010300]00    <1> 	cmp 	byte [u.uid], 0 ; Super User ([u.uid]=0) ?
 59157                              <1> 	;jna	short sysexec_0ext
 59158 00010105 760E                <1> 	jna	short sysexec_1 ; yes 
 59159                              <1> 
 59160                              <1> 	; 'permission denied !' error  
 59161 00010107 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = ERR_PERM_DENIED
 59162 0001010C EBCC                <1>         jmp	short sysexec_access_error
 59163                              <1> 
 59164                              <1> sysexec_not_exf:
 59165                              <1> 	; 'not executable file !' error
 59166 0001010E B816000000          <1> 	mov	eax, ERR_NOT_EXECUTABLE
 59167 00010113 EBC5                <1> 	jmp	sysexec_ext_error
 59168                              <1> 
 59169                              <1> ;sysexec_0ext:
 59170                              <1> sysexec_1:
 59171                              <1> 	; 18/11/2017
 59172 00010115 BE[24810100]        <1> 	mov	esi, FindFile_Name
 59173                              <1> 	; 13/11/2017
 59174                              <1> 	; check program file name extension
 59175                              <1> 	; ('.PRG' for current TRDOS version)
 59176 0001011A E8BAA2FFFF          <1> 	call	check_prg_filename_ext
 59177 0001011F 72ED                <1> 	jc	short sysexec_not_exf
 59178                              <1> 	
 59179                              <1> 	; 18/11/2017
 59180 00010121 3C50                <1> 	cmp	al, 'P'
 59181 00010123 75E9                <1> 	jne	short sysexec_not_exf	
 59182                              <1> 
 59183                              <1> 	; '.PRG' extension is OK.
 59184                              <1> 	; Only '.PRG' files are valid program files
 59185                              <1> 	; for current TRDOS 386 version.
 59186                              <1> 
 59187 00010125 8B15[50810100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
 59188 0001012B 66A1[48810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
 59189 00010131 C1E010              <1> 	shl	eax, 16
 59190 00010134 66A1[4E810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
 59191                              <1> 	; EAX = First Cluster number
 59192                              <1> 	; EDX = File Size
 59193                              <1> 
 59194 0001013A A3[20020300]        <1> 	mov	[ii], eax
 59195 0001013F 8915[24020300]      <1> 	mov	[i.size], edx
 59196                              <1> 
 59197                              <1> ;sysexec_1:
 59198                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59199                              <1> 	; 06/02/2022 - Retro UNIX 386 v1.2
 59200                              <1> 	; 13/11/2017 - TRDOS 386 (TRDOS v2.0)
 59201                              <1> 	; 24/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 59202                              <1>         ; Moving arguments to the end of [u.upage]
 59203                              <1> 	; (by regarding page borders in user's memory space)
 59204                              <1> 	;
 59205                              <1> 	; 10/10/2015
 59206                              <1> 	; 21/07/2015
 59207                              <1> 	;mov	ebp, esp ; (**)
 59208                              <1> 	; 18/10/2015
 59209                              <1> 	;mov 	edi, ebp
 59210                              <1> 	; 23/07/2022
 59211 00010145 89E7                <1> 	mov	edi, esp ; (**)
 59212 00010147 B900010000          <1> 	mov 	ecx, MAX_ARG_LEN ; 256
 59213                              <1> 	;sub	edi, MAX_ARG_LEN ; 256
 59214 0001014C 29CF                <1> 	sub	edi, ecx
 59215 0001014E 89FC                <1> 	mov	esp, edi ; *!*
 59216 00010150 31C0                <1> 	xor	eax, eax
 59217 00010152 A3[48010300]        <1> 	mov 	[u.nread], eax ; 0
 59218                              <1> 	; ([argc] must be cleared because previous 'sysexec'
 59219                              <1> 	; may leave it with any value after an error))
 59220                              <1> 	;mov	[argc], ax ; 0 ; 13/11/2017
 59221                              <1> 	; 23/07/2022
 59222 00010157 A3[14020300]        <1> 	mov	[argc], eax ; 0
 59223 0001015C 49                  <1> 	dec	ecx ; 256 - 1
 59224 0001015D 890D[44010300]      <1> 	mov 	[u.count], ecx ; MAX_ARG_LEN - 1 ; 255
 59225                              <1> 	;mov 	dword [u.count], MAX_ARG_LEN - 1 ; 255
 59226                              <1> sysexec_2:
 59227 00010163 8B35[18020300]      <1> 	mov	esi, [argv] ; 18/10/2015 
 59228 00010169 E87A020000          <1> 	call	get_argp
 59229                              <1> 	;mov	ecx, 4 
 59230                              <1> 	; 23/07/2022
 59231 0001016E 31C9                <1> 	xor	ecx, ecx
 59232 00010170 B104                <1> 	mov	cl, 4
 59233                              <1> sysexec_3:
 59234 00010172 21C0                <1> 	and	eax, eax
 59235 00010174 7453                <1>         jz	short sysexec_6 ; 23/07/2022
 59236                              <1> 	; 18/10/2015
 59237 00010176 010D[18020300]      <1> 	add	[argv], ecx ; 4
 59238                              <1> 	;;inc	word [argc]
 59239                              <1> 	; 23/07/2022
 59240                              <1> 	;inc	dword [argc]
 59241 0001017C FE05[14020300]      <1> 	inc	byte [argc]
 59242                              <1> 	;
 59243 00010182 A3[40010300]        <1> 	mov	[u.base], eax
 59244                              <1>  	; 23/10/2015
 59245 00010187 66C705[80010300]00- <1> 	mov	word [u.pcount], 0
 59246 0001018F 00                  <1>
 59247                              <1> sysexec_4:
 59248 00010190 E8390B0000          <1> 	call	cpass ; get a character from user's core memory
 59249 00010195 750B                <1>         jnz	short sysexec_5
 59250                              <1> 		; (max. 255 chars + null)
 59251                              <1> 	; 18/10/2015
 59252 00010197 28C0                <1> 	sub 	al, al
 59253 00010199 AA                  <1> 	stosb
 59254 0001019A FF05[48010300]      <1> 	inc	dword [u.nread]
 59255                              <1> 	; 23/07/2022
 59256 000101A0 EB27                <1> 	jmp	short sysexec_6 ; 24/04/2016
 59257                              <1> sysexec_5:
 59258 000101A2 AA                  <1> 	stosb
 59259 000101A3 20C0                <1> 	and 	al, al
 59260 000101A5 75E9                <1> 	jnz	short sysexec_4
 59261                              <1> 	;mov	ecx, 4
 59262                              <1> 	; 23/07/2022
 59263 000101A7 31C9                <1> 	xor	ecx, ecx
 59264 000101A9 B104                <1> 	mov	cl, 4
 59265 000101AB 390D[10020300]      <1> 	cmp	[ncount], ecx ; 4
 59266 000101B1 72B0                <1> 	jb	short sysexec_2
 59267 000101B3 8B35[0C020300]      <1> 	mov	esi, [nbase]
 59268 000101B9 010D[0C020300]      <1> 	add	[nbase], ecx ; 4	
 59269                              <1> 	;sub	[ncount], cx 
 59270                              <1> 	; 23/07/2022
 59271 000101BF 290D[10020300]      <1> 	sub	[ncount], ecx
 59272 000101C5 8B06                <1> 	mov	eax, [esi]
 59273 000101C7 EBA9                <1> 	jmp	short sysexec_3
 59274                              <1> 
 59275                              <1> sysexec_6:
 59276                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59277                              <1> 	; 19/11/2017
 59278                              <1> 	; 18/11/2017
 59279                              <1> 	; 14/11/2017
 59280                              <1> 	; 13/11/2017
 59281 000101C9 8925[18020300]      <1> 	mov	[argv], esp ; *!* ; start address of argument list 
 59282                              <1> 
 59283                              <1> 	; 04/01/2017
 59284                              <1> 	; 24/10/2016
 59285                              <1> 	;;02/05/2016
 59286                              <1> 	; 23/04/2016 (TRDOS 386)
 59287                              <1> 	; 18/10/2015 ('sysexec_6')
 59288                              <1> 	; 23/06/2015
 59289 000101CF A1[74010300]        <1> 	mov	eax, [u.pgdir] ; physical address of page directory
 59290                              <1> 	;cmp 	eax, [k_page_dir] ; TRDOS MainProg ? 
 59291                              <1> 	;je	short sysexec_7
 59292                              <1> 	; 19/11/2017
 59293 000101D4 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; phy addr of the parent's page dir
 59294 000101DA E8EC55FFFF          <1> 	call	deallocate_page_dir
 59295                              <1> sysexec_7:
 59296 000101DF E81C55FFFF          <1> 	call	make_page_dir
 59297                              <1> 	;jc	panic  ; allocation error 
 59298                              <1> 	;	       ; after a deallocation would be nonsence !?
 59299                              <1> 	; 23/07/2022
 59300 000101E4 7243                <1> 	jc	short sysexec_panic
 59301                              <1> 
 59302                              <1> 	; 24/07/2015
 59303                              <1> 	; map kernel pages (1st 4MB) to PDE 0
 59304                              <1> 	;     of the user's page directory
 59305                              <1> 	;     (It is needed for interrupts!)
 59306                              <1> 	; 18/10/2015
 59307 000101E6 8B15[80770100]      <1> 	mov	edx, [k_page_dir] ; Kernel's page directory
 59308 000101EC 8B02                <1> 	mov	eax, [edx] ; physical address of
 59309                              <1> 			   ; kernel's first page table (1st 4 MB)
 59310                              <1> 			   ; (PDE 0 of kernel's page directory)
 59311 000101EE 8B15[74010300]      <1> 	mov 	edx, [u.pgdir]
 59312 000101F4 8902                <1> 	mov	[edx], eax ; PDE 0 (1st 4MB)
 59313                              <1> 	;
 59314                              <1> 	; 20/07/2015
 59315 000101F6 BB00004000          <1> 	mov	ebx, CORE ; start address = 0 (virtual) + CORE
 59316                              <1> 	; 18/10/2015
 59317 000101FB BE[04020300]        <1> 	mov	esi, pcore ; physical start address
 59318                              <1> sysexec_8:	
 59319 00010200 B907000000          <1> 	mov	ecx, PDE_A_USER + PDE_A_WRITE + PDE_A_PRESENT
 59320 00010205 E81455FFFF          <1> 	call	make_page_table
 59321                              <1> 	;jc	panic
 59322                              <1> 	; 23/07/2022
 59323 0001020A 721D                <1> 	jc	short sysexec_panic
 59324                              <1> 	;
 59325                              <1> 	;mov	ecx, PTE_A_USER + PTE_A_WRITE + PTE_A_PRESENT
 59326 0001020C E81B55FFFF          <1> 	call	make_page ; make new page, clear and set the pte 
 59327                              <1> 	;jc	panic
 59328                              <1> 	; 23/07/2022
 59329 00010211 7216                <1> 	jc	short sysexec_panic
 59330                              <1> 	;
 59331 00010213 8906                <1> 	mov	[esi], eax ; 24/06/2015
 59332                              <1> 	; ebx = virtual address (24/07/2015)
 59333                              <1> 	; 23/07/2022
 59334                              <1> 	;call 	add_to_swap_queue
 59335                              <1> 	; 18/10/2015
 59336 00010215 81FE[08020300]      <1> 	cmp	esi, ecore ; user's stack (last) page ?
 59337 0001021B 7411                <1> 	je	short sysexec_9 ; yes
 59338 0001021D BE[08020300]        <1> 	mov	esi, ecore  ; physical address of the last page 
 59339                              <1> 	; 20/07/2015
 59340 00010222 BB00F0FFFF          <1> 	mov	ebx, (ECORE - PAGE_SIZE) + CORE
 59341                              <1> 	; ebx = virtual end address + segment base address - 4K
 59342 00010227 EBD7                <1>         jmp     short sysexec_8
 59343                              <1> sysexec_panic:
 59344                              <1> 	; 23/07/2022
 59345 00010229 E95B6AFFFF          <1> 	jmp	panic
 59346                              <1> 
 59347                              <1> sysexec_9:
 59348                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59349                              <1> 	; 19/11/2017 
 59350                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 59351                              <1> 	; 25/06/2015 - 26/08/2015 - 18/10/2015
 59352                              <1> 	; move arguments from kernel stack to [ecore]
 59353                              <1> 	; (argument list/line will be copied from kernel stack
 59354                              <1> 	; frame to the last (stack) page of user's core memory)
 59355                              <1> 	; 18/10/2015
 59356 0001022E 8B3D[08020300]      <1> 	mov	edi, [ecore]
 59357 00010234 81C700100000        <1> 	add	edi, PAGE_SIZE
 59358                              <1> 	; 19/11/2017
 59359                              <1> 	;sub	edi, 4
 59360                              <1> 	;mov	dword [edi], 0 
 59361                              <1> 	;mov	ebx, edi
 59362                              <1> 	;
 59363                              <1> 	;movzx	eax, word [argc]
 59364                              <1> 	;or	eax, eax
 59365                              <1> 	;jz	short sysexec_13 ; 19/11/2017
 59366                              <1> 	;;jnz	short sysexec_10
 59367                              <1> 	;;mov 	ebx, edi
 59368                              <1> 	;;sub	ebx, 4 
 59369                              <1> 	;;mov	[ebx], eax ; 0
 59370                              <1> 	;;jmp 	short sysexec_13
 59371                              <1> 	; 23/07/2022
 59372                              <1> 	; [argc] < 32
 59373 0001023A A1[14020300]        <1> 	mov	eax, [argc]
 59374 0001023F 09C0                <1> 	or	eax, eax
 59375 00010241 7509                <1> 	jnz	short sysexec_10
 59376 00010243 89FB                <1> 	mov 	ebx, edi
 59377 00010245 83EB04              <1> 	sub	ebx, 4 
 59378 00010248 8903                <1> 	mov	[ebx], eax ; 0
 59379 0001024A EB47                <1> 	jmp 	short sysexec_13
 59380                              <1> 
 59381                              <1> sysexec_10:
 59382 0001024C 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 59383                              <1> 	; 13/11/2017
 59384                              <1> 	;;mov	esi, TextBuffer ; 'load_and_execute_file'
 59385                              <1> 	;mov	esi, esp  	; 'sysexec'
 59386 00010252 8B35[18020300]      <1> 	mov	esi, [argv] ; 24/04/2016 (TRDOS 386  = TRDOS v2.0)
 59387                              <1> 	; 23/07/2022
 59388 00010258 29CF                <1> 	sub	edi, ecx ; page end address - argument list length
 59389                              <1> 	;sub	ebx, ecx ; 19/11/2017
 59390                              <1> 
 59391                              <1> 	;;;;
 59392                              <1> 	; 23/07/2022
 59393                              <1> 	; (move edi -backward- to dword boundary)
 59394                              <1> 	; ((this will prevent 'general protection fault' error
 59395                              <1> 	;  as result of a lodsd or dword move instruction
 59396                              <1> 	;  at the end of argument list))
 59397 0001025A 83EF03              <1> 	sub	edi, 3
 59398 0001025D 83E7FC              <1> 	and	edi, ~3 ; (*)
 59399                              <1> 	;;;
 59400                              <1> 
 59401 00010260 89C2                <1> 	mov	edx, eax
 59402 00010262 FEC2                <1> 	inc	dl ; argument count + 1 for argc value  
 59403 00010264 C0E202              <1> 	shl 	dl, 2  ; 4 * (argument count + 1)
 59404                              <1> 	; edx <= 128
 59405 00010267 89FB                <1> 	mov	ebx, edi
 59406                              <1> 	;mov	edi, ebx ; 19//11/2017
 59407                              <1> 	; 23/07/2022 (*) - edi is already dword aligned -
 59408                              <1> 	;and	bl, 0FCh ; 32 bit (dword) alignment
 59409 00010269 29D3                <1> 	sub 	ebx, edx
 59410 0001026B 89FA                <1> 	mov	edx, edi
 59411 0001026D F3A4                <1> 	rep	movsb
 59412 0001026F 89D6                <1> 	mov 	esi, edx
 59413 00010271 89DF                <1> 	mov 	edi, ebx
 59414 00010273 BA00F0BFFF          <1> 	mov	edx, ECORE - PAGE_SIZE ; virtual addr. of the last page
 59415 00010278 2B15[08020300]      <1> 	sub 	edx, [ecore] ; difference (virtual - physical) 
 59416 0001027E AB                  <1> 	stosd	; eax = argument count	
 59417                              <1> sysexec_11:
 59418 0001027F 89F0                <1> 	mov	eax, esi
 59419 00010281 01D0                <1> 	add	eax, edx
 59420 00010283 AB                  <1> 	stosd  ; eax = virtual address
 59421                              <1> 	; 23/07/2022
 59422 00010284 FE0D[14020300]      <1> 	dec	byte [argc]
 59423                              <1> 	;dec	dword [argc]
 59424                              <1> 	;;dec	word [argc] ; 14/11/2017
 59425 0001028A 7407                <1> 	jz	short sysexec_13
 59426                              <1> sysexec_12:
 59427 0001028C AC                  <1> 	lodsb
 59428 0001028D 20C0                <1> 	and	al, al
 59429 0001028F 75FB                <1> 	jnz	short sysexec_12
 59430 00010291 EBEC                <1> 	jmp	short sysexec_11
 59431                              <1> sysexec_13:
 59432                              <1> 	; 24/10/2016
 59433                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 59434                              <1> 	; 23/06/2015 - 19/10/2015 (Retro UNIX 386 v1, 'sysexec_13')
 59435                              <1> 	;
 59436                              <1> 	; moving arguments to [ecore] is OK here..
 59437                              <1> 	;
 59438                              <1> 	; ebx = beginning addres of argument list pointers
 59439                              <1> 		;	in user's stack
 59440 00010293 2B1D[08020300]      <1> 	sub 	ebx, [ecore]
 59441 00010299 81C300F0BFFF        <1> 	add     ebx, (ECORE - PAGE_SIZE)
 59442                              <1> 			; end of core - 4096 (last page)
 59443                              <1> 			; (virtual address)
 59444 0001029F 891D[18020300]      <1> 	mov	[argv], ebx
 59445 000102A5 891D[4C010300]      <1> 	mov	[u.break], ebx ; available user memory
 59446                              <1> 	;
 59447 000102AB 29C0                <1> 	sub	eax, eax
 59448 000102AD C705[44010300]2000- <1> 	mov	dword [u.count], 32 ; Executable file header size
 59449 000102B5 0000                <1>
 59450 000102B7 C705[30010300]-     <1> 	mov	dword [u.fofp], u.off
 59451 000102BD [3C010300]          <1>
 59452 000102C1 A3[3C010300]        <1> 	mov	[u.off], eax ; 0
 59453 000102C6 A3[40010300]        <1> 	mov	[u.base], eax ; 0, start of user's core (virtual)
 59454                              <1> 	; 24/10/2016
 59455 000102CB A0[42780100]        <1> 	mov	al, [Current_Drv]
 59456 000102D0 A2[01010300]        <1> 	mov	[cdev], al
 59457                              <1> 	;
 59458 000102D5 A1[20020300]        <1> 	mov	eax, [ii] ; Fist Cluster of the Program (PRG) file
 59459                              <1> 	; EAX = First cluster of the executable file
 59460 000102DA E893050000          <1> 	call	readi
 59461                              <1> 
 59462 000102DF 8B0D[4C010300]      <1> 	mov	ecx, [u.break] ; top of user's stack (physical addr.)
 59463 000102E5 890D[44010300]      <1> 	mov	[u.count], ecx ; save for overrun check
 59464                              <1> 	;
 59465 000102EB 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 59466 000102F1 890D[4C010300]      <1> 	mov	[u.break], ecx ; virtual address (offset from start)
 59467 000102F7 80F920              <1> 	cmp	cl, 32
 59468 000102FA 7540                <1>         jne     short sysexec_15
 59469                              <1> 	;:
 59470                              <1> 	; Retro UNIX 386 v1 (32 bit) executable file header format
 59471 000102FC 8B35[04020300]      <1> 	mov	esi, [pcore] ; start address of user's core memory 
 59472                              <1> 		             ; (phys. start addr. of the exec. file)
 59473 00010302 AD                  <1> 	lodsd
 59474 00010303 663DEB1E            <1> 	cmp	ax, 1EEBh ; EBH, 1Eh -> jump to +32
 59475 00010307 7533                <1> 	jne	short sysexec_15
 59476 00010309 AD                  <1> 	lodsd
 59477 0001030A 89C1                <1> 	mov	ecx, eax ; text (code) section size
 59478 0001030C AD                  <1> 	lodsd
 59479 0001030D 01C1                <1> 	add	ecx, eax ; + data section size (initialized data)
 59480 0001030F 89CB                <1> 	mov	ebx, ecx
 59481 00010311 AD                  <1> 	lodsd	
 59482 00010312 01C3                <1> 	add	ebx, eax ; + bss section size (for overrun checking)
 59483 00010314 3B1D[44010300]      <1> 	cmp	ebx, [u.count]
 59484 0001031A 7711                <1> 	ja	short sysexec_14  ; program overruns stack !
 59485                              <1> 	;
 59486                              <1> 	; add bss section size to [u.break]
 59487 0001031C 0105[4C010300]      <1> 	add 	[u.break], eax
 59488                              <1> 	;
 59489 00010322 83E920              <1> 	sub	ecx, 32  ; header size (already loaded)
 59490                              <1> 	;cmp	ecx, [u.count]
 59491                              <1> 	;jnb	short sysexec_16
 59492 00010325 890D[44010300]      <1> 	mov	[u.count], ecx ; required read count
 59493 0001032B EB29                <1> 	jmp	short sysexec_16
 59494                              <1> sysexec_14:
 59495                              <1> 	; insufficient (out of) memory
 59496 0001032D C705[84010300]0400- <1> 	mov	dword [u.error], ERR_MINOR_IM ; 1
 59497 00010335 0000                <1>
 59498 00010337 E996C9FFFF          <1> 	jmp	error
 59499                              <1> sysexec_15:
 59500 0001033C 8B15[24020300]      <1>         mov	edx, [i.size] ; file size
 59501 00010342 29CA                <1> 	sub	edx, ecx ; file size - loaded bytes
 59502 00010344 7626                <1> 	jna	short sysexec_17 ; no need to next read
 59503 00010346 01D1                <1> 	add	ecx, edx ; [i.size]
 59504 00010348 3B0D[44010300]      <1> 	cmp	ecx, [u.count] ; overrun check (!)
 59505 0001034E 77DD                <1> 	ja	short sysexec_14
 59506 00010350 8915[44010300]      <1> 	mov	[u.count], edx
 59507                              <1> sysexec_16:
 59508 00010356 A1[20020300]        <1> 	mov	eax, [ii] ; first cluster
 59509 0001035B E812050000          <1> 	call	readi
 59510 00010360 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 59511 00010366 010D[4C010300]      <1> 	add	[u.break], ecx
 59512                              <1> sysexec_17:
 59513 0001036C A1[20020300]        <1> 	mov	eax, [ii] ; first cluster
 59514 00010371 E8A3190000          <1> 	call	iclose
 59515 00010376 31C0                <1> 	xor     eax, eax
 59516 00010378 FEC0                <1> 	inc	al
 59517 0001037A 66A3[68010300]      <1> 	mov	[u.intr], ax ; 1 (interrupt/time-out is enabled)
 59518 00010380 66A3[6A010300]      <1> 	mov	[u.quit], ax ; 1 ('crtl+brk' signal is enabled) 
 59519                              <1> 	; 23/07/2022
 59520 00010386 FEC8                <1> 	dec	al
 59521                              <1> 	;cmp	dword [u.ppgdir], 0  ; is the caller MainProg (kernel) ?
 59522 00010388 3905[78010300]      <1> 	cmp	[u.ppgdir], eax ; 0 ; 23/07/2022
 59523 0001038E 770C                <1> 	ja	short sysexec_18 ; no, the caller is user process
 59524                              <1> 	; If the caller is kernel (MainProg), 'sysexec' will come here
 59525 00010390 8B15[80770100]      <1> 	mov	edx, [k_page_dir] ; kernel's page directory
 59526 00010396 8915[78010300]      <1> 	mov	[u.ppgdir], edx ; next time 'sysexec' must not come here 
 59527                              <1> sysexec_18:
 59528                              <1> 	; 02/05/2016
 59529                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 59530                              <1> 	; 18/10/2015 (Retro UNIX 386 v1)
 59531                              <1> 	; 05/08/2015
 59532                              <1> 	; 29/07/2015
 59533                              <1> 
 59534                              <1> ;	; **** arguments list test start - 19/11/2017
 59535                              <1> ;	mov	ebp, [argv]
 59536                              <1> ;	sub	ebp, ECORE - 4096
 59537                              <1> ;	add	ebp, [ecore]
 59538                              <1> ;
 59539                              <1> ;	mov	ebx, [ebp]
 59540                              <1> ;	mov	[argc], bx
 59541                              <1> ;	add	ebp, 4
 59542                              <1> ;	mov	byte [ccolor], 1Fh
 59543                              <1> ;_zx0:
 59544                              <1> ;	cmp	word [argc], 0
 59545                              <1> ;	jna	short _zx2
 59546                              <1> ;_zx1:
 59547                              <1> ;	push	ebp
 59548                              <1> ;	mov	esi, [ebp]
 59549                              <1> ;
 59550                              <1> ;	sub	esi, ECORE - 4096
 59551                              <1> ;	add	esi, [ecore]
 59552                              <1> ;
 59553                              <1> ;	call	print_cmsg
 59554                              <1> ;
 59555                              <1> ;	dec	word [argc]
 59556                              <1> ;	jz	short _zx2
 59557                              <1> ;
 59558                              <1> ;	mov	al, '.'
 59559                              <1> ;	mov	bl, 07h
 59560                              <1> ;	mov	bh, [u.ttyn]
 59561                              <1> ;	call 	_write_tty 
 59562                              <1> ;
 59563                              <1> ;	pop	ebp
 59564                              <1> ;	add	ebp, 4
 59565                              <1> ;	jmp	short _zx1
 59566                              <1> ;_zx2:
 59567                              <1> ;	pop	ebp
 59568                              <1> ;	mov	byte [ccolor], 07h
 59569                              <1> ;	mov	eax, 1
 59570                              <1> ;	; **** arguments list test stop
 59571                              <1> ;	Test result is OK! (there is not a wrong thing) - 19/11/2017
 59572                              <1> 
 59573 0001039C 8B2D[18020300]      <1> 	mov	ebp, [argv] ; user's stack pointer must point to argument
 59574                              <1> 			    ; list pointers (argument count)
 59575 000103A2 FA                  <1> 	cli
 59576 000103A3 8B25[1C770100]      <1>         mov     esp, [tss.esp0] ; ring 0 (kernel) stack pointer
 59577                              <1> 	;mov   	esp, [u.sp] ; Restore Kernel stack
 59578                              <1> 			    ; for this process	 
 59579                              <1> 	;add	esp, 20 ; --> EIP, CS, EFLAGS, ESP, SS
 59580                              <1> 	;;xor	eax, eax ; 0
 59581                              <1> 	; 23/07/2022
 59582                              <1> 	;dec	al ; eax = 0
 59583                              <1> 	; eax = 0
 59584                              <1> 
 59585                              <1> 	;mov	edx, UDATA
 59586                              <1> 	; 18/11/2017
 59587 000103A9 6A23                <1> 	push	UDATA ; user's stack segment
 59588                              <1> 	;push	edx
 59589 000103AB 55                  <1> 	push	ebp ; user's stack pointer
 59590                              <1> 		    ; (points to number of arguments)
 59591                              <1> 	
 59592                              <1> 	; 04/01/2017
 59593                              <1> 	; MainProg comes here while [sysflg]= 0FFh
 59594                              <1> 	; (but sysexec comes here while [sysflg]= 0)
 59595 000103AC C605[10010300]00    <1> 	mov	byte [sysflg], 0 ; 04/01/2017
 59596                              <1> 				 ; (timer_int sysflg control)
 59597 000103B3 FB                  <1> 	sti
 59598 000103B4 9C                  <1> 	pushfd	; EFLAGS
 59599                              <1> 		; Set IF for enabling interrupts in user mode
 59600                              <1> 	;or	dword [esp], 200h 
 59601                              <1> 	;
 59602                              <1> 	;mov	bx, UCODE
 59603                              <1> 	;push	bx ; user's code segment
 59604 000103B5 6A1B                <1> 	push	UCODE
 59605                              <1> 	;push	0
 59606 000103B7 50                  <1> 	push	eax ; EIP (=0) - start address -
 59607 000103B8 8925[14010300]      <1> 	mov	[u.sp], esp ; 29/07/2015
 59608                              <1> 	; 05/08/2015
 59609                              <1> 	; Remedy of a General Protection Fault during 'iretd' is here !
 59610                              <1> 	; ('push dx' would cause to general protection fault, 
 59611                              <1> 	; after 'pop ds' etc.)
 59612                              <1> 	;
 59613                              <1> 	;; push dx ; ds (UDATA)
 59614                              <1> 	;; push dx ; es (UDATA)
 59615                              <1> 	;; push dx ; fs (UDATA)
 59616                              <1> 	;; push dx ; gs (UDATA)
 59617                              <1> 	;
 59618                              <1> 	; This is a trick to prevent general protection fault
 59619                              <1> 	; during 'iretd' intruction at the end of 'sysrele' (in u1.s):
 59620 000103BE 66BA2300            <1> 	mov	dx, UDATA ; 19/11/2017
 59621 000103C2 8EC2                <1> 	mov 	es, dx ; UDATA
 59622 000103C4 06                  <1> 	push 	es ; ds (UDATA)
 59623 000103C5 06                  <1> 	push 	es ; es (UDATA)
 59624 000103C6 06                  <1> 	push 	es ; fs (UDATA)
 59625 000103C7 06                  <1> 	push	es ; gs (UDATA)
 59626 000103C8 66BA1000            <1> 	mov	dx, KDATA
 59627 000103CC 8EC2                <1> 	mov	es, dx
 59628                              <1> 	;
 59629                              <1> 	;; pushad simulation
 59630 000103CE 89E5                <1> 	mov	ebp, esp ; esp before pushad
 59631 000103D0 50                  <1> 	push	eax ; eax (0)
 59632 000103D1 50                  <1> 	push	eax ; ecx (0)
 59633 000103D2 50                  <1> 	push	eax ; edx (0)
 59634 000103D3 50                  <1> 	push	eax ; ebx (0)
 59635 000103D4 55                  <1> 	push	ebp ; esp before pushad
 59636 000103D5 50                  <1> 	push	eax ; ebp (0)
 59637 000103D6 50                  <1> 	push	eax ; esi (0)		
 59638 000103D7 50                  <1> 	push	eax ; edi (0)	
 59639                              <1> 	;
 59640 000103D8 A3[1C010300]        <1> 	mov	[u.r0], eax ; eax = 0
 59641 000103DD 8925[18010300]      <1> 	mov	[u.usp], esp
 59642                              <1> 
 59643                              <1> 	; 14/11/2017
 59644 000103E3 E90CC9FFFF          <1> 	jmp	sysret0
 59645                              <1> 
 59646                              <1> get_argp:
 59647                              <1> 	; 08/08/2022
 59648                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59649                              <1> 	; 11/12/2021 - Retro UNIX 386 v1.2 
 59650                              <1> 	; 14/11/2017 - TRDOS 386 (TRDOS v2.0)
 59651                              <1> 	; 18/10/2015 (nbase, ncount)
 59652                              <1> 	; 21/07/2015
 59653                              <1> 	; 24/06/2015 (Retro UNIX 386 v1)
 59654                              <1> 	; Get (virtual) address of argument from user's core memory
 59655                              <1> 	;
 59656                              <1> 	; INPUT:
 59657                              <1> 	;	esi = virtual address of argument pointer
 59658                              <1> 	; OUTPUT:
 59659                              <1> 	;	eax = virtual address of argument
 59660                              <1> 	;
 59661                              <1> 	; Modified registers: EAX, EBX, ECX, EDX, ESI 
 59662                              <1> 	;
 59663 000103E8 833D[78010300]00    <1>  	cmp     dword [u.ppgdir], 0 ; /etc/init ?
 59664                              <1> 				    ; (the caller is kernel)
 59665                              <1> 	;jna	short get_argpk
 59666                              <1> 	; 08/08/2022
 59667 000103EF 7705                <1> 	ja	short get_argp5
 59668 000103F1 E985000000          <1> 	jmp	get_argpk
 59669                              <1> get_argp5:
 59670 000103F6 89F3                <1>      	mov	ebx, esi
 59671 000103F8 E88B56FFFF          <1> 	call	get_physical_addr ; get physical address
 59672 000103FD 7253                <1>         jc      short get_argp_err ; 23/07/2022
 59673 000103FF A3[0C020300]        <1> 	mov 	[nbase], eax ; physical address	
 59674                              <1> 	;mov	[ncount], cx ; remain byte count in page (1-4096)
 59675                              <1> 	; 23/07/2022
 59676 00010404 890D[10020300]      <1> 	mov	[ncount], ecx
 59677                              <1> 	;mov	eax, 4 ; 21/07/2015
 59678 0001040A 31C0                <1> 	xor	eax, eax
 59679 0001040C B004                <1> 	mov	al, 4
 59680                              <1> 	;cmp	cx, ax ; 4
 59681                              <1> 	; 23/07/2022
 59682 0001040E 39C1                <1> 	cmp	ecx, eax ; 4
 59683 00010410 7354                <1> 	jnb	short get_argp2
 59684 00010412 89F3                <1> 	mov	ebx, esi
 59685 00010414 01CB                <1> 	add	ebx, ecx
 59686 00010416 E86D56FFFF          <1> 	call	get_physical_addr ; get physical address
 59687 0001041B 7235                <1> 	jc	short get_argp_err
 59688                              <1> 	;push	esi
 59689 0001041D 89C6                <1> 	mov	esi, eax
 59690                              <1> 	;xchg	cx, [ncount]
 59691                              <1> 	; 23/07/2022
 59692 0001041F 870D[10020300]      <1> 	xchg	ecx, [ncount]
 59693 00010425 8735[0C020300]      <1> 	xchg	esi, [nbase]
 59694 0001042B B504                <1> 	mov	ch, 4
 59695 0001042D 28CD                <1> 	sub	ch, cl
 59696                              <1> get_argp0:
 59697 0001042F AC                  <1> 	lodsb
 59698                              <1> 	;push	ax
 59699                              <1> 	; 23/07/2022
 59700 00010430 50                  <1> 	push	eax
 59701 00010431 FEC9                <1> 	dec	cl
 59702 00010433 75FA                <1>         jnz     short get_argp0
 59703 00010435 8B35[0C020300]      <1> 	mov	esi, [nbase]
 59704                              <1> 	; 21/07/2015
 59705 0001043B 0FB6C5              <1> 	movzx	eax, ch
 59706 0001043E 0105[0C020300]      <1> 	add	[nbase], eax
 59707                              <1> 	;sub	[ncount], ax
 59708                              <1> 	; 23/07/2022
 59709 00010444 2905[10020300]      <1> 	sub	[ncount], eax
 59710                              <1> get_argp1:
 59711 0001044A AC                  <1> 	lodsb
 59712 0001044B FECD                <1> 	dec	ch
 59713 0001044D 7445                <1>         jz      short get_argp3
 59714                              <1>         ;push	ax
 59715                              <1> 	; 23/07/2022
 59716 0001044F 50                  <1> 	push	eax
 59717 00010450 EBF8                <1> 	jmp     short get_argp1
 59718                              <1> get_argp_err:
 59719 00010452 A3[84010300]        <1> 	mov	[u.error], eax
 59720                              <1> 	; 14/11/2017
 59721 00010457 B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 59722 0001045C A3[1C010300]        <1> 	mov	[u.r0], eax
 59723 00010461 E96CC8FFFF          <1> 	jmp	error
 59724                              <1> get_argp2:
 59725                              <1> 	; 21/07/2015
 59726                              <1> 	;mov	eax, 4
 59727 00010466 8B15[0C020300]      <1> 	mov 	edx, [nbase] ; 18/10/2015
 59728 0001046C 0105[0C020300]      <1> 	add	[nbase], eax
 59729                              <1> 	;sub	[ncount], ax
 59730                              <1> 	; 23/07/2022
 59731 00010472 2905[10020300]      <1> 	sub	[ncount], eax
 59732                              <1> 	;
 59733 00010478 8B02                <1> 	mov	eax, [edx]
 59734 0001047A C3                  <1> 	retn
 59735                              <1> get_argpk:
 59736                              <1> 	; Argument is in kernel's memory space
 59737 0001047B 66C705[10020300]00- <1> 	mov	word [ncount], PAGE_SIZE ; 4096
 59738 00010483 10                  <1>
 59739 00010484 8935[0C020300]      <1> 	mov	[nbase], esi
 59740 0001048A 8305[0C020300]04    <1> 	add	dword [nbase], 4
 59741 00010491 8B06                <1> 	mov	eax, [esi] ; virtual addr. = physical addr.
 59742 00010493 C3                  <1> 	retn
 59743                              <1> get_argp3:
 59744 00010494 B103                <1> 	mov	cl, 3
 59745                              <1> get_argp4:
 59746 00010496 C1E008              <1> 	shl	eax, 8
 59747                              <1> 	;pop	dx
 59748                              <1> 	; 23/07/2022
 59749 00010499 5A                  <1> 	pop	edx
 59750 0001049A 88D0                <1> 	mov 	al, dl
 59751 0001049C E2F8                <1>         loop    get_argp4
 59752                              <1> 	;pop	esi
 59753 0001049E C3                  <1> 	retn
 59754                              <1> 
 59755                              <1> 	; 23/07/2022
 59756                              <1> %if 0	
 59757                              <1> 
 59758                              <1> sysstat: 
 59759                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 59760                              <1> 	; temporary !
 59761                              <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 59762                              <1>         mov     [u.error], eax
 59763                              <1>         mov     [u.r0], eax 
 59764                              <1> 	jmp	error
 59765                              <1> 
 59766                              <1> sysfstat: 
 59767                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 59768                              <1> 	; temporary !
 59769                              <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 59770                              <1>         mov     [u.error], eax
 59771                              <1>         mov     [u.r0], eax 
 59772                              <1> 	jmp	error
 59773                              <1> 
 59774                              <1> %endif
 59775                              <1> 
 59776                              <1> fclose:
 59777                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 59778                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 59779                              <1> 	;
 59780                              <1> 	; 18/06/2015 (Retro UNIX 386 v1 - Beginning)
 59781                              <1> 	;            (32 bit offset pointer modification)
 59782                              <1> 	; 19/04/2013 - 12/01/2014 (Retro UNIX 8086 v1)
 59783                              <1> 	;
 59784                              <1> 	; Given the file descriptor (index to the u.fp list)
 59785                              <1> 	; 'fclose' first gets the i-number of the file via 'getf'.
 59786                              <1> 	; If i-node is active (i-number > 0) the entry in 
 59787                              <1> 	; u.fp list is cleared. If all the processes that opened
 59788                              <1> 	; that file close it, then fsp etry is freed and the file
 59789                              <1> 	; is closed. If not a return is taken. 
 59790                              <1> 	; If the file has been deleted while open, 'anyi' is called
 59791                              <1> 	; to see anyone else has it open, i.e., see if it is appears
 59792                              <1> 	; in another entry in the fsp table. Upon return from 'anyi'
 59793                              <1> 	; a check is made to see if the file is special.
 59794                              <1> 	;
 59795                              <1> 	; INPUTS ->
 59796                              <1> 	;    r1 - contains the file descriptor (value=0,1,2...)
 59797                              <1> 	;    u.fp - list of entries in the fsp table
 59798                              <1> 	;    fsp - table of entries (4 words/entry) of open files. 
 59799                              <1> 	; OUTPUTS ->
 59800                              <1> 	;    r1 - contains the same file descriptor
 59801                              <1> 	;    r2 - contains i-number
 59802                              <1> 	;
 59803                              <1> 	; ((AX = R1))
 59804                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI, EBP))
 59805                              <1> 	;
 59806                              <1> 	; Retro UNIX 8086 v1 modification : CF = 1
 59807                              <1> 	;              if i-number of the file is 0. (error)
 59808                              <1> 	;
 59809                              <1> 	; TRDOS 386 (06/10/2016)
 59810                              <1> 	; 
 59811                              <1> 	; INPUT:
 59812                              <1> 	;	EAX = File Handle (File Descriptor, File Index)
 59813                              <1> 	;
 59814                              <1> 	; OUTPUT:
 59815                              <1> 	;	CF = 1 -> File not open !
 59816                              <1> 	;	CF = 0 -> OK!
 59817                              <1> 	;	     EBX = File Number (System)
 59818                              <1> 	;	     [cdev] = Logical DOS Drive Number
 59819                              <1> 	;	     EAX = File Handle/Number (user)
 59820                              <1> 	;
 59821                              <1> 	; Modified Registers: EBX
 59822                              <1> 
 59823 0001049F 50                  <1> 	push	eax ; File handle
 59824                              <1> 	
 59825 000104A0 E846000000          <1> 	call	getf
 59826                              <1> 	;jc	device_close ; eax = device number
 59827                              <1> 	; 17/04/2021 (temporary)
 59828 000104A5 7306                <1> 	jnc	short _fclose_0
 59829 000104A7 58                  <1> 	pop	eax
 59830 000104A8 E943CFFFFF          <1> 	jmp	rw2 ; file not open !
 59831                              <1> _fclose_0:
 59832 000104AD 80BB[DC840100]01    <1> 	cmp	byte [ebx+OF_MODE], 1 ; open mode ; 0 = empty entry
 59833 000104B4 722C                <1> 	jb	short fclose_1	      ; 1 = read, 2 = write
 59834                              <1> 	
 59835 000104B6 83F801              <1> 	cmp	eax, 1 ; is the first cluster number > 0
 59836 000104B9 7227                <1> 	jb	short fclose_1 ; no, this is empty entry
 59837                              <1> 
 59838                              <1> fclose_0:
 59839 000104BB FE8B[1C850100]      <1> 	dec	byte [ebx+OF_OPENCOUNT] ; decrement the number of processes 
 59840                              <1> 			                ; that have opened the file
 59841 000104C1 791F                <1> 	jns	short fclose_1 ; jump if not negative (jump if bit 7 is 0)	 
 59842                              <1> 			; if all processes haven't closed the file, return
 59843                              <1> 	;
 59844                              <1> 	; eax ; First cluster
 59845 000104C3 31C0                <1> 	xor	eax, eax ; 0
 59846 000104C5 8883[DC840100]      <1> 	mov	[ebx+OF_MODE], al ; 0 = empty entry
 59847                              <1> 	;mov	[ebx+OF_STATUS], al ; 0 = empty entry
 59848                              <1> 	;shl	bx, 2 
 59849                              <1> 	; 23/07/2022
 59850                              <1> 	;shl	bl, 2
 59851 000104CB C1E302              <1> 	shl	ebx, 2
 59852 000104CE 8983[3C840100]      <1> 	mov	[ebx+OF_FCLUSTER], eax ; 0
 59853 000104D4 8983[BC870100]      <1> 	mov	[ebx+OF_CCLUSTER], eax ; 0
 59854                              <1> 	;mov	[ebx+OF_CCINDEX], eax ; 0
 59855                              <1> 	; 23/07/2022
 59856                              <1> 	;mov	[ebx+OF_OPENCOUNT], al ; 0
 59857 000104DA A3[30010300]        <1> 	mov	[u.fofp], eax ; 0
 59858                              <1> 	;shr	bx, 2
 59859                              <1> 	; 23/07/2022
 59860                              <1> 	;shr	bl, 2
 59861 000104DF C1EB02              <1> 	shr	ebx, 2
 59862                              <1> fclose_1: ; 1:
 59863 000104E2 58                  <1> 	pop	eax ; File handle (File Descriptor, File Index)
 59864 000104E3 C680[26010300]00    <1> 	mov	byte [eax+u.fp], 0 ; clear that entry in the u.fp list
 59865 000104EA C3                  <1> 	retn
 59866                              <1> 
 59867                              <1> getf:
 59868                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 59869                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 59870                              <1> 	;	(temporary modifications)
 59871                              <1> 	; 12/10/2016
 59872                              <1> 	; 11/10/2016
 59873                              <1> 	; 08/10/2016
 59874                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 59875                              <1> 	; / get the device number and the i-number of an open file
 59876                              <1> 	; 13/05/2015
 59877                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 59878                              <1> 	; 19/04/2013 - 18/11/2013 (Retro UNIX 8086 v1)
 59879                              <1> 	;
 59880 000104EB 89C3                <1> 	mov	ebx, eax
 59881                              <1> getf1: 
 59882 000104ED 83FB0A              <1> 	cmp	ebx, 10
 59883 000104F0 730A                <1>         jnb	short getf2
 59884 000104F2 8A9B[26010300]      <1> 	mov	bl, [ebx+u.fp]
 59885 000104F8 08DB                <1> 	or	bl, bl
 59886 000104FA 7503                <1> 	jnz	short getf3
 59887                              <1> getf2:
 59888                              <1> 	; 'File not open !' error (ax=0)
 59889 000104FC 29C0                <1> 	sub	eax, eax
 59890 000104FE C3                  <1> 	retn
 59891                              <1> getf3:	
 59892                              <1> 	; 23/07/2022
 59893                              <1> 	;test	bl, 80h
 59894                              <1> 	;jnz	short getf5 ; device
 59895 000104FF FECB                <1> 	dec	bl ; 0 based
 59896 00010501 8A83[BC840100]      <1> 	mov	al, [ebx+OF_DRIVE]
 59897 00010507 A2[01010300]        <1> 	mov	[cdev], al
 59898 0001050C C0E302              <1> 	shl	bl, 2 ; *4 (dword offset)
 59899                              <1> 	; 23/07/2022
 59900                              <1> 	;shl	ebx, 2
 59901 0001050F 8B83[BC850100]      <1> 	mov	eax, [ebx+OF_SIZE]
 59902 00010515 A3[24020300]        <1> 	mov	[i.size], eax ; file size
 59903 0001051A 8D83[3C850100]      <1> 	lea	eax, [ebx+OF_POINTER] ; 12/10/2016
 59904 00010520 A3[30010300]        <1> 	mov	[u.fofp], eax
 59905 00010525 8B83[3C840100]      <1> 	mov	eax, [ebx+OF_FCLUSTER]
 59906 0001052B C0EB02              <1> 	shr	bl, 2 ; /4 (byte offset)
 59907                              <1> 	; 23/07/2022
 59908                              <1> 	;shr	ebx, 2
 59909                              <1> 	; 17/04/2021
 59910 0001052E F8                  <1> 	clc 
 59911                              <1> getf4:
 59912 0001052F C3                  <1> 	retn
 59913                              <1> ;getf5: 
 59914                              <1> 	; 17/04/2021
 59915                              <1> 	; (following code is disabled as temporary)
 59916                              <1> 	;
 59917                              <1> 	;; get device number
 59918                              <1> 	;and	bl, 7Fh ; 1 to 7Fh
 59919                              <1> 	;dec	bl ; 0 based (0 to 7Eh)
 59920                              <1> 	;mov	al, [ebx+DEV_DRIVER]
 59921                              <1> 	;mov	ch, [ebx+DEV_ACCESS]
 59922                              <1> 	;mov	cl, [ebx+DEV_OPENMODE]
 59923                              <1> 	;and	ch, 0FEh ; reset bit 0 ; dev_close
 59924                              <1> 	;
 59925                              <1> 	; 23/07/2022
 59926                              <1> 	;stc ; cf = 1 
 59927                              <1> 	;retn
 59928                              <1> 
 59929                              <1> trans_addr_nmbp:
 59930                              <1> 	; 18/10/2015
 59931                              <1> 	; 12/10/2015
 59932 00010530 8B2D[38010300]      <1> 	mov 	ebp, [u.namep]
 59933                              <1> trans_addr_nm: 
 59934                              <1> 	; Convert virtual (pathname) address to physical address
 59935                              <1> 	; (Retro UNIX 386 v1 feature only !)
 59936                              <1> 	; 18/10/2015
 59937                              <1> 	; 12/10/2015 (u.pnbase & u.pncount has been removed from code)
 59938                              <1> 	; 02/07/2015
 59939                              <1> 	; 17/06/2015
 59940                              <1> 	; 16/06/2015
 59941                              <1> 	;
 59942                              <1> 	; INPUTS: 
 59943                              <1> 	;	ebp = pathname address (virtual) ; [u.namep]
 59944                              <1> 	;	[u.pgdir] = user's page directory
 59945                              <1> 	; OUTPUT:
 59946                              <1> 	;       esi = physical address of the pathname
 59947                              <1> 	;	ecx = remain byte count in the page
 59948                              <1> 	;
 59949                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI)
 59950                              <1> 	;
 59951 00010536 833D[78010300]00    <1>         cmp     dword [u.ppgdir], 0  ; /etc/init ? (sysexec)
 59952 0001053D 7618                <1> 	jna	short trans_addr_nmk ; the caller is os kernel;
 59953                              <1> 				     ; it is already physical address
 59954 0001053F 50                  <1>    	push	eax	
 59955 00010540 89EB                <1> 	mov	ebx, ebp ; [u.namep] ; pathname address (virtual)
 59956 00010542 E84155FFFF          <1>        	call	get_physical_addr ; get physical address
 59957 00010547 7204                <1> 	jc	short tr_addr_nm_err
 59958                              <1> 	; 18/10/2015
 59959                              <1> 	; eax = physical address 
 59960                              <1> 	; cx = remain byte count in page (1-4096) 
 59961                              <1> 		; 12/10/2015 (cx = [u.pncount])
 59962 00010549 89C6                <1> 	mov	esi, eax ; 12/10/2015 (esi=[u.pnbase])
 59963 0001054B 58                  <1> 	pop	eax 
 59964 0001054C C3                  <1> 	retn
 59965                              <1> 
 59966                              <1> tr_addr_nm_err:
 59967 0001054D A3[84010300]        <1> 	mov	[u.error], eax
 59968                              <1> 	;pop 	eax
 59969 00010552 E97BC7FFFF          <1> 	jmp	error
 59970                              <1> 
 59971                              <1> trans_addr_nmk:
 59972                              <1> 	; 12/10/2015
 59973                              <1> 	; 02/07/2015
 59974 00010557 8B35[38010300]      <1> 	mov	esi, [u.namep]  ; [u.pnbase]
 59975 0001055D 66B90010            <1> 	mov	cx, PAGE_SIZE ; 4096 ; [u.pncount]
 59976 00010561 C3                  <1> 	retn
 59977                              <1> 
 59978                              <1> sysbreak:
 59979                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 59980                              <1> 	; 18/10/2015
 59981                              <1> 	; 07/10/2015
 59982                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 59983                              <1> 	; 20/06/2013 - 24/03/2014 (Retro UNIX 8086 v1)
 59984                              <1> 	;
 59985                              <1> 	; 'sysbreak' sets the programs break points. 
 59986                              <1> 	; It checks the current break point (u.break) to see if it is
 59987                              <1> 	; between "core" and the stack (sp). If it is, it is made an
 59988                              <1> 	; even address (if it was odd) and the area between u.break
 59989                              <1> 	; and the stack is cleared. The new breakpoint is then put
 59990                              <1> 	; in u.break and control is passed to 'sysret'.
 59991                              <1> 	;
 59992                              <1> 	; Calling sequence:
 59993                              <1> 	;	sysbreak; addr
 59994                              <1> 	; Arguments: -
 59995                              <1> 	;	
 59996                              <1> 	; Inputs: u.break - current breakpoint
 59997                              <1> 	; Outputs: u.break - new breakpoint 
 59998                              <1> 	;	area between old u.break and the stack (sp) is cleared.
 59999                              <1> 	; ...............................................................
 60000                              <1> 	;	
 60001                              <1> 	; Retro UNIX 8086 v1 modification:
 60002                              <1> 	;	The user/application program puts breakpoint address
 60003                              <1> 	;       in BX register as 'sysbreak' system call argument.
 60004                              <1> 	; 	(argument transfer method 1)
 60005                              <1> 	;
 60006                              <1> 	;  NOTE: Beginning of core is 0 in Retro UNIX 8086 v1 !
 60007                              <1> 	; 	((!'sysbreak' is not needed in Retro UNIX 8086 v1!))
 60008                              <1> 	;  NOTE:
 60009                              <1> 	; 	'sysbreak' clears extended part (beyond of previous
 60010                              <1> 	;	'u.break' address) of user's memory for original unix's
 60011                              <1> 	;	'bss' compatibility with Retro UNIX 8086 v1 (19/11/2013)
 60012                              <1> 
 60013                              <1> 		; mov u.break,r1 / move users break point to r1
 60014                              <1> 		; cmp r1,$core / is it the same or lower than core?
 60015                              <1> 		; blos 1f / yes, 1f
 60016                              <1> 	; 23/06/2015
 60017 00010562 8B2D[4C010300]      <1> 	mov	ebp, [u.break] ; virtual address (offset)
 60018                              <1> 	;and	ebp, ebp
 60019                              <1> 	;jz	short sysbreak_3 
 60020                              <1> 	; Retro UNIX 386 v1 NOTE: u.break points to virtual address !!!
 60021                              <1> 	; (Even break point address is not needed for Retro UNIX 386 v1)
 60022 00010568 8B15[14010300]      <1> 	mov	edx, [u.sp] ; kernel stack at the beginning of sys call
 60023 0001056E 83C20C              <1> 	add	edx, 12 ; EIP -4-> CS -4-> EFLAGS -4-> ESP (user) 
 60024                              <1> 	; 07/10/2015
 60025 00010571 891D[4C010300]      <1> 	mov	[u.break], ebx ; virtual address !!!
 60026                              <1> 	;
 60027 00010577 3B1A                <1> 	cmp	ebx, [edx] ; compare new break point with 
 60028                              <1> 			   ; with top of user's stack (virtual!)
 60029 00010579 7323                <1> 	jnb	short sysbreak_3
 60030                              <1> 		; cmp r1,sp / is it the same or higher 
 60031                              <1> 			  ; / than the stack?
 60032                              <1> 		; bhis 1f / yes, 1f
 60033 0001057B 89DE                <1> 	mov	esi, ebx
 60034 0001057D 29EE                <1> 	sub	esi, ebp ; new break point - old break point
 60035 0001057F 761D                <1> 	jna	short sysbreak_3 
 60036                              <1> 	;push	ebx
 60037                              <1> sysbreak_1:
 60038 00010581 89EB                <1> 	mov	ebx, ebp  
 60039 00010583 E80055FFFF          <1> 	call	get_physical_addr ; get physical address
 60040 00010588 72C3                <1> 	jc	short tr_addr_nm_err ; 23/07/2022
 60041                              <1> 	; 18/10/2015
 60042 0001058A 89C7                <1> 	mov	edi, eax 
 60043 0001058C 29C0                <1> 	sub	eax, eax ; 0
 60044                              <1> 		 ; ECX = remain byte count in page (1-4096)
 60045 0001058E 39CE                <1> 	cmp	esi, ecx
 60046 00010590 7302                <1> 	jnb	short sysbreak_2
 60047 00010592 89F1                <1> 	mov	ecx, esi
 60048                              <1> sysbreak_2:
 60049 00010594 29CE                <1> 	sub	esi, ecx
 60050 00010596 01CD                <1> 	add	ebp, ecx
 60051 00010598 F3AA                <1> 	rep 	stosb
 60052 0001059A 09F6                <1> 	or	esi, esi
 60053 0001059C 75E3                <1> 	jnz	short sysbreak_1
 60054                              <1> 	;
 60055                              <1> 		; bit $1,r1 / is it an odd address
 60056                              <1> 		; beq 2f / no, its even
 60057                              <1> 		; clrb (r1)+ / yes, make it even
 60058                              <1> 	; 2: / clear area between the break point and the stack
 60059                              <1> 		; cmp r1,sp / is it higher or same than the stack
 60060                              <1> 		; bhis 1f / yes, quit
 60061                              <1> 		; clr (r1)+ / clear word
 60062                              <1> 		; br 2b / go back
 60063                              <1> 	;pop	ebx
 60064                              <1> sysbreak_3: ; 1:
 60065                              <1> 	;mov	[u.break], ebx ; virtual address !!!
 60066                              <1> 		; jsr r0,arg; u.break / put the "address" 
 60067                              <1> 			; / in u.break (set new break point)
 60068                              <1> 		; br sysret4 / br sysret
 60069 0001059E E94FC7FFFF          <1> 	jmp	sysret
 60070                              <1> 
 60071                              <1> sysseek: ; / moves read write pointer in an fsp entry
 60072                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 60073                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60074                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 60075                              <1> 	;
 60076                              <1> 	; 'sysseek' changes the r/w pointer of (3rd word of in an
 60077                              <1> 	; fsp entry) of an open file whose file descriptor is in u.r0.
 60078                              <1> 	; The file descriptor refers to a file open for reading or
 60079                              <1> 	; writing. The read (or write) pointer is set as follows:
 60080                              <1> 	;	* if 'ptrname' is 0, the pointer is set to offset.
 60081                              <1> 	;	* if 'ptrname' is 1, the pointer is set to its
 60082                              <1> 	;	  current location plus offset.
 60083                              <1> 	;	* if 'ptrname' is 2, the pointer is set to the
 60084                              <1> 	;	  size of file plus offset.
 60085                              <1> 	; The error bit (e-bit) is set for an undefined descriptor.
 60086                              <1> 	;
 60087                              <1> 	; Calling sequence:
 60088                              <1> 	;	sysseek; offset; ptrname
 60089                              <1> 	; Arguments:
 60090                              <1> 	;	offset - number of bytes desired to move 
 60091                              <1> 	;		 the r/w pointer
 60092                              <1> 	;	ptrname - a switch indicated above
 60093                              <1> 	;
 60094                              <1> 	; Inputs: r0 - file descriptor 
 60095                              <1> 	; Outputs: -
 60096                              <1> 	; ...............................................................
 60097                              <1> 	;	
 60098                              <1> 	; Retro UNIX 8086 v1 modification: 
 60099                              <1> 	;       'sysseek' system call has three arguments; so,
 60100                              <1> 	;	* 1st argument, file descriptor is in BX (BL) register
 60101                              <1> 	;	* 2nd argument, offset is in CX register
 60102                              <1> 	;	* 3rd argument, ptrname/switch is in DX (DL) register
 60103                              <1> 
 60104 000105A3 E821000000          <1> 	call	seektell
 60105                              <1> 	; EAX = Current R/W pointer of the file
 60106                              <1> 	; EBX = [u.fofp]
 60107                              <1> 	; [u.base] = offset (ECX input)
 60108                              <1> 
 60109 000105A8 0305[40010300]      <1> 	add	eax, [u.base]
 60110 000105AE 8903                <1> 	mov	[ebx], eax
 60111 000105B0 E93DC7FFFF          <1> 	jmp	sysret
 60112                              <1> 
 60113                              <1> systell: ; / get the r/w pointer
 60114                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0) - temporary !-
 60115                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60116                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 60117                              <1> 	;
 60118                              <1> 	; Retro UNIX 8086 v1 modification:
 60119                              <1> 	; ! 'systell' does not work in original UNIX v1,
 60120                              <1> 	; 	    it returns with error !
 60121                              <1> 	; Inputs: r0 - file descriptor 
 60122                              <1> 	; Outputs: r0 - file r/w pointer
 60123                              <1> 
 60124                              <1> 	;xor	ecx, ecx ; 0
 60125 000105B5 BA01000000          <1> 	mov	edx, 1 ; 05/08/2013
 60126                              <1> 	;call 	seektell
 60127 000105BA E810000000          <1> 	call 	seektell0 ; 05/08/2013
 60128                              <1> 	;; 06/11/2016
 60129                              <1> 	;; mov	eax, [ebx]
 60130 000105BF A3[1C010300]        <1> 	mov	[u.r0], eax
 60131 000105C4 E929C7FFFF          <1> 	jmp	sysret
 60132                              <1> 
 60133                              <1> ; Original unix v1 'systell' system call:
 60134                              <1> 		; jsr r0,seektell
 60135                              <1> 		; br error4
 60136                              <1> 
 60137                              <1> seektell:
 60138                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 60139                              <1> 	; 03/01/2016
 60140                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60141                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 60142                              <1> 	;
 60143                              <1> 	; 'seektell' puts the arguments from sysseek and systell
 60144                              <1> 	; call in u.base and u.count. It then gets the i-number of
 60145                              <1> 	; the file from the file descriptor in u.r0 and by calling
 60146                              <1> 	; getf. The i-node is brought into core and then u.count
 60147                              <1> 	; is checked to see it is a 0, 1, or 2.
 60148                              <1> 	; If it is 0 - u.count stays the same
 60149                              <1> 	;          1 - u.count = offset (u.fofp)
 60150                              <1> 	;	   2 - u.count = i.size (size of file)
 60151                              <1> 	; 	 		
 60152                              <1> 	; !! Retro UNIX 8086 v1 modification:
 60153                              <1> 	;	Argument 1, file descriptor is in BX;
 60154                              <1> 	;	Argument 2, offset is in CX;
 60155                              <1> 	;	Argument 3, ptrname/switch is in DX register.	
 60156                              <1> 	;
 60157                              <1> 	; ((Return -> eax = base for offset (position= base+offset))
 60158                              <1> 	;
 60159 000105C9 890D[40010300]      <1> 	mov 	[u.base], ecx ; offset
 60160                              <1> seektell0:
 60161 000105CF 8915[44010300]      <1> 	mov 	[u.count], edx
 60162                              <1> 	; EBX = file descriptor (file number)
 60163 000105D5 E813FFFFFF          <1> 	call	getf1
 60164                              <1> 	; EAX = First cluster of the file
 60165                              <1> 	; EBX = File number (Open file number)
 60166                              <1> 	; [u.fofp] = Pointer to File pointer
 60167                              <1> 	; [i.size] = File size
 60168                              <1> 
 60169 000105DA 09C0                <1> 	or	eax, eax
 60170 000105DC 7514                <1> 	jnz	short seektell1
 60171                              <1> 
 60172 000105DE B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN
 60173 000105E3 A3[1C010300]        <1> 	mov	[u.r0], eax 
 60174 000105E8 A3[84010300]        <1> 	mov	dword [u.error], eax ; 'file not open !'
 60175 000105ED E9E0C6FFFF          <1> 	jmp	error
 60176                              <1> 
 60177                              <1> seektell1:
 60178 000105F2 8B1D[30010300]      <1>         mov     ebx, [u.fofp]
 60179 000105F8 803D[44010300]01    <1> 	cmp	byte [u.count], 1
 60180 000105FF 7705                <1> 	ja	short seektell2
 60181 00010601 7409                <1> 	je	short seektell3
 60182 00010603 31C0                <1> 	xor	eax, eax
 60183 00010605 C3                  <1> 	retn
 60184                              <1> 
 60185                              <1> seektell2:
 60186 00010606 A1[24020300]        <1>         mov   	eax, [i.size]
 60187 0001060B C3                  <1> 	retn
 60188                              <1> 
 60189                              <1> seektell3:
 60190 0001060C 8B03                <1> 	mov	eax, [ebx]
 60191 0001060E C3                  <1> 	retn
 60192                              <1> 
 60193                              <1> sysintr: ; / set interrupt handling
 60194                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60195                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 60196                              <1> 	;
 60197                              <1> 	; 'sysintr' sets the interrupt handling value. It puts
 60198                              <1> 	; argument of its call in u.intr then branches into 'sysquit'
 60199                              <1> 	; routine. u.tty is checked if to see if a control tty exists.
 60200                              <1> 	; If one does the interrupt character in the tty buffer is
 60201                              <1> 	; cleared and 'sysret'is called. If one does not exits
 60202                              <1> 	; 'sysret' is just called.
 60203                              <1> 	;
 60204                              <1> 	; Calling sequence:
 60205                              <1> 	;	sysintr; arg
 60206                              <1> 	; Argument:
 60207                              <1> 	;	arg - if 0, interrupts (ASCII DELETE) are ignored.
 60208                              <1> 	;	    - if 1, intterupts cause their normal result
 60209                              <1> 	;		 i.e force an exit.
 60210                              <1> 	;	    - if arg is a location within the program,
 60211                              <1> 	;		control is passed to that location when
 60212                              <1> 	;		an interrupt occurs.
 60213                              <1> 	; Inputs: -
 60214                              <1> 	; Outputs: -
 60215                              <1> 	; ...............................................................
 60216                              <1> 	;	
 60217                              <1> 	; Retro UNIX 8086 v1 modification: 
 60218                              <1> 	;       'sysintr' system call sets u.intr to value of BX
 60219                              <1> 	;	then branches into sysquit.
 60220                              <1> 	;
 60221 0001060F 66891D[68010300]    <1> 	mov	[u.intr], bx
 60222                              <1> 		; jsr r0,arg; u.intr / put the argument in u.intr
 60223                              <1> 		; br 1f / go into quit routine
 60224 00010616 E9D7C6FFFF          <1> 	jmp	sysret
 60225                              <1> 
 60226                              <1> sysquit:
 60227                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60228                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 60229                              <1> 	;
 60230                              <1> 	; 'sysquit' turns off the quit signal. it puts the argument of
 60231                              <1> 	; the call in u.quit. u.tty is checked if to see if a control 
 60232                              <1> 	; tty exists. If one does the interrupt character in the tty
 60233                              <1> 	; buffer is cleared and 'sysret'is called. If one does not exits
 60234                              <1> 	; 'sysret' is just called.
 60235                              <1> 	;
 60236                              <1> 	; Calling sequence:
 60237                              <1> 	;	sysquit; arg
 60238                              <1> 	; Argument:
 60239                              <1> 	;	arg - if 0, this call diables quit signals from the
 60240                              <1> 	;		typewriter (ASCII FS)
 60241                              <1> 	;	    - if 1, quits are re-enabled and cause execution to
 60242                              <1> 	;		cease and a core image to be produced.
 60243                              <1> 	;		 i.e force an exit.
 60244                              <1> 	;	    - if arg is an addres in the program,
 60245                              <1> 	;		a quit causes control to sent to that
 60246                              <1> 	;		location.
 60247                              <1> 	; Inputs: -
 60248                              <1> 	; Outputs: -
 60249                              <1> 	; ...............................................................
 60250                              <1> 	;	
 60251                              <1> 	; Retro UNIX 8086 v1 modification: 
 60252                              <1> 	;       'sysquit' system call sets u.quit to value of BX
 60253                              <1> 	;	then branches into 'sysret'.
 60254                              <1> 	;
 60255 0001061B 66891D[6A010300]    <1> 	mov	[u.quit], bx
 60256 00010622 E9CBC6FFFF          <1> 	jmp	sysret
 60257                              <1> 		; jsr r0,arg; u.quit / put argument in u.quit
 60258                              <1> 	;1:
 60259                              <1> 		; mov u.ttyp,r1 / move pointer to control tty buffer
 60260                              <1> 			      ; / to r1
 60261                              <1> 		; beq sysret4 / return to user
 60262                              <1> 		; clrb 6(r1) / clear the interrupt character 
 60263                              <1> 			   ; / in the tty buffer
 60264                              <1> 		; br sysret4 / return to user
 60265                              <1> 
 60266                              <1> %if 0
 60267                              <1> 
 60268                              <1> anyi: 
 60269                              <1> 	; 23/07/2022
 60270                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 60271                              <1> 	; Major Modification!
 60272                              <1> 	; TRDOS 386 does not permit to delete a file while it is open 
 60273                              <1> 	; The role of 'anyi' procedure has beeen changed to ensure that.
 60274                              <1> 	; 	
 60275                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 60276                              <1> 	; 25/04/2013 (Retro UNIX 8086 v1)
 60277                              <1> 	;
 60278                              <1> 	; 'anyi' is called if a file deleted while open.
 60279                              <1> 	; "anyi" checks to see if someone else has opened this file.
 60280                              <1> 	;
 60281                              <1> 	; INPUTS ->
 60282                              <1> 	;    r1 - contains an i-number
 60283                              <1> 	;    fsp - start of table containing open files
 60284                              <1> 	;
 60285                              <1> 	; OUTPUTS ->
 60286                              <1> 	;    "deleted" flag set in fsp entry of another occurrence of
 60287                              <1> 	;	   this file and r2 points 1st word of this fsp entry.
 60288                              <1> 	;    if file not found - bit in i-node map is cleared
 60289                              <1> 	;    			 (i-node is freed)
 60290                              <1> 	;               all blocks related to i-node are freed
 60291                              <1> 	;	        all flags in i-node are cleared
 60292                              <1> 	; ((AX = R1)) input
 60293                              <1> 	;
 60294                              <1> 	;    (Retro UNIX Prototype : 02/12/2012, UNIXCOPY.ASM)
 60295                              <1>         ;    ((Modified registers: EDX, ECX, EBX, ESI, EDI, EBP))
 60296                              <1> 	;
 60297                              <1> 	; / r1 contains an i-number
 60298                              <1> 
 60299                              <1> 	; TRDOS 386 (06/10/2016)
 60300                              <1> 	; 
 60301                              <1> 	; INPUT:
 60302                              <1> 	;	EAX = First Cluster
 60303                              <1> 	;	 DL = Logical DOS Drive Number
 60304                              <1> 	;
 60305                              <1> 	; OUTPUT:
 60306                              <1> 	;	CF = 1 -> EBX = File Handle/Number/Index
 60307                              <1> 	;	CF = 0 -> EBX = 0
 60308                              <1> 	;
 60309                              <1> 	; Modified Registers: EBX
 60310                              <1> 
 60311                              <1> 	xor	ebx, ebx
 60312                              <1> anyi_0: 
 60313                              <1> 	cmp	byte [ebx+OF_MODE], 0 ; 0 = empty entry
 60314                              <1> 	ja	short anyi_2 ; 1 (r), 2 (w) or 3 (r&w)
 60315                              <1> anyi_1:
 60316                              <1> 	inc	bl
 60317                              <1> 	cmp	bl, OPENFILES ; max. count of open files
 60318                              <1> 	jb	short anyi_0
 60319                              <1> 	xor	eax, eax
 60320                              <1> 	retn 
 60321                              <1> anyi_2:
 60322                              <1> 	cmp	dl, [ebx+OF_DRIVE]
 60323                              <1> 	jne	short anyi_1
 60324                              <1> 	;shl	bx, 2 ; *4 (dword offset)
 60325                              <1> 	shl	ebx, 2 ; 23/07/2022
 60326                              <1> 	cmp	eax, [ebx+OF_FCLUSTER]
 60327                              <1> 	je	short anyi_3
 60328                              <1> 	;shr	bx, 2 ; /4 (byte offset)
 60329                              <1> 	shr	ebx, 2 ; 23/07/2022
 60330                              <1> 	jmp	short anyi_1 	
 60331                              <1> anyi_3:
 60332                              <1> 	;shr	bx, 2 ; /4 (bytes offset) (index)
 60333                              <1> 	shr	ebx, 2 ; 23/07/2022
 60334                              <1> 	stc
 60335                              <1> 	retn
 60336                              <1> 
 60337                              <1> %endif
 60338                              <1> 
 60339                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS9.INC
 60340                              <1> ; Last Modification: 09/12/2015
 60341                              <1> 
 60342                              <1> syssleep:
 60343                              <1> 	; 24/07/2022 - TRDOS 386 v2.0.5
 60344                              <1> 	; 29/06/2015 - (Retro UNIX 386 v1)
 60345                              <1> 	; 11/06/2014 - (Retro UNIX 8086 v1)
 60346                              <1> 	;
 60347                              <1> 	; Retro UNIX 8086 v1 feature only
 60348                              <1> 	; (INPUT -> none)
 60349                              <1> 	
 60350                              <1> 	; Temporary - 24/07/2022
 60351 00010627 891D[1C010300]      <1> 	mov	[u.r0], ebx
 60352                              <1> 	;
 60353 0001062D 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; process number
 60354 00010634 8AA3[3F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; current/console tty
 60355 0001063A E8DA160000          <1> 	call	sleep
 60356                              <1> 	; 24/07/2022
 60357 0001063F FF05[1C010300]      <1> 	inc	dword [u.r0] ; Temporary ! 
 60358 00010645 E9A8C6FFFF          <1> 	jmp	sysret
 60359                              <1> 
 60360                              <1> _vp_clr:
 60361                              <1> 	; Reset/Clear Video Page
 60362                              <1> 	;
 60363                              <1> 	; 24/07/2022 - TRDOS 386 v2.0.5
 60364                              <1> 	; 30/06/2015 - (Retro UNIX 386 v1)
 60365                              <1> 	; 21/05/2013 - 30/10/2013(Retro UNIX 8086 v1) (U0.ASM)
 60366                              <1> 	;
 60367                              <1> 	; Retro UNIX 8086 v1 feature only !
 60368                              <1> 	;
 60369                              <1> 	; INPUTS -> 
 60370                              <1> 	;   BH = video page number	 
 60371                              <1> 	;
 60372                              <1> 	; OUTPUT ->
 60373                              <1> 	;   none
 60374                              <1> 	; ((Modified registers: EAX, BH, ECX, EDX, ESI, EDI))
 60375                              <1> 	;
 60376                              <1> 	; 04/12/2013
 60377 0001064A 28C0                <1> 	sub	al, al
 60378                              <1> 	; al = 0 (clear video page)
 60379                              <1> 	; bh = video page ; 13/05/2016
 60380 0001064C B407                <1> 	mov	ah, 07h
 60381                              <1> 	; ah = 7 (attribute/color)
 60382                              <1> 	;xor 	cx, cx ; 0, left upper column (cl) & row (cl)
 60383                              <1> 	;mov	dx, 184Fh ; right lower column & row (dl=24, dh=79)
 60384                              <1> 	; 24/07/2022
 60385 0001064E 31C9                <1> 	xor	ecx, ecx
 60386 00010650 BA4F180000          <1> 	mov	edx, 184Fh
 60387 00010655 E81619FFFF          <1> 	call	_scroll_up
 60388                              <1> 	; bh = video page
 60389                              <1> 	;xor	dx, dx ; 0 (cursor position) 
 60390                              <1> 	; 24/07/2022
 60391 0001065A 31D2                <1> 	xor	edx, edx
 60392 0001065C E9551CFFFF          <1> 	jmp 	_set_cpos
 60393                              <1> 
 60394                              <1> sysmsg:
 60395                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 60396                              <1> 	; 07/12/2020
 60397                              <1> 	; 05/12/2020
 60398                              <1> 	; 13/05/2016
 60399                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 60400                              <1> 	; 01/07/2015 - 11/11/2015 (Retro UNIX 386 v1)
 60401                              <1> 	; Print user-application message on user's console tty
 60402                              <1> 	;
 60403                              <1> 	; Input -> EBX = Message address
 60404                              <1> 	;	   ECX = Message length (max. 255)
 60405                              <1> 	;	   DL = Color (IBM PC Rombios color attributes)
 60406                              <1> 	;
 60407 00010661 81F9FF000000        <1> 	cmp	ecx, MAX_MSG_LEN ; 255
 60408                              <1> 	;ja	sysret ; nothing to do with big message size
 60409                              <1> 	; 23/07/2022
 60410 00010667 7605                <1> 	jna	short sysmsg8
 60411                              <1> sysmsg7:
 60412 00010669 E984C6FFFF          <1> 	jmp	sysret
 60413                              <1> sysmsg8:	; 23/07/2022
 60414 0001066E 08C9                <1> 	or	cl, cl
 60415                              <1> 	;jz	sysret
 60416                              <1> 	; 23/07/2022
 60417 00010670 74F7                <1> 	jz	short sysmsg7
 60418 00010672 20D2                <1> 	and	dl, dl
 60419 00010674 7502                <1> 	jnz	short sysmsg0
 60420 00010676 B207                <1> 	mov	dl, 07h ; default color
 60421                              <1> 		; (black background, light gray character) 
 60422                              <1> sysmsg0:
 60423 00010678 891D[40010300]      <1> 	mov	[u.base], ebx
 60424 0001067E 8815[AF770100]      <1> 	mov	[ccolor], dl ; color attributes
 60425 00010684 89E5                <1> 	mov	ebp, esp
 60426 00010686 31DB                <1> 	xor	ebx, ebx ; 0
 60427 00010688 891D[48010300]      <1> 	mov	[u.nread], ebx ; 0
 60428                              <1> 	;
 60429 0001068E 381D[82010300]      <1> 	cmp	[u.kcall], bl ; 0
 60430 00010694 776F                <1> 	ja	short sysmsgk ; Temporary (01/07/2015)
 60431                              <1> 	;
 60432 00010696 890D[44010300]      <1> 	mov	[u.count], ecx
 60433                              <1> 	;inc	ecx ; + 00h ; ASCIIZ
 60434                              <1> 	;
 60435                              <1> 	; 07/12/2020
 60436                              <1> 	;add	ecx, 3
 60437 0001069C 6683C103            <1> 	add	cx, 3
 60438 000106A0 80E1FC              <1> 	and	cl, ~3  ; not 3
 60439                              <1> 	;
 60440 000106A3 29CC                <1> 	sub	esp, ecx
 60441 000106A5 89E7                <1> 	mov	edi, esp
 60442 000106A7 89E6                <1> 	mov	esi, esp
 60443 000106A9 66891D[80010300]    <1> 	mov	[u.pcount], bx ; reset page (phy. addr.) counter
 60444                              <1> 	; 11/11/2015
 60445 000106B0 8A25[50010300]      <1> 	mov 	ah, [u.ttyp] ; recent open tty
 60446                              <1> 	; 0 = none
 60447 000106B6 FECC                <1> 	dec	ah
 60448 000106B8 790C                <1> 	jns	short sysmsg1 
 60449 000106BA 8A1D[6D010300]      <1> 	mov	bl, [u.uno] ; process number	
 60450 000106C0 8AA3[3F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; user's (process's) console tty
 60451                              <1> sysmsg1:
 60452 000106C6 8825[52010300]      <1> 	mov	[u.ttyn], ah
 60453                              <1> sysmsg2:
 60454 000106CC E8FD050000          <1> 	call	cpass
 60455 000106D1 7416                <1> 	jz	short sysmsg5
 60456 000106D3 AA                  <1> 	stosb
 60457 000106D4 20C0                <1> 	and	al, al
 60458 000106D6 75F4                <1> 	jnz	short sysmsg2
 60459                              <1> sysmsg3:
 60460 000106D8 80FC07              <1> 	cmp	ah, 7 ; tty number
 60461 000106DB 7711                <1> 	ja	short sysmsg6 ; serial port
 60462 000106DD E83E000000          <1> 	call	print_cmsg ; 05/12/2020
 60463                              <1> sysmsg4:
 60464 000106E2 89EC                <1> 	mov	esp, ebp	
 60465 000106E4 E909C6FFFF          <1> 	jmp	sysret
 60466                              <1> sysmsg5:
 60467 000106E9 C60700              <1> 	mov	byte [edi], 0
 60468 000106EC EBEA                <1> 	jmp	short sysmsg3
 60469                              <1> sysmsg6:
 60470 000106EE 8A06                <1> 	mov	al, [esi]
 60471 000106F0 E824160000          <1> 	call	sndc
 60472 000106F5 72EB                <1> 	jc	short sysmsg4
 60473 000106F7 803E00              <1> 	cmp	byte [esi], 0  ; 0 is stop character
 60474 000106FA 76E6                <1> 	jna	short sysmsg4
 60475 000106FC 46                  <1> 	inc 	esi
 60476 000106FD 8A25[52010300]      <1> 	mov	ah, [u.ttyn]
 60477 00010703 EBE9                <1> 	jmp	short sysmsg6
 60478                              <1> 
 60479                              <1> sysmsgk: ; Temporary (01/07/2015)
 60480                              <1> 	; The message has been sent by Kernel (ASCIIZ string)
 60481                              <1> 	; (ECX -character count- will not be considered)
 60482 00010705 8B35[40010300]      <1> 	mov	esi, [u.base]
 60483 0001070B 8A25[AE770100]      <1> 	mov	ah, [ptty] ; present/current screen (video page)
 60484 00010711 8825[52010300]      <1> 	mov	[u.ttyn], ah
 60485 00010717 C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 60486 0001071E EBB8                <1> 	jmp	short sysmsg3
 60487                              <1> 	
 60488                              <1> print_cmsg: 
 60489                              <1> 	; 08/12/2020
 60490                              <1> 	; 07/12/2020
 60491                              <1> 	; 05/12/2020
 60492                              <1> 	; 18/11/2017
 60493                              <1> 	; 13/05/2016 - TRDOS 386 (TRDOS v2.0)
 60494                              <1> 	; 01/07/2015 (Retro UNIX 386 v1)
 60495                              <1> 	;
 60496                              <1> 	; print message (on user's console tty) 
 60497                              <1> 	;	with requested color
 60498                              <1> 	;
 60499                              <1> 	; INPUTS:
 60500                              <1> 	;	esi = message address
 60501                              <1> 	;	[u.ttyn] = tty number (0 to 7)
 60502                              <1> 	;	[ccolor] = color attributes (IBM PC BIOS colors)
 60503                              <1> 	;
 60504                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 60505                              <1> 	; (ebp must be preserved)
 60506                              <1> 
 60507                              <1> 	;mov	bh, ah
 60508 00010720 8A3D[52010300]      <1> 	mov	bh, [u.ttyn]
 60509 00010726 8A1D[AF770100]      <1> 	mov	bl, [ccolor] ; * ; 05/12/2020
 60510                              <1> 
 60511                              <1> 	; 05/12/2020
 60512 0001072C 803D[D00F0300]00    <1> 	cmp	byte [pmi32], 0 ; is vbios's 32 bit pmi enabled ?
 60513 00010733 772E                <1> 	ja	short pcmsg5 ; yes
 60514                              <1> pcmsg1:
 60515                              <1> 	; 08/12/2020
 60516 00010735 8A1D[AF770100]      <1> 	mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 60517                              <1> 	
 60518 0001073B AC                  <1> 	lodsb
 60519 0001073C 20C0                <1> 	and 	al, al  ; 0
 60520 0001073E 743A                <1> 	jz 	short pcmsg2
 60521                              <1> pcmsg7:
 60522 00010740 56                  <1> 	push 	esi
 60523                              <1> 	;mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 60524                              <1> 	; 05/12/2020
 60525                              <1> 	;;mov	bh, [u.ttyn]
 60526                              <1> 	;call 	_write_tty
 60527                              <1> 	;pop	esi
 60528                              <1> 	;jmp	short pcmsg1
 60529                              <1> ;pcmsg2:
 60530                              <1> 	;retn
 60531                              <1> 
 60532                              <1> 	; 07/12/2020
 60533 00010741 803D[9E660000]03    <1> 	cmp     byte [CRT_MODE], 3
 60534 00010748 7708                <1> 	ja 	short pcmsg4
 60535                              <1> pcmsg3:
 60536 0001074A E8E21AFFFF          <1> 	call	_write_tty_m3
 60537 0001074F 5E                  <1> 	pop	esi
 60538 00010750 EBE3                <1> 	jmp	short pcmsg1
 60539                              <1> pcmsg4:
 60540 00010752 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7
 60541 00010759 76EF                <1> 	jna 	short pcmsg3
 60542 0001075B E89A27FFFF          <1> 	call	vga_write_teletype
 60543 00010760 5E                  <1> 	pop	esi
 60544 00010761 EBD2                <1> 	jmp	short pcmsg1
 60545                              <1> pcmsg5:
 60546                              <1> 	; 07/12/2020
 60547 00010763 803D[9E660000]07    <1>         cmp     byte [CRT_MODE], 7
 60548 0001076A 76C9                <1> 	jna 	short pcmsg1
 60549                              <1> 
 60550                              <1> 	; 05/12/2020
 60551                              <1> 	; writing message by using
 60552                              <1> 	; VESA VBE3 video bios protected mode interface
 60553                              <1> 	
 60554 0001076C B40E                <1> 	mov	ah, 0Eh
 60555                              <1> pcmsg6:
 60556 0001076E AC                  <1> 	lodsb
 60557 0001076F 20C0                <1> 	and 	al, al  ; 0
 60558 00010771 7407                <1> 	jz 	short pcmsg2
 60559                              <1> 	; bh = video page
 60560                              <1> 	; ah = 0Eh 
 60561                              <1> 	; al = character
 60562                              <1> 	; bl = color
 60563 00010773 E8FA11FFFF          <1> 	call	int10h_32bit_pmi
 60564 00010778 EBF4                <1> 	jmp	short pcmsg6
 60565                              <1> pcmsg2:
 60566 0001077A C3                  <1> 	retn
 60567                              <1> 
 60568                              <1> sysgeterr:
 60569                              <1> 	; 09/12/2015
 60570                              <1> 	; 21/09/2015 - (Retro UNIX 386 v1 feature only!)
 60571                              <1> 	; Get last error number or page fault count
 60572                              <1> 	; (for debugging)
 60573                              <1> 	;
 60574                              <1> 	; Input -> EBX = return type
 60575                              <1> 	;	   0 = last error code (which is in 'u.error')	
 60576                              <1> 	;	   FFFFFFFFh = page fault count for running process
 60577                              <1> 	;	   FFFFFFFEh = total page fault count
 60578                              <1> 	;	   1 .. FFFFFFFDh = undefined 
 60579                              <1> 	;
 60580                              <1> 	; Output -> EAX = last error number or page fault count
 60581                              <1> 	;	   (depending on EBX input)
 60582                              <1> 	; 	
 60583 0001077B 21DB                <1> 	and 	ebx, ebx
 60584 0001077D 750B                <1> 	jnz	short glerr_2
 60585                              <1> glerr_0:
 60586 0001077F A1[84010300]        <1> 	mov	eax, [u.error]
 60587                              <1> glerr_1:
 60588 00010784 A3[1C010300]        <1> 	mov	[u.r0], eax
 60589 00010789 C3                  <1>  	retn
 60590                              <1> glerr_2:
 60591 0001078A 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0, FFFFFFFEh -> FFFFFFFFh
 60592 0001078B 74FD                <1> 	jz	short glerr_2 ; page fault count for process
 60593 0001078D 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0	
 60594 0001078E 75EF                <1> 	jnz	short glerr_0
 60595 00010790 A1[34030300]        <1> 	mov	eax, [PF_Count] ; total page fault count
 60596 00010795 EBED                <1>         jmp     short glerr_1
 60597                              <1> glerr_3:
 60598 00010797 A1[88010300]        <1> 	mov 	eax, [u.pfcount]
 60599 0001079C EBE6                <1> 	jmp	short glerr_1
 60600                              <1> 
 60601                              <1> load_and_run_file:
 60602                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 60603                              <1> 	; 18/11/2017
 60604                              <1> 	; 22/01/2017
 60605                              <1> 	; 04/01/2017 - 07/01/2017
 60606                              <1> 	; 24/10/2016
 60607                              <1> 	; 24/04/2016 - 02/05/2016 - 03/05/2016 - 06/05/2016
 60608                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
 60609                              <1> 	; 23/10/2015 (Retro UNIX 386 v1, 'sysexec')
 60610                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 60611                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 60612                              <1> 	; EAX = First Cluster number
 60613                              <1> 	; EDX = File Size
 60614                              <1> 	; ESI = Argument list address
 60615                              <1> 	; [argc] = argument count
 60616                              <1> 	; [u.nread] = argument list length
 60617                              <1> 	; [esp] = return address to the caller (*)
 60618                              <1> 	;
 60619 0001079E 8935[18020300]      <1> 	mov	[argv], esi
 60620 000107A4 8915[24020300]      <1> 	mov	[i.size], edx
 60621 000107AA A3[20020300]        <1> 	mov	[ii], eax
 60622                              <1> 
 60623                              <1> 	;sti	; 07/01/2017
 60624                              <1> 	;mov	eax, [k_page_dir]
 60625                              <1> 	;mov	[u.pgdir], eax
 60626 000107AF 31C0                <1> 	xor 	eax, eax ; clc ; *** ; 04/01/2017
 60627                              <1> 	;mov	[u.r0], eax ; 0 ; 07/01/2017
 60628                              <1> 
 60629                              <1> 	; 06/05/2016
 60630                              <1> 	; Set 'sysexit' return order to MainProg
 60631                              <1> 	;
 60632 000107B1 58                  <1> 	pop	eax ; * 'loc_load_and_run_file_8:' address
 60633                              <1> 	;; 22/01/2017
 60634                              <1> 	;;cli ; 07/01/2017
 60635 000107B2 8B25[1C770100]      <1> 	mov	esp, [tss.esp0]
 60636                              <1> 	;
 60637                              <1> 	; 'loc_load_run_file_8' address has 
 60638                              <1> 	; 'jmp loc_file_rw_restore_retn' instruction
 60639                              <1> 	; 'loc_file_rw_restore_retn:' will return to
 60640                              <1> 	; [mainprog_return_addr] 
 60641                              <1> 	; just after 'call command_interpreter'
 60642                              <1> 	;
 60643 000107B8 68[086C0000]        <1> 	push	_end_of_mainprog ; we must not return to here !
 60644 000107BD FF35[FC830100]      <1> 	push	dword [mainprog_return_addr]
 60645 000107C3 89E5                <1> 	mov	ebp, esp ; **
 60646                              <1> 	;	
 60647 000107C5 9C                  <1> 	pushfd  ; EFLAGS      ; IRETD ; ***
 60648 000107C6 6A08                <1> 	push	KCODE ; cs    ; IRETD
 60649 000107C8 50                  <1> 	push	eax ; * (eip) ; IRETD
 60650 000107C9 8925[14010300]      <1> 	mov	[u.sp], esp
 60651                              <1> 	;mov	byte [u.quant], time_count
 60652 000107CF 1E                  <1> 	push	ds
 60653 000107D0 06                  <1> 	push	es
 60654 000107D1 0FA0                <1> 	push	fs
 60655 000107D3 0FA8                <1> 	push	gs	
 60656                              <1> 	;mov	eax, [u.r0]
 60657 000107D5 29C0                <1> 	sub	eax, eax
 60658 000107D7 60                  <1> 	pushad
 60659 000107D8 68[F2CC0000]        <1> 	push	sysret
 60660                              <1> 	;push	sysrel1 ; 07/01/2017
 60661 000107DD 8925[18010300]      <1> 	mov	[u.usp], esp
 60662                              <1> 	;
 60663 000107E3 E801040000          <1> 	call	wswap ; Save MainProg (process 1) 'u' structure
 60664                              <1> 		      ; and registers for return (from program)	
 60665 000107E8 89EC                <1> 	mov	esp, ebp ; **
 60666                              <1> 	;;22/01/2017
 60667                              <1> 	;;sti ; 07/01/2017
 60668                              <1> 	; 23/07/2022
 60669                              <1> 	;push	eax  ; * 'loc_load_and_run_file_8:' address
 60670                              <1> 	;
 60671                              <1> 	;;; 02/05/2016
 60672                              <1> 	;;; Create a new process (parent: MainProg)	
 60673 000107EA 31F6                <1> 	xor 	esi, esi
 60674                              <1> cnpm_1: ; search p.stat table for unused process number
 60675 000107EC 46                  <1> 	inc	esi
 60676 000107ED 80BE[5F000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE
 60677                              <1> 				; is process active, unused, dead
 60678 000107F4 760B                <1> 	jna	short cnpm_2	; it's unused so branch
 60679 000107F6 6683FE10            <1> 	cmp	si, nproc 	; all processes checked
 60680 000107FA 72F0                <1> 	jb	short cnpm_1    ; no, branch back
 60681                              <1> cnpm_panic:
 60682 000107FC E98864FFFF          <1> 	jmp	panic 
 60683                              <1> cnpm_2:
 60684 00010801 A1[74010300]        <1> 	mov	eax, [u.pgdir] ; page directory of MainProg
 60685 00010806 A3[78010300]        <1> 	mov	[u.ppgdir], eax ; parent's page directory
 60686 0001080B E88B4EFFFF          <1> 	call	allocate_page
 60687                              <1> 	;jc	panic
 60688                              <1> 	; 23/07/2022
 60689 00010810 72EA                <1> 	jc	short cnpm_panic
 60690                              <1> 	
 60691                              <1> 	; EAX = UPAGE (user structure page) address
 60692 00010812 A3[70010300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
 60693 00010817 89F7                <1> 	mov	edi, esi
 60694                              <1> 	;shl	di, 2
 60695                              <1> 	; 23/07/2022
 60696 00010819 C1E702              <1> 	shl	edi, 2
 60697 0001081C 8987[6C000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
 60698 00010822 E8E54EFFFF          <1> 	call	clear_page ; 03/05/2016
 60699                              <1> 	;;movzx	eax, byte [p.ttyc] ; console tty (for MainProg)
 60700                              <1> 	;sub	ax, ax ; 0
 60701                              <1> 	; 23/07/2022
 60702 00010827 29C0                <1> 	sub	eax, eax
 60703 00010829 668986[3F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
 60704                              <1> 				   ; ah - reset child's wait channel	
 60705 00010830 66A3[50010300]      <1> 	mov 	[u.ttyp], ax ; 0
 60706                              <1> 	
 60707 00010836 89F2                <1> 	mov	edx, esi
 60708 00010838 8815[6D010300]      <1> 	mov	[u.uno], dl ; child process number
 60709 0001083E FE86[5F000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN
 60710                              <1> 	;shl	si, 1 ; multiply si by 2 to get index into p.pid table
 60711                              <1> 	; 23/07/2022
 60712 00010844 D1E6                <1> 	shl	esi, 1
 60713 00010846 66FF05[04010300]    <1> 	inc	word [mpid] ; increment m.pid; get a new process name
 60714                              <1> 
 60715                              <1> 	; 23/07/2022	
 60716                              <1> 	;mov	ax, [p.pid]  ; get process name of MainProg
 60717                              <1> 	;mov	ax, 1
 60718 0001084D FEC0                <1> 	inc	al ; eax = 1
 60719 0001084F 668986[1E000300]    <1> 	mov	[esi+p.ppid-2], ax ; put parent process name 
 60720                              <1> 			           ; in parent process slot for child
 60721 00010856 A2[66010300]        <1> 	mov	[u.pri], al ; 1	; normal priority
 60722                              <1> 	
 60723                              <1> 	;dec	ax ; 0
 60724                              <1> 	;mov 	[u.ttyp], ax ; 0
 60725                              <1> 
 60726 0001085B 66A1[04010300]      <1> 	mov	ax, [mpid]
 60727 00010861 668986[FEFF0200]    <1> 	mov	[esi+p.pid-2], ax ; put new process name 
 60728                              <1> 				  ; in child process' name slot
 60729                              <1> 	;;;
 60730 00010868 A1[20020300]        <1> 	mov 	eax,  [ii]
 60731                              <1> 	; 23/07/2022
 60732                              <1> 	; Retro UNIX 386 v1, 'sysexec' (u2.s)
 60733                              <1> 	;call	iopen
 60734                              <1> 	; 06/06/2016
 60735                              <1> 	;mov	byte [u.pri], 1 ; normal priority
 60736                              <1> 	;
 60737                              <1> 	;jmp	short sysexec_7 ; 02/05/2016
 60738                              <1> 	; 23/07/2022
 60739 0001086D E96DF9FFFF          <1> 	jmp	sysexec_7
 60740                              <1> 
 60741                              <1> ;	; 02/05/2016
 60742                              <1> ;	;inc	byte [sysflg] ; 0FFh -> 0
 60743                              <1> ;	;mov	byte [sysflg], 0 ; 04/01/2017
 60744                              <1> ;	movzx	ebx, byte [u.uno]
 60745                              <1> ;	shl	bl, 1 ; 13/11/2017 	
 60746                              <1> ;	cmp	word [ebx+p.ppid-2], 1 ; MainProg
 60747                              <1> ;	ja	sysret0 ; 03/05/2016
 60748                              <1> ;	push	sysret ; * 
 60749                              <1> ;	mov	[u.usp], esp
 60750                              <1> ;	call	wswap ; save child process 'u' structure and
 60751                              <1> ;		      ; registers
 60752                              <1> ;	add	dword [u.usp], 4 ; 03/05/2016 
 60753                              <1> ;sysexec_19: ; 02/05/2016
 60754                              <1> ;	retn ; * 'sysret' ; byte [sysflg] -> 0FFh
 60755                              <1> 
 60756                              <1> readi:
 60757                              <1> 	; 09/08/2022
 60758                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 60759                              <1> 	; 01/05/2016
 60760                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 60761                              <1> 	; 20/05/2015 - Retro UNIX 386 v1
 60762                              <1> 	; 11/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 60763                              <1> 	;
 60764                              <1> 	; Reads from a file whose the first cluster number in EAX
 60765                              <1> 	; 
 60766                              <1> 	; INPUTS ->
 60767                              <1> 	;    EAX - First cluster number of the file
 60768                              <1> 	;    u.count - byte count user desires
 60769                              <1> 	;    u.base - points to user buffer
 60770                              <1> 	;    u.fofp - points to dword with current file offset
 60771                              <1> 	;    i.size - file size
 60772                              <1> 	;    cdev - logical dos drive number of the file
 60773                              <1> 	; OUTPUTS ->
 60774                              <1> 	;    u.count - cleared
 60775                              <1> 	;    u.nread - accumulates total bytes passed back
 60776                              <1> 	;
 60777                              <1> 	; ((EAX)) input/output
 60778                              <1> 	; (Retro UNIX Prototype : 14/12/2012 - 01/03/2013, UNIXCOPY.ASM)
 60779                              <1>         ; ((Modified registers: edx, ebx, ecx, esi, edi))  
 60780                              <1> 
 60781 00010872 31D2                <1> 	xor	edx, edx ; 0
 60782 00010874 8915[48010300]      <1> 	mov 	[u.nread], edx ; 0
 60783 0001087A 668915[80010300]    <1> 	mov	[u.pcount], dx ; 19/05/2015
 60784 00010881 3915[44010300]      <1> 	cmp 	[u.count], edx ; 0
 60785                              <1> 	;ja 	short readi_1
 60786                              <1> 	;retn
 60787                              <1> 	; 09/08/2022
 60788 00010887 765E                <1> 	jna	short dskr_5 ; retn
 60789                              <1> ;readi_1:
 60790                              <1> dskr:
 60791                              <1> 	; 01/05/2016
 60792                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 60793                              <1> 	; 24/05/2015 - 12/10/2015 (Retro UNIX 386 v1)
 60794                              <1> 	; 26/04/2013 - 03/08/2013 (Retro UNIX 8086 v1)
 60795                              <1> dskr_0:
 60796 00010889 8B15[24020300]      <1>         mov	edx, [i.size]
 60797 0001088F 8B1D[30010300]      <1> 	mov	ebx, [u.fofp]
 60798 00010895 2B13                <1> 	sub	edx, [ebx]
 60799 00010897 7647                <1> 	jna	short dskr_4
 60800                              <1> 	;
 60801 00010899 50                  <1> 	push	eax ; 01/05/2016
 60802 0001089A 3B15[44010300]      <1> 	cmp     edx, [u.count] 
 60803 000108A0 7306                <1> 	jnb	short dskr_1
 60804 000108A2 8915[44010300]      <1> 	mov	[u.count], edx
 60805                              <1> dskr_1:
 60806                              <1> 	; EAX = First Cluster
 60807                              <1> 	; [Current_Drv] = Physical drive number 
 60808 000108A8 E83B000000          <1> 	call	mget_r
 60809                              <1> 	; NOTE: in 'mget_r', relevant sector will be read in buffer
 60810                              <1> 	; if it is not already in buffer !
 60811 000108AD BB[40030300]        <1> 	mov	ebx, readi_buffer
 60812 000108B2 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0 ; the caller is 'namei' sign (=1)
 60813 000108B9 770F                <1> 	ja	short dskr_3	  ; zf=0 -> the caller is 'namei'
 60814 000108BB 66833D[80010300]00  <1> 	cmp	word [u.pcount], 0
 60815 000108C3 7705                <1> 	ja	short dskr_3
 60816                              <1> dskr_2:
 60817                              <1> 	; [u.base] = virtual address to transfer (as destination address)
 60818 000108C5 E88E010000          <1> 	call	trans_addr_w ; translate virtual address to physical (w)
 60819                              <1> dskr_3:
 60820                              <1> 	; EBX (r5) = system (I/O) buffer address -physical-
 60821 000108CA E8F1010000          <1> 	call	sioreg
 60822 000108CF 87F7                <1> 	xchg	esi, edi
 60823                              <1> 	; EDI = file (user data) offset
 60824                              <1> 	; ESI = sector (I/O) buffer offset
 60825                              <1> 	; ECX = byte count
 60826 000108D1 F3A4                <1> 	rep	movsb
 60827                              <1> 	; eax = remain bytes in buffer
 60828                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 60829 000108D3 09C0                <1> 	or	eax, eax
 60830 000108D5 75EE                <1> 	jnz	short dskr_2 ; (page end before system buffer end!)
 60831 000108D7 58                  <1> 	pop	eax  ; (first cluster number)
 60832 000108D8 390D[44010300]      <1> 	cmp	[u.count], ecx ; 0
 60833 000108DE 77A9                <1> 	ja	short dskr_0
 60834                              <1> dskr_4:
 60835 000108E0 C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 60836                              <1> dskr_5:		; 23/07/2022
 60837 000108E7 C3                  <1> 	retn
 60838                              <1> 
 60839                              <1> mget_r:
 60840                              <1> 	; 30/07/2022
 60841                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 60842                              <1> 	; 24/10/2016
 60843                              <1> 	; 22/10/2016
 60844                              <1> 	; 12/10/2016
 60845                              <1> 	; 29/04/2016
 60846                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 60847                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 60848                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 60849                              <1> 	;
 60850                              <1> 	; Get existing or (allocate) a new disk block for file
 60851                              <1> 	; 
 60852                              <1> 	; INPUTS ->
 60853                              <1> 	;    [u.fofp] = file offset pointer
 60854                              <1> 	;    EAX = First Cluster
 60855                              <1> 	;    [cdev] = Logical dos drive number 	  
 60856                              <1> 	;    ([u.off] = file offset)
 60857                              <1> 	; OUTPUTS ->
 60858                              <1> 	;    EAX = logical sector number
 60859                              <1> 	;    ESI = Logical Dos Drive Description Table address	
 60860                              <1> 	;
 60861                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI
 60862                              <1> 
 60863 000108E8 8B35[30010300]      <1> 	mov     esi, [u.fofp]
 60864 000108EE 8B1E                <1> 	mov	ebx, [esi] ; (u.off)
 60865                              <1> 
 60866 000108F0 29C9                <1> 	sub	ecx, ecx
 60867 000108F2 8A2D[01010300]      <1> 	mov	ch, [cdev]
 60868                              <1> 
 60869 000108F8 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 60870 000108FD 01CE                <1> 	add	esi, ecx
 60871                              <1> 
 60872 000108FF 380D[B0830100]      <1> 	cmp	[readi.valid], cl ; 0
 60873 00010905 7648                <1> 	jna	short mget_r_0
 60874                              <1> 	
 60875 00010907 3A2D[B1830100]      <1> 	cmp	ch, [readi.drv]
 60876 0001090D 7540                <1> 	jne	short mget_r_0
 60877                              <1> 
 60878 0001090F 3B05[C4830100]      <1> 	cmp	eax, [readi.fclust]
 60879 00010915 7562                <1> 	jne	short mget_r_3
 60880                              <1> 	
 60881 00010917 89D8                <1> 	mov	eax, ebx ; file offset
 60882 00010919 668B0D[B8830100]    <1> 	mov	cx, [readi.bpc]
 60883 00010920 41                  <1> 	inc	ecx ; <= 65536
 60884 00010921 29D2                <1> 	sub	edx, edx
 60885 00010923 F7F1                <1> 	div	ecx
 60886                              <1> 
 60887 00010925 8B3D[C0830100]      <1> 	mov	edi, [readi.c_index] ; cluster index
 60888                              <1> 
 60889 0001092B 39F8                <1> 	cmp	eax, edi
 60890 0001092D 7577                <1>         jne     short mget_r_4  ; (*)
 60891                              <1> 
 60892                              <1> 	; edx = byte offset in cluster (<= 65535)
 60893 0001092F 668915[BA830100]    <1> 	mov	[readi.offset], dx
 60894                              <1> 	; 23/07/2022
 60895                              <1> 	;shr	dx, 9 ; / 512
 60896 00010936 C1EA09              <1> 	shr	edx, 9
 60897 00010939 8815[B3830100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 60898                              <1> 	
 60899 0001093F A1[BC830100]        <1> 	mov	eax, [readi.cluster]  ; > 0 if [readi.valid] = 1
 60900 00010944 8B15[C8830100]      <1> 	mov	edx, [readi.fs_index]
 60901 0001094A E997000000          <1>         jmp     mget_r_7
 60902                              <1> 	
 60903                              <1> mget_r_0:
 60904 0001094F 882D[B1830100]      <1> 	mov	[readi.drv], ch ; physical drive number
 60905 00010955 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 60906 00010959 7707                <1> 	ja	short mget_r_1
 60907 0001095B 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 60908 0001095E D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 60909 00010960 EB03                <1> 	jmp	short mget_r_2	
 60910                              <1> mget_r_1:
 60911 00010962 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]
 60912                              <1> mget_r_2:
 60913 00010965 880D[B2830100]      <1> 	mov	[readi.spc], cl  ; sectors per cluster
 60914                              <1> 	; NOTE: readi bytes per sector value is always 512 !
 60915                              <1> 	; 23/07/2022
 60916                              <1> 	;xor	ch, ch
 60917                              <1> 	;shl	ecx, 9 
 60918 0001096B 66C1E109            <1> 	shl	cx, 9 ; * 512
 60919                              <1> 	;dec	cx ; bytes per cluster - 1
 60920                              <1> 	; 23/07/2022
 60921 0001096F 49                  <1> 	dec	ecx
 60922 00010970 66890D[B8830100]    <1> 	mov	[readi.bpc], cx
 60923                              <1> 	;sub	cx, cx
 60924                              <1> 	; 23/07/2022
 60925 00010977 29C9                <1> 	sub	ecx, ecx
 60926                              <1> mget_r_3:
 60927 00010979 A3[C4830100]        <1> 	mov	[readi.fclust], eax ; first cluster (or FDT address)
 60928 0001097E 880D[B0830100]      <1> 	mov	[readi.valid], cl ; 0 
 60929                              <1> 	;mov	[readi.s_index], cl ; 0
 60930                              <1> 	;mov	[readi.offset], cx ; 0
 60931 00010984 890D[C0830100]      <1> 	mov	[readi.c_index], ecx ; 0
 60932 0001098A 890D[BC830100]      <1> 	mov	[readi.cluster], ecx ; 0
 60933 00010990 890D[B4830100]      <1> 	mov	[readi.sector], ecx ; 0
 60934                              <1> 	
 60935 00010996 89D8                <1> 	mov	eax, ebx ; file offset
 60936 00010998 668B0D[B8830100]    <1> 	mov	cx, [readi.bpc]
 60937 0001099F 41                  <1> 	inc	ecx ; <= 65536
 60938 000109A0 29D2                <1> 	sub	edx, edx
 60939 000109A2 F7F1                <1> 	div	ecx
 60940                              <1> 	;mov	edi, [readi.c_index] ; previous cluster index
 60941 000109A4 29FF                <1> 	sub	edi, edi
 60942                              <1> mget_r_4:
 60943 000109A6 A3[C0830100]        <1> 	mov	[readi.c_index], eax ; cluster index
 60944                              <1> 	; edx = byte offset in cluster (<= 65535)
 60945 000109AB 668915[BA830100]    <1> 	mov	[readi.offset], dx
 60946                              <1> 	; 23/07/2022
 60947                              <1> 	;shr	dx, 9 ; / 512
 60948 000109B2 C1EA09              <1> 	shr	edx, 9
 60949 000109B5 8815[B3830100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 60950                              <1> 
 60951 000109BB 89C1                <1> 	mov	ecx, eax ; current cluster index
 60952 000109BD A1[C4830100]        <1> 	mov	eax, [readi.fclust]
 60953 000109C2 09C9                <1> 	or	ecx, ecx ; cluster index
 60954 000109C4 741B                <1> 	jz	short mget_r_6
 60955                              <1> 
 60956 000109C6 39CF                <1> 	cmp	edi, ecx
 60957 000109C8 7710                <1> 	ja	short mget_r_5 ; old cluster index is higher
 60958 000109CA 8B15[BC830100]      <1> 	mov	edx, [readi.cluster]
 60959 000109D0 21D2                <1> 	and	edx, edx
 60960 000109D2 7406                <1> 	jz	short mget_r_5
 60961                              <1> 	; valid 'readi' parameters (*)
 60962 000109D4 89D0                <1> 	mov	eax, edx
 60963 000109D6 29F9                <1> 	sub	ecx, edi
 60964 000109D8 740C                <1> 	jz	short mget_r_7
 60965                              <1> mget_r_5:
 60966                              <1> 	; EAX = Beginning cluster
 60967                              <1> 	; EDX = Sector index in disk/file section
 60968                              <1> 	;	(Only for SINGLIX file system!)
 60969                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 60970                              <1> 	; ESI = Logical DOS Drive Description Table address
 60971 000109DA E82BC1FFFF          <1> 	call	get_cluster_by_index
 60972 000109DF 724C                <1> 	jc	short mget_r_err
 60973                              <1> 	; EAX = Cluster number		
 60974                              <1> mget_r_6:
 60975 000109E1 A3[BC830100]        <1> 	mov	[readi.cluster], eax ; FDT number for Singlix File System
 60976                              <1> mget_r_7:
 60977 000109E6 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 60978 000109EA 765D                <1> 	jna	short mget_r_12
 60979                              <1> 
 60980                              <1> 	;sub	eax, 2
 60981                              <1> 	; 30/07/2022
 60982 000109EC 48                  <1> 	dec	eax
 60983 000109ED 48                  <1> 	dec	eax
 60984 000109EE 0FB615[B2830100]    <1> 	movzx	edx, byte [readi.spc]
 60985 000109F5 F7E2                <1> 	mul	edx
 60986                              <1> 
 60987 000109F7 034668              <1> 	add	eax, [esi+LD_DATABegin]
 60988 000109FA 8A15[B3830100]      <1> 	mov	dl, [readi.s_index]
 60989 00010A00 01D0                <1> 	add	eax, edx
 60990                              <1> mget_r_8:
 60991                              <1> 	; eax = logical sector number
 60992 00010A02 803D[B0830100]00    <1> 	cmp	byte [readi.valid], 0
 60993 00010A09 7608                <1> 	jna	short mget_r_9
 60994 00010A0B 3B05[B4830100]      <1> 	cmp	eax, [readi.sector]
 60995 00010A11 7435                <1> 	je	short mget_r_11 ; sector is already in 'readi' buffer
 60996                              <1> mget_r_9:
 60997 00010A13 A3[B4830100]        <1> 	mov	[readi.sector], eax
 60998 00010A18 BB[40030300]        <1> 	mov	ebx, readi_buffer ; buffer address
 60999                              <1> 	;mov	ecx, 1
 61000                              <1> 	; 30/07/2022
 61001 00010A1D 31C9                <1> 	xor	ecx, ecx
 61002 00010A1F FEC1                <1> 	inc	cl
 61003                              <1> 	; ecx = 1	
 61004                              <1> 
 61005                              <1> 	; 29/04/2016
 61006                              <1> 	;xor	dl, dl
 61007                              <1> 
 61008                              <1> 	; EAX = Logical sector number
 61009                              <1> 	; ECX = Sector count
 61010                              <1> 	; EBX = Buffer address
 61011                              <1> 	; (EDX = 0)
 61012                              <1> 	; ESI = Logical DOS drive description table address	
 61013                              <1> 
 61014 00010A21 E803130000          <1> 	call	disk_read
 61015 00010A26 7314                <1> 	jnc	short mget_r_10
 61016                              <1> 
 61017                              <1> 	; 22/10/2016 (15h -> 17)
 61018 00010A28 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 61019                              <1> mget_r_err:
 61020 00010A2D A3[84010300]        <1> 	mov	[u.error], eax
 61021                              <1> 	; 12/10/2016
 61022 00010A32 A3[1C010300]        <1> 	mov	[u.r0], eax
 61023 00010A37 E996C2FFFF          <1> 	jmp	error
 61024                              <1> mget_r_10:
 61025 00010A3C C605[B0830100]01    <1> 	mov	byte [readi.valid], 1 ; 24/10/2016
 61026 00010A43 A1[B4830100]        <1> 	mov	eax, [readi.sector]
 61027                              <1> mget_r_11:
 61028 00010A48 C3                  <1> 	retn
 61029                              <1> mget_r_12:
 61030                              <1> 	; EAX = FDT number
 61031                              <1> 	; EDX = Sector index from FDT sector (0,1,2,3,4...)
 61032 00010A49 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 61033 00010A4A 8915[C8830100]      <1> 	mov	[readi.fs_index], edx
 61034 00010A50 01D0                <1> 	add	eax, edx
 61035 00010A52 EBAE                <1> 	jmp	short mget_r_8
 61036                              <1> 
 61037                              <1> trans_addr_r:
 61038                              <1> 	; 12/10/2016
 61039                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 61040                              <1> 	; Translate virtual address to physical address 
 61041                              <1> 	; for reading from user's memory space
 61042                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 61043                              <1> 
 61044 00010A54 31D2                <1> 	xor	edx, edx ; 0 (read access sign)
 61045 00010A56 EB04                <1> 	jmp 	short trans_addr_rw
 61046                              <1> 
 61047                              <1> trans_addr_w:
 61048                              <1> 	; 12/10/2016
 61049                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61050                              <1> 	; Translate virtual address to physical address 
 61051                              <1> 	; for writing to user's memory space
 61052                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 61053                              <1> 	
 61054 00010A58 29D2                <1> 	sub	edx, edx
 61055 00010A5A FEC2                <1> 	inc	dl ; 1 (write access sign)
 61056                              <1> trans_addr_rw:
 61057 00010A5C 50                  <1> 	push	eax
 61058 00010A5D 53                  <1> 	push	ebx
 61059 00010A5E 52                  <1> 	push 	edx ; r/w sign (in DL)
 61060                              <1> 	;
 61061 00010A5F 8B1D[40010300]      <1> 	mov	ebx, [u.base]
 61062 00010A65 E81E50FFFF          <1> 	call	get_physical_addr ; get physical address
 61063 00010A6A 730F                <1> 	jnc	short passc_0
 61064 00010A6C A3[84010300]        <1> 	mov	[u.error], eax
 61065 00010A71 A3[1C010300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 61066                              <1> 	;pop	edx
 61067                              <1> 	;pop 	ebx
 61068                              <1> 	;pop	eax
 61069 00010A76 E957C2FFFF          <1> 	jmp	error
 61070                              <1> passc_0:
 61071 00010A7B F6C202              <1> 	test	dl, PTE_A_WRITE ; writable page
 61072 00010A7E 5A                  <1> 	pop	edx
 61073 00010A7F 751C                <1> 	jnz	short passc_1
 61074                              <1> 	
 61075 00010A81 20D2                <1> 	and 	dl, dl
 61076 00010A83 7418                <1> 	jz	short passc_1
 61077                              <1> 	; read only (duplicated) page -must be copied to a new page-
 61078                              <1> 	; EBX = linear address
 61079 00010A85 51                  <1> 	push 	ecx
 61080 00010A86 E86C4FFFFF          <1> 	call 	copy_page
 61081 00010A8B 59                  <1> 	pop	ecx
 61082 00010A8C 721E                <1> 	jc	short passc_2
 61083 00010A8E 50                  <1> 	push	eax ; physical address of the new/allocated page
 61084 00010A8F E8F44FFFFF          <1> 	call	add_to_swap_queue	
 61085 00010A94 58                  <1> 	pop	eax
 61086 00010A95 81E3FF0F0000        <1> 	and 	ebx, PAGE_OFF ; 0FFFh
 61087                              <1> 	;mov 	ecx, PAGE_SIZE
 61088                              <1> 	;sub	ecx, ebx 
 61089 00010A9B 01D8                <1> 	add	eax, ebx  
 61090                              <1> passc_1: 
 61091 00010A9D A3[7C010300]        <1> 	mov 	[u.pbase], eax ; physical address	
 61092 00010AA2 66890D[80010300]    <1> 	mov	[u.pcount], cx ; remain byte count in page (1-4096)
 61093 00010AA9 5B                  <1> 	pop	ebx
 61094 00010AAA 58                  <1> 	pop	eax
 61095 00010AAB C3                  <1> 	retn
 61096                              <1> passc_2:
 61097 00010AAC B804000000          <1> 	mov	eax, ERR_MINOR_IM ; "Insufficient memory !" error
 61098 00010AB1 A3[1C010300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 61099 00010AB6 A3[84010300]        <1> 	mov	[u.error], eax
 61100                              <1> 	;pop 	ebx
 61101                              <1> 	;pop	eax
 61102 00010ABB E912C2FFFF          <1> 	jmp	error
 61103                              <1> 
 61104                              <1> sioreg: 
 61105                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61106                              <1> 	; 19/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 61107                              <1> 	; 12/03/2013 - 22/07/2013 (Retro UNIX 8086 v1)
 61108                              <1> 	; INPUTS -> 
 61109                              <1> 	;     EBX = system buffer (data) address (r5)
 61110                              <1> 	;     [u.fofp] = pointer to file offset pointer
 61111                              <1> 	;     [u.base] = virtual address of the user buffer
 61112                              <1> 	;     [u.pbase] = physical address of the user buffer
 61113                              <1> 	;     [u.count] = byte count
 61114                              <1> 	;     [u.pcount] = byte count within page frame
 61115                              <1> 	; OUTPUTS -> 
 61116                              <1> 	;     ESI = user data offset (r1)
 61117                              <1> 	;     EDI = system (I/O) buffer offset (r2)
 61118                              <1> 	;     ECX = byte count (r3)
 61119                              <1> 	;     EAX = remain bytes after byte count within page frame
 61120                              <1> 	;	(If EAX > 0, transfer will continue from the next page)
 61121                              <1>         ;
 61122                              <1> 	; ((Modified registers:  EDX))
 61123                              <1>  
 61124 00010AC0 8B35[30010300]      <1>         mov     esi, [u.fofp]
 61125 00010AC6 8B3E                <1>         mov     edi, [esi]
 61126 00010AC8 89F9                <1> 	mov	ecx, edi
 61127 00010ACA 81C900FEFFFF        <1> 	or	ecx, 0FFFFFE00h
 61128 00010AD0 81E7FF010000        <1> 	and	edi, 1FFh
 61129 00010AD6 01DF                <1> 	add	edi, ebx ; EBX = system buffer (data) address
 61130 00010AD8 F7D9                <1> 	neg	ecx
 61131 00010ADA 3B0D[44010300]      <1> 	cmp	ecx, [u.count]
 61132 00010AE0 7606                <1> 	jna	short sioreg_0
 61133 00010AE2 8B0D[44010300]      <1> 	mov	ecx, [u.count]
 61134                              <1> sioreg_0:
 61135 00010AE8 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0 
 61136 00010AEF 7613                <1> 	jna	short sioreg_1
 61137                              <1> 	 ; the caller is 'mkdir' or 'namei'
 61138 00010AF1 A1[40010300]        <1> 	mov	eax, [u.base]
 61139 00010AF6 A3[7C010300]        <1> 	mov 	[u.pbase], eax ; physical address = virtual address
 61140 00010AFB 66890D[80010300]    <1> 	mov	word [u.pcount], cx ; remain bytes in buffer (1 sector)
 61141 00010B02 EB0B                <1> 	jmp	short sioreg_2
 61142                              <1> sioreg_1:
 61143 00010B04 0FB715[80010300]    <1> 	movzx	edx, word [u.pcount]
 61144 00010B0B 39D1                <1> 	cmp	ecx, edx	
 61145 00010B0D 772A                <1> 	ja	short sioreg_4 ; transfer count > [u.pcount]
 61146                              <1> sioreg_2: ; 2:
 61147 00010B0F 31C0                <1> 	xor 	eax, eax
 61148                              <1> sioreg_3:
 61149 00010B11 010D[48010300]      <1> 	add 	[u.nread], ecx
 61150 00010B17 290D[44010300]      <1> 	sub 	[u.count], ecx
 61151 00010B1D 010D[40010300]      <1> 	add 	[u.base], ecx
 61152 00010B23 010E                <1>         add 	[esi], ecx 
 61153 00010B25 8B35[7C010300]      <1> 	mov	esi, [u.pbase]
 61154 00010B2B 66290D[80010300]    <1> 	sub	[u.pcount], cx
 61155 00010B32 010D[7C010300]      <1> 	add	[u.pbase], ecx
 61156 00010B38 C3                  <1>         retn
 61157                              <1> sioreg_4:
 61158                              <1> 	; transfer count > [u.pcount] 
 61159                              <1> 	; (ecx > edx)
 61160 00010B39 89C8                <1> 	mov	eax, ecx
 61161 00010B3B 29D0                <1> 	sub	eax, edx ; remain bytes for 1 sector (block) transfer 
 61162 00010B3D 89D1                <1> 	mov	ecx, edx ; current transfer count = [u.pcount]
 61163 00010B3F EBD0                <1> 	jmp	short sioreg_3
 61164                              <1> 
 61165                              <1> tswitch: ; Retro UNIX 386 v1
 61166                              <1> tswap:
 61167                              <1> 	; 16/01/2017
 61168                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0)
 61169                              <1> 	; 10/05/2015 - 01/09/2015 (Retro UNIX 386 v1)
 61170                              <1> 	; 14/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 61171                              <1> 	; time out swap, called when a user times out.
 61172                              <1> 	; the user is put on the low priority queue.
 61173                              <1> 	; This is done by making a link from the last user
 61174                              <1> 	; on the low priority queue to him via a call to 'putlu'.
 61175                              <1> 	; then he is swapped out.
 61176                              <1> 
 61177                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 21/05/2016 **
 61178                              <1> 	;     * when a high priority (event) process will be stopped
 61179                              <1> 	;	(swapped out, swithched out/off), 'tswap/tswitch' will
 61180                              <1> 	;	not add it to a run queue. 
 61181                              <1> 	;	/// What for: Process may be already in a run queue, 
 61182                              <1> 	;	it is unspeficied state because process might be started
 61183                              <1> 	;	by a timer event which does not regard previous priority
 61184                              <1> 	;	level and run queue of the process (for fast executing!).
 61185                              <1> 	;	After the 'run for event', process will be sequenced
 61186                              <1> 	;	to run by it's actual run queue. ///
 61187                              <1> 	;
 61188                              <1> 	; Retro UNIX 386 v1 modification ->
 61189                              <1> 	;       swap (software task switch) is performed by changing
 61190                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 61191                              <1> 	;	as in Retro UNIX 8086 v1.
 61192                              <1> 	;
 61193                              <1> 	; RETRO UNIX 8086 v1 modification ->
 61194                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 61195                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 61196                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 61197                              <1> 	;	compatibles was using 1MB segmented memory
 61198                              <1> 	;	in 8086/8088 times.
 61199                              <1> 	;
 61200                              <1> 	; INPUTS ->
 61201                              <1> 	;    u.uno - users process number
 61202                              <1> 	;    runq+4 - lowest priority queue
 61203                              <1> 	; OUTPUTS ->
 61204                              <1> 	;    r0 - users process number
 61205                              <1> 	;    r2 - lowest priority queue address
 61206                              <1> 	;
 61207                              <1> 	; ((AX = R0, BX = R2)) output
 61208                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI))
 61209                              <1> 	;
 61210                              <1> 
 61211                              <1> 	NOTE:
 61212                              <1> 	;* [u.pri] priority level is specified by run queue which is process 
 61213                              <1> 	;  comes to run from.
 61214                              <1> 	;* Initial [u.pri] is 1 ('normal/regular') for programs 
 61215                              <1> 	;  (which are launched by MainProg or 'sysexec'), it is changed
 61216                              <1> 	;  to 2 ('high') by timer event, if program uses 'systimer' system call.
 61217                              <1> 	;* Program (Process) also can change it's running priority 
 61218                              <1> 	;  from 1 to 0 or up to 2 by using 'syspri' system call; but,
 61219                              <1> 	;  if program selects priority level 2 (high) for running, next time 
 61220                              <1> 	;  it is reduced to 1 (normal/regular) because 'syspri' adds this
 61221                              <1> 	;  program to 'run for normal' queue while running duration is a bit
 61222                              <1> 	;  protected from swap/switch out immediate, behalf of other high 
 61223                              <1> 	;  priority process in sequence. Program (with high priority) will not 
 61224                              <1> 	;  be swapped/switched out (by timer event) before it's time quantum 
 61225                              <1> 	;  will be elapsed, but, this will be temporary if program is not using 
 61226                              <1> 	;  timer event function.
 61227                              <1> 
 61228                              <1> 	;For example:
 61229                              <1> 	;If a process frequently gets a timer event, it runs at high priority
 61230                              <1> 	;level but when it returns from running it returns to actual run queue,
 61231                              <1> 	;not to 'run for event' queue again.
 61232                              <1> 	;'tswap' will not change the sequence at return/stop(swap out) stage.
 61233                              <1> 	;But if priority level not high (=2, 'run for event'), 'tswap/tswitch'
 61234                              <1> 	;will add the stopping process to relevant run queue according to
 61235                              <1> 	;[u.pri] priority level.
 61236                              <1> 
 61237                              <1> 	; 16/01/2017
 61238 00010B41 BB[0C010300]        <1> 	mov	ebx, runq+2 	; 'runq_normal' ; normal/regular priority
 61239                              <1> 	; 21/05/2016
 61240                              <1> 	;cmp	byte [u.pri], 2	; high priority (run for event) ?
 61241                              <1> 	;jnb	short swap
 61242                              <1> 	; 16/01/2017
 61243                              <1> 	; (Normal and also high/event priority processes will be added to
 61244                              <1> 	; normal priority run queue for ensuring circular running sequence!)
 61245                              <1> 	; (Timer interrupt or 'syspri' system call may change priority and run
 61246                              <1> 	; queue to high/event level.)
 61247 00010B46 803D[66010300]00    <1> 	cmp	byte [u.pri], 0
 61248 00010B4D 7702                <1> 	ja	short tswap_1	; normal priority run queue
 61249                              <1> 	;
 61250 00010B4F 43                  <1> 	inc	ebx
 61251 00010B50 43                  <1> 	inc	ebx		; runq+4, 'runq_background', low priority
 61252                              <1> tswap_1:
 61253 00010B51 A0[6D010300]        <1> 	mov 	al, [u.uno]
 61254                              <1> 	       	; movb u.uno,r1 / move users process number to r1
 61255                              <1> 		; mov  $runq+4,r2 
 61256                              <1> 			; / move lowest priority queue address to r2
 61257                              <1>       	; ebx = run queue
 61258 00010B56 E8FE000000          <1> 	call 	putlu
 61259                              <1> 		; jsr r0,putlu / create link from last user on Q to 
 61260                              <1> 		             ; / u.uno's user
 61261                              <1> 
 61262                              <1> switch: ; Retro UNIX 386 v1
 61263                              <1> swap:
 61264                              <1> 	; 02/01/2017
 61265                              <1> 	; 21/05/2016
 61266                              <1> 	; 20/05/2016
 61267                              <1> 	; 02/05/2016
 61268                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61269                              <1> 	; 10/05/2015 - 02/09/2015 (Retro UNIX 386 v1)
 61270                              <1> 	; 14/04/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 61271                              <1> 	;
 61272                              <1> 	; 'swap' is routine that controls the swapping of processes
 61273                              <1> 	; in and out of core.
 61274                              <1> 	;
 61275                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 20/05/2016 **
 61276                              <1> 	;     * 3 different priority level is applied 
 61277                              <1> 	;	(just as original unix v1)
 61278                              <1> 	;	1) high priority (event) run queue, 'runq_event'
 61279                              <1> 	;	2) normal priority (regular) run queue, 'runq_normal'
 61280                              <1> 	;	3) low priority (background) run queue, 'runq_backgroud'
 61281                              <1> 	;	'swap' code will run a process which has max. priority
 61282                              <1>         ;       (for earliest event at first)
 61283                              <1> 	;
 61284                              <1> 	; Retro UNIX 386 v1 modification ->
 61285                              <1> 	;       swap (software task switch) is performed by changing
 61286                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 61287                              <1> 	;	as in Retro UNIX 8086 v1.
 61288                              <1> 	;
 61289                              <1> 	; RETRO UNIX 8086 v1 modification ->
 61290                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 61291                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 61292                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 61293                              <1> 	;	compatibles was using 1MB segmented memory
 61294                              <1> 	;	in 8086/8088 times.
 61295                              <1> 	;
 61296                              <1> 	; INPUTS ->
 61297                              <1> 	;    runq table - contains processes to run.
 61298                              <1> 	;    p.link - contains next process in line to be run.
 61299                              <1> 	;    u.uno - process number of process in core	
 61300                              <1> 	;    s.stack - swap stack used as an internal stack for swapping.
 61301                              <1> 	; OUTPUTS ->
 61302                              <1> 	;    (original unix v1 -> present process to its disk block)
 61303                              <1> 	;    (original unix v1 -> new process into core -> 
 61304                              <1> 	;	   Retro Unix 8086 v1 -> segment registers changed 
 61305                              <1> 	;	   for new process)
 61306                              <1> 	;    u.quant = 3 (Time quantum for a process)
 61307                              <1> 	; 	((INT 1Ch count down speed -> 18.2 times per second)
 61308                              <1> 	;    RETRO UNIX 8086 v1 will use INT 1Ch (18.2 times per second)
 61309                              <1> 	;	 for now, it will swap the process if there is not
 61310                              <1> 	;	 a keyboard event (keystroke) (Int 15h, function 4Fh)
 61311                              <1> 	;	 or will count down from 3 to 0 even if there is a
 61312                              <1> 	;        keyboard event locking due to repetitive key strokes.
 61313                              <1> 	;	 u.quant will be reset to 3 for RETRO UNIX 8086 v1.
 61314                              <1> 	;
 61315                              <1> 	; ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI))
 61316                              <1> 
 61317                              <1> 	;NOTE:
 61318                              <1> 	;High priority queue is the first for selecting a process to run.
 61319                              <1> 	;If there is not a process in high priority level run queue,
 61320                              <1> 	;a process in normal priority run queue will be selected
 61321                              <1> 	;or a proces in low priority run queue will be selected if normal
 61322                              <1> 	;priority level run queue is empty.
 61323                              <1> 	
 61324                              <1> 	; 21/05/2016 -(3 priority levels, 3 run queues)
 61325 00010B5B BE[0A010300]        <1> 	mov	esi, runq ; 'runq_event' ; high priority, 'run for event'
 61326 00010B60 C605[0C840100]03    <1> 	mov	byte [priority], 3 ; high priority + 1
 61327 00010B67 31DB                <1> 	xor	ebx, ebx ; 02/01/2017
 61328                              <1> swap_0: ; 1: / search runq table for highest priority process
 61329 00010B69 66AD                <1> 	lodsw  ; mov ax, [esi], add esi+2
 61330                              <1> 	;xor	ebx, ebx ; 02/05/2016
 61331 00010B6B 6621C0              <1> 	and 	ax, ax ; are there any processes to run in this Q entry
 61332 00010B6E 750E                <1> 	jnz	short swap_2 
 61333                              <1> 	; 21/05/2026
 61334                              <1> 	; runq_normal = runq+2, runq_background = runq+4
 61335 00010B70 FE0D[0C840100]      <1> 	dec	byte [priority] ; 3 -> 3, 2 -> 1, 1-> 0
 61336 00010B76 75F1                <1> 	jnz	short swap_0	
 61337                              <1> 	;cmp	esi, runq+6  ; if zero compare address to end of table
 61338                              <1> 	;jb	short swap_0 ; if not at end, go back
 61339                              <1> swap_1:
 61340                              <1> 	; 02/05/2016
 61341                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 61342                              <1> 	; No user process to run...
 61343                              <1> 	; Run the kernel process... MainProg: Internal Command Interpreter
 61344 00010B78 FEC0                <1> 	inc	al ; mov al, 1  ; process number of MainProg
 61345 00010B7A FEC3                <1> 	inc	bl ; mov bl, al ; 1
 61346 00010B7C EB1E                <1> 	jmp	short swap_4
 61347                              <1> swap_2:
 61348                              <1> 	; 21/05/2016
 61349 00010B7E FE0D[0C840100]      <1> 	dec	byte [priority] ; priority level of present user/process
 61350                              <1> 			        ; 0, 1, 2
 61351 00010B84 4E                  <1> 	dec	esi
 61352 00010B85 4E                  <1>         dec     esi
 61353                              <1> 	;
 61354 00010B86 88C3                <1> 	mov	bl, al
 61355 00010B88 38E0                <1> 	cmp	al, ah ; is there only 1 process in the queue to be run
 61356 00010B8A 740A                <1> 	je	short swap_3 ; yes
 61357 00010B8C 8AA3[4F000300]      <1> 	mov	ah, [ebx+p.link-1] 
 61358 00010B92 8826                <1>        	mov	[esi], ah ; move next process in line into run queue
 61359 00010B94 EB06                <1> 	jmp	short swap_4
 61360                              <1> swap_3: 
 61361 00010B96 6631D2              <1> 	xor	dx, dx
 61362 00010B99 668916              <1> 	mov	[esi], dx ; zero the entry; no processes on the Q
 61363                              <1> swap_4: 
 61364 00010B9C 8A25[6D010300]      <1> 	mov 	ah, [u.uno]
 61365 00010BA2 38C4                <1> 	cmp	ah, al ; is this process the same as the process in core?
 61366 00010BA4 743B                <1>        	je	short swap_8 ; yes, don't have to swap
 61367 00010BA6 08E4                <1> 	or	ah, ah  ; is the process # = 0
 61368 00010BA8 740D                <1>        	jz	short swap_6 ; 'sysexit'
 61369                              <1> 	;cmp	ah, al ;is this process the same as the process in core?
 61370                              <1>        	;je	short swap_8 ; yes, don't have to swap
 61371 00010BAA 8925[18010300]      <1> 	mov	[u.usp], esp ; return  address for 'syswait' & 'sleep'
 61372 00010BB0 E834000000          <1> 	call	wswap   ; write out core to disk
 61373 00010BB5 EB1C                <1> 	jmp 	short swap_7
 61374                              <1> swap_6:
 61375                              <1> 	; Deallocate memory pages belong to the process
 61376                              <1> 	; which is being terminated.
 61377                              <1> 	; (Retro UNIX 386 v1 modification !)
 61378                              <1> 	;
 61379 00010BB7 53                  <1> 	push	ebx
 61380 00010BB8 A1[74010300]        <1> 	mov 	eax, [u.pgdir]  ; page directory of the process
 61381 00010BBD 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 61382 00010BC3 E8034CFFFF          <1> 	call	deallocate_page_dir
 61383 00010BC8 A1[70010300]        <1> 	mov	eax, [u.upage] ; 'user' structure page of the process
 61384 00010BCD E8914CFFFF          <1> 	call	deallocate_page
 61385 00010BD2 5B                  <1> 	pop	ebx
 61386                              <1> swap_7: 
 61387 00010BD3 C0E302              <1> 	shl	bl, 2 ; * 4 
 61388 00010BD6 8B83[6C000300]      <1> 	mov	eax, [ebx+p.upage-4] ; the 'u' page of the new process
 61389 00010BDC E840000000          <1> 	call	rswap ; read new process into core
 61390                              <1> swap_8: 
 61391                              <1> 	; Retro UNIX  8086 v1 modification !
 61392 00010BE1 C605[64010300]04    <1> 	mov	byte [u.quant], time_count 
 61393 00010BE8 C3                  <1> 	retn
 61394                              <1> 
 61395                              <1> wswap:  ; < swap out, swap to disk >
 61396                              <1> 	; 28/02/2017 (fnsave)
 61397                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61398                              <1> 	; 09/05/2015 (Retro UNIX 386 v1)
 61399                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 61400                              <1> 	; 'wswap' writes out the process that is in core onto its
 61401                              <1> 	; appropriate disk area.
 61402                              <1> 	;
 61403                              <1> 	; Retro UNIX 386 v1 modification ->
 61404                              <1> 	;       User (u) structure content and the user's register content
 61405                              <1> 	;	will be copied to the process's/user's UPAGE (a page for
 61406                              <1> 	;	saving 'u' structure and user registers for task switching).
 61407                              <1> 	;	u.usp - points to kernel stack address which contains
 61408                              <1> 	;		user's registers while entering system call.
 61409                              <1> 	;	u.sp  - points to kernel stack address 
 61410                              <1> 	;		to return from system call -for IRET-.
 61411                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 61412                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 61413                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 61414                              <1> 	;
 61415                              <1> 	; Retro UNIX 8086 v1 modification ->
 61416                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 61417                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 61418                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 61419                              <1> 	;	compatibles was using 1MB segmented memory 
 61420                              <1> 	;	in 8086/8088 times.
 61421                              <1> 	;
 61422                              <1> 	; INPUTS ->
 61423                              <1> 	;    u.break - points to end of program
 61424                              <1> 	;    u.usp - stack pointer at the moment of swap
 61425                              <1> 	;    core - beginning of process program
 61426                              <1> 	;    ecore - end of core 	
 61427                              <1> 	;    user - start of user parameter area
 61428                              <1> 	;    u.uno - user process number
 61429                              <1> 	;    p.dska - holds block number of process
 61430                              <1> 	; OUTPUTS ->
 61431                              <1> 	;    swp I/O queue
 61432                              <1> 	;    p.break - negative word count of process 
 61433                              <1> 	;    r1 - process disk address	
 61434                              <1> 	;    r2 - negative word count
 61435                              <1> 	;
 61436                              <1> 	; RETRO UNIX 8086 v1 input/output:
 61437                              <1> 	;
 61438                              <1> 	; INPUTS ->
 61439                              <1> 	;    u.uno - process number (to be swapped out)
 61440                              <1> 	; OUTPUTS ->
 61441                              <1> 	;    none
 61442                              <1> 	;
 61443                              <1> 	;   ((Modified registers: ECX, ESI, EDI))  
 61444                              <1> 	;
 61445                              <1> 
 61446                              <1> 	; 28/02/2017
 61447                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 61448                              <1> 	;jna	short wswp
 61449 00010BE9 803D[97010300]00    <1> 	cmp	byte [u.fpsave], 0 ; 28/02/2017
 61450 00010BF0 7606                <1> 	jna	short wswp
 61451 00010BF2 DD35[98010300]      <1> 	fnsave	[u.fpregs] ; save floating point registers (94 bytes)
 61452                              <1> wswp:
 61453 00010BF8 8B3D[70010300]      <1> 	mov	edi, [u.upage] ; process's user (u) structure page addr
 61454 00010BFE B93C000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 61455 00010C03 BE[14010300]        <1> 	mov	esi, user ; active user (u) structure
 61456 00010C08 F3A5                <1> 	rep	movsd
 61457                              <1> 	;
 61458 00010C0A 8B35[18010300]      <1> 	mov	esi, [u.usp] ; esp (system stack pointer, 
 61459                              <1> 			     ;      points to user registers)
 61460 00010C10 8B0D[14010300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 61461                              <1> 			     ; (for IRET)
 61462                              <1> 			     ; [u.sp] -> EIP (user)
 61463                              <1> 			     ; [u.sp+4]-> CS (user)
 61464                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 61465                              <1> 			     ; [u.sp+12] -> ESP (user)
 61466                              <1> 			     ; [u.sp+16] -> SS (user)
 61467 00010C16 29F1                <1> 	sub	ecx, esi     ; required space for user registers
 61468 00010C18 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 61469                              <1> 			     ; (for IRET)
 61470 00010C1B C1E902              <1> 	shr	ecx, 2
 61471 00010C1E F3A5                <1> 	rep	movsd
 61472 00010C20 C3                  <1> 	retn
 61473                              <1> 
 61474                              <1> rswap:  ; < swap in, swap from disk >
 61475                              <1> 	; 28/02/2017 (frstor)
 61476                              <1> 	; 15/01/2017
 61477                              <1> 	; 14/01/2017
 61478                              <1> 	; 21/05/2016
 61479                              <1> 	; 03/05/2016
 61480                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61481                              <1> 	; 09/05/2015 - 15/09/2015 (Retro UNIX 386 v1)
 61482                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 61483                              <1> 	; 'rswap' reads a process whose number is in r1,
 61484                              <1> 	; from disk into core.
 61485                              <1> 	;
 61486                              <1> 	; Retro UNIX 386 v1 modification ->
 61487                              <1> 	;       User (u) structure content and the user's register content
 61488                              <1> 	;	will be restored from process's/user's UPAGE (a page for
 61489                              <1> 	;	saving 'u' structure and user registers for task switching).
 61490                              <1> 	;	u.usp - points to kernel stack address which contains
 61491                              <1> 	;		user's registers while entering system call.
 61492                              <1> 	;	u.sp  - points to kernel stack address 
 61493                              <1> 	;		to return from system call -for IRET-.
 61494                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 61495                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 61496                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 61497                              <1> 	;
 61498                              <1> 	; RETRO UNIX 8086 v1 modification ->
 61499                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 61500                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 61501                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 61502                              <1> 	;	compatibles was using 1MB segmented memory 
 61503                              <1> 	;	in 8086/8088 times.
 61504                              <1> 	;
 61505                              <1> 	; INPUTS ->
 61506                              <1> 	;    r1 - process number of process to be read in
 61507                              <1> 	;    p.break - negative of word count of process 
 61508                              <1> 	;    p.dska - disk address of the process
 61509                              <1> 	;    u.emt - determines handling of emt's
 61510                              <1> 	;    u.ilgins - determines handling of illegal instructions
 61511                              <1> 	; OUTPUTS ->
 61512                              <1> 	;    8 = (u.ilgins)
 61513                              <1> 	;    24 = (u.emt)
 61514                              <1> 	;    swp - bit 10 is set to indicate read 
 61515                              <1> 	;		(bit 15=0 when reading is done)	
 61516                              <1> 	;    swp+2 - disk block address
 61517                              <1> 	;    swp+4 - negative word count 	
 61518                              <1> 	;      ((swp+6 - address of user structure)) 
 61519                              <1> 	;
 61520                              <1> 	; RETRO UNIX 8086 v1 input/output:
 61521                              <1> 	;
 61522                              <1> 	; INPUTS ->
 61523                              <1> 	;    AL	- new process number (to be swapped in)	 
 61524                              <1> 	; OUTPUTS ->
 61525                              <1> 	;    none
 61526                              <1> 	;
 61527                              <1> 	;   ((Modified registers: EAX, ECX, ESI, EDI, ESP))
 61528                              <1> 	;
 61529                              <1> 	; Retro UNIX 386 v1 - modification ! 14/05/2015
 61530 00010C21 89C6                <1> 	mov	esi, eax  ; process's user (u) structure page addr
 61531 00010C23 B93C000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 61532 00010C28 BF[14010300]        <1> 	mov	edi, user ; active user (u) structure	
 61533 00010C2D F3A5                <1> 	rep	movsd
 61534 00010C2F 58                  <1> 	pop	eax	; 'rswap' return address
 61535                              <1> 	; 
 61536                              <1> 	;cli
 61537 00010C30 8B3D[18010300]      <1> 	mov	edi, [u.usp] ; esp (system stack pointer,
 61538                              <1> 			     ;     points to user registers)
 61539 00010C36 89FC                <1> 	mov	esp, edi     ; 14/01/2017
 61540 00010C38 8B0D[14010300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 61541                              <1> 			     ; (for IRET)
 61542                              <1> 			     ; [u.sp] -> EIP (user)
 61543                              <1> 			     ; [u.sp+4]-> CS (user)
 61544                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 61545                              <1> 			     ; [u.sp+12] -> ESP (user)
 61546                              <1> 			     ; [u.sp+16] -> SS (user)
 61547 00010C3E 29F9                <1> 	sub	ecx, edi     ; required space for user registers
 61548 00010C40 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 61549                              <1> 			     ; (for IRET)
 61550 00010C43 C1E902              <1> 	shr	ecx, 2
 61551 00010C46 F3A5                <1> 	rep	movsd
 61552                              <1> 	;mov	esp, [u.usp] ; 15/09/2015
 61553                              <1> 	;sti
 61554                              <1> 	; 28/02/2017
 61555                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 61556                              <1> 	;jna	short rswp_retn
 61557 00010C48 803D[97010300]00    <1> 	cmp	byte [u.fpsave], 0
 61558 00010C4F 7606                <1> 	jna	short rswp_retn
 61559 00010C51 DD25[98010300]      <1> 	frstor	[u.fpregs] ; restore floating point regs (94 bytes)
 61560                              <1> rswp_retn:
 61561 00010C57 50                  <1> 	push	eax	; 'rswap' return address
 61562 00010C58 C3                  <1> 	retn
 61563                              <1> 
 61564                              <1> putlu: 
 61565                              <1> 	; 20/05/2016
 61566                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61567                              <1> 	; 10/05/2015 - 12/09/2015 (Retro UNIX 386 v1)
 61568                              <1> 	; 15/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
 61569                              <1> 	; 'putlu' is called with a process number in r1 and a pointer
 61570                              <1> 	; to lowest priority Q (runq+4) in r2. A link is created from
 61571                              <1> 	; the last process on the queue to process in r1 by putting
 61572                              <1> 	; the process number in r1 into the last process's link.
 61573                              <1> 	;
 61574                              <1> 	; INPUTS ->
 61575                              <1> 	;    r1 - user process number
 61576                              <1> 	;    r2 - points to lowest priority queue
 61577                              <1> 	;    p.dska - disk address of the process	
 61578                              <1> 	;    u.emt - determines handling of emt's
 61579                              <1> 	;    u.ilgins - determines handling of illegal instructions
 61580                              <1> 	; OUTPUTS ->
 61581                              <1> 	;    r3 - process number of last process on the queue upon
 61582                              <1> 	;	  entering putlu
 61583                              <1> 	;    p.link-1 + r3 - process number in r1
 61584                              <1> 	;    r2 - points to lowest priority queue
 61585                              <1> 	;
 61586                              <1> 	; ((Modified registers: EDX, EBX)) 
 61587                              <1> 	;
 61588                              <1> 	; / r1 = user process no.; r2 points to lowest priority queue
 61589                              <1> 
 61590                              <1> 	; EBX = r2
 61591                              <1> 	; EAX = r1 (AL=r1b)
 61592                              <1> 
 61593                              <1> 	; 20/05/2016
 61594                              <1> 	; AL = process number (1 to 16) // Retro UNIX 8086, 386 v1 //
 61595                              <1> 	;     (max. 16 processes available for current kernel version)
 61596                              <1> 	; EBX = run queue address ; 20/05/2016 (TRDOS 386)
 61597                              <1> 		; which is one of following addresses:
 61598                              <1> 		;  1) 'runq_event' high priority run queue
 61599                              <1> 		;  2) 'runq_normal' normal/regular priority run queue
 61600                              <1> 		;  3) 'runq_background' low priority run queue
 61601                              <1> 
 61602                              <1> 	;mov	ebx, runq
 61603 00010C59 0FB613              <1> 	movzx  	edx, byte [ebx]
 61604 00010C5C 43                  <1> 	inc	ebx
 61605 00010C5D 20D2                <1> 	and	dl, dl
 61606                              <1> 		; tstb (r2)+ / is queue empty?
 61607 00010C5F 740A                <1>        	jz	short putlu_1
 61608                              <1> 		; beq 1f / yes, branch
 61609 00010C61 8A13                <1> 	mov 	dl, [ebx] ; 12/09/2015
 61610                              <1> 		; movb (r2),r3 / no, save the "last user" process number
 61611                              <1> 			     ; / in r3
 61612 00010C63 8882[4F000300]      <1>        	mov	[edx+p.link-1], al
 61613                              <1> 		; movb r1,p.link-1(r3) / put pointer to user on 
 61614                              <1> 			     ; / "last users" link
 61615 00010C69 EB03                <1> 	jmp	short putlu_2
 61616                              <1> 		; br 2f /
 61617                              <1> putlu_1: ; 1:
 61618 00010C6B 8843FF              <1> 	mov	[ebx-1], al
 61619                              <1>        		; movb r1,-1(r2) / user is only user; 
 61620                              <1> 			    ; / put process no. at beginning and at end
 61621                              <1> putlu_2: ; 2: 
 61622 00010C6E 8803                <1> 	mov	[ebx], al
 61623                              <1>        		; movb r1,(r2) / user process in r1 is now the last entry
 61624                              <1> 			     ; / on the queue
 61625 00010C70 88C2                <1> 	mov	dl, al
 61626 00010C72 88B2[4F000300]      <1>         mov     [edx+p.link-1], dh ; 0
 61627                              <1> 		; dec r2 / restore r2
 61628 00010C78 C3                  <1>         retn
 61629                              <1> 		; rts r0
 61630                              <1> 
 61631                              <1> sysver:
 61632                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 61633 00010C79 C705[1C010300]0002- <1> 	mov	dword [u.r0], 200h ; AH = major version, AL = minor version 
 61634 00010C81 0000                <1>
 61635 00010C83 E96AC0FFFF          <1> 	jmp	sysret
 61636                              <1> 
 61637                              <1> syspri: ; change running priority (of the process)
 61638                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 61639                              <1> 	; 21/05/2016
 61640                              <1> 	; 20/05/2026 - TRDOS 386 (TRDOS v2.0)
 61641                              <1> 	; INPUT ->
 61642                              <1> 	;	BL = priority level
 61643                              <1> 	;	   0 = low running priority (running on background)
 61644                              <1> 	;	   1 = normal/regular priority (running as regular)
 61645                              <1> 	;	   2 = high/event priority (running for event)
 61646                              <1> 	;	   >2 = invalid, it will accepted as 2 (event)
 61647                              <1> 	;	   0FFh = get/return current running priority only
 61648                              <1> 	; OUTPUT -> 	
 61649                              <1> 	;	* if current [u.pri] < 2
 61650                              <1> 	;	  if BL input < 0FFh ->
 61651                              <1> 	;	     [u.pri] is updated as in BL input (0,1,2)
 61652                              <1> 	;	  if BL input = 0FFh -> AL = [u.pri] (current)
 61653                              <1> 	;	      
 61654                              <1> 	;	* if current [u.pri] = 2
 61655                              <1> 	;	  if BL input < 0FFh -> cf = 1 & AL = 2
 61656                              <1> 	;	  if BL input = 0FFh -> cf = 0 & AL = 2
 61657                              <1> 	;	
 61658                              <1> 	;	NOTE: 	
 61659                              <1> 	;	If [u.pri] = 2, it can not be changed to 1 or 0;
 61660                              <1> 	;	because, run queue of the running process is unspecified
 61661                              <1> 	;	at this	stage. Process might be started by a timer event
 61662                              <1> 	;	or priority might be changed to high by previous
 61663                              <1> 	;	'syspri' system	call. In both cases, the process is in
 61664                              <1> 	;	'runq_normal' or 'runq_background' queue.
 61665                              <1> 	;	As result of this fact, when the [u.quant] time quantum
 61666                              <1> 	;	of the process is elapsed or 'sysrele' system call is
 61667                              <1> 	;	instructed by the process, 'tswap' ('tswitch') procedure
 61668                              <1> 	;	will be called (to 'swap' or 'switch' out the procedure)
 61669                              <1> 	;	and it will not call 'putlu' to add the (stopping)
 61670                              <1> 	;	process to relevant run queue when [u.pri] = 2.
 61671                              <1> 	;	(Otherwise, it would be possible to add process to
 61672                              <1> 	;	a run queue while it is already in a run queue, wrongly.)
 61673                              <1>   	;
 61674                              <1> 	;	If [u.pri]< 2, 'tswap/tswitch' procedure will call
 61675                              <1> 	;	'putlu' to add process to relevant run queue
 61676                              <1> 	;	according to [u.pri] value. ('runq_normal' for 1,
 61677                              <1> 	;	'runq_background' for 0).
 61678                              <1> 	;
 61679                              <1> 	;	If BL input >= 2 and < 0FFh while [u.pri] < 2,
 61680                              <1> 	;	process will be added to 'runq_normal' queue and
 61681                              <1> 	;	[u.pri] will be set to 2. (in 'syspri' system call)
 61682                              <1> 	;
 61683                              <1> 
 61684 00010C88 29C0                <1> 	sub	eax, eax ; 0
 61685 00010C8A A3[84010300]        <1> 	mov	[u.error], eax
 61686                              <1> 
 61687 00010C8F A0[66010300]        <1> 	mov	al, [u.pri]
 61688 00010C94 A3[1C010300]        <1> 	mov	[u.r0], eax
 61689                              <1> 
 61690 00010C99 FEC3                <1> 	inc	bl
 61691                              <1> 	;jz	sysret ; 0FFh -> 0, get priority level
 61692                              <1> 	; 23/07/2022	
 61693 00010C9B 742C                <1> 	jz	short syspri_2	; jmp sysret
 61694                              <1> 
 61695 00010C9D 3C02                <1> 	cmp	al, 2
 61696                              <1> 	;jnb	error ; CF = 1 & AL = 2 (& last error = 0)
 61697                              <1> 	; 23/07/2022
 61698 00010C9F 7205                <1> 	jb	short syspri_0
 61699 00010CA1 E92CC0FFFF          <1> 	jmp	error
 61700                              <1> syspri_0:
 61701 00010CA6 FECB                <1> 	dec	bl
 61702 00010CA8 80FB02              <1> 	cmp	bl, 2
 61703 00010CAB 7602                <1> 	jna	short syspri_1
 61704 00010CAD B302                <1> 	mov	bl, 2
 61705                              <1> syspri_1:
 61706 00010CAF 881D[66010300]      <1> 	mov	[u.pri], bl
 61707 00010CB5 80FB02              <1> 	cmp	bl, 2
 61708                              <1> 	;jb	sysret
 61709                              <1> 	; 23/07/2022
 61710 00010CB8 720F                <1> 	jb	short syspri_2	; jmp sysret
 61711                              <1> 
 61712                              <1> 	; here...
 61713                              <1> 	; Priority of current process has been changed to high
 61714                              <1> 	; ('run for event') but current process will be added to
 61715                              <1> 	; 'run as normal' queue. ('run for event' high priority
 61716                              <1> 	; queue is under control of timer -& RTC- interrupt only!) 
 61717                              <1> 	;
 61718                              <1> 	; (Otherwise, process can fall into black hole!
 61719                              <1> 	; e.g. if it is not in waiting list and it has not got 
 61720                              <1> 	; a timer event and it is not in a run queue!
 61721                              <1> 	; Because, when [u.pri] is 2, 'tswap/tswitch' will not 
 61722                              <1> 	; add the stopping process to a run queue.)
 61723                              <1> 
 61724 00010CBA A0[6D010300]        <1> 	mov	al, [u.uno]
 61725 00010CBF BB[0C010300]        <1> 	mov	ebx, runq_normal ; normal priority !
 61726                              <1> 				 ; [u.pri] is set to high
 61727                              <1> 				 ; but 'runq_event' queue is set
 61728                              <1> 				 ; only by the kernel's timer
 61729                              <1> 				 ; event function (timer interrupt). 
 61730 00010CC4 E890FFFFFF          <1> 	call	putlu
 61731                              <1> syspri_2:
 61732 00010CC9 E924C0FFFF          <1> 	jmp	sysret
 61733                              <1> 
 61734                              <1> cpass: ; / get next character from user area of core and put it in AL (r1)
 61735                              <1> 	; 30/07/2022 - TRDOS 386 Kernel v2.0.5
 61736                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 61737                              <1> 	; 19/05/2015 - 18/10/2015 (Retro UNIX 386 v1)
 61738                              <1> 	; 14/08/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 61739                              <1> 	; INPUTS -> 
 61740                              <1> 	;     [u.base] = virtual address in user area
 61741                              <1> 	;     [u.count] = byte count (max.)
 61742                              <1> 	;     [u.pcount] = byte count in page (0 = reset)
 61743                              <1> 	; OUTPUTS -> 
 61744                              <1> 	;     AL = the character which is pointed by [u.base]
 61745                              <1> 	;     zf = 1 -> transfer count has been completed
 61746                              <1>         ;
 61747                              <1> 	; ((Modified registers: EAX, EDX, ECX))
 61748                              <1> 	
 61749                              <1> 	; 30/07/2022
 61750 00010CCE 29C0                <1> 	sub	eax, eax
 61751                              <1> 	
 61752 00010CD0 3905[44010300]      <1> 	cmp	[u.count], eax ; 0
 61753                              <1> 	;cmp 	dword [u.count], 0  ; have all the characters been transferred
 61754                              <1> 			    	    ; i.e., u.count, # of chars. left
 61755 00010CD6 763D                <1> 	jna	short cpass_3	    ; to be transferred = 0?) yes, branch
 61756 00010CD8 FF0D[44010300]      <1> 	dec	dword [u.count]	    ; no, decrement u.count
 61757                              <1>         ; 19/05/2015 
 61758                              <1> 	;(Retro UNIX 386 v1 - translation from user's virtual address
 61759                              <1> 	;		      to physical address
 61760                              <1> 	; 30/07/2022
 61761 00010CDE 663905[80010300]    <1> 	cmp	[u.pcount], ax ; 0
 61762                              <1> 	;cmp	word [u.pcount], 0 ; byte count in page = 0 (initial value)
 61763                              <1> 			     ; 1-4095 --> use previous physical base address
 61764                              <1> 			     ; in [u.pbase]
 61765 00010CE5 770D                <1> 	ja	short cpass_1
 61766                              <1> 	; 30/07/2022
 61767 00010CE7 3905[78010300]      <1> 	cmp	[u.ppgdir], eax ; 0
 61768                              <1> 	;cmp	dword [u.ppgdir], 0 ; is the caller os kernel
 61769 00010CED 7427                <1>         je      short cpass_k       ; (sysexec, '/etc/init') ?  (MainProg)
 61770 00010CEF E860FDFFFF          <1> 	call	trans_addr_r
 61771                              <1> cpass_1:
 61772 00010CF4 66FF0D[80010300]    <1> 	dec	word [u.pcount]
 61773                              <1> cpass_2: 
 61774 00010CFB 8B15[7C010300]      <1> 	mov	edx, [u.pbase]
 61775 00010D01 8A02                <1> 	mov	al, [edx]	; take the character pointed to 
 61776                              <1> 				; by u.base and put it in r1
 61777 00010D03 FF05[48010300]      <1> 	inc	dword [u.nread] ; increment no. of bytes transferred
 61778 00010D09 FF05[40010300]      <1> 	inc	dword [u.base]  ; increment the buffer address to point to the
 61779                              <1> 			        ; next byte
 61780 00010D0F FF05[7C010300]      <1> 	inc	dword [u.pbase]
 61781                              <1> cpass_3:
 61782 00010D15 C3                  <1> 	retn
 61783                              <1> cpass_k:
 61784                              <1> 	; 02/07/2015
 61785                              <1> 	; The caller is os kernel 
 61786                              <1> 	; (get sysexec arguments from kernel's memory space)
 61787 00010D16 8B1D[40010300]      <1> 	mov	ebx, [u.base]
 61788 00010D1C 66C705[80010300]00- <1>         mov     word [u.pcount], PAGE_SIZE ; 4096
 61789 00010D24 10                  <1>
 61790 00010D25 891D[7C010300]      <1> 	mov	[u.pbase], ebx
 61791 00010D2B EBCE                <1> 	jmp	short cpass_2
 61792                              <1> 
 61793                              <1> transfer_to_user_buffer: ; fast transfer
 61794                              <1> 	; 27/05/2016
 61795                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 61796                              <1> 	;
 61797                              <1> 	; INPUT ->
 61798                              <1> 	;	ESI = source address in system space
 61799                              <1> 	;	EDI = user's buffer address
 61800                              <1> 	;	ECX = transfer (byte) count
 61801                              <1> 	;	[u.pgdir] = user's page directory
 61802                              <1> 	; OUTPUT ->
 61803                              <1> 	;	ECX = actual transfer count
 61804                              <1> 	;	cf = 1 -> error
 61805                              <1> 	;	[u.count] = remain byte count
 61806                              <1> 	;
 61807                              <1> 	; Modified registers: eax, ecx
 61808                              <1> 	;
 61809                              <1> 
 61810 00010D2D 21C9                <1> 	and	ecx, ecx
 61811 00010D2F 743B                <1> 	jz	short ttub_4
 61812                              <1> 
 61813 00010D31 890D[44010300]      <1> 	mov	[u.count], ecx
 61814                              <1> 	
 61815 00010D37 57                  <1> 	push	edi
 61816 00010D38 56                  <1> 	push	esi
 61817 00010D39 53                  <1> 	push	ebx
 61818 00010D3A 52                  <1> 	push	edx
 61819 00010D3B 51                  <1> 	push	ecx
 61820                              <1> 
 61821 00010D3C 89FB                <1> 	mov	ebx, edi
 61822 00010D3E 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 61823                              <1> ttub_1:
 61824                              <1> 	; ebx = virtual (linear) address
 61825                              <1> 	; [u.pgdir] = user's page directory
 61826 00010D44 E8454DFFFF          <1>        	call	get_physical_addr_x ; get physical address
 61827 00010D49 7222                <1> 	jc	short ttub_5
 61828                              <1> 	; eax = physical address 
 61829                              <1> 	; ecx = remain byte count in page (1-4096)
 61830 00010D4B 89C7                <1> 	mov	edi, eax
 61831 00010D4D A1[44010300]        <1> 	mov	eax, [u.count]
 61832 00010D52 39C1                <1> 	cmp	ecx, eax
 61833 00010D54 7602                <1> 	jna	short ttub_2
 61834 00010D56 89C1                <1> 	mov	ecx, eax
 61835                              <1> ttub_2:	
 61836 00010D58 29C8                <1> 	sub	eax, ecx
 61837 00010D5A 01CB                <1> 	add	ebx, ecx
 61838 00010D5C F3A4                <1> 	rep	movsb
 61839 00010D5E A3[44010300]        <1> 	mov	[u.count], eax
 61840 00010D63 09C0                <1> 	or	eax, eax
 61841 00010D65 75DD                <1> 	jnz	short ttub_1
 61842                              <1> ttub_retn:
 61843                              <1> tfub_retn:
 61844 00010D67 59                  <1> 	pop	ecx ; transfer count = actual transfer count
 61845                              <1> ttub_3:
 61846 00010D68 5A                  <1> 	pop	edx
 61847 00010D69 5B                  <1> 	pop	ebx
 61848 00010D6A 5E                  <1> 	pop	esi
 61849 00010D6B 5F                  <1> 	pop	edi
 61850                              <1> ttub_4:
 61851 00010D6C C3                  <1> 	retn
 61852                              <1> ttub_5:
 61853 00010D6D 59                  <1> 	pop	ecx
 61854 00010D6E 2B0D[44010300]      <1> 	sub	ecx, [u.count] ; actual transfer count
 61855 00010D74 F9                  <1> 	stc
 61856 00010D75 EBF1                <1> 	jmp	short ttub_3
 61857                              <1> 
 61858                              <1> transfer_from_user_buffer: ; fast transfer
 61859                              <1> 	; 27/05/2016
 61860                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 61861                              <1> 	;
 61862                              <1> 	; INPUT ->
 61863                              <1> 	;	ESI = user's buffer address
 61864                              <1> 	;	EDI = destination address in system space
 61865                              <1> 	;	ECX = transfer (byte) count
 61866                              <1> 	;	[u.pgdir] = user's page directory
 61867                              <1> 	; OUTPUT ->
 61868                              <1> 	;	ecx = actual transfer count
 61869                              <1> 	;	cf = 1 -> error
 61870                              <1> 	;	[u.count] = remain byte count
 61871                              <1> 	;
 61872                              <1> 	; Modified registers: eax, ecx
 61873                              <1> 	;
 61874                              <1> 
 61875 00010D77 21C9                <1> 	and	ecx, ecx
 61876                              <1> 	;jz	short tfub_4
 61877 00010D79 74F1                <1> 	jz	short ttub_4
 61878                              <1> 
 61879 00010D7B 890D[44010300]      <1> 	mov	[u.count], ecx
 61880                              <1> 	
 61881 00010D81 57                  <1> 	push	edi
 61882 00010D82 56                  <1> 	push	esi
 61883 00010D83 53                  <1> 	push	ebx
 61884 00010D84 52                  <1> 	push	edx
 61885 00010D85 51                  <1> 	push	ecx
 61886                              <1> 
 61887 00010D86 89F3                <1> 	mov	ebx, esi
 61888 00010D88 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 61889                              <1> tfub_1:
 61890                              <1> 	; ebx = virtual (linear) address
 61891                              <1> 	; [u.pgdir] = user's page directory
 61892 00010D8E E8FB4CFFFF          <1>        	call	get_physical_addr_x ; get physical address
 61893                              <1> 	;jc	short tfub_5
 61894 00010D93 72D8                <1> 	jc	short ttub_5
 61895                              <1> 	; eax = physical address 
 61896                              <1> 	; ecx = remain byte count in page (1-4096)
 61897 00010D95 89C6                <1> 	mov	esi, eax
 61898 00010D97 A1[44010300]        <1> 	mov	eax, [u.count]
 61899 00010D9C 39C1                <1> 	cmp	ecx, eax
 61900 00010D9E 7602                <1> 	jna	short tfub_2
 61901 00010DA0 89C1                <1> 	mov	ecx, eax
 61902                              <1> tfub_2:	
 61903 00010DA2 29C8                <1> 	sub	eax, ecx
 61904 00010DA4 01CB                <1> 	add	ebx, ecx
 61905 00010DA6 F3A4                <1> 	rep	movsb
 61906 00010DA8 A3[44010300]        <1> 	mov	[u.count], eax
 61907 00010DAD 09C0                <1> 	or	eax, eax
 61908 00010DAF 75DD                <1> 	jnz	short tfub_1
 61909                              <1> 
 61910 00010DB1 EBB4                <1> 	jmp	short tfub_retn
 61911                              <1> 
 61912                              <1> ;tfub_retn:
 61913                              <1> ;	pop	ecx ; transfer count = actual transfer count
 61914                              <1> ;tfub_3:
 61915                              <1> ;	pop	edx
 61916                              <1> ;	pop	ebx
 61917                              <1> ;	pop	esi
 61918                              <1> ;	pop	edi
 61919                              <1> ;tfub_4:
 61920                              <1> ;	retn
 61921                              <1> ;tfub_5:
 61922                              <1> ;	pop	ecx
 61923                              <1> ;	sub	ecx, [u.count] ; actual transfer count
 61924                              <1> ;	stc
 61925                              <1> ;	jmp	short tfub_3
 61926                              <1> 
 61927                              <1> sysfff: ; <Find First File>
 61928                              <1> 	; 08/08/2022
 61929                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 61930                              <1> 	; 17/10/2016
 61931                              <1> 	; 16/10/2016
 61932                              <1> 	; 15/10/2016 TRDOS 386 (TRDOS v2.0) feature only !
 61933                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 61934                              <1> 	;            ("loc_INT21h_find_first_file")
 61935                              <1> 	; TRDOS 8086 (v1.0)
 61936                              <1>         ; 	07/08/2011 
 61937                              <1>         ;	Find First File
 61938                              <1> 	;	INPUT:
 61939                              <1>         ;	    CX= Attributes
 61940                              <1>         ;	    DS:DX= Pointer to filename
 61941                              <1> 	;	MSDOS OUTPUT:
 61942                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 61943                              <1> 	;	    Offset  Descrription
 61944                              <1> 	;	    0	    Reserved for use find next file
 61945                              <1> 	;	    21	    Attribute of file found
 61946                              <1> 	;	    22	    Time stamp of file
 61947                              <1> 	;	    24	    Date stamp of file
 61948                              <1> 	;	    26	    File size in bytes
 61949                              <1> 	;	    30	    Filename and extension (zero terminated)
 61950                              <1> 	;	If cf = 1:
 61951                              <1> 	;	    Error Codes: (in AX)
 61952                              <1> 	;	    	2 - File not found
 61953                              <1> 	;	       18 - No more files
 61954                              <1>         ;
 61955                              <1> 	; TRDOS 386 (v2.0) 
 61956                              <1> 	; 15/10/2016
 61957                              <1> 	;	
 61958                              <1>         ; INPUT ->
 61959                              <1>         ;	   CL = File attributes
 61960                              <1> 	;     	      bit 0 (1) - Read only file (R)
 61961                              <1> 	;             bit 1 (1) - Hidden file (H)
 61962                              <1>         ;             bit 2 (1) - System file (R)
 61963                              <1> 	;             bit 3 (1) - Volume label/name (V)
 61964                              <1>         ;             bit 4 (1) - Subdirectory (D)
 61965                              <1> 	;	      bit 5 (1) - File has been archived (A)
 61966                              <1> 	;	   CH = 0 -> Return basic parameters (24 bytes)
 61967                              <1> 	;	   CH > 0 -> Return FindFile structure/table (128 bytes)
 61968                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
 61969                              <1> 	;	   EDX = File parameters buffer address
 61970                              <1> 	;		(buffer size = 24 bytes if CH input = 0)
 61971                              <1> 	;		(buffer size = 128 bytes if CH input > 0)
 61972                              <1> 	;		 
 61973                              <1> 	; OUTPUT ->
 61974                              <1> 	;	   EAX = 0 if CH input > 0
 61975                              <1> 	;	   EAX = First cluster number of file if CH input = 0
 61976                              <1> 	;	   EDX = File parameters table/structure address
 61977                              <1> 	;	   Basic Parameters:
 61978                              <1> 	;		Offset  Description
 61979                              <1> 	;		------	---------------
 61980                              <1> 	;		0	File Attributes
 61981                              <1> 	;		1	Ambiguous filename chars are used sign
 61982                              <1> 	;			(0 = filename fits exactly with request)
 61983                              <1> 	;			(>0 = ambiguous filename chars are used)
 61984                              <1> 	;	      	2	Time stamp of file
 61985                              <1> 	;		4	Date stamp of file
 61986                              <1> 	;		6	File size in bytes
 61987                              <1> 	;		10	Short Filename (ASCIIZ, max. 13 bytes)
 61988                              <1> 	;		23	Longname Length (1-255) if existing 
 61989                              <1> 	;  
 61990                              <1> 	;          cf = 1 -> Error code in AL
 61991                              <1> 	;
 61992                              <1> 	; Modified Registers: EAX (at the return of system call)
 61993                              <1> 	;  
 61994                              <1> 	; TR-DOS FindFile (FFF) Structure (128 bytes):
 61995                              <1> 	; 09/10/2011 (DIR.ASM) - 10/02/2016 (trdoskx.s)
 61996                              <1> 	;	
 61997                              <1> 	; Offset	Parameter		Size
 61998                              <1> 	; ------	------------------	-------- 
 61999                              <1> 	; 0		FindFile_Drv		1 byte
 62000                              <1> 	; 1		FindFile_Directory	65 bytes
 62001                              <1> 	; 66		FindFile_Name		13 bytes
 62002                              <1> 	; 79		FindFile_LongNameEntryLength 1 byte
 62003                              <1> 	;Above 80 bytes form
 62004                              <1> 	;TR-DOS Source/Destination File FullName Format/Structure
 62005                              <1> 	; 80		FindFile_AttributesMask 1 word
 62006                              <1> 	; 82		FindFile_DirEntry	32 bytes (*)
 62007                              <1> 	; 114		FindFile_DirFirstCluster 1 double word
 62008                              <1> 	; 118		FindFile_DirCluster	1 double word
 62009                              <1> 	; 122		FindFile_DirEntryNumber 1 word
 62010                              <1> 	; 124		FindFile_MatchCounter	1 word
 62011                              <1> 	; 126		FindFile_Reserved	1 word
 62012                              <1>    	; (*) MS-DOS, FAT 12-16-32 classic directory entry (32 bytes)
 62013                              <1> 
 62014                              <1> 	;mov	[u.namep], ebx
 62015                              <1> 	; 16/10/2016
 62016 00010DB3 8915[2C840100]      <1> 	mov	[FFF_UBuffer], edx
 62017 00010DB9 66890D[31840100]    <1> 	mov	[FFF_Attrib], cx ; [FFF_RType] = ch
 62018                              <1> 		    ; Attributes in CL, return data type in CH
 62019 00010DC0 89DE                <1> 	mov	esi, ebx
 62020                              <1> 	; file name is forced, change directory as temporary
 62021                              <1> 	;mov	ax, 1
 62022                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 62023                              <1> 	;call	set_working_path 
 62024 00010DC2 E878130000          <1> 	call	set_working_path_x ; 17/10/2016	
 62025 00010DC7 731D                <1> 	jnc	short sysfff_0
 62026                              <1>  
 62027 00010DC9 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 62028 00010DCB 7505                <1> 	jnz	short sysfff_err
 62029                              <1> 
 62030                              <1> 	; eax = 0
 62031 00010DCD B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 62032                              <1> sysfff_err:
 62033 00010DD2 A3[1C010300]        <1> 	mov	[u.r0], eax
 62034 00010DD7 A3[84010300]        <1> 	mov	[u.error], eax
 62035 00010DDC E833140000          <1>         call 	reset_working_path
 62036 00010DE1 E9ECBEFFFF          <1> 	jmp	error
 62037                              <1> 
 62038                              <1> sysfff_0:
 62039                              <1> 	;sub	ah, ah ; ah = 0
 62040 00010DE6 8A0424              <1> 	mov	al, [esp]
 62041 00010DE9 08C0                <1> 	or	al, al
 62042 00010DEB 7412                <1> 	jz	short sysfff_2
 62043 00010DED B410                <1> 	mov	ah, 10h
 62044 00010DEF A808                <1> 	test	al, 08h
 62045 00010DF1 7503                <1> 	jnz	short sysfff_1
 62046 00010DF3 80CC08              <1> 	or	ah, 08h
 62047                              <1> sysfff_1:
 62048 00010DF6 2410                <1> 	and	al, 10h ; Directory
 62049 00010DF8 7405                <1> 	jz	short sysfff_2
 62050 00010DFA 80E408              <1> 	and	ah, 08h
 62051 00010DFD 30C0                <1> 	xor	al, al ; When a directory is searched,
 62052                              <1> 		       ; filename will be returned even if
 62053                              <1> 		       ; it is not a directory!
 62054                              <1> 		       ; Because: (in order to prevent
 62055                              <1> 		       ; creating a dir with existing file name)
 62056                              <1> 		       ; Dir and file names must not be same!
 62057                              <1> 		       ; (return attribute must be checked)	
 62058                              <1> sysfff_2:
 62059                              <1> 	; AX = Attributes mask 
 62060                              <1> 		; AL = AND mask (result must be equal to AL)
 62061                              <1> 		; AH = Negative AND mask (result must be ZERO)
 62062                              <1>  	; ESI = FindFile_Name address
 62063                              <1> 
 62064 00010DFF E80D7CFFFF          <1> 	call	find_first_file
 62065 00010E04 72CC                <1> 	jc	short sysfff_err ; eax = 2 (File not found !)
 62066                              <1> 
 62067                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 62068                              <1> 	; EDI = Directory Buffer Directory Entry Location
 62069                              <1> 	; EAX = File Size
 62070                              <1> 	;  BL = Attributes of The File/Directory
 62071                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 62072                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 62073                              <1> 
 62074                              <1> sysfff_3:
 62075                              <1> 	; 16/10/2016
 62076 00010E06 668B0D[31840100]    <1> 	mov	cx, [FFF_Attrib]
 62077                              <1> 	; Attribs in CL, return data type in CH
 62078                              <1> 
 62079                              <1> 	;or	cl, cl
 62080                              <1> 	;jz	short sysfff_4 ; 0 = No filter
 62081 00010E0D 80F1FF              <1> 	xor	cl, 0FFh
 62082 00010E10 20D9                <1> 	and	cl, bl
 62083 00010E12 7409                <1> 	jz	short sysfff_4
 62084                              <1> 
 62085                              <1> 	;mov	eax, 2 ; 'file not found !' error
 62086                              <1> 	;jmp	short sysfff_err_1
 62087                              <1> 
 62088                              <1> 	; 16/10/2016
 62089 00010E14 E8A57CFFFF          <1> 	call	find_next_file
 62090 00010E19 72B7                <1> 	jc	short sysfff_err ; eax = 12 (no more files !)
 62091 00010E1B EBE9                <1> 	jmp	short sysfff_3
 62092                              <1> 
 62093                              <1> sysfff_4:
 62094 00010E1D 20ED                <1> 	and	ch, ch ; [FFF_RType]
 62095 00010E1F 740C                <1> 	jz	short sysfff_5
 62096                              <1> 	;mov	ecx, 128 ; ; transfer length
 62097                              <1> 	; 30/07/2022
 62098 00010E21 29C9                <1> 	sub	ecx, ecx
 62099 00010E23 B180                <1> 	mov	cl, 128
 62100 00010E25 880D[30840100]      <1> 	mov	[FFF_Valid], cl
 62101                              <1> sysfnf_11:
 62102                              <1> 	; ecx = 128
 62103                              <1> 	; 08/08/2022
 62104                              <1> 	;mov	esi, FindFile_Drv
 62105 00010E2B EB3F                <1> 	jmp	short sysfff_6	
 62106                              <1> sysfff_5:
 62107                              <1> 	;;mov	esi, FindFile_DirEntry
 62108                              <1> 	;mov	ecx, 24  ; transfer length
 62109                              <1> 	; 30/07/2022
 62110                              <1> 	;sub	ecx, ecx
 62111                              <1> 	;mov	cl, 24
 62112                              <1> 	;mov	[FFF_Valid], cl
 62113 00010E2D C605[30840100]18    <1> 	mov	byte [FFF_Valid], 24
 62114                              <1> sysfnf_12:
 62115 00010E34 BF[FC880100]        <1> 	mov	edi, DTA ; FFF data transfer address
 62116                              <1> 	;mov	al, [esi+DirEntry_Attr] ; 11
 62117 00010E39 88D8                <1> 	mov	al, bl ; File/Dir Attributes
 62118 00010E3B 887F17              <1> 	mov	[edi+23], bh ; Longname length (0= none)
 62119 00010E3E AA                  <1> 	stosb
 62120 00010E3F 88D0                <1> 	mov	al, dl ; DL is for '?'
 62121 00010E41 00F0                <1> 	add	al, dh ; DH is for '*'
 62122                              <1> 	; AL > 0 if ambiguous file name wildcards are used
 62123 00010E43 AA                  <1> 	stosb
 62124 00010E44 8B4616              <1> 	mov	eax, [esi+DirEntry_WrtTime] ; 22
 62125 00010E47 AB                  <1>         stosd	; DirEntry_WrtTime & DirEntry_WrtDate
 62126 00010E48 8B461C              <1>         mov	eax, [esi+DirEntry_FileSize] ; 28
 62127 00010E4B AB                  <1>         stosd
 62128 00010E4C 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
 62129                              <1> 	;shl	ax, 16
 62130                              <1> 	; 23/07/2022 (BugFix)
 62131 00010E50 C1E010              <1> 	shl	eax, 16 
 62132 00010E53 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
 62133 00010E57 A3[1C010300]        <1> 	mov	[u.r0], eax ; First Cluster
 62134                              <1> 
 62135                              <1>         ;mov	esi, FindFile_DirEntry
 62136 00010E5C E8F0130000          <1> 	call	get_file_name
 62137                              <1> 
 62138 00010E61 8A0D[30840100]      <1> 	mov	cl, [FFF_Valid]
 62139 00010E67 BE[FC880100]        <1>        	mov	esi, DTA ; FFF data transfer address
 62140                              <1> sysfff_6:
 62141 00010E6C 8B3D[2C840100]      <1> 	mov	edi, [FFF_UBuffer] ; user's buffer address (edx)
 62142 00010E72 E8B6FEFFFF          <1> 	call	transfer_to_user_buffer
 62143                              <1> 
 62144 00010E77 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 62145 00010E7D E892130000          <1>         call 	reset_working_path
 62146 00010E82 E96BBEFFFF          <1> 	jmp	sysret
 62147                              <1> 
 62148                              <1> sysfnf: ; <Find Next File>
 62149                              <1> 	; 08/08/2022
 62150                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 62151                              <1> 	; 16/10/2016 TRDOS 386 (TRDOS v2.0) feature only !
 62152                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 62153                              <1> 	;            ("loc_INT21h_find_next_file")
 62154                              <1> 	; TRDOS 8086 (v1.0)
 62155                              <1>         ; 	07/08/2011 
 62156                              <1>         ;	Find First File
 62157                              <1> 	;	INPUT:
 62158                              <1>         ;	    none
 62159                              <1> 	;	MSDOS OUTPUT:
 62160                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 62161                              <1> 	;	    Offset  Descrription
 62162                              <1> 	;	    0	    Reserved for use find next file
 62163                              <1> 	;	    21	    Attribute of file found
 62164                              <1> 	;	    22	    Time stamp of file
 62165                              <1> 	;	    24	    Date stamp of file
 62166                              <1> 	;	    26	    File size in bytes
 62167                              <1> 	;	    30	    Filename and extension (zero terminated)
 62168                              <1> 	;	If cf = 1:
 62169                              <1> 	;	    Error Codes: (in AX)
 62170                              <1> 	;	       18 - No more files
 62171                              <1>         ;
 62172                              <1> 	; TRDOS 386 (v2.0) 
 62173                              <1> 	; 16/10/2016
 62174                              <1> 	;	
 62175                              <1>         ; INPUT ->
 62176                              <1>        	; 	   none
 62177                              <1> 	; OUTPUT ->
 62178                              <1> 	;	   EAX = 0 if CH input of 'Find First File' > 0
 62179                              <1> 	;	   EAX = First cluster number of file
 62180                              <1> 	;		 if CH input of 'Find First File' = 0	
 62181                              <1> 	;	   EDX = File parameters table/structure address
 62182                              <1> 	;
 62183                              <1> 	;          cf = 1 -> Error code in AL
 62184                              <1> 	;
 62185                              <1>  	; Modified Registers: EAX (at the return of system call)
 62186                              <1> 
 62187                              <1> 	;	
 62188                              <1> 	; Note: If byte [FFF_Valid] = 0
 62189                              <1> 	;	'sysfnf' will return with 'no more files' error.
 62190                              <1> 	;	If byte [FFF_Valid] = 24
 62191                              <1> 	;	'sysfnf' will return with 32 bytes basic parameters
 62192                              <1> 	;	at the address which is in EDX.
 62193                              <1> 	;	If byte [FFF_Valid] = 128
 62194                              <1> 	;	'sysfnf' will return with 128 bytes Find File 
 62195                              <1> 	;	Structure/Table at the address which is in EDX.
 62196                              <1> 	
 62197 00010E87 803D[30840100]00    <1> 	cmp	byte [FFF_Valid], 0
 62198 00010E8E 7713                <1> 	ja	short stsfnf_0
 62199                              <1>  	; 'no more files !' error 
 62200                              <1> 	;mov	eax, ERR_NO_MORE_FILES ; 12
 62201                              <1> 	; 30/07/2022
 62202 00010E90 29C0                <1> 	sub	eax, eax
 62203 00010E92 B00C                <1> 	mov	al, ERR_NO_MORE_FILES ; 12
 62204 00010E94 A3[1C010300]        <1> 	mov	[u.r0], eax
 62205 00010E99 A3[84010300]        <1> 	mov	[u.error], eax
 62206 00010E9E E92FBEFFFF          <1> 	jmp	error
 62207                              <1> stsfnf_0:
 62208                              <1> 	;cmp	byte [FFF_Valid], 128
 62209                              <1> 	;je	short stsfnf_1
 62210                              <1> 	;cmp	byte [FFF_Valid], 24
 62211                              <1> 	;je	short stsfnf_1
 62212                              <1> 	;mov	[FFF_Valid], 24 ; Default
 62213                              <1> stsfnf_1:
 62214 00010EA3 0FB61D[42780100]    <1> 	movzx	ebx, byte [Current_Drv]
 62215 00010EAA 66891D[36840100]    <1> 	mov	[SWP_DRV], bx
 62216 00010EB1 8A15[E2800100]      <1> 	mov	dl, [FindFile_Drv]
 62217 00010EB7 38DA                <1> 	cmp	dl, bl
 62218 00010EB9 7535                <1> 	jne	short stsfnf_2
 62219 00010EBB 86FB                <1> 	xchg	bh, bl
 62220 00010EBD BE00010900          <1> 	mov	esi, Logical_DOSDisks
 62221 00010EC2 01DE                <1> 	add	esi, ebx
 62222 00010EC4 EB37                <1> 	jmp	short sysfnf_3
 62223                              <1> 
 62224                              <1> sysfnf_8:
 62225 00010EC6 E87BB4FFFF          <1> 	call	load_FAT_sub_directory	 
 62226 00010ECB 7275                <1> 	jc	short sysfnf_err_1 ; read error (no FNF stop)
 62227                              <1> 
 62228                              <1> sysfnf_9:
 62229 00010ECD E8EC7BFFFF          <1> 	call	find_next_file
 62230 00010ED2 7263                <1> 	jc	short sysfnf_5
 62231                              <1> 	; 08/08/2022
 62232                              <1> 	; esi = FindFile_Drv
 62233                              <1> 
 62234 00010ED4 A0[31840100]        <1> 	mov	al, [FFF_Attrib]
 62235                              <1> 	;or	al, al
 62236                              <1> 	;jz	short sysfnf_10 ; 0 = No filter
 62237 00010ED9 34FF                <1> 	xor	al, 0FFh
 62238 00010EDB 20D8                <1> 	and	al, bl
 62239 00010EDD 75EE                <1> 	jnz	short sysfnf_9 ; search for next file until
 62240                              <1> 			       ; an error return from
 62241                              <1> 			       ; find_next_file procedure
 62242                              <1> sysfnf_10:
 62243                              <1>         ;movzx	ecx, byte [FFF_Valid]
 62244                              <1> 	;cmp	cl, 128 ; complete FindFile structure/table 
 62245                              <1> 	;je	sysfnf_11
 62246                              <1> 	;;cmp	cl, 24  ; basic parameters
 62247                              <1> 	;;je	sysfnf_12       
 62248                              <1> 	;jmp	sysfnf_12
 62249                              <1> 	; 30/07/2022
 62250 00010EDF 0FB60D[30840100]    <1> 	movzx	ecx, byte [FFF_Valid]
 62251 00010EE6 80F980              <1> 	cmp	cl, 128
 62252                              <1> 	;jne	short sysfnf_12
 62253                              <1> 	;jmp	short sysfnf_11	
 62254                              <1> 	; 08/08/2022
 62255 00010EE9 746B                <1> 	je	short sysfnf_6 ; esi = FindFile_Drv
 62256 00010EEB E944FFFFFF          <1> 	jmp	sysfnf_12
 62257                              <1> 
 62258                              <1> stsfnf_2:
 62259 00010EF0 FE05[37840100]      <1> 	inc	byte [SWP_DRV_chg]
 62260                              <1> 
 62261 00010EF6 E86868FFFF          <1> 	call	change_current_drive
 62262 00010EFB 7245                <1> 	jc	short sysfnf_err_1 ; read error ! 
 62263                              <1> 				   ; (do not stop, because
 62264                              <1> 				   ; we don't have a
 62265                              <1> 				   ; 'no more files'
 62266                              <1> 				   ; -file not found- error,
 62267                              <1> 				   ; next sysfnf system call
 62268                              <1> 				   ; may solve the problem,
 62269                              <1> 				   ; after re-placing the disk)
 62270                              <1> sysfnf_3:
 62271 00010EFD A1[58810100]        <1> 	mov	eax, [FindFile_DirCluster]
 62272 00010F02 21C0                <1> 	and	eax, eax
 62273 00010F04 7550                <1> 	jnz	short sysfnf_6
 62274                              <1>         
 62275 00010F06 803D[41780100]02    <1> 	cmp	byte [Current_FATType], 2
 62276 00010F0D 772C                <1> 	ja	short sysfnf_err_0 ; invalid, we neeed to stop !?
 62277 00010F0F 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 62278 00010F16 7223                <1> 	jb	short sysfnf_err_0 ; invalid, we neeed to stop !?
 62279                              <1> 
 62280 00010F18 3805[697F0100]      <1> 	cmp	byte [DirBuff_ValidData], al ; 0
 62281 00010F1E 7608                <1> 	jna	short sysfnf_4 
 62282                              <1> 
 62283 00010F20 3B05[6E7F0100]      <1> 	cmp	eax, [DirBuff_Cluster] ; 0 ?
 62284 00010F26 74A5                <1> 	je	short sysfnf_9
 62285                              <1> 
 62286                              <1> 	;cmp	byte [Current_Dir_Level], 0
 62287                              <1>         ;ja	short sysfnf_4  
 62288                              <1>         ;jna	short sysfnf_9 
 62289                              <1> 
 62290                              <1> sysfnf_4:
 62291 00010F28 FE05[37840100]      <1> 	inc	byte [SWP_DRV_chg]
 62292 00010F2E E895B3FFFF          <1> 	call 	load_FAT_root_directory
 62293 00010F33 7398                <1> 	jnc	short sysfnf_9
 62294                              <1> 	; eax = error code (17, 'drv not ready or read error')
 62295 00010F35 EB0B                <1> 	jmp	short sysfnf_err_1 ; read error ! (no FNF stop)
 62296                              <1> 				   ; (if you want, try again, 
 62297                              <1> 				   ;  after re-placing the disk)
 62298                              <1> sysfnf_5:	
 62299 00010F37 3C0C                <1> 	cmp	al, 12 ; 'no more files' error
 62300 00010F39 7507                <1> 	jne	short sysfnf_err_1 ; (no FNF stop -sysfnf will try
 62301                              <1> 				   ;  to read the directory again,
 62302                              <1> 				   ;  if the user calls sysfnf
 62303                              <1> 				   ;  just after this error return-)
 62304                              <1> 	; (FNF stop -sysfnf will not try
 62305                              <1> 	;  to read the directory again-)	
 62306                              <1> 
 62307                              <1> sysfnf_err_0:
 62308 00010F3B C605[30840100]00    <1> 	mov	byte [FFF_Valid], 0 ; FNF stop sign
 62309                              <1> sysfnf_err_1:
 62310 00010F42 A3[1C010300]        <1> 	mov	[u.r0], eax
 62311 00010F47 A3[84010300]        <1> 	mov	[u.error], eax
 62312 00010F4C E8C3120000          <1> 	call	reset_working_path
 62313 00010F51 E97CBDFFFF          <1> 	jmp	error
 62314                              <1> 	  
 62315                              <1> sysfnf_6:
 62316 00010F56 803D[697F0100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
 62317 00010F5D 760D                <1> 	jna	short sysfnf_7
 62318                              <1> 
 62319 00010F5F 3B05[6E7F0100]      <1> 	cmp	eax, [DirBuff_Cluster]
 62320                              <1> 	;je	short sysfnf_9
 62321                              <1> 	; 08/08/2022
 62322 00010F65 7505                <1> 	jne	short sysfnf_7
 62323 00010F67 E961FFFFFF          <1> 	jmp	sysfnf_9
 62324                              <1> sysfnf_7:
 62325 00010F6C FE05[37840100]      <1> 	inc	byte [SWP_DRV_chg]
 62326 00010F72 803D[41780100]01    <1> 	cmp	byte [Current_FATType], 1
 62327                              <1> 	;jnb	short sysfnf_8
 62328                              <1> 	; 08/08/2022
 62329 00010F79 7205                <1> 	jb	short sysfnf_13
 62330 00010F7B E946FFFFFF          <1> 	jmp	sysfnf_8
 62331                              <1> sysfnf_13:
 62332                              <1> 	; Singlix (TRFS) File System 
 62333                              <1> 	; (access via compatibility buffer)
 62334 00010F80 E8FBB3FFFF          <1> 	call	load_FS_sub_directory
 62335                              <1> 	;jnc	short sysfnf_9
 62336                              <1> 	;jmp	short sysfnf_err_1 ; read error (no FNF stop)
 62337                              <1> 	; 08/08/2022
 62338 00010F85 72BB                <1> 	jc	short sysfnf_err_1
 62339 00010F87 E941FFFFFF          <1> 	jmp	sysfnf_9
 62340                              <1> 
 62341                              <1> writei:
 62342                              <1> 	; 08/08/2022
 62343                              <1> 	; 30/07/2022
 62344                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 62345                              <1> 	; 26/10/2016
 62346                              <1> 	; 25/10/2016
 62347                              <1> 	; 23/10/2016
 62348                              <1> 	; 22/10/2016
 62349                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 62350                              <1> 	; 19/05/2015 - 20/05/2015 (Retro UNIX 386 v1)
 62351                              <1> 	; 12/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 62352                              <1> 	;
 62353                              <1> 	; Write data to file with first cluster number in EAX
 62354                              <1> 	; 
 62355                              <1> 	; INPUTS ->
 62356                              <1> 	;    EAX - First cluster number of the file
 62357                              <1> 	;    EBX - File number (Open file index number)
 62358                              <1> 	;    u.count - byte count to be written
 62359                              <1> 	;    u.base - points to user buffer
 62360                              <1> 	;    u.fofp - points to dword with current file offset
 62361                              <1> 	;    i.size - file size
 62362                              <1> 	;    cdev - logical dos drive number of the file
 62363                              <1> 	; OUTPUTS ->
 62364                              <1> 	;    u.count - cleared
 62365                              <1> 	;    u.nread - accumulates total bytes passed back
 62366                              <1> 	;    i.size - new file size (if file byte offset overs file size)
 62367                              <1> 	;    u.fofp - points to u.off (with new offset value)	
 62368                              <1> 	;
 62369                              <1> 	; (Retro UNIX Prototype : 11/11/2012 - 18/11/2012, UNIXCOPY.ASM)
 62370                              <1> 	; ((Modified registers: eax, edx, ebx, ecx, esi, edi, ebp)) 	
 62371                              <1> 
 62372 00010F8C 31C9                <1> 	xor	ecx, ecx
 62373 00010F8E 890D[48010300]      <1> 	mov 	[u.nread], ecx  ; 0
 62374 00010F94 66890D[80010300]    <1> 	mov	[u.pcount], cx ; 19/05/2015
 62375 00010F9B 390D[44010300]      <1> 	cmp 	[u.count], ecx
 62376 00010FA1 7701                <1> 	ja 	short writei_1 ; 08/08/2022
 62377 00010FA3 C3                  <1> 	retn
 62378                              <1> 	; 23/07/2022
 62379                              <1> 	;jna	short dskw_8 ; retn
 62380                              <1> 	
 62381                              <1> writei_1:
 62382                              <1> dskw:
 62383 00010FA4 881D[F0830100]      <1> 	mov	[writei.ofn], bl ; Open file number
 62384 00010FAA 880D[2B840100]      <1> 	mov	[setfmod], cl ; 0 ; reset 'update lm date&time' sign
 62385                              <1> dskw_0: 
 62386                              <1> 	; 26/10/2016
 62387                              <1> 	; 22/10/2016, 23/10/2016, 25/10/2016
 62388                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 62389                              <1> 	; 31/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 62390                              <1> 	; 26/04/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 62391                              <1> 	;
 62392                              <1> 	; 01/08/2013 (mkdir_w check)
 62393 00010FB0 E8D0000000          <1>  	call	mget_w
 62394                              <1> 	; eax = sector/block number
 62395                              <1> 
 62396 00010FB5 8B1D[30010300]      <1> 	mov     ebx, [u.fofp]
 62397 00010FBB 8B13                <1> 	mov	edx, [ebx]
 62398 00010FBD 81E2FF010000        <1> 	and	edx, 1FFh  ; / test the lower 9 bits of the file offset
 62399 00010FC3 750C                <1> 	jnz	short dskw_1 ; / if its non-zero, branch
 62400                              <1> 			     ; if zero, file offset = 0,
 62401                              <1> 		       	     ; / 512, 1024,...(i.e., start of new block)
 62402 00010FC5 813D[44010300]0002- <1> 	cmp	dword [u.count], 512
 62403 00010FCD 0000                <1>
 62404                              <1> 				; / if zero, is there enough data to fill
 62405                              <1> 				; / an entire block? (i.e., no. of
 62406 00010FCF 7331                <1> 	jnb	short dskw_2 ; / bytes to be written greater than 512.? 
 62407                              <1> 			     ; / Yes, branch. Don't have to read block
 62408                              <1> dskw_1: ; in as no past info. is to be saved 
 62409                              <1> 	; (the entire block will be overwritten).
 62410                              <1> 	; 23/10/2016
 62411                              <1> 
 62412 00010FD1 BB[48050300]        <1> 	mov	ebx, writei_buffer
 62413                              <1> 	; esi = logical dos drive description table address
 62414                              <1> 	; eax = sector number
 62415                              <1> 	; ebx = buffer address (in kernel's memory space)
 62416                              <1> 	; ecx = sector count
 62417                              <1> 	; 30/07/2022
 62418                              <1> 	;mov	ecx, 1
 62419 00010FD6 31C9                <1> 	xor	ecx, ecx
 62420 00010FD8 FEC1                <1> 	inc	cl
 62421                              <1> 	; ecx = 1
 62422 00010FDA E84A0D0000          <1> 	call	disk_read
 62423                              <1> 	;call	dskrd 	; / no, must retain old info.. 
 62424                              <1> 		       	; / Hence, read block 'r1' into an I/O buffer
 62425 00010FDF 7321                <1> 	jnc	short dskw_2
 62426                              <1> 
 62427                              <1> 	; disk read error
 62428                              <1> 	; 30/07/2022
 62429                              <1> 	;mov	eax, 17 ; drive not ready or READ ERROR !
 62430 00010FE1 29C0                <1> 	sub	eax, eax
 62431 00010FE3 B011                <1> 	mov	al, 17
 62432                              <1> dskw_err: ; jump from disk write error
 62433 00010FE5 A3[1C010300]        <1> 	mov	[u.r0], eax
 62434 00010FEA A3[84010300]        <1> 	mov	[u.error], eax
 62435                              <1> 
 62436 00010FEF 803D[2B840100]00    <1> 	cmp	byte [setfmod], 0
 62437                              <1> 	;jna	error
 62438                              <1> 	; 23/07/2022
 62439 00010FF6 7605                <1> 	jna	short writei_err
 62440                              <1> 
 62441 00010FF8 E8A9030000          <1> 	call	update_file_lmdt ; update last modif. date&time of the file
 62442                              <1> 	;mov	byte [setfmod], 0	
 62443                              <1> writei_err:
 62444 00010FFD E9D0BCFFFF          <1> 	jmp	error
 62445                              <1> 
 62446                              <1> dskw_2: ; 3:
 62447                              <1> 	; 23/10/2016
 62448 00011002 C605[CC830100]01    <1> 	mov	byte [writei.valid], 1 ; writei buffer contains valid data
 62449 00011009 56                  <1> 	push	esi ; logical dos drive description table address
 62450                              <1> 	; EAX (r1) = block/sector number
 62451                              <1> 	;call	wslot
 62452                              <1> 		; jsr r0,wslot / set write and inhibit bits in I/O queue, 
 62453                              <1> 			   ; / proc. status=0, r5 points to 1st word of data
 62454 0001100A 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0
 62455 00011011 770F                <1> 	ja	short dskw_4 ; zf=0 -> the caller is 'mkdir'
 62456                              <1> 	;
 62457 00011013 66833D[80010300]00  <1> 	cmp	word [u.pcount], 0
 62458 0001101B 7705                <1> 	ja	short dskw_4
 62459                              <1> dskw_3:
 62460                              <1> 	; [u.base] = virtual address to transfer (as source address)
 62461 0001101D E832FAFFFF          <1> 	call	trans_addr_r ; translate virtual address to physical (r)
 62462                              <1> dskw_4:
 62463 00011022 BB[48050300]        <1> 	mov	ebx, writei_buffer
 62464                              <1> 	; EBX (r5) = system (I/O) buffer address
 62465 00011027 E894FAFFFF          <1> 	call	sioreg
 62466                              <1> 	; ESI = file (user data) offset
 62467                              <1> 	; EDI = sector (I/O) buffer offset
 62468                              <1> 	; ECX = byte count
 62469                              <1> 	;
 62470 0001102C F3A4                <1>   	rep	movsb
 62471                              <1> 	; 25/07/2015
 62472                              <1> 	; eax = remain bytes in buffer
 62473                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 62474 0001102E 09C0                <1> 	or	eax, eax
 62475 00011030 75EB                <1> 	jnz	short dskw_3 ; (page end before system buffer end!)	
 62476                              <1> 
 62477                              <1> 	; 23/10/2016
 62478 00011032 B101                <1> 	mov	cl, 1
 62479 00011034 5E                  <1> 	pop	esi
 62480 00011035 A1[D0830100]        <1> 	mov	eax, [writei.sector]
 62481                              <1> 	; esi = logical dos drive description table address
 62482                              <1> 	; eax = sector number
 62483                              <1> 	; ebx = writei buffer address
 62484                              <1> 	; ecx = sector count
 62485 0001103A E8DB0C0000          <1> 	call	disk_write ; / yes, write the block
 62486 0001103F 7313                <1> 	jnc	short dskw_5
 62487                              <1> 
 62488                              <1> 	;mov	eax, 18 ; drive not ready or WRITE ERROR !
 62489                              <1> 	; 30/08/2022
 62490 00011041 29C0                <1> 	sub	eax, eax
 62491 00011043 B012                <1> 	mov	al, 18
 62492 00011045 EB9E                <1> 	jmp	short dskw_err
 62493                              <1> 
 62494                              <1> dskw_7:
 62495                              <1>  	; update last modif. date&time of the file
 62496                              <1> 	; (also updates file size as OF_SIZE)
 62497 00011047 E85A030000          <1> 	call	update_file_lmdt
 62498                              <1> 	;mov	byte [setfmod], 0	
 62499                              <1> 
 62500                              <1> 	; 03/08/2013
 62501 0001104C C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 62502                              <1> 	; 23/10/2016
 62503                              <1> 	;mov	eax, [writei.fclust]
 62504                              <1> dskw_8:		; 23/07/2022
 62505 00011053 C3                  <1> 	retn
 62506                              <1> 
 62507                              <1> dskw_5:
 62508                              <1> 	; 26/10/2016
 62509 00011054 0FB61D[F0830100]    <1> 	movzx	ebx, byte [writei.ofn] ; open file number
 62510 0001105B C0E302              <1> 	shl	bl, 2 ; *4
 62511 0001105E 8B83[3C850100]      <1> 	mov	eax, [ebx+OF_POINTER]
 62512 00011064 3B83[BC850100]      <1> 	cmp	eax, [ebx+OF_SIZE]
 62513 0001106A 7606                <1> 	jna	short dskw_6
 62514 0001106C 8983[BC850100]      <1> 	mov	[ebx+OF_SIZE], eax
 62515                              <1> dskw_6:
 62516                              <1> 	;shr	bl, 2
 62517 00011072 833D[44010300]00    <1>         cmp     dword [u.count], 0 ; / any more data to write?
 62518 00011079 76CC                <1> 	jna	short dskw_7
 62519 0001107B A1[E0830100]        <1> 	mov	eax, [writei.fclust]
 62520 00011080 E92BFFFFFF          <1> 	jmp	dskw_0 ; / yes, branch
 62521                              <1> 
 62522                              <1> mget_w:
 62523                              <1> 	; 08/08/2022
 62524                              <1> 	; 25/07/2022
 62525                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 62526                              <1> 	; 02/11/2016
 62527                              <1> 	; 01/11/2016
 62528                              <1> 	; 23/10/2016, 31/10/2016
 62529                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 62530                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 62531                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 62532                              <1> 	;
 62533                              <1> 	; Get existing or (allocate) a new disk block for file
 62534                              <1> 	; 
 62535                              <1> 	; INPUTS ->
 62536                              <1> 	;    [u.fofp] = file offset pointer
 62537                              <1> 	;    [i.size] = file size
 62538                              <1> 	;    [u.count] = byte count	 
 62539                              <1> 	;    EAX = First cluster
 62540                              <1> 	;    [cdev] = Logical dos drive number 	  
 62541                              <1> 	;    [writei.ofn] = File Number
 62542                              <1> 	;		   (Open file index, 0 based)
 62543                              <1> 	;    ([u.off] = file offset)
 62544                              <1> 	; OUTPUTS ->
 62545                              <1> 	;    EAX = logical sector number
 62546                              <1> 	;    ESI = Logical Dos Drive Description Table address
 62547                              <1> 	;
 62548                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI, EBP  
 62549                              <1> 
 62550 00011085 8B35[30010300]      <1>         mov     esi, [u.fofp]
 62551 0001108B 8B2E                <1> 	mov	ebp, [esi] ; u.off (or EBX*4+OF_POINTER)
 62552                              <1> 
 62553 0001108D 29C9                <1> 	sub	ecx, ecx
 62554 0001108F 8A2D[01010300]      <1> 	mov	ch, [cdev]
 62555                              <1> 
 62556 00011095 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 62557 0001109A 01CE                <1> 	add	esi, ecx
 62558                              <1> 
 62559                              <1> 	; 31/10/2016
 62560 0001109C 89C3                <1> 	mov	ebx, eax ; First Cluster or FDT address
 62561                              <1> 
 62562 0001109E 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 62563                              <1> 	;jna	mget_w_14 ; Singlix FS
 62564                              <1> 	; 23/07/2022
 62565 000110A2 7705                <1> 	ja	short mget_w_20
 62566 000110A4 E9D8010000          <1> 	jmp	mget_w_14  ; Singlix FS	
 62567                              <1>  
 62568                              <1> mget_w_20:
 62569 000110A9 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 62570 000110AD 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 62571 000110B1 8815[CE830100]      <1> 	mov	[writei.spc], dl  ; sectors per cluster
 62572 000110B7 F7E2                <1> 	mul	edx
 62573                              <1> 	; edx = 0
 62574                              <1> 	; eax = bytes per cluster (<= 65536)
 62575                              <1> 
 62576                              <1> 	; 02/11/2016
 62577 000110B9 89C1                <1> 	mov	ecx, eax
 62578 000110BB 48                  <1> 	dec	eax
 62579 000110BC 66A3[D4830100]      <1> 	mov	[writei.bpc], ax	
 62580                              <1> 	
 62581 000110C2 89E8                <1> 	mov	eax, ebp
 62582 000110C4 0305[44010300]      <1> 	add	eax, [u.count] ; next file position
 62583 000110CA 3B05[24020300]      <1> 	cmp	eax, [i.size] ; <= file size ?
 62584                              <1> 	;jna	mget_w_4 ; no
 62585                              <1> 	; 23/07/2022
 62586 000110D0 7705                <1> 	ja	short mget_w_21
 62587 000110D2 E907010000          <1> 	jmp	mget_w_4
 62588                              <1> mget_w_21:
 62589 000110D7 F7F1                <1> 	div	ecx
 62590 000110D9 A3[DC830100]        <1> 	mov	[writei.c_index], eax ; cluster index
 62591                              <1> 	; edx = byte offset in cluster (<= 65535)
 62592                              <1> 	;mov	[writei.offset], dx
 62593                              <1> 	;shr	dx, 9 ; / 512
 62594                              <1> 	;mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 62595                              <1> 
 62596 000110DE 29D2                <1> 	sub	edx, edx ; 01/11/2016
 62597 000110E0 8915[D0830100]      <1> 	mov 	[writei.sector], edx ; 0
 62598 000110E6 668915[D6830100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 62599 000110ED 8815[CF830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 62600                              <1> 
 62601 000110F3 89D8                <1> 	mov	eax, ebx ; First Cluster
 62602                              <1> 
 62603                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 62604 000110F5 3815[CC830100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 62605 000110FB 7624                <1> 	jna	short mget_w_0
 62606                              <1> 
 62607 000110FD 8815[CC830100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 62608                              <1> 
 62609 00011103 3B05[E0830100]      <1> 	cmp	eax, [writei.fclust]
 62610 00011109 7516                <1> 	jne	short mget_w_0
 62611                              <1> 
 62612 0001110B 8A0D[01010300]      <1> 	mov	cl, [cdev]
 62613 00011111 3A0D[CD830100]      <1> 	cmp	cl, [writei.drv]
 62614 00011117 7508                <1> 	jne	short mget_w_0
 62615                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 62616                              <1> 	;  we don't need to get last cluster & last cluster index
 62617 00011119 8B0D[EC830100]      <1> 	mov	ecx, [writei.l_index]
 62618 0001111F EB61                <1> 	jmp	short mget_w_2
 62619                              <1> mget_w_0:
 62620 00011121 A3[E0830100]        <1> 	mov	[writei.fclust], eax ; first cluster
 62621                              <1> 	; edx = 0
 62622 00011126 A3[D8830100]        <1> 	mov	[writei.cluster], eax ; first cluster ; 01/11/2016
 62623 0001112B 8915[E4830100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; current cluster index
 62624                              <1> 
 62625                              <1> 	; FAT file system (FAT12, FAT16, FAT32)
 62626 00011131 E8D5B7FFFF          <1> 	call	get_last_cluster
 62627                              <1> 	;jc	short mget_w_err ; eax = error code
 62628                              <1> 	; 08/08/2022
 62629 00011136 7305                <1> 	jnc	short mget_w_25
 62630 00011138 E992000000          <1> 	jmp	mget_w_err
 62631                              <1> mget_w_25:		
 62632 0001113D A3[E8830100]        <1> 	mov	[writei.lclust], eax ; last cluster
 62633                              <1> 
 62634 00011142 8B0D[0C820100]      <1> 	mov	ecx, [glc_index] ; last cluster index
 62635 00011148 890D[EC830100]      <1> 	mov	[writei.l_index], ecx
 62636                              <1> 
 62637 0001114E A0[F0830100]        <1> 	mov	al, [writei.ofn]
 62638 00011153 FEC0                <1> 	inc	al
 62639 00011155 A2[2B840100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 62640                              <1> 
 62641                              <1> mget_w_1:
 62642 0001115A 3B0D[DC830100]      <1> 	cmp	ecx, [writei.c_index]  ; last cluster index
 62643 00011160 7320                <1> 	jnb	short mget_w_2 ; 01/11/2016
 62644                              <1> 
 62645 00011162 A1[E8830100]        <1> 	mov	eax, [writei.lclust]
 62646                              <1> 	; EAX = Last cluster
 62647 00011167 E8AAB8FFFF          <1> 	call	add_new_cluster
 62648 0001116C 7261                <1> 	jc	short mget_w_err ; eax = error code
 62649                              <1> 	; edx = 0
 62650 0001116E A3[E8830100]        <1> 	mov	[writei.lclust], eax ; (new) last cluster
 62651 00011173 8B0D[EC830100]      <1> 	mov	ecx, [writei.l_index]
 62652 00011179 41                  <1> 	inc	ecx ; add 1 to last cluster index
 62653 0001117A 890D[EC830100]      <1> 	mov	[writei.l_index], ecx ; current last cluster index
 62654                              <1> 
 62655 00011180 EBD8                <1> 	jmp	short mget_w_1
 62656                              <1> 
 62657                              <1> mget_w_2:
 62658 00011182 89E9                <1> 	mov	ecx, ebp
 62659 00011184 030D[44010300]      <1> 	add	ecx, [u.count]
 62660 0001118A 890D[24020300]      <1> 	mov	[i.size], ecx ; save new file size
 62661                              <1> 	;sub	edx, edx ; 0
 62662                              <1> 
 62663 00011190 A0[01010300]        <1> 	mov	al, [cdev]
 62664 00011195 A2[CD830100]        <1> 	mov	[writei.drv], al ; physical drive number
 62665                              <1> 	; edx = 0
 62666 0001119A 89E8                <1> 	mov	eax, ebp ; file offset
 62667 0001119C 0FB70D[D4830100]    <1> 	movzx	ecx, word [writei.bpc] ; bytes per cluster - 1
 62668 000111A3 41                  <1> 	inc	ecx ; bytes per cluster
 62669 000111A4 F7F1                <1> 	div	ecx
 62670                              <1> 	; edx = byte offset in cluster (<= 65535)
 62671                              <1> 	; eax = cluster index
 62672 000111A6 A3[DC830100]        <1> 	mov	[writei.c_index], eax
 62673 000111AB 668915[D6830100]    <1> 	mov	[writei.offset], dx
 62674                              <1> 	;shr	dx, 9 ; / 512
 62675                              <1> 	; 23/07/2022
 62676 000111B2 C1EA09              <1> 	shr	edx, 9
 62677 000111B5 8815[CF830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 62678                              <1> 
 62679                              <1> mget_w_3:
 62680 000111BB 3B05[EC830100]      <1> 	cmp	eax, [writei.l_index] ; last cluster index
 62681 000111C1 7538                <1> 	jne	short mget_w_5
 62682                              <1> 
 62683 000111C3 A3[E4830100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 62684 000111C8 A1[E8830100]        <1> 	mov	eax, [writei.lclust] ; last cluster
 62685 000111CD EB6E                <1> 	jmp	short mget_w_10
 62686                              <1> 
 62687                              <1> mget_w_err:
 62688 000111CF A3[84010300]        <1> 	mov	[u.error], eax
 62689 000111D4 A3[1C010300]        <1> 	mov	[u.r0], eax
 62690 000111D9 E9F4BAFFFF          <1> 	jmp	error
 62691                              <1> 
 62692                              <1> mget_w_4: ; 02/11/2016
 62693                              <1> 	; eax = next file position
 62694 000111DE 2B05[44010300]      <1> 	sub	eax, [u.count] ; current file position
 62695                              <1> 	; edx = 0
 62696                              <1> 	; ecx = bytes per cluster
 62697 000111E4 F7F1                <1> 	div	ecx
 62698 000111E6 A3[DC830100]        <1> 	mov	[writei.c_index], eax ; cluster index
 62699 000111EB 668915[D6830100]    <1> 	mov	[writei.offset], dx
 62700                              <1> 	;shr	dx, 9 ; / 512
 62701                              <1> 	; 23/07/2022
 62702 000111F2 C1EA09              <1> 	shr	edx, 9
 62703 000111F5 8815[CF830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 62704                              <1> 
 62705                              <1> mget_w_5:
 62706 000111FB 21C0                <1> 	and	eax, eax ; 0 = First Cluster's index number
 62707 000111FD 750C                <1> 	jnz	short mget_w_6
 62708                              <1> 
 62709 000111FF A3[E4830100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 62710 00011204 A1[E0830100]        <1> 	mov	eax, [writei.fclust] ; first cluster
 62711 00011209 EB32                <1> 	jmp	short mget_w_10
 62712                              <1> 
 62713                              <1> mget_w_6:
 62714 0001120B 3B05[E4830100]      <1> 	cmp	eax, [writei.fs_index] ; current cluster index (>0)
 62715 00011211 7507                <1> 	jne	short mget_w_7
 62716 00011213 A1[D8830100]        <1> 	mov	eax, [writei.cluster] ; current cluster 
 62717 00011218 EB3A                <1> 	jmp	short mget_w_11
 62718                              <1> 
 62719                              <1> mget_w_7:
 62720 0001121A 89C1                <1> 	mov	ecx, eax
 62721 0001121C 2B0D[E4830100]      <1> 	sub	ecx, [writei.fs_index]
 62722 00011222 730D                <1> 	jnc	short mget_w_8
 62723                              <1> 	; get cluster by index from the first cluster
 62724 00011224 A1[E0830100]        <1> 	mov	eax, [writei.fclust]
 62725 00011229 8B0D[DC830100]      <1> 	mov	ecx, [writei.c_index]
 62726 0001122F EB05                <1> 	jmp	short mget_w_9
 62727                              <1> 
 62728                              <1> mget_w_8:
 62729 00011231 A1[D8830100]        <1> 	mov	eax, [writei.cluster] ; beginning cluster
 62730                              <1> 	; ecx = cluster sequence number after the beginning cluster
 62731                              <1> 	; sub	edx, edx ; 0
 62732                              <1> 
 62733                              <1> mget_w_9:
 62734                              <1> 	; EAX = Beginning cluster
 62735                              <1> 	; EDX = Sector index in disk/file section
 62736                              <1> 	;	(Only for SINGLIX file system!)
 62737                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 62738                              <1> 	; ESI = Logical DOS Drive Description Table address
 62739 00011236 E8CFB8FFFF          <1> 	call	get_cluster_by_index
 62740 0001123B 7292                <1> 	jc	short mget_w_err ; error code in EAX
 62741                              <1> 
 62742                              <1> 	; EAX = Cluster number		
 62743                              <1> mget_w_10:
 62744 0001123D A3[D8830100]        <1> 	mov	[writei.cluster], eax ; FDT number for Singlix File System
 62745                              <1> 
 62746 00011242 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 62747 00011246 7628                <1> 	jna	short mget_w_13
 62748                              <1> 	; 01/11/2016
 62749 00011248 8B15[DC830100]      <1> 	mov	edx, [writei.c_index]
 62750 0001124E 8915[E4830100]      <1> 	mov	[writei.fs_index], edx
 62751                              <1> mget_w_11:
 62752                              <1> 	;sub	eax, 2
 62753                              <1> 	; 23/07/2022
 62754 00011254 48                  <1> 	dec	eax
 62755 00011255 48                  <1> 	dec	eax
 62756 00011256 0FB615[CE830100]    <1> 	movzx	edx, byte [writei.spc]
 62757 0001125D F7E2                <1> 	mul	edx
 62758                              <1> 
 62759 0001125F 034668              <1> 	add	eax, [esi+LD_DATABegin]
 62760 00011262 8A15[CF830100]      <1> 	mov	dl, [writei.s_index]
 62761 00011268 01D0                <1> 	add	eax, edx
 62762                              <1> mget_w_12:
 62763 0001126A A3[D0830100]        <1> 	mov	[writei.sector], eax
 62764                              <1> 	;; buffer validation must be done in writei
 62765                              <1> 	;;mov	byte [writei.valid], 1 
 62766 0001126F C3                  <1> 	retn
 62767                              <1> 
 62768                              <1> mget_w_13:
 62769                              <1> 	; EAX = FDT number (Current Section)
 62770                              <1> 	; EDX = Sector index from the first section (0,1,2,3,4...)
 62771 00011270 2B15[E4830100]      <1> 	sub	edx, [writei.fs_index]	
 62772                              <1> 	; EDX = Sector index from current section
 62773 00011276 8915[E4830100]      <1> 	mov	[writei.fs_index], edx
 62774 0001127C 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 62775 0001127D 01D0                <1> 	add	eax, edx
 62776 0001127F EBE9                <1> 	jmp	short mget_w_12
 62777                              <1> 
 62778                              <1> mget_w_14:
 62779 00011281 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 62780 00011284 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 62781 00011286 880D[CE830100]      <1> 	mov	[writei.spc], cl  ; sectors per cluster
 62782                              <1> 	; NOTE: writei bytes per sector value is always 512 ! 
 62783 0001128C 66C705[D4830100]00- <1> 	mov	word [writei.bpc], 512
 62784 00011294 02                  <1>
 62785                              <1> 
 62786 00011295 89E9                <1> 	mov	ecx, ebp
 62787 00011297 030D[44010300]      <1> 	add	ecx, [u.count] ; next file position
 62788 0001129D 3B0D[24020300]      <1> 	cmp	ecx, [i.size] ; <= file size ?
 62789                              <1> 	;jna	mget_w_19 ; no
 62790 000112A3 7705                <1> 	ja	short mget_w_22
 62791                              <1> 	; 23/07/2022
 62792 000112A5 E9C6000000          <1> 	jmp	mget_w_19
 62793                              <1> 
 62794                              <1> mget_w_22:
 62795 000112AA 29D2                <1> 	sub	edx, edx ; 0
 62796 000112AC 8915[D0830100]      <1> 	mov 	[writei.sector], edx ; 0
 62797 000112B2 668915[D6830100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 62798 000112B9 8815[CF830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 62799                              <1> 
 62800 000112BF C1E909              <1> 	shr	ecx, 9 ; 1 cluster = 512 bytes
 62801 000112C2 890D[DC830100]      <1> 	mov	[writei.c_index], ecx ; section/cluster index
 62802                              <1> 	
 62803 000112C8 89D8                <1> 	mov	eax, ebx ; FDT number (First FDT address)
 62804                              <1> 
 62805                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 62806 000112CA 3815[CC830100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 62807 000112D0 7624                <1> 	jna	short mget_w_15
 62808                              <1> 
 62809 000112D2 8815[CC830100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 62810                              <1> 
 62811 000112D8 3B05[E0830100]      <1> 	cmp	eax, [writei.fclust]
 62812 000112DE 7516                <1> 	jne	short mget_w_15
 62813                              <1> 
 62814 000112E0 8A0D[01010300]      <1> 	mov	cl, [cdev]
 62815 000112E6 3A0D[CD830100]      <1> 	cmp	cl, [writei.drv]
 62816 000112EC 7508                <1> 	jne	short mget_w_15
 62817                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 62818                              <1> 	;  we don't need to get last cluster & last cluster index
 62819 000112EE 8B0D[EC830100]      <1> 	mov	ecx, [writei.l_index]
 62820 000112F4 EB4A                <1> 	jmp	short mget_w_17
 62821                              <1> mget_w_15:
 62822 000112F6 A3[E0830100]        <1> 	mov	[writei.fclust], eax ; first section (FDT number)
 62823                              <1> 	; edx = 0
 62824 000112FB 8915[D8830100]      <1> 	mov	[writei.cluster], edx ; 0 ; current section
 62825 00011301 8915[E4830100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret section index
 62826                              <1> 
 62827                              <1> 	; eax = FDT number (section 0 header address)
 62828 00011307 E827B8FFFF          <1> 	call	get_last_section
 62829                              <1> 	;jc	short mget_w_err ; eax = error code
 62830                              <1> 	; 08/08/2022
 62831 0001130C 7305                <1> 	jnc	short mget_w_26
 62832 0001130E E9BCFEFFFF          <1> 	jmp	mget_w_err
 62833                              <1> mget_w_26:
 62834 00011313 8915[E4830100]      <1> 	mov 	[writei.fs_index], edx ; sector index in last section
 62835                              <1> 		
 62836 00011319 A3[E8830100]        <1> 	mov	[writei.lclust], eax ; last section address
 62837                              <1> 
 62838 0001131E 8B0D[0C820100]      <1> 	mov	ecx, [glc_index] ; last section index
 62839 00011324 890D[EC830100]      <1> 	mov	[writei.l_index], ecx
 62840                              <1> 
 62841 0001132A A0[F0830100]        <1> 	mov	al, [writei.ofn]
 62842 0001132F FEC0                <1> 	inc	al
 62843 00011331 A2[2B840100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 62844                              <1> 
 62845                              <1> mget_w_16:
 62846                              <1> 	; edx = (existing) last section (sector) index
 62847 00011336 8B0D[DC830100]      <1> 	mov	ecx, [writei.c_index] ; final section (sector) index
 62848 0001133C 29D1                <1> 	sub	ecx, edx
 62849 0001133E 7630                <1> 	jna	short mget_w_19
 62850                              <1> 	; ecx = sector count
 62851                              <1> mget_w_17:
 62852 00011340 A1[E8830100]        <1> 	mov	eax, [writei.lclust]
 62853                              <1> 	; ESI = Logical dos drv desc. table address
 62854                              <1>         ; EAX = Last section
 62855                              <1>         ; (ECX = 0 for directory) 
 62856                              <1>         ; ECX = sector count (except FDT)
 62857 00011345 E83FAEFFFF          <1> 	call	add_new_fs_section
 62858 0001134A 730F                <1> 	jnc	short mget_w_18
 62859                              <1> 
 62860                              <1> 	; If error number = 27h (insufficient disk space)
 62861                              <1> 	; it is needed to check free consequent sectors
 62862                              <1> 	; (1 data sector at least and +1 section header sector) 
 62863                              <1> 
 62864 0001134C 83F827              <1> 	cmp	eax, 27h
 62865                              <1> 	;jne	mget_w_err ; eax = error code
 62866                              <1> 	; 25/07/2022
 62867 0001134F 7405                <1> 	je	short mget_w_24
 62868                              <1> mget_w_23:
 62869 00011351 E979FEFFFF          <1> 	jmp	mget_w_err
 62870                              <1> mget_w_24:
 62871                              <1> 	; ecx = count of free consequent sectors
 62872                              <1> 	; ecx must be > 1 (1 data + 1 header sector)
 62873 00011356 49                  <1> 	dec	ecx
 62874                              <1> 	;jz	short mget_w_err
 62875                              <1> 	;jmp	short mget_w_17
 62876                              <1> 	; 23/07/2022
 62877 00011357 75E7                <1> 	jnz	short mget_w_17
 62878                              <1> 	;jmp	mget_w_err
 62879                              <1> 	; 25/07/2022
 62880 00011359 EBF6                <1> 	jmp	short mget_w_23
 62881                              <1> 
 62882                              <1> mget_w_18:
 62883 0001135B A3[E8830100]        <1> 	mov	[writei.lclust], eax ; (new) last section
 62884                              <1> 	; ecx = sector count (except section header)
 62885 00011360 8B15[EC830100]      <1> 	mov	edx, [writei.l_index]
 62886 00011366 01CA                <1> 	add	edx, ecx ; add sector count to index
 62887 00011368 8915[EC830100]      <1> 	mov	[writei.l_index], edx
 62888 0001136E EBC6                <1> 	jmp	short mget_w_16
 62889                              <1> 
 62890                              <1> mget_w_19:
 62891 00011370 89E9                <1> 	mov	ecx, ebp
 62892 00011372 030D[44010300]      <1> 	add	ecx, [u.count]
 62893 00011378 890D[24020300]      <1> 	mov	[i.size], ecx ; save new file size
 62894                              <1> 	;sub	edx, edx ; 0
 62895                              <1> 
 62896 0001137E A0[01010300]        <1> 	mov	al, [cdev]
 62897 00011383 A2[CD830100]        <1> 	mov	[writei.drv], al ; physical drive number
 62898                              <1> 	; edx = 0
 62899 00011388 89E8                <1> 	mov	eax, ebp ; file offset
 62900 0001138A 89C2                <1> 	mov	edx, eax
 62901                              <1> 	; 1 cluster = 512 bytes (for Singlix FS)
 62902 0001138C C1E809              <1> 	shr	eax, 9  ; / 512
 62903 0001138F 81E2FF010000        <1> 	and	edx, 1FFh
 62904                              <1> 	; edx = byte offset in cluster/sector (<= 511)
 62905                              <1> 	; eax = section (sector/cluster) index
 62906 00011395 A3[DC830100]        <1> 	mov	[writei.c_index], eax
 62907 0001139A 668915[D6830100]    <1> 	mov	[writei.offset], dx
 62908                              <1> 	;mov	byte [writei.s_index], 0 ; sector index in cluster
 62909 000113A1 E915FEFFFF          <1> 	jmp	mget_w_3
 62910                              <1> 
 62911                              <1> update_file_lmdt: ; & update file size
 62912                              <1> 	; 30/07/2022
 62913                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 62914                              <1> 	; 26/10/2016
 62915                              <1> 	; 24/10/2016
 62916                              <1> 	; 23/10/2016
 62917                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 62918                              <1> 	;
 62919                              <1> 	; Update last modification date&time of file
 62920                              <1> 	; (call from syswrite -> writei)
 62921                              <1> 	; ((also updates file size)) // 26/10/2016
 62922                              <1> 	; 
 62923                              <1> 	; INPUT:
 62924                              <1> 	;      byte [setfmod] = open file number
 62925                              <1> 	; OUTPUT:
 62926                              <1> 	;      cf = 0 -> success !
 62927                              <1> 	;      cf = 1 -> lmdt update has been failed!
 62928                              <1> 	;
 62929                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 62930                              <1> 	;
 62931                              <1> 
 62932                              <1> 	;cmp	byte [setfmod], 0
 62933                              <1> 	;jna	short uflmdt_2 ; nothing to do
 62934                              <1> 
 62935 000113A6 31C0                <1> 	xor	eax, eax
 62936                              <1> 
 62937 000113A8 0FB61D[2B840100]    <1> 	movzx	ebx, byte [setfmod]
 62938 000113AF FECB                <1> 	dec	bl ; open file index number (0 based)
 62939                              <1> 
 62940 000113B1 8AA3[BC840100]      <1> 	mov	ah, [ebx+OF_DRIVE]
 62941 000113B7 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 62942 000113BC 01C6                <1> 	add	esi, eax
 62943 000113BE C0E302              <1> 	shl	bl, 2 ; *4	
 62944 000113C1 8B8B[3C840100]      <1> 	mov	ecx, [ebx+OF_FCLUSTER] ; first cluster
 62945 000113C7 8B93[BC860100]      <1> 	mov	edx, [ebx+OF_DIRCLUSTER] ; dir cluster
 62946                              <1> 
 62947 000113CD D0EB                <1> 	shr	bl, 1 ; /2
 62948 000113CF 0FB7BB[BC880100]    <1> 	movzx	edi, word [ebx+OF_DIRENTRY]
 62949                              <1> 	
 62950 000113D6 803D[697F0100]01    <1> 	cmp	byte [DirBuff_ValidData], 1
 62951 000113DD 7265                <1> 	jb	short uflmdt_4
 62952                              <1> 
 62953 000113DF A0[677F0100]        <1> 	mov	al, [DirBuff_DRV]
 62954 000113E4 2C41                <1> 	sub	al, 'A'	
 62955 000113E6 38E0                <1> 	cmp	al, ah
 62956 000113E8 755A                <1> 	jne	short uflmdt_4 ; different drive
 62957 000113EA 8A4603              <1> 	mov	al, [esi+LD_FATType] 
 62958 000113ED 3A05[687F0100]      <1> 	cmp	al, [DirBuff_FATType]
 62959 000113F3 7552                <1> 	jne	short uflmdt_5 ; different FS type
 62960 000113F5 3B15[6E7F0100]      <1> 	cmp	edx, [DirBuff_Cluster]
 62961 000113FB 754A                <1> 	jne	short uflmdt_5 ; different cluster
 62962                              <1> 
 62963                              <1> uflmdt_1:
 62964                              <1> 	; Directory buffer is ready here!
 62965                              <1> 	; OF_FCLUSTER must be compared/verified
 62966 000113FD BE00000800          <1> 	mov	esi, Directory_Buffer
 62967                              <1> 	;shl	di, 5 ; dir entry index * 32
 62968                              <1> 	; 23/07/2022
 62969 00011402 C1E705              <1> 	shl	edi, 5 
 62970 00011405 01FE                <1> 	add	esi, edi ; offset
 62971                              <1> 	;
 62972 00011407 F6460B18            <1> 	test	byte [esi+DirEntry_Attr], 18h ; Vol & Dir
 62973 0001140B 7564                <1> 	jnz	short uflmdt_2 ; not a valid file !
 62974 0001140D 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI]
 62975 00011411 C1E010              <1> 	shl	eax, 16
 62976 00011414 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO]
 62977 00011418 39C8                <1> 	cmp	eax, ecx ; same first cluster ?
 62978                              <1> 	;je	short uflmdt_3 ; yes, it is OK !!!	
 62979                              <1> 	; 23/07/2022
 62980 0001141A 7555                <1> 	jne	short uflmdt_2
 62981                              <1> 	
 62982                              <1> uflmdt_3:
 62983                              <1> 	; Update directory entry
 62984                              <1> 	; 26/10/2016
 62985 0001141C D0E3                <1> 	shl	bl, 1 ; *2 
 62986 0001141E 8B83[BC850100]      <1> 	mov	eax, [ebx+OF_SIZE] ; file size
 62987 00011424 89461C              <1> 	mov	[esi+DirEntry_FileSize], eax
 62988                              <1> 	;
 62989 00011427 E8529AFFFF          <1> 	call	convert_current_date_time
 62990                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 62991                              <1>         ; 	    AX = Time in dos dir entry format	
 62992 0001142C 66894616            <1> 	mov	[esi+DirEntry_WrtTime], ax
 62993 00011430 66895618            <1> 	mov	[esi+DirEntry_WrtDate], dx	
 62994 00011434 66895612            <1> 	mov	[esi+DirEntry_LastAccDate], dx
 62995 00011438 C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 62996                              <1> 	;call	save_directory_buffer
 62997                              <1> 	;retn
 62998                              <1> 	; 23/07/2022
 62999 0001143F E9CF9AFFFF          <1> 	jmp	save_directory_buffer	
 63000                              <1> 
 63001                              <1> uflmdt_4:
 63002                              <1> 	; Directory buffer sector read&write
 63003                              <1> 	; 23/10/2016
 63004                              <1> 	;
 63005 00011444 8A4603              <1> 	mov	al, [esi+LD_FATType]
 63006                              <1> uflmdt_5:
 63007 00011447 BB[50070300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 63008                              <1> 		
 63009 0001144C 20C0                <1> 	and	al, al ; 0 = Singlix FS
 63010 0001144E 7428                <1> 	jz	short uflmdt_11
 63011                              <1> 
 63012                              <1> ;uflmdt_12:
 63013 00011450 21D2                <1> 	and	edx, edx
 63014 00011452 752B                <1> 	jnz	short uflmdt_9
 63015                              <1> 
 63016 00011454 3C02                <1> 	cmp	al, 2  ; 3 = FAT32
 63017 00011456 7724                <1> 	ja	short uflmdt_8
 63018                              <1> 
 63019 00011458 89F8                <1> 	mov	eax, edi ; directory entry index number
 63020                              <1> 	;shr	ax, 4 ; 16 entries per sector	 
 63021                              <1> 	; 23/07/2022
 63022 0001145A C1E804              <1> 	shr	eax, 4
 63023 0001145D 034664              <1> 	add	eax, [esi+LD_ROOTBegin]
 63024                              <1> 	; eax = root directory sector
 63025                              <1> uflmdt_6:
 63026 00011460 50                  <1> 	push	eax ; * ; disk sector address
 63027 00011461 51                  <1> 	push	ecx ; first cluster	
 63028 00011462 B901000000          <1> 	mov	ecx, 1
 63029                              <1> 	; ecx = sector count
 63030 00011467 E8BD080000          <1> 	call	disk_read
 63031 0001146C 59                  <1> 	pop	ecx
 63032 0001146D 7324                <1> 	jnc	short uflmdt_10
 63033 0001146F 58                  <1> 	pop	eax ; *
 63034                              <1> uflmdt_7:
 63035 00011470 C3                  <1> 	retn
 63036                              <1> 
 63037                              <1> uflmdt_2:	
 63038                              <1> 	; save directory buffer if has modified/changed sign
 63039                              <1> 	; (It is good to save dir buff even if the searched
 63040                              <1> 	; directory entry is not found !?)
 63041 00011471 E89D9AFFFF          <1> 	call	save_directory_buffer
 63042 00011476 F9                  <1> 	stc	; update failed
 63043 00011477 C3                  <1> 	retn
 63044                              <1> 
 63045                              <1> uflmdt_11:
 63046                              <1> 	; 24/10/2016
 63047                              <1> 	; Update last modification date & time of a file
 63048                              <1> 	; on a disk with Singlix File System.
 63049                              <1> 	;
 63050                              <1> 	; (Method: Read the FDT -File Description Table-
 63051                              <1> 	; sector of the file and update the lmdt data fields,
 63052                              <1> 	; then write FDT sector to the disk.
 63053                              <1> 	; /// It is easy but there is compatibility buffer
 63054                              <1> 	; method also for changing directory entry data and
 63055                              <1> 	; also there are some programming issues for Singlix
 63056                              <1> 	; file system (TRFS), which are not completed yet!)
 63057                              <1> 	;
 63058                              <1> 	; Not ready yet ! (24/10/2016)
 63059                              <1> 	; /// Temporary code for error return ! ///
 63060 00011478 31C0                <1> 	xor	eax, eax
 63061 0001147A F9                  <1> 	stc
 63062 0001147B C3                  <1> 	retn	
 63063                              <1> 
 63064                              <1> uflmdt_8:
 63065 0001147C 8B5632              <1> 	mov	edx, [esi+LD_BPB+FAT32_RootFClust]
 63066                              <1> uflmdt_9:
 63067 0001147F 83FA02              <1> 	cmp	edx, 2
 63068 00011482 72EC                <1> 	jb	short uflmdt_7 ; invalid, nothing to do
 63069                              <1> 
 63070                              <1> 	;sub	edx, 2
 63071                              <1> 	; 30/07/2022
 63072 00011484 4A                  <1> 	dec	edx
 63073 00011485 4A                  <1> 	dec	edx
 63074 00011486 89D0                <1> 	mov	eax, edx
 63075 00011488 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 63076 0001148C F7E2                <1> 	mul	edx
 63077 0001148E 034668              <1> 	add	eax, [esi+LD_DATABegin]
 63078                              <1> 	; eax = sub directory (data) sector 
 63079 00011491 EBCD                <1> 	jmp	short uflmdt_6
 63080                              <1> 
 63081                              <1> uflmdt_10:
 63082                              <1> 	; Directory sector buffer is ready here!
 63083                              <1> 	; OF_FCLUSTER must be compared/verified
 63084                              <1> 	; edi = dir entry index number (<= 2047)
 63085 00011493 6683E70F            <1> 	and	di, 0Fh ; 16 entries per sector
 63086                              <1> 	;shl	di, 5 ; dir entry index * 32
 63087                              <1> 	; 23/07/2022
 63088 00011497 C1E705              <1> 	shl	edi, 5
 63089 0001149A 81C7[50070300]      <1> 	add	edi, rw_buffer
 63090                              <1> 	;
 63091 000114A0 F6470B18            <1> 	test	byte [edi+DirEntry_Attr], 18h ; Vol & Dir
 63092 000114A4 75CB                <1> 	jnz	short uflmdt_2 ; not a valid file !
 63093 000114A6 668B5714            <1> 	mov	dx, [edi+DirEntry_FstClusHI]
 63094 000114AA C1E210              <1> 	shl	edx, 16
 63095 000114AD 668B571A            <1> 	mov	dx, [edi+DirEntry_FstClusLO]
 63096 000114B1 39CA                <1> 	cmp	edx, ecx ; same first cluster ?
 63097 000114B3 75BC                <1> 	jne	short uflmdt_2 ; no !?
 63098                              <1> 
 63099                              <1> 	; Update directory entry
 63100 000114B5 E8C499FFFF          <1> 	call	convert_current_date_time
 63101                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 63102                              <1>         ; 	    AX = Time in dos dir entry format	
 63103 000114BA 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
 63104 000114BE 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
 63105 000114C2 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
 63106                              <1> 	
 63107 000114C6 58                  <1> 	pop	eax ; *
 63108                              <1> 
 63109 000114C7 BB[50070300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 63110 000114CC B901000000          <1> 	mov	ecx, 1
 63111                              <1> 	; esi = logical dos description table address
 63112                              <1> 	; eax = disk sector number/address (LBA)
 63113                              <1> 	; ecx = sector count
 63114                              <1> 	; ebx = buffer address
 63115 000114D1 E844080000          <1> 	call	disk_write
 63116 000114D6 7299                <1> 	jc	short uflmdt_2
 63117                              <1> ;uflmdt_12:	
 63118                              <1> 	; save directory buffer if has modified/changed sign
 63119                              <1> 	;call	save_directory_buffer
 63120                              <1> 	;retn
 63121                              <1> 	; 23/07/2022
 63122 000114D8 E9369AFFFF          <1> 	jmp	save_directory_buffer
 63123                              <1> 
 63124                              <1> 
 63125                              <1> sysalloc:
 63126                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 63127                              <1> 	; 14/10/2017
 63128                              <1> 	; 20/08/2017 - 01/09/2017
 63129                              <1> 	; 20/02/2017 - 04/03/2017 - 15/05/2017
 63130                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 63131                              <1> 	; (TRDOS 386 feature only!)
 63132                              <1> 	;
 63133                              <1> 	; Allocate Contiguous Memory Block/Pages (for user)
 63134                              <1> 	; (System call for DMA Buffer allocation etc.)	
 63135                              <1> 	;
 63136                              <1> 	; INPUT ->
 63137                              <1> 	;	EBX = Virtual address (for user)
 63138                              <1> 	;	     (Physical memory block/aperture
 63139                              <1> 	;	     will be mapped to this virtual address) 
 63140                              <1> 	;	ECX = Byte Count
 63141                              <1> 	;	     (will be rounded up to page border)
 63142                              <1> 	;	If ECX = 0
 63143                              <1> 	;	    System call will return with an error (cf=1)
 63144                              <1> 	;	    but ECX will contain maximum size of
 63145                              <1> 	;	    available memory aperture and physical
 63146                              <1> 	;	    (beginning) address of that aperture
 63147                              <1> 	;	    (which have maximum size) will be in EAX.
 63148                              <1> 	;	EDX = Upper limit of the requested physical memory
 63149                              <1> 	;	      block/pages.
 63150                              <1> 	;	     (The last byte address of the memory aperture 
 63151                              <1> 	;	      must not be equal to or above this limit.)	
 63152                              <1> 	;	If EDX = 0
 63153                              <1> 	; 	   there is NOLIMIT !
 63154                              <1> 	;	If EDX = 0FFFFFFFFh (-1) 
 63155                              <1> 	;	   ESI = Lower Limit !
 63156                              <1> 	;		(Beginning of the block must not be 'less'
 63157                              <1> 	;		than this.) (Must be equal to or above...)
 63158                              <1> 	;	   EDI = Upper Limit !
 63159                              <1> 	;		(End of the block must be !less! than this)
 63160                              <1> 	;		(The last byte addr of the memory aperture 
 63161                              <1> 	;		must not be equal to or above this limit.)
 63162                              <1> 	;
 63163                              <1> 	; OUTPUT ->
 63164                              <1> 	;	If CF = 0
 63165                              <1> 	;	EAX = Physical address of the allocated memory block
 63166                              <1> 	;	ECX = Allocated bytes (as rounded up to page borders)
 63167                              <1> 	;	EBX = Virtual address (as rounded up)
 63168                              <1> 	;	IF CF = 1
 63169                              <1> 	;	    Requested (size of) Memory block could not be 
 63170                              <1> 	;	    allocated to the user!	
 63171                              <1> 	;	IF CF = 1 & EAX = 0 (Insufficient memory error!)
 63172                              <1> 	;	   ECX = Total number of free bytes
 63173                              <1> 	;	         (not size of available contiguous bytes!)		 	
 63174                              <1> 	;	If CF = 1 & EAX > 0
 63175                              <1> 	;	   there is not a memory aperture with requested size
 63176                              <1> 	;	   but total free mem is not less than requested size.
 63177                              <1> 	;	   EAX = Physical addr of available memory aperture
 63178                              <1> 	;	   	 with max size 
 63179                              <1> 	;	        (but it doesn't fit to the conditions!) 	
 63180                              <1> 	;	   ECX = Size of available memory aperture in bytes.
 63181                              <1> 	;	If CF = 1 -> EAX = 0FFFFFFFFh	
 63182                              <1> 	;	   Conditions/Parameters are wrong !		 		
 63183                              <1> 	;	   ECX is same with input value.
 63184                              <1> 	;
 63185                              <1> 	; Note:	Previously allocated pages will be deallocated if
 63186                              <1> 	;       new allocation conditions are met.
 63187                              <1> 	;
 63188                              <1> 	; Note: u.break control may be included in future versions	
 63189                              <1> 	;
 63190                              <1> 
 63191 000114DD 31C0                <1> 	xor	eax, eax ; 0
 63192                              <1> 	; 14/10/2017
 63193 000114DF 4A                  <1> 	dec	edx ; is there a limit ?
 63194 000114E0 7810                <1> 	js	short sysalloc_1 ;  0 -> 0FFFFFFFFh -> NO LIMIT
 63195 000114E2 42                  <1> 	inc	edx ; > 0
 63196                              <1> 	; Check upper address limit
 63197                              <1> 	;(round up to page borders)
 63198 000114E3 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 63199 000114E9 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 63200 000114EE 39CA                <1> 	cmp	edx, ecx ; upper limit - block size
 63201 000114F0 7224                <1> 	jb	short sysalloc_err
 63202                              <1> sysalloc_1:
 63203                              <1> 	; EAX = Beginning address (physical)
 63204                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 63205                              <1> 	; ECX = Number of bytes to be allocated		
 63206 000114F2 E8C646FFFF          <1> 	call	allocate_memory_block
 63207 000114F7 721D                <1> 	jc	short sysalloc_err
 63208                              <1> 	; 01/09/2017
 63209 000114F9 29C2                <1> 	sub	edx, eax ; upper limit address - beginning address
 63210 000114FB 760F                <1> 	jna	short sysalloc_3 ; begin addr not less than the limit
 63211 000114FD 39CA                <1> 	cmp	edx, ecx
 63212 000114FF 720B                <1> 	jb	short sysalloc_3 ; end address overs the limit
 63213                              <1> sysalloc_2:	
 63214                              <1> 	; EAX = Beginning (physical) addr of the allocated mem block
 63215                              <1> 	; ECX = Num of allocated bytes (rounded up to page borders) 
 63216 00011501 50                  <1> 	push	eax ; * ; 04/03/2017	
 63217                              <1> 	; Here, requested contiquous memory pages have been allocated
 63218                              <1> 	; on Memory Allocation Table but user's page directory 
 63219                              <1> 	; and page tables have not been updated yet!
 63220 00011502 51                  <1> 	push	ecx ; **
 63221                              <1> 	; ebx = virtual address (will be rounded up to page border)
 63222                              <1> 	; ecx = number of bytes to be deallocated
 63223                              <1> 	;	will be adjusted to ebx+ecx round down - ebx round up
 63224 00011503 E8004AFFFF          <1> 	call	deallocate_user_pages 
 63225 00011508 731F                <1> 	jnc	short sysalloc_4 ; EAX = Deallocated memory bytes
 63226 0001150A 59                  <1> 	pop	ecx ; **
 63227 0001150B 58                  <1> 	pop	eax ; *
 63228                              <1> sysalloc_3:
 63229                              <1> 	; error !
 63230                              <1> 	; restore Memory Allocation Table Content
 63231 0001150C E8B948FFFF          <1> 	call	deallocate_memory_block
 63232 00011511 31C0                <1> 	xor	eax, eax ; 0
 63233 00011513 48                  <1> 	dec	eax ; 0FFFFFFFFh ; 15/05/2017
 63234 00011514 EB09                <1> 	jmp	short sysalloc_wrong
 63235                              <1> sysalloc_err:
 63236 00011516 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 63237 0001151C 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value 
 63238                              <1> sysalloc_wrong:
 63239                              <1> 	; eax = 0FFFFFFFFh
 63240 0001151F A3[1C010300]        <1> 	mov	[u.r0], eax
 63241 00011524 E9A9B7FFFF          <1> 	jmp	error
 63242                              <1> sysalloc_4:
 63243 00011529 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 63244 0001152F 894518              <1> 	mov	[ebp+24], eax ; return to user with ecx value 
 63245 00011532 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx (rounded up)
 63246 00011535 89C1                <1> 	mov	ecx, eax ; byte count (from 'deallocate_user_pages')
 63247 00011537 5A                  <1> 	pop	edx ; ** ; discard (another) byte count
 63248 00011538 58                  <1> 	pop	eax ; *
 63249 00011539 A3[1C010300]        <1> 	mov	[u.r0], eax ; physical address
 63250                              <1> 	
 63251 0001153E 51                  <1> 	push	ecx ; 20/08/2017
 63252                              <1> 	;
 63253                              <1> 	; Write newly allocated contiguous (physical) pages
 63254                              <1> 	; on page dir and page tables of current user/process	
 63255                              <1> 	; as PRESENT, USER, WRITABLE
 63256                              <1> 	; (then clear allocated pages)
 63257 0001153F E8AC4AFFFF          <1> 	call	allocate_user_pages
 63258                              <1> 	;jnc	sysret ; OK! return to process with success...
 63259                              <1> 
 63260                              <1> 	; 20/08/2017 ('sysdma' modification)
 63261 00011544 59                  <1> 	pop	ecx
 63262 00011545 A1[1C010300]        <1> 	mov	eax, [u.r0]   ; physical address (of the block)
 63263                              <1> 
 63264 0001154A 7219                <1> 	jc	short sysalloc_6
 63265                              <1> 
 63266 0001154C 833D[EC8D0100]FF    <1> 	cmp	dword [dma_addr], 0FFFFFFFFh ; -1	
 63267                              <1> 	;jb	sysret
 63268                              <1> 	; 23/07/2022
 63269 00011553 720B                <1> 	jb	short sysalloc_5 ; jmp sysret
 63270                              <1> 
 63271 00011555 A3[EC8D0100]        <1> 	mov	[dma_addr], eax ; save dma address for sysdma
 63272 0001155A 890D[F08D0100]      <1> 	mov	[dma_size], ecx ; save dma buff size for sysdma
 63273                              <1> sysalloc_5:
 63274 00011560 E98DB7FFFF          <1> 	jmp	sysret
 63275                              <1> 		
 63276                              <1> sysalloc_6:
 63277                              <1> 	;
 63278                              <1> 	; unexpected error ! insufficient memory !? conflict !?
 63279                              <1> 	; (!!?there is not a free page for a new page table?!!)
 63280                              <1> 	; We need to terminate process with error message !!!  
 63281                              <1> 	;
 63282 00011565 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 63283 0001156B 8B4D18              <1> 	mov	ecx, [ebp+24] ; byte count
 63284                              <1> 	
 63285                              <1> 	; 20/08/2017
 63286                              <1> 	;mov	eax, [u.r0]   ; physical address (of the block)
 63287                              <1> 	
 63288                              <1> 	;
 63289                              <1> 	; restore Memory Allocation Table Content
 63290 0001156E E85748FFFF          <1> 	call	deallocate_memory_block
 63291                              <1> 	;
 63292 00011573 803D[9E660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80x25 text mode?
 63293 0001157A 7407                <1> 	je	short sysalloc_7 ; yes
 63294                              <1> 	; Current mode is VGA (or CGA graphics) mode,
 63295                              <1> 	; We need to return to text mode for displaying
 63296                              <1> 	; error message just before 'sysexit'.  
 63297 0001157C B003                <1> 	mov	al, 3
 63298 0001157E E84905FFFF          <1> 	call	_set_mode
 63299                              <1> sysalloc_7:
 63300 00011583 BE[D1330100]        <1> 	mov	esi, beep_Insufficient_Memory ; error message
 63301 00011588 E89D56FFFF          <1> 	call	print_msg ; print/display the message
 63302 0001158D B801000000          <1> 	mov	eax, 1 ; ax=1 is needed for 'sysexit' procedure
 63303 00011592 E998B8FFFF          <1> 	jmp	sysexit ; and terminate the process !
 63304                              <1> 
 63305                              <1> sysdalloc:
 63306                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 63307                              <1> 	; (TRDOS 386 feature only!)
 63308                              <1> 	;
 63309                              <1> 	; Deallocate Memory Block/Pages (for user)
 63310                              <1> 	; (Complementary call for sysalloc.)	
 63311                              <1> 	;
 63312                              <1> 	; INPUT ->
 63313                              <1> 	;	EBX = Virtual address (for user)
 63314                              <1> 	;	      (will be rounded up to page border)
 63315                              <1> 	;	ECX = Byte Count
 63316                              <1> 	;	     (will be adjusted to page borders)
 63317                              <1> 	;	If ICX = 0
 63318                              <1> 	;	   nothing to do
 63319                              <1> 	;	If EBX + ECX > User's ESP
 63320                              <1> 	;	   nothing to do		
 63321                              <1> 	; 
 63322                              <1> 	; Note: u.break control may be included in future versions	
 63323                              <1> 	;
 63324                              <1> 	; OUTPUT ->
 63325                              <1> 	;	If CF = 0
 63326                              <1> 	;	   EAX = Deallocated memory bytes
 63327                              <1> 	;	   EBX = Virtual address (as rounded up)	
 63328                              <1> 	;	IF CF = 1
 63329                              <1> 	;	   EAX = 0
 63330                              <1> 	;
 63331                              <1> 	; Note:	Main purpose of this call is to deallocate/release
 63332                              <1> 	;	previously allocated (physically) contiguous memory
 63333                              <1> 	;	pages but beginning (virtual) address may not be
 63334                              <1> 	;	followed by physically contiguous pages. So, this
 63335                              <1> 	;	system call will deallocate user's virtually
 63336                              <1> 	;	contiguous memory pages. Also, there is not any
 63337                              <1> 	;	objections to use this system call without sysalloc
 63338                              <1> 	;	system call; only possible objection is to lost data
 63339                              <1> 	;	within user's memory space, if the beginning address
 63340                              <1> 	;	and size is not proper.
 63341                              <1> 	;
 63342                              <1> 	; Note: Empty page tables will not be deallocated!!!
 63343                              <1> 	;       (they will be deallocated at process termination)
 63344                              <1> 	;
 63345                              <1> 	; Note: When the program terminates itself or when it is 
 63346                              <1> 	;	terminated by operating system kernel, all allocated
 63347                              <1> 	;	memory pages will be deallocated during termination
 63348                              <1> 	;	stage. So, 'sysdalloc' is not necessary except 
 63349                              <1> 	;	forgiving memory block to other programs/processes.
 63350                              <1> 	;	
 63351 00011597 8B15[14010300]      <1> 	mov	edx, [u.sp]
 63352 0001159D 8B420C              <1> 	mov	eax, [edx+12] ; user's stack pointer
 63353 000115A0 29C8                <1> 	sub	eax, ecx ; esp - byte count
 63354 000115A2 24FC                <1> 	and	al, 0FCh ; dword alignment
 63355 000115A4 39D8                <1> 	cmp	eax, ebx
 63356 000115A6 7220                <1> 	jb	short sysdalloc_err ; deallocation overlaps with stack 	
 63357                              <1> 
 63358 000115A8 31C0                <1> 	xor	eax, eax
 63359 000115AA 21C9                <1> 	and	ecx, ecx
 63360 000115AC 7407                <1> 	jz	short sysdalloc_2
 63361                              <1> 	
 63362 000115AE E85549FFFF          <1> 	call	deallocate_user_pages
 63363 000115B3 7213                <1> 	jc	short sysdalloc_err
 63364                              <1> 
 63365                              <1> sysdalloc_2:
 63366 000115B5 A3[1C010300]        <1> 	mov	[u.r0], eax
 63367 000115BA 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
 63368 000115C0 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx
 63369 000115C3 E92AB7FFFF          <1> 	jmp	sysret
 63370                              <1> 
 63371                              <1> sysdalloc_err:
 63372 000115C8 A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 63373 000115CD E900B7FFFF          <1> 	jmp	error
 63374                              <1> 
 63375                              <1> syscalbac:
 63376                              <1> 	; SYS CALLBACK
 63377                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 63378                              <1> 	; 03/08/2020
 63379                              <1> 	; 16/04/2017
 63380                              <1> 	; 14/04/2017
 63381                              <1> 	; 13/04/2017
 63382                              <1> 	; 28/02/2017
 63383                              <1> 	; 26/02/2017
 63384                              <1> 	; 24/02/2017
 63385                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
 63386                              <1> 	; (TRDOS 386 feature only!)
 63387                              <1> 	;
 63388                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
 63389                              <1> 	;
 63390                              <1> 	; INPUT ->
 63391                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
 63392                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
 63393                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
 63394                              <1> 	;	     (numbers >15 are invalid)
 63395                              <1> 	;
 63396                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
 63397                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
 63398                              <1> 	;	     2 = Link IRQ by using Callback service method 		
 63399                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
 63400                              <1> 	;	    >3 = invalid 
 63401                              <1> 	;	
 63402                              <1> 	;	CL = Signal Return/Response Byte value 
 63403                              <1> 	;
 63404                              <1> 	;	If BH = 3, kernel will put a counter value  ; 03/08/2020
 63405                              <1> 	;	          (into the S.R.B. addr)
 63406                              <1> 	;		  between 0 to 255. (start value = CL+1)
 63407                              <1> 	;	
 63408                              <1> 	;	NOTE: counter value, for example: even and odd numbers
 63409                              <1> 	;	      may be used for -audio- DMA buffer switch 
 63410                              <1> 	;	      within double buffer method, etc. 		
 63411                              <1> 	;
 63412                              <1> 	;	EDX = Signal return (Response) byte address
 63413                              <1> 	;	       		  - or -
 63414                              <1> 	;	      Interrupt/Callback service/routine address
 63415                              <1> 	; 	
 63416                              <1> 	;	      (virtual address in user's memory space)
 63417                              <1> 	;
 63418                              <1> 	; OUTPUT ->
 63419                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
 63420                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
 63421                              <1> 	;			by another process
 63422                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
 63423                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
 63424                              <1> 	;		       invalid parameter/option or bad address
 63425                              <1> 	;
 63426                              <1> 	;	NOTE: Timer callbacks are set by using 'systimer'
 63427                              <1> 	;	      system call (IRQ 0, PIT and IRQ 8, RTC)
 63428                              <1> 	;
 63429                              <1> 	;	      Direct keyboard access is performed by using
 63430                              <1> 	;	      Keyboard Interrupt (INT 32h)	 	
 63431                              <1> 	;	
 63432                              <1> 	;	      It is prohibited here because:
 63433                              <1> 	;		1) Signal Response Byte method has not advantage
 63434                              <1> 	;		   against INT 32h, function AH = 1. Also,
 63435                              <1> 	;		   keyboard service interrupt will return with
 63436                              <1> 	;		   ascii and scan codes (AL, AH) while
 63437                              <1> 	;		   SRB method has only 1 byte space for ascii code
 63438                              <1> 	;		   or scan code. One byte signal response is used 
 63439                              <1> 	;		   for ensuring very simple and very fast
 63440                              <1> 	;		   virtual to physical memory address conversion
 63441                              <1> 	;		   without any memory page crossover risk. 
 63442                              <1> 	;		   (Otherwise double page conversion or word 
 63443                              <1> 	;		   alignment would be needed.)
 63444                              <1> 	;		2) Badly written user code (callback code)
 63445                              <1> 	;		   can prevent keyboard and timesharing functions
 63446                              <1> 	;		   of the operating system via continuous and long
 63447                              <1> 	;		   keyboard event handling by callback service.
 63448                              <1> 	;		   (It can cause to lose immediate keystroke 
 63449                              <1> 	;		   response from hardware to user.)
 63450                              <1> 	;		3) If user will check any keyboard events, 'getkey'
 63451                              <1> 	;		   (or 'getchar') must have more priority than other
 63452                              <1> 	;		   (video etc.) events because only control ability
 63453                              <1> 	;		   on a procedural infinite loop is a keyboard or
 63454                              <1> 	;		   mouse event. So user can use keyboard function
 63455                              <1> 	;		   at the end or at the beginning of a loop.
 63456                              <1> 	;		   In this case, INT 32h is used for that purpose
 63457                              <1> 	;		   and timer interrupt etc. callbacks can be used
 63458                              <1> 	;		   for dynamic and synchronized data refresh/transfer
 63459                              <1> 	;		   while cpu is in a static loop (without polling).
 63460                              <1> 	;		   Keyboard Int callback is not more useful because 
 63461                              <1> 	;		   already a manual check (a key is pressed or not)
 63462                              <1> 	;		   can be performed (via INT 32h, AH = 1) efficiently
 63463                              <1> 	;		   in a loop to prevent a locked infinitive loop.
 63464                              <1> 	;
 63465                              <1> 	;	    Disk IRQs (6,14,15) have been phohibited from ring 3 
 63466                              <1> 	;	    callback because, disk operations (file system services
 63467                              <1> 	;	    etc.) are independent from user program, for fast disk r/w.
 63468                              <1> 	;	    They are not more useful at ring 3 while they are in use
 63469                              <1> 	;	    by standard diskio functions which are mandatory part of 
 63470                              <1> 	;	    (monolithic) OS kernel and mainprog command interpreter.
 63471                              <1> 	;	    INT 33h diskio functions are enough for user level disk
 63472                              <1> 	;	    r/w.				
 63473                              <1> 	;
 63474                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
 63475                              <1> 	;	
 63476                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
 63477                              <1> 	;			which IRQs are locked by (that) user.
 63478                              <1> 	;		        Lock and unlock (by user) will change
 63479                              <1> 	;			these flags or 'terminate process' (sysexit)
 63480                              <1> 	;			will clear these flags and unlock those IRQs.
 63481                              <1> 	;			               
 63482                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
 63483                              <1> 	;
 63484                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
 63485                              <1> 	;
 63486                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
 63487                              <1> 	;			   0 = Signal Response Byte method
 63488                              <1> 	;			   1 = Callback service method
 63489                              <1> 	;			   >1 = invalid for current 'syscalback'.
 63490                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
 63491                              <1> 	;			            function (audio etc.) or
 63492                              <1> 	;			   	    a device driver.	   	
 63493                              <1> 	;			(system function will ignore the lock/owner)
 63494                              <1> 	;
 63495                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
 63496                              <1> 	;			  (a fixed value by user or a counter value
 63497                              <1> 	;			 from 0 to 255, which is increased by every
 63498                              <1> 	;			 interrupt just before putting it into 
 63499                              <1> 	;			 the Signal Response byte address
 63500                              <1> 	;			 (This is not used in callback serv method)
 63501                              <1> 	;	    	  
 63502                              <1> 	;	   IRQ(x).addr	: 1 dword
 63503                              <1> 	;			  Signal Response Byte address (physical)
 63504                              <1> 	;			  		-or-
 63505                              <1> 	;			  Callback service address (virtual)
 63506                              <1> 	;
 63507                              <1> 	;	   IRQ(x).dev	: 1 byte
 63508                              <1> 	;			  0 = Default device or kernel function
 63509                              <1> 	;			  		-or-
 63510                              <1> 	;			  1-255 = Assigned device driver number
 63511                              <1> 	;
 63512                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
 63513                              <1> 	;
 63514                              <1> 	;	
 63515                              <1> 	;	NOTE: If user's process/program calls the kernel (INT 40h)
 63516                              <1> 	;	      while it is already running in a (ring 3) callback
 63517                              <1> 	;	      service, kernel will force (convert) system call to
 63518                              <1> 	;	      'sysrele' (sys release). So, this feature provides
 63519                              <1> 	;	      easy and simple usage of callback services without
 63520                              <1> 	;	      falling into deepless <please 'callback me' then 
 63521                              <1> 	;	      let me 'callback you'> cycles! (User must return
 63522                              <1> 	;	      from callback service by using 'sysrele' system
 63523                              <1> 	;	      call, without a significant delay. Otherwise user
 63524                              <1> 	;	      process/program may be late to catch the next event
 63525                              <1> 	;	      within same callback purpose.	    		 	
 63526                              <1> 	;
 63527                              <1> 
 63528 000115D2 30C0                <1> 	xor	al, al ; the caller is 'syscalbac' sign/flag
 63529 000115D4 E88E160000          <1>  	call	set_irq_callback_service
 63530                              <1> 	; 16/04/2017
 63531 000115D9 A3[1C010300]        <1> 	mov	[u.r0], eax
 63532                              <1> 	;jnc	sysret
 63533                              <1> 	; 23/07/2022
 63534 000115DE 7205                <1> 	jc	short syscalbac_err
 63535 000115E0 E90DB7FFFF          <1> 	jmp	sysret
 63536                              <1> syscalbac_err:
 63537 000115E5 A3[84010300]        <1> 	mov	dword [u.error], eax
 63538 000115EA E9E3B6FFFF          <1> 	jmp	error
 63539                              <1> 
 63540                              <1> sysfpstat:
 63541                              <1> 	; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
 63542                              <1> 	; (TRDOS 386 feature only!)
 63543                              <1> 	;
 63544                              <1> 	; Set or reset FPU registers save/restore option (for user)
 63545                              <1> 	;	       (during software task switching, wswap-rswap)
 63546                              <1> 	;
 63547                              <1> 	; INPUT ->
 63548                              <1> 	;	BL = 0 -> reset
 63549                              <1> 	;	BL = 1 -> set (FPU register will be saved and restored)
 63550                              <1> 	;	
 63551                              <1> 	; OUTPUT ->
 63552                              <1> 	;	cf = 0 -> no error, FPU is ready... 
 63553                              <1> 	;		  (EAX = 0)
 63554                              <1> 	;	Cf = 1 -> error, 80387 FPU is not ready !
 63555                              <1> 	;		  (EAX = 0FFFFFFFFh)
 63556                              <1> 
 63557 000115EF 31C0                <1> 	xor	eax, eax
 63558 000115F1 803D[38840100]00    <1> 	cmp	byte [fpready], 0
 63559 000115F8 7613                <1> 	jna	short sysfpstat_err	
 63560                              <1> 
 63561 000115FA 80E301              <1> 	and	bl, 1 ; use BIT 0 only !
 63562 000115FD 881D[97010300]      <1> 	mov	[u.fpsave], bl
 63563 00011603 A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 63564 00011608 E9E5B6FFFF          <1> 	jmp	sysret	 	
 63565                              <1> 
 63566                              <1> sysfpstat_err:
 63567 0001160D 48                  <1> 	dec 	eax ; 0FFFFFFFFh
 63568 0001160E A3[1C010300]        <1> 	mov 	[u.r0], eax ; -1
 63569 00011613 E9BAB6FFFF          <1> 	jmp 	error
 63570                              <1> 
 63571                              <1> sysdelete: ; Delete (Remove, Unlink) File
 63572                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 63573                              <1> 	;	
 63574                              <1>         ; INPUT ->
 63575                              <1>         ;          EBX = File name (ASCIIZ string) address
 63576                              <1> 	; OUTPUT ->
 63577                              <1> 	;          cf = 0 -> eax = 0
 63578                              <1> 	;          cf = 1 -> Error code in AL
 63579                              <1> 	;
 63580                              <1> 	; Modified Registers: EAX (at the return of system call)
 63581                              <1> 	;   
 63582                              <1> 
 63583 00011618 89DE                <1> 	mov	esi, ebx
 63584                              <1> 	; file name is forced, change directory as temporary
 63585                              <1> 	;mov	ax, 1
 63586                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 63587                              <1> 	;call	set_working_path 
 63588 0001161A E8200B0000          <1> 	call	set_working_path_x
 63589 0001161F 731D                <1> 	jnc	short sysdelete_1
 63590                              <1> 
 63591 00011621 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 63592 00011623 7505                <1> 	jnz	short sysdelete_err
 63593                              <1> 	; eax = 0
 63594                              <1> sysdelete_path_err:
 63595 00011625 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 63596                              <1> sysdelete_err:
 63597 0001162A A3[1C010300]        <1> 	mov	[u.r0], eax
 63598 0001162F A3[84010300]        <1> 	mov	[u.error], eax
 63599 00011634 E8DB0B0000          <1> 	call 	reset_working_path
 63600 00011639 E994B6FFFF          <1> 	jmp	error
 63601                              <1> sysdelete_1:
 63602                              <1> 	;mov	esi, FindFile_Name
 63603 0001163E 66B80018            <1> 	mov	ax, 1800h ; Only files
 63604 00011642 E8CA73FFFF          <1> 	call	find_first_file
 63605 00011647 72E1                <1> 	jc	short sysdelete_err
 63606                              <1> sysdelete_2:
 63607                              <1> 	; check file attributes
 63608                              <1> 
 63609                              <1> 	;test	bl, 17 ; system, hidden, readonly, directory
 63610 00011649 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 63611 0001164C 7407                <1>         jz	short sysdelete_3
 63612                              <1> 
 63613 0001164E B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
 63614 00011653 EBD5                <1>         jmp	short sysdelete_err
 63615                              <1> sysdelete_3:
 63616 00011655 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 63617 00011658 7407                <1> 	jz	short sysdelete_4
 63618 0001165A B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 26 = 'invalid file name !'
 63619 0001165F EBC9                <1>         jmp	short sysdelete_err
 63620                              <1> sysdelete_4:
 63621                              <1> 	;mov	bh, [LongName_EntryLength]
 63622 00011661 883D[AA810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 63623                              <1> 	; edi = Directory Entry Offset (DirBuff)
 63624                              <1> 	; esi = Directory Entry (FFF Structure)
 63625 00011667 E8D89BFFFF          <1> 	call	remove_file
 63626 0001166C 72BC                <1> 	jc	short sysdelete_err
 63627                              <1> sysrmdir_5:
 63628 0001166E 31C0                <1> 	xor	eax, eax ; 0
 63629 00011670 A3[1C010300]        <1> 	mov	[u.r0], eax
 63630                              <1> 	;mov	[u.error], eax
 63631 00011675 E89A0B0000          <1> 	call 	reset_working_path
 63632 0001167A E973B6FFFF          <1> 	jmp	sysret
 63633                              <1> 
 63634                              <1> 
 63635                              <1> sysrmdir: ; Remove (Unlink) Directory
 63636                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 63637                              <1> 	; 19/01/2021
 63638                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 63639                              <1> 	;	
 63640                              <1>         ; INPUT ->
 63641                              <1>         ;          EBX = Pointer to directory name
 63642                              <1> 	; OUTPUT ->
 63643                              <1> 	;          cf = 0 -> eax = 0
 63644                              <1> 	;          cf = 1 -> Error code in AL
 63645                              <1> 	;
 63646                              <1> 	; Modified Registers: EAX (at the return of system call)
 63647                              <1> 	;  
 63648                              <1> 
 63649                              <1> 	; 19/01/2021
 63650 0001167F 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 63651 00011686 7614                <1> 	jna	short sysrmdir_0
 63652                              <1> 
 63653                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 63654 00011688 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; ERR_NOT_SUPERUSER
 63655 0001168D A3[1C010300]        <1> 	mov	[u.r0], eax
 63656 00011692 A3[84010300]        <1> 	mov	[u.error], eax
 63657 00011697 E936B6FFFF          <1> 	jmp	error
 63658                              <1> 
 63659                              <1> sysrmdir_0:
 63660 0001169C 89DE                <1> 	mov	esi, ebx
 63661                              <1> 	; file name is forced, change directory as temporary
 63662                              <1> 	;mov	ax, 1
 63663                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 63664                              <1> 	;call	set_working_path 
 63665 0001169E E89C0A0000          <1> 	call	set_working_path_x
 63666 000116A3 7308                <1> 	jnc	short sysrmdir_1
 63667                              <1> 
 63668 000116A5 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 63669 000116A7 7513                <1> 	jnz	short sysrmdir_err
 63670                              <1> 	; eax = 0
 63671                              <1> sysrmdir_not_found:
 63672                              <1> 	;mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 63673                              <1> 	; 23/07/2022
 63674 000116A9 B00C                <1> 	mov	al, ERR_DIR_NOT_FOUND
 63675 000116AB EB0F                <1> 	jmp	short sysrmdir_err
 63676                              <1> ;sysrmdir_err:
 63677                              <1> ;	mov	[u.r0], eax
 63678                              <1> ;	mov	[u.error], eax
 63679                              <1> ;	call 	reset_working_path
 63680                              <1> ;	jmp	error
 63681                              <1> sysrmdir_1:
 63682                              <1> 	;mov	esi, FindFile_Name
 63683 000116AD 66B81008            <1> 	mov	ax, 0810h ; Only directories
 63684 000116B1 E85B73FFFF          <1> 	call	find_first_file
 63685 000116B6 7318                <1> 	jnc	short sysrmdir_2
 63686                              <1> 
 63687                              <1> 	; eax = 2 (File not found !)
 63688 000116B8 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 63689 000116BA 74ED                <1> 	je	short sysrmdir_not_found
 63690                              <1> 	;jmp	short sysrmdir_err
 63691                              <1> 	; 23/07/2022
 63692                              <1> sysrmdir_err:
 63693 000116BC A3[1C010300]        <1> 	mov	[u.r0], eax
 63694 000116C1 A3[84010300]        <1> 	mov	[u.error], eax
 63695                              <1> sysrmdir_8:	; 23/07/2022
 63696 000116C6 E8490B0000          <1> 	call 	reset_working_path
 63697 000116CB E902B6FFFF          <1> 	jmp	error
 63698                              <1> sysrmdir_2:
 63699                              <1> 	; check directory attributes
 63700                              <1> 
 63701 000116D0 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 63702 000116D3 7407                <1>         jz	short sysrmdir_3
 63703                              <1> 
 63704 000116D5 B80B000000          <1>         mov	eax, ERR_DIR_ACCESS ; 11 = 'permission denied !'
 63705 000116DA EBE0                <1>         jmp	short sysrmdir_err
 63706                              <1> sysrmdir_3:
 63707 000116DC 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 63708 000116DF 7407                <1> 	jz	short sysrmdir_4
 63709                              <1> 	;mov	eax, ERR_NOT_DIR ; 'not a valid directory !'
 63710 000116E1 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 63711 000116E6 EBD4                <1>         jmp	short sysrmdir_err
 63712                              <1> sysrmdir_4:
 63713                              <1> 	;mov	bh, [LongName_EntryLength]
 63714 000116E8 883D[AA810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 63715                              <1> 	; edi = Directory Entry Offset (DirBuff)
 63716                              <1> 	; esi = Directory Entry (FFF Structure)
 63717 000116EE E8BE79FFFF          <1> 	call	delete_sub_directory
 63718                              <1> 	;jnc	sysrmdir_5
 63719                              <1> 	; 23/07/2022
 63720 000116F3 7205                <1> 	jc	short sysrmdir_6
 63721 000116F5 E974FFFFFF          <1> 	jmp	sysrmdir_5
 63722                              <1> 
 63723                              <1> ;	jc	short sysrmdir_6
 63724                              <1> ;
 63725                              <1> ;	xor	eax, eax ; 0
 63726                              <1> ;sysrmdir_5:
 63727                              <1> ;	mov	[u.r0], eax
 63728                              <1> ;	;mov	[u.error], eax
 63729                              <1> ;	call 	reset_working_path
 63730                              <1> ;	jmp	sysret
 63731                              <1> 
 63732                              <1> sysrmdir_6:
 63733 000116FA A3[1C010300]        <1> 	mov	[u.r0], eax
 63734 000116FF A3[84010300]        <1> 	mov	[u.error], eax
 63735                              <1> 
 63736 00011704 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
 63737 00011706 7414                <1> 	jz	short sysrmdir_9
 63738                              <1> 
 63739                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
 63740                              <1> 
 63741 00011708 833D[5E7F0100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
 63742 0001170F 72B5                <1> 	jb	short sysrmdir_8
 63743                              <1> sysrmdir_7:
 63744                              <1> 	; ESI = Logical DOS Drive Description Table address	
 63745 00011711 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
 63746                              <1> 	           ; BL = 0 -> Recalculate free cluster count
 63747 00011715 E873B0FFFF          <1> 	call	calculate_fat_freespace	
 63748                              <1> 	; 23/07/2022
 63749 0001171A EBAA                <1> 	jmp	short sysrmdir_8
 63750                              <1> ;sysrmdir_8:
 63751                              <1> ;	call 	reset_working_path
 63752                              <1> ;	jmp	error
 63753                              <1> 
 63754                              <1> sysrmdir_9:
 63755 0001171C A1[5E7F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 63756 00011721 09C0                <1> 	or	eax, eax ; 0 ?
 63757                              <1> 	;jz	short sysrmdir_err
 63758                              <1> 	; 23/07/2022
 63759 00011723 74A1                <1> 	jz	short sysrmdir_8
 63760                              <1> 
 63761                              <1> 	; ESI = Logical DOS Drive Description Table address	
 63762 00011725 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
 63763                              <1> 	           ; BL = 1 -> add free clusters
 63764 00011729 E85FB0FFFF          <1> 	call	calculate_fat_freespace
 63765 0001172E 09C9                <1> 	or	ecx, ecx
 63766 00011730 7494                <1>         jz	short sysrmdir_8 ; ecx = 0 -> OK
 63767                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
 63768 00011732 EBDD                <1> 	jmp	short sysrmdir_7
 63769                              <1> 
 63770                              <1> 
 63771                              <1> syschdir: ; Change Current (Working) Drive & Directory (for user)
 63772                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 63773                              <1> 	;	
 63774                              <1>         ; INPUT ->
 63775                              <1>         ;          EBX = Directory name (ASCIIZ string) address
 63776                              <1> 	; OUTPUT ->
 63777                              <1> 	;          cf = 0 -> eax = 0
 63778                              <1> 	;          cf = 1 -> Error code in AL
 63779                              <1> 	;
 63780                              <1> 	; Modified Registers: EAX (at the return of system call)
 63781                              <1> 	;
 63782                              <1> 	; NOTE: If drive name is not included, only the working
 63783                              <1> 	; directory (for user, not for drive/OS) will be chanded.
 63784                              <1> 	; If there is a drive name (as A:, B:, C:, D: etc.)
 63785                              <1> 	; at the beginning of the ASCIIZ (directory) string,
 63786                              <1> 	; working drive and working directory (for user) 
 63787                              <1> 	; will be changed together.
 63788                              <1> 	; (When the program is terminated, MainProg -internal 
 63789                              <1> 	; shell- will reset working directory to the previous
 63790                              <1> 	; -current- logical drive's current directory again.) 	
 63791                              <1>   
 63792 00011734 89DE                <1> 	mov	esi, ebx
 63793                              <1> 	; file name is not forced, change directory as temporary
 63794 00011736 31C0                <1> 	xor	eax, eax
 63795                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 63796                              <1> 	;call	set_working_path 
 63797 00011738 E8060A0000          <1> 	call	set_working_path_xx
 63798 0001173D 731D                <1> 	jnc	short syschdir_ok
 63799 0001173F 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 63800 00011741 7505                <1> 	jnz	short syschdir_err
 63801                              <1> 	; eax = 0
 63802                              <1> syschdir_not_found:
 63803 00011743 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 63804                              <1> syschdir_err:
 63805 00011748 A3[1C010300]        <1> 	mov	[u.r0], eax
 63806 0001174D A3[84010300]        <1> 	mov	[u.error], eax
 63807 00011752 E8BD0A0000          <1> 	call 	reset_working_path
 63808 00011757 E976B5FFFF          <1> 	jmp	error
 63809                              <1> syschdir_ok:
 63810 0001175C 31C0                <1> 	xor	eax, eax ; 0
 63811 0001175E A3[1C010300]        <1> 	mov	[u.r0], eax
 63812                              <1> 	;mov	[u.error], eax
 63813 00011763 E98AB5FFFF          <1> 	jmp	sysret
 63814                              <1> 
 63815                              <1> 
 63816                              <1> syschmod: ; Get & Change File (or Directory) Attributes
 63817                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 63818                              <1> 	; 19/01/2021
 63819                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 63820                              <1> 	;	
 63821                              <1>         ; INPUT ->
 63822                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 63823                              <1> 	;	    CL = New attributes (if CL < 40h)
 63824                              <1> 	;	    CL >= 40h -> Get File Attributes		
 63825                              <1> 	; OUTPUT ->
 63826                              <1> 	;          cf = 0 -> EAX = File attributes (in AL)
 63827                              <1> 	;          cf = 1 -> Error code in AL
 63828                              <1> 	;
 63829                              <1> 	; Modified Registers: EAX (at the return of system call)
 63830                              <1> 	;  
 63831                              <1> 	; MSDOS File Attributes:    (bit value of attrib byte)
 63832                              <1> 	;	ATTR_READ_ONLY	=	01h  (bit 0, 'R')
 63833                              <1> 	;	ATTR_HIDDEN	=	02h  (bit 1, 'H')
 63834                              <1> 	;	ATTR_SYSTEM	=	04h  (bit 2, 'S')
 63835                              <1> 	;	ATTR_VOLUME_ID	=	08h  (bit 3)
 63836                              <1> 	;	ATTR_DIRECTORY	=	10h  (bit 4)
 63837                              <1> 	;	ATTR_ARCHIVE	=	20h  (bit 5, 'A')
 63838                              <1> 	;	ATTR_LONG_NAME	=	ATTR_READONLY |
 63839                              <1> 	;				ATTR_HIDDEN |
 63840                              <1> 	;				ATTR_SYSTEM |
 63841                              <1> 	;				ATTR_VOLUME_ID				
 63842                              <1> 	;	The upper two bits of attributes must be 0.
 63843                              <1> 
 63844                              <1> 	; Note:	* If ATTR_DIRECTORY is set, only directory names
 63845                              <1> 	;	  will be searched (and S,H,R,A attributeds of 
 63846                              <1> 	;	  the directory will be changed.)
 63847                              <1> 	;	* If ATTR_VOLUME_ID is set, 'syschmod' system call
 63848                              <1> 	;	  will return with 'permission denied' error.
 63849                              <1> 	;	* If ATTR_DIRECTORY is not set, only file names
 63850                              <1> 	;	  will be searched (and S,H,R,A attributes of the
 63851                              <1> 	;	  file will be changed.)
 63852                              <1> 	;
 63853                              <1> 	; (Ony Super User can change S,H,R attributes.) 
 63854                              <1> 
 63855 00011768 80F940              <1> 	cmp	cl, 40h	
 63856 0001176B 7327                <1> 	jnb	short syschmod_0
 63857                              <1> 
 63858 0001176D F6C108              <1> 	test	cl, 08h ; ATTR_VOLUME_ID
 63859 00011770 750E                <1> 	jnz	short syschmod_perm_err
 63860                              <1> 
 63861                              <1> 	; 19/01/2021
 63862 00011772 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 63863 00011779 7619                <1> 	jna	short syschmod_0
 63864                              <1> 
 63865                              <1> 	; Not super user..
 63866 0001177B F6C107              <1> 	test	cl, 07h	; S,H,R attributes
 63867 0001177E 7414                <1> 	jz	short syschmod_0
 63868                              <1> 
 63869                              <1> syschmod_perm_err:
 63870                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 63871 00011780 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 63872 00011785 A3[1C010300]        <1> 	mov	[u.r0], eax
 63873 0001178A A3[84010300]        <1> 	mov	[u.error], eax
 63874 0001178F E93EB5FFFF          <1> 	jmp	error
 63875                              <1> 
 63876                              <1> syschmod_0:
 63877 00011794 880D[F8810100]      <1> 	mov	[Attributes], cl
 63878 0001179A 89DE                <1> 	mov	esi, ebx
 63879                              <1> 	; file name is forced, change directory as temporary
 63880                              <1> 	;mov	ax, 1
 63881                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 63882                              <1> 	;call	set_working_path 
 63883 0001179C E89E090000          <1> 	call	set_working_path_x
 63884 000117A1 7308                <1> 	jnc	short syschmod_1
 63885 000117A3 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 63886 000117A5 751E                <1> 	jnz	short syschmod_err
 63887                              <1> 	; eax = 0
 63888                              <1> syschmod_path_not_found:
 63889                              <1> 	;mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 63890                              <1> 	; 23/07/2022
 63891 000117A7 B013                <1> 	mov	al, ERR_INV_PATH_NAME
 63892                              <1> ;syschmod_err:
 63893                              <1> 	;mov	[u.r0], eax
 63894                              <1> 	;mov	[u.error], eax
 63895                              <1> 	;call 	reset_working_path
 63896                              <1> 	;jmp	error
 63897                              <1> 	; 23/07/2022
 63898 000117A9 EB1A                <1> 	jmp	short syschmod_err
 63899                              <1> syschmod_1:
 63900 000117AB B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 63901 000117AD A0[F8810100]        <1> 	mov	al, [Attributes]
 63902 000117B2 2410                <1> 	and	al, 10h ;
 63903                              <1> 	;mov	esi, FindFile_Name
 63904                              <1> 	;mov	ax, 1800h ; Only files
 63905                              <1> 	;mov	ax, 0810h ; Only directories
 63906 000117B4 E85872FFFF          <1> 	call	find_first_file
 63907                              <1> 	;jnc	short syschmod_2
 63908 000117B9 720A                <1> 	jc	short syschmod_err
 63909                              <1> 
 63910                              <1> 	;; eax = 2 (File not found !)
 63911                              <1> 	;cmp	al, 2 ; ERR_NOT_FOUND
 63912                              <1> 	;jne	short syschmod_err
 63913                              <1> 
 63914                              <1> 	;and	byte [Attributes], 10h
 63915                              <1> 	;jz	short syschmod_err
 63916                              <1> 
 63917                              <1> 	;; Directory not found !
 63918                              <1> 	;mov	al, 3 ; ERR_PATH_NOT_FOUND
 63919                              <1> 	;jmp	short syschmod_err
 63920                              <1> 
 63921                              <1> syschmod_2:
 63922 000117BB 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 63923 000117BE 7419                <1> 	jz	short syschmod_3
 63924 000117C0 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 63925                              <1>         ;jmp	short syschmod_err
 63926                              <1> syschmod_err:
 63927 000117C5 A3[1C010300]        <1> 	mov	[u.r0], eax
 63928 000117CA A3[84010300]        <1> 	mov	[u.error], eax
 63929 000117CF E8400A0000          <1> 	call 	reset_working_path
 63930 000117D4 E9F9B4FFFF          <1> 	jmp	error
 63931                              <1> syschmod_3:
 63932                              <1> 	; EDI = Directory buffer entry offset/address
 63933                              <1> 	; BL = File (or Directory) Attributes 
 63934                              <1> 	; mov	bl, [EDI+0Bh]
 63935                              <1> 
 63936                              <1> 	; check directory attributes
 63937 000117D9 8A3D[F8810100]      <1> 	mov	bh, [Attributes] ; new attributes
 63938 000117DF 80FF40              <1> 	cmp	bh, 40h  ;>=40 -> get file/directory attributes
 63939 000117E2 732D                <1> 	jnb	short syschmod_6
 63940                              <1> 
 63941                              <1> 	; set file/directory attributes
 63942 000117E4 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 63943 000117E7 7409                <1>         jz	short syschmod_4
 63944                              <1> 
 63945                              <1> 	; 19/01/2021
 63946 000117E9 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 63947 000117F0 778E                <1> 	ja	short syschmod_perm_err
 63948                              <1> syschmod_4:
 63949 000117F2 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 63950 000117F8 7424                <1> 	je	short syschmod_7
 63951                              <1> 
 63952 000117FA 887F0B              <1> 	mov	[edi+0Bh], bh    ; Attributes (New!)
 63953                              <1> 
 63954 000117FD C605[697F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; modified sign
 63955                              <1> 					    ; to force write	
 63956 00011804 E80A97FFFF          <1> 	call 	save_directory_buffer
 63957 00011809 72BA                <1> 	jc	short syschmod_err
 63958                              <1> 
 63959                              <1> syschmod_5:
 63960 0001180B 8A1D[F8810100]      <1> 	mov	bl, [Attributes]
 63961                              <1> syschmod_6:
 63962 00011811 0FB6C3              <1> 	movzx	eax, bl
 63963 00011814 A3[1C010300]        <1> 	mov	[u.r0], eax
 63964                              <1> 	;mov	dword [u.error], 0
 63965 00011819 E9D4B4FFFF          <1> 	jmp	sysret
 63966                              <1> 
 63967                              <1> syschmod_7:
 63968 0001181E 29C0                <1> 	sub	eax, eax
 63969 00011820 8A25[677F0100]      <1>         mov     ah, [DirBuff_DRV]
 63970 00011826 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 63971 0001182B 01C6                <1>         add     esi, eax
 63972 0001182D 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
 63973 00011831 7304                <1> 	jnc	short syschmod_8
 63974 00011833 B01D                <1> 	mov	al, ERR_INV_DATA ; 29 = Invalid Data
 63975 00011835 EB8E                <1> 	jmp	short syschmod_err
 63976                              <1> 
 63977                              <1> syschmod_8:
 63978                              <1> 	; BH = New MS-DOS File Attributes
 63979 00011837 88F8                <1> 	mov	al, bh ; File/Directory Attributes
 63980 00011839 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
 63981 0001183B E8B382FFFF          <1> 	call	change_fs_file_attributes
 63982                              <1> 	;jc	syschmod_err
 63983                              <1> 	;jmp	short syschmod_5
 63984                              <1> 	; 23/07/2022
 63985 00011840 73C9                <1> 	jnc	short syschmod_5
 63986 00011842 EB81                <1> 	jmp	short syschmod_err
 63987                              <1> 
 63988                              <1> 
 63989                              <1> sysdrive: ; Get/Set Current (Working) Drive (for user)
 63990                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 63991                              <1> 	;	
 63992                              <1>         ; INPUT ->
 63993                              <1>         ;          BL = Logical DOS Drive number (0=A: ... 2=C:)
 63994                              <1> 	;	   If BL = 0FFh -> Get Current Drive 	
 63995                              <1> 	; OUTPUT ->
 63996                              <1> 	;          cf = 0 -> 
 63997                              <1> 	;		   AL = Current Drive number	
 63998                              <1> 	;		   AH = The Last Logical DOS Drive no.
 63999                              <1> 	;          cf = 1 -> Error code in AL
 64000                              <1> 	;
 64001                              <1> 	; Modified Registers: EAX (at the return of system call)
 64002                              <1> 	;
 64003                              <1> 	; NOTE: If the requested logical dos drive is ready, 
 64004                              <1> 	;	it's current current directory will be the user's
 64005                              <1> 	;	(program's) current directory.
 64006                              <1> 	;	(When the program is terminated, MainProg -internal 
 64007                              <1> 	;	shell- will reset the previous -current- logical drive
 64008                              <1> 	;       as current drive again).	
 64009                              <1>   
 64010 00011844 80FBFF              <1> 	cmp	bl, 0FFh
 64011 00011847 7435                <1> 	je	short sysdrive_ok
 64012 00011849 3A1D[67300100]      <1> 	cmp	bl, [Last_DOS_DiskNo]
 64013 0001184F 771E                <1> 	ja	short sysdrive_err	
 64014                              <1> 
 64015                              <1> 	; Save current drive and reset mode
 64016                              <1> 	; for 'reset_working_path' procedure (for MainProg)
 64017 00011851 30C0                <1> 	xor	al, al
 64018 00011853 66A3[34840100]      <1> 	mov	[SWP_Mode], ax ; ah = 0
 64019 00011859 A0[42780100]        <1> 	mov	al, [Current_Drv]
 64020 0001185E FEC4                <1> 	inc	ah ; mov ah, 1
 64021 00011860 66A3[36840100]      <1> 	mov	[SWP_DRV], ax 
 64022                              <1> 
 64023 00011866 88DA                <1> 	mov	dl, bl
 64024 00011868 E8F65EFFFF          <1> 	call	change_current_drive
 64025 0001186D 730F                <1> 	jnc	short sysdrive_ok
 64026                              <1> sysdrive_err:
 64027 0001186F C705[1C010300]0F00- <1> 	mov	dword [u.r0], ERR_DRV_NOT_RDY ; 'drive not ready !'
 64028 00011877 0000                <1>
 64029 00011879 E954B4FFFF          <1> 	jmp	error
 64030                              <1> sysdrive_ok:
 64031 0001187E A0[42780100]        <1> 	mov	al, [Current_Drv]
 64032 00011883 8A25[67300100]      <1> 	mov	ah, [Last_DOS_DiskNo]
 64033 00011889 A3[1C010300]        <1> 	mov	[u.r0], eax
 64034 0001188E E95FB4FFFF          <1> 	jmp	sysret
 64035                              <1> 
 64036                              <1> 
 64037                              <1> sysdir: ; Get Current (Working) Drive & Directory (for user)
 64038                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64039                              <1> 	;	
 64040                              <1>         ; INPUT ->
 64041                              <1>         ;          EBX = Current directory name buffer address
 64042                              <1> 	;		(Buffer length = 92 bytes)
 64043                              <1> 	; OUTPUT ->
 64044                              <1> 	;          AL = Current drive (0=A: .. 2=C:)
 64045                              <1> 	;	   If CF = 1 -> AL = error code
 64046                              <1> 	;
 64047                              <1> 	; Modified Registers: EAX (at the return of system call)
 64048                              <1> 	;
 64049                              <1> 	; Note: Required directory name buffer length may be 
 64050                              <1> 	;	<= 92 bytes for current TRDOS 386 version.
 64051                              <1> 	;	(7*12 name chars + 7 slash + 0)
 64052                              <1> 
 64053 00011893 89E5                <1> 	mov	ebp, esp
 64054 00011895 83EC60              <1> 	sub	esp, 96
 64055 00011898 53                  <1> 	push	ebx ; User's buffer address
 64056 00011899 30D2                <1> 	xor	dl, dl ; 0 = current drive
 64057 0001189B E8EC8BFFFF          <1>   	call	get_current_directory
 64058 000118A0 72CD                <1> 	jc	short sysdrive_err ; 'drive not ready !' error
 64059 000118A2 89E6                <1> 	mov	esi, esp ; System's buffer address
 64060 000118A4 5F                  <1> 	pop	edi  ; User's buffer address
 64061                              <1> 	; ecx = transfer (byte) count (<=92)
 64062 000118A5 E883F4FFFF          <1> 	call	transfer_to_user_buffer
 64063 000118AA 89EC                <1> 	mov	esp, ebp
 64064 000118AC 730F                <1> 	jnc	short sysdir_ok
 64065                              <1> sysdir_err:
 64066 000118AE C705[1C010300]2E00- <1> 	mov	dword [u.r0], ERR_BUFFER  ; 'buffer error !'
 64067 000118B6 0000                <1>
 64068 000118B8 E915B4FFFF          <1> 	jmp	error
 64069                              <1> sysdir_ok:	
 64070 000118BD 8A0D[42780100]      <1> 	mov	cl, [Current_Drv]
 64071 000118C3 890D[1C010300]      <1> 	mov	[u.r0], ecx
 64072 000118C9 E924B4FFFF          <1> 	jmp	sysret
 64073                              <1> 
 64074                              <1> 
 64075                              <1> sysldrvt: ; Get copy of Logical DOS Drive Description Table
 64076                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64077                              <1> 	;	
 64078                              <1>         ; INPUT ->
 64079                              <1> 	;	    BL = Logical DOS drive number (zero based)	
 64080                              <1>         ;          ECX = Logical DOS drv desc table buffer addr
 64081                              <1> 	;		(Buffer length = 256 bytes)
 64082                              <1> 	; OUTPUT ->
 64083                              <1> 	;          cf = 0 -> 
 64084                              <1> 	;		   AL = Current Drive number	
 64085                              <1> 	;		   AH = The Last Logical DOS Drive no.
 64086                              <1> 	;          cf = 1 -> Error code in AL
 64087                              <1> 	;		   AH = The Last Logical DOS Drive no.
 64088                              <1> 	;
 64089                              <1> 	; Modified Registers: EAX (at the return of system call)
 64090                              <1> 	;
 64091                              <1> 	; Note: Required description table buffer length is
 64092                              <1> 	;	256 bytes for current TRDOS 386 version.
 64093                              <1> 	
 64094 000118CE 89CF                <1> 	mov	edi, ecx ; Destination address (user space)
 64095 000118D0 88DC                <1> 	mov	ah, bl
 64096 000118D2 30C0                <1> 	xor	al, al
 64097 000118D4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 64098 000118D9 01C6                <1> 	add	esi, eax ; Source address (system space)	 
 64099 000118DB B900010000          <1> 	mov	ecx, 256 ; Byte count 
 64100                              <1> 			 ; Logical Dos Drv Desc Table size
 64101 000118E0 E848F4FFFF          <1> 	call	transfer_to_user_buffer
 64102 000118E5 72C7                <1> 	jc	short sysdir_err
 64103 000118E7 8A2D[67300100]      <1> 	mov	ch, [Last_DOS_DiskNo]
 64104 000118ED EBCE                <1> 	jmp	short sysdir_ok
 64105                              <1> 
 64106                              <1> 
 64107                              <1> systime: ; Get System Date&Time
 64108                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64109                              <1> 	;	
 64110                              <1>         ; INPUT -> BL =
 64111                              <1> 	;	    0 = Get Date&Time in Unix/Epoch format
 64112                              <1> 	;	    1 = Get Time in MSDOS format
 64113                              <1> 	;	    2 = Get Date in MSDOS format
 64114                              <1> 	;	    3 = Get Date&Time in MSDOS format
 64115                              <1> 	;	    4 & other values =
 64116                              <1> 	;		System timer ticks will be returned
 64117                              <1> 	;		in EAX and Carry Flag will be set.
 64118                              <1> 	;		(CF will not be set if BL = 4)	 	
 64119                              <1> 	; OUTPUT ->
 64120                              <1> 	;	For BL input = 3
 64121                              <1> 	;          EAX = Current Time (RTC)
 64122                              <1> 	;		AL = Second (DL in MSDOS)
 64123                              <1> 	;		AH = Minute (CL in MSDOS)
 64124                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 64125                              <1> 	;	   EDX = Current System Date (RTC)
 64126                              <1> 	;		DL = Day (DL in MSDOS)
 64127                              <1> 	;		DH = Month (DH in MSDOS)
 64128                              <1> 	;		HW of EDX = Year (CX in MSDOS)	
 64129                              <1> 	;
 64130                              <1> 	;	For BL input = 2
 64131                              <1> 	;	   EAX = Current System Date (RTC)
 64132                              <1> 	;		DL = Day (DL in MSDOS)
 64133                              <1> 	;		DH = Month (DH in MSDOS)
 64134                              <1> 	;		HW of EDX = Year (CX in MSDOS)
 64135                              <1> 	;
 64136                              <1> 	;	For BL input = 1
 64137                              <1> 	;          EAX = Current Time (RTC)
 64138                              <1> 	;		AL = Second (DL in MSDOS)
 64139                              <1> 	;		AH = Minute (CL in MSDOS)
 64140                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 64141                              <1> 	;
 64142                              <1> 	;	For BL input = 0
 64143                              <1> 	;          EAX = Unix (Epoch) Time Ticks/Seconds
 64144                              <1> 	;
 64145                              <1> 	;	For BL input  = 4
 64146                              <1> 	;	   EAX = System timer ticks
 64147                              <1> 	;
 64148                              <1> 	;	If CF = 1 (for other values of BL input)
 64149                              <1> 	;	   EAX = System timer ticks (no error code!)	
 64150                              <1> 	;		
 64151                              <1> 	; Modified Registers: EAX, (EDX)
 64152                              <1> 	;		 (at the return of system call)
 64153                              <1> 	;
 64154                              <1> 
 64155 000118EF 20DB                <1> 	and	bl, bl
 64156 000118F1 750F                <1> 	jnz	short systime_1
 64157 000118F3 E88754FFFF          <1> 	call	epoch
 64158                              <1> systime_0:
 64159 000118F8 A3[1C010300]        <1> 	mov	[u.r0], eax
 64160 000118FD E9F0B3FFFF          <1> 	jmp	sysret
 64161                              <1> systime_1:
 64162 00011902 80FB04              <1> 	cmp	bl, 4
 64163 00011905 7211                <1> 	jb	short systime_2
 64164 00011907 A1[00780100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 64165                              <1> 				; Note: [TIMER_LH] may be set
 64166                              <1> 				; to wrong timer value due to
 64167                              <1> 				; program functions.
 64168                              <1> 				; (This value must not be
 64169                              <1> 				; accepted as [TIMER_LH]/18.2
 64170                              <1> 				; seconds since the midnight.)
 64171 0001190C 76EA                <1> 	jna	short systime_0
 64172 0001190E A3[1C010300]        <1> 	mov	[u.r0], eax	
 64173 00011913 E9BAB3FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 64174                              <1> 
 64175                              <1> systime_2:
 64176                              <1> 	;push	ebx
 64177 00011918 E8DC53FFFF          <1> 	call	get_rtc_date_time
 64178                              <1> 	;pop	ebx
 64179 0001191D F6C301              <1> 	test	bl, 1
 64180 00011920 7429                <1> 	jz	short systime_4
 64181 00011922 30E4                <1> 	xor	ah, ah
 64182 00011924 A0[4A740100]        <1> 	mov	al, [hour]
 64183 00011929 88C2                <1> 	mov	dl, al
 64184 0001192B C1E010              <1> 	shl	eax, 16
 64185 0001192E A0[4E740100]        <1> 	mov	al, [second]
 64186 00011933 8A25[4C740100]      <1> 	mov	ah, [minute]
 64187 00011939 F6C302              <1> 	test	bl, 2
 64188 0001193C 74BA                <1> 	jz	short systime_0
 64189                              <1> 	; Check time & date match risk 
 64190                              <1> 	; (23:59:59 may cause to wrong
 64191                              <1> 	; date -new day with previous date-...)
 64192 0001193E 80FA17              <1> 	cmp	dl, 23
 64193 00011941 7206                <1> 	jb	short systime_3
 64194 00011943 663D3B3B            <1> 	cmp	ax, (59*256)+59 ; if hour is 23:59:59
 64195 00011947 73CF                <1> 	jnb	short systime_2 ; wait for 1 second
 64196                              <1> systime_3:
 64197                              <1> 	; eax = time
 64198 00011949 89C6                <1> 	mov	esi, eax
 64199                              <1> systime_4:	
 64200 0001194B 66A1[44740100]      <1> 	mov	ax, [year]
 64201 00011951 C1E010              <1> 	shl	eax, 16
 64202 00011954 A0[48740100]        <1> 	mov	al, [day]
 64203 00011959 8A25[46740100]      <1> 	mov	ah, [month]
 64204                              <1> 	; eax = date
 64205 0001195F 80E301              <1> 	and	bl, 1
 64206 00011962 7494                <1> 	jz	short systime_0
 64207 00011964 96                  <1> 	xchg	esi, eax
 64208                              <1> 	; eax = time, esi = date
 64209 00011965 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 64210                              <1> 	; (user) edx <-- (system) esi
 64211 0001196B 897514              <1> 	mov	[ebp+20], esi ; return to user with EDX value 
 64212 0001196E EB88                <1> 	jmp	short systime_0
 64213                              <1> 
 64214                              <1> 
 64215                              <1> sysstime: ; Set System Date&Time
 64216                              <1> 	; 31/12/2017
 64217                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64218                              <1> 	;	
 64219                              <1>         ; INPUT -> BL =
 64220                              <1> 	;	    0 = Set Date&Time in Unix/Epoch format
 64221                              <1> 	;	    1 = Set Time in MSDOS format
 64222                              <1> 	;	    2 = Set Date in MSDOS format
 64223                              <1> 	;	    3 = Set Date&Time in MSDOS format
 64224                              <1> 	;	    4 = Set System Timer (Ticks)
 64225                              <1> 	;	    5 = Convert/Save current time to/as
 64226                              <1> 	;		18.2 Hz system timer ticks
 64227                              <1> 	;	    6 = Convert MSDOS Date&Time to UNIX format
 64228                              <1> 	;		without setting system date&time ; (test)
 64229                              <1> 	;	    7 = Convert UNIX Date&Time to MSDOS format
 64230                              <1> 	;		without setting system date&time ; (test)
 64231                              <1> 	;	   8-0FFh = invalid !
 64232                              <1> 	;	  ECX = Time (or Timer) value in selected format  	
 64233                              <1> 	;	  EDX = Date value in MSDOS format if BL=2,3,6	
 64234                              <1> 	; 	
 64235                              <1> 	; OUTPUT ->
 64236                              <1> 	;	If CF = 0 ->
 64237                              <1> 	;          EAX = Set value
 64238                              <1> 	;	If CF = 1 -> (invalid BL input)
 64239                              <1> 	;	   EAX = Ticks count [TIMER_LH]	
 64240                              <1> 	;
 64241                              <1> 
 64242 00011970 20DB                <1> 	and	bl, bl ; 0
 64243 00011972 7511                <1> 	jnz	short sysstime_0
 64244 00011974 89C8                <1> 	mov	eax, ecx
 64245 00011976 E88954FFFF          <1> 	call	convert_from_epoch
 64246 0001197B E82955FFFF          <1> 	call	set_rtc_date_time
 64247 00011980 E96DB3FFFF          <1> 	jmp	sysret
 64248                              <1> sysstime_0:
 64249 00011985 80FB08              <1> 	cmp	bl, 8
 64250 00011988 722D                <1> 	jb	short sysstime_1
 64251                              <1> 	; invalid input (>7)
 64252 0001198A A1[00780100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 64253                              <1> 				; Note: [TIMER_LH] may be set
 64254                              <1> 				; to wrong timer value due to
 64255                              <1> 				; program functions.
 64256                              <1> 				; (This value must not be
 64257                              <1> 				; accepted as [TIMER_LH]/18.2
 64258                              <1> 				; seconds since the midnight.)
 64259 0001198F A3[1C010300]        <1> 	mov	[u.r0], eax	
 64260 00011994 E939B3FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 64261                              <1> 
 64262                              <1> sysstime_8:	
 64263                              <1> 	; BL = 7
 64264 00011999 89C8                <1> 	mov	eax, ecx ; seconds since 1/1/1970 00:00:00
 64265 0001199B E86454FFFF          <1> 	call	convert_from_epoch
 64266 000119A0 30E4                <1> 	xor	ah, ah
 64267 000119A2 A0[4A740100]        <1> 	mov	al, [hour]
 64268 000119A7 C1E010              <1> 	shl	eax, 16
 64269 000119AA A0[4E740100]        <1> 	mov	al, [second]
 64270 000119AF 8A25[4C740100]      <1> 	mov	ah, [minute]
 64271 000119B5 EB92                <1> 	jmp	short systime_3
 64272                              <1> 
 64273                              <1> sysstime_1:
 64274 000119B7 80FB04              <1> 	cmp	bl, 4
 64275 000119BA 743F                <1> 	je	short sysstime_2 ; set system timer ticks	
 64276 000119BC 80FB05              <1> 	cmp	bl, 5
 64277 000119BF 754B                <1> 	jne	short sysstime_4
 64278                              <1> 	; convert current time to system timer ticks (18.2Hz)
 64279 000119C1 E83353FFFF          <1> 	call	get_rtc_date_time
 64280 000119C6 0FB60D[4A740100]    <1> 	movzx	ecx, byte [hour]
 64281 000119CD B8100E0000          <1> 	mov	eax, 60*60 ; 1 hour = 3600 seconds
 64282 000119D2 F7E1                <1> 	mul	ecx
 64283 000119D4 89C3                <1> 	mov	ebx, eax	
 64284 000119D6 B13C                <1> 	mov	cl, 60  ; 1 minute = 60 seconds
 64285 000119D8 0FB605[4C740100]    <1> 	movzx	eax, byte [minute]
 64286 000119DF F7E1                <1> 	mul	ecx
 64287 000119E1 01D8                <1> 	add	eax, ebx  
 64288 000119E3 8A0D[4E740100]      <1> 	mov	cl, [second]
 64289 000119E9 01C8                <1> 	add	eax, ecx
 64290 000119EB B1B6                <1> 	mov	cl, 182
 64291 000119ED F7E1                <1> 	mul	ecx
 64292 000119EF 83C009              <1> 	add	eax, 9
 64293 000119F2 83D200              <1> 	adc	edx, 0
 64294 000119F5 B10A                <1> 	mov	cl, 10
 64295 000119F7 F7F1                <1> 	div	ecx
 64296                              <1> 	; eax = ((182*seconds)+9)/10
 64297 000119F9 89C1                <1> 	mov	ecx, eax
 64298                              <1> sysstime_2:
 64299 000119FB 890D[00780100]      <1> 	mov	[TIMER_LH], ecx ; 18.2 * seconds
 64300                              <1> sysstime_3:
 64301 00011A01 890D[1C010300]      <1> 	mov	[u.r0], ecx
 64302 00011A07 E9E6B2FFFF          <1> 	jmp	sysret
 64303                              <1> sysstime_4:
 64304 00011A0C 80FB06              <1> 	cmp	bl, 6
 64305 00011A0F 7788                <1> 	ja	short sysstime_8
 64306                              <1> 
 64307 00011A11 890D[1C010300]      <1> 	mov	[u.r0], ecx
 64308                              <1> 
 64309 00011A17 880D[4E740100]      <1> 	mov	[second], cl
 64310 00011A1D 882D[4C740100]      <1> 	mov	[minute], ch
 64311 00011A23 C1E910              <1> 	shr	ecx, 16
 64312 00011A26 880D[4A740100]      <1> 	mov	[hour], cl
 64313                              <1> 	; BL = 1,2,3,6
 64314 00011A2C 80FB01              <1> 	cmp	bl, 1
 64315 00011A2F 762A                <1> 	jna	short sysstime_5
 64316                              <1> 	; BL = 2,3,6
 64317 00011A31 8815[48740100]      <1> 	mov	[day], dl
 64318 00011A37 8835[46740100]      <1> 	mov	[month], dh
 64319 00011A3D C1EA10              <1> 	shr	edx, 16
 64320 00011A40 668915[44740100]    <1> 	mov	[year], dx
 64321 00011A47 80E303              <1> 	and	bl, 3
 64322 00011A4A 742D                <1> 	jz	short sysstime_7 ; 6
 64323                              <1> 	; BL = 2,3
 64324 00011A4C F6C301              <1> 	test	bl, 1
 64325 00011A4F 7419                <1> 	jz	short sysstime_6 ; 2
 64326                              <1> 	; BL = 3
 64327 00011A51 E85354FFFF          <1> 	call	set_rtc_date_time
 64328 00011A56 E997B2FFFF          <1> 	jmp	sysret
 64329                              <1> sysstime_5:
 64330                              <1> 	; BL = 1
 64331 00011A5B E88A54FFFF          <1> 	call	set_time_bcd
 64332 00011A60 E89647FFFF          <1> 	call	set_rtc_time
 64333 00011A65 E988B2FFFF          <1> 	jmp	sysret	
 64334                              <1> sysstime_6:
 64335                              <1> 	; BL = 2
 64336 00011A6A E84E54FFFF          <1> 	call	set_date_bcd
 64337 00011A6F E8EA47FFFF          <1> 	call	set_rtc_date
 64338 00011A74 E979B2FFFF          <1> 	jmp	sysret
 64339                              <1> sysstime_7:
 64340                              <1> 	; BL = 6
 64341                              <1> 	; [year], [month], [day], 
 64342                              <1> 	; [hour], [minute], [second]
 64343 00011A79 E80653FFFF          <1> 	call	convert_to_epoch
 64344 00011A7E 89C1                <1> 	mov	ecx, eax ; seconds since 1/1/1970 00:00:00
 64345 00011A80 E97CFFFFFF          <1> 	jmp	sysstime_3
 64346                              <1> 
 64347                              <1> sysrename: ; Rename File (or Directory)
 64348                              <1> 	; 08/08/2022
 64349                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 64350                              <1> 	; 19/01/2021
 64351                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64352                              <1> 	;	
 64353                              <1>         ; INPUT ->
 64354                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 64355                              <1> 	;	   ECX = New name (in same dir, no path name)			
 64356                              <1> 	; OUTPUT ->
 64357                              <1> 	;          cf = 0 -> EAX = 0
 64358                              <1> 	;          cf = 1 -> Error code in AL
 64359                              <1> 
 64360                              <1> 	; 19/01/2021
 64361 00011A85 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 64362                              <1> 	;jna	short sysrename_0
 64363                              <1> 	; 23/07/2022
 64364 00011A8C 7717                <1> 	ja	short sysrename_perm_err
 64365                              <1> 
 64366                              <1> ;sysrename_perm_err:
 64367                              <1> ;	;mov	dword [u.r0], ERR_PERM_DENIED
 64368                              <1> ;	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 64369                              <1> ;	mov	[u.r0], eax
 64370                              <1> ;	mov	[u.error], eax
 64371                              <1> ;	jmp	error
 64372                              <1> 
 64373                              <1> sysrename_0:
 64374 00011A8E 51                  <1> 	push	ecx ; new file name address (in user space)
 64375 00011A8F 89DE                <1> 	mov	esi, ebx
 64376                              <1> 	; file name is forced, change directory as temporary
 64377                              <1> 	;mov	ax, 1
 64378                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 64379                              <1> 	;call	set_working_path 
 64380 00011A91 E8A9060000          <1> 	call	set_working_path_x
 64381 00011A96 7321                <1> 	jnc	short sysrename_1
 64382 00011A98 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 64383 00011A9A 753B                <1> 	jnz	short sysrename_err
 64384                              <1> 	; eax = 0
 64385                              <1> sysrename_path_not_found:
 64386 00011A9C B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 64387                              <1> 	; 23/07/2022
 64388 00011AA1 B013                <1> 	mov	al, ERR_INV_PATH_NAME
 64389 00011AA3 EB32                <1> 	jmp	short sysrename_err
 64390                              <1> ;sysrename_err:
 64391                              <1> ;	pop	ecx ; new file name address (in user space)
 64392                              <1> ;sysrename_error:
 64393                              <1> ;	mov	[u.r0], eax
 64394                              <1> ;	mov	[u.error], eax
 64395                              <1> ;	call 	reset_working_path
 64396                              <1> ;	jmp	error
 64397                              <1> 	
 64398                              <1> 	; 23/07/2022
 64399                              <1> sysrename_perm_err:
 64400                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 64401 00011AA5 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 64402 00011AAA A3[1C010300]        <1> 	mov	[u.r0], eax
 64403 00011AAF A3[84010300]        <1> 	mov	[u.error], eax
 64404 00011AB4 E919B2FFFF          <1> 	jmp	error
 64405                              <1> 
 64406                              <1> sysrename_1:
 64407 00011AB9 B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 64408 00011ABB A0[F8810100]        <1> 	mov	al, [Attributes]
 64409 00011AC0 2410                <1> 	and	al, 10h ;
 64410                              <1> 	;mov	esi, FindFile_Name
 64411                              <1> 	;mov	ax, 1800h ; Only files
 64412                              <1> 	;mov	ax, 0810h ; Only directories
 64413 00011AC2 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 64414 00011AC6 E8466FFFFF          <1> 	call	find_first_file
 64415                              <1> 	;jnc	short sysrename_2
 64416 00011ACB 720A                <1> 	jc	short sysrename_err
 64417                              <1> sysrename_2:
 64418                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 64419                              <1> 	; EDI = Directory Buffer Directory Entry Location
 64420                              <1> 	; EAX = File Size
 64421                              <1> 	;  BL = Attributes of The File/Directory
 64422                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 64423                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 64424                              <1> 
 64425 00011ACD 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 64426 00011AD0 741A                <1> 	jz	short sysrename_3
 64427 00011AD2 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 64428                              <1> 	;jmp	short sysrename_err
 64429                              <1> 	; 23/07/2022	
 64430                              <1> sysrename_err:
 64431 00011AD7 59                  <1> 	pop	ecx ; new file name address (in user space)
 64432                              <1> sysrename_error:
 64433 00011AD8 A3[1C010300]        <1> 	mov	[u.r0], eax
 64434 00011ADD A3[84010300]        <1> 	mov	[u.error], eax
 64435 00011AE2 E82D070000          <1> 	call 	reset_working_path
 64436 00011AE7 E9E6B1FFFF          <1> 	jmp	error
 64437                              <1> sysrename_3:
 64438                              <1> 	; EDI = Directory buffer entry offset/address
 64439                              <1> 	; BL = File (or Directory) Attributes 
 64440                              <1> 	; mov	bl, [EDI+0Bh]
 64441                              <1> 
 64442 00011AEC 5A                  <1> 	pop	edx ; new file name address (in user space)
 64443                              <1> 
 64444                              <1> 	; check file/directory attributes
 64445 00011AED F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 64446 00011AF0 75B3                <1>         jnz	short sysrename_perm_err
 64447                              <1> sysrename_4:
 64448 00011AF2 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 64449 00011AF8 74AB                <1> 	je	short sysrename_perm_err ; -temporary!-
 64450                              <1> 
 64451                              <1> 	; save old file name & file info (FFF structure)
 64452 00011AFA BE[E2800100]        <1> 	mov	esi, FindFile_Drv
 64453 00011AFF BF[28820100]        <1> 	mov	edi, SourceFile_Drv
 64454                              <1> 	;mov	ecx, 128/4
 64455                              <1> 	; 23/07/2022
 64456 00011B04 29C9                <1> 	sub	ecx, ecx
 64457 00011B06 B120                <1> 	mov	cl, 128/4
 64458 00011B08 F3A5                <1> 	rep	movsd
 64459                              <1> 
 64460 00011B0A 89D6                <1> 	mov	esi, edx ; new file name address (in user space)
 64461 00011B0C BF[A8820100]        <1> 	mov	edi, DestinationFile_Drv
 64462 00011B11 E8C18FFFFF          <1> 	call	parse_path_name
 64463 00011B16 72C0                <1> 	jc	short sysrename_error ; eax = 1 (Bad file name)
 64464                              <1> 
 64465                              <1> 	; same drive ? 
 64466 00011B18 A0[E2800100]        <1> 	mov	al, [FindFile_Drv]
 64467 00011B1D 3A05[A8820100]      <1> 	cmp	al, [DestinationFile_Drv]
 64468                              <1> 	;jne	short sysrename_perm_err ; Permission denied
 64469 00011B23 7509                <1> 	jne	short sysrename_5 ; Bad file name
 64470                              <1>  
 64471                              <1> 	; no path name !? (rename file in same directory)
 64472 00011B25 803D[A9820100]20    <1> 	cmp	byte [DestinationFile_Directory], 20h
 64473 00011B2C 7607                <1> 	jna	short sysrename_6
 64474                              <1> sysrename_5:
 64475 00011B2E B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 1 = Bad file name 
 64476                              <1> 				     ; (Bad argument)
 64477 00011B33 EBA3                <1> 	jmp	short sysrename_error
 64478                              <1> sysrename_6:
 64479 00011B35 803D[EA820100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
 64480 00011B3C 76F0                <1> 	jna	short sysrename_5
 64481                              <1> 
 64482 00011B3E BE[EA820100]        <1> 	mov	esi, DestinationFile_Name
 64483 00011B43 E86E72FFFF          <1> 	call	check_filename ; is it a valid msdos file name?
 64484 00011B48 728E                <1> 	jc	short sysrename_error ; 26 = ERR_INV_FILE_NAME 
 64485                              <1> 	
 64486                              <1> 	;mov	esi, DestinationFile_Name
 64487 00011B4A 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 64488 00011B4E E8BE6EFFFF          <1> 	call	find_first_file
 64489 00011B53 720A                <1> 	jc	short sysrename_7
 64490                              <1> 	
 64491 00011B55 B80E000000          <1> 	mov	eax, ERR_FILE_EXISTS  ; file already exists !
 64492                              <1> jmp_sysrename_err:	; 08/08/2022
 64493 00011B5A E979FFFFFF          <1> 	jmp	sysrename_error
 64494                              <1> sysrename_7:
 64495                              <1> 	; eax = 2 (File not found !)
 64496 00011B5F 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 64497                              <1> 	;jne	short sysrename_error
 64498                              <1> 	; 08/08/2022
 64499 00011B61 75F7                <1> 	jne	short jmp_sysrename_err
 64500                              <1> 
 64501                              <1> 	; 31/12/2017
 64502                              <1> 	; Following code is also part of 'rename_file' in
 64503                              <1> 	; 'trdosk3.s' (MainProg's 'rename' command) ; 13/11/2017
 64504 00011B63 BE[EA820100]        <1> 	mov	esi, DestinationFile_Name ; (Rename_NewName)
 64505 00011B68 668B0D[A2820100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
 64506 00011B6F 66A1[8E820100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
 64507 00011B75 C1E010              <1> 	shl	eax, 16
 64508 00011B78 66A1[94820100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
 64509 00011B7E 0FB61D[77820100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
 64510 00011B85 E85597FFFF          <1>    	call	rename_directory_entry
 64511                              <1> 	;jc	short sysrename_error
 64512                              <1> 	; 08/08/2022
 64513 00011B8A 72CE                <1> 	jc	short jmp_sysrename_err
 64514                              <1> 	;xor	eax, eax
 64515 00011B8C A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 64516                              <1> 	;mov	[u.error], eax
 64517 00011B91 E87E060000          <1> 	call 	reset_working_path
 64518 00011B96 E957B1FFFF          <1> 	jmp	sysret
 64519                              <1> 
 64520                              <1> sysmem: ; Get Total&Free Memory amount 
 64521                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64522                              <1> 	;	
 64523                              <1>         ; INPUT -> 
 64524                              <1> 	;	none	
 64525                              <1> 	; OUTPUT ->
 64526                              <1> 	;	EAX = Total memory count (in bytes)
 64527                              <1> 	;	EBX = Virtually available memory amount (in bytes)
 64528                              <1> 	;	      = 4GB - CORE (4MB)	
 64529                              <1> 	;	ECX = Free memory count (in bytes)
 64530                              <1> 	;	EDX = Calculated free memory count (in bytes)
 64531                              <1> 	
 64532 00011B9B A1[84770100]        <1> 	mov	eax, [memory_size] ; in pages
 64533 00011BA0 C1E00C              <1> 	shl	eax, 12		   ; in bytes
 64534 00011BA3 A3[1C010300]        <1> 	mov	[u.r0], eax
 64535 00011BA8 E8C825FFFF          <1> 	call	calc_free_mem
 64536                              <1> 	; edx = calculated free pages
 64537                              <1> 	; ecx = 0
 64538 00011BAD 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 64539 00011BB3 C745100000C0FF      <1> 	mov	dword [ebp+16], ECORE ; EBX (for user)
 64540                              <1> 				; 0FFC00000h ; 4GB - 4MB
 64541 00011BBA C1E20C              <1> 	shl	edx, 12
 64542 00011BBD 895514              <1> 	mov	[ebp+20], edx ; EDX (for user)
 64543 00011BC0 8B0D[88770100]      <1> 	mov 	ecx, [free_pages]
 64544 00011BC6 C1E10C              <1> 	shl	ecx, 12	; free bytes
 64545 00011BC9 894D18              <1> 	mov	[ebp+24], ecx ; ECX (for user)
 64546                              <1> 	;mov	[free_pages], edx	
 64547 00011BCC E921B1FFFF          <1> 	jmp	sysret
 64548                              <1> 
 64549                              <1> sysprompt:
 64550                              <1> 	; Set TRDOS 386 Command Interpreter (MainProg) prompt 
 64551                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 64552                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64553                              <1> 	;	
 64554                              <1>         ; INPUT -> 
 64555                              <1> 	;	EBX = 0 -> use default prompt
 64556                              <1> 	;	EBX > 0 -> prompt string (ASCIIZ) address
 64557                              <1> 	;		  (Max. 11 characters except ZERO tail)	
 64558                              <1> 	; OUTPUT ->
 64559                              <1> 	;	(EAX = 0)
 64560                              <1> 	;	CF = 0 -> Successful
 64561                              <1> 	;	CF = 1 -> Failed
 64562                              <1> 
 64563 00011BD1 21DB                <1> 	and	ebx, ebx
 64564 00011BD3 750A                <1> 	jnz	short sysprompt_0
 64565                              <1> 
 64566 00011BD5 E85D68FFFF          <1> 	call	default_command_prompt ; '['+'TRDOS'+']'
 64567 00011BDA E913B1FFFF          <1> 	jmp	sysret
 64568                              <1> 
 64569                              <1> sysprompt_0:
 64570 00011BDF 31C0                <1> 	xor	eax, eax
 64571 00011BE1 A3[1C010300]        <1> 	mov	[u.r0], eax 
 64572 00011BE6 89DE                <1> 	mov	esi, ebx
 64573                              <1> 	;mov	ecx, 12
 64574                              <1> 	; 30/07/2022
 64575 00011BE8 31C9                <1> 	xor	ecx, ecx
 64576 00011BEA B10C                <1> 	mov	cl, 12
 64577 00011BEC 89E5                <1> 	mov	ebp, esp
 64578 00011BEE 29CC                <1> 	sub	esp, ecx
 64579 00011BF0 49                  <1> 	dec	ecx ; 11
 64580 00011BF1 89E7                <1> 	mov	edi, esp
 64581 00011BF3 E87FF1FFFF          <1> 	call	transfer_from_user_buffer
 64582 00011BF8 7211                <1> 	jc	short sysprompt_err
 64583 00011BFA 803E20              <1> 	cmp	byte [esi], 20h
 64584 00011BFD 760C                <1> 	jna	short sysprompt_err
 64585 00011BFF E84568FFFF          <1> 	call	set_command_prompt
 64586 00011C04 89EC                <1> 	mov	esp, ebp
 64587 00011C06 E9E7B0FFFF          <1> 	jmp	sysret
 64588                              <1> sysprompt_err:
 64589                              <1> syspath_err:
 64590 00011C0B 89EC                <1> 	mov	esp, ebp
 64591 00011C0D E9C0B0FFFF          <1> 	jmp	error
 64592                              <1> 
 64593                              <1> syspath:
 64594                              <1> 	; Get/Set Run Path
 64595                              <1> 	;
 64596                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 64597                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64598                              <1> 	;	
 64599                              <1>         ; INPUT -> 
 64600                              <1> 	;	EBX = 0 -> get path (to buffer address in ECX)
 64601                              <1> 	;	EBX > 0 -> set path
 64602                              <1> 	;	    EBX = Path string buffer address (ASCIIZ)
 64603                              <1> 	;	    	  (Path description except 'PATH=')
 64604                              <1> 	;	ECX = Buffer address (if EBX = 0)
 64605                              <1> 	;	      (ECX will not be used if EBX > 0)	
 64606                              <1> 	;	DL = Buffer size (0 = 256 byte)	
 64607                              <1> 	;
 64608                              <1> 	; OUTPUT ->
 64609                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 64610                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 64611                              <1> 	;
 64612                              <1> 	; NOTE: 'PATH=' or 'PATH' must be excluded
 64613                              <1> 	;  (It must not be at the beginning of the string.)
 64614                              <1> 
 64615 00011C12 89E5                <1> 	mov	ebp, esp
 64616 00011C14 81EC00010000        <1> 	sub	esp, 256
 64617 00011C1A 89E7                <1> 	mov	edi, esp
 64618                              <1> 
 64619 00011C1C 31C0                <1> 	xor	eax, eax
 64620 00011C1E A3[1C010300]        <1> 	mov	[u.r0], eax 
 64621                              <1> 	
 64622 00011C23 21DB                <1> 	and	ebx, ebx
 64623 00011C25 752A                <1> 	jnz	short syspath_0
 64624                              <1> 
 64625                              <1> 	; EBX = 0 -> get run path
 64626 00011C27 89CB                <1> 	mov	ebx, ecx ; buffer addr (in user's mem space)
 64627 00011C29 BE[3C310100]        <1> 	mov	esi, Cmd_Path  ; 'PATH' address
 64628 00011C2E 0FB6CA              <1> 	movzx	ecx, dl
 64629                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 64630                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 64631                              <1> 	; 30/07/2022
 64632 00011C31 FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 64633 00011C33 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1 
 64634                              <1> 	; EDI = Output buffer 
 64635                              <1> 	; CX = Buffer length
 64636                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 64637                              <1> 	; ESI = 'PATH' address (with zero tail)
 64638 00011C34 E8807FFFFF          <1> 	call	get_environment_string
 64639 00011C39 72D0                <1> 	jc	short syspath_err
 64640 00011C3B 89DF                <1> 	mov	edi, ebx ; User's buffer address
 64641 00011C3D 89E6                <1> 	mov	esi, esp 
 64642                              <1> 	; EDI = User's buffer address
 64643                              <1> 	; ECX = transfer (byte) count
 64644 00011C3F E8E9F0FFFF          <1> 	call	transfer_to_user_buffer
 64645 00011C44 72C5                <1> 	jc	short syspath_err
 64646 00011C46 890D[1C010300]      <1> 	mov	[u.r0], ecx 
 64647 00011C4C E9A1B0FFFF          <1> 	jmp	sysret
 64648                              <1> 
 64649                              <1> syspath_0:
 64650 00011C51 89DE                <1> 	mov	esi, ebx
 64651 00011C53 0FB6CA              <1> 	movzx	ecx, dl
 64652                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 64653                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 64654                              <1> 	; 30/07/2022
 64655 00011C56 FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 64656 00011C58 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1
 64657 00011C59 E819F1FFFF          <1> 	call	transfer_from_user_buffer
 64658 00011C5E 72AB                <1> 	jc	short syspath_err
 64659                              <1> 	;(*) 'PATH=' will be added to 
 64660                              <1> 	;         the head of the string
 64661 00011C60 83EC08              <1> 	sub	esp, 8 ;(*)
 64662 00011C63 89FE                <1> 	mov	esi, edi ;(*)
 64663 00011C65 E8337FFFFF          <1> 	call	set_path_x ;(*)
 64664 00011C6A 729F                <1> 	jc	short syspath_err
 64665 00011C6C 8915[1C010300]      <1> 	mov	[u.r0], edx ; run path string length
 64666 00011C72 E97BB0FFFF          <1> 	jmp	sysret	
 64667                              <1> 
 64668                              <1> sysenv:
 64669                              <1> 	; Get/Set Environment Variables
 64670                              <1> 	;
 64671                              <1> 	; 30/07/2022
 64672                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 64673                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 64674                              <1> 	;	
 64675                              <1>         ; INPUT -> 
 64676                              <1> 	;	EBX = 0 -> get (all) environment variables
 64677                              <1> 	;	      (Required Buffer length = 512 bytes)
 64678                              <1> 	;	EBX > 0 -> set (one) environment variable
 64679                              <1> 	;	      (If there is not a '=' after
 64680                              <1> 	;	      the environment variable name, it will
 64681                              <1> 	;	      accepted as 'get environment variable'.) 
 64682                              <1> 	;	       EBX = Buffer address
 64683                              <1> 	;	ECX = Buffer address (if EBX = 0)
 64684                              <1> 	;	      (ECX will not be used if EBX > 0)	
 64685                              <1> 	;	      (Note: Buffer size is 512 bytes.)	
 64686                              <1> 	;	DL = Buffer size (0 = 256 byte)
 64687                              <1> 	;	     (For one envrionment variable)		
 64688                              <1> 	;
 64689                              <1> 	; OUTPUT ->
 64690                              <1> 	;	(EAX = 0)
 64691                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 64692                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 64693                              <1> 	;
 64694                              <1> 	; Note: Environment variable name, for example,
 64695                              <1> 	;	'PATH=' must be included at the beginning
 64696                              <1> 	;	of the environment string. If the variable
 64697                              <1> 	;	name is as 'PATH' but it is not as 'PATH='
 64698                              <1> 	;	the variable string (row) will be returned.
 64699                              <1> 	;	If variable name is as 'PATH=' but there is
 64700                              <1> 	;	not a following text after the variable name,
 64701                              <1> 	;	the environment variable will be reset/deleted.
 64702                              <1> 
 64703 00011C77 89E5                <1> 	mov	ebp, esp
 64704 00011C79 81EC00020000        <1> 	sub	esp, 512
 64705 00011C7F 89E7                <1> 	mov	edi, esp
 64706                              <1> 
 64707 00011C81 31C0                <1> 	xor	eax, eax
 64708 00011C83 A3[1C010300]        <1> 	mov	[u.r0], eax 
 64709                              <1> 	
 64710 00011C88 21DB                <1> 	and	ebx, ebx
 64711 00011C8A 751F                <1> 	jnz	short sysenv_0
 64712                              <1> 
 64713                              <1> 	; EBX = 0 -> get (all) environment variables
 64714 00011C8C 89EC                <1> 	mov	esp, ebp
 64715 00011C8E BE00300900          <1> 	mov	esi, Env_Page  ; Environment page
 64716 00011C93 89CF                <1> 	mov	edi, ecx ; buffer addr (in user's mem space)
 64717                              <1> 	;mov	ecx, 512
 64718                              <1> 	; 30/07/2022
 64719 00011C95 29C9                <1> 	sub	ecx, ecx
 64720 00011C97 B502                <1> 	mov	ch, 2
 64721                              <1> 	; ecx = 512
 64722 00011C99 E88FF0FFFF          <1> 	call	transfer_to_user_buffer
 64723                              <1> 	;jc	error
 64724                              <1> 	; 23/07/202
 64725 00011C9E 725B                <1> 	jc	short sysenv_error
 64726 00011CA0 890D[1C010300]      <1> 	mov	[u.r0], ecx 
 64727 00011CA6 E947B0FFFF          <1> 	jmp	sysret
 64728                              <1> 
 64729                              <1> sysenv_0:
 64730 00011CAB 89DE                <1> 	mov	esi, ebx ; * ; user's buffer address
 64731 00011CAD 0FB6CA              <1> 	movzx	ecx, dl
 64732                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 64733                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 64734                              <1> 	; 30/07/2022
 64735 00011CB0 FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 64736 00011CB2 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1
 64737 00011CB3 E8BFF0FFFF          <1> 	call	transfer_from_user_buffer
 64738 00011CB8 723F                <1> 	jc	short sysenv_err
 64739 00011CBA 89FE                <1> 	mov	esi, edi
 64740 00011CBC 8A06                <1> 	mov	al, [esi]
 64741 00011CBE 3C20                <1> 	cmp	al, 20h
 64742 00011CC0 7637                <1> 	jna	short sysenv_err
 64743 00011CC2 3C3D                <1> 	cmp	al, '='
 64744 00011CC4 7433                <1> 	je	short sysenv_err
 64745 00011CC6 56                  <1> 	push	esi
 64746                              <1> sysenv_1:
 64747 00011CC7 46                  <1> 	inc	esi
 64748 00011CC8 803E3D              <1> 	cmp	byte [esi], '='
 64749 00011CCB 7433                <1> 	je	short sysenv_3
 64750 00011CCD 803E20              <1> 	cmp	byte [esi], 20h
 64751 00011CD0 73F5                <1> 	jnb	short sysenv_1
 64752 00011CD2 C60600              <1> 	mov	byte [esi], 0 
 64753 00011CD5 5E                  <1> 	pop	esi
 64754                              <1> 	; EDI = Output buffer 
 64755                              <1> 	; CX = Buffer length
 64756 00011CD6 30C0                <1> 	xor	al, al
 64757                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 64758                              <1> 	; ESI = Environment variable name address
 64759 00011CD8 E8DC7EFFFF          <1> 	call	get_environment_string
 64760 00011CDD 721A                <1> 	jc	short sysenv_err
 64761 00011CDF 89DF                <1> 	mov	edi, ebx ; * ; user's buffer address
 64762 00011CE1 89C1                <1> 	mov	ecx, eax ; String length
 64763 00011CE3 89E6                <1> 	mov	esi, esp 
 64764                              <1> 	; ESI = system buffer address
 64765                              <1> 	; EDI = User's buffer address
 64766                              <1> 	; ECX = transfer (byte) count
 64767 00011CE5 E843F0FFFF          <1> 	call	transfer_to_user_buffer
 64768 00011CEA 720D                <1> 	jc	short sysenv_err
 64769 00011CEC 890D[1C010300]      <1> 	mov	[u.r0], ecx ; transfer (byte) count
 64770                              <1> sysenv_2:
 64771 00011CF2 89EC                <1> 	mov	esp, ebp
 64772 00011CF4 E9F9AFFFFF          <1> 	jmp	sysret
 64773                              <1> sysenv_err:
 64774 00011CF9 89EC                <1> 	mov	esp, ebp
 64775                              <1> sysenv_error:	; 23/07/2022
 64776 00011CFB E9D2AFFFFF          <1> 	jmp	error
 64777                              <1> sysenv_3:
 64778 00011D00 46                  <1> 	inc	esi
 64779 00011D01 803E20              <1> 	cmp	byte [esi], 20h
 64780 00011D04 73FA                <1> 	jnb	short sysenv_3
 64781 00011D06 C60600              <1> 	mov	byte [esi], 0	
 64782 00011D09 5E                  <1> 	pop	esi
 64783 00011D0A E86D7FFFFF          <1> 	call	set_environment_string
 64784 00011D0F 72E8                <1> 	jc	short sysenv_err
 64785 00011D11 8915[1C010300]      <1> 	mov	[u.r0], edx
 64786 00011D17 EBD9                <1> 	jmp	short sysenv_2
 64787                              <1> 
 64788                              <1> ; 23/07/2022 - TRDOS 386 v2.0.5
 64789                              <1> 
 64790                              <1> ; 22/01/2021
 64791                              <1> ; temporary - 24/01/2016
 64792                              <1> 
 64793                              <1> iget:
 64794                              <1> 	;retn
 64795                              <1> isintr:
 64796                              <1> 	;retn
 64797                              <1> iopen:
 64798                              <1> 	;retn
 64799                              <1> iclose:
 64800                              <1> 	;retn
 64801                              <1> sndc:
 64802                              <1> 	;retn
 64803                              <1> access:
 64804                              <1> 	;retn
 64805                              <1> sleep:
 64806 00011D19 C3                  <1> 	retn
 64807                                  %include 'trdosk7.s' ; 24/01/2016
 64808                              <1> ; ****************************************************************************
 64809                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - DISK READ&WRITE : trdosk7.s
 64810                              <1> ; ----------------------------------------------------------------------------
 64811                              <1> ; Last Update: 25/07/2022  (Previous: 25/02/2016 - Kernel v2.0.4)
 64812                              <1> ; ----------------------------------------------------------------------------
 64813                              <1> ; Beginning: 24/01/2016
 64814                              <1> ; ----------------------------------------------------------------------------
 64815                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
 64816                              <1> ; ----------------------------------------------------------------------------
 64817                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 64818                              <1> ; DISK_IO.ASM (20/07/2011)
 64819                              <1> ; ****************************************************************************
 64820                              <1> ; DISK_IO.ASM (c) 2009-2011 Erdogan TAN [ 04/07/2009 ] Last Update: 20/07/2011
 64821                              <1> 
 64822                              <1> disk_write:
 64823                              <1> 	; 25/02/2016
 64824                              <1> 	; 24/02/2016
 64825                              <1> 	; 23/02/2016
 64826 00011D1A 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
 64827 00011D1E 7776                <1>         ja      short lba_write
 64828                              <1> 
 64829                              <1> chs_write:
 64830                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 64831                              <1> 	; 25/02/2016
 64832                              <1> 	; 23/02/2016
 64833 00011D20 C605[31800100]03    <1> 	mov	byte [disk_rw_op], 3 ; CHS write
 64834 00011D27 EB0D                <1> 	jmp	short chs_rw
 64835                              <1> 
 64836                              <1> disk_read:
 64837                              <1> 	; 25/02/2016
 64838                              <1> 	; 24/02/2016
 64839                              <1> 	; 23/02/2016
 64840                              <1> 	; 17/02/2016
 64841                              <1> 	; 14/02/2016
 64842                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
 64843                              <1> 	; 17/10/2010
 64844                              <1> 	; 18/04/2010
 64845                              <1> 	;
 64846                              <1> 	; INPUT -> EAX = Logical Block Address
 64847                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
 64848                              <1> 	;	   ECX = Sector Count	
 64849                              <1> 	; 	   EBX = Destination Buffer
 64850                              <1> 	; OUTPUT -> 
 64851                              <1> 	;	   cf = 0 or cf = 1
 64852                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
 64853                              <1> 
 64854 00011D29 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
 64855 00011D2D 7770                <1>         ja      short lba_read
 64856                              <1> 
 64857                              <1> chs_read:
 64858                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
 64859                              <1> 	; 25/02/2016
 64860                              <1> 	; 24/02/2016
 64861                              <1> 	; 23/02/2016
 64862                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
 64863                              <1> 	; 20/07/2011
 64864                              <1> 	; 04/07/2009
 64865                              <1> 	;
 64866                              <1> 	; INPUT -> EAX = Logical Block Address
 64867                              <1> 	;	   ECX = Number of sectors to read
 64868                              <1> 	; 	   ESI = Logical Dos Disk Table Offset (DRV)
 64869                              <1> 	; 	   EBX = Destination Buffer
 64870                              <1> 	; OUTPUT -> 
 64871                              <1> 	;	   cf = 0 or cf = 1
 64872                              <1> 	; (Modified registers: EAX; EBX, ECX, EDX)
 64873                              <1> 
 64874                              <1> 	; 23/02/2016
 64875 00011D2F C605[31800100]02    <1> 	mov	byte [disk_rw_op], 2 ; CHS read
 64876                              <1> 
 64877                              <1> chs_rw:
 64878                              <1> 	;;movzx	edx, word [esi+LD_BPB+SecPerTrack]
 64879                              <1> 	;movzx	edx, byte [esi+LD_BPB+SecPerTrack] ; <= 63
 64880                              <1> 	;mov	[disk_rw_spt], dl
 64881                              <1> 
 64882                              <1> chs_read_next_sector:
 64883 00011D36 C605[32800100]04    <1> 	mov	byte [retry_count], 4
 64884                              <1>      
 64885                              <1> chs_read_retry:
 64886                              <1> 	;mov	[sector_count], ecx ; 23/02/2016
 64887                              <1> 
 64888 00011D3D 50                  <1> 	push	eax			; Linear sector #
 64889 00011D3E 51                  <1> 	push	ecx			; # of FAT/FILE/DIR sectors
 64890                              <1>                 
 64891 00011D3F 0FB74E1E            <1> 	movzx	ecx, word [esi+LD_BPB+SecPerTrack]
 64892                              <1> 	;movzx	ecx, byte [disk_rw_spt] ; 23/02/2016
 64893 00011D43 29D2                <1> 	sub	edx, edx
 64894 00011D45 F7F1                <1> 	div	ecx
 64895                              <1> 	; eax = track, dx (dl ) = sector (on track)
 64896                              <1> 	;sub	cl, dl ; 24/02/2016 (spt - sec)
 64897                              <1> 	;push	ecx ; *
 64898                              <1> 	; 25/07/2022
 64899                              <1> 	;mov	cx, dx			; Sector (zero based)
 64900                              <1> 	;inc	cx			; To make it 1 based
 64901                              <1> 	;push	cx
 64902 00011D47 89D1                <1> 	mov	ecx, edx
 64903 00011D49 41                  <1> 	inc	ecx
 64904 00011D4A 51                  <1> 	push	ecx
 64905 00011D4B 668B4E20            <1> 	mov	cx, [esi+LD_BPB+Heads]
 64906                              <1> 	;sub	dx, dx
 64907                              <1> 	; 25/07/2022
 64908 00011D4F 29D2                <1> 	sub	edx, edx
 64909 00011D51 F7F1                <1> 	div	ecx			; Convert track to head & cyl
 64910                              <1> 	; eax (ax) = cylinder, dx (dl) = head (max. FFh)
 64911 00011D53 88D6                <1> 	mov	dh, dl
 64912                              <1> 	;pop	cx			; AX=Cyl, DH=Head, CX=Sector
 64913                              <1> 	; 25/07/2022
 64914 00011D55 59                  <1> 	pop	ecx 
 64915 00011D56 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
 64916                              <1> 
 64917 00011D59 88C5                <1> 	mov	ch, al			; NOTE: max. 1023 cylinders !                   
 64918 00011D5B C0CC02              <1> 	ror	ah, 2			; Rotate 2 bits right
 64919 00011D5E 08E1                <1> 	or	cl, ah
 64920                              <1> 
 64921                              <1> 	; 24/02/2016
 64922                              <1> 	;pop	eax ; * (spt - sec) (example: 63 - 0 = 63)
 64923                              <1> 	;cmp	eax, [sector_count]
 64924                              <1> 	;jb	short chs_write_sectors
 64925                              <1> 	;je	short chs_read_sectors
 64926                              <1> 	;; (# of sectors to read is more than remaining sectors on the track)
 64927                              <1> 	;mov	al, [sector_count]
 64928                              <1> ;chs_read_sectors: ; read or write !
 64929 00011D60 B001                <1> 	mov	al, 1 ; 25/02/2016
 64930 00011D62 8A25[31800100]      <1> 	mov	ah, [disk_rw_op]  ; 02h = chs read, 03h = chs write 
 64931                              <1> 	;
 64932 00011D68 E8D031FFFF          <1> 	call	int13h			; BIOS Service func ( ah ) = 2
 64933                              <1>                                         ; Read disk sectors
 64934                              <1>                                         ; AL-sec num CH-track CL-sec
 64935                              <1>                                         ; DH-head DL-drive ES:BX-buffer
 64936                              <1>                                         ; CF-flag AH-stat AL-sec read
 64937                              <1> 	                                ; If CF = 1 then (If AH > 0)
 64938 00011D6D 8825[33800100]      <1> 	mov	[disk_rw_err], ah
 64939                              <1> 	
 64940 00011D73 59                  <1> 	pop	ecx
 64941 00011D74 58                  <1> 	pop	eax
 64942 00011D75 7314                <1> 	jnc	short chs_read_ok
 64943                              <1> 
 64944 00011D77 803D[33800100]09    <1> 	cmp	byte [disk_rw_err], 09h ; DMA crossed 64K segment boundary
 64945 00011D7E 7408                <1> 	je	short chs_read_error_retn
 64946                              <1>              
 64947 00011D80 FE0D[32800100]      <1> 	dec	byte [retry_count]
 64948 00011D86 75B5                <1> 	jnz	short chs_read_retry
 64949                              <1> 
 64950                              <1> chs_read_error_retn:
 64951 00011D88 F9                  <1> 	stc
 64952                              <1> 	;retn
 64953 00011D89 EB67                <1> 	jmp	short update_drv_error_byte
 64954                              <1> 
 64955                              <1> ;chs_write_sectors: ; read or write 
 64956                              <1> 	;; (# of sectors to read is less than remaining sectors on the track)
 64957                              <1> 	;mov	[sector_count], al
 64958                              <1> 	;jmp	short chs_read_sectors
 64959                              <1> 
 64960                              <1> chs_read_ok:
 64961                              <1> 	;; 23/02/2016
 64962                              <1> 	;movzx	edx, byte [sector_count] ; sector count (<= spt)	
 64963                              <1>         ;sub    ecx, edx  ; remaining sector count
 64964                              <1> 	;jna	short update_drv_error_byte	
 64965                              <1> 	;add	eax, edx ; next disk sector
 64966                              <1> 	;shl	edx, 9 ; 512 * sector count
 64967                              <1> 	;add	ebx, edx ; next buffer byte address 
 64968                              <1>         ;jmp	chs_read_next_sector        
 64969                              <1> 	; 25/02/2016
 64970 00011D8B 40                  <1> 	inc	eax ; next sector
 64971 00011D8C 81C300020000        <1> 	add	ebx, 512
 64972 00011D92 E2A2                <1> 	loop	chs_read_next_sector
 64973 00011D94 EB5C                <1> 	jmp	short update_drv_error_byte
 64974                              <1> 
 64975                              <1> lba_write:
 64976                              <1> 	; 23/02/2016
 64977 00011D96 C605[31800100]1C    <1> 	mov	byte [disk_rw_op], 1Ch ; LBA write
 64978 00011D9D EB07                <1> 	jmp	short lba_rw
 64979                              <1> 
 64980                              <1> lba_read:
 64981                              <1> 	; 14/07/2022
 64982                              <1> 	; 23/02/2016
 64983                              <1> 	; 17/02/2016
 64984                              <1> 	; 14/02/2016
 64985                              <1> 	; 13/02/2016
 64986                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
 64987                              <1> 	; 10/07/2015 (Retro UNIX 386 v1)
 64988                              <1> 	;
 64989                              <1> 	; INPUT -> EAX = Logical Block Address
 64990                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
 64991                              <1> 	;	   ECX = Sector Count	
 64992                              <1> 	; 	   EBX = Destination Buffer
 64993                              <1> 	; OUTPUT -> 
 64994                              <1> 	;	   cf = 0 or cf = 1
 64995                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
 64996                              <1> 
 64997                              <1> 	; LBA read/write (with private LBA function) 
 64998                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
 64999                              <1> 
 65000                              <1> 	; 23/02/2016
 65001 00011D9F C605[31800100]1B    <1> 	mov	byte [disk_rw_op], 1Bh ; LBA read
 65002                              <1> 
 65003                              <1> lba_rw:
 65004                              <1> 	; 17/02/2016
 65005 00011DA6 57                  <1> 	push	edi
 65006                              <1> 
 65007 00011DA7 890D[34800100]      <1> 	mov	[sector_count], ecx ; total sector (read) count
 65008                              <1> 
 65009 00011DAD 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
 65010                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
 65011                              <1> 
 65012                              <1> lba_read_next:
 65013                              <1> 	; 14/07/2022
 65014 00011DB0 BF00010000          <1> 	mov	edi, 256
 65015 00011DB5 39F9                <1> 	cmp	ecx, edi
 65016                              <1> 	;cmp	ecx, 256
 65017 00011DB7 7602                <1> 	jna	short lba_read_rsc
 65018                              <1> 	;mov	ecx, 256 ; 17/02/2016
 65019 00011DB9 89F9                <1> 	mov	ecx, edi
 65020                              <1> lba_read_rsc:
 65021 00011DBB 290D[34800100]      <1> 	sub	[sector_count], ecx ; remain sectors
 65022                              <1> 
 65023 00011DC1 89CF                <1> 	mov	edi, ecx 
 65024 00011DC3 89C1                <1> 	mov	ecx, eax ; sector number/address
 65025                              <1> 
 65026 00011DC5 C605[32800100]04    <1> 	mov	byte [retry_count], 4
 65027                              <1> lba_read_retry:
 65028 00011DCC 89F8                <1> 	mov	eax, edi
 65029                              <1> 	;
 65030                              <1> 	; ecx = sector number
 65031                              <1> 	; al = sector count (0 - 255) /// (0 = 256)
 65032                              <1> 	; dl = drive number
 65033                              <1> 	; ebx = buffer offset
 65034                              <1> 	;
 65035                              <1> 	; Function 1Bh = LBA read, 1Ch = LBA write
 65036                              <1> 	; 23/02/2016
 65037 00011DCE 8A25[31800100]      <1> 	mov	ah, [disk_rw_op] ; 1Bh = LBA read, 1Ch = LBA write
 65038 00011DD4 E86431FFFF          <1> 	call	int13h
 65039                              <1> 	; al = ? (changed)
 65040                              <1> 	; ah = error code
 65041 00011DD9 8825[33800100]      <1> 	mov	[disk_rw_err], ah
 65042 00011DDF 7332                <1> 	jnc	short lba_read_ok
 65043 00011DE1 80FC80              <1> 	cmp	ah, 80h ; time out?
 65044 00011DE4 740A                <1>         je      short lba_read_stc_retn
 65045 00011DE6 FE0D[32800100]      <1> 	dec	byte [retry_count]
 65046 00011DEC 7FDE                <1> 	jg	short lba_read_retry
 65047 00011DEE 7438                <1> 	jz	short lba_read_reset
 65048                              <1> 	; sf = 1
 65049                              <1> 
 65050                              <1> lba_read_stc_retn:
 65051 00011DF0 F9                  <1> 	stc
 65052                              <1> lba_read_retn:
 65053 00011DF1 5F                  <1> 	pop	edi
 65054                              <1> 
 65055                              <1> update_drv_error_byte:
 65056 00011DF2 9C                  <1> 	pushf
 65057 00011DF3 53                  <1> 	push	ebx
 65058                              <1> 	;push	cx
 65059 00011DF4 51                  <1> 	push	ecx ; 14/07/2022
 65060                              <1> 	;or	ecx, ecx
 65061                              <1> 	;jz	short udrv_errb0
 65062 00011DF5 8A0D[33800100]      <1> 	mov	cl, [disk_rw_err]
 65063                              <1> udrv_errb0:
 65064 00011DFB 0FB65E02            <1> 	movzx	ebx, byte [esi+LD_PhyDrvNo]
 65065 00011DFF 80FB02              <1> 	cmp	bl, 2
 65066 00011E02 7203                <1>         jb      short udrv_errb1
 65067 00011E04 80EB7E              <1> 	sub	bl, 7Eh
 65068                              <1> 	;cmp	bl, 5
 65069                              <1> 	;ja	short udrv_errb2	
 65070                              <1> udrv_errb1:
 65071 00011E07 81C3[25650000]      <1>         add     ebx, drv.error ; 13/02/2016
 65072 00011E0D 880B                <1> 	mov	[ebx], cl ; error code
 65073                              <1> udrv_errb2:
 65074                              <1> 	;pop	cx
 65075 00011E0F 59                  <1> 	pop	ecx  ; 14/07/2022
 65076 00011E10 5B                  <1> 	pop	ebx
 65077 00011E11 9D                  <1> 	popf
 65078 00011E12 C3                  <1> 	retn
 65079                              <1> 
 65080                              <1> lba_read_ok:
 65081 00011E13 89C8                <1> 	mov	eax, ecx ; sector number
 65082 00011E15 01F8                <1> 	add	eax, edi ; sector number (next)
 65083 00011E17 C1E709              <1> 	shl	edi, 9 ; sector count * 512
 65084 00011E1A 01FB                <1> 	add	ebx, edi ; next buffer offset
 65085                              <1> 
 65086 00011E1C 8B0D[34800100]      <1> 	mov	ecx, [sector_count] ; remaining sectors
 65087 00011E22 09C9                <1> 	or	ecx, ecx
 65088 00011E24 758A                <1> 	jnz	short lba_read_next
 65089 00011E26 EBC9                <1> 	jmp	short lba_read_retn
 65090                              <1> 
 65091                              <1> lba_read_reset:
 65092 00011E28 B40D                <1> 	mov	ah, 0Dh ; Alternate reset
 65093 00011E2A E80E31FFFF          <1>         call	int13h
 65094                              <1> 	; al = ? (changed)
 65095                              <1> 	; ah = error code
 65096 00011E2F 739B                <1> 	jnc	short lba_read_retry
 65097 00011E31 EBBE                <1> 	jmp	short lba_read_retn
 65098                                  %include 'trdosk8.s' ; 24/01/2016
 65099                              <1> ; ****************************************************************************
 65100                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - MAIN PROGRAM : trdosk8.s
 65101                              <1> ; ----------------------------------------------------------------------------
 65102                              <1> ; Last Update: 09/08/2022  (Previous: 17/04/2021)
 65103                              <1> ; ----------------------------------------------------------------------------
 65104                              <1> ; Beginning: 24/01/2016
 65105                              <1> ; ----------------------------------------------------------------------------
 65106                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 65107                              <1> ; ----------------------------------------------------------------------------
 65108                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 65109                              <1> ; u0.s (20/11/2015), u4.s (14/10/2015)
 65110                              <1> ; ****************************************************************************
 65111                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 65112                              <1> ; TRDOS2.ASM (09/11/2011)
 65113                              <1> ; ----------------------------------------------------------------------------
 65114                              <1> ; DIR.ASM (c) 2004-2011 Erdogan TAN  [07/01/2004] Last Update: 09/10/2011
 65115                              <1> 
 65116                              <1> set_run_sequence:
 65117                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 65118                              <1> 	; 23/12/2016
 65119                              <1> 	; 10/06/2016
 65120                              <1> 	; 22/05/2016
 65121                              <1> 	; 20/05/2016
 65122                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
 65123                              <1> 	; TRDOS 386 feature only !
 65124                              <1> 	;
 65125                              <1> 	; INPUT ->
 65126                              <1> 	;	AL = process number (next process)
 65127                              <1> 	;
 65128                              <1> 	;	this process must be added to run sequence
 65129                              <1> 	;
 65130                              <1> 	;	[u.pri] = priority of present process
 65131                              <1> 	;
 65132                              <1> 	;	DL = priority (queue)
 65133                              <1> 	;	     0 = background (low) ; run on background 
 65134                              <1> 	;	     1 = regular (normal) ; run as regular
 65135                              <1> 	;	     2 = event (high)     ; run for event
 65136                              <1> 	;
 65137                              <1> 	;	1) If the requested process is already running:
 65138                              <1> 	;	   a) If present priority is high ([u.pri]=2) 
 65139                              <1> 	;	      and requested priority is also high, 
 65140                              <1> 	;	      there is nothing to do! Because it has been
 65141                              <1> 	;	      done already (before this attempt).		 	
 65142                              <1> 	;	   b) If present priority is high ([u.pri]=2)
 65143                              <1> 	;	      and requested priority is not high, there is
 65144                              <1> 	;	      nothing to do! Because, it's current
 65145                              <1> 	;	      run queue is unspecified, here. (It may be in
 65146                              <1> 	;	      a waiting list or in a run queue; if the new
 65147                              <1> 	;	      priority would be used to add it to relavant
 65148                              <1>         ;             run queue, this would be wrong, unnecessary
 65149                              <1> 	;	      and destabilizing duplication!)
 65150                              <1> 	;	   c) If present priority is not high ([u.pri]<2)
 65151                              <1>         ;             and requested priority is high (event),
 65152                              <1> 	;	      process will be added to present priority's
 65153                              <1> 	;	      run queue and then, priority will be changed
 65154                              <1> 	;	      to high ([u.pri]=2).
 65155                              <1> 	;	   d) If present priority is not high ([u.pri]<2)
 65156                              <1> 	;	      and requested priority is not high, [u.pri]
 65157                              <1> 	;	      value will be changed. There is nothing to do
 65158                              <1> 	;	      in addition. (The new priority value will be
 65159                              <1> 	;	      used by 'tswap/tswitch' procedure at 'sysret'
 65160                              <1> 	;	      or 'sysrele' stage.)
 65161                              <1> 	;
 65162                              <1> 	;	2) If the requested process is not running:
 65163                              <1> 	;	   a) If requested priority of the requested
 65164                              <1> 	;	      (next) process is high (event) and priority
 65165                              <1> 	;	      of present process is not high, the requested
 65166                              <1> 	;	      process will be added to ('runq_event') high
 65167                              <1> 	;	      priority run queue and then present (running)
 65168                              <1> 	;	      process will be stopped (swapped/switched out)
 65169                              <1> 	;	      immediately if it is in user mode, or it's 
 65170                              <1> 	;	      [u.quant] value will be reset to 0 and (then) 
 65171                              <1> 	;	      it will be stopped at 'sysret' stage.			
 65172                              <1> 	;	   b) If requested priority of the requested
 65173                              <1> 	;	      (next) process is high (event) and priority
 65174                              <1> 	;	      of present process is also high, the requested
 65175                              <1> 	;	      process will be added to ('runq_event') high
 65176                              <1> 	;	      priority run queue and present (running) 
 65177                              <1> 	;	      process will be allowed to run until it's 
 65178                              <1> 	;	      time quantum will be elapsed ([u.quant]=0).	
 65179                              <1> 	;	   c) If requested priority of the requested
 65180                              <1> 	;	      (next) process is not high ('run for event'), 
 65181                              <1> 	;	      there is nothing to do. Because, it's current
 65182                              <1> 	;	      run queue is unspecified, here. (It may be in
 65183                              <1> 	;	      a waiting list or in a run queue; if the new
 65184                              <1> 	;	      priority would be used to add it to relavant
 65185                              <1>         ;             run queue, this would be wrong, unnecessary
 65186                              <1> 	;	      and destabilizing duplication!) 
 65187                              <1> 	;
 65188                              <1> 	; OUTPUT ->
 65189                              <1> 	;	none
 65190                              <1> 	;
 65191                              <1> 	;	[u.pri] = priority of present process
 65192                              <1> 	;
 65193                              <1> 	;	cf = 1, if the request could not be fulfilled.
 65194                              <1> 	;			 	     	  
 65195                              <1> 	;	NOTE: 
 65196                              <1>         ;          * Processes in 'run as regular' queue can run
 65197                              <1> 	;	     if there is no process in 'run for event' queue
 65198                              <1> 	;	     ('run for event' processes have higher priority)	 		 
 65199                              <1> 	;	   * When [u.quant] time quantum of a process is
 65200                              <1> 	;	     elapsed, it's high priority ('run for event')
 65201                              <1> 	;	     status will be disabled, it can be run in sequence
 65202                              <1> 	;	     of it's actual run queue.
 65203                              <1> 	;	   * A 'run on background' process will always be 
 65204                              <1> 	;	     sequenced in 'run on background' (low priority)
 65205                              <1> 	;	     queue, it can run only when other priority queues
 65206                              <1> 	;	     are empty. (idle time processes, e.g. printing)  	 	
 65207                              <1> 	;
 65208                              <1> 	; Modified registers: eax, ebx, edx
 65209                              <1> 	;
 65210                              <1> 
 65211                              <1> srunseq_0:
 65212 00011E33 3A05[6D010300]      <1>         cmp     al, [u.uno]     ; same process ?
 65213 00011E39 750C                <1> 	jne	short srunseq_2 ; no
 65214                              <1> 
 65215 00011E3B 8A25[66010300]      <1> 	mov	ah, [u.pri] 	; present/current priority
 65216 00011E41 80FC02              <1> 	cmp	ah, 2       	; 'run for event' priority level
 65217 00011E44 7220                <1> 	jb	short srunseq_6 ; no
 65218                              <1> 
 65219                              <1> srunseq_1:
 65220                              <1> 	; there is nothing to do!
 65221 00011E46 C3                  <1> 	retn
 65222                              <1> 
 65223                              <1> srunseq_2:
 65224                              <1> 	;;this not necessary ! 23/12/2016
 65225                              <1>         ;;cmp	al, nproc	; number of processes = 16 
 65226                              <1> 	;;jnb	short srunseq_5	; error ! invalid process number 
 65227                              <1> 
 65228                              <1> 	; dl = priority
 65229 00011E47 80FA02              <1> 	cmp	dl, 2 		; event queue
 65230 00011E4A 72FA                <1> 	jb	short srunseq_1 ; requested process is not present
 65231                              <1> 				; process and priority of requested
 65232                              <1> 				; process is not high (event), 
 65233                              <1> 				; there is nothing to do!
 65234                              <1> 	
 65235                              <1> 	; requested process is not present process
 65236                              <1> 	; & priority of requested process is high
 65237 00011E4C 3A15[66010300]      <1> 	cmp	dl, [u.pri] 	; priority of present process
 65238 00011E52 7606                <1> 	jna	short srunseq_3 ; is high, also
 65239                              <1> 	;
 65240                              <1> 	; present process will be swapped/switched out
 65241 00011E54 FE05[0D840100]      <1> 	inc	byte [p_change] ; 1
 65242                              <1> 
 65243                              <1> srunseq_3:
 65244                              <1> 	; add process to 'runq_event' queue for new event
 65245 00011E5A BB[0A010300]        <1> 	mov	ebx, runq_event ; high priority run queue
 65246                              <1> 
 65247                              <1> srunseq_4:
 65248                              <1> 	; al = process number
 65249                              <1> 	; ebx = run queue
 65250                              <1> 	;call	putlu
 65251                              <1> 	;retn
 65252                              <1> 	; 29/07/2022
 65253 00011E5F E9F5EDFFFF          <1> 	jmp	putlu
 65254                              <1> 
 65255                              <1> srunseq_5:
 65256 00011E64 F5                  <1> 	cmc
 65257 00011E65 C3                  <1> 	retn
 65258                              <1> 
 65259                              <1> srunseq_6:
 65260                              <1> 	; present priority of the process is not high
 65261                              <1> 	
 65262 00011E66 8815[66010300]      <1> 	mov	[u.pri], dl ; new priority 
 65263                              <1> 			    ; (will be used by 'tswap')
 65264                              <1> 
 65265 00011E6C 80FA02              <1> 	cmp	dl, 2 		; high priority ?
 65266 00011E6F 72F3                <1> 	jb	short srunseq_5 ; no, there is nothing to do
 65267                              <1> 				; in addition
 65268                              <1> 
 65269                              <1> 	; process must be added to relevant run queue, here!
 65270                              <1> 	; (new priority is high/event priority and process
 65271                              <1> 	; will not be added to a run queue by 'tswap')
 65272                              <1> 
 65273 00011E71 BB[0C010300]        <1> 	mov	ebx, runq_normal ; 'run as regular' queue
 65274                              <1> 
 65275 00011E76 20E4                <1> 	and	ah, ah  ;  previous value of [u.pri]
 65276 00011E78 75E5                <1> 	jnz	short srunseq_4
 65277                              <1> 
 65278 00011E7A 43                  <1> 	inc	ebx
 65279 00011E7B 43                  <1> 	inc	ebx
 65280                              <1> 	; ebx = runq_background ; 'run on backgroud' queue 
 65281                              <1> 
 65282 00011E7C EBE1                <1> 	jmp	short srunseq_4
 65283                              <1> clock:
 65284                              <1> 	; 23/05/2016
 65285                              <1> 	; 22/05/2016
 65286                              <1> 	; 20/05/2016
 65287                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
 65288                              <1> 	; 14/05/2015 - 14/10/2015 (Retro UNIX 386 v1)
 65289                              <1> 	; 07/12/2013 - 10/04/2014 (Retro UNIX 8086 v1)
 65290                              <1> 
 65291 00011E7E 803D[64010300]00    <1> 	cmp	byte [u.quant], 0
 65292 00011E85 772C                <1> 	ja	short clk_1
 65293                              <1> 	;
 65294 00011E87 803D[6D010300]01    <1> 	cmp     byte [u.uno], 1 ; /etc/init ? (for Retro UNIX 8086 & 386 v1)
 65295                              <1> 				; MainProg (Kernel's Command Interpreter)
 65296                              <1> 				; for TRDOS 386.
 65297 00011E8E 7623                <1> 	jna	short clk_1 ; yes, do not swap out
 65298                              <1> 	;
 65299 00011E90 803D[10010300]FF    <1> 	cmp     byte [sysflg], 0FFh ; user or system space ?
 65300 00011E97 7520                <1> 	jne	short clk_2 	    ; system space (sysflg <> 0FFh)
 65301                              <1> 	;
 65302 00011E99 66833D[68010300]00  <1> 	cmp	word [u.intr], 0
 65303 00011EA1 7616                <1> 	jna	short clk_2
 65304                              <1> 	;
 65305                              <1> 	; 23/05/2016
 65306 00011EA3 803D[0E840100]00    <1> 	cmp	byte [multi_tasking], 0
 65307 00011EAA 760D                <1> 	jna	short clk_2
 65308                              <1> 	;
 65309 00011EAC FE05[0D840100]      <1> 	inc	byte [p_change] ; it is time to change running process	
 65310 00011EB2 C3                  <1> 	retn
 65311                              <1> clk_1:
 65312 00011EB3 FE0D[64010300]      <1> 	dec	byte [u.quant]
 65313                              <1> clk_2:
 65314 00011EB9 C3                  <1> 	retn   ; return to (hardware) timer interrupt routine
 65315                              <1> 
 65316                              <1> ; 12/10/2017
 65317                              <1> ; 15/01/2017
 65318                              <1> ; 14/01/2017
 65319                              <1> ; 07/01/2017
 65320                              <1> ; 02/01/2017
 65321                              <1> ; 17/08/2016
 65322                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 65323                              <1> int34h: ; #IOCTL# (I/O port access support for ring 3)
 65324                              <1> 	;
 65325                              <1> 	; 23/05/2016
 65326                              <1> 	; 20/06/2016
 65327                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 65328                              <1> 	;
 65329                              <1> 	; INPUT ->
 65330                              <1> 	;	AH = 0 -> read port  (physical IO port) -byte-
 65331                              <1> 	;	AH = 1 -> write port (physical IO port) -byte-
 65332                              <1> 	;		AL = data byte
 65333                              <1> 	;	AH = 2 -> read port  (physical IO port) -word-
 65334                              <1> 	;	AH = 3 -> write port (physical IO port) -word-
 65335                              <1> 	;		BX = data word
 65336                              <1> 	;	AH = 4 -> read port  (physical IO port) -dword-
 65337                              <1> 	;	AH = 5 -> write port (physical IO port) -dword-
 65338                              <1> 	;		EBX = data dword
 65339                              <1> 	;	; 12/10/2017
 65340                              <1> 	;	AH = 6 -> read port (physical IO port) twice -byte-
 65341                              <1> 	;	AH = 7 -> write port (physical IO port) twice -byte-
 65342                              <1> 	;		BX = data word	
 65343                              <1> 	;
 65344                              <1> 	;	DX = Port number (<= 0FFFFh)
 65345                              <1> 	;
 65346                              <1> 	; OUTPUT ->
 65347                              <1> 	;	AL = data byte (in al, dx)
 65348                              <1> 	;	AX = data word (in ax, dx)
 65349                              <1> 	;	EAX = data dword (in eax, dx)
 65350                              <1> 	;
 65351                              <1> 	;	(ECX = actual TRANSFER COUNT for string functions)
 65352                              <1> 	;
 65353                              <1> 	;
 65354                              <1> 	; Modified registers: EAX
 65355                              <1> 	;
 65356                              <1> 
 65357                              <1> 	;cmp	ah, 5
 65358                              <1> 	;ja	short int34h_5 ; invalid function !
 65359                              <1> 
 65360                              <1> 	; 12/10/2017
 65361 00011EBA 80FC07              <1> 	cmp	ah, 7
 65362 00011EBD 7743                <1> 	ja	short int34h_5 ; invalid function !
 65363                              <1> 
 65364                              <1> 	;; 15/01/2017
 65365                              <1> 	; 14/01/2017
 65366                              <1> 	; 02/01/2017
 65367                              <1> 	;;mov	byte [ss:intflg], 34h	; IOCTL interrupt 
 65368 00011EBF FB                  <1> 	sti
 65369                              <1> 	
 65370                              <1> 	;sti	; enable interrupts
 65371 00011EC0 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
 65372                              <1> 
 65373 00011EC5 80FC01              <1> 	cmp	ah, 1
 65374 00011EC8 7205                <1> 	jb	short int34h_0
 65375 00011ECA 7705                <1> 	ja	short int34h_1
 65376                              <1> 
 65377 00011ECC EE                  <1> 	out	dx, al
 65378                              <1> 	;iretd
 65379 00011ECD EB01                <1> 	jmp	short int34h_iret
 65380                              <1> 
 65381                              <1> int34h_0:
 65382 00011ECF EC                  <1> 	in	al, dx
 65383                              <1> 	;iretd
 65384                              <1> int34h_iret:
 65385                              <1> 	;cli	; 07/01/2017
 65386                              <1> 	;; 15/01/2017
 65387                              <1> 	;;mov	byte [ss:intflg], 0 ; reset
 65388 00011ED0 CF                  <1> 	iretd 
 65389                              <1> 
 65390                              <1> int34h_1:
 65391 00011ED1 F6C401              <1> 	test	ah, 1
 65392 00011ED4 7516                <1> 	jnz	short int34h_3 ; out
 65393                              <1> 
 65394                              <1> 	; in
 65395 00011ED6 80FC02              <1> 	cmp	ah, 2
 65396 00011ED9 7707                <1> 	ja	short int34h_2
 65397                              <1> 
 65398 00011EDB 6689D8              <1> 	mov	ax, bx
 65399 00011EDE 66ED                <1> 	in	ax, dx
 65400                              <1> 	;iretd
 65401 00011EE0 EBEE                <1> 	jmp	short int34h_iret
 65402                              <1> 
 65403                              <1> int34h_2:
 65404 00011EE2 80FC04              <1> 	cmp	ah, 4
 65405 00011EE5 772C                <1> 	ja	short int34h_7	; 12/10/2017
 65406                              <1> 	; ah = 4
 65407 00011EE7 89D8                <1> 	mov	eax, ebx
 65408 00011EE9 ED                  <1> 	in	eax, dx
 65409                              <1> 	;iretd
 65410 00011EEA EBE4                <1> 	jmp	short int34h_iret
 65411                              <1> 
 65412                              <1> int34h_3:
 65413 00011EEC 80FC03              <1> 	cmp	ah, 3
 65414 00011EEF 7707                <1> 	ja	short int34h_4
 65415                              <1> 
 65416 00011EF1 6689D8              <1> 	mov	ax, bx
 65417 00011EF4 66EF                <1> 	out	dx, ax
 65418                              <1> 	;iretd
 65419 00011EF6 EBD8                <1> 	jmp	short int34h_iret
 65420                              <1> 
 65421                              <1> int34h_4:
 65422 00011EF8 80FC05              <1> 	cmp	ah, 5
 65423 00011EFB 770B                <1> 	ja	short int34h_6	; 12/10/2017
 65424                              <1> 	; ah = 5
 65425 00011EFD 89D8                <1> 	mov	eax, ebx
 65426 00011EFF EF                  <1> 	out	dx, eax
 65427                              <1> 	;iretd
 65428 00011F00 EBCE                <1> 	jmp	short int34h_iret
 65429                              <1> 
 65430                              <1> int34h_5:
 65431 00011F02 804C240801          <1> 	or	byte [esp+8], 1	; set carry bit of eflags register
 65432 00011F07 CF                  <1> 	iretd
 65433                              <1> 
 65434                              <1> 	; 12/10/2017
 65435                              <1> int34h_6:
 65436 00011F08 6689D8              <1> 	mov	ax, bx
 65437 00011F0B EE                  <1> 	out	dx, al
 65438 00011F0C EB00                <1> 	jmp	short $+2
 65439 00011F0E 86E0                <1> 	xchg	ah, al
 65440 00011F10 EE                  <1> 	out	dx, al
 65441                              <1> 	;xchg	al, ah
 65442                              <1> 	;iretd
 65443 00011F11 EB06                <1> 	jmp	short int34h_8
 65444                              <1> int34h_7:
 65445 00011F13 EC                  <1> 	in	al, dx
 65446 00011F14 EB00                <1> 	jmp	short $+2
 65447 00011F16 88C4                <1> 	mov	ah, al
 65448 00011F18 EC                  <1> 	in	al, dx
 65449                              <1> int34h_8:
 65450 00011F19 86C4                <1> 	xchg	al, ah
 65451 00011F1B CF                  <1> 	iretd
 65452                              <1> 			
 65453                              <1> INT4Ah:
 65454                              <1> 	; 24/01/2016
 65455                              <1> 	; this procedure will be called by 'RTC_INT' (in 'timer.s')
 65456 00011F1C C3                  <1> 	retn
 65457                              <1> 
 65458                              <1> ; u0.s
 65459                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS0.INC
 65460                              <1> ; Last Modification: 20/11/2015
 65461                              <1> 
 65462                              <1> com2_int:
 65463                              <1> 	; 07/11/2015 
 65464                              <1> 	; 24/10/2015
 65465                              <1> 	; 23/10/2015
 65466                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
 65467                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
 65468                              <1> 	; < serial port 2 interrupt handler >
 65469                              <1> 	;
 65470 00011F1D 890424              <1> 	mov 	[esp], eax ; overwrite call return address
 65471                              <1> 	;push	eax
 65472 00011F20 66B80900            <1> 	mov	ax, 9
 65473 00011F24 EB07                <1> 	jmp	short comm_int
 65474                              <1> com1_int:
 65475                              <1> 	; 07/11/2015
 65476                              <1> 	; 24/10/2015
 65477 00011F26 890424              <1> 	mov 	[esp], eax ; overwrite call return address
 65478                              <1> 	; 23/10/2015
 65479                              <1> 	;push	eax
 65480 00011F29 66B80800            <1> 	mov	ax, 8
 65481                              <1> comm_int:
 65482                              <1> 	; 20/11/2015
 65483                              <1> 	; 18/11/2015
 65484                              <1> 	; 17/11/2015
 65485                              <1> 	; 16/11/2015
 65486                              <1> 	; 09/11/2015
 65487                              <1> 	; 08/11/2015
 65488                              <1> 	; 07/11/2015
 65489                              <1> 	; 06/11/2015 (serial4.asm, 'serial')	
 65490                              <1> 	; 01/11/2015
 65491                              <1> 	; 26/10/2015
 65492                              <1> 	; 23/10/2015
 65493 00011F2D 53                  <1> 	push	ebx
 65494 00011F2E 56                  <1> 	push	esi
 65495 00011F2F 57                  <1> 	push	edi
 65496 00011F30 1E                  <1> 	push 	ds
 65497 00011F31 06                  <1> 	push 	es
 65498                              <1> 	; 18/11/2015
 65499 00011F32 0F20DB              <1> 	mov	ebx, cr3
 65500 00011F35 53                  <1> 	push	ebx ; ****
 65501                              <1> 	;
 65502 00011F36 51                  <1> 	push	ecx ; ***
 65503 00011F37 52                  <1> 	push	edx ; **
 65504                              <1> 	;
 65505 00011F38 BB10000000          <1> 	mov	ebx, KDATA
 65506 00011F3D 8EDB                <1> 	mov	ds, bx
 65507 00011F3F 8EC3                <1> 	mov	es, bx
 65508                              <1> 	;
 65509 00011F41 8B0D[80770100]      <1> 	mov	ecx, [k_page_dir]
 65510 00011F47 0F22D9              <1> 	mov	cr3, ecx
 65511                              <1> 	; 20/11/2015
 65512                              <1> 	; Interrupt identification register
 65513 00011F4A 66BAFA02            <1> 	mov	dx, 2FAh ; COM2
 65514                              <1> 	;
 65515 00011F4E 3C08                <1> 	cmp 	al, 8 
 65516 00011F50 7702                <1> 	ja 	short com_i0
 65517                              <1> 	;
 65518                              <1> 	; 20/11/2015
 65519                              <1> 	; 17/11/2015
 65520                              <1> 	; 16/11/2015
 65521                              <1> 	; 15/11/2015
 65522                              <1> 	; 24/10/2015
 65523                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
 65524                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
 65525                              <1> 	; < serial port 1 interrupt handler >
 65526                              <1> 	;
 65527 00011F52 FEC6                <1> 	inc	dh ; 3FAh ; COM1 Interrupt id. register
 65528                              <1> com_i0:
 65529                              <1> 	;push	eax ; *
 65530                              <1> 	; 07/11/2015
 65531 00011F54 A2[EA770100]        <1> 	mov 	byte [ccomport], al
 65532                              <1> 	; 09/11/2015
 65533 00011F59 0FB7D8              <1> 	movzx	ebx, ax ; 8 or 9
 65534                              <1> 	; 17/11/2015
 65535                              <1>  	; reset request for response status
 65536 00011F5C 88A3[E0770100]      <1> 	mov	[ebx+req_resp-8], ah ; 0
 65537                              <1> 	;
 65538                              <1> 	; 20/11/2015
 65539 00011F62 EC                  <1> 	in	al, dx		; read interrupt id. register
 65540 00011F63 EB00                <1> 	JMP	$+2	   	; I/O DELAY
 65541 00011F65 2404                <1> 	and	al, 4		; received data available?	
 65542 00011F67 7470                <1> 	jz	short com_eoi	; (transmit. holding reg. empty)
 65543                              <1> 	;
 65544                              <1> 	; 20/11/2015
 65545 00011F69 80EA02              <1> 	sub	dl, 3FAh-3F8h	; data register (3F8h, 2F8h)
 65546 00011F6C EC                  <1> 	in	al, dx     	; read character
 65547                              <1> 	;JMP	$+2	   	; I/O DELAY
 65548                              <1> 	; 08/11/2015
 65549                              <1> 	; 07/11/2015
 65550 00011F6D 89DE                <1> 	mov	esi, ebx 
 65551 00011F6F 89DF                <1> 	mov	edi, ebx
 65552 00011F71 81C6[E4770100]      <1> 	add 	esi, rchar - 8 ; points to last received char
 65553 00011F77 81C7[E6770100]      <1> 	add	edi, schar - 8 ; points to last sent char
 65554 00011F7D 8806                <1> 	mov	[esi], al ; received char (current char)
 65555                              <1> 	; query
 65556 00011F7F 20C0                <1> 	and	al, al
 65557 00011F81 7527                <1> 	jnz	short com_i2
 65558                              <1>    	; response
 65559                              <1> 	; 17/11/2015
 65560                              <1> 	; set request for response status
 65561 00011F83 FE83[E0770100]      <1>         inc     byte [ebx+req_resp-8] ; 1 
 65562                              <1> 	;
 65563 00011F89 6683C205            <1> 	add	dx, 3FDh-3F8h	; (3FDh, 2FDh)
 65564 00011F8D EC                  <1> 	in	al, dx	   	; read line status register 
 65565 00011F8E EB00                <1> 	JMP	$+2	   	; I/O DELAY
 65566 00011F90 2420                <1> 	and	al, 20h	   	; transmitter holding reg. empty?
 65567 00011F92 7445                <1> 	jz	short com_eoi 	; no
 65568 00011F94 B0FF                <1> 	mov 	al, 0FFh   	; response			
 65569 00011F96 6683EA05            <1> 	sub	dx, 3FDh-3F8h 	; data port (3F8h, 2F8h)
 65570 00011F9A EE                  <1> 	out	dx, al	   	; send on serial port
 65571                              <1> 	; 17/11/2015
 65572 00011F9B 803F00              <1> 	cmp 	byte [edi], 0   ; query ? (schar)
 65573 00011F9E 7502                <1> 	jne 	short com_i1    ; no
 65574 00011FA0 8807                <1> 	mov	[edi], al 	; 0FFh (responded)
 65575                              <1> com_i1:
 65576                              <1> 	; 17/11/2015
 65577                              <1> 	; reset request for response status (again)
 65578 00011FA2 FE8B[E0770100]      <1>         dec     byte [ebx+req_resp-8] ; 0 
 65579 00011FA8 EB2F                <1> 	jmp	short com_eoi
 65580                              <1> com_i2:	
 65581                              <1> 	; 08/11/2015
 65582 00011FAA 3CFF                <1> 	cmp 	al, 0FFh	; (response ?)
 65583 00011FAC 7417                <1> 	je	short com_i3	; (check for response signal)
 65584                              <1> 	; 07/11/2015
 65585 00011FAE 3C04                <1> 	cmp	al, 04h	; EOT
 65586 00011FB0 751C                <1> 	jne	short com_i4	
 65587                              <1> 	; EOT = 04h (End of Transmit) - 'CTRL + D'
 65588                              <1> 	;(an EOT char is supposed as a ctrl+brk from the terminal)
 65589                              <1> 	; 08/11/2015
 65590                              <1> 		; ptty -> tty 0 to 7 (pseudo screens)
 65591 00011FB2 861D[AE770100]      <1> 	xchg	bl, [ptty]  ; tty number (8 or 9)
 65592 00011FB8 E8F14CFFFF          <1> 	call 	ctrlbrk
 65593 00011FBD 861D[AE770100]      <1> 	xchg	[ptty], bl ; (restore ptty value and BL value)
 65594                              <1> 	;mov	al, 04h ; EOT
 65595                              <1> 	; 08/11/2015
 65596 00011FC3 EB09                <1> 	jmp	short com_i4	
 65597                              <1> com_i3:
 65598                              <1> 	; 08/11/2015
 65599                              <1> 	; If 0FFh has been received just after a query
 65600                              <1> 	; (schar, ZERO), it is a response signal.
 65601                              <1> 	; 17/11/2015
 65602 00011FC5 803F00              <1>         cmp     byte [edi], 0 ; query ? (schar)
 65603 00011FC8 7704                <1> 	ja	short com_i4 ; no
 65604                              <1> 	; reset query status (schar)
 65605 00011FCA 8807                <1> 	mov	[edi], al ; 0FFh
 65606 00011FCC FEC0                <1> 	inc	al ; 0
 65607                              <1> com_i4:
 65608                              <1> 	; 27/07/2014
 65609                              <1> 	; 09/07/2014
 65610 00011FCE D0E3                <1> 	shl	bl, 1	
 65611 00011FD0 81C3[B0770100]      <1> 	add	ebx, ttychr
 65612                              <1> 	; 23/07/2014 (always overwrite)
 65613                              <1> 	;;cmp	word [ebx], 0
 65614                              <1> 	;;ja	short com_eoi
 65615                              <1> 	;
 65616 00011FD6 668903              <1> 	mov	[ebx], ax   ; Save ascii code
 65617                              <1> 			    ; scan code = 0
 65618                              <1> com_eoi:
 65619                              <1> 	;mov	al, 20h
 65620                              <1> 	;out	20h, al	   ; end of interrupt
 65621                              <1> 	;
 65622                              <1> 	; 07/11/2015
 65623                              <1>       	;pop	eax ; *
 65624 00011FD9 A0[EA770100]        <1> 	mov	al, byte [ccomport] ; current COM port
 65625                              <1> 	 ; al = tty number (8 or 9)
 65626 00011FDE E85B010000          <1>         call	wakeup
 65627                              <1> com_iret:
 65628                              <1> 	; 23/10/2015
 65629 00011FE3 5A                  <1> 	pop	edx ; **
 65630 00011FE4 59                  <1> 	pop	ecx ; ***
 65631                              <1> 	; 18/11/2015
 65632                              <1> 	;pop	eax ; ****
 65633                              <1> 	;mov	cr3, eax
 65634                              <1> 	;jmp	iiret
 65635 00011FE5 E9ACEDFEFF          <1> 	jmp	iiretp
 65636                              <1> 
 65637                              <1> ;iiretp: ; 01/09/2015
 65638                              <1> ;	; 28/08/2015
 65639                              <1> ;	pop	eax ; (*) page directory
 65640                              <1> ;	mov	cr3, eax
 65641                              <1> ;iiret:
 65642                              <1> ;	; 22/08/2014
 65643                              <1> ;	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
 65644                              <1> ;	out	20h, al	; 8259 PORT
 65645                              <1> ;	;
 65646                              <1> ;	pop	es
 65647                              <1> ;	pop	ds
 65648                              <1> ;	pop	edi
 65649                              <1> ;	pop	esi
 65650                              <1> ;	pop	ebx ; 29/08/2014
 65651                              <1> ;	pop 	eax
 65652                              <1> ;	iretd
 65653                              <1> 
 65654                              <1> sp_init:
 65655                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 65656                              <1> 	; 07/11/2015
 65657                              <1> 	; 29/10/2015
 65658                              <1> 	; 26/10/2015
 65659                              <1> 	; 23/10/2015
 65660                              <1> 	; 29/06/2015
 65661                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - 115200 baud)
 65662                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1 - 9600 baud)
 65663                              <1> 	; Initialization of Serial Port Communication Parameters
 65664                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
 65665                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
 65666                              <1> 	;
 65667                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
 65668                              <1> 	;
 65669                              <1> 	; INPUT:  (29/06/2015)
 65670                              <1> 	;	AL = 0 for COM1
 65671                              <1> 	;	     1 for COM2
 65672                              <1> 	;	AH = Communication parameters	
 65673                              <1> 	;
 65674                              <1> 	;  (*) Communication parameters (except BAUD RATE):
 65675                              <1> 	;	Bit	4	3	2	1	0
 65676                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
 65677                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
 65678                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
 65679                              <1> 	;		11 = even
 65680                              <1> 	;  Baud rate setting bits: (29/06/2015)
 65681                              <1> 	;		Retro UNIX 386 v1 feature only !
 65682                              <1> 	;	Bit	7    6    5  | Baud rate
 65683                              <1> 	;		------------------------
 65684                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
 65685                              <1> 	;		0    0    1  | 9600 (12)
 65686                              <1> 	;		0    1    0  | 19200 (6) 
 65687                              <1> 	;		0    1	  1  | 38400 (3) 
 65688                              <1> 	;		1    0	  0  | 14400 (8)
 65689                              <1> 	;		1    0	  1  | 28800 (4)
 65690                              <1> 	;		1    1    0  | 57600 (2)
 65691                              <1> 	;		1    1    1  | 115200 (1) 	
 65692                              <1> 	
 65693                              <1> 	; References:	
 65694                              <1> 	; (1) IBM PC-XT Model 286 BIOS Source Code
 65695                              <1> 	;     RS232.ASM --- 10/06/1985 COMMUNICATIONS BIOS (RS232)
 65696                              <1> 	; (2) Award BIOS 1999 - ATORGS.ASM
 65697                              <1> 	; (3) http://wiki.osdev.org/Serial_Ports
 65698                              <1> 	;
 65699                              <1> 	; Set communication parameters for COM1 (= 03h)	
 65700                              <1> 	;
 65701 00011FEA BB[E6770100]        <1> 	mov	ebx, com1p		; COM1 parameters  
 65702 00011FEF 66BAF803            <1> 	mov	dx, 3F8h		; COM1
 65703                              <1> 	 ; 29/10/2015
 65704 00011FF3 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
 65705 00011FF7 E86D000000          <1> 	call	sp_i3	; call A4	
 65706 00011FFC A880                <1> 	test	al, 80h
 65707 00011FFE 7410                <1> 	jz	short sp_i0 ; OK..
 65708                              <1> 		; Error !
 65709                              <1> 	;mov	dx, 3F8h
 65710 00012000 80EA05              <1> 	sub	dl, 5 ; 3FDh -> 3F8h
 65711 00012003 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
 65712 00012007 E85D000000          <1> 	call	sp_i3	; call A4	
 65713 0001200C A880                <1> 	test	al, 80h
 65714 0001200E 7508                <1> 	jnz	short sp_i1
 65715                              <1> sp_i0:
 65716                              <1>         ; (Note: Serial port interrupts will be disabled here...)	
 65717                              <1>         ; (INT 14h initialization code disables interrupts.)
 65718                              <1> 	;
 65719 00012010 C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
 65720 00012013 E8DB000000          <1> 	call	sp_i5 ; 29/06/2015
 65721                              <1> sp_i1:
 65722 00012018 43                  <1> 	inc	ebx
 65723 00012019 66BAF802            <1> 	mov	dx, 2F8h		; COM2
 65724                              <1> 	 ; 29/10/2015
 65725 0001201D 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
 65726 00012021 E843000000          <1> 	call	sp_i3	; call A4	
 65727 00012026 A880                <1> 	test	al, 80h
 65728 00012028 7410                <1> 	jz	short sp_i2 ; OK..
 65729                              <1> 		; Error !
 65730                              <1> 	;mov	dx, 2F8h
 65731 0001202A 80EA05              <1> 	sub	dl, 5 ; 2FDh -> 2F8h
 65732 0001202D 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
 65733 00012031 E833000000          <1> 	call	sp_i3	; call A4	
 65734 00012036 A880                <1> 	test	al, 80h
 65735 00012038 752E                <1> 	jnz	short sp_i7
 65736                              <1> sp_i2:
 65737 0001203A C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
 65738                              <1> sp_i6:
 65739                              <1> 	;; COM2 - enabling IRQ 3
 65740                              <1> 	; 29/07/2022
 65741                              <1> 	; 07/11/2015
 65742                              <1> 	; 26/10/2015
 65743 0001203D 9C                  <1> 	pushf
 65744 0001203E FA                  <1> 	cli
 65745                              <1> 	;
 65746 0001203F 66BAFC02            <1> 	mov	dx, 2FCh   		; modem control register
 65747 00012043 EC                  <1> 	in	al, dx 	   		; read register
 65748 00012044 EB00                <1> 	JMP	$+2	   		; I/O DELAY
 65749 00012046 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
 65750 00012048 EE                  <1> 	out	dx, al     		; write back to register
 65751 00012049 EB00                <1> 	JMP	$+2	   		; I/O DELAY
 65752                              <1> 	;mov	dx, 2F9h   		; interrupt enable register
 65753                              <1> 	; 29/07/2022
 65754 0001204B B2F9                <1> 	mov	dl, 0F9h
 65755 0001204D EC                  <1> 	in	al, dx     		; read register
 65756 0001204E EB00                <1> 	JMP	$+2	   		; I/O DELAY
 65757                              <1> 	;or	al, 1      		; receiver data interrupt enable and
 65758 00012050 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
 65759 00012052 EE                  <1> 	out	dx, al 	   		; write back to register
 65760 00012053 EB00                <1> 	JMP	$+2        		; I/O DELAY
 65761 00012055 E421                <1> 	in	al, 21h    		; read interrupt mask register
 65762 00012057 EB00                <1> 	JMP	$+2	   		; I/O DELAY
 65763 00012059 24F7                <1> 	and	al, 0F7h   		; enable IRQ 3 (COM2)
 65764 0001205B E621                <1> 	out	21h, al    		; write back to register
 65765                              <1> 	;
 65766                              <1> 	; 23/10/2015
 65767 0001205D B8[1D1F0100]        <1> 	mov 	eax, com2_int
 65768 00012062 A3[39210100]        <1> 	mov	[com2_irq3], eax
 65769                              <1> 	; 26/10/2015
 65770 00012067 9D                  <1> 	popf	
 65771                              <1> sp_i7:
 65772 00012068 C3                  <1> 	retn
 65773                              <1> 
 65774                              <1> sp_i3:
 65775                              <1> ;A4:  	;-----	INITIALIZE THE COMMUNICATIONS PORT
 65776                              <1> 	; 28/10/2015
 65777 00012069 FEC2                <1> 	inc	dl	; 3F9h (2F9h)	; 3F9h, COM1 Interrupt enable register 
 65778 0001206B B000                <1> 	mov	al, 0
 65779 0001206D EE                  <1> 	out	dx, al			; disable serial port interrupt
 65780 0001206E EB00                <1> 	JMP	$+2			; I/O DELAY
 65781 00012070 80C202              <1> 	add	dl, 2 	; 3FBh (2FBh)	; COM1 Line control register (3FBh)
 65782 00012073 B080                <1> 	mov	al, 80h			
 65783 00012075 EE                  <1> 	out	dx, al			; SET DLAB=1 ; divisor latch access bit
 65784                              <1> 	;-----	SET BAUD RATE DIVISOR
 65785                              <1> 	; 26/10/2015
 65786 00012076 80EA03              <1> 	sub 	dl, 3   ; 3F8h (2F8h)	; register for least significant byte
 65787                              <1> 					; of the divisor value
 65788 00012079 88C8                <1> 	mov	al, cl	; 1
 65789 0001207B EE                  <1> 	out	dx, al			; 1 = 115200 baud (Retro UNIX 386 v1)
 65790                              <1> 					; 2 = 57600 baud
 65791                              <1> 					; 3 = 38400 baud
 65792                              <1> 					; 6 = 19200 baud
 65793                              <1> 					; 12 = 9600 baud (Retro UNIX 8086 v1)
 65794 0001207C EB00                <1> 	JMP	$+2			; I/O DELAY
 65795 0001207E 28C0                <1> 	sub	al, al
 65796 00012080 FEC2                <1> 	inc	dl      ; 3F9h (2F9h)	; register for most significant byte
 65797                              <1> 					; of the divisor value
 65798 00012082 EE                  <1> 	out	dx, al ; 0
 65799 00012083 EB00                <1> 	JMP	$+2			; I/O DELAY
 65800                              <1> 	;	
 65801 00012085 88E8                <1> 	mov	al, ch ; 3		; 8 data bits, 1 stop bit, no parity
 65802                              <1> 	;and	al, 1Fh ; Bits 0,1,2,3,4	
 65803 00012087 80C202              <1> 	add	dl, 2	; 3FBh (2FBh)	; Line control register
 65804 0001208A EE                  <1> 	out	dx, al			
 65805 0001208B EB00                <1> 	JMP	$+2			; I/O DELAY
 65806                              <1> 	; 29/10/2015
 65807 0001208D FECA                <1> 	dec 	dl 	; 3FAh (2FAh)	; FIFO Control register (16550/16750)
 65808 0001208F 30C0                <1> 	xor	al, al			; 0
 65809 00012091 EE                  <1> 	out	dx, al			; Disable FIFOs (reset to 8250 mode)
 65810 00012092 EB00                <1> 	JMP	$+2	
 65811                              <1> sp_i4:
 65812                              <1> ;A18:	;-----	COMM PORT STATUS ROUTINE
 65813                              <1> 	; 29/06/2015 (line status after modem status)
 65814 00012094 80C204              <1> 	add	dl, 4	; 3FEh (2FEh)	; Modem status register
 65815                              <1> sp_i4s:
 65816 00012097 EC                  <1> 	in	al, dx			; GET MODEM CONTROL STATUS
 65817 00012098 EB00                <1> 	JMP	$+2			; I/O DELAY
 65818 0001209A 88C4                <1> 	mov	ah, al			; PUT IN (AH) FOR RETURN
 65819 0001209C FECA                <1> 	dec	dl	; 3FDh (2FDh)	; POINT TO LINE STATUS REGISTER
 65820                              <1> 					; dx = 3FDh for COM1, 2FDh for COM2
 65821 0001209E EC                  <1> 	in	al, dx			; GET LINE CONTROL STATUS
 65822                              <1> 	; AL = Line status, AH = Modem status
 65823 0001209F C3                  <1> 	retn
 65824                              <1> 
 65825                              <1> sp_status:
 65826                              <1> 	; 29/06/2015
 65827                              <1> 	; 27/06/2015 (Retro UNIX 386 v1)
 65828                              <1> 	; Get serial port status
 65829 000120A0 66BAFE03            <1> 	mov	dx, 3FEh		; Modem status register (COM1)
 65830 000120A4 28C6                <1> 	sub	dh, al			; dh = 2 for COM2 (al = 1)
 65831                              <1> 					; dx = 2FEh for COM2
 65832 000120A6 EBEF                <1> 	jmp	short sp_i4s
 65833                              <1> 
 65834                              <1> sp_setp: ; Set serial port communication parameters
 65835                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 65836                              <1> 	; 07/11/2015
 65837                              <1> 	; 29/10/2015
 65838                              <1> 	; 29/06/2015
 65839                              <1> 	; Retro UNIX 386 v1 feature only !	
 65840                              <1> 	;
 65841                              <1> 	; INPUT:
 65842                              <1> 	;	AL = 0 for COM1
 65843                              <1> 	;	     1 for COM2
 65844                              <1> 	;	AH = Communication parameters (*)
 65845                              <1> 	; OUTPUT:
 65846                              <1> 	;	CL = Line status
 65847                              <1> 	;	CH = Modem status
 65848                              <1> 	;   If cf = 1 -> Error code in [u.error]
 65849                              <1> 	;		 'invalid parameter !' 
 65850                              <1> 	;		 	 or
 65851                              <1> 	;		 'device not ready !' error
 65852                              <1> 	;	
 65853                              <1> 	;  (*) Communication parameters (except BAUD RATE):
 65854                              <1> 	;	Bit	4	3	2	1	0
 65855                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
 65856                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
 65857                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
 65858                              <1> 	;		11 = even
 65859                              <1> 	;  Baud rate setting bits: (29/06/2015)
 65860                              <1> 	;		Retro UNIX 386 v1 feature only !
 65861                              <1> 	;	Bit	7    6    5  | Baud rate
 65862                              <1> 	;		------------------------
 65863                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
 65864                              <1> 	;		0    0    1  | 9600 (12)
 65865                              <1> 	;		0    1    0  | 19200 (6) 
 65866                              <1> 	;		0    1	  1  | 38400 (3) 
 65867                              <1> 	;		1    0	  0  | 14400 (8)
 65868                              <1> 	;		1    0	  1  | 28800 (4)
 65869                              <1> 	;		1    1    0  | 57600 (2)
 65870                              <1> 	;		1    1    1  | 115200 (1) 
 65871                              <1> 	;
 65872                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
 65873                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
 65874                              <1> 	;
 65875                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
 65876                              <1> 	;
 65877 000120A8 66BAF803            <1> 	mov	dx, 3F8h
 65878 000120AC BB[E6770100]        <1> 	mov	ebx, com1p ; COM1 control byte offset
 65879 000120B1 3C01                <1> 	cmp	al, 1
 65880 000120B3 776A                <1> 	ja 	short sp_invp_err
 65881 000120B5 7203                <1> 	jb	short sp_setp1 ;  COM1 (AL = 0)
 65882 000120B7 FECE                <1> 	dec	dh ; 2F8h
 65883 000120B9 43                  <1> 	inc	ebx ; COM2 control byte offset
 65884                              <1> sp_setp1:
 65885                              <1> 	; 29/10/2015
 65886 000120BA 8823                <1> 	mov	[ebx], ah
 65887 000120BC 0FB6CC              <1> 	movzx 	ecx, ah
 65888 000120BF C0E905              <1> 	shr	cl, 5 ; -> baud rate index
 65889 000120C2 80E41F              <1> 	and	ah, 1Fh ; communication parameters except baud rate
 65890 000120C5 8A81[2E210100]      <1> 	mov	al, [ecx+b_div_tbl]
 65891 000120CB 6689C1              <1> 	mov	cx, ax
 65892 000120CE E896FFFFFF          <1> 	call	sp_i3
 65893 000120D3 6689C1              <1> 	mov	cx, ax ; CL = Line status, CH = Modem status
 65894 000120D6 A880                <1> 	test	al, 80h
 65895 000120D8 740F                <1> 	jz	short sp_setp2
 65896 000120DA C603E3              <1>         mov     byte [ebx], 0E3h ; Reset to initial value (11100011b)
 65897                              <1> stp_dnr_err:
 65898 000120DD C705[84010300]0F00- <1> 	mov	dword [u.error], ERR_DEV_NOT_RDY ; 'device not ready !'
 65899 000120E5 0000                <1>
 65900                              <1> 	; CL = Line status, CH = Modem status
 65901 000120E7 F9                  <1> 	stc
 65902 000120E8 C3                  <1> 	retn
 65903                              <1> sp_setp2:
 65904 000120E9 80FE02              <1> 	cmp	dh, 2 ; COM2 (2F?h)
 65905                              <1> 	;jna	sp_i6 
 65906                              <1> 		      ; COM1 (3F?h)
 65907                              <1> 	; 29/07/2022
 65908 000120EC 7705                <1> 	ja	short sp_i5
 65909 000120EE E94AFFFFFF          <1> 	jmp	sp_i6
 65910                              <1> sp_i5: 
 65911                              <1> 	; 29/07/2022
 65912                              <1> 	; 07/11/2015
 65913                              <1> 	; 26/10/2015
 65914                              <1> 	; 29/06/2015
 65915                              <1> 	;
 65916                              <1> 	;; COM1 - enabling IRQ 4
 65917 000120F3 9C                  <1> 	pushf
 65918 000120F4 FA                  <1> 	cli
 65919 000120F5 66BAFC03            <1> 	mov	dx, 3FCh   		; modem control register
 65920 000120F9 EC                  <1> 	in	al, dx 	   		; read register
 65921 000120FA EB00                <1> 	JMP	$+2			; I/O DELAY
 65922 000120FC 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
 65923 000120FE EE                  <1> 	out	dx, al     		; write back to register
 65924 000120FF EB00                <1> 	JMP	$+2			; I/O DELAY
 65925                              <1> 	;mov	dx, 3F9h   		; interrupt enable register
 65926                              <1> 	; 29/07/2022
 65927 00012101 B2F9                <1> 	mov	dl, 0F9h
 65928 00012103 EC                  <1> 	in	al, dx     		; read register
 65929 00012104 EB00                <1> 	JMP	$+2			; I/O DELAY
 65930                              <1> 	;or	al, 1      		; receiver data interrupt enable and
 65931 00012106 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
 65932 00012108 EE                  <1> 	out	dx, al 	   		; write back to register
 65933 00012109 EB00                <1> 	JMP	$+2        		; I/O DELAY
 65934 0001210B E421                <1> 	in	al, 21h    		; read interrupt mask register
 65935 0001210D EB00                <1> 	JMP	$+2			; I/O DELAY
 65936 0001210F 24EF                <1> 	and	al, 0EFh   		; enable IRQ 4 (COM1)
 65937 00012111 E621                <1> 	out	21h, al    		; write back to register
 65938                              <1> 	;
 65939                              <1> 	; 23/10/2015
 65940 00012113 B8[261F0100]        <1> 	mov 	eax, com1_int
 65941 00012118 A3[35210100]        <1> 	mov	[com1_irq4], eax
 65942                              <1> 	; 26/10/2015
 65943 0001211D 9D                  <1> 	popf
 65944 0001211E C3                  <1> 	retn
 65945                              <1> 
 65946                              <1> sp_invp_err:
 65947 0001211F C705[84010300]1700- <1> 	mov	dword [u.error], ERR_INV_PARAMETER ; 'invalid parameter !' 
 65948 00012127 0000                <1>
 65949 00012129 31C9                <1> 	xor	ecx, ecx
 65950 0001212B 49                  <1> 	dec	ecx ; 0FFFFh
 65951 0001212C F9                  <1> 	stc
 65952 0001212D C3                  <1> 	retn
 65953                              <1> 
 65954                              <1> ; 29/10/2015
 65955                              <1> b_div_tbl: ; Baud rate divisor table (115200/divisor)
 65956 0001212E 010C0603080401      <1> 	db 1, 12, 6, 3, 8, 4, 1
 65957                              <1> 
 65958                              <1> 
 65959                              <1> ; 23/10/2015
 65960                              <1> com1_irq4:
 65961 00012135 [3D210100]          <1> 	dd dummy_retn
 65962                              <1> com2_irq3:
 65963 00012139 [3D210100]          <1> 	dd dummy_retn
 65964                              <1> 
 65965                              <1> dummy_retn:
 65966 0001213D C3                  <1> 	retn
 65967                              <1> 
 65968                              <1> wakeup:
 65969                              <1> 	; 24/01/2016
 65970 0001213E C3                  <1> 	retn
 65971                              <1> 
 65972                              <1> set_working_path_x:
 65973                              <1> 		; 17/10/2016 (TRDOS 386 - FFF & FNF)
 65974                              <1> 		;mov	ax, 1 
 65975                              <1> 			; File name is needed/forced (AL=1)
 65976                              <1> 			; Change directory as temporary (AH=0)	
 65977                              <1> 		; 29/07/2022
 65978 0001213F 31C0                <1> 		xor	eax, eax
 65979 00012141 FEC0                <1> 		inc	al
 65980                              <1> 		; eax = 1
 65981                              <1> set_working_path_xx: ; 30/12/2017 (syschdir)
 65982                              <1> 		; This is needed for preventing wrong Find Next File
 65983                              <1> 		; system call after sysopen, syscreate, sysmkdir etc. 
 65984                              <1> 		; Find Next File must immediate follow Find First File)
 65985                              <1> 
 65986 00012143 8825[30840100]      <1> 		mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 65987                              <1> 
 65988                              <1> set_working_path:
 65989                              <1> 		; 08/08/2022
 65990                              <1> 		; 29/07/2022 - TRDOS 386 Kernel v2.0.5
 65991                              <1> 		; 16/10/2016
 65992                              <1> 		; 12/10/2016
 65993                              <1> 		; 10/10/2016
 65994                              <1> 		; 05/10/2016 - TRDOS 386 (TRDOS v2.0)
 65995                              <1> 		;
 65996                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_set_working_path")
 65997                              <1>                 ; 27/01/2011 - 08/02/2011 
 65998                              <1> 		; Set/Changes current drive, directory and file
 65999                              <1> 		; depending on command tail
 66000                              <1> 		; (procedure is derivated from CMD_INTR.ASM 
 66001                              <1> 		; file or dir locating code of internal commands)
 66002                              <1> 		; (This procedure is prepared for INT 21H file/dir 
 66003                              <1> 		; functions and also to get compact code for 
 66004                              <1> 		; internal mainprog -command interpreter- commands)
 66005                              <1> 		; 
 66006                              <1> 		; INPUT: DS:SI -> Command tail (ASCIIZ string)
 66007                              <1> 		; AL = 0 -> any, AL > 0 -> file name is forced
 66008                              <1> 		; AH = CD -> Change directory permanently 
 66009                              <1> 		; AH <> CD -> Change directory as temporary    
 66010                              <1> 		; 
 66011                              <1> 		; OUTPUT: ES=DS, FindFile structure has been set
 66012                              <1> 		;        RUN_CDRV points previous current drive  
 66013                              <1> 		;        DS:SI = FindFile structure address
 66014                              <1> 		;        (DS=CS)       
 66015                              <1> 		;        AX, BX, CX, DX, DI will be changed
 66016                              <1> 		;   cf = 1 -> Error code in AX (AL)
 66017                              <1> 		;        stc & AX = 0 -> Bad command or path name 
 66018                              <1> 		; -----------------------------------------------
 66019                              <1> 		;
 66020                              <1> 		; TRDOS 386 (05/10/2016)
 66021                              <1> 		; INPUT:
 66022                              <1> 		;	ESI = File/Directory Path (ASCIIZ string)
 66023                              <1> 		;             address in user's memory space
 66024                              <1> 		;       AL = 0 -> any
 66025                              <1> 		;       AL > 0 -> file name is forced
 66026                              <1> 		;       AH = CD -> change directory as permanent
 66027                              <1> 		;       AH <> CD -> change directory as temporary
 66028                              <1> 		; 
 66029                              <1> 		; OUTPUT:
 66030                              <1> 		;	FindFile structure has been set
 66031                              <1> 		;       RUN_CDRV points previous current drive  
 66032                              <1> 		;       ESI = FindFile_Name address ; 12/10/2016
 66033                              <1> 		;
 66034                              <1> 		;       cf = 1 -> Error code in EAX (AL)
 66035                              <1> 		;       stc & EAX = 0 -> Bad command or path name
 66036                              <1> 		;  
 66037                              <1> 		; Modified registers: EAX, EBX, ECX, EDX, ESI, EDI
 66038                              <1> 
 66039 00012149 66A3[34840100]      <1> 		mov	[SWP_Mode], ax
 66040 0001214F A0[42780100]        <1> 		mov	al, [Current_Drv]
 66041 00012154 30E4                <1> 		xor	ah, ah
 66042 00012156 66A3[36840100]      <1> 		mov	[SWP_DRV], ax
 66043                              <1> 
 66044                              <1> 		; TRDOS 386 ring 3 (user's page directory)
 66045                              <1> 		; to ring 0 (kernel's page directory) 
 66046                              <1> 		; transfer modifications (05/10/2016).
 66047                              <1> 
 66048 0001215C 55                  <1> 		push	ebp
 66049 0001215D 89E5                <1> 		mov	ebp, esp
 66050                              <1> 		
 66051                              <1> 		;mov	ecx, 128 ; maximum path length = 128 bytes
 66052                              <1> 		; 29/07/2022
 66053 0001215F 31C9                <1> 		xor	ecx, ecx
 66054 00012161 B180                <1> 		mov	cl, 128
 66055 00012163 29CC                <1> 		sub	esp, ecx ; reserve 128 bytes (buffer) on stack
 66056 00012165 89E7                <1> 		mov	edi, esp ; destination address (kernel space)
 66057                              <1> 		; esi = source address (virtual, in user's memory space)
 66058 00012167 E80BECFFFF          <1> 		call	transfer_from_user_buffer
 66059 0001216C 720D                <1> 		jc	short loc_swp_xor_retn 
 66060                              <1> 		
 66061 0001216E 89E6                <1> 		mov	esi, esp ; temporary buffer (the path) on stack
 66062                              <1> loc_swp_fchar:
 66063 00012170 8A06                <1> 		mov	al, [esi]
 66064 00012172 3C20                <1> 		cmp	al, 20h
 66065 00012174 7711                <1> 		ja	short loc_swp_parse_path_name
 66066                              <1> 		;je	short loc_swp_fchar_next
 66067                              <1> 		; 29/07/2022
 66068 00012176 7203                <1> 		jb	short loc_swp_xor_retn
 66069                              <1> 
 66070                              <1> loc_swp_fchar_next:
 66071 00012178 46                  <1> 		inc	esi
 66072 00012179 EBF5                <1> 		jmp	short loc_swp_fchar
 66073                              <1> 
 66074                              <1> loc_swp_xor_retn:
 66075 0001217B 31C0                <1> 		xor	eax, eax
 66076 0001217D F9                  <1> 		stc
 66077                              <1> loc_swp_retn:
 66078 0001217E 89EC                <1> 		mov	esp, ebp
 66079 00012180 5D                  <1> 		pop	ebp
 66080                              <1> 
 66081                              <1> 		;mov	esi, FindFile_Drv
 66082 00012181 BE[24810100]        <1> 		mov	esi, FindFile_Name ; 12/10/2016
 66083 00012186 C3                  <1> 		retn 
 66084                              <1> 
 66085                              <1> ;loc_swp_fchar_next:
 66086                              <1> ;		inc	esi
 66087                              <1> ;		jmp	short loc_swp_fchar  
 66088                              <1> 
 66089                              <1> loc_swp_parse_path_name:
 66090 00012187 BF[E2800100]        <1> 		mov	edi, FindFile_Drv
 66091 0001218C E84689FFFF          <1> 		call	parse_path_name
 66092 00012191 72EB                <1> 		jc	short loc_swp_retn
 66093                              <1> 
 66094                              <1> loc_swp_checkfile_name:
 66095 00012193 803D[34840100]00    <1> 		cmp	byte [SWP_Mode], 0
 66096 0001219A 761E                <1> 		jna	short loc_swp_drv
 66097                              <1> 
 66098                              <1> 		; 10/10/2016 (valid file name checking)
 66099 0001219C BE[24810100]        <1> 		mov	esi, FindFile_Name
 66100 000121A1 803E20              <1> 		cmp	byte [esi], 20h
 66101 000121A4 76D5                <1> 		jna	short loc_swp_xor_retn
 66102                              <1> 
 66103                              <1> 		; 16/10/2016
 66104 000121A6 C605[33840100]00    <1> 		mov	byte [SWP_inv_fname], 0 ; reset 
 66105                              <1> 		; esi = file name address (ASCIIZ)
 66106 000121AD E8046CFFFF          <1> 		call	check_filename
 66107 000121B2 7306                <1> 		jnc	short loc_swp_drv
 66108                              <1> 
 66109 000121B4 FE05[33840100]      <1> 		inc	byte [SWP_inv_fname] ; set 	
 66110                              <1> loc_swp_drv:
 66111 000121BA 8A35[42780100]      <1> 		mov	dh, [Current_Drv]
 66112                              <1>                ;mov	[RUN_CDRV], dh
 66113                              <1> 
 66114 000121C0 8A15[E2800100]      <1> 		mov	dl, [FindFile_Drv]
 66115                              <1>                ;cmp	dl, dh
 66116 000121C6 3A15[42780100]      <1> 		cmp	dl, [Current_Drv]
 66117 000121CC 740D                <1> 		je	short loc_swp_change_directory
 66118                              <1> 
 66119 000121CE FE05[37840100]      <1> 		inc	byte [SWP_DRV_chg]
 66120 000121D4 E88A55FFFF          <1> 		call	change_current_drive
 66121 000121D9 72A3                <1> 		jc	short loc_swp_retn ; eax = error code
 66122                              <1> 		; eax = 0
 66123                              <1> 
 66124                              <1> loc_swp_change_directory:
 66125 000121DB 803D[E3800100]21    <1> 		cmp	byte [FindFile_Directory], 21h
 66126 000121E2 F5                  <1> 		cmc
 66127 000121E3 7399                <1> 		jnc	short loc_swp_retn
 66128                              <1> 
 66129 000121E5 FE05[37840100]      <1> 		inc	byte [SWP_DRV_chg]
 66130 000121EB FE05[68300100]      <1> 		inc	byte [Restore_CDIR]
 66131 000121F1 BE[E3800100]        <1> 		mov	esi, FindFile_Directory
 66132 000121F6 8A25[35840100]      <1> 		mov	ah, [SWP_Mode+1] 
 66133 000121FC E8EA82FFFF          <1> 		call	change_current_directory
 66134                              <1> 		;jc	short loc_swp_retn ; eax = error code
 66135                              <1> 		; 08/08/2022
 66136 00012201 7305                <1> 		jnc	short loc_swp_change_prompt_dir_string
 66137 00012203 E976FFFFFF          <1> 		jmp	loc_swp_retn	
 66138                              <1> 
 66139                              <1> loc_swp_change_prompt_dir_string:
 66140                              <1> 		; esi = PATH_Array
 66141                              <1> 		; eax = Current Directory First Cluster
 66142                              <1> 		; edi = Logical DOS Drive Description Table	
 66143 00012208 E80782FFFF          <1> 		call	change_prompt_dir_str 
 66144 0001220D 29C0                <1> 		sub	eax, eax ; 0
 66145 0001220F E96AFFFFFF          <1> 		jmp	loc_swp_retn 
 66146                              <1> 
 66147                              <1> reset_working_path:
 66148                              <1> 		; 06/10/2016 - TRDOS 386 (TRDOS v2.0)
 66149                              <1> 		;
 66150                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_reset_working_path")
 66151                              <1> 		; 05/02/2011 - 08/02/2011 
 66152                              <1> 		;
 66153                              <1> 		; Restores current drive and directory 
 66154                              <1> 		; 
 66155                              <1> 		; INPUT: none
 66156                              <1> 		; OUTPUT: DL = SWP_DRV, EAX = 0 -> OK
 66157                              <1> 		;
 66158                              <1> 		;    AX = 0 -> ESI = Logical Dos Drv Desc. Table
 66159                              <1> 		;
 66160                              <1> 		;    EAX, EBX, ECX, EDX, ESI, EDI will be changed
 66161                              <1> 		;
 66162                              <1> 
 66163                              <1>   
 66164 00012214 31C0                <1> 		xor	eax, eax
 66165 00012216 48                  <1> 		dec	eax 
 66166                              <1> 
 66167 00012217 668B15[36840100]    <1> 		mov	dx, [SWP_DRV]
 66168 0001221E 08F6                <1> 		or	dh, dh
 66169 00012220 742E                <1> 		jz	short loc_rwp_return
 66170                              <1> 
 66171 00012222 3A15[42780100]      <1> 		cmp	dl, [Current_Drv]
 66172 00012228 7407                <1> 		je	short loc_rwp_restore_cdir
 66173                              <1> loc_rwp_restore_cdrv:
 66174 0001222A E83455FFFF          <1> 		call	change_current_drive 
 66175 0001222F EB10                <1> 		jmp	short loc_rwp_restore_ok
 66176                              <1> loc_rwp_restore_cdir:
 66177 00012231 31DB                <1> 		xor	ebx, ebx
 66178 00012233 88D7                <1> 		mov	bh, dl
 66179 00012235 BE00010900          <1> 		mov	esi, Logical_DOSDisks
 66180 0001223A 01DE                <1> 		add	esi, ebx
 66181                              <1> 
 66182 0001223C E8D855FFFF          <1> 		call	restore_current_directory
 66183                              <1> 
 66184                              <1> loc_rwp_restore_ok:
 66185 00012241 668B15[36840100]    <1> 		mov	dx, [SWP_DRV]
 66186 00012248 31C0                <1> 		xor	eax, eax  
 66187 0001224A 66A3[37840100]      <1> 		mov	[SWP_DRV_chg], ax
 66188                              <1> loc_rwp_return:
 66189 00012250 C3                  <1> 		retn
 66190                              <1> 
 66191                              <1> get_file_name:
 66192                              <1> 		; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 66193                              <1> 		; 15/10/2016 - TRDOS 386 (TRDOS v2.0)
 66194                              <1> 		; Convert file name 
 66195                              <1> 		;	from directory entry format
 66196                              <1>                 ; 	to (8.3) dot file name format 
 66197                              <1> 		;
 66198                              <1> 		; TRDOS v1.0 (DIR.ASM, "get_file_name")
 66199                              <1>                 ; 2005 - 09/10/2011 	
 66200                              <1> 		; INPUT: 
 66201                              <1> 		;	DS:SI -> Directory Entry Format File Name
 66202                              <1> 		;       ES:DI -> DOS Dot File Name Address
 66203                              <1> 		; OUTPUT:
 66204                              <1> 		;	DS:SI -> DOS Dot File Name Address
 66205                              <1>                 ;	ES:DI -> Directory Entry Format File Name
 66206                              <1> 		;	
 66207                              <1> 		; TRDOS 386 (15/10/2016)
 66208                              <1> 		; INPUT:
 66209                              <1> 		;	ESI = File name addr in dir entry format
 66210                              <1> 		;	EDI = Dot file name address (destination)
 66211                              <1> 		; OUTPUT: 
 66212                              <1> 		;	File name is converted and moved
 66213                              <1> 		;	to destination (as 8.3 dot filename)
 66214                              <1> 		;  
 66215                              <1> 		; Modified registers: EAX, ECX
 66216                              <1> 
 66217                              <1>                 ; 2005 (TRDOS 8086) - 2016 (TRDOS 386)
 66218                              <1>                             
 66219 00012251 57                  <1> 		push	edi
 66220 00012252 56                  <1> 		push	esi
 66221 00012253 AC                  <1> 		lodsb
 66222 00012254 3C20                <1> 		cmp	al, 20h
 66223 00012256 7629                <1> 		jna	short pass_gfn_ext
 66224 00012258 56                  <1> 		push	esi
 66225 00012259 AA                  <1> 		stosb
 66226                              <1> 		;mov	ecx, 7
 66227                              <1> 		; 29/07/2022
 66228 0001225A 31C9                <1> 		xor	ecx, ecx
 66229 0001225C B107                <1> 		mov	cl, 7
 66230                              <1> loc_gfn_next_char:
 66231 0001225E AC                  <1> 		lodsb
 66232 0001225F 3C20                <1> 		cmp	al, 20h
 66233 00012261 7603                <1> 		jna	short pass_gfn_fn
 66234 00012263 AA                  <1> 		stosb
 66235 00012264 E2F8                <1> 		loop	loc_gfn_next_char
 66236                              <1> pass_gfn_fn:
 66237 00012266 5E                  <1> 		pop	esi
 66238 00012267 83C607              <1> 		add	esi, 7
 66239 0001226A AC                  <1> 		lodsb
 66240 0001226B 3C20                <1> 		cmp	al, 20h
 66241 0001226D 7612                <1> 		jna	short pass_gfn_ext
 66242 0001226F B42E                <1> 		mov	ah, '.'
 66243 00012271 86E0                <1> 		xchg	ah, al
 66244 00012273 66AB                <1> 		stosw
 66245 00012275 AC                  <1> 		lodsb
 66246 00012276 3C20                <1> 		cmp	al, 20h
 66247 00012278 7607                <1> 		jna	short pass_gfn_ext
 66248 0001227A AA                  <1> 		stosb
 66249 0001227B AC                  <1> 		lodsb
 66250 0001227C 3C20                <1> 		cmp	al, 20h
 66251 0001227E 7601                <1> 		jna	short pass_gfn_ext
 66252 00012280 AA                  <1> 		stosb
 66253                              <1> pass_gfn_ext:		
 66254 00012281 30C0                <1> 		xor	al, al
 66255 00012283 AA                  <1> 		stosb
 66256 00012284 5E                  <1> 		pop	esi
 66257 00012285 5F                  <1> 		pop	edi
 66258 00012286 C3                  <1> 		retn
 66259                              <1> 
 66260                              <1> set_hardware_int_vector:
 66261                              <1> 		; 18/03/2017
 66262                              <1> 		; 03/03/2017
 66263                              <1> 		; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
 66264                              <1> 		;
 66265                              <1> 		; SET/RESET HARDWARE INTERRUPT GATE
 66266                              <1> 		;
 66267                              <1> 		; Changes interrupt gate descriptor table
 66268                              <1> 		; (without changing default interrupt list)
 66269                              <1> 		;
 66270                              <1> 		; INPUT:
 66271                              <1> 		;	AL = IRQ number (0 to 15)
 66272                              <1> 		;	AH > 0 -> set
 66273                              <1> 		;	AH = 0 -> reset
 66274                              <1> 		;	
 66275                              <1> 		; Modified registers: eax, ebx, edx, edi 
 66276                              <1> 		;
 66277                              <1> 		
 66278 00012287 C0E002              <1> 		shl	al, 2 ; IRQ number * 4
 66279 0001228A 0FB6D8              <1> 		movzx	ebx, al
 66280                              <1> 
 66281 0001228D 08E4                <1> 		or	ah, ah
 66282 0001228F 7508                <1> 		jnz	short shintv_1 ; set (for user call service)
 66283                              <1> 		
 66284                              <1> 		; 18/03/2017
 66285 00012291 81C3[54380100]      <1> 		add	ebx, IRQ_list ; reset to default interrupt list
 66286 00012297 EB06                <1> 		jmp	short shintv_2
 66287                              <1> shintv_1:
 66288 00012299 81C3[C0220100]      <1> 		add	ebx, IRQ_u_list
 66289                              <1> shintv_2:	
 66290 0001229F 8B13                <1> 		mov	edx, [ebx] ; IRQ handler address
 66291                              <1> 		
 66292                              <1> 		; 03/03/2017
 66293 000122A1 D0E0                <1> 		shl	al, 1 ; IRQ number * 8 
 66294                              <1> 		; 18/03/2017
 66295 000122A3 0FB6F8              <1> 		movzx	edi, al 
 66296 000122A6 81C7[98750100]      <1> 		add	edi, idt + (8*32) ; IRQ 0 offset = idt + 256
 66297                              <1> 		
 66298 000122AC 89D0                <1> 		mov	eax, edx ; IRQ handler address
 66299 000122AE BB00000800          <1> 		mov	ebx, 80000h
 66300                              <1> 
 66301                              <1> 		;mov	edx, eax
 66302 000122B3 66BA008E            <1> 		mov	dx, 8E00h
 66303 000122B7 6689C3              <1> 		mov	bx, ax
 66304 000122BA 89D8                <1> 		mov	eax, ebx ; /* selector = 0x0008 = cs */
 66305                              <1>        			         ; /* interrupt gate - dpl=0, present */
 66306 000122BC AB                  <1> 		stosd	; selector & offset bits 0-15 	
 66307 000122BD 8917                <1> 		mov	[edi], edx ; attributes & offset bits 16-23
 66308                              <1> 
 66309 000122BF C3                  <1> 		retn
 66310                              <1> IRQ_u_list:
 66311                              <1> 		; 28/02/2017
 66312 000122C0 [41090000]          <1> 		dd	timer_int
 66313 000122C4 [9F100000]          <1> 		dd	kb_int
 66314 000122C8 [240B0000]          <1> 		dd	irq2
 66315 000122CC [00230100]          <1> 		dd	IRQ_service3
 66316 000122D0 [0A230100]          <1> 		dd	IRQ_service4
 66317 000122D4 [14230100]          <1> 		dd	IRQ_service5
 66318 000122D8 [D24D0000]          <1> 		dd	fdc_int	
 66319 000122DC [1E230100]          <1> 		dd	IRQ_service7
 66320 000122E0 [AC0A0000]          <1> 		dd	rtc_int
 66321 000122E4 [28230100]          <1> 		dd	IRQ_service9
 66322 000122E8 [32230100]          <1> 		dd	IRQ_service10
 66323 000122EC [3C230100]          <1> 		dd	IRQ_service11
 66324 000122F0 [46230100]          <1> 		dd	IRQ_service12
 66325 000122F4 [50230100]          <1> 		dd	IRQ_service13
 66326 000122F8 [54560000]          <1> 		dd	hdc1_int
 66327 000122FC [77560000]          <1> 		dd	hdc2_int
 66328                              <1> 
 66329                              <1> 		; 03/03/2017
 66330                              <1> 		; 27/02/2017
 66331                              <1> IRQ_service3:
 66332 00012300 36C605[A4890100]03  <1> 		mov	byte [ss:IRQnum], 3
 66333 00012308 EB4E                <1> 		jmp	short IRQ_service
 66334                              <1> IRQ_service4:
 66335 0001230A 36C605[A4890100]04  <1> 		mov	byte [ss:IRQnum], 4
 66336 00012312 EB44                <1> 		jmp	short IRQ_service
 66337                              <1> IRQ_service5:
 66338 00012314 36C605[A4890100]05  <1> 		mov	byte [ss:IRQnum], 5
 66339 0001231C EB3A                <1> 		jmp	short IRQ_service
 66340                              <1> IRQ_service7:
 66341 0001231E 36C605[A4890100]07  <1> 		mov	byte [ss:IRQnum], 7
 66342 00012326 EB30                <1> 		jmp	short IRQ_service
 66343                              <1> IRQ_service9:
 66344 00012328 36C605[A4890100]09  <1> 		mov	byte [ss:IRQnum], 9
 66345 00012330 EB26                <1> 		jmp	short IRQ_service
 66346                              <1> IRQ_service10:
 66347 00012332 36C605[A4890100]0A  <1> 		mov	byte [ss:IRQnum], 10
 66348 0001233A EB1C                <1> 		jmp	short IRQ_service
 66349                              <1> IRQ_service11:
 66350 0001233C 36C605[A4890100]0B  <1> 		mov	byte [ss:IRQnum], 11
 66351 00012344 EB12                <1> 		jmp	short IRQ_service
 66352                              <1> IRQ_service12:
 66353 00012346 36C605[A4890100]0C  <1> 		mov	byte [ss:IRQnum], 12
 66354 0001234E EB08                <1> 		jmp	short IRQ_service
 66355                              <1> IRQ_service13:
 66356 00012350 36C605[A4890100]0D  <1> 		mov	byte [ss:IRQnum], 13
 66357                              <1> 		;jmp	short IRQ_service
 66358                              <1> IRQ_service:
 66359                              <1> 		; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 66360                              <1> 		; 13/06/2017
 66361                              <1> 		; 11/06/2017
 66362                              <1> 		; 10/06/2017
 66363                              <1> 		; 01/03/2017, 04/03/2017
 66364                              <1> 		; 27/02/2017, 28/02/2017
 66365 00012358 1E                  <1> 		push	ds
 66366 00012359 06                  <1> 		push	es
 66367 0001235A 0FA0                <1> 		push	fs
 66368 0001235C 0FA8                <1> 		push	gs
 66369                              <1> 
 66370 0001235E 60                  <1> 		pushad	; eax,ecx,edx,ebx,esp,ebp,esi,edi
 66371 0001235F 66B91000            <1> 		mov     cx, KDATA
 66372 00012363 8ED9                <1>         	mov     ds, cx
 66373 00012365 8EC1                <1>         	mov     es, cx
 66374 00012367 8EE1                <1>         	mov     fs, cx
 66375 00012369 8EE9                <1>         	mov     gs, cx
 66376                              <1> 
 66377 0001236B 0F20D8              <1> 		mov	eax, cr3
 66378 0001236E A3[A0890100]        <1> 		mov	[IRQ_cr3], eax
 66379                              <1> 
 66380 00012373 A1[80770100]        <1> 		mov	eax, [k_page_dir]
 66381 00012378 0F22D8              <1> 		mov	cr3, eax 
 66382                              <1> 
 66383 0001237B A0[A4890100]        <1> 		mov	al, [IRQnum]
 66384                              <1> 
 66385                              <1> 		;mov	cl, [sysflg]
 66386                              <1> 		;mov	[u.r_mode], cl  ; system (0) or user mode (FFh) 
 66387                              <1> IRQsrv_0:
 66388 00012380 0FB6D8              <1> 		movzx	ebx, al
 66389 00012383 8A9B[8A370100]      <1> 		mov	bl, [ebx+IRQenum] ; IRQ (available) index number + 1
 66390                              <1> 		; 01/03/2017
 66391 00012389 FECB                <1> 		dec	bl  ; IRQ index number, 0 to 8
 66392                              <1> 		;js	IRQsrv_5 ; not available to use here!?
 66393                              <1> 		; 29/07/2022
 66394 0001238B 785E                <1> 		js	short IRQsrv_j5  ; (jump to IRQsrv_5)		
 66395                              <1> 		;		 
 66396 0001238D 80BB[6A890100]80    <1> 		cmp	byte [ebx+IRQ.method], 80h ; using by a dev or kernel? 
 66397 00012394 7205                <1> 		jb	short IRQsrv_1 ; no
 66398                              <1> 
 66399                              <1> 		; If the IRQ service is already owned by TRDOS 386 kernel
 66400                              <1> 		;	 or a Device driver
 66401                              <1> 		; we need to call 'dev_IRQ_service'
 66402                              <1> 
 66403                              <1> 		; IRQ number in AL
 66404 00012396 E80E010000          <1> 		call	dev_IRQ_service	 ; IRQ service for device drivers	
 66405                              <1> 		; IRQ number in AL
 66406                              <1> IRQsrv_1:		
 66407                              <1> 		; check user callback service status
 66408                              <1> 		; AL = IRQ number
 66409                              <1> 		; EBX = IRQ (Available) Index number
 66410                              <1> 
 66411 0001239B A2[93010300]        <1> 		mov	[u.irqwait], al ; set waiting IRQ flag
 66412                              <1> 
 66413 000123A0 8A83[58890100]      <1> 		mov	al, [ebx+IRQ.owner]
 66414 000123A6 20C0                <1> 		and	al, al
 66415                              <1> 		;jz	IRQsrv_5 ; it is not owned by a user/proc
 66416                              <1> 		; 29/07/2022
 66417 000123A8 7441                <1> 		jz	short IRQsrv_j5  ; (jump to IRQsrv_5)
 66418                              <1> 
 66419                              <1> 		; 03/03/2017
 66420 000123AA 89DA                <1> 		mov	edx, ebx
 66421 000123AC C0E202              <1> 		shl	dl, 2
 66422 000123AF 8B92[7C890100]      <1> 		mov	edx, [edx+IRQ.addr] ; S.R.B. or Callback service addr
 66423                              <1> 		
 66424 000123B5 8AA3[6A890100]      <1> 		mov	ah, [ebx+IRQ.method]
 66425 000123BB F6C401              <1> 		test	ah, 1
 66426 000123BE 7530                <1> 		jnz	short IRQsrv_4 ; Callback service method
 66427                              <1> 
 66428                              <1> 		; Signal Response Byte method
 66429                              <1> 		;mov	edx, [edx+IRQ.addr] ; Signal Response Byte address
 66430                              <1> 		;			    ; (Physical address, non-swappable) 	
 66431 000123C0 80E402              <1> 		and	ah, 2 ; bit 1, (S.R.B.) counter (auto increment) method
 66432 000123C3 8AA3[73890100]      <1> 		mov	ah, [ebx+IRQ.srb] ; Signal Response Byte value
 66433 000123C9 7408                <1> 		jz	short IRQsrv_2 ; fixed S.R.B. value
 66434                              <1> 		; counter method (auto increment)
 66435 000123CB FEC4                <1> 		inc	ah
 66436 000123CD 88A3[73890100]      <1> 		mov	[ebx+IRQ.srb], ah ; next (count) number
 66437                              <1> IRQsrv_2:
 66438 000123D3 8822                <1> 		mov	[edx], ah ; put S.R.B. val to the user's S.R.B. addr
 66439 000123D5 C605[93010300]00    <1> 		mov	byte [u.irqwait], 0 ; clear waiting IRQ flag
 66440                              <1> 
 66441 000123DC 3A05[6D010300]      <1> 		cmp	al, [u.uno]
 66442                              <1> 		;je	IRQsrv_5 ; the owner is current user/process
 66443                              <1> 		; 29/07/2022
 66444 000123E2 7407                <1> 		je	short IRQsrv_j5  ; (jump to IRQsrv_5)
 66445                              <1> IRQsrv_3:
 66446                              <1> 		; the owner is not current user/process
 66447                              <1> 		; AL = process number
 66448 000123E4 B202                <1> 		mov	dl, 2 ; priority, 2 = event (high)	
 66449 000123E6 E848FAFFFF          <1> 		call	set_run_sequence
 66450                              <1> 
 66451                              <1> 		; [u.irqwait] = waiting IRQ number for callback service
 66452                              <1> IRQsrv_j5:		; 29/07/2022
 66453 000123EB E998000000          <1> 		jmp	IRQsrv_5
 66454                              <1> IRQsrv_4:
 66455 000123F0 3A05[6D010300]      <1> 		cmp	al, [u.uno]  ; is the owner is current user/process?
 66456 000123F6 75EC                <1> 		jne	short IRQsrv_3 ; no !
 66457                              <1> 
 66458                              <1> 		; Check if an IRQ callback service already in progress
 66459 000123F8 803D[94010300]00    <1> 		cmp	byte [u.r_lock], 0
 66460                              <1> 		;ja	IRQsrv_5 ; nothing to do !  
 66461                              <1> 				     ; (we need to complete prev callback)
 66462                              <1> 		; 29/07/2022
 66463 000123FF 77EA                <1> 		ja	short IRQsrv_j5  ; (jump to IRQsrv_5)
 66464                              <1> 
 66465 00012401 803D[90010300]00    <1> 		cmp	byte [u.t_lock], 0
 66466 00012408 777E                <1> 		ja	short IRQsrv_5 ; nothing to do !  
 66467                              <1> 				     ; (we need to complete timer callback)
 66468                              <1> 
 66469                              <1> 		; 04/03/2017
 66470 0001240A C605[93010300]00    <1> 		mov	byte [u.irqwait], 0 ; reset/clear waiting IRQ flag
 66471                              <1> 
 66472 00012411 FE05[94010300]      <1> 		inc	byte [u.r_lock] ; 'IRQ callback service in progress' flag
 66473                              <1> 
 66474 00012417 8A0D[10010300]      <1> 		mov	cl, [sysflg]   ; (system call) mode flag (kernel/user)
 66475 0001241D 880D[95010300]      <1> 		mov	[u.r_mode], cl ; system mode (0) or user mode (FFh)
 66476                              <1> 
 66477                              <1> 		; 
 66478 00012423 8B2D[1C770100]      <1> 		mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
 66479 00012429 83ED14              <1> 		sub	ebp, 20		; eip, cs, eflags, esp, ss
 66480 0001242C 892D[14010300]      <1> 	 	mov	[u.sp], ebp
 66481 00012432 8925[18010300]      <1> 		mov	[u.usp], esp
 66482                              <1> 
 66483                              <1> 		;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
 66484                              <1> 
 66485 00012438 8B44241C            <1> 		mov	eax, [esp+28] ; pushed eax
 66486 0001243C A3[1C010300]        <1> 		mov	[u.r0], eax
 66487                              <1> 
 66488 00012441 E8A3E7FFFF          <1> 		call	wswap ; save user's registers & status
 66489                              <1> 
 66490                              <1> 		; software int is in ring 0 but IRQ handler must return to ring 3
 66491                              <1> 		; so, ring 3 return address and stack registers
 66492                              <1> 		; (eip, cs, eflags, esp, ss) 
 66493                              <1> 		; must be copied to IRQ handler return
 66494                              <1> 		; eip will be replaced by callback service routine address
 66495                              <1> 
 66496 00012446 C605[10010300]FF    <1> 		mov	byte [sysflg], 0FFh ; user mode
 66497                              <1> 
 66498                              <1> 		; system mode (system call)
 66499                              <1> 		;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
 66500                              <1> 				    ; ESP (u), SS (UDATA)
 66501                              <1> 
 66502 0001244D 8B4510              <1> 		mov	eax, [ebp+16]	; SS (UDATA)
 66503 00012450 89E6                <1> 		mov	esi, esp
 66504 00012452 50                  <1> 		push	eax
 66505 00012453 50                  <1> 		push	eax
 66506 00012454 89E7                <1> 		mov	edi, esp
 66507 00012456 893D[18010300]      <1> 		mov	[u.usp], edi
 66508 0001245C B908000000          <1> 		mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
 66509 00012461 F3A5                <1> 		rep	movsd
 66510 00012463 B104                <1> 		mov	cl, 4	
 66511 00012465 F3AB                <1> 		rep	stosd
 66512 00012467 893D[14010300]      <1> 		mov	[u.sp], edi
 66513 0001246D 89EE                <1> 		mov	esi, ebp
 66514 0001246F B105                <1> 		mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
 66515 00012471 F3A5                <1> 		rep	movsd
 66516                              <1> 		;
 66517                              <1> 
 66518 00012473 8B0D[74010300]      <1> 		mov	ecx, [u.pgdir]
 66519 00012479 890D[A0890100]      <1> 		mov	[IRQ_cr3], ecx
 66520                              <1> 
 66521                              <1> set_IRQ_callback_addr:
 66522                              <1> 		;
 66523                              <1> 		; This routine sets return address
 66524                              <1> 		; to start of user's interrupt
 66525                              <1> 		; service (callback) address
 66526                              <1> 		;
 66527                              <1> 		; INPUT:
 66528                              <1> 		;	EDX = callback routine/service address
 66529                              <1> 		;	      (virtual, not physical address!)	
 66530                              <1> 		;	[u.sp] = kernel stack, points to
 66531                              <1> 		;		 user's EIP,CS,EFLAGS,ESP,SS
 66532                              <1> 		;		 registers.
 66533                              <1> 		; OUTPUT:
 66534                              <1> 		;	EIP (user) = callback (service) address
 66535                              <1> 		;	CS (user) = UCODE
 66536                              <1> 		;	EFLAGS (user) = flags before callback 	 
 66537                              <1> 		;       ESP (user) = ESP-4 (user, before callback) 
 66538                              <1> 		;	[ESP](user) = EIP (user) before callback
 66539                              <1> 		;
 66540                              <1> 		; Note: If CPU was in user mode while entering 
 66541                              <1> 		;	the timer interrupt service routine,
 66542                              <1> 		;	'IRET' will get return to callback routine
 66543                              <1> 		;	immediately. If CPU was in system/kernel mode  
 66544                              <1> 		;	'iret' will get return to system call and
 66545                              <1> 		;	then, callback routine will be return address
 66546                              <1> 		;	from system call. (User's callback/service code
 66547                              <1> 		;	will be able to return to normal return address
 66548                              <1> 		;	via a 'sysrele' system call at the end.) 
 66549                              <1> 		;
 66550                              <1> 		; Note: User's IRQ callback service code must be ended
 66551                              <1> 		;	with a 'sysrele' system call !
 66552                              <1> 		;
 66553                              <1> 		;	For example:
 66554                              <1> 		;
 66555                              <1> 		;	audio_IRQ_callback:
 66556                              <1> 		;	    ...	 
 66557                              <1> 		;	    <load DMA buffer with audio data>
 66558                              <1> 		;	    ...
 66559                              <1> 		;	    mov eax, 39 ; 'sysrele'
 66560                              <1> 		;	    int 40h ; TRDOS 386 system call (interrupt)		
 66561                              <1> 		;
 66562                              <1> 		
 66563                              <1> 		;mov	edx, [edx+IRQ.addr] ; Callback service address
 66564                              <1> 		;			    ; (Virtual address)
 66565                              <1> 		
 66566 0001247F 8B2D[14010300]      <1> 		mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
 66567 00012485 895500              <1> 		mov	[ebp], edx
 66568                              <1> IRQsrv_5:
 66569                              <1> 		; EOI & return
 66570                              <1> 		; 01/08/2020
 66571                              <1> 		; 11/06/2017
 66572                              <1> 		; 10/06/2017 
 66573                              <1> 		;mov	al, [IRQnum]
 66574 00012488 B020                <1> 		mov	al, 20h ; 01/08/2020
 66575 0001248A FA                  <1> 		cli
 66576                              <1> 		;cmp	al, 7
 66577 0001248B 803D[A4890100]07    <1> 		cmp	byte [IRQnum], 7 ; 01/08/2020	
 66578 00012492 7602                <1> 		jna	short IRQsrv_6
 66579                              <1> 		;
 66580                              <1> 		;;mov	al, EOI	; end of interrupt
 66581                              <1> 		;mov	al, 20h ; 01/08/2020
 66582                              <1> 		;cli		; disable interrupts till stack cleared
 66583                              <1> 		;out	INTB00, al ; For controll2 #2
 66584 00012494 E6A0                <1> 		out	0A0h, al
 66585                              <1> IRQsrv_6:
 66586                              <1> 		;mov	byte [IRQnum], 0 ; reset
 66587                              <1> 		;;mov	al, EOI	; end of interrupt
 66588                              <1> 		;mov	al, 20h ; 01/08/2020
 66589                              <1> 		;cli		; disable interrupts till stack cleared
 66590                              <1> 		;out	INTA00, al ; end of interrupt to 8259 - 1
 66591 00012496 E620                <1> 		out	20h, al	
 66592                              <1> IRQsrv_7:	
 66593                              <1> 		;; 13/06/2017
 66594                              <1> 		;or	word [ebp+8], 200h ; force enabling interrupts
 66595                              <1> 		;
 66596 00012498 8B0D[A0890100]      <1> 		mov 	ecx, [IRQ_cr3]	; previous content of cr3 register
 66597 0001249E 0F22D9              <1>  		mov	cr3, ecx	; restore cr3 register content
 66598                              <1> 		;
 66599 000124A1 61                  <1> 		popad ; edi,esi,ebp,(icrement esp by 4),ebx,edx,ecx,eax
 66600                              <1> 		;
 66601 000124A2 0FA9                <1> 		pop	gs
 66602 000124A4 0FA1                <1> 		pop	fs
 66603 000124A6 07                  <1> 		pop	es
 66604 000124A7 1F                  <1> 		pop	ds
 66605                              <1> 		;
 66606 000124A8 CF                  <1> 		iretd	; return from interrupt
 66607                              <1> 
 66608                              <1> ; 17/04/2021
 66609                              <1> ; ('get_device_number' procedure is disabled as temporary)
 66610                              <1> 
 66611                              <1> ;get_device_number:
 66612                              <1> ;		; 08/10/2016
 66613                              <1> ;		; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
 66614                              <1> ;		;
 66615                              <1> ;		; This procedure compares name of requested
 66616                              <1> ;		; device with kernel device names and
 66617                              <1> ;		; installable device names. If names match, 
 66618                              <1> ;		; the relevant device index (entry) number 
 66619                              <1> ;		; will be returned the caller (sysopen) 
 66620                              <1> ;		; for the requested device.
 66621                              <1> ;		;
 66622                              <1> ;		; NOTE: Installable device drivers must
 66623                              <1> ;		; be loaded before using 'sysopen'
 66624                              <1> ;		; (opendev) system call.
 66625                              <1> ;		;
 66626                              <1> ;		; INPUT:
 66627                              <1> ;		;    ESI = device name address (ASCIIZ)
 66628                              <1> ;		;         (in kernel's memory space)  
 66629                              <1> ;  		;    max name length = 8 without '/dev/')
 66630                              <1> ;		;    Device name will be capitalized 
 66631                              <1> ;		;    and if there is, '/dev/' will be
 66632                              <1> ;		;    removed from name before comparising)
 66633                              <1> ;		;
 66634                              <1> ;		; OUTPUT:
 66635                              <1> ;		;    cf = 0 -> 
 66636                              <1> ;		;      EAX (AL) = device entry/index number 	 	
 66637                              <1> ;		;    cf = 1 -> device not found (installed)
 66638                              <1> ;		;	       or invalid device name
 66639                              <1> ;		;	       (AL=0)
 66640                              <1> ;		;    device_name = device name address (asciiz)
 66641                              <1> ;			;
 66642                              <1> ;		; Modified registers: EAX, EBX, ESI, EDI
 66643                              <1> ;
 66644                              <1> ;		mov	edi, device_name
 66645                              <1> ;		call 	lodsb_capitalize
 66646                              <1> ;		mov	ah, al
 66647                              <1> ;		cmp	al, '/'
 66648                              <1> ;		jne	short gdn_1
 66649                              <1> ;		mov	edi, device_name
 66650                              <1> ;		call 	lodsb_capitalize
 66651                              <1> ;gdn_0:
 66652                              <1> ;		and	al, al ; 0 ?
 66653                              <1> ;		jz	short gdn_err ; null name after '/'
 66654                              <1> ;gdn_1:
 66655                              <1> ;		cmp	al, 'D'
 66656                              <1> ;		jne	short gdn_2
 66657                              <1> ;		call 	lodsb_capitalize
 66658                              <1> ;		cmp	al, 'E'
 66659                              <1> ;		jne	short gdn_2
 66660                              <1> ;		call 	lodsb_capitalize
 66661                              <1> ;		cmp	al, 'V'
 66662                              <1> ;		jne	short gdn_2			
 66663                              <1> ;		lodsb
 66664                              <1> ;		cmp	al, '/'
 66665                              <1> ;		je	short gdn_4
 66666                              <1> ;gdn_2:
 66667                              <1> ;		cmp	ah, '/'
 66668                              <1> ;		jne	short gdn_5
 66669                              <1> ;gdn_err:		
 66670                              <1> ;		; invalid device name or device not found
 66671                              <1> ;		xor	eax, eax ; 0
 66672                              <1> ;		stc
 66673                              <1> ;		retn
 66674                              <1> ;gdn_3:
 66675                              <1> ;		cmp	al, '/'
 66676                              <1> ;		jne	short gdn_5
 66677                              <1> ;gdn_4:
 66678                              <1> ;		mov	edi, device_name
 66679                              <1> ;		jmp	short gdn_6
 66680                              <1> ;gdn_5:
 66681                              <1> ;		cmp	al, 0
 66682                              <1> ;		je	short gdn_7
 66683                              <1> ;gdn_6:
 66684                              <1> ;		call	lodsb_capitalize
 66685                              <1> ;		cmp	edi, device_name + 8
 66686                              <1> ;		jb	short gdn_3
 66687                              <1> ;		cmp	al, 0
 66688                              <1> ;		jne	short gdn_err
 66689                              <1> ;		cmp	edi, device_name + 1
 66690                              <1> ;		jna	short gdn_err ; null name after '/'
 66691                              <1> ;gdn_7:
 66692                              <1> ;		stosb
 66693                              <1> ;		; zero padding ("NAME",0,0,0,0)
 66694                              <1> ;		cmp	edi, device_name + 8
 66695                              <1> ;		jb	short gdn_7
 66696                              <1> ;gdn_8:
 66697                              <1> ;		; search for kernel device names
 66698                              <1> ;		mov	esi, device_name 
 66699                              <1> ;		mov	edi, KDEV_NAME
 66700                              <1> ;		xor	eax, eax
 66701                              <1> ;gdn_9:
 66702                              <1> ;		cmpsd	
 66703                              <1> ;		jne	short gdn_10
 66704                              <1> ;		cmpsd
 66705                              <1> ;		jne	short gdn_11
 66706                              <1> ;		jmp	short gdn_17 ; match
 66707                              <1> ;gdn_10:
 66708                              <1> ;		cmpsd  ; add esi, 4 & add edi, 4
 66709                              <1> ;gdn_11:
 66710                              <1> ;		mov	esi, device_name
 66711                              <1> ;		inc	al
 66712                              <1> ;		cmp	al, NumOfKernelDevNames
 66713                              <1> ;		jb	short gdn_9
 66714                              <1> ;gdn_12:
 66715                              <1> ;		; search for installable device names
 66716                              <1> ;		; esi = offset device_name 
 66717                              <1> ;		mov	edi, IDEV_NAME
 66718                              <1> ;		sub	al, al ; 0
 66719                              <1> ;gdn_13:
 66720                              <1> ;		cmpsd	
 66721                              <1> ;		jne	short gdn_14
 66722                              <1> ;		cmpsd
 66723                              <1> ;		jne	short gdn_15
 66724                              <1> ;		jmp	short gdn_19 ; match
 66725                              <1> ;gdn_14:
 66726                              <1> ;		cmpsd  ; add esi, 4 & add edi, 4
 66727                              <1> ;gdn_15:
 66728                              <1> ;		mov	esi, device_name
 66729                              <1> ;		inc	al
 66730                              <1> ;		cmp	al, NumOfInstallableDevices
 66731                              <1> ;		jb	short gdn_13
 66732                              <1> ;
 66733                              <1> ;gdn_16: 	; error: invalid device name (not found) !
 66734                              <1> ;		xor	al, al
 66735                              <1> ;		stc
 66736                              <1> ;		retn
 66737                              <1> ;
 66738                              <1> ;gdn_17:	; name match (with one of kernel device names)
 66739                              <1> ;		;
 66740                              <1> ;		; convert KDEV_NAME index to 
 66741                              <1> ;		; KDEV_NUMBER index
 66742                              <1> ;		; (different names are used for same devices)
 66743                              <1> ;		; (example: "COM1" & "TTY8" = device number 18) 
 66744                              <1> ;		mov	ebx, eax ; < 256
 66745                              <1> ;		mov	al, [KDEV_NUMBER+ebx]
 66746                              <1> ;
 66747                              <1> ;		; check if empty dev entry in the list
 66748                              <1> ;		cmp	byte [DEV_OPENMODE+eax], 0
 66749                              <1> ;		ja	short gdn_18 ; it must be already set
 66750                              <1> ;
 66751                              <1> ;		; (re)set device name and access flags
 66752                              <1> ;		; (remain open work will be easy after that)
 66753                              <1> ;		; (NOTE: here, data will be copied to bss section)
 66754                              <1> ;		mov	bl, al
 66755                              <1> ;		sub	edi, 8 ; kernel device name address (data)
 66756                              <1> ;		shl	bx, 2 
 66757                              <1> ;		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
 66758                              <1> ;		mov	bl, [KDEV_ACCESS+eax] ; kernel dev list (data)
 66759                              <1> ;		mov	[DEV_ACCESS+eax], bl ; (all) device list (bss)
 66760                              <1> ;gdn_18:
 66761                              <1> ;		inc	al ; 1 to NumOfKernelDevNames (<=7Fh)
 66762                              <1> ;		; eax = device index/entry number
 66763                              <1> ;		retn		
 66764                              <1> ;
 66765                              <1> ;gdn_19:	; name match (with one of installable device names)
 66766                              <1> ;		;
 66767                              <1> ;		; al = 0 to NumOfInstallableDevices - 1 (<=7Fh)
 66768                              <1> ;
 66769                              <1> ;		mov	ebx, eax
 66770                              <1> ;		add	bl, NumOfKernelDevices 	; < NUMOFDEVICES	
 66771                              <1> ;
 66772                              <1> ;		; check if empty dev entry in the list
 66773                              <1> ;		cmp	byte [DEV_OPENMODE+ebx], 0
 66774                              <1> ;		ja	short gdn_20 ; it must be already set
 66775                              <1> ;
 66776                              <1> ;		; (re)set device name and access flags
 66777                              <1> ;		; (remain open work will be easy after that)
 66778                              <1> ;		sub	edi, 8 ; installable device name address
 66779                              <1> ;		shl	bx, 2 ;*4
 66780                              <1> ;		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
 66781                              <1> ;		shr	bx, 2
 66782                              <1> ;		mov	al, [IDEV_FLAGS+eax] ; installable dev list
 66783                              <1> ;		mov	[DEV_ACCESS+ebx], al ; (all) device list
 66784                              <1> ;gdn_20:	
 66785                              <1> ;		mov	al, bl
 66786                              <1> ;		; eax = device index/entry number ; < NUMOFDEVICES  
 66787                              <1> ;		retn
 66788                              <1> 
 66789                              <1> ;lodsb_capitalize:
 66790                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
 66791                              <1> ;	; INPUT -> [esi] = character
 66792                              <1> ;	;          edi = destination
 66793                              <1> ;	; OUTPUT -> AL contains capitalized character
 66794                              <1> ;	;	   esi = esi+1
 66795                              <1> ;	;	   edi = edi+1	
 66796                              <1> ;	; 
 66797                              <1> ;	lodsb	
 66798                              <1> ;	cmp	al, 61h
 66799                              <1> ;    	jb	short lodsb_cap_retn
 66800                              <1> ;     	cmp	al, 7Ah
 66801                              <1> ;     	ja	short lodsb_cap_retn
 66802                              <1> ;     	and	al, 0DFh
 66803                              <1> ;lodsb_cap_retn:
 66804                              <1> ;	stosb
 66805                              <1> ;	retn
 66806                              <1> 
 66807                              <1> ; 17/04/2021
 66808                              <1> ; ('device_open' procedure is disabled as temporary)
 66809                              <1> 
 66810                              <1> ;device_open:
 66811                              <1> ;	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
 66812                              <1> ;	; Complete device opening work for sysopen (device)
 66813                              <1> ;	;
 66814                              <1> ;	; INPUT -> 
 66815                              <1> ;	;	EAX = Device Number (AL)
 66816                              <1> ;	;        CL = Open mode (1 = read, 2 = write)
 66817                              <1> ;	;	 CH = Device access byte (bit 0 = 0)		
 66818                              <1> ;	; OUTPUT ->
 66819                              <1> ;	;	EAX = Device Number	
 66820                              <1> ;	;	CF = 0 -> device has been opened
 66821                              <1> ;	;	CF = 1 -> device could not be opened
 66822                              <1> ;	;
 66823                              <1> ;	;  Modified registers: ebx, (edx, ecx, esi, edi, ebp)
 66824                              <1> ;	;
 66825                              <1> ;
 66826                              <1> ;	mov	ebx, eax
 66827                              <1> ;	shl	bx, 2 ; *4
 66828                              <1> ;
 66829                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
 66830                              <1> ;	jz	short d_open_2 ; Kernel device
 66831                              <1> ;	; installable device
 66832                              <1> ;d_open_1:
 66833                              <1> ;       jmp	dword [ebx+IDEV_OADDR-4]
 66834                              <1> ;d_open_2:
 66835                              <1> ;	jmp	dword [ebx+KDEV_OADDR-4]
 66836                              <1> 
 66837                              <1> ; 17/04/2021
 66838                              <1> ; ('device_close' procedure is disabled as temporary)
 66839                              <1> 
 66840                              <1> ;device_close:
 66841                              <1> ;	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
 66842                              <1> ;	; Complete device closing work for sysclose (device)
 66843                              <1> ;	;
 66844                              <1> ;	; INPUT -> 
 66845                              <1> ;	;	EAX = Device Number (AL)
 66846                              <1> ;	;        CL = Open mode (1 = read, 2 = write)
 66847                              <1> ;	;	 CH = Device access byte (bit 0 = 0)		
 66848                              <1> ;	; OUTPUT ->
 66849                              <1> ;	;	EAX = Device Number	
 66850                              <1> ;	;	CF = 0 -> device has been closed
 66851                              <1> ;	;	CF = 1 -> device could not be closed
 66852                              <1> ;	;
 66853                              <1> ;	; Modified registers: ebx, (edx, ecx, esi, edi, ebp)
 66854                              <1> ;	;
 66855                              <1> ;
 66856                              <1> ;	mov	ebx, eax
 66857                              <1> ;	shl	bx, 2 ; *4
 66858                              <1> ;
 66859                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
 66860                              <1> ;	jz	short d_close_2 ; Kernel device
 66861                              <1> ;	; installable device
 66862                              <1> ;d_close_1:
 66863                              <1> ;       jmp	dword [ebx+IDEV_CADDR-4]
 66864                              <1> ;d_close_2:
 66865                              <1> ;	jmp	dword [ebx+KDEV_CADDR-4]	
 66866                              <1> 
 66867                              <1> ;rnull:
 66868                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
 66869                              <1> ;	; read null (read from null device)
 66870                              <1> ;	retn
 66871                              <1> 
 66872                              <1> ;wnull:
 66873                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
 66874                              <1> ;	; write null (write to null device)
 66875                              <1> ;	retn
 66876                              <1> 
 66877                              <1> dev_IRQ_service:
 66878                              <1> 	; 12/05/2017
 66879                              <1> 	; 13/04/2017
 66880                              <1> 	; 27/02/2017 - TRDOS 386 (TRDOS v2.0)
 66881                              <1> 	; INPUT ->
 66882                              <1> 	;	AL = IRQ Number (0 to 15)
 66883                              <1> 	;	
 66884 000124A9 53                  <1> 	push	ebx
 66885 000124AA 0FB6D8              <1> 	movzx	ebx, al
 66886 000124AD C0E302              <1> 	shl	bl, 2 ; * 4	
 66887 000124B0 8B9B[18890100]      <1> 	mov	ebx, [ebx+DEV_INT_HNDLR]
 66888 000124B6 21DB                <1> 	and 	ebx, ebx
 66889 000124B8 7404                <1>         jz	short dIRQ_s_retn
 66890 000124BA 50                  <1> 	push	eax
 66891                              <1> 
 66892 000124BB FFD3                <1> 	call	ebx
 66893                              <1> 
 66894 000124BD 58                  <1> 	pop	eax
 66895                              <1> dIRQ_s_retn:
 66896 000124BE 5B                  <1> 	pop	ebx
 66897 000124BF C3                  <1> 	retn		
 66898                              <1> 
 66899                              <1> set_dev_IRQ_service:
 66900                              <1> 	; 09/08/2022
 66901                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
 66902                              <1> 	; 13/04/2017 - TRDOS 386 (TRDOS v2.0)
 66903                              <1> 	;
 66904                              <1> 	; Set Device Interrupt Service
 66905                              <1> 	;
 66906                              <1> 	; INPUT ->
 66907                              <1> 	;	AL = IRQ Number
 66908                              <1> 	;	EBX = Hardware Interrupt Service Address
 66909                              <1> 	;
 66910                              <1> 	; Note: There is not a validation check here
 66911                              <1> 	;	because this procedure is called by
 66912                              <1> 	;	TRDOS 386 kernel !
 66913                              <1> 	;       (Even if a device driver does not exist
 66914                              <1> 	;	this setting may be used by sysaudio
 66915                              <1> 	;	and other system calls for hardware
 66916                              <1> 	;	components which use IRQ method for I/O.)
 66917                              <1> 	;
 66918                              <1> 	;push	esi
 66919 000124C0 0FB6F0              <1> 	movzx	esi, al
 66920                              <1> 	;shl	si, 2 ; * 4	
 66921                              <1> 	; 09/08/2022
 66922 000124C3 C1E602              <1> 	shl	esi, 2 ; * 4
 66923 000124C6 899E[18890100]      <1> 	mov	[esi+DEV_INT_HNDLR], ebx
 66924                              <1> 	;pop	esi
 66925 000124CC C3                  <1> 	retn		
 66926                              <1> 
 66927                              <1> sysaudio: ; AUDIO FUNCTIONS
 66928                              <1> 	; 29/07/2022 (TRDOS 386 v2.0.5)
 66929                              <1> 	; 12/02/2021 (TRDOS 386 v2.0.3) 
 66930                              <1> 	; 28/07/2020
 66931                              <1> 	; 27/07/2020
 66932                              <1> 	; 10/10/2017
 66933                              <1> 	; 22/06/2017
 66934                              <1> 	; 28/05/2017, 04/06/2017, 05/06/2017, 10/06/2017
 66935                              <1> 	; 01/05/2017, 12/05/2017, 15/05/2017, 20/05/2017
 66936                              <1> 	; 21/04/2017, 22/04/2017, 23/04/2017, 24/04/2017
 66937                              <1> 	; 10/04/2017, 13/04/2017, 14/04/2017, 16/04/2017
 66938                              <1> 	; 03/04/2017 (VIA VT8237R)
 66939                              <1> 	; 01/04/2016 (trdosk6.s -> tdosk8.s)
 66940                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 66941                              <1> 	;
 66942                              <1> 	; Inputs:
 66943                              <1> 	;
 66944                              <1> 	;	BH = 0 -> Beep (PC Speaker)
 66945                              <1> 	;	     BL = Duration Counter (1 for 1/64 second)
 66946                              <1> 	;	     CX = Frequency Divisor (1193180/Frequency)
 66947                              <1> 	;		 (1331 for 886 Hz)
 66948                              <1> 	;
 66949                              <1> 	;	01/04/2017	
 66950                              <1> 	;
 66951                              <1> 	; 	BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
 66952                              <1> 	;	     BL = 0 : PC SPEAKER
 66953                              <1> 	;		  1 : SOUND BLASTER 16
 66954                              <1> 	;		  2 : INTEL AC'97
 66955                              <1> 	;		  3 : VIA VT8237R (VT8233)			 				
 66956                              <1> 	;		  4 : INTEL HDA
 66957                              <1> 	;	      5-FEh : unknown/invalid
 66958                              <1> 	;	        ; 04/06/2017
 66959                              <1> 	;		FFh : Get current audio device id
 66960                              <1> 	;
 66961                              <1> 	; 	BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
 66962                              <1> 	;		ECX = Audio Buffer Size (must be equal to
 66963                              <1> 	;		      the half of DMA buffer size) 
 66964                              <1> 	;		EDX = Virtual Address of the buffer
 66965                              <1> 	;		      (This is not DMA buffer!)
 66966                              <1> 	;
 66967                              <1> 	;	BH = 3 -> INITIALIZE AUDIO DEVICE
 66968                              <1> 	;	     BL = 0,2 -> for Signal Response Byte	 	
 66969                              <1> 	;	     	CL = Signal Response Byte Value (fixed)
 66970                              <1> 	;				if BL = 0
 66971                              <1> 	;	             auto increment of S.R.B. value
 66972                              <1> 	;			 	if BL = 2
 66973                              <1> 	;	        EDX = Signal Response (Return) Byte Address
 66974                              <1> 	;	     	   			
 66975                              <1> 	;	     BL = 1 for CallBack Method	 	
 66976                              <1> 	;	    	EDX = CallBack Service Address (Virtual)
 66977                              <1> 	;
 66978                              <1> 	;	     BL > 2 -> invalid function	
 66979                              <1> 	;
 66980                              <1> 	;	    (Audio buffer must be allocated before
 66981                              <1> 	;	     initialization.) 		
 66982                              <1> 	;
 66983                              <1> 	;	BH = 4 -> START TO PLAY
 66984                              <1> 	;	     BL = Mode
 66985                              <1> 	;		  Bit 0 = mono/stereo (1 = stereo)		
 66986                              <1> 	;		  Bit 1 = 8 bit / 16 bit (1 = 16 bit)
 66987                              <1> 	;	     CX = Sampling Rate (Hz)
 66988                              <1> 	;
 66989                              <1> 	;	BH = 5 -> PAUSE
 66990                              <1> 	;	     BL = Any
 66991                              <1> 	;
 66992                              <1> 	;	BH = 6 -> CONTINUE TO PLAY
 66993                              <1> 	;	     BL = Any
 66994                              <1> 	;
 66995                              <1> 	;	BH = 7 -> STOP
 66996                              <1> 	;	     BL = Any
 66997                              <1> 	;
 66998                              <1> 	;	BH = 8 -> RESET 
 66999                              <1> 	;	     BL = Any
 67000                              <1> 	;
 67001                              <1> 	;	BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
 67002                              <1> 	;	     BL = Any	
 67003                              <1> 	;	
 67004                              <1> 	;	BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
 67005                              <1> 	;	     BL = Any
 67006                              <1> 	;
 67007                              <1> 	;	BH = 11 -> SET VOLUME LEVEL
 67008                              <1> 	;	     BL: (Bit 0 to 6)
 67009                              <1> 	;		  0 = Master (Playback, Lineout) volume
 67010                              <1> 	;	     CL = Left Channel Volume
 67011                              <1> 	;	     CH = Right Channel Volume
 67012                              <1> 	;	
 67013                              <1> 	;	     Note: If BL >= 80h (Bit 7 of BL is set),
 67014                              <1> 	;	     volume level will be set for next playing
 67015                              <1> 	;	     (actual volume level will not be changed
 67016                              <1> 	;	     immediately)	
 67017                              <1> 	;
 67018                              <1> 	;	BH = 12 -> DISABLE AUDIO DEVICE
 67019                              <1> 	;	     (reset audio device and unlink dma buffer)	
 67020                              <1> 	;	     BL = Any	  		  	  	
 67021                              <1> 	;
 67022                              <1> 	;    	12/05/2017
 67023                              <1> 	;	BH = 13 -> MAP DMA BUFFER TO USER
 67024                              <1> 	;	    (for direct access to system's dma buffer)
 67025                              <1> 	;
 67026                              <1> 	;	     ECX = map size in bytes 
 67027                              <1> 	;		  (will be rounded up to page borders)
 67028                              <1> 	;	     EDX = Virtual Address of the buffer
 67029                              <1> 	;		  (Will be rounded up to page borders)
 67030                              <1> 	;
 67031                              <1> 	;	05/06/2017	
 67032                              <1> 	;    	04/06/2017
 67033                              <1> 	;	BH = 14 -> GET AUDIO DEVICE INFO
 67034                              <1> 	;	     BL: 0 = Audio Controller Info
 67035                              <1> 	;	       > 0 = Invalid for now! 
 67036                              <1> 	;
 67037                              <1> 	;	22/06/2017	
 67038                              <1> 	;	BH = 15 -> GET CURRENT SOUND DATA (for graphics)
 67039                              <1> 	;	     BL: 0 -> PCM OUT data
 67040                              <1> 	;	       > 0 -> Invalid for now! 
 67041                              <1> 	;	     ECX = 0 -> Get DMA Buffer Pointer
 67042                              <1> 	;		 EDX = Not Used
 67043                              <1> 	;	     ECX > 0 -> Byte count for buffer (EDX)	 	
 67044                              <1> 	;	         EDX = Buffer Address (Virtual)	
 67045                              <1> 	;
 67046                              <1> 	;	10/10/2017	
 67047                              <1> 	;	BH = 16 -> UPDATE DMA BUFFER DATA
 67048                              <1> 	;		   (by using the Audio Buffer content)
 67049                              <1> 	;	     BL = 0 : Update dma half buffer in sequence
 67050                              <1> 	;		      (automatic destination)	
 67051                              <1> 	;		  1 : Update 1st half of the dma buffer
 67052                              <1> 	;		  2 : Update 2nd half of the dma buffer
 67053                              <1> 	;		  3-FEh: Invalid!
 67054                              <1> 	;		  FFh = Get current flag value
 67055                              <1> 	;			(Half buffer number -1)
 67056                              <1> 	;
 67057                              <1> 	;
 67058                              <1> 	; Outputs:
 67059                              <1> 	;
 67060                              <1> 	;	For BH = 0 -> Beep
 67061                              <1> 	;	    None
 67062                              <1> 	;
 67063                              <1> 	;	01/04/2017
 67064                              <1> 	;
 67065                              <1> 	; 	For BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
 67066                              <1> 	;	    AH = 0 : PC SPEAKER
 67067                              <1> 	;		 1 : SOUND BLASTER 16
 67068                              <1> 	;		 2 : INTEL AC'97
 67069                              <1> 	;		 3 : VIA VT8237R (VT8233)			 				
 67070                              <1> 	;		 4 : INTEL HDA
 67071                              <1> 	;	      5-FFh : unknown/invalid
 67072                              <1> 	;	    AL = mode status
 67073                              <1> 	;		 bit 0 = mono /stereo (1 = stereo)
 67074                              <1> 	;		 bit 1 = 8 bit / 16 bit ( 1 = 16 bit)
 67075                              <1> 	;	    04/06/2017
 67076                              <1> 	;	    EBX = PCI DEVICE/VENDOR ID (if >0)
 67077                              <1> 	;		 (BX = VENDOR ID) 
 67078                              <1> 	;	    (if CF = 1 -> Error code in EAX)
 67079                              <1> 	;
 67080                              <1> 	; 	For BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
 67081                              <1> 	;	    EAX = Physical Address of the buffer
 67082                              <1> 	;	    (if CF = 1 -> Error code in EAX)
 67083                              <1> 	;
 67084                              <1> 	;	For BH = 3 -> INITIALIZE AUDIO DEVICE
 67085                              <1> 	;	    (if CF = 1 -> Error code in EAX)
 67086                              <1> 	;
 67087                              <1> 	;	For BH = 4 -> START TO PLAY
 67088                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
 67089                              <1> 	;
 67090                              <1> 	;	For BH = 5 -> PAUSE
 67091                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
 67092                              <1> 	;
 67093                              <1> 	;	For BH = 6 -> CONTINUE TO PLAY
 67094                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
 67095                              <1> 	;
 67096                              <1> 	;	For BH = 7 -> STOP
 67097                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67098                              <1> 	;
 67099                              <1> 	;	For BH = 8 -> RESET 
 67100                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67101                              <1> 	;
 67102                              <1> 	;	For BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
 67103                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67104                              <1> 	;	
 67105                              <1> 	;	For BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
 67106                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67107                              <1> 	;
 67108                              <1> 	;	For BH = 11 -> SET VOLUME LEVEL
 67109                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67110                              <1> 	;
 67111                              <1> 	;	For BH = 12 -> DISABLE AUDIO DEVICE
 67112                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
 67113                              <1> 	; 
 67114                              <1> 	;    	12/05/2017
 67115                              <1> 	;	For BH = 13 -> MAP DMA BUFFER TO USER
 67116                              <1> 	;	    EAX = Physical Address of the buffer
 67117                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
 67118                              <1> 	;
 67119                              <1> 	;    	04/06/2017
 67120                              <1> 	;	For BH = 14 -> GET AUDIO DEVICE INFO
 67121                              <1> 	;	(for BL = 0) ; 05/06/2017	
 67122                              <1> 	;	    EAX = IRQ Number in AL
 67123                              <1> 	;		  Audio Device Number in AH 
 67124                              <1> 	;	    EBX = DEV/VENDOR ID
 67125                              <1> 	;		 (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
 67126                              <1> 	;	    ECX = BUS/DEV/FN 
 67127                              <1> 	;		 (00000000BBBBBBBBDDDDDFFF00000000)
 67128                              <1> 	;	    EDX = NABMBAR/NAMBAR (for AC97)
 67129                              <1> 	;		  (Low word, DX = NAMBAR address)
 67130                              <1> 	;	    EDX = Base IO Addr (DX) for SB16 & VT8233	  			  		
 67131                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
 67132                              <1> 	;	                 (ERR_DEV_NOT_RDY = 15)  
 67133                              <1> 	;
 67134                              <1> 	;	22/06/2017	
 67135                              <1> 	;	For BH = 15 -> GET CURRENT SOUND DATA
 67136                              <1> 	;			 (for graphics)
 67137                              <1> 	;	(for BL = 0)
 67138                              <1> 	;	 If ECX input is 0 
 67139                              <1> 	;	    EAX = DMA Buffer Current Position (Offset)
 67140                              <1> 	;	 If ECX input >  0
 67141                              <1> 	;	    EAX = Actual transfer count 		 	
 67142                              <1> 	;	    (Sound samples will be copied from 
 67143                              <1> 	;	     Current DMA Buffer Position to EDX
 67144                              <1> 	;	     virtual address as EAX bytes.)
 67145                              <1> 	;	 ((If CF = 1 ->  Error code in EAX))
 67146                              <1> 	;
 67147                              <1> 	;
 67148                              <1> 	;	10/10/2017	
 67149                              <1> 	;	For BH = 16 -> UPDATE DMA BUFFER DATA
 67150                              <1> 	;	    EAX = 0, if the updated (or current)
 67151                              <1> 	;		     half buffer is DMA half buffer 1
 67152                              <1> 	;	    EAX = 1, if the updated (or current)
 67153                              <1> 	; 		     half buffer is DMA half buffer 2 	  	
 67154                              <1> 	;	    (If CF = 1 -> Error code in EAX)	
 67155                              <1> 	;	
 67156                              <1> 
 67157 000124CD 80FF11              <1> 	cmp	bh, AUDIO1L/4
 67158 000124D0 0F831CA8FFFF        <1> 	jnb	sysret
 67159                              <1> 
 67160 000124D6 C0E702              <1> 	shl	bh, 2 ; *4	
 67161 000124D9 0FB6F7              <1> 	movzx	esi, bh
 67162                              <1> 
 67163                              <1> 	; 22/04/2017
 67164 000124DC 31C0                <1> 	xor	eax, eax
 67165 000124DE A3[1C010300]        <1> 	mov	[u.r0], eax  ; 0
 67166                              <1> 		
 67167 000124E3 FF96[EE240100]      <1> 	call	dword [esi+AUDIO1]
 67168                              <1> 	;jc	error
 67169 000124E9 E904A8FFFF          <1> 	jmp	sysret	
 67170                              <1> 
 67171 000124EE [00230000]          <1> AUDIO1:	dd	_beep ; 12/02/2021	
 67172                              <1> 	;dd	beep ; FUNCTION = 0 (bl = Duration Counter
 67173                              <1> 		     ; 		     cx = Frequency Divisor
 67174 000124F2 [32250100]          <1> 	dd	soundc_detect
 67175 000124F6 [CE250100]          <1> 	dd	sound_alloc
 67176 000124FA [8C260100]          <1> 	dd	soundc_init
 67177 000124FE [3A280100]          <1> 	dd	sound_play
 67178 00012502 [CD280100]          <1> 	dd	sound_pause
 67179 00012506 [F7280100]          <1> 	dd	sound_continue
 67180 0001250A [21290100]          <1> 	dd	sound_stop
 67181 0001250E [4C290100]          <1> 	dd	soundc_reset
 67182 00012512 [7F290100]          <1> 	dd	soundc_cancel
 67183 00012516 [A5290100]          <1> 	dd	sound_dalloc
 67184 0001251A [D0290100]          <1> 	dd	sound_volume
 67185 0001251E [102A0100]          <1> 	dd	soundc_disable
 67186 00012522 [7F2A0100]          <1> 	dd	sound_dma_map
 67187 00012526 [ED2A0100]          <1> 	dd	soundc_info
 67188 0001252A [4C2B0100]          <1> 	dd	sound_data
 67189 0001252E [EE2B0100]          <1> 	dd	sound_update
 67190                              <1> 	
 67191                              <1> AUDIO1L	EQU	$ - AUDIO1
 67192                              <1> 
 67193                              <1> soundc_detect:
 67194                              <1> 	; FUNCTION = 1
 67195                              <1> 	; bl = Audio device type number 
 67196                              <1> 	; (0= pc speaker, 1 = sound blaster 16, 2 = intel ac97
 67197                              <1> 	;  3= via vt823x, 4 = intel HDA, 0FFh= any)
 67198                              <1> 	
 67199                              <1> 	; 04/06/2017
 67200 00012532 8A25[A9890100]      <1> 	mov	ah, [audio_device]
 67201 00012538 80FBFF              <1> 	cmp	bl, 0FFh ; get current audio device id
 67202 0001253B 7408                <1> 	je	short sysaudio0
 67203                              <1> 
 67204 0001253D 20E4                <1> 	and	ah, ah
 67205 0001253F 741E                <1> 	jz	short soundc_get_dev
 67206                              <1> 
 67207 00012541 38DC                <1> 	cmp	ah, bl
 67208 00012543 7567                <1> 	jne	short soundc_dev_err
 67209                              <1> 
 67210                              <1> sysaudio0:	
 67211 00012545 A0[AA890100]        <1> 	mov	al, [audio_mode]
 67212                              <1> sysaudio1:
 67213 0001254A A3[1C010300]        <1> 	mov	[u.r0], eax
 67214 0001254F 8B1D[B4890100]      <1> 	mov	ebx, [audio_vendor] ; (DEVICE/VENDOR ID)
 67215 00012555 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
 67216 0001255B 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
 67217 0001255E C3                  <1> 	retn
 67218                              <1> 
 67219                              <1> soundc_get_dev:
 67220                              <1> 	; 28/05/2017
 67221                              <1> 	; 03/04/2017, 24/04/2017
 67222 0001255F C605[A8890100]00    <1> 	mov	byte [audio_pci], 0
 67223 00012566 80FB03              <1> 	cmp	bl, 3 ; VIA VT8233 (VT8237R) Audio Controller & AC97 Codec
 67224                              <1> 	;jne	short soundc_get_dev_sb
 67225                              <1> 	; 28/05/2017
 67226 00012569 7220                <1> 	jb	short soundc_get_dev_sb
 67227 0001256B 773F                <1> 	ja	short soundc_dev_err  ; temporary (28/05/2017)
 67228                              <1> 	;  		
 67229 0001256D E81B160000          <1> 	call	DetectVT8233
 67230 00012572 7238                <1> 	jc	short soundc_dev_err
 67231                              <1> 	; eax = 0
 67232                              <1> 
 67233                              <1> 	;mov	ebx, [audio_vendor]
 67234                              <1> 	; ebx = DEVICE/VENDOR ID
 67235                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
 67236                              <1> 
 67237 00012574 B003                <1> 	mov	al, 3  ; VIA VT8237R (VT3233) Audio Controller
 67238 00012576 88C4                <1> 	mov	ah, al
 67239                              <1> 
 67240                              <1> soundc_get_pci_dev_ok: ; 28/05/2017
 67241 00012578 FE05[A8890100]      <1> 	inc	byte [audio_pci] ; = 1
 67242                              <1> soundc_get_dev_ok:
 67243                              <1> 	
 67244                              <1> soundc_get_dev_sb16_ok:
 67245 0001257E A2[A9890100]        <1> 	mov	[audio_device], al
 67246 00012583 8825[AA890100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability	
 67247 00012589 EBBF                <1> 	jmp	short sysaudio1
 67248                              <1> 
 67249                              <1> soundc_get_dev_sb:
 67250                              <1> 	; 24/04/2017
 67251 0001258B 80FB01              <1> 	cmp	bl, 1 ; Sound Blaster 16
 67252 0001258E 750E                <1> 	jne	short soundc_get_dev_ich ; 28/05/2017
 67253                              <1> 	;
 67254 00012590 E8F11A0000          <1> 	call	DetectSB
 67255 00012595 7215                <1> 	jc	short soundc_dev_err
 67256 00012597 B801030000          <1> 	mov	eax, 0301h ; Sound Blaster 16
 67257 0001259C EBE0                <1> 	jmp	short soundc_get_dev_sb16_ok
 67258                              <1> 
 67259                              <1> soundc_get_dev_ich:
 67260                              <1> 	; 28/05/2017
 67261                              <1> 	;cmp	bl, 2 ; Intel AC'97 Audio Controller (ICH)
 67262                              <1> 	;jne	short soundc_dev_err ; Temporary  (28/05/2017)
 67263                              <1> 	;			     ; (Here will be modified just after
 67264                              <1> 	;			     ; new sound card code will be ready!)  	
 67265 0001259E E8DD150000          <1> 	call	DetectICH
 67266 000125A3 7207                <1> 	jc	short soundc_dev_err
 67267                              <1> 	;
 67268 000125A5 B802030000          <1> 	mov	eax, 0302h ; AC'97 (ICH)
 67269 000125AA EBCC                <1> 	jmp	short soundc_get_pci_dev_ok
 67270                              <1> 
 67271                              <1> soundc_dev_err:
 67272 000125AC B80F000000          <1> 	mov	eax, ERR_DEV_NOT_RDY ; Device not ready !
 67273                              <1> 	; 29/07/2022
 67274                              <1> 	;sub	eax, eax
 67275                              <1> 	;mov	al, ERR_DEV_NOT_RDY
 67276 000125B1 EB0C                <1> 	jmp	short sysaudio_err
 67277                              <1> 
 67278                              <1> sound_buff_error:
 67279 000125B3 B82E000000          <1> 	mov	eax, ERR_BUFFER ; Buffer error !
 67280                              <1> 	; 29/07/2022
 67281                              <1> 	;sub	eax, eax
 67282                              <1> 	;mov	al, ERR_BUFFER
 67283 000125B8 EB05                <1> 	jmp	short sysaudio_err
 67284                              <1> 
 67285                              <1> soundc_respond_err:
 67286                              <1> 	; ERR_TIME_OUT ; 'time out !' error	
 67287 000125BA B819000000          <1> 	mov	eax, ERR_DEV_NOT_RESP ; 'device not responding !' error
 67288                              <1> 	; 29/07/2022
 67289                              <1> 	;sub	eax, eax
 67290                              <1> 	;mov	al, ERR_DEV_NOT_RESP
 67291                              <1> sysaudio_err:
 67292 000125BF A3[1C010300]        <1> 	mov	[u.r0], eax
 67293 000125C4 A3[84010300]        <1> 	mov	[u.error], eax
 67294 000125C9 E904A7FFFF          <1> 	jmp	error
 67295                              <1> 
 67296                              <1> sound_alloc:
 67297                              <1> 	; FUNCTION =  2
 67298                              <1> 	; ecx = audio buffer size (in bytes)
 67299                              <1> 	; edx = audio buffer address (virtual)
 67300                              <1> 	; 27/07/2020
 67301                              <1> 	; 28/05/2017
 67302                              <1> 	; 01/05/2017, 15/05/2017
 67303                              <1> 	; 21/04/2017, 24/04/2017
 67304 000125CE 803D[A8890100]00    <1> 	cmp	byte [audio_pci], 0
 67305 000125D5 7708                <1> 	ja	short snd_alloc_0
 67306                              <1> 	; Max. 64KB DMA buffer !!!
 67307 000125D7 81F900800000        <1> 	cmp	ecx, 32768
 67308 000125DD 77D4                <1> 	ja	short sound_buff_error
 67309                              <1> snd_alloc_0:
 67310                              <1> 	; 15/05/2017
 67311 000125DF 81F900100000        <1> 	cmp	ecx, 4096 ; PAGE_SIZE
 67312 000125E5 72CC                <1> 	jb	short sound_buff_error
 67313                              <1> 	;
 67314 000125E7 A1[BC890100]        <1> 	mov	eax, [audio_buffer] ; audio buffer address (current)
 67315 000125EC 09C0                <1> 	or	eax, eax
 67316 000125EE 7445                <1> 	jz	short snd_alloc_2
 67317                              <1> 	; audio buffer exists !
 67318 000125F0 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
 67319 000125F6 3A1D[D1890100]      <1> 	cmp	bl, [audio_user]
 67320 000125FC 0F85FE000000        <1> 	jne	sndc_owner_error ; not owner !
 67321 00012602 39D0                <1> 	cmp	eax, edx ; same virtual buffer address ?
 67322 00012604 7508                <1> 	jne	short snd_alloc_1
 67323 00012606 3B0D[C4890100]      <1> 	cmp	ecx, [audio_buff_size]
 67324 0001260C 746C                <1> 	je	short snd_alloc_3 ; Nothing to do !
 67325                              <1> 				  ; Buffer has been set already!
 67326                              <1> snd_alloc_1:
 67327 0001260E 51                  <1> 	push	ecx
 67328 0001260F 52                  <1> 	push	edx
 67329 00012610 89C3                <1> 	mov	ebx, eax ; audio buffer address (current)
 67330 00012612 8B0D[C4890100]      <1> 	mov	ecx, [audio_buff_size]
 67331 00012618 E8EB38FFFF          <1> 	call	deallocate_user_pages
 67332 0001261D 5A                  <1> 	pop	edx
 67333 0001261E 59                  <1> 	pop	ecx
 67334 0001261F 31C0                <1> 	xor	eax, eax ; 0
 67335 00012621 A3[BC890100]        <1> 	mov	[audio_buffer], eax  ; 0
 67336 00012626 A3[C0890100]        <1>  	mov	[audio_p_buffer], eax  ; 0
 67337 0001262B A3[C4890100]        <1>  	mov	[audio_buff_size], eax
 67338 00012630 A2[D1890100]        <1> 	mov	[audio_user], al ; 0
 67339                              <1> snd_alloc_2:
 67340 00012635 89D3                <1> 	mov	ebx, edx
 67341                              <1> 	; 01/05/2017
 67342 00012637 BA00F0FFFF          <1> 	mov	edx, ~PAGE_OFF ; truncating page offsets
 67343                              <1> 			       ; for aligning to page borders	
 67344                              <1> 	;and	eax, edx
 67345 0001263C 21D3                <1> 	and	ebx, edx
 67346 0001263E 21D1                <1> 	and	ecx, edx
 67347                              <1> 	; 15/05/2017
 67348                              <1> 	; EAX = Beginning address (physical)
 67349                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 67350                              <1> 	; ECX = Number of bytes to be allocated		
 67351 00012640 E87835FFFF          <1> 	call	allocate_memory_block
 67352 00012645 0F8268FFFFFF        <1> 	jc	sound_buff_error
 67353                              <1> 	; EAX = Physical address of the allocated memory block
 67354                              <1> 	; ECX = Allocated bytes (as truncated to page border)
 67355                              <1> 	; EBX = Virtual address (as truncated to page border)
 67356 0001264B 50                  <1> 	push	eax
 67357 0001264C 53                  <1> 	push	ebx
 67358 0001264D 51                  <1> 	push	ecx
 67359 0001264E E89D39FFFF          <1> 	call	allocate_user_pages
 67360 00012653 59                  <1> 	pop	ecx
 67361 00012654 5B                  <1> 	pop	ebx
 67362 00012655 58                  <1> 	pop	eax
 67363 00012656 722A                <1> 	jc	short snd_alloc_4  ; insufficient memory, buff error
 67364                              <1> 	; eax = physical address of the user's audio buffer
 67365                              <1> 	; ebx = virtual address of the user's audio buffer
 67366                              <1> 	; ecx = buffer size (in bytes)
 67367 00012658 A3[C0890100]        <1> 	mov	[audio_p_buffer], eax
 67368 0001265D 891D[BC890100]      <1> 	mov	[audio_buffer], ebx
 67369 00012663 890D[C4890100]      <1>  	mov	[audio_buff_size], ecx
 67370 00012669 8A15[6D010300]      <1> 	mov	dl, [u.uno]
 67371 0001266F 8815[D1890100]      <1> 	mov	[audio_user], dl
 67372 00012675 A3[1C010300]        <1> 	mov	[u.r0], eax
 67373                              <1> snd_alloc_3:
 67374                              <1> 	; 27/07/2020
 67375 0001267A C605[D0890100]00    <1> 	mov	byte [audio_flag], 0 ; clear dma half buffer flag
 67376                              <1> 	;	
 67377 00012681 C3                  <1> 	retn
 67378                              <1> snd_alloc_4:
 67379                              <1> 	; 15/05/2017
 67380                              <1> 	; EAX = Beginning address (physical)
 67381                              <1> 	; ECX = Number of bytes to be deallocated
 67382 00012682 E84337FFFF          <1> 	call	deallocate_memory_block
 67383 00012687 E927FFFFFF          <1> 	jmp	sound_buff_error  ; insufficient memory, buff error
 67384                              <1> 
 67385                              <1> soundc_init:
 67386                              <1> 	; FUNCTION = 3 
 67387                              <1> 	; bl = method (0= s.r.b., 1= callback, 2= auto incr s.r.b.)
 67388                              <1> 	; cl = signal response byte (initial or fixed) value
 67389                              <1> 	; edx = signal response byte or callback address
 67390                              <1> 	; 07/08/2022
 67391                              <1> 	; 29/07/2022
 67392                              <1> 	; 27/07/2020
 67393                              <1> 	; 28/05/2017
 67394                              <1> 	; 12/05/2017, 20/05/2017
 67395                              <1> 	; 22/04/2017, 23/04/2017, 24/04/2017
 67396                              <1> 	; 13/04/2017, 14/04/2017, 16/04/2017, 21/04/2017
 67397                              <1> 	; 03/04/2017, 10/04/2017
 67398                              <1> 
 67399 0001268C A0[A9890100]        <1> 	mov	al, [audio_device]
 67400 00012691 20C0                <1> 	and	al, al
 67401 00012693 754A                <1> 	jnz	short sndc_init6
 67402                              <1> 	;
 67403 00012695 C605[A8890100]00    <1> 	mov	byte [audio_pci], 0
 67404 0001269C 52                  <1> 	push	edx
 67405 0001269D 53                  <1> 	push	ebx
 67406 0001269E 51                  <1> 	push	ecx
 67407 0001269F E8E2190000          <1> 	call	DetectSB
 67408 000126A4 7213                <1> 	jc	short sndc_init8
 67409 000126A6 66B80103            <1> 	mov	ax, 0301h ; Sound Blaster 16
 67410 000126AA EB1E                <1> 	jmp	short sndc_init7
 67411                              <1> 
 67412                              <1> sndc_init11:
 67413                              <1> 	; 28/05/2017
 67414 000126AC E8CF140000          <1> 	call	DetectICH ; Detect AC'97 (ICH) Audio Controller
 67415 000126B1 7217                <1> 	jc	short sndc_init7
 67416 000126B3 66B80203            <1> 	mov	ax, 0302h ; Intel AC'97 Audio Device
 67417 000126B7 EB0B                <1> 	jmp	short sndc_init12 ; (PCI device)
 67418                              <1> 
 67419                              <1> sndc_init8:
 67420 000126B9 E8CF140000          <1> 	call	DetectVT8233
 67421                              <1> 	;jc	short sndc_init7
 67422                              <1> 	; 29/07/2022
 67423 000126BE 72EC                <1> 	jc	short sndc_init11 ; 28/05/2017
 67424                              <1> 
 67425                              <1> 	; eax = 0
 67426 000126C0 B003                <1> 	mov	al, 3	; VIA VT8237R (VT3233) Audio Controller
 67427 000126C2 88C4                <1> 	mov	ah, al
 67428                              <1> 
 67429                              <1> sndc_init12:
 67430 000126C4 FE05[A8890100]      <1> 	inc	byte [audio_pci] ; = 1
 67431                              <1> sndc_init7:
 67432 000126CA 59                  <1> 	pop	ecx
 67433 000126CB 5B                  <1> 	pop	ebx
 67434 000126CC 5A                  <1> 	pop	edx
 67435                              <1> 	;jc	soundc_dev_err
 67436                              <1> 	; 29/07/2022
 67437 000126CD 7305                <1> 	jnc	short sndc_init14
 67438 000126CF E9D8FEFFFF          <1> 	jmp	soundc_dev_err
 67439                              <1> sndc_init14:
 67440 000126D4 A2[A9890100]        <1> 	mov	[audio_device], al
 67441 000126D9 8825[AA890100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability
 67442                              <1> 
 67443                              <1> sndc_init6:
 67444 000126DF 833D[BC890100]00    <1> 	cmp	dword [audio_buffer], 0
 67445                              <1> 	;jna	sound_buff_error
 67446                              <1> 	; 29/07/2022
 67447 000126E6 7705                <1> 	ja	short sndc_init19
 67448 000126E8 E9C6FEFFFF          <1> 	jmp	sound_buff_error ; 07/08/2022
 67449                              <1> sndc_init19:
 67450 000126ED A0[6D010300]        <1> 	mov	al, [u.uno]
 67451 000126F2 8A25[D1890100]      <1> 	mov	ah, [audio_user]
 67452 000126F8 08E4                <1> 	or	ah, ah
 67453 000126FA 7418                <1> 	jz	short sndc_init0
 67454 000126FC 38E0                <1> 	cmp	al, ah
 67455 000126FE 7419                <1> 	je	short sndc_init1
 67456                              <1> 
 67457                              <1> sndc_owner_error:
 67458 00012700 B80B000000          <1> 	mov	eax, ERR_NOT_OWNER ; 'permission denied !' error
 67459                              <1> 	; 29/07/2022
 67460                              <1> 	;sub	eax, eax
 67461                              <1> 	;mov	al, ERR_NOT_OWNER
 67462                              <1> sndc_perm_error:
 67463 00012705 A3[1C010300]        <1> 	mov	[u.r0], eax
 67464 0001270A A3[84010300]        <1> 	mov	[u.error], eax
 67465 0001270F E9BEA5FFFF          <1> 	jmp	error
 67466                              <1> sndc_init0:
 67467 00012714 A2[D1890100]        <1> 	mov	[audio_user], al
 67468                              <1> sndc_init1:
 67469 00012719 8915[D4890100]      <1> 	mov	[audio_cb_addr], edx
 67470 0001271F 881D[D2890100]      <1> 	mov	[audio_cb_mode], bl
 67471 00012725 880D[D3890100]      <1> 	mov	[audio_srb], cl
 67472                              <1> 
 67473                              <1> 	; 27/07/2020
 67474                              <1> 	;mov	byte [audio_flag], 0  ; clear dma half buffer flag
 67475                              <1> 
 67476                              <1> 	; 24/04/2017
 67477 0001272B 803D[A9890100]03    <1> 	cmp	byte [audio_device], 3 ; VT8233 (VT8237R)
 67478 00012732 7435                <1> 	je	short sndc_init9
 67479                              <1> 	;ja	short soundc_respond_err ; temporary (28/05/2017)
 67480 00012734 803D[A9890100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
 67481 0001273B 7510                <1> 	jne	short sndc_init13
 67482 0001273D BB[9E420100]        <1> 	mov	ebx, sb16_int_handler
 67483                              <1> 	; Note: 'SbInit' is at 'Start to Play' stage
 67484                              <1> 	; 20/05/2017
 67485 00012742 66C705[DE890100]08- <1> 	mov	word [audio_master_volume], 0808h ; 2/8
 67486 0001274A 08                  <1>
 67487 0001274B EB34                <1> 	jmp	short sndc_init10
 67488                              <1> sndc_init13:
 67489                              <1> 	; 28/05/2017
 67490 0001274D 803D[A9890100]02    <1> 	cmp	byte [audio_device], 2 ; AC 97 (ICH)	
 67491                              <1> 	;jne	soundc_respond_err ; temporary (28/05/2017)
 67492                              <1> 	; 29/07/2022
 67493 00012754 7405                <1> 	je	short sndc_init16
 67494                              <1> sndc_init15:
 67495 00012756 E95FFEFFFF          <1> 	jmp	soundc_respond_err
 67496                              <1> sndc_init16:
 67497 0001275B E8881C0000          <1> 	call	ac97_codec_config
 67498                              <1> 	;jc	soundc_respond_err ; codec error !
 67499                              <1> 	; 29/07/2022
 67500 00012760 72F4                <1> 	jc	short sndc_init15
 67501                              <1> 
 67502 00012762 BB[CA450100]        <1> 	mov	ebx, ac97_int_handler
 67503 00012767 EB18                <1> 	jmp	short sndc_init10	
 67504                              <1> 
 67505                              <1> sndc_init9:
 67506                              <1> 	;call	reset_codec
 67507                              <1> 	;; eax = 1
 67508                              <1> 	;call	codec_io_w16 ; w32
 67509 00012769 E88E150000          <1> 	call	init_codec ; 28/05/2017
 67510                              <1> 	;jc	soundc_respond_err ; codec error !
 67511                              <1> 	; 29/07/2022
 67512 0001276E 72E6                <1> 	jc	short sndc_init15
 67513                              <1> 
 67514 00012770 E8A4170000          <1> 	call	channel_reset
 67515                              <1> 
 67516                              <1> 	; setup the Codec (actually mixer registers) 
 67517 00012775 E8CD160000          <1>         call    codec_config  ; unmute codec, set rates.
 67518                              <1> 	;jc	soundc_respond_err ; codec error !
 67519                              <1> 	; 29/07/2022
 67520 0001277A 72DA                <1> 	jc	short sndc_init15
 67521                              <1> 
 67522 0001277C BB[AB3E0100]        <1> 	mov	ebx, vt8233_int_handler
 67523                              <1> sndc_init10:
 67524                              <1> 	; 13/04/2017
 67525 00012781 A0[AB890100]        <1> 	mov	al, [audio_intr] ; IRQ number	
 67526 00012786 E835FDFFFF          <1> 	call	set_dev_IRQ_service
 67527                              <1> 
 67528                              <1> 	; SETUP (audio) INTERRUPT CALLBACK SERVICE
 67529 0001278B 8A1D[AB890100]      <1> 	mov	bl, [audio_intr] ; IRQ number
 67530 00012791 8A3D[D2890100]      <1> 	mov	bh, [audio_cb_mode]
 67531 00012797 FEC7                <1> 	inc	bh  ; 1 = Signal Response Byte method (fixed value)
 67532                              <1> 		    ; 2 = Callback service method
 67533                              <1> 		    ; 3 = Auto Increment S.R.B. method 	
 67534 00012799 8A0D[D3890100]      <1> 	mov	cl, [audio_srb]
 67535 0001279F 8B15[D4890100]      <1> 	mov	edx, [audio_cb_addr]
 67536 000127A5 A0[D1890100]        <1> 	mov	al, [audio_user]
 67537                              <1> 	; 14/04/2017
 67538 000127AA E8B8040000          <1>  	call	set_irq_callback_service
 67539                              <1> 	; 16/04/2017
 67540 000127AF A3[1C010300]        <1> 	mov	[u.r0], eax
 67541                              <1> 	;jnc	sysret
 67542 000127B4 7316                <1> 	jnc	short sndc_init2 ; 21/04/2017
 67543                              <1> 	;
 67544 000127B6 A3[84010300]        <1> 	mov	dword [u.error], eax
 67545                              <1> 
 67546 000127BB A0[AB890100]        <1> 	mov	al, [audio_intr] ; IRQ number	
 67547 000127C0 31DB                <1> 	xor	ebx, ebx ; reset IRQ handler address
 67548 000127C2 E8F9FCFFFF          <1> 	call	set_dev_IRQ_service
 67549                              <1> 
 67550 000127C7 E906A5FFFF          <1> 	jmp	error
 67551                              <1> 
 67552                              <1> sndc_init2:
 67553                              <1> 	; 21/04/2017
 67554 000127CC 8B0D[C4890100]      <1> 	mov	ecx, [audio_buff_size] ; audio buffer size
 67555 000127D2 D1E1                <1> 	shl	ecx, 1 ; *2
 67556 000127D4 A1[C8890100]        <1> 	mov	eax, [audio_dma_buff]
 67557 000127D9 21C0                <1> 	and	eax, eax
 67558 000127DB 7415                <1> 	jz	short sndc_init3
 67559                              <1> 
 67560 000127DD 8B15[CC890100]      <1> 	mov	edx, [audio_dmabuff_size] ; dma buffer size
 67561 000127E3 39D1                <1> 	cmp	ecx, edx
 67562 000127E5 7428                <1> 	je	short sndc_init5
 67563                              <1> 
 67564 000127E7 87CA                <1> 	xchg	ecx, edx
 67565 000127E9 E8DC35FFFF          <1> 	call	deallocate_memory_block
 67566 000127EE 87D1                <1> 	xchg	edx, ecx
 67567 000127F0 31C0                <1> 	xor	eax, eax
 67568                              <1> sndc_init3:
 67569                              <1> 	; 12/05/2017
 67570 000127F2 803D[A9890100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
 67571 000127F9 7515                <1> 	jne	short sndc_init4
 67572 000127FB C705[C8890100]-     <1> 	mov	dword [audio_dma_buff], sb16_dma_buffer
 67573 00012801 [00000200]          <1>
 67574 00012805 C705[CC890100]0000- <1> 	mov	dword [audio_dmabuff_size], 65536
 67575 0001280D 0100                <1>
 67576                              <1> 	;xor	eax, eax
 67577                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
 67578                              <1> sndc_init5:	; 29/07/2022
 67579 0001280F C3                  <1> 	retn 
 67580                              <1> 
 67581                              <1> sndc_init4:
 67582                              <1> 	; EAX = Beginning address (physical)
 67583                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 67584                              <1> 	; ECX = Number of bytes to be allocated	(>0)	
 67585 00012810 E8A833FFFF          <1> 	call	allocate_memory_block
 67586                              <1> 	;jc	sound_buff_error
 67587                              <1> 	; 29/07/2022
 67588 00012815 7305                <1> 	jnc	short sndc_init17
 67589 00012817 E997FDFFFF          <1> 	jmp	sound_buff_error
 67590                              <1> 
 67591                              <1> sndc_init17:	; 29/07/2022
 67592                              <1> 	; set dma buffer address and size parameters
 67593 0001281C A3[C8890100]        <1> 	mov	[audio_dma_buff], eax ; dma buffer address
 67594 00012821 890D[CC890100]      <1> 	mov	[audio_dmabuff_size], ecx ; dma buffer size
 67595                              <1> ;	; EAX = Beginning (physical) addr of the allocated mem block
 67596                              <1> ;	; ECX = Num of allocated bytes (rounded up to page borders)
 67597                              <1> ;	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
 67598                              <1> ;	ja	short sndc_init4
 67599                              <1> ;
 67600                              <1> ;	; Sound Blaster 16 uses classic DMA
 67601                              <1> ;	mov	edx, eax
 67602                              <1> ;	add	edx, ecx
 67603                              <1> ;	cmp	edx, 1000000h ; 1st 16 MB
 67604                              <1> ;	jna	short sndc_init4
 67605                              <1> ;
 67606                              <1> ;	; error !
 67607                              <1> ;	; restore Memory Allocation Table Content
 67608                              <1> ;	; EAX = Beginning address (physical)
 67609                              <1> ;	; ECX = Number of bytes to be deallocated
 67610                              <1> ;	call	deallocate_memory_block
 67611                              <1> ;	; reset dma buffer address and size parameters
 67612                              <1> ;	xor	eax, eax ; 0
 67613                              <1> ;	mov	[audio_dma_buff], eax ; 0
 67614                              <1> ;	mov	[audio_dmabuff_size], ecx ; 0
 67615                              <1> ;	jmp	sound_buff_error				
 67616                              <1> ;
 67617                              <1> ;sndc_init4:
 67618 00012827 803D[A9890100]03    <1> 	cmp	byte [audio_device], 3
 67619                              <1> 	;jne	short sndc_init5
 67620                              <1> 	; 29/07/2022
 67621 0001282E 7505                <1> 	jne	short sndc_init18 ; 28/05/2017
 67622                              <1> 
 67623                              <1> ; 29/07/2022
 67624                              <1> ;	call	set_vt8233_bdl	
 67625                              <1> ;sndc_init5:
 67626                              <1> ;	;sub	eax, eax ; 0
 67627                              <1> ;	;mov	[u.r0], eax ; 0 = no error, successful
 67628                              <1> ;	retn
 67629                              <1> 
 67630 00012830 E91E170000          <1> 	jmp	set_vt8233_bdl
 67631                              <1> 
 67632                              <1> sndc_init18:
 67633                              <1> 	;call	set_ac97_bdl
 67634                              <1> 	;;jmp	short sndc_init5
 67635                              <1> 	;retn
 67636                              <1> 	; 29/07/2022
 67637 00012835 E9C61C0000          <1> 	jmp	set_ac97_bdl
 67638                              <1> 
 67639                              <1> sound_play:
 67640                              <1> 	; FUNCTION = 4 
 67641                              <1> 	; bl = Mode 
 67642                              <1> 	;      bit 0 = mono/stereo (1 = stereo)		
 67643                              <1> 	;      bit 1 = 8 bit / 16 bit (1 = 16 bit)
 67644                              <1> 	; cx = Sampling Rate (Hz)
 67645                              <1> 
 67646                              <1> 	; 13/06/2017
 67647                              <1> 	; Note: Even if Mode bits are not 11b,
 67648                              <1> 	; 	AC'97 Audio Controller (&Codec)
 67649                              <1> 	;	will play audio samples as 16 bit, stereo
 67650                              <1> 	;	samples.
 67651                              <1> 	;	(Program must fill the audio buffer
 67652                              <1> 	;	as required; 8 bit samples must be converted
 67653                              <1> 	;	to 16 bit samples and mono samples must be
 67654                              <1> 	;	converted to stereo samples...)
 67655                              <1> 	 
 67656                              <1> 	; 30/07/2022	
 67657                              <1> 	; 28/07/2020
 67658                              <1> 	; 27/07/2020	 	
 67659                              <1> 	; 28/05/2017
 67660                              <1> 	; 15/05/2017, 20/05/2017
 67661                              <1> 	; 21/04/2017, 24/04/2017
 67662                              <1> 	; ... device check at first
 67663 0001283A A0[A9890100]        <1> 	mov	al, [audio_device]
 67664 0001283F 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
 67665                              <1> 	;jz	beeper_gfx ; 'video.s' ; temporary 
 67666                              <1> 	; 30/07/022
 67667 00012841 7505                <1> 	jnz	short snd_play_7
 67668 00012843 E9C9FAFEFF          <1> 	jmp	beeper_gfx
 67669                              <1> 
 67670                              <1> snd_play_7:
 67671                              <1> ;	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67672                              <1> ;	je	short snd_play_1
 67673                              <1> ;	cmp	al, 1 ; SB 16
 67674                              <1> ;	jne	soundc_dev_err ; temporary !
 67675                              <1> ;snd_play_0:
 67676                              <1> 	; ... buffer & (buffer) owner check at second
 67677 00012848 833D[BC890100]00    <1> 	cmp	dword [audio_buffer], 0
 67678                              <1> 	;jna	sound_buff_error
 67679                              <1> 	; 30/07/2022
 67680 0001284F 763C                <1> 	jna	short snd_play_4 ; jmp sound_buff_error
 67681 00012851 A0[6D010300]        <1> 	mov	al, [u.uno]
 67682 00012856 3A05[D1890100]      <1> 	cmp	al, [audio_user]
 67683                              <1> 	;jne	sndc_owner_error
 67684                              <1> 	; 30/07/2022
 67685 0001285C 7405                <1> 	je	short snd_play_3
 67686 0001285E E99DFEFFFF          <1> 	jmp	sndc_owner_error
 67687                              <1> snd_play_3:
 67688 00012863 66890D[DA890100]    <1> 	mov	[audio_freq], cx ; sample frequency (Hertz)
 67689 0001286A 88D8                <1> 	mov	al, bl
 67690 0001286C 2401                <1> 	and	al, 1 ; mono/stereo (1= stereo)
 67691 0001286E FEC0                <1> 	inc	al ; channels
 67692 00012870 A2[D9890100]        <1> 	mov	[audio_stmo], al ; sound channels (1 or 2)
 67693 00012875 B008                <1> 	mov	al, 8
 67694 00012877 F6C302              <1> 	test	bl, 2 ; bits per sample (1= 16 bit)
 67695 0001287A 7402                <1> 	jz	short snd_play_bps
 67696 0001287C D0E0                <1> 	shl	al, 1  
 67697                              <1> snd_play_bps:	
 67698 0001287E A2[D8890100]        <1> 	mov	[audio_bps], al
 67699                              <1> 
 67700                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
 67701 00012883 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
 67702 00012889 09FF                <1> 	or	edi, edi
 67703                              <1> 	;jz	sound_buff_error
 67704                              <1> 	; 30/07/2022
 67705 0001288B 7505                <1> 	jnz	short snd_play_5
 67706                              <1> snd_play_4:
 67707 0001288D E921FDFFFF          <1> 	jmp	sound_buff_error
 67708                              <1> snd_play_5:
 67709                              <1> 	; 27/07/2020
 67710 00012892 8B35[C0890100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
 67711                              <1> 	;mov	ecx, [audio_buff_size] ; 15/05/2017
 67712 00012898 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size] ; 27/07/2020
 67713                              <1> 	;or	ecx, ecx 
 67714                              <1> 	;jz	sound_buff_error
 67715                              <1> 	; 28/07/2020
 67716 0001289E D1E9                <1> 	shr	ecx, 1  ; dma half buffer size
 67717                              <1> 
 67718 000128A0 8035[D0890100]01    <1> 	xor	byte [audio_flag], 1 ;  0 -> 1, 1 -> 0
 67719 000128A7 7502                <1> 	jnz	short snd_play_0 ; [audio_flag] = 1
 67720                              <1> 				 ; fill dma half buffer 1
 67721                              <1> 	; [audio_flag] = 0
 67722                              <1> 	
 67723                              <1> 	; fill dma half buffer 2
 67724 000128A9 01CF                <1> 	add	edi, ecx
 67725                              <1> 
 67726                              <1> snd_play_0:
 67727                              <1> 	;rep	movsb
 67728 000128AB C1E902              <1> 	shr	ecx, 2  ; convert byte count to dword count
 67729 000128AE F3A5                <1> 	rep	movsd
 67730                              <1> 
 67731                              <1> 	; here, if [audio_flag] = 0, interrupt handler will update
 67732                              <1> 				; dma half buffer 2 
 67733                              <1> 				; (user's audio buffer data will be 
 67734                              <1> 				; copied into dma half buffer 2) 
 67735                              <1> 	;; 20/05/2017
 67736                              <1> 	;mov	byte [audio_flag], 1 ; next half (on next time)
 67737                              <1> 
 67738                              <1> 	; 24/04/2017
 67739 000128B0 A0[A9890100]        <1> 	mov	al, [audio_device]
 67740 000128B5 3C03                <1> 	cmp	al, 3 ; VT8233 (VT8237R) 
 67741 000128B7 7409                <1> 	je	short snd_play_1
 67742 000128B9 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 67743 000128BB 750A                <1> 	jne	short snd_play_2  ; 28/05/2017
 67744                              <1> 
 67745                              <1> ; 30/07/2022
 67746                              <1> ;	call	SbInit_play
 67747                              <1> ;	;jc	soundc_respond_err
 67748                              <1> ;	;retn
 67749                              <1> ;	; 30/07/2022
 67750                              <1> ;	jnc	short snd_play_6  ; retn
 67751                              <1> ;	jmp	soundc_respond_err
 67752                              <1> 
 67753                              <1> 	; 30/07/2022
 67754 000128BD E98A180000          <1> 	jmp	SbInit_play	; sb16_start_play
 67755                              <1> 
 67756                              <1> snd_play_1:	
 67757                              <1> 	;call	vt8233_start_play
 67758                              <1> 	;retn
 67759                              <1> 	; 30/07/2022
 67760 000128C2 E9C2160000          <1> 	jmp	vt8233_start_play
 67761                              <1> 
 67762                              <1> snd_play_2:
 67763                              <1> 	; 28/05/2017
 67764                              <1> 	;cmp	al, 2 ; AC'97
 67765                              <1> 	;jne	short snd_play_3
 67766                              <1> 
 67767                              <1> 	;call	ac97_start_play
 67768                              <1> 	;retn
 67769                              <1> 	; 30/07/2022
 67770 000128C7 E9671C0000          <1> 	jmp	ac97_start_play
 67771                              <1> 
 67772                              <1> ;snd_play_3:
 67773                              <1> ;	;call	hda_start_play
 67774                              <1> ;	retn
 67775                              <1> 	; 30/07/2022
 67776                              <1> 	;jmp	hda_start_play
 67777                              <1> 
 67778                              <1> snd_play_6:
 67779                              <1> 	; 30/07/2022
 67780 000128CC C3                  <1> 	retn
 67781                              <1> 
 67782                              <1> sound_pause:
 67783                              <1> 	; FUNCTION = 5
 67784                              <1> 	; Pause
 67785                              <1> 	; 28/05/2017
 67786                              <1> 	; 24/04/2017
 67787                              <1> 	; 22/04/2017
 67788 000128CD E8F7020000          <1> 	call	snd_dev_check
 67789 000128D2 7277                <1> 	jc	short snd_nothing ; temporary.
 67790 000128D4 E8FD020000          <1> 	call	snd_buf_check
 67791 000128D9 7270                <1> 	jc	short snd_nothing ; temporary.
 67792 000128DB A0[A9890100]        <1> 	mov	al, [audio_device]
 67793 000128E0 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67794 000128E2 7409                <1> 	je	short snd_pause_1
 67795 000128E4 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 67796 000128E6 750A                <1> 	jne	short snd_pause_2 ; 28/05/2017
 67797 000128E8 E9341A0000          <1> 	jmp	sb16_pause
 67798                              <1> snd_pause_1:
 67799 000128ED E94C170000          <1> 	jmp	vt8233_pause
 67800                              <1> snd_pause_2:
 67801                              <1> 	; 28/05/2017
 67802                              <1> 	;cmp	al, 2 ; AC'97
 67803                              <1> 	;jne	short snd_nothing ; temporary.
 67804 000128F2 E9B81D0000          <1> 	jmp	ac97_pause
 67805                              <1> 
 67806                              <1> sound_continue:
 67807                              <1> 	; FUNCTION = 6
 67808                              <1> 	; Continue to play
 67809                              <1> 	; 28/05/2017
 67810                              <1> 	; 22/04/2017
 67811 000128F7 E8CD020000          <1> 	call	snd_dev_check
 67812 000128FC 724D                <1> 	jc	short snd_nothing ; temporary.
 67813 000128FE E8D3020000          <1> 	call	snd_buf_check
 67814 00012903 7246                <1> 	jc	short snd_nothing ; temporary.
 67815 00012905 A0[A9890100]        <1> 	mov	al, [audio_device]
 67816 0001290A 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67817 0001290C 7409                <1> 	je	short snd_cont_1
 67818 0001290E 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 67819 00012910 750A                <1> 	jne	short snd_cont_2 ; 28/05/2017
 67820 00012912 E92C1A0000          <1> 	jmp	sb16_continue
 67821                              <1> snd_cont_1:
 67822 00012917 E9D4160000          <1> 	jmp	vt8233_play
 67823                              <1> snd_cont_2:
 67824                              <1> 	; 28/05/2017
 67825                              <1> 	;cmp	al, 2 ; AC'97
 67826                              <1> 	;;jne	short snd_nothing ; temporary.
 67827                              <1> 	; 30/07/2022
 67828                              <1> 	;jne	short snd_cont_3
 67829 0001291C E9651C0000          <1> 	jmp	ac97_play
 67830                              <1> ;snd_cont_3:
 67831                              <1> 	;jmp	hda_play
 67832                              <1> 
 67833                              <1> sound_stop:
 67834                              <1> 	; FUNCTION = 7
 67835                              <1> 	; Stop playing
 67836                              <1> 	; 30/07/2022
 67837                              <1> 	; 28/05/2017
 67838                              <1> 	; 24/05/2017
 67839                              <1> 	; 21/04/2017, 22/04/2017, 24/04/2017
 67840 00012921 E8A3020000          <1> 	call	snd_dev_check
 67841 00012926 7223                <1> 	jc	short snd_nothing ; temporary.
 67842                              <1> 	;call	snd_buf_check
 67843 00012928 E8B2020000          <1> 	call	snd_user_check ; 24/05/2017
 67844 0001292D 721C                <1> 	jc	short snd_nothing ; temporary.	
 67845                              <1> 	
 67846 0001292F A0[A9890100]        <1> 	mov	al, [audio_device]
 67847 00012934 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67848                              <1> 	;je	vt8233_stop
 67849                              <1> 	;; 28/05/2017
 67850                              <1> 	;;ja	short snd_nothing
 67851                              <1> 	; 30/07/2022
 67852 00012936 7505                <1> 	jne	short snd_stop_1
 67853 00012938 E90D160000          <1> 	jmp	vt8233_stop
 67854                              <1> snd_stop_1:
 67855 0001293D 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 67856                              <1> 	;je	sb16_stop
 67857                              <1> 	; 30/07/2022
 67858 0001293F 7505                <1> 	jne	short snd_stop_2
 67859 00012941 E91F1A0000          <1> 	jmp	sb16_stop
 67860                              <1> snd_stop_2:
 67861                              <1> 	;cmp	al, 2 
 67862                              <1> 	;;je	short ac97_stop
 67863                              <1> 	; 30/07/2022
 67864                              <1> 	;jne	short snd_stop_3
 67865 00012946 E9361D0000          <1> 	jmp	ac97_stop ; temporary.
 67866                              <1> ;snd_stop_3:
 67867                              <1> 	;jmp	hda_stop
 67868                              <1> 
 67869                              <1> sndc_cancel_ok:
 67870                              <1> 	; 30/07/2022
 67871                              <1> sndc_reset_ok:
 67872                              <1> 	; 30/07/2022
 67873                              <1> snd_nothing:
 67874                              <1> 	; 21/04/2017
 67875 0001294B C3                  <1> 	retn
 67876                              <1> 
 67877                              <1> soundc_reset:
 67878                              <1> 	; FUNCTION = 8
 67879                              <1> 	; Reset Audio Controller
 67880                              <1> 	; 30/07/2022
 67881                              <1> 	; 28/05/2017
 67882                              <1> 	; 22/04/2017
 67883 0001294C E878020000          <1> 	call	snd_dev_check
 67884 00012951 72F8                <1> 	jc	short snd_nothing ; temporary.
 67885 00012953 E87E020000          <1> 	call	snd_buf_check
 67886 00012958 72F1                <1> 	jc	short snd_nothing ; temporary.	
 67887                              <1> 	
 67888 0001295A A0[A9890100]        <1> 	mov	al, [audio_device]
 67889                              <1> 	; 30/07/2022
 67890 0001295F 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67891 00012961 7207                <1> 	jb	short sndc_reset_1
 67892                              <1> 	;je	vt8233_reset
 67893 00012963 77E6                <1> 	ja	short snd_nothing ; temporary.
 67894                              <1> 	;;ja	hda_reset
 67895                              <1> 	;ja	short sndc_reset_3
 67896                              <1> 	; 30/07/2022
 67897 00012965 E9E0160000          <1> 	jmp	vt8233_reset	
 67898                              <1> sndc_reset_1:
 67899 0001296A 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 67900                              <1> 	;jne	ac97_reset	
 67901                              <1> 	; 30/07/2022
 67902 0001296C 750C                <1> 	jne	short sndc_reset_2
 67903 0001296E E8431A0000          <1> 	call	sb16_reset
 67904                              <1> 	;jc	soundc_respond_err
 67905                              <1> 	;retn
 67906                              <1> 	; 30/07/2022
 67907 00012973 73D6                <1> 	jnc	short sndc_reset_ok
 67908 00012975 E940FCFFFF          <1> 	jmp	soundc_respond_err	
 67909                              <1> sndc_reset_2:
 67910                              <1> 	; 30/07/2022
 67911                              <1> 	;cmp	al, 2
 67912                              <1> 	;ja	short sndc_reset_3
 67913 0001297A E9811D0000          <1> 	jmp	ac97_reset
 67914                              <1> ;sndc_reset_3:
 67915                              <1> 	;jmp	hda_reset
 67916                              <1> 
 67917                              <1> soundc_cancel:
 67918                              <1> 	; FUNCTION = 9
 67919                              <1> 	; Cancel audio callback service
 67920                              <1> 	; 30/07/2022
 67921                              <1> 	; 22/04/2017
 67922 0001297F A0[D1890100]        <1> 	mov	al, [audio_user]	
 67923 00012984 3A05[6D010300]      <1> 	cmp	al, [u.uno]
 67924 0001298A 75BF                <1> 	jne	short snd_nothing
 67925                              <1> 	; RESET (audio) INTERRUPT CALLBACK SERVICE
 67926 0001298C 8A1D[AB890100]      <1> 	mov	bl, [audio_intr] ; IRQ number
 67927 00012992 A0[6D010300]        <1> 	mov	al, [u.uno]
 67928 00012997 28FF                <1> 	sub	bh, bh ; 0 ; unlink IRQ from user service
 67929 00012999 E8C9020000          <1>  	call	set_irq_callback_service
 67930                              <1> 	;jc	sndc_perm_error ; 'permission denied' error
 67931                              <1> 	;retn
 67932                              <1> 	; 30/07/2022
 67933 0001299E 73AB                <1> 	jnc	short sndc_cancel_ok
 67934 000129A0 E960FDFFFF          <1> 	jmp	sndc_perm_error
 67935                              <1> 
 67936                              <1> sound_dalloc:
 67937                              <1> 	; FUNCTION = 10
 67938                              <1> 	; Deallocate (ring 3) audio buffer
 67939                              <1> 	; 22/04/2017
 67940 000129A5 A0[D1890100]        <1> 	mov	al, [audio_user]	
 67941 000129AA 3A05[6D010300]      <1> 	cmp	al, [u.uno]
 67942 000129B0 7599                <1> 	jne	short snd_nothing
 67943 000129B2 8B1D[BC890100]      <1> 	mov	ebx, [audio_buffer]
 67944                              <1> 	;or	ebx, ebx
 67945                              <1> 	;jz	short snd_nothing
 67946 000129B8 8B0D[C4890100]      <1> 	mov	ecx, [audio_buff_size]
 67947 000129BE E84535FFFF          <1> 	call	deallocate_user_pages
 67948 000129C3 31C0                <1> 	xor	eax, eax
 67949 000129C5 A3[BC890100]        <1> 	mov	[audio_buffer], eax ; 0
 67950 000129CA A2[D1890100]        <1> 	mov	[audio_user], al ; 0
 67951                              <1> ;sndc_cancel_ok:
 67952 000129CF C3                  <1> 	retn
 67953                              <1> 
 67954                              <1> sound_volume:
 67955                              <1> 	; FUNCTION = 11
 67956                              <1> 	; Set sound volume level
 67957                              <1> 	; 30/07/2022
 67958                              <1> 	; 28/05/2017
 67959                              <1> 	; 20/05/2017
 67960                              <1> 	; 22/04/2017, 24/04/2017
 67961                              <1> 	; bl = component (0 = master/playback/lineout volume)
 67962                              <1> 	; cl = left channel volume level (0 to 31)
 67963                              <1> 	; ch = right channel volume level (0 to 31)
 67964                              <1> 
 67965 000129D0 80FB80              <1> 	cmp	bl, 80h
 67966 000129D3 720A                <1> 	jb	short snd_vol_1
 67967                              <1> 	;ja	snd_nothing ; temporary.
 67968                              <1> 	; 30/07/2022
 67969 000129D5 7707                <1> 	ja	short snd_vol_0
 67970                              <1> 	; Set volume level for next play (BL>= 80h)
 67971 000129D7 66890D[DE890100]    <1> 	mov	[audio_master_volume], cx
 67972                              <1> snd_vol_0:
 67973 000129DE C3                  <1> 	retn
 67974                              <1> snd_vol_1:
 67975                              <1> 	; set volume level immediate (BL< 80h)
 67976 000129DF 80FB00              <1> 	cmp	bl, 0
 67977                              <1> 	;ja	snd_nothing ; temporary.
 67978                              <1> 	; 30/07/2022
 67979 000129E2 77FA                <1> 	ja	short snd_vol_0
 67980                              <1> 
 67981 000129E4 E8E0010000          <1> 	call	snd_dev_check
 67982                              <1> 	;jc	snd_nothing ; temporary.
 67983                              <1> 	; 30/07/2022
 67984 000129E9 72F3                <1> 	jc	short snd_vol_0
 67985 000129EB E8E6010000          <1> 	call	snd_buf_check
 67986                              <1> 	;jc	snd_nothing ; temporary.
 67987                              <1> 	; 30/07/2022
 67988 000129F0 72EC                <1> 	jc	short snd_vol_0	
 67989                              <1> 
 67990 000129F2 A0[A9890100]        <1> 	mov	al, [audio_device]
 67991 000129F7 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 67992                              <1> 	;je	vt8233_volume
 67993                              <1> 	; 30/07/2022
 67994 000129F9 7207                <1> 	jb	short snd_vol_2
 67995                              <1> 	; 28/05/2017
 67996                              <1> 	;ja	snd_nothing ; temporary.
 67997                              <1> 	; 30/07/2022
 67998 000129FB 77E1                <1> 	ja	short snd_vol_0
 67999                              <1> 	;ja	hda_volume
 68000                              <1> 	; 30/07/2022
 68001 000129FD E961160000          <1> 	jmp	vt8233_volume
 68002                              <1> snd_vol_2:	
 68003                              <1> 	; Sound Blaster 16
 68004 00012A02 3C01                <1> 	cmp	al, 1 ; SB 16
 68005                              <1> 	;je	sb16_volume
 68006                              <1> 	; 30/07/2022
 68007 00012A04 7705                <1> 	ja	short snd_vol_3
 68008 00012A06 E9E5180000          <1> 	jmp	sb16_volume
 68009                              <1> snd_vol_3:
 68010                              <1> 	; 30/07/2022
 68011                              <1> 	;cmp	al, 2
 68012                              <1> 	;ja	short snd_vol_4
 68013 00012A0B E9921B0000          <1> 	jmp	ac97_volume
 68014                              <1> ;snd_vol_4:
 68015                              <1> 	;jmp	hda_volume
 68016                              <1> 
 68017                              <1> soundc_disable:
 68018                              <1> 	; FUNCTION = 12 
 68019                              <1> 	; Disable audio device (and unlink DMA memory)
 68020                              <1> 	; 30/07/2022
 68021                              <1> 	; 28/05/2017
 68022                              <1> 	; 24/05/2017
 68023                              <1> 	; 22/04/2017
 68024 00012A10 E8B4010000          <1> 	call	snd_dev_check
 68025                              <1> 	;jc	soundc_dev_err ; temporary.
 68026                              <1> 	; 30/07/2022
 68027 00012A15 7305                <1> 	jnc	short snd_disable_4
 68028 00012A17 E990FBFFFF          <1> 	jmp	soundc_dev_err
 68029                              <1> snd_disable_4:
 68030                              <1> 	;call	snd_buf_check
 68031                              <1> 	;;jc	sndc_owner_error ; temporary.
 68032                              <1> 	; 30/07/2022
 68033                              <1> 	;jnc	short snd_disable_5
 68034                              <1> 	;jmp	sndc_owner_error
 68035                              <1> ;snd_disable_5:
 68036 00012A1C A0[A9890100]        <1> 	mov	al, [audio_device]
 68037 00012A21 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
 68038 00012A23 7414                <1> 	je	short snd_disable_1
 68039                              <1> 	;ja	snd_nothing ; temporary.
 68040                              <1> 	; 30/07/2022
 68041 00012A25 7757                <1> 	ja	short snd_disable_3 ; retn
 68042 00012A27 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
 68043 00012A29 7507                <1> 	jne	short snd_disable_0
 68044 00012A2B E835190000          <1> 	call	sb16_stop
 68045 00012A30 EB0C                <1> 	jmp	short snd_disable_2
 68046                              <1> snd_disable_0:
 68047 00012A32 E84A1C0000          <1> 	call	ac97_stop
 68048 00012A37 EB05                <1> 	jmp	short snd_disable_2
 68049                              <1> snd_disable_1:
 68050 00012A39 E80C150000          <1> 	call	vt8233_stop
 68051                              <1> snd_disable_2:
 68052 00012A3E A0[AB890100]        <1> 	mov	al, [audio_intr]
 68053 00012A43 29DB                <1> 	sub	ebx, ebx ; 0 = reset
 68054 00012A45 E876FAFFFF          <1> 	call	set_dev_IRQ_service
 68055                              <1> 
 68056                              <1> 	;mov	al, [audio_intr]
 68057 00012A4A 28E4                <1> 	sub	ah, ah ; 0 = reset
 68058 00012A4C E836F8FFFF          <1> 	call	set_hardware_int_vector
 68059                              <1> 
 68060 00012A51 31C0                <1> 	xor	eax, eax
 68061 00012A53 A2[A9890100]        <1> 	mov	byte [audio_device], al
 68062 00012A58 A2[AB890100]        <1> 	mov	byte [audio_intr], al
 68063 00012A5D 8705[C8890100]      <1> 	xchg	eax, [audio_dma_buff]
 68064                              <1> 	; 24/05/2017
 68065                              <1> 	;or	eax, eax
 68066                              <1> 	;jz	short snd_disable_3
 68067                              <1> 	;cmp	eax, sb16_dma_buffer ; default DMA buffer
 68068                              <1> 	;je	short snd_disable_3
 68069 00012A63 803D[A8890100]00    <1> 	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
 68070 00012A6A 7612                <1> 	jna	short snd_disable_3
 68071 00012A6C C605[A8890100]00    <1> 	mov	byte [audio_pci], 0
 68072                              <1> 	;sub	ecx, ecx
 68073                              <1> 	;xchg	ecx, [audio_dmabuff_size]
 68074 00012A73 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size]
 68075 00012A79 E84C33FFFF          <1> 	call	deallocate_memory_block
 68076                              <1> snd_disable_3:
 68077 00012A7E C3                  <1> 	retn
 68078                              <1> 
 68079                              <1> sound_dma_map:
 68080                              <1> 	; FUNCTION = 13 
 68081                              <1> 	; Map audio dma buff addr to user's buffer addr
 68082                              <1> 	; 30/07/2022
 68083                              <1> 	; 12/05/2017
 68084 00012A7F 21C9                <1> 	and	ecx, ecx
 68085                              <1> 	;jz	sound_buff_error
 68086                              <1> 	; 30/07/2022
 68087 00012A81 7505                <1> 	jnz	short snd_dma_map_3
 68088 00012A83 E92BFBFFFF          <1> 	jmp	sound_buff_error
 68089                              <1> snd_dma_map_3:
 68090 00012A88 803D[A9890100]01    <1> 	cmp	byte [audio_device], 1
 68091 00012A8F 722A                <1> 	jb	short snd_dma_map_1
 68092                              <1> snd_dma_map_0:
 68093 00012A91 A1[C8890100]        <1> 	mov	eax, [audio_dma_buff]
 68094 00012A96 21C0                <1> 	and	eax, eax
 68095 00012A98 7421                <1> 	jz	short snd_dma_map_1
 68096                              <1> 	;
 68097 00012A9A 8A1D[D1890100]      <1> 	mov	bl, [audio_user]
 68098 00012AA0 08DB                <1> 	or	bl, bl
 68099 00012AA2 7417                <1> 	jz	short snd_dma_map_1
 68100 00012AA4 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
 68101                              <1> 	;jne	sndc_owner_error
 68102                              <1> 	; 30/07/2022
 68103 00012AAA 7405                <1> 	je	short snd_dma_map_4
 68104 00012AAC E94FFCFFFF          <1> 	jmp	sndc_owner_error
 68105                              <1> snd_dma_map_4:
 68106 00012AB1 8B1D[CC890100]      <1> 	mov	ebx, [audio_dmabuff_size]
 68107 00012AB7 21DB                <1> 	and	ebx, ebx
 68108 00012AB9 750A                <1> 	jnz	short snd_dma_map_2
 68109                              <1> snd_dma_map_1:
 68110 00012ABB B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
 68111 00012AC0 BB00000100          <1> 	mov	ebx, 65536
 68112                              <1> snd_dma_map_2:	
 68113 00012AC5 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 68114 00012ACB 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 68115 00012AD0 39D9                <1> 	cmp	ecx, ebx
 68116                              <1> 	;ja	sound_buff_error
 68117                              <1> 	; 30/07/2022
 68118 00012AD2 7605                <1> 	jna	short snd_dma_map_6
 68119                              <1> snd_dma_map_5:
 68120 00012AD4 E9DAFAFFFF          <1> 	jmp	sound_buff_error
 68121                              <1> snd_dma_map_6:
 68122 00012AD9 50                  <1> 	push	eax
 68123 00012ADA 89D3                <1> 	mov	ebx, edx
 68124 00012ADC C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
 68125                              <1> 	; eax = physical address of (audio) dma buffer
 68126                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
 68127                              <1> 	; ecx = page count (>0)
 68128 00012ADF E85633FFFF          <1> 	call	direct_memory_access
 68129 00012AE4 58                  <1> 	pop	eax
 68130                              <1> 	;jc	sound_buff_error
 68131                              <1> 	; 30/07/2022
 68132 00012AE5 72ED                <1> 	jc	short snd_dma_map_5
 68133 00012AE7 A3[1C010300]        <1> 	mov	[u.r0], eax
 68134 00012AEC C3                  <1> 	retn
 68135                              <1> 
 68136                              <1> soundc_info:
 68137                              <1> 	; FUNCTION = 14 
 68138                              <1> 	; Get Audio Controller Info
 68139                              <1> 	; 30/07/2022
 68140                              <1> 	; 10/06/2017
 68141                              <1> 	; 05/06/2017
 68142 00012AED 20DB                <1> 	and	bl, bl ; 0
 68143 00012AEF 7409                <1> 	jz	short sndc_info_0
 68144                              <1> 	; invalid parameter !
 68145                              <1> ; 30/07/2022
 68146                              <1> 	;mov	eax, ERR_INV_PARAMETER ; 23
 68147                              <1> ;sndc_inf_error:
 68148                              <1> ;	mov	[u.r0], eax
 68149                              <1> ;	mov	[u.error], eax
 68150                              <1> ;	jmp	error
 68151                              <1> 	; 30/07/2022
 68152 00012AF1 29C0                <1> 	sub	eax, eax
 68153 00012AF3 B017                <1> 	mov	al, ERR_INV_PARAMETER ; 23
 68154 00012AF5 E9C5FAFFFF          <1> 	jmp	sysaudio_err
 68155                              <1> 
 68156                              <1> sndc_info_0:
 68157 00012AFA E8CA000000          <1> 	call	snd_dev_check
 68158                              <1> 	;jc	soundc_dev_err
 68159                              <1> 	; 30/07/2022
 68160 00012AFF 7305                <1> 	jnc	short sndc_info_3
 68161                              <1> snd_data_dev_err:
 68162 00012B01 E9A6FAFFFF          <1> 	jmp	soundc_dev_err
 68163                              <1> sndc_info_3:
 68164 00012B06 8B1D[B4890100]      <1> 	mov	ebx, [audio_vendor]
 68165 00012B0C 8B0D[B0890100]      <1> 	mov	ecx, [audio_dev_id]
 68166                              <1> 	;mov	al,  [audio_device]
 68167 00012B12 3C02                <1> 	cmp	al, 2 ; AC'97 (ICH)
 68168 00012B14 7513                <1> 	jne	short sndc_info_1
 68169                              <1> 	; Intel AC97 (ICH) Audio Controller (=2)	
 68170 00012B16 668B15[E2890100]    <1> 	mov	dx, [NABMBAR]
 68171 00012B1D C1E210              <1> 	shl	edx, 16
 68172 00012B20 668B15[E0890100]    <1> 	mov	dx, [NAMBAR]
 68173 00012B27 EB07                <1> 	jmp	short sndc_info_2
 68174                              <1> sndc_info_1:
 68175                              <1> 	; 05/06/2017
 68176                              <1> 	; Note: Intel HDA code (here) is not ready yet!
 68177                              <1> 	; !!! SB16 or VT8233 (VT8237R) !!!
 68178 00012B29 0FB715[AE890100]    <1> 	movzx	edx, word [audio_io_base]	
 68179                              <1> sndc_info_2:
 68180 00012B30 88C4                <1> 	mov	ah, al ;  [audio_device]
 68181 00012B32 A0[AB890100]        <1> 	mov	al, [audio_intr] 
 68182                              <1> 
 68183                              <1> 	; EAX = IRQ Number in AL
 68184                              <1> 	;	Audio Device Number in AH 
 68185                              <1> 	; EBX = DEV/VENDOR ID
 68186                              <1> 	;	(DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
 68187                              <1> 	; ECX = BUS/DEV/FN 
 68188                              <1> 	;	(00000000BBBBBBBBDDDDDFFF00000000)
 68189                              <1> 	; EDX = NABMBAR/NAMBAR (for AC97)
 68190                              <1> 	;	(Low word, DX = NAMBAR address)
 68191                              <1> 	; EDX = Base IO Addr (DX) for SB16 & VT8233
 68192                              <1> 
 68193                              <1> 	; 10/06/2017
 68194 00012B37 A3[1C010300]        <1> 	mov	[u.r0], eax
 68195 00012B3C 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
 68196 00012B42 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
 68197 00012B45 895514              <1> 	mov	[ebp+20], edx  ; edx
 68198 00012B48 894D18              <1> 	mov	[ebp+24], ecx  ; ecx
 68199                              <1>   			  		
 68200 00012B4B C3                  <1>  	retn
 68201                              <1> 
 68202                              <1> sound_data:
 68203                              <1> 	; FUNCTION = 15 
 68204                              <1> 	; Get Current Sound data for graphics
 68205                              <1> 	; 30/07/2022
 68206                              <1> 	; 22/06/2017
 68207                              <1> 	;
 68208 00012B4C E878000000          <1> 	call	snd_dev_check
 68209                              <1> 	;jc	soundc_dev_err ; Device not ready !
 68210                              <1> 	; 30/07/2022
 68211 00012B51 72AE                <1> 	jc	short snd_data_dev_err
 68212                              <1> 
 68213 00012B53 80FB00              <1> 	cmp	bl, 0
 68214 00012B56 760A                <1> 	jna	short sound_data_0
 68215                              <1> 
 68216                              <1> 	; Only PCM OUT buffer data is valid for now!
 68217 00012B58 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER  ; 23
 68218 00012B5D E95DFAFFFF          <1> 	jmp	sysaudio_err
 68219                              <1> 
 68220                              <1> sound_data_0:
 68221 00012B62 A1[C8890100]        <1> 	mov	eax, [audio_dma_buff]
 68222 00012B67 09C0                <1> 	or	eax, eax
 68223                              <1> 	;jz	sound_buff_error
 68224                              <1> 	; 30/07/2022
 68225 00012B69 741A                <1> 	jz	short sound_data_5
 68226                              <1> 
 68227 00012B6B 803D[A9890100]04    <1> 	cmp	byte [audio_device], 4 ; Intel HDA
 68228 00012B72 744C                <1> 	je	short sound_data_4 ; temporary ! (22/06/2017)
 68229                              <1> 
 68230 00012B74 21C9                <1> 	and	ecx, ecx
 68231                              <1> 	;jnz	short sound_data_1 ; sample tranfer
 68232                              <1> 	
 68233                              <1> 	; Return only DMA Buffer pointer/offset... 
 68234                              <1> 	; (If DMA Buffer has been mapped to user's
 68235                              <1> 	;  memory space; program can get graphics
 68236                              <1> 	;  data by using only this pointer value.)
 68237                              <1> 	   	
 68238                              <1> 	;call	get_dma_buffer_offset
 68239                              <1> 	;; eax = DMA buffer offset
 68240                              <1> 	;;	(!not half buffer offset!)
 68241                              <1> 	;mov	[u.r0], eax
 68242                              <1> 	;retn
 68243                              <1> 
 68244                              <1> 	;jz	get_dma_buffer_offset
 68245                              <1> 	; 30/07/2022
 68246 00012B76 7505                <1> 	jnz	short sound_data_1
 68247 00012B78 E9EF1C0000          <1> 	jmp	get_dma_buffer_offset		
 68248                              <1> 	
 68249                              <1> sound_data_1:
 68250                              <1> 	;mov	eax, [audio_dmabuff_size]
 68251                              <1> 	;shr	eax, 1 ; half buffer size
 68252                              <1> 	;cmp	ecx, eax
 68253                              <1> 	;ja	short sound_buff_error	
 68254                              <1> 
 68255 00012B7D 3B0D[CC890100]      <1> 	cmp	ecx, [audio_dmabuff_size]
 68256                              <1> 	;ja	sound_buff_error
 68257                              <1> 	; 30/07/2022
 68258 00012B83 7605                <1> 	jna	short sound_data_6
 68259                              <1> sound_data_5:
 68260 00012B85 E929FAFFFF          <1> 	jmp	sound_buff_error	
 68261                              <1> sound_data_6:
 68262 00012B8A 89D0                <1> 	mov	eax, edx
 68263 00012B8C 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 4095 (0FFFh)
 68264 00012B91 81F900100000        <1> 	cmp	ecx, 4096
 68265 00012B97 7604                <1> 	jna	short sound_data_2
 68266                              <1> 	;mov	ecx, 4096 ; max. 1 page
 68267                              <1> 	; 30/07/2022
 68268 00012B99 31C9                <1> 	xor	ecx, ecx
 68269 00012B9B B510                <1> 	mov	ch, 16
 68270                              <1> 	; ecx = 4096
 68271                              <1> sound_data_2:
 68272 00012B9D 01C8                <1> 	add	eax, ecx
 68273 00012B9F 3D00100000          <1> 	cmp	eax, 4096
 68274 00012BA4 7606                <1> 	jna	short sound_data_3
 68275 00012BA6 6625FF0F            <1> 	and	ax, PAGE_OFF ; 4095 (0FFFh)
 68276 00012BAA 29C1                <1> 	sub	ecx, eax
 68277                              <1> 	; here, ECX has been adjusted to fit 
 68278                              <1> 	;	in page border..  (<= 4096, >0)
 68279                              <1> sound_data_3:
 68280 00012BAC 51                  <1> 	push	ecx
 68281 00012BAD 52                  <1> 	push	edx
 68282 00012BAE 89D3                <1> 	mov	ebx, edx 
 68283 00012BB0 E8D32EFFFF          <1> 	call	get_physical_addr
 68284 00012BB5 5A                  <1> 	pop	edx
 68285 00012BB6 59                  <1> 	pop	ecx
 68286                              <1> 	;jc	sound_buff_error
 68287                              <1> 	; 30/07/2022
 68288 00012BB7 72CC                <1> 	jc	short sound_data_5	
 68289                              <1> 	
 68290                              <1> 	; eax = physical address of user's buffer
 68291 00012BB9 89C3                <1> 	mov	ebx, eax  
 68292                              <1> 	; ecx = byte (transfer) count
 68293                              <1> 	;call	get_current_sound_data
 68294                              <1> 	;retn
 68295 00012BBB E90A1C0000          <1> 	jmp	get_current_sound_data
 68296                              <1> 
 68297                              <1> sound_data_4:
 68298                              <1> 	; Intel HDA code is not ready yet !
 68299                              <1> 	; 22/06/2017
 68300 00012BC0 31C0                <1> 	xor	eax, eax
 68301 00012BC2 48                  <1> 	dec	eax
 68302 00012BC3 A3[1C010300]        <1> 	mov	[u.r0], eax ; 0FFFFFFFFh
 68303 00012BC8 C3                  <1> 	retn 
 68304                              <1> 
 68305                              <1> snd_dev_check:
 68306                              <1> 	; 10/06/2017
 68307                              <1> 	; 05/06/2017
 68308                              <1> 	; 24/05/2017
 68309                              <1> 	; 22/04/2017
 68310                              <1> 	; 21/04/2017
 68311                              <1> 	; ... device check at first
 68312 00012BC9 A0[A9890100]        <1> 	mov	al, [audio_device]
 68313 00012BCE 3C01                <1> 	cmp	al, 1 ; SB 16
 68314 00012BD0 7203                <1> 	jb	short snd_dev_chk_retn ; error !
 68315                              <1> 	;cmp	al, 4 ; Intel HDA
 68316                              <1> 	;ja	short snd_dbchk_stc ; invalid !
 68317                              <1> 	; 10/06/2017
 68318 00012BD2 3C05                <1> 	cmp	al, 5
 68319 00012BD4 F5                  <1> 	cmc
 68320                              <1> snd_dev_chk_retn:
 68321 00012BD5 C3                  <1> 	retn
 68322                              <1> 
 68323                              <1> snd_buf_check:
 68324                              <1> 	; 10/06/2017
 68325                              <1> 	; 22/04/2017
 68326                              <1> 	; 21/04/2017
 68327                              <1> 	; ... buffer & (buffer) owner check at second
 68328 00012BD6 833D[BC890100]00    <1> 	cmp	dword [audio_buffer], 0
 68329 00012BDD 760D                <1> 	jna	short snd_dbchk_stc
 68330                              <1> snd_user_check:
 68331 00012BDF A0[6D010300]        <1> 	mov	al, [u.uno]
 68332 00012BE4 3A05[D1890100]      <1> 	cmp	al, [audio_user]
 68333                              <1> 	;jne	short snd_dbchk_stc
 68334                              <1> 	;retn
 68335 00012BEA 74E9                <1> 	je	short snd_dev_chk_retn
 68336                              <1> 
 68337                              <1> snd_dbchk_stc:
 68338 00012BEC F9                  <1> 	stc
 68339 00012BED C3                  <1> 	retn
 68340                              <1> 
 68341                              <1> sound_update:
 68342                              <1> 	; FUNCTION = 16 
 68343                              <1> 	; bl = 
 68344                              <1> 	;    0 = automatic (sequental) update (with flag switch!)
 68345                              <1> 	;    1 = update dma half buffer 1 (without flag switch!)		
 68346                              <1> 	;    2 = update dma half buffer 2 (without flag switch!)
 68347                              <1> 	;  FFh = get current flag value	
 68348                              <1> 	;      0 = dma half buffer 1 (will be played next)
 68349                              <1> 	;      1 = dma half buffer 2 (will be played next)
 68350                              <1> 	
 68351                              <1> 	; 30/07/2022
 68352                              <1> 	; 10/10/2017
 68353                              <1> 	; ... device check at first
 68354 00012BEE A0[A9890100]        <1> 	mov	al, [audio_device]
 68355 00012BF3 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
 68356                              <1> 	;jz	soundc_dev_err
 68357                              <1> 	; 30/07/2022
 68358 00012BF5 7505                <1> 	jnz	short snd_update_4
 68359 00012BF7 E9B0F9FFFF          <1> 	jmp	soundc_dev_err
 68360                              <1> snd_update_4:
 68361                              <1> 	; ... buffer & (buffer) owner check at second
 68362 00012BFC 833D[BC890100]00    <1> 	cmp	dword [audio_buffer], 0
 68363                              <1> 	;jna	sound_buff_error
 68364                              <1> 	; 30/07/2022
 68365 00012C03 761C                <1> 	jna	short snd_update_6 ; jmp sound_buff_error
 68366 00012C05 A0[6D010300]        <1> 	mov	al, [u.uno]
 68367 00012C0A 3A05[D1890100]      <1> 	cmp	al, [audio_user]
 68368                              <1> 	;jne	sndc_owner_error
 68369                              <1> 	; 30/07/2022
 68370 00012C10 7405                <1> 	je	short snd_update_5
 68371 00012C12 E9E9FAFFFF          <1> 	jmp	sndc_owner_error
 68372                              <1> snd_update_5:
 68373                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
 68374 00012C17 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
 68375 00012C1D 09FF                <1> 	or	edi, edi
 68376                              <1> 	;jz	sound_buff_error
 68377                              <1> 	; 30/07/2022
 68378 00012C1F 7505                <1> 	jnz	short snd_update_7
 68379                              <1> snd_update_6:
 68380 00012C21 E98DF9FFFF          <1> 	jmp	sound_buff_error
 68381                              <1> snd_update_7:
 68382 00012C26 8B35[C0890100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
 68383 00012C2C 8B0D[C4890100]      <1> 	mov	ecx, [audio_buff_size]
 68384                              <1> 	
 68385                              <1> 	;movzx	eax, byte [audio_flag]
 68386 00012C32 A0[D0890100]        <1> 	mov	al, [audio_flag]
 68387                              <1> 
 68388 00012C37 FEC3                <1> 	inc	bl
 68389 00012C39 7426                <1> 	jz	short snd_update_3 ; bl = 0FFh
 68390 00012C3B FECB                <1> 	dec	bl 
 68391 00012C3D 7410                <1> 	jz	short snd_update_0 ; bl = 0
 68392                              <1> 
 68393 00012C3F 80FB02              <1> 	cmp	bl, 2
 68394 00012C42 7416                <1> 	je	short snd_update_1 ; dma half buffer 2
 68395 00012C44 7216                <1> 	jb	short snd_update_2 ; dma half buffer 1
 68396                              <1>  
 68397                              <1> 	; invalid parameter !
 68398                              <1> ; 30/07/2022
 68399                              <1> 	;mov	eax, ERR_INV_PARAMETER ; 23
 68400                              <1> ;	mov	[u.r0], eax
 68401                              <1> ;	mov	[u.error], eax
 68402                              <1> ;	jmp	error
 68403                              <1> 
 68404                              <1> 	; 30/07/2022
 68405 00012C46 29C0                <1> 	sub	eax, eax
 68406 00012C48 B017                <1> 	mov	al, ERR_INV_PARAMETER ; 23
 68407 00012C4A E970F9FFFF          <1> 	jmp	sysaudio_err
 68408                              <1> 	
 68409                              <1> snd_update_0:
 68410 00012C4F 8035[D0890100]01    <1> 	xor	byte [audio_flag], 1 ; update flag !!!
 68411 00012C56 3C01                <1> 	cmp	al, 1
 68412 00012C58 7202                <1> 	jb	short snd_update_2 ; dma half buffer 1
 68413                              <1> snd_update_1:
 68414                              <1> 	; dma half buffer 2
 68415 00012C5A 01CF                <1> 	add	edi, ecx
 68416                              <1> snd_update_2:
 68417                              <1> 	;rep	movsb
 68418 00012C5C C1E902              <1> 	shr	ecx, 2
 68419 00012C5F F3A5                <1> 	rep	movsd
 68420                              <1> snd_update_3:
 68421 00012C61 A3[1C010300]        <1> 	mov	[u.r0], eax
 68422                              <1> 
 68423 00012C66 C3                  <1> 	retn
 68424                              <1> 
 68425                              <1> set_irq_callback_service:
 68426                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 68427                              <1> 	; 03/08/2020
 68428                              <1> 	; 10/06/2017
 68429                              <1> 	; 12/05/2017
 68430                              <1> 	; 24/04/2017
 68431                              <1> 	; 22/04/2017
 68432                              <1> 	; caller: 'syscalbac' or 'sysaudio' or ...
 68433                              <1> 	; 13/04/2017, 14/04/2017, 17/04/2017
 68434                              <1> 	; 24/02/2017, 26/02/2017, 28/02/2017
 68435                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
 68436                              <1> 	;
 68437                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
 68438                              <1> 	;
 68439                              <1> 	; INPUT ->
 68440                              <1> 	;	If AL = 0, the caller is 'syscalbac';
 68441                              <1> 	;	   otherwise, the caller is 'sysaudio' or ...
 68442                              <1> 	;	   (AL = user number) 
 68443                              <1> 	; 	 
 68444                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
 68445                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
 68446                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
 68447                              <1> 	;	     (numbers >15 are invalid)
 68448                              <1> 	;
 68449                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
 68450                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
 68451                              <1> 	;	     2 = Link IRQ by using Callback service method 		
 68452                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
 68453                              <1> 	;	    >3 = invalid 
 68454                              <1> 	;		 (syscallback version will return to user) 	
 68455                              <1> 	;	
 68456                              <1> 	;	CL = Signal Return/Response Byte value 
 68457                              <1> 	;
 68458                              <1> 	;	If BH = 3, kernel will put a counter value ; 03/08/2020
 68459                              <1> 	;	          (into the S.R.B. addr)
 68460                              <1> 	;		  between 0 to 255. (start value = CL+1)
 68461                              <1> 	;	
 68462                              <1> 	;	NOTE: counter value, for example: even and odd numbers
 68463                              <1> 	;	      may be used for -audio- DMA buffer switch 
 68464                              <1> 	;	      within double buffer method, etc. 		
 68465                              <1> 	;
 68466                              <1> 	;	EDX = Signal return (Response) byte address
 68467                              <1> 	;	       		  - or -
 68468                              <1> 	;	      Interrupt/Callback service/routine address
 68469                              <1> 	; 	
 68470                              <1> 	;	      (virtual address in user's memory space)
 68471                              <1> 	;
 68472                              <1> 	; OUTPUT ->
 68473                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
 68474                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
 68475                              <1> 	;			by another process
 68476                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
 68477                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
 68478                              <1> 	;		       invalid parameter/option or bad address
 68479                              <1> 	;
 68480                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
 68481                              <1> 	;	
 68482                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
 68483                              <1> 	;			which IRQs are locked by (that) user.
 68484                              <1> 	;		        Lock and unlock (by user) will change
 68485                              <1> 	;			these flags or 'terminate process' (sysexit)
 68486                              <1> 	;			will clear these flags and unlock those IRQs.
 68487                              <1> 	;			               
 68488                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
 68489                              <1> 	;
 68490                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
 68491                              <1> 	;
 68492                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
 68493                              <1> 	;			   0 = Signal Response Byte method
 68494                              <1> 	;			   1 = Callback service method
 68495                              <1> 	;			   >1 = invalid for current 'syscalback'.
 68496                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
 68497                              <1> 	;			            function (audio etc.) or
 68498                              <1> 	;			   	    a device driver.	   	
 68499                              <1> 	;			(system function will ignore the lock/owner)
 68500                              <1> 	;
 68501                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
 68502                              <1> 	;			  (a fixed value by user or a counter value
 68503                              <1> 	;			 from 0 to 255, which is increased by every
 68504                              <1> 	;			 interrupt just before putting it into 
 68505                              <1> 	;			 the Signal Response byte address
 68506                              <1> 	;			 (This is not used in callback serv method)
 68507                              <1> 	;	    	  
 68508                              <1> 	;	   IRQ(x).addr	: 1 dword
 68509                              <1> 	;			  Signal Response Byte address (physical)
 68510                              <1> 	;			  		-or-
 68511                              <1> 	;			  Callback service address (virtual)
 68512                              <1> 	;
 68513                              <1> 	;	   IRQ(x).dev	: 1 byte
 68514                              <1> 	;			  0 = Default device or kernel function
 68515                              <1> 	;			  		-or-
 68516                              <1> 	;			  1-255 = Assigned device driver number
 68517                              <1> 	;
 68518                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
 68519                              <1> 	;
 68520                              <1> 	
 68521 00012C67 80FB0F              <1> 	cmp	bl, 15
 68522 00012C6A 7728                <1> 	ja	short scbs_2
 68523                              <1> 	
 68524 00012C6C 80FF03              <1> 	cmp	bh, 3
 68525 00012C6F 7723                <1> 	ja	short scbs_2  ; invalid parameter
 68526                              <1> 
 68527 00012C71 0FB6FB              <1> 	movzx	edi, bl ; save IRQ number
 68528                              <1> 
 68529                              <1> 		;  IRQ 0,1,2,6,8,14,15 are prohibited
 68530                              <1> 	;IRQenum: ; 'trdosk9.s'
 68531                              <1> 	;	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
 68532                              <1> 
 68533 00012C74 0FB6B7[8A370100]    <1> 	movzx	esi, byte [edi+IRQenum] ; IRQ availability 
 68534                              <1> 					; enumeration/index
 68535                              <1> 	;dec	esi
 68536 00012C7B 664E                <1> 	dec	si
 68537 00012C7D 780F                <1> 	js	short scbs_1 ;  0 -> 0FFFFh  
 68538                              <1> 
 68539                              <1> 	; ESI = IRQ callback parameters index number (0 to 8)
 68540                              <1> 
 68541 00012C7F 08FF                <1> 	or	bh, bh
 68542 00012C81 7417                <1> 	jz	short scbs_4 ; unlink the IRQ (in BL)
 68543                              <1> 
 68544 00012C83 FECF                <1> 	dec	bh
 68545                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
 68546                              <1> 	;	      (2 = auto increment of signal response byte) 
 68547                              <1> 
 68548 00012C85 80BE[58890100]00    <1> 	cmp	byte [esi+IRQ.owner], 0 ; locked ?
 68549 00012C8C 7635                <1> 	jna	short scbs_6	; no... OK...	
 68550                              <1> 
 68551                              <1> scbs_1:
 68552                              <1> 	; permission denied (prohibited IRQ)
 68553                              <1> 	;mov	eax, ERR_PERM_DENIED
 68554                              <1> 	; 30/07/2022
 68555 00012C8E 29C0                <1> 	sub	eax, eax
 68556 00012C90 B00B                <1> 	mov	al, ERR_PERM_DENIED
 68557 00012C92 F9                  <1> 	stc
 68558 00012C93 C3                  <1> 	retn
 68559                              <1> scbs_2:
 68560                              <1> 	;stc
 68561                              <1> scbs_3:
 68562                              <1> 	;mov	eax, ERR_INV_PARAMETER
 68563                              <1> 	; 30/07/2022
 68564 00012C94 29C0                <1> 	sub	eax, eax
 68565 00012C96 B017                <1> 	mov	al, ERR_INV_PARAMETER
 68566 00012C98 F9                  <1> 	stc
 68567 00012C99 C3                  <1> 	retn
 68568                              <1> 
 68569                              <1> scbs_4: ; unlink the requested IRQ (if it belongs to current user)
 68570                              <1> 	; 10/06/2017
 68571                              <1> 	; 22/04/2017
 68572                              <1> 	; 14/04/2017
 68573                              <1> 	; If AL = 0 -> The caller is 'syscalbac'
 68574 00012C9A 8AA6[58890100]      <1> 	mov	ah, [esi+IRQ.owner]
 68575 00012CA0 3A25[6D010300]      <1> 	cmp	ah, [u.uno]
 68576 00012CA6 75E6                <1> 	jne	short scbs_1
 68577                              <1> 
 68578 00012CA8 FE0D[92010300]      <1> 	dec	byte [u.irqc] ; decrease IRQ count (in use)
 68579                              <1> 
 68580                              <1> 	;sub	ah, ah
 68581                              <1> 	;mov	[esi+IRQ.owner], ah ; 0 ; free !!!
 68582                              <1> 	;and	byte [esi+IRQ.method], 80h
 68583                              <1> 	;mov	[esi+IRQ.srb], ah ; 0
 68584                              <1> 	;mov	[esi+IRQ.dev], ah ; 0
 68585                              <1> 	;mov	dword [esi+IRQ.addr], 0
 68586                              <1> 	;mov	dword [u.r0], 0
 68587                              <1> 
 68588                              <1> 	;mov	byte [esi+IRQ.owner], 0
 68589                              <1> 
 68590                              <1> 	; 22/04/2017
 68591 00012CAE 29C0                <1> 	sub	eax, eax
 68592 00012CB0 8886[58890100]      <1> 	mov	[esi+IRQ.owner], al ; 0
 68593                              <1> 	; 10/06/2017
 68594 00012CB6 8686[6A890100]      <1> 	xchg	al, [esi+IRQ.method]
 68595 00012CBC 2480                <1> 	and	al, 80h
 68596 00012CBE 745E                <1> 	jz	short scbs_12 
 68597                              <1> 	; Audio device must be disabled -later- ! ([IRQ.medhod] = 80h)
 68598                              <1> 
 68599                              <1> ;	cmp	byte [esi+IRQ.method], 80h ; device drv or kernel extension ?
 68600                              <1> ;	jb	short scbs_12 ; bh = 0 reset to default IRQ handler
 68601                              <1> ;
 68602                              <1> ;	and	al, al
 68603                              <1> ;	jz	short scbs_5  ; the caller is 'syscalbac'
 68604                              <1> ;	; The caller is 'sysaudio' or ...
 68605 00012CC0 30C0                <1> 	xor	al, al
 68606                              <1> ;	mov	[esi+IRQ.method], al ; 0 ; reset kernel extension flag
 68607                              <1> ;scbs_5:
 68608                              <1> ;	sub	ah, ah
 68609                              <1> 	;mov	[u.r0], eax ; 0
 68610 00012CC2 C3                  <1> 	retn	
 68611                              <1> 
 68612                              <1> scbs_6:
 68613                              <1> 	; 14/04/2017
 68614 00012CC3 20C0                <1> 	and	al, al
 68615 00012CC5 7405                <1> 	jz	short scbs_7  ; the caller is 'syscalbac'
 68616                              <1> 	; AL = user number ([u.uno] or [audio.user] or ...)
 68617                              <1> 	; The caller is 'sysaudio' or ...
 68618                              <1> 	;	
 68619                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
 68620                              <1> 	;	      (2 = auto increment of signal response byte) 
 68621                              <1> 
 68622 00012CC7 80CF80              <1> 	or	bh, 80h		; Kernel extension flag !
 68623 00012CCA EB0A                <1> 	jmp	short scbs_8
 68624                              <1> scbs_7:	
 68625 00012CCC 8A86[6A890100]      <1> 	mov	al, [esi+IRQ.method] ; >= 80h = kernel is using this IRQ
 68626 00012CD2 2480                <1> 	and	al, 80h ; use only bit 7 (kernel function flag)
 68627 00012CD4 08C7                <1> 	or	bh, al		 ; method 
 68628                              <1> 				 ; 0 = signal response byte, 1 = callback
 68629                              <1> 				 ; 2 = auto increment of s.r.b.
 68630                              <1> scbs_8:
 68631 00012CD6 A0[6D010300]        <1> 	mov	al, [u.uno] ; user (process) number (1 to 16)
 68632 00012CDB 8886[58890100]      <1> 	mov	[esi+IRQ.owner], al ; lock the IRQ for user
 68633 00012CE1 88BE[6A890100]      <1> 	mov	[esi+IRQ.method], bh
 68634                              <1> 
 68635                              <1> ;	test	bh, 1
 68636                              <1> ;	jnz	short scbs_9 	 ; Callback method, CX will not be used 
 68637                              <1> ;			
 68638                              <1> ;	test	bh, 2		 ; use auto increment (counter) method
 68639                              <1> ;	jz	short scbs_10	 ; (count can be used for buffer switch)
 68640                              <1> ;scbs_9:
 68641                              <1> ;	xor	ecx, ecx ; 0
 68642                              <1> 
 68643                              <1> scbs_10:			      	
 68644                              <1> 	;mov	[esi+IRQ.method], bh
 68645 00012CE7 888E[73890100]      <1> 	mov	[esi+IRQ.srb], cl
 68646 00012CED C686[61890100]00    <1> 	mov	byte [esi+IRQ.dev], 0 ; device number is always 0 
 68647                              <1> 				 ; for this system call
 68648                              <1> 	;test	bh, 1
 68649 00012CF4 80E701              <1> 	and	bh, 1 ; 17/04/2017
 68650 00012CF7 7513                <1> 	jnz	short scbs_11	 ; callback method, use virtual address 
 68651                              <1> 
 68652 00012CF9 53                  <1> 	push	ebx ; IRQ number (in BL)
 68653 00012CFA 89D3                <1> 	mov	ebx, edx
 68654                              <1> 	; ebx = virtual address
 68655                              <1> 	; [u.pgdir] = page directory's physical address
 68656 00012CFC FE05[16890100]      <1> 	inc	 byte [no_page_swap] ; 1 
 68657                              <1> 			; Do not add this page to swap queue
 68658                              <1> 			; and remove it from swap queue if it is
 68659                              <1> 			; on the queue.
 68660 00012D02 E8812DFFFF          <1> 	call	get_physical_addr
 68661 00012D07 5B                  <1> 	pop	ebx
 68662 00012D08 728A                <1> 	jc	short scbs_3 ; invalid address !
 68663                              <1> 	; eax = physical address of the virtual address in user's space
 68664 00012D0A 89C2                <1> 	mov	edx, eax
 68665                              <1> scbs_11:
 68666 00012D0C 66C1E602            <1> 	shl	si, 2		; byte (index) to dword (offset)
 68667 00012D10 8996[7C890100]      <1> 	mov	[esi+IRQ.addr], edx
 68668                              <1> 
 68669 00012D16 FE05[92010300]      <1> 	inc	byte [u.irqc]	; increase IRQ (in use) count
 68670                              <1> 
 68671 00012D1C FEC7                <1> 	inc	bh ; 17/04/2017
 68672                              <1> 	; bh > 0 -> set to requested IRQ handler (IRQ_u_list)
 68673                              <1> scbs_12:
 68674 00012D1E 88D8                <1> 	mov	al, bl ; IRQ number
 68675 00012D20 88FC                <1> 	mov	ah, bh ; 0 = reset, >0 = set
 68676 00012D22 E860F5FFFF          <1> 	call	set_hardware_int_vector
 68677                              <1> 
 68678 00012D27 31C0                <1> 	xor	eax, eax
 68679                              <1> 	;mov 	[u.r0], eax ; 0	
 68680                              <1> 
 68681 00012D29 C3                  <1> 	retn	; return with success (cf=0, eax=0)
 68682                              <1> 
 68683                              <1> 
 68684                              <1> sysdma: ; DMA FUNCTIONS
 68685                              <1> 	; 08/08/2022
 68686                              <1> 	; 30/07/2022 - TRDOS 386 Kernel v2.0.5
 68687                              <1> 	; 02/09/2017
 68688                              <1> 	; 28/08/2017
 68689                              <1> 	; 20/08/2017 - TRDOS 386 (TRDOS v2.0)
 68690                              <1> 	;
 68691                              <1> 	; Inputs:
 68692                              <1> 	;	BH = 0 -> Allocate DMA buffer
 68693                              <1> 	;	   BL = 0 -> Use the system's default DMA
 68694                              <1> 	;		     (SB16) Buffer
 68695                              <1> 	;	        Buffer Size (max.) = 65536 bytes
 68696                              <1> 	;	   BL > 0 -> Allocate (a new) DMA buffer
 68697                              <1>  	;	   ECX = DMA Buffer Size in bytes (<=128KB)
 68698                              <1> 	;	   EDX = Virtual Address of DMA buffer 	
 68699                              <1> 	;		
 68700                              <1> 	;	BH = 1 -> Initialize (Start) DMA service
 68701                              <1> 	;	     BL, bit 0 to 3 = Channel Number (0 to 7)	
 68702                              <1> 	;	     BL, bit 7 = Auto Initialized Mode 
 68703                              <1> 	;			(If bit 7 is set)
 68704                              <1> 	;		 bit 6 = Record (read) mode (0= playback)
 68705                              <1> 	;	     ECX = byte count (0 = use dma buffer size)
 68706                              <1> 	;	     EDX = physical buffer address
 68707                              <1> 	;	     	   (0 = use dma buffer -start- address)		
 68708                              <1> 	;
 68709                              <1> 	;	BH = 2 -> Get Current DMA Buffer Offset
 68710                              <1> 	;	     BL = DMA channel number	
 68711                              <1> 	;		
 68712                              <1> 	;	BH = 3 -> Get Current DMA count down value
 68713                              <1> 	;	     BL = DMA channel number (0 tO 7)	
 68714                              <1> 	;
 68715                              <1> 	;	BH = 4 -> Get Current DMA channel (in progress)
 68716                              <1> 	;
 68717                              <1> 	;	BH = 5 -> Get System's Default DMA Buffer Address
 68718                              <1> 	;
 68719                              <1> 	;	BH = 6 -> Get Current DMA Buffer Address	
 68720                              <1> 	;
 68721                              <1> 	;	BH = 7 -> Stop DMA service
 68722                              <1> 	;
 68723                              <1> 	; Outputs:
 68724                              <1> 	;
 68725                              <1> 	;	For BH = 0 ; Allocate DMA buffer
 68726                              <1> 	;	    EAX = Physical address of DMA buffer
 68727                              <1> 	;	    ECX = Allocated buffer size in bytes
 68728                              <1> 	;		  - page count * 4096 -
 68729                              <1> 	;		  (may be bigger than requested)	
 68730                              <1> 	;	    If BL input > 0,
 68731                              <1> 	;	       'sysalloc:' system call will be used with
 68732                              <1>   	;	       EBX (for 'sysalloc') = EDX (for 'sysdma')
 68733                              <1> 	;	       ECX is same, byte count (buffer size)
 68734                              <1> 	;	       EDX = 1024*1024*16 ; 16 MB upper limit	 		        	 
 68735                              <1> 	;	    If BL input = 0,
 68736                              <1> 	;	       Default DMA buffer (SB16 buffer) will be
 68737                              <1> 	;	       checked and if it is free, it's address
 68738                              <1> 	;	       will be returned in EAX and it's size
 68739                              <1> 	;	       will be returned in ECX (as 65536)
 68740                              <1> 	;
 68741                              <1> 	;	    If CF = 1, error code is in EAX
 68742                              <1> 	;	       EAX = -1 ; DMA buffer allocation error! 		
 68743                              <1> 	;	       EAX = 11 ; 'Permission Denied' error !
 68744                              <1> 	;
 68745                              <1> 	;	       Note: 'sysalloc' error return method
 68746                              <1> 	;		      will be applied if BL input > 0 !		
 68747                              <1> 	;
 68748                              <1> 	; 	 For BH = 1 ; Initialize (Start) DMA
 68749                              <1> 	;	     EAX = 0 (Successful)	
 68750                              <1> 	;	     If CF = 1, error code is in EAX
 68751                              <1> 	;
 68752                              <1> 	; 	 For BH = 2 ; Get Current DMA Buffer Offset
 68753                              <1> 	;	     EAX = DMA Buffer Offset (in bytes)
 68754                              <1> 	;	     ;
 68755                              <1> 	;	      AX = DMA buffer offset
 68756                              <1> 	;	     EAX bits 16 to 23 = Page register value
 68757                              <1> 	;		   	
 68758                              <1> 	; 	 For BH = 3 ; Get Current DMA count down value
 68759                              <1> 	;	     EAX = Count down value (remain bytes)
 68760                              <1> 	;	
 68761                              <1> 	;	 For BH = 4 ; Get Current DMA channel (in progress)
 68762                              <1> 	;	     EAX = DMA channel number (0 to 7)
 68763                              <1> 	;		AH = 0 if the owner is the caller process
 68764                              <1> 	;		AH > 0 if the dma channel is in use by
 68765                              <1> 	;		       another user/process
 68766                              <1> 	;	     EAX = -1 (0FFFFFFFFh) 
 68767                              <1> 	;		    if DMA service is not in use	    		
 68768                              <1> 	;	 	    (stopped or not initialized/started)	
 68769                              <1> 	;
 68770                              <1> 	;	 For BH = 5 ; Get System's Default DMA Buff Addr
 68771                              <1> 	;	     EAX = Default DMA Buffer Address (Physical)
 68772                              <1> 	;		 = offset 'sb16_dma_buffer:'	
 68773                              <1> 	;	     ECX = Buffer size
 68774                              <1> 	;		 = 65536 
 68775                              <1> 	;
 68776                              <1> 	;	 For BH = 6 ; Get Current DMA Buffer Address
 68777                              <1> 	;	     EAX = Current DMA buffer address (Physical)
 68778                              <1> 	;	     ECX = Current DMA buffer size (setting value)	   		  	 		
 68779                              <1> 	;	     Note: These values are for current dma channel
 68780                              <1> 	;		   settings for the user/process
 68781                              <1> 	;	     ** For now (for current TRDOS 386 version)
 68782                              <1> 	;		only one user/process can use only one
 68783                              <1> 	;		dma channel & one dma buffer at same time
 68784                              <1> 	;		(no multi tasking on DMA service) !!! **
 68785                              <1> 	;	     (Once, current DMA user must stop it's own DMA
 68786                              <1> 	;	      DMA service, than another user/program 
 68787                              <1> 	;	      can use DMA service with same dma channel 
 68788                              <1> 	;	      or with another DMA channel.)	 			      		
 68789                              <1> 	;
 68790                              <1> 	;	 For BH = 7 ; Stop DMA service (for current user
 68791                              <1> 	;	     and current DMA channel)	
 68792                              <1> 	;	     EAX = 0 ; successful
 68793                              <1> 	;	     CF = 1 & EAX > 0 (= -1) -> Error		
 68794                              <1> 
 68795 00012D2A 80FF07              <1> 	cmp	bh, 7
 68796 00012D2D 7612                <1> 	jna	short sysdma_0
 68797                              <1> 
 68798                              <1> sysdma_err:
 68799 00012D2F 31C0                <1> 	xor	eax, eax
 68800 00012D31 48                  <1> 	dec	eax ; -1
 68801                              <1> sysdma_perm_err:
 68802 00012D32 A3[1C010300]        <1> 	mov	[u.r0], eax
 68803 00012D37 A3[84010300]        <1> 	mov	[u.error], eax ; DMA service error !
 68804 00012D3C E9919FFFFF          <1> 	jmp	error
 68805                              <1> 
 68806                              <1> sysdma_0:
 68807 00012D41 08FF                <1> 	or	bh, bh
 68808 00012D43 7537                <1> 	jnz	short sysdma_1 ; 30/07/2022
 68809                              <1> 	
 68810 00012D45 20DB                <1> 	and	bl, bl
 68811 00012D47 7416                <1> 	jz	short sysdma_01
 68812                              <1> 
 68813                              <1> 	; redirect system call to 'sysalloc'
 68814 00012D49 89D3                <1> 	mov	ebx, edx ; virtual address of DMA buffer
 68815                              <1> 	;ecx = Buffer size in bytes
 68816                              <1> 	; DMA buffer address <= 16MB upper limit
 68817 00012D4B BA00000001          <1> 	mov	edx, 1024*1024*16 ; 16MB limit for DMA buff
 68818                              <1> 
 68819 00012D50 C705[EC8D0100]FFFF- <1> 	mov	dword [dma_addr], 0FFFFFFFFh ; -1
 68820 00012D58 FFFF                <1>
 68821                              <1> 
 68822 00012D5A E97EE7FFFF          <1> 	jmp	sysalloc
 68823                              <1> 
 68824                              <1> sysdma_01:
 68825 00012D5F B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
 68826                              <1> 
 68827 00012D64 803D[A9890100]01    <1> 	cmp	byte [audio_device], 1
 68828 00012D6B 724A                <1> 	jb	short sysdma_03
 68829                              <1> 
 68830 00012D6D 3B05[C8890100]      <1> 	cmp	eax, [audio_dma_buff]
 68831 00012D73 7527                <1> 	jne	short sysdma_02
 68832                              <1> 
 68833                              <1> sysdma_0_err:
 68834 00012D75 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
 68835 00012D7A EBB6                <1> 	jmp	short sysdma_perm_err
 68836                              <1> 
 68837                              <1> 	; 30/07/2022
 68838                              <1> sysdma_1:
 68839 00012D7C 80FF01              <1> 	cmp	bh, 1
 68840                              <1> 	;ja	sysdma_5
 68841                              <1> 	; 30/07/2022
 68842 00012D7F 7605                <1> 	jna	short sysdma_10
 68843 00012D81 E90C010000          <1> 	jmp	sysdma_5
 68844                              <1> 
 68845                              <1> sysdma_10:
 68846 00012D86 F6C340              <1> 	test	bl, 40h	; record (read) mode -BL, bit 6-
 68847                              <1> 	;jnz	sysdma_err ; not ready yet!
 68848                              <1> 	; 30/07/2022
 68849 00012D89 757C                <1> 	jnz	short sysdma_06 ; jmp sysdma_err
 68850                              <1> 
 68851 00012D8B A1[EC8D0100]        <1> 	mov	eax, [dma_addr] ; physical address of dma buffer
 68852 00012D90 21C0                <1> 	and	eax, eax
 68853                              <1> 	;jz	sysdma_err
 68854                              <1> 	; 30/07/2022
 68855 00012D92 7473                <1> 	jz	short sysdma_06 ; jmp sysdma_err
 68856                              <1> 
 68857 00012D94 09D2                <1> 	or	edx, edx
 68858 00012D96 7574                <1> 	jnz	short sysdma_11
 68859                              <1> 
 68860 00012D98 89C2                <1> 	mov	edx, eax
 68861 00012D9A EB74                <1> 	jmp	short sysdma_12	
 68862                              <1> 
 68863                              <1> sysdma_02:
 68864                              <1> 	; Only one user is permitted for audio/dma functions
 68865                              <1> 
 68866 00012D9C 833D[C8890100]00    <1> 	cmp	dword [audio_dma_buff], 0
 68867 00012DA3 7612                <1> 	jna	short sysdma_03
 68868                              <1> 
 68869 00012DA5 8A1D[D1890100]      <1> 	mov	bl, [audio_user]
 68870 00012DAB 08DB                <1> 	or	bl, bl
 68871 00012DAD 7408                <1> 	jz	short sysdma_03
 68872                              <1> 
 68873 00012DAF 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
 68874 00012DB5 75BE                <1> 	jne	short sysdma_0_err
 68875                              <1> 
 68876                              <1> sysdma_03: 
 68877 00012DB7 8A1D[E98D0100]      <1> 	mov	bl, [dma_user]
 68878 00012DBD 20DB                <1> 	and	bl, bl
 68879 00012DBF 750E                <1> 	jnz	short sysdma_04
 68880                              <1> 	
 68881 00012DC1 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
 68882 00012DC7 881D[E98D0100]      <1> 	mov	[dma_user], bl
 68883                              <1> 
 68884 00012DCD EB15                <1> 	jmp	short sysdma_05
 68885                              <1> 
 68886                              <1> sysdma_04:
 68887 00012DCF 8B35[EC8D0100]      <1> 	mov	esi, [dma_addr]
 68888 00012DD5 21F6                <1> 	and	esi, esi
 68889 00012DD7 740B                <1> 	jz	short sysdma_05
 68890                              <1> 
 68891 00012DD9 46                  <1> 	inc	esi ; -1 -> 0
 68892 00012DDA 7408                <1> 	jz	short sysdma_05
 68893                              <1> 
 68894 00012DDC 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
 68895 00012DE2 7591                <1> 	jne	short sysdma_0_err
 68896                              <1> 	
 68897                              <1> sysdma_05:
 68898                              <1> 	; edx = virtual address (user's buffer address)
 68899                              <1> 	; 
 68900 00012DE4 81F900000100        <1> 	cmp	ecx, 65536   ; byte count (buffer size)
 68901                              <1> 	;ja	sysdma_err
 68902                              <1> 	; 30/07/2022
 68903 00012DEA 771B                <1> 	ja	short sysdma_06 ; jmp sysdma_err
 68904                              <1> 	;
 68905 00012DEC 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 68906 00012DF2 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 68907                              <1> 	;cmp	ecx, 65536
 68908                              <1> 	;ja	sysdma_err
 68909 00012DF7 51                  <1> 	push	ecx	; buffer size (allocated pages * 4096) 
 68910 00012DF8 50                  <1> 	push	eax	; offset sb16_dma_buffer
 68911 00012DF9 89D3                <1> 	mov	ebx, edx
 68912 00012DFB C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
 68913                              <1> 	; eax = physical address of (audio) dma buffer
 68914                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
 68915                              <1> 	; ecx = page count (>0)
 68916 00012DFE E83730FFFF          <1> 	call	direct_memory_access
 68917 00012E03 58                  <1> 	pop	eax
 68918 00012E04 59                  <1> 	pop	ecx
 68919                              <1> 	;jc	sysdma_err
 68920                              <1> 	; 30/07/2022
 68921 00012E05 7315                <1> 	jnc	short sysdma_07
 68922                              <1> sysdma_06:
 68923 00012E07 E923FFFFFF          <1> 	jmp	sysdma_err
 68924                              <1> 
 68925                              <1> sysdma_11:
 68926 00012E0C 39C2                <1> 	cmp	edx, eax
 68927                              <1> 	;jb	sysdma_err
 68928                              <1> 	; 30/07/2022
 68929 00012E0E 72F7                <1> 	jb	short sysdma_06 ; jmp sysdma_err
 68930                              <1> sysdma_12:
 68931 00012E10 21C9                <1> 	and	ecx, ecx
 68932 00012E12 7515                <1> 	jnz	short sysdma_13
 68933                              <1> 
 68934 00012E14 8B0D[F08D0100]      <1> 	mov	ecx, [dma_size]
 68935 00012E1A EB15                <1> 	jmp	short sysdma_14
 68936                              <1> 
 68937                              <1> sysdma_07:
 68938 00012E1C A3[EC8D0100]        <1> 	mov	[dma_addr], eax
 68939 00012E21 890D[F08D0100]      <1> 	mov	[dma_size], ecx ; dma buffer size (in bytes)
 68940                              <1> 
 68941                              <1> 	;mov	[u.r0], eax ; DMA Buffer Address (Physical)
 68942                              <1> 
 68943                              <1> 	;mov	ebp, [u.usp]  ; ebp points to user's registers
 68944                              <1> 	;mov	[ebp+24], ecx ; return to user with ecx value
 68945                              <1> 
 68946                              <1> 	;jmp	sysret
 68947                              <1> 
 68948                              <1> 	; 28/08/2017
 68949 00012E27 EB7A                <1> 	jmp	sysdma_51
 68950                              <1> 
 68951                              <1> sysdma_13:
 68952 00012E29 3B0D[F08D0100]      <1> 	cmp	ecx, [dma_size]
 68953                              <1> 	;ja	sysdma_err
 68954                              <1> 	; 30/07/2022
 68955 00012E2F 77D6                <1> 	ja	short sysdma_06 ; jmp sysdma_err
 68956                              <1> sysdma_14:
 68957 00012E31 89C6                <1> 	mov	esi, eax
 68958 00012E33 0335[F08D0100]      <1> 	add	esi, [dma_size]
 68959                              <1> 
 68960 00012E39 89D0                <1> 	mov	eax, edx
 68961 00012E3B 01C8                <1> 	add	eax, ecx
 68962                              <1> 	;jc	sysdma_err ; 02/09/2017
 68963                              <1> 	; 30/07/2022
 68964 00012E3D 72C8                <1> 	jc	short sysdma_06 ; jmp sysdma_err	
 68965                              <1> 		
 68966 00012E3F 39F0                <1> 	cmp	eax, esi
 68967                              <1> 	;ja	sysdma_err
 68968                              <1> 	; 30/07/2022
 68969 00012E41 77C4                <1> 	ja	short sysdma_06 ; jmp sysdma_err
 68970                              <1> 
 68971 00012E43 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff]
 68972 00012E49 8B35[EC8D0100]      <1> 	mov	esi, [dma_addr]
 68973                              <1> 
 68974 00012E4F 09FF                <1> 	or	edi, edi
 68975 00012E51 7425                <1> 	jz	short sysdma_16
 68976                              <1> 	
 68977 00012E53 803D[A9890100]01    <1> 	cmp	byte [audio_device], 1
 68978 00012E5A 7209                <1> 	jb	short sysdma_15
 68979                              <1> 
 68980                              <1> 	; Sound Blaster 16
 68981 00012E5C 39FE                <1> 	cmp	esi, edi
 68982                              <1> 	;je	sysdma_0_err ; permmission denied !
 68983                              <1> 	; 30/07/2022
 68984 00012E5E 7505                <1> 	jne	short sysdma_15
 68985 00012E60 E910FFFFFF          <1> 	jmp	sysdma_0_err
 68986                              <1> sysdma_15:
 68987 00012E65 C605[EB8D0100]48    <1> 	mov	byte [dma_mode], 48h ; single mode playback	
 68988                              <1> 
 68989 00012E6C F6C380              <1> 	test	bl, 80h ; DMA mode - BL, bit 7, auto init -
 68990 00012E6F 7407                <1> 	jz	short sysdma_16	
 68991                              <1> 	; Auto initialized playback (write) mode
 68992 00012E71 8005[EB8D0100]10    <1> 	add	byte [dma_mode], 10h ; = 58h
 68993                              <1> sysdma_16:
 68994 00012E78 80E307              <1> 	and	bl, 07h
 68995 00012E7B 881D[EA8D0100]      <1> 	mov	[dma_channel], bl
 68996 00012E81 8915[F48D0100]      <1> 	mov	[dma_start], edx
 68997 00012E87 890D[F88D0100]      <1> 	mov	[dma_count], ecx
 68998                              <1> 	 
 68999                              <1> 	; 28/08/2017
 69000                              <1> 	;call	dma_init
 69001                              <1> 	;jmp	sysret
 69002 00012E8D E945010000          <1> 	jmp	dma_init
 69003                              <1> 
 69004                              <1> sysdma_5:
 69005 00012E92 80FF05              <1> 	cmp	bh, 5
 69006 00012E95 726D                <1> 	jb	short sysdma_3
 69007 00012E97 7759                <1> 	ja	short sysdma_6
 69008                              <1> 
 69009                              <1> 	; Get the system's default dma buffer addr and size
 69010 00012E99 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
 69011 00012E9E B900000100          <1> 	mov	ecx, 65536 ; Buffer size in bytes
 69012                              <1> 
 69013                              <1> sysdma_51:
 69014                              <1> 	; 0 = there is not a dma buffer (in use or available)
 69015 00012EA3 A3[1C010300]        <1> 	mov	[u.r0], eax
 69016                              <1> 
 69017 00012EA8 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 69018 00012EAE 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value
 69019                              <1> 
 69020 00012EB1 E93C9EFFFF          <1> 	jmp	sysret
 69021                              <1> 
 69022                              <1> sysdma_2:
 69023                              <1> 	; Get current dma buffer offset (& page)
 69024                              <1> 	; 28/08/2017
 69025 00012EB6 0FB635[EA8D0100]    <1> 	movzx	esi, byte [dma_channel]
 69026 00012EBD 0FB696[C2370100]    <1> 	movzx	edx, byte [dma_flip+esi]
 69027 00012EC4 EE                  <1> 	out	dx, al			; flip-flop clear
 69028 00012EC5 8A96[9A370100]      <1> 	mov	dl, [dma_adr+esi]
 69029 00012ECB EC                  <1> 	in	al, dx			; get dma position
 69030 00012ECC 0FB6D8              <1> 	movzx	ebx, al
 69031 00012ECF EC                  <1> 	in	al, dx			
 69032 00012ED0 88C7                <1> 	mov	bh, al
 69033                              <1> 
 69034 00012ED2 6683FE04            <1> 	cmp	si, 4	; channel number ?
 69035 00012ED6 7202                <1> 	jb	short sysdma_21 ; 8 bit dma channel
 69036                              <1> 
 69037 00012ED8 D1E3                <1> 	shl	ebx, 1	; word offset to byte offset
 69038                              <1> 
 69039                              <1> sysdma_21:
 69040 00012EDA 891D[1C010300]      <1> 	mov	[u.r0], ebx
 69041                              <1> 
 69042 00012EE0 8A96[AA370100]      <1> 	mov	dl, [dma_page+esi]
 69043 00012EE6 EC                  <1> 	in	al, dx			; get dma page
 69044                              <1> 
 69045                              <1> 	;add	[u.ro+2], al
 69046 00012EE7 0805[1E010300]      <1> 	or	[u.r0+2], al
 69047                              <1> 
 69048 00012EED E9009EFFFF          <1> 	jmp	sysret
 69049                              <1> 
 69050                              <1> sysdma_6:
 69051 00012EF2 80FF06              <1> 	cmp	bh, 6
 69052 00012EF5 775C                <1> 	ja	short sysdma_7
 69053                              <1> 
 69054                              <1> 	; 28/08/2017
 69055                              <1> 	; Get current DMA buffer addr and size
 69056 00012EF7 A1[EC8D0100]        <1> 	mov	eax, [dma_addr] ; dma buffer address
 69057 00012EFC 8B0D[F08D0100]      <1> 	mov	ecx, [dma_size] ; dma buffer size (in bytes)
 69058                              <1> 
 69059 00012F02 EB9F                <1> 	jmp	short sysdma_51
 69060                              <1> 
 69061                              <1> sysdma_3:
 69062 00012F04 80FF03              <1> 	cmp	bh, 3
 69063 00012F07 72AD                <1> 	jb	short sysdma_2
 69064 00012F09 772F                <1> 	ja	short sysdma_4
 69065                              <1> 
 69066                              <1> 	; Get current dma count down value (remain bytes)
 69067                              <1> 	; 28/08/2017
 69068 00012F0B 0FB635[EA8D0100]    <1> 	movzx	esi, byte [dma_channel]
 69069 00012F12 0FB696[C2370100]    <1> 	movzx	edx, byte [dma_flip+esi]
 69070 00012F19 EE                  <1> 	out	dx, al			; flip-flop clear
 69071 00012F1A 8A96[A2370100]      <1> 	mov	dl, [dma_cnt+esi] ; dma count register addr
 69072 00012F20 EC                  <1> 	in	al, dx
 69073 00012F21 0FB6D8              <1> 	movzx	ebx, al	
 69074 00012F24 EC                  <1> 	in	al, dx
 69075 00012F25 88C7                <1> 	mov     bh, al
 69076                              <1> 	
 69077 00012F27 6683FE04            <1> 	cmp	si, 4	; channel number ?
 69078 00012F2B 7202                <1> 	jb	short sysdma_31 ; 8 bit dma channel
 69079                              <1> 
 69080 00012F2D D1E3                <1> 	shl	ebx, 1	; word count to byte count
 69081                              <1> 
 69082                              <1> sysdma_31:
 69083 00012F2F 891D[1C010300]      <1> 	mov	[u.r0], ebx
 69084                              <1> 
 69085 00012F35 E9B89DFFFF          <1> 	jmp	sysret
 69086                              <1> 
 69087                              <1> sysdma_4:
 69088                              <1> 	; Get current DMA channel number
 69089                              <1> 	; 28/08/2017
 69090 00012F3A 8A25[E98D0100]      <1> 	mov	ah, [dma_user]
 69091 00012F40 20E4                <1> 	and	ah, ah
 69092 00012F42 7539                <1> 	jnz	short sysdma_42
 69093                              <1> 
 69094                              <1> sysdma_41:	
 69095                              <1> 	; Not a valid dma channel (in use)
 69096 00012F44 C705[1C010300]FFFF- <1> 	mov	dword [u.r0], -1 ; 0FFFFFFFFh
 69097 00012F4C FFFF                <1>
 69098 00012F4E E99F9DFFFF          <1> 	jmp	sysret
 69099                              <1> 
 69100                              <1> sysdma_7:
 69101                              <1> 	; DMA service STOP
 69102 00012F53 A0[6D010300]        <1> 	mov	al, [u.uno]
 69103 00012F58 3A05[E98D0100]      <1> 	cmp	al, [dma_user]
 69104 00012F5E 7543                <1> 	jne	short sysdma_72
 69105                              <1> 	
 69106 00012F60 28C0                <1> 	sub	al, al ; 0
 69107                              <1> 
 69108 00012F62 A2[E98D0100]        <1> 	mov	[dma_user], al ; clear user
 69109                              <1> 
 69110 00012F67 8605[EB8D0100]      <1> 	xchg	al, [dma_mode]
 69111 00012F6D 20C0                <1> 	and	al, al
 69112                              <1> 	;jz	short sysdma_err
 69113 00012F6F 754E                <1> 	jnz	short sysdma_73	
 69114                              <1> 
 69115                              <1> sysdma_71:
 69116 00012F71 31C0                <1> 	xor	eax, eax
 69117 00012F73 A3[1C010300]        <1> 	mov	[u.r0], eax; 0
 69118 00012F78 E9759DFFFF          <1> 	jmp	sysret
 69119                              <1> 
 69120                              <1> sysdma_42:
 69121 00012F7D 8B35[EC8D0100]      <1> 	mov	esi, [dma_addr]
 69122 00012F83 21F6                <1> 	and	esi, esi
 69123 00012F85 74BD                <1> 	jz	short sysdma_41
 69124                              <1> 
 69125 00012F87 46                  <1> 	inc	esi ; -1 -> 0
 69126 00012F88 74BA                <1> 	jz	short sysdma_41
 69127                              <1> 
 69128 00012F8A A0[EA8D0100]        <1> 	mov	al, [dma_channel]
 69129                              <1> 
 69130 00012F8F 3A25[6D010300]      <1> 	cmp	ah, [u.uno]
 69131 00012F95 7502                <1> 	jne	short sysdma_43
 69132                              <1> 
 69133 00012F97 30E4                <1> 	xor	ah, ah ; DMA channel in use by current user
 69134                              <1> 
 69135                              <1> sysdma_43:
 69136 00012F99 A3[1C010300]        <1> 	mov	[u.r0], eax ; AL = dma channel number
 69137                              <1> 			    ; AH > 0 if the the channel
 69138                              <1> 			    ; in use by another user/process
 69139 00012F9E E94F9DFFFF          <1> 	jmp	sysret
 69140                              <1> 
 69141                              <1> sysdma_72:
 69142                              <1> 	; 28/08/2017
 69143 00012FA3 803D[E98D0100]00    <1> 	cmp	byte [dma_user], 0
 69144 00012FAA 76C5                <1> 	jna	short sysdma_71 ; Nothing to do !
 69145                              <1> 
 69146 00012FAC 833D[EC8D0100]00    <1> 	cmp	dword [dma_addr], 0
 69147                              <1> 	;ja	sysdma_0_err
 69148                              <1> 	; 30/07/2022
 69149 00012FB3 7605                <1> 	jna	short sysdma_74
 69150 00012FB5 E9BBFDFFFF          <1> 	jmp	sysdma_0_err
 69151                              <1> 
 69152                              <1> sysdma_74:	
 69153 00012FBA A2[E98D0100]        <1> 	mov	[dma_user], al ; reset to current user
 69154                              <1> 
 69155                              <1> sysdma_73:
 69156                              <1> 	; 28/08/2017
 69157 00012FBF 0FB635[EA8D0100]    <1> 	movzx	esi, byte [dma_channel]
 69158 00012FC6 0FB696[B2370100]    <1> 	movzx	edx, byte [dma_mask+esi]
 69159 00012FCD A0[EA8D0100]        <1> 	mov	al, [dma_channel]
 69160 00012FD2 0C04                <1> 	or	al, 4
 69161 00012FD4 EE                  <1> 	out	dx, al
 69162                              <1> 
 69163 00012FD5 EB9A                <1> 	jmp	short sysdma_71
 69164                              <1> 
 69165                              <1> dma_init:
 69166                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 69167                              <1> 	; 28/08/2017
 69168                              <1> 	; 20/08/2017
 69169                              <1> 	; DMA initialization
 69170                              <1> 	; 14/08/2017
 69171                              <1> 	; 03/08/2017, 06/08/2017, 08/08/2017
 69172                              <1> 	; 02/07/2017, 13/07/2017, 16/07/2017, 30/07/2017
 69173                              <1> 	; (Derived from 'DMA_INIT' procedure in SB16MOD.ASM)
 69174                              <1> 	; Modified for TRDOS 386 DMA buffer allocation & initialization !
 69175                              <1> 
 69176 00012FD7 8B1D[F48D0100]      <1> 	mov	ebx, [dma_start]
 69177 00012FDD 8B0D[F88D0100]      <1> 	mov	ecx, [dma_count]
 69178                              <1> 
 69179 00012FE3 0FB635[EA8D0100]    <1> 	movzx	esi, byte [dma_channel]
 69180                              <1> 
 69181 00012FEA 6683FE04            <1> 	cmp	si, 4
 69182 00012FEE 7204                <1> 	jb	short gdmi1
 69183                              <1> 	; 08/08/2017
 69184                              <1> 	;shr	cx, 1 ; word count
 69185                              <1> 	; 30/07/2022
 69186 00012FF0 D1E9                <1> 	shr	ecx, 1
 69187 00012FF2 D1EB                <1> 	shr	ebx, 1 ; convert byte offset to word offset
 69188                              <1> gdmi1:
 69189                              <1> 	;mov	[dma_poff], bx ; 08/08/2017
 69190                              <1> 	;dec	cx			; dma size = block size - 1
 69191                              <1> 	; 30/07/2022
 69192 00012FF4 49                  <1> 	dec	ecx	
 69193                              <1> 
 69194 00012FF5 0FB696[B2370100]    <1> 	movzx	edx, byte [dma_mask+esi] ; 30/07/2017
 69195 00012FFC A0[EA8D0100]        <1> 	mov	al, [dma_channel]
 69196 00013001 0C04                <1> 	or	al, 4
 69197 00013003 EE                  <1> 	out	dx, al			; dma channel mask
 69198                              <1> 
 69199 00013004 30C0                <1> 	xor	al, al ; 0 ; any value ! 08/08/2017
 69200 00013006 8A96[C2370100]      <1> 	mov	dl, [dma_flip+esi]
 69201 0001300C EE                  <1> 	out	dx, al			; flip-flop clear
 69202                              <1> 	
 69203 0001300D 8A96[BA370100]      <1> 	mov	dl, [dma_mod+esi]
 69204 00013013 A0[EA8D0100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
 69205 00013018 2403                <1> 	and	al, 3
 69206                              <1> 	; 08/08/2017
 69207 0001301A 0A05[EB8D0100]      <1> 	or	al, [dma_mode] ; 58h    ; dma mode for SB16
 69208 00013020 EE                  <1> 	out	dx, al			
 69209                              <1> 
 69210 00013021 8A96[9A370100]      <1> 	mov	dl, [dma_adr+esi]	
 69211 00013027 88D8                <1> 	mov	al, bl			
 69212 00013029 EE                  <1> 	out	dx, al			; offset low
 69213                              <1> 
 69214 0001302A 88F8                <1> 	mov	al, bh
 69215 0001302C EE                  <1> 	out	dx, al			; offset high
 69216                              <1> 
 69217 0001302D 8A96[A2370100]      <1> 	mov	dl, [dma_cnt+esi]
 69218 00013033 88C8                <1> 	mov	al, cl
 69219 00013035 EE                  <1> 	out	dx, al			; size low
 69220                              <1> 
 69221 00013036 88E8                <1> 	mov	al, ch
 69222 00013038 EE                  <1> 	out	dx, al			; size high
 69223                              <1> 
 69224 00013039 8A96[AA370100]      <1> 	mov	dl, [dma_page+esi]
 69225                              <1> 	; 14/08/2017 
 69226 0001303F 6683FE04            <1> 	cmp	si, 4
 69227 00013043 7305                <1> 	jnb	short gdmi2
 69228 00013045 C1EB10              <1> 	shr	ebx, 16
 69229 00013048 EB06                <1> 	jmp	short gdmi3
 69230                              <1> gdmi2:
 69231                              <1> 	; 09/08/2017
 69232 0001304A C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
 69233 0001304D 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary)
 69234                              <1> gdmi3:	
 69235 00013050 88D8                <1> 	mov	al, bl
 69236 00013052 EE                  <1> 	out	dx, al			; page			
 69237                              <1> 	
 69238 00013053 8A96[B2370100]      <1> 	mov	dl, [dma_mask+esi]
 69239 00013059 A0[EA8D0100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
 69240 0001305E 2403                <1> 	and	al, 3
 69241 00013060 EE                  <1> 	out	dx, al			; dma channel unmask
 69242                              <1> 
 69243                              <1> 	;retn
 69244                              <1> 	; 28/08/2017
 69245 00013061 E98C9CFFFF          <1> 	jmp	sysret
 69246                              <1> 
 69247                              <1> otty:
 69248                              <1> sret:
 69249                              <1> ocvt:
 69250                              <1> ctty:
 69251                              <1> cret:
 69252                              <1> ccvt:
 69253                              <1> rtty:
 69254                              <1> wtty:
 69255                              <1> rmem:
 69256                              <1> wmem:
 69257                              <1> rfd:
 69258                              <1> rhd:
 69259                              <1> wfd:
 69260                              <1> whd:
 69261                              <1> rlpt:
 69262                              <1> wlpt:
 69263                              <1> rcvt:
 69264                              <1> xmtt:
 69265 00013066 C3                  <1> 	retn
 69266                                  %include 'trdosk9.s' ; 04/01/2016
 69267                              <1> ; ****************************************************************************
 69268                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - INITIALIZED DATA : trdosk9.s
 69269                              <1> ; ----------------------------------------------------------------------------
 69270                              <1> ; Last Update: 11/08/2022 (Previous: 18/04/2021 - Kernel v2.0.4)
 69271                              <1> ; ----------------------------------------------------------------------------
 69272                              <1> ; Beginning: 04/01/2016
 69273                              <1> ; ----------------------------------------------------------------------------
 69274                              <1> ; ----------------------------------------------------------------------------
 69275                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 69276                              <1> ; ----------------------------------------------------------------------------
 69277                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 69278                              <1> ; TRDOS2.ASM (09/11/2011)
 69279                              <1> ; ****************************************************************************
 69280                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
 69281                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
 69282                              <1> ; CMD_INTR.ASM [29/01/2005] Last Update: 09/11/2011
 69283                              <1> ; FILE.ASM [29/10/2009] Last Update: 09/10/2011
 69284                              <1> 
 69285                              <1> ; 12/02/2016
 69286                              <1> Last_DOS_DiskNo: 
 69287 00013067 01                  <1> 		db 1 ; A: = 0 & B: = 1
 69288                              <1> 
 69289                              <1> Restore_CDIR:	
 69290 00013068 FF                  <1> 		db 0FFh ; Initial value -> any number except 0
 69291                              <1> 
 69292                              <1> msg_CRLF_temp:  
 69293 00013069 070D0A00            <1> 		db 07h, 0Dh, 0Ah, 0
 69294                              <1> 
 69295                              <1> Magic_Bytes:
 69296 0001306D 04                  <1> 		db 4
 69297 0001306E 01                  <1> 		db 1
 69298                              <1> mainprog_Version:
 69299 0001306F 07                  <1> 		db 7
 69300 00013070 5B5452444F535D204D- <1> 		db "[TRDOS] Main Program v2.0.5 (11/08/2022)"
 69301 00013079 61696E2050726F6772- <1>
 69302 00013082 616D2076322E302E35- <1>
 69303 0001308B 202831312F30382F32- <1>
 69304 00013094 30323229            <1>
 69305 00013098 0D0A                <1> 		db 0Dh, 0Ah
 69306 0001309A 286329204572646F67- <1> 		db "(c) Erdogan Tan 2005-2022"
 69307 000130A3 616E2054616E203230- <1>
 69308 000130AC 30352D32303232      <1>
 69309 000130B3 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69310                              <1> 
 69311                              <1> MainProgCfgFile: ; 14/04/2016
 69312 000130B6 4D41494E50524F472E- <1> 		db "MAINPROG.CFG", 0
 69313 000130BF 43464700            <1>
 69314                              <1> 
 69315                              <1> TRDOSPromptLabel:
 69316 000130C3 5452444F53          <1> 		db "TRDOS"
 69317 000130C8 00                  <1> 		db 0
 69318 000130C9 00<rept>            <1>                 times 5 db 0
 69319 000130CE 00                  <1> 		db 0
 69320                              <1> 
 69321                              <1> ; INTERNAL COMMANDS
 69322                              <1> Command_List:
 69323 000130CF 44495200            <1> Cmd_Dir:	db "DIR", 0
 69324 000130D3 434400              <1> Cmd_Cd:		db "CD", 0
 69325 000130D6 433A00              <1> Cmd_Drive:	db "C:", 0
 69326 000130D9 56455200            <1> Cmd_Ver:	db "VER", 0
 69327 000130DD 4558495400          <1> Cmd_Exit:	db "EXIT", 0
 69328 000130E2 50524F4D505400      <1> Cmd_Prompt:	db "PROMPT", 0
 69329 000130E9 564F4C554D4500      <1> Cmd_Volume:	db "VOLUME", 0
 69330 000130F0 4C4F4E474E414D4500  <1> Cmd_LongName:	db "LONGNAME", 0
 69331 000130F9 4441544500          <1> Cmd_Date:	db "DATE", 0
 69332 000130FE 54494D4500          <1> Cmd_Time:	db "TIME", 0
 69333 00013103 52554E00            <1> Cmd_Run:	db "RUN", 0
 69334 00013107 53455400            <1> Cmd_Set:	db "SET", 0 
 69335 0001310B 434C5300            <1> Cmd_Cls:	db "CLS", 0
 69336 0001310F 53484F5700          <1> Cmd_Show:	db "SHOW", 0
 69337 00013114 44454C00            <1> Cmd_Del:	db "DEL", 0
 69338 00013118 41545452494200      <1> Cmd_Attrib:	db "ATTRIB", 0
 69339 0001311F 52454E414D4500      <1> Cmd_Rename:	db "RENAME", 0
 69340 00013126 524D44495200        <1> Cmd_Rmdir:	db "RMDIR", 0
 69341 0001312C 4D4B44495200        <1> Cmd_Mkdir:	db "MKDIR", 0
 69342 00013132 434F505900          <1> Cmd_Copy:	db "COPY", 0
 69343 00013137 4D4F564500          <1> Cmd_Move:	db "MOVE", 0
 69344 0001313C 5041544800          <1> Cmd_Path:	db "PATH", 0
 69345 00013141 4D454D00            <1> Cmd_Mem:	db "MEM", 0
 69346 00013145 00                  <1> 		db 0
 69347 00013146 46494E4400          <1> Cmd_Find:	db "FIND", 0
 69348 0001314B 4543484F00          <1> Cmd_Echo:	db "ECHO", 0
 69349 00013150 2A00                <1> Cmd_Remark:	db "*", 0
 69350 00013152 3F00                <1> Cmd_Help:	db "?", 0
 69351 00013154 44455649434500      <1> Cmd_Device:	db "DEVICE", 0
 69352 0001315B 4445564C49535400    <1> Cmd_DevList:	db "DEVLIST", 0
 69353 00013163 434844495200        <1> Cmd_Chdir:	db "CHDIR", 0
 69354 00013169 4245455000          <1> Cmd_Beep:	db "BEEP", 0
 69355                              <1> 		
 69356 0001316E 00                  <1> 		db 0
 69357                              <1> 
 69358                              <1> ; 15/02/2016 (FILE.ASM, 09/10/2011)
 69359                              <1> invalid_fname_chars:
 69360 0001316F 222728292A2B2C2F    <1> 		db 22h, 27h, 28h, 29h, 2Ah, 2Bh, 2Ch, 2Fh
 69361 00013177 3A3B3C3D3E3F40      <1> 		db 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h
 69362 0001317E 5B5C5D5E60          <1> 		db 5Bh, 5Ch, 5Dh, 5Eh, 60h
 69363                              <1> sizeInvFnChars  equ ($ - invalid_fname_chars)                
 69364                              <1> ;
 69365                              <1> 
 69366                              <1> Msg_Enter_Date:
 69367 00013183 456E746572206E6577- <1>                 db 'Enter new date (dd-mm-yy): '
 69368 0001318C 206461746520286464- <1>
 69369 00013195 2D6D6D2D7979293A20  <1>
 69370 0001319E 00                  <1>                 db 0
 69371                              <1> Msg_Show_Date:
 69372 0001319F 43757272656E742064- <1>                 db   'Current date is '
 69373 000131A8 61746520697320      <1>
 69374 000131AF 30                  <1> Day:            db   '0'
 69375 000131B0 30                  <1> 		db   '0'
 69376 000131B1 2F                  <1>                 db   '/'
 69377 000131B2 30                  <1> Month:          db   '0'
 69378 000131B3 30                  <1> 		db   '0'
 69379 000131B4 2F                  <1>                 db   '/'
 69380 000131B5 30                  <1> Century:        db   '0'
 69381 000131B6 30                  <1>                 db   '0'
 69382 000131B7 30                  <1> Year:           db   '0'
 69383 000131B8 30                  <1> 		db   '0'
 69384 000131B9 0D0A00              <1>                 db   0Dh, 0Ah, 0
 69385                              <1> 
 69386                              <1> Msg_Enter_Time:
 69387 000131BC 456E746572206E6577- <1> 		db 'Enter new time: '
 69388 000131C5 2074696D653A20      <1>
 69389 000131CC 00                  <1> 		db 0
 69390                              <1> Msg_Show_Time:
 69391 000131CD 43757272656E742074- <1> 		db   'Current time is '
 69392 000131D6 696D6520697320      <1>
 69393 000131DD 30                  <1> Hour:           db   '0'
 69394 000131DE 30                  <1> 		db   '0'
 69395 000131DF 3A                  <1> 		db   ':'
 69396 000131E0 30                  <1> Minute:         db   '0'
 69397 000131E1 30                  <1> 		db   '0'
 69398 000131E2 3A                  <1> 		db   ':'
 69399 000131E3 30                  <1> Second:         db   '0'
 69400 000131E4 30                  <1> 		db   '0'
 69401 000131E5 0D0A00              <1> 		db   0Dh, 0Ah, 0
 69402                              <1> 
 69403                              <1> ;VolSize_Unit1:   dd 0
 69404                              <1> ;VolSize_Unit2:   dd 0
 69405                              <1> 
 69406                              <1> VolSize_KiloBytes:
 69407 000131E8 206B696C6F62797465- <1> 		db " kilobytes", 0Dh, 0Ah, 0
 69408 000131F1 730D0A00            <1>
 69409                              <1> VolSize_Bytes:
 69410 000131F5 2062797465730D0A00  <1> 		db " bytes", 0Dh, 0Ah, 0
 69411                              <1> Volume_in_drive:
 69412 000131FE 0D0A                <1> 		db 0Dh, 0Ah
 69413                              <1> Vol_FS_Name:
 69414 00013200 54522046533120      <1> 		db "TR FS1 "
 69415 00013207 566F6C756D6520696E- <1> 		db "Volume in drive "
 69416 00013210 20647269766520      <1>
 69417 00013217 30                  <1> Vol_Drv_Name:   db 30h
 69418 00013218 3A                  <1> 		db ":"
 69419 00013219 20697320            <1> 		db " is "
 69420 0001321D 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69421                              <1> Dir_Drive_Str:
 69422 00013220 54522D444F53204472- <1>                 db "TR-DOS Drive "
 69423 00013229 69766520            <1>
 69424                              <1> Dir_Drive_Name:
 69425 0001322D 303A                <1>                 db "0:"
 69426 0001322F 0D0A                <1>                 db  0Dh, 0Ah
 69427                              <1> Vol_Str_Header:
 69428 00013231 566F6C756D65204E61- <1>                 db "Volume Name: "
 69429 0001323A 6D653A20            <1>
 69430                              <1> Vol_Name:
 69431 0001323E 00<rept>            <1> 		times 64 db 0
 69432 0001327E 00                  <1> 		db 0
 69433                              <1> Vol_Serial_Header:
 69434 0001327F 0D0A                <1> 		db 0Dh, 0Ah
 69435 00013281 566F6C756D65205365- <1> 		db "Volume Serial No: "
 69436 0001328A 7269616C204E6F3A20  <1>
 69437                              <1> Vol_Serial1:
 69438 00013293 30303030            <1> 		db "0000"
 69439 00013297 2D                  <1> 		db "-"
 69440                              <1> Vol_Serial2:
 69441 00013298 30303030            <1> 		db "0000"
 69442 0001329C 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69443                              <1> 
 69444                              <1> ;Vol_Tot_Sec_Str_Start:
 69445                              <1> ;		dd 0
 69446                              <1> Vol_Total_Sector_Header:
 69447 0001329F 0D0A                <1> 		db 0Dh, 0Ah
 69448 000132A1 566F6C756D65205369- <1> 		db "Volume Size : ", 0
 69449 000132AA 7A65203A2000        <1>
 69450                              <1> ;Vol_Tot_Sec_Str: 
 69451                              <1> ;		db "0000000000"
 69452                              <1> ;Vol_Tot_Sec_Str_End:
 69453                              <1> ;		db 0
 69454                              <1> ;Vol_Free_Sectors_Str_Start:
 69455                              <1> ;		dd 0
 69456                              <1> Vol_Free_Sectors_Header:
 69457 000132B0 467265652053706163- <1> 		db "Free Space  : ", 0
 69458 000132B9 6520203A2000        <1>
 69459                              <1> ;Vol_Free_Sectors_Str:
 69460                              <1> ;		db "0000000000"
 69461                              <1> ;Vol_Free_Sectors_Str_End:
 69462                              <1> ;		db 0
 69463                              <1> 
 69464                              <1> Dir_Str_Header:
 69465 000132BF 4469726563746F7279- <1>                 db "Directory: "
 69466 000132C8 3A20                <1>
 69467 000132CA 2F                  <1> Dir_Str_Root:   db "/"
 69468 000132CB 00<rept>            <1> Dir_Str:        times 64 db 0
 69469 0001330B 00000000            <1>                 dd 0
 69470 0001330F 00                  <1>                 db 0
 69471                              <1> 
 69472                              <1> Msg_Bad_Command:
 69473 00013310 42616420636F6D6D61- <1>                 db "Bad command or file name!"
 69474 00013319 6E64206F722066696C- <1>
 69475 00013322 65206E616D6521      <1>
 69476 00013329 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69477                              <1> 
 69478                              <1> msgl_drv_not_ready: 
 69479 0001332C 070D0A              <1> 		db 07h, 0Dh, 0Ah
 69480                              <1> 
 69481                              <1> ; CMD_INTR.ASM - 09/11/2011 - Messages
 69482                              <1> 
 69483                              <1> Msg_Not_Ready_Read_Err:
 69484 0001332F 4472697665206E6F74- <1>                 db "Drive not ready or read error!"
 69485 00013338 207265616479206F72- <1>
 69486 00013341 207265616420657272- <1>
 69487 0001334A 6F7221              <1>
 69488 0001334D 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69489                              <1> 
 69490                              <1> Msg_Not_Ready_Write_Err:
 69491 00013350 4472697665206E6F74- <1>                 db "Drive not ready or write error!"
 69492 00013359 207265616479206F72- <1>
 69493 00013362 207772697465206572- <1>
 69494 0001336B 726F7221            <1>
 69495 0001336F 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69496                              <1> 
 69497                              <1> Msg_Dir_Not_Found:
 69498 00013372 4469726563746F7279- <1>                 db "Directory not found!"
 69499 0001337B 206E6F7420666F756E- <1>
 69500 00013384 6421                <1>
 69501 00013386 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69502                              <1> 
 69503                              <1> Msg_File_Not_Found:
 69504 00013389 46696C65206E6F7420- <1>                 db "File not found!"
 69505 00013392 666F756E6421        <1>
 69506 00013398 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69507                              <1> 
 69508                              <1> Msg_File_Directory_Not_Found:
 69509 0001339B 46696C65206F722064- <1>                 db "File or directory not found!"
 69510 000133A4 69726563746F727920- <1>
 69511 000133AD 6E6F7420666F756E64- <1>
 69512 000133B6 21                  <1>
 69513 000133B7 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69514                              <1> 
 69515                              <1> Msg_LongName_Not_Found:
 69516 000133BA 4C6F6E67206E616D65- <1>                 db "Long name not found!"
 69517 000133C3 206E6F7420666F756E- <1>
 69518 000133CC 6421                <1>
 69519 000133CE 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69520                              <1> 
 69521                              <1> beep_Insufficient_Memory: ; 20/02/2017
 69522 000133D1 0D0A                <1> 		db 0Dh, 0Ah
 69523 000133D3 07                  <1> 		db 07h
 69524                              <1> Msg_Insufficient_Memory:
 69525 000133D4 496E73756666696369- <1>                 db "Insufficient memory!"
 69526 000133DD 656E74206D656D6F72- <1>
 69527 000133E6 7921                <1>
 69528 000133E8 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69529                              <1> 
 69530                              <1> Msg_Error_Code:
 69531 000133EB 436F6D6D616E642066- <1>                 db 'Command failed! Error code : '
 69532 000133F4 61696C656421204572- <1>
 69533 000133FD 726F7220636F646520- <1>
 69534 00013406 3A20                <1>
 69535 00013408 303068              <1> error_code_hex: db '00h'
 69536 0001340B 0A0A00              <1>                 db 0Ah, 0Ah, 0
 69537                              <1> 
 69538                              <1> align 2
 69539                              <1> 
 69540                              <1> ; 10/02/2016
 69541                              <1> ; DIR.ASM - 09/10/2011
 69542                              <1> 
 69543 0001340E 3C4449523E20202020- <1> Type_Dir:       db '<DIR>     ' ; 10 bytes
 69544 00013417 20                  <1>
 69545                              <1> 
 69546                              <1> File_Name:
 69547 00013418 20<rept>            <1>                 times 12 db 20h
 69548 00013424 20                  <1> 		db 20h
 69549                              <1> Dir_Or_FileSize:
 69550 00013425 20<rept>            <1>                 times 10 db 20h
 69551 0001342F 20                  <1> 		db 20h
 69552                              <1> File_Attribute:
 69553 00013430 20202020            <1> 		dd 20202020h
 69554 00013434 20                  <1> 		db 20h
 69555                              <1> File_Day:
 69556 00013435 3030                <1>                 db '0','0'
 69557 00013437 2F                  <1> 		db '/'
 69558                              <1> File_Month:
 69559 00013438 3030                <1>                 db '0','0'
 69560 0001343A 2F                  <1> 		db '/'
 69561                              <1> File_Year:
 69562 0001343B 30303030            <1>                 db '0','0','0','0'
 69563 0001343F 20                  <1> 		db 20h
 69564                              <1> File_Hour:
 69565 00013440 3030                <1>                 db '0','0'
 69566 00013442 3A                  <1> 		db ':'
 69567                              <1> File_Minute:
 69568 00013443 3030                <1>                 db '0','0'
 69569 00013445 00                  <1> 		db 0
 69570                              <1> 
 69571                              <1> Decimal_File_Count_Header:
 69572 00013446 0D0A                <1> 		db 0Dh, 0Ah
 69573                              <1> Decimal_File_Count:
 69574 00013448 00<rept>            <1> 		times 6 db 0
 69575                              <1> 
 69576 0001344E 2066696C6528732920- <1> str_files:	db " file(s) & "
 69577 00013457 2620                <1>
 69578                              <1> Decimal_Dir_Count: 
 69579 00013459 00<rept>            <1> 		times 6 db 0
 69580                              <1> str_dirs:       
 69581 0001345F 206469726563746F72- <1> 		db " directory(s) "
 69582 00013468 7928732920          <1>
 69583 0001346D 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69584                              <1> 
 69585 00013470 206279746528732920- <1> str_bytes:	db " byte(s) in file(s)"
 69586 00013479 696E2066696C652873- <1>
 69587 00013482 29                  <1>
 69588 00013483 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69589                              <1> 
 69590                              <1> ; CMD_INTR.ASM - 09/11/2011
 69591                              <1> ; 07/10/2010
 69592                              <1> Msg_invalid_name_chars:
 69593 00013486 496E76616C69642066- <1>                 db "Invalid file or directory name characters!"
 69594 0001348F 696C65206F72206469- <1>
 69595 00013498 726563746F7279206E- <1>
 69596 000134A1 616D65206368617261- <1>
 69597 000134AA 637465727321        <1>
 69598 000134B0 0D0A00              <1>         	db 0Dh, 0Ah, 0
 69599                              <1> ; 21/02/2016
 69600 000134B3 46696C65206F722064- <1> Msg_Name_Exists: db "File or directory name exists!"
 69601 000134BC 69726563746F727920- <1>
 69602 000134C5 6E616D652065786973- <1>
 69603 000134CE 747321              <1>
 69604 000134D1 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69605                              <1> Msg_DoYouWantMkdir:
 69606 000134D4 446F20796F75207761- <1>                 db "Do you want to make directory ", 0
 69607 000134DD 6E7420746F206D616B- <1>
 69608 000134E6 65206469726563746F- <1>
 69609 000134EF 72792000            <1>
 69610 000134F3 2028592F4E29203F20- <1> Msg_YesNo:      db " (Y/N) ? ", 0  
 69611 000134FC 00                  <1>
 69612 000134FD 000D0A00            <1> Y_N_nextline:	db 0, 0Dh, 0Ah, 0 
 69613 00013501 4F4B2E0D0A00        <1> Msg_OK:		db "OK.", 0Dh, 0Ah, 0
 69614                              <1> 
 69615                              <1> ; 27/02/2016
 69616                              <1> Msg_DoYouWantRmDir:
 69617 00013507 446F20796F75207761- <1>                 db "Do you want to delete directory ", 0
 69618 00013510 6E7420746F2064656C- <1>
 69619 00013519 657465206469726563- <1>
 69620 00013522 746F72792000        <1>
 69621                              <1> Msg_Dir_Not_Empty:
 69622 00013528 4469726563746F7279- <1>                 db "Directory not empty!"
 69623 00013531 206E6F7420656D7074- <1>
 69624 0001353A 7921                <1>
 69625 0001353C 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69626                              <1> 
 69627                              <1> Msg_DoYouWantDelete:
 69628 0001353F 446F20796F75207761- <1>                 db "Do you want to delete file ",0
 69629 00013548 6E7420746F2064656C- <1>
 69630 00013551 6574652066696C6520- <1>
 69631 0001355A 00                  <1>
 69632                              <1> 
 69633 0001355B 44656C657465642E2E- <1> Msg_Deleted:    db "Deleted...", 0Dh, 0Ah, 0
 69634 00013564 2E0D0A00            <1>
 69635                              <1> 
 69636                              <1> Msg_Permission_Denied:
 69637 00013568 07                  <1>                 db 7
 69638 00013569 5065726D697373696F- <1>                 db "Permission denied!", 0Dh, 0Ah, 0
 69639 00013572 6E2064656E69656421- <1>
 69640 0001357B 0D0A00              <1>
 69641                              <1> 
 69642                              <1> ; 04/03/2016
 69643 0001357E 4E657720            <1> Msg_New:        db "New "
 69644 00013582 00                  <1>                 db 0
 69645                              <1> Str_Attributes:
 69646 00013583 417474726962757465- <1>                 db "Attributes : "
 69647 0001358C 73203A20            <1>
 69648 00013590 4E4F524D414C        <1> Attr_Chars:     db "NORMAL"
 69649 00013596 00                  <1>                 db 0
 69650                              <1> 
 69651                              <1> ; 06/03/2016
 69652                              <1> ; CMD_INTR.ASM - 16/11/2010 
 69653                              <1> Msg_DoYouWantRename:
 69654 00013597 446F20796F75207761- <1>                 db "Do you want to rename ", 0
 69655 000135A0 6E7420746F2072656E- <1>
 69656 000135A9 616D652000          <1>
 69657 000135AE 66696C652000        <1> Rename_File:    db "file ", 0
 69658 000135B4 6469726563746F7279- <1> Rename_Directory: db "directory ", 0
 69659 000135BD 2000                <1>
 69660 000135BF 00<rept>            <1> Rename_OldName: times 13 db 0
 69661 000135CC 20617320            <1> Msg_File_rename_as: db " as "
 69662 000135D0 00<rept>            <1> Rename_NewName: times 13 db 0
 69663                              <1> 
 69664                              <1> ; 08/03/2016
 69665                              <1> ; CMD_INTR.ASM - 01/08/2010 - 23/04/2011
 69666                              <1> msg_not_same_drv:
 69667 000135DD 4E6F742073616D6520- <1>                 db "Not same drive!" 
 69668 000135E6 647269766521        <1>
 69669 000135EC 0D0A00              <1>                 db 0Dh, 0Ah, 0 
 69670                              <1> 
 69671                              <1> Msg_DoYouWantMoveFile:
 69672 000135EF 446F20796F75207761- <1>                 db "Do you want to move file", 0
 69673 000135F8 6E7420746F206D6F76- <1>
 69674 00013601 652066696C6500      <1>
 69675                              <1> 
 69676                              <1> msg_insufficient_disk_space:
 69677 00013608 496E73756666696369- <1>                 db "Insufficient disk space!" 
 69678 00013611 656E74206469736B20- <1>
 69679 0001361A 737061636521        <1>
 69680 00013620 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69681                              <1> 
 69682                              <1> ; 01/08/2010
 69683                              <1> msg_source_file: 
 69684 00013623 0D0A536F7572636520- <1> 		db 0Dh, 0Ah, "Source file name      :   "
 69685 0001362C 66696C65206E616D65- <1>
 69686 00013635 2020202020203A2020- <1>
 69687 0001363E 20                  <1>
 69688                              <1> msg_source_file_drv: 
 69689 0001363F 203A00              <1> 		db " :", 0
 69690                              <1> msg_destination_file: 
 69691 00013642 0D0A44657374696E61- <1> 		db 0Dh, 0Ah, "Destination file name :   "
 69692 0001364B 74696F6E2066696C65- <1>
 69693 00013654 206E616D65203A2020- <1>
 69694 0001365D 20                  <1>
 69695                              <1> msg_destination_file_drv: 
 69696 0001365E 203A00              <1> 		db " :", 0
 69697                              <1> msg_copy_nextline: 
 69698 00013661 0D0A00              <1> 		db 0Dh, 0Ah, 0
 69699                              <1> 
 69700                              <1> ; 15/03/2016
 69701                              <1> ; CMD_INTR.ASM
 69702                              <1> 
 69703                              <1> Msg_DoYouWantOverWriteFile:
 69704 00013664 446F20796F75207761- <1>                 db "Do you want to overwrite file ",0
 69705 0001366D 6E7420746F206F7665- <1>
 69706 00013676 727772697465206669- <1>
 69707 0001367F 6C652000            <1>
 69708                              <1>   
 69709                              <1> Msg_DoYouWantCopyFile:
 69710 00013683 446F20796F75207761- <1>                 db "Do you want to copy file",0
 69711 0001368C 6E7420746F20636F70- <1>
 69712 00013695 792066696C6500      <1>
 69713                              <1> 
 69714                              <1> Msg_read_file_error_before_EOF:
 69715 0001369C 46696C652072656164- <1> 		db "File reading error! (before EOF)"
 69716 000136A5 696E67206572726F72- <1>
 69717 000136AE 2120286265666F7265- <1>
 69718 000136B7 20454F4629          <1>
 69719 000136BC 0A0A00              <1> 		db 0Ah, 0Ah, 0
 69720                              <1> 
 69721                              <1> ; 18/03/2016
 69722                              <1> ; TRDOS 386 (v2.0) mainprog copy procedure
 69723                              <1> msg_reading:
 69724 000136BF 52656164696E672E2E- <1> 		db "Reading... ", 0
 69725 000136C8 2E2000              <1>
 69726                              <1> msg_writing:
 69727 000136CB 57726974696E672E2E- <1> 		db "Writing... ", 0
 69728 000136D4 2E2000              <1>
 69729                              <1> percentagestr:
 69730 000136D7 2020202500          <1> 		db "   %", 0  ; "  0%" .. "100%"
 69731                              <1> ; 11/04/2016
 69732                              <1> Msg_No_Set_Space:
 69733 000136DC 496E73756666696369- <1>                 db "Insufficient environment space!"
 69734 000136E5 656E7420656E766972- <1>
 69735 000136EE 6F6E6D656E74207370- <1>
 69736 000136F7 61636521            <1>
 69737 000136FB 0D0A00              <1>                 db 0Dh, 0Ah, 0
 69738                              <1> ; 18/04/2016
 69739                              <1> isc_msg:	
 69740 000136FE 0D0A                <1> 		db 0Dh, 0Ah
 69741 00013700 494E56414C49442053- <1> 		db "INVALID SYSTEM CALL", 0
 69742 00013709 595354454D2043414C- <1>
 69743 00013712 4C00                <1>
 69744                              <1> usi_msg:
 69745 00013714 0D0A                <1> 		db 0Dh, 0Ah
 69746 00013716 554E444546494E4544- <1> 		db "UNDEFINED SOFTWARE INTERRUPT", 0
 69747 0001371F 20534F465457415245- <1>
 69748 00013728 20494E544552525550- <1>
 69749 00013731 5400                <1>
 69750                              <1> ifc_msg:
 69751 00013733 0D0A                <1> 		db 0Dh, 0Ah
 69752 00013735 494E56414C49442046- <1> 		db "INVALID FUNCTION CALL"
 69753 0001373E 554E4354494F4E2043- <1>
 69754 00013747 414C4C              <1>
 69755                              <1> inv_msg_for_trdos_v2:
 69756 0001374A 20                  <1> 		db 20h
 69757 0001374B 666F72205452444F53- <1> 		db "for TRDOS v2!"
 69758 00013754 20763221            <1>
 69759 00013758 07                  <1> 		db 07h
 69760 00013759 0D0A                <1> 		db 0Dh, 0Ah
 69761 0001375B 0D0A                <1> 		db 0Dh, 0Ah
 69762 0001375D 494E5420            <1> 		db "INT "
 69763 00013761 303068              <1> int_num_str:	db "00h"
 69764 00013764 0D0A                <1> 		db 0Dh, 0Ah
 69765 00013766 454158203A20        <1> 		db "EAX : "
 69766 0001376C 303030303030303068- <1> eax_str:	db "00000000h", 0Dh, 0Ah
 69767 00013775 0D0A                <1>
 69768 00013777 454950203A20        <1> 		db "EIP : "
 69769 0001377D 303030303030303068- <1> eip_str:	db "00000000h", 0Dh, 0Ah, 0
 69770 00013786 0D0A00              <1>
 69771                              <1> 
 69772                              <1> ; 17/04/2021
 69773                              <1> ; ('KDEV' device parameters are disabled as temporary)
 69774                              <1> 
 69775                              <1> ; 07/10/2016
 69776                              <1> ; Device names & parameters (for kernel devices)
 69777                              <1> 
 69778 00013789 90                  <1> align 2
 69779                              <1> ;KDEV_NAME:
 69780                              <1> ;		db 'TTY',0,0,0,0,0 ; 1
 69781                              <1> ;		db 'MEM',0,0,0,0,0 ; 2
 69782                              <1> ;		db 'FD0',0,0,0,0,0 ; 3
 69783                              <1> ;		db 'FD1',0,0,0,0,0 ; 4
 69784                              <1> ;		db 'HD0',0,0,0,0,0 ; 5
 69785                              <1> ;		db 'HD1',0,0,0,0,0 ; 6
 69786                              <1> ;		db 'HD2',0,0,0,0,0 ; 7
 69787                              <1> ;		db 'HD3',0,0,0,0,0 ; 8
 69788                              <1> ;		db 'LPT',0,0,0,0,0 ; 9
 69789                              <1> ;		db 'TTY0',0,0,0,0 ; 10
 69790                              <1> ;		db 'TTY1',0,0,0,0 ; 11
 69791                              <1> ;		db 'TTY2',0,0,0,0 ; 12
 69792                              <1> ;		db 'TTY3',0,0,0,0 ; 13
 69793                              <1> ;		db 'TTY4',0,0,0,0 ; 14
 69794                              <1> ;		db 'TTY5',0,0,0,0 ; 15
 69795                              <1> ;		db 'TTY6',0,0,0,0 ; 16
 69796                              <1> ;		db 'TTY7',0,0,0,0 ; 17
 69797                              <1> ;		db 'TTY8',0,0,0,0 ; 18
 69798                              <1> ;		db 'TTY9',0,0,0,0 ; 19
 69799                              <1> ;		db 'COM1',0,0,0,0 ; 18
 69800                              <1> ;		db 'COM2',0,0,0,0 ; 19
 69801                              <1> ;		;db 'CONSOLE',0	  ; 1
 69802                              <1> ;		;db 'PRINTER',0   ; 9
 69803                              <1> ;		;db 'CDROM'	  ; 20
 69804                              <1> ;		;db 'CDROM0'	  ; 20
 69805                              <1> ;		;db 'CDROM1'	  ; 21		
 69806                              <1> ;		;db 'DVD'	  ; 22
 69807                              <1> ;		;db 'DVD0'	  ; 22
 69808                              <1> ;		;db 'DVD1'	  ; 23		
 69809                              <1> ;		;db 'USB'	  ; 24
 69810                              <1> ;		;db 'USB0'	  ; 24
 69811                              <1> ;		;db 'USB1'	  ; 25
 69812                              <1> ;		;db 'USB2'	  ; 26
 69813                              <1> ;		;db 'USB3'        ; 27
 69814                              <1> ;		;db 'KEYBOARD'	  ; 1	
 69815                              <1> ;		;db 'MOUSE'	  ; 28
 69816                              <1> ;		;db 'SOUND'	  ; 29
 69817                              <1> ;		;db 'VGA',0,0,0,0 ; 30
 69818                              <1> ;		;db 'CGA',0,0,0,0 ; 31
 69819                              <1> ;		;db 'AUDIO',0,0,0 ; 29
 69820                              <1> ;		;db 'VIDEO',0,0,0 ; 32
 69821                              <1> ;		;db 'MUSIC',0,0,0 ; 33
 69822                              <1> ;		;db 'ETHERNET'	  ; 34 		
 69823                              <1> ;		;db 'SD0',0,0,0,0,0 ; 35
 69824                              <1> ;		;db 'SD1',0,0,0,0,0 ; 36
 69825                              <1> ;		;db 'SD2',0,0,0,0,0 ; 37
 69826                              <1> ;		;db 'SD3',0,0,0,0,0 ; 38
 69827                              <1> ;		;db 'SATA0'	  ; 35
 69828                              <1> ;		;db 'SATA1'	  ; 36
 69829                              <1> ;		;db 'SATA2'        ; 37
 69830                              <1> ;		;db 'SATA3'        ; 38
 69831                              <1> ;		;db 'PATA0',0,0,0  ; 5
 69832                              <1> ;		;db 'PATA1',0,0,0  ; 6
 69833                              <1> ;		;db 'PATA2',0,0,0  ; 7
 69834                              <1> ;		;db 'PATA3',0,0,0  ; 8
 69835                              <1> ;		;db 'WIRELESS'	  ; 39
 69836                              <1> ;		;db 'HDMI',0,0,0,0 ; 40
 69837                              <1> ;		db 'NULL',0,0,0,0 ; 0
 69838                              <1> 
 69839                              <1> ;NumOfKernelDevNames equ ($-KDEV_NAME) / 8 ; 20 (07/10/2016)
 69840                              <1> 
 69841                              <1> ;KDEV_NUMBER:
 69842                              <1> ;		db 1,2,3,4,5,6,7,8,9
 69843                              <1> ;		db 10,11,12,13,14,15,16,17,18,19
 69844                              <1> ;		db 18,19,0
 69845                              <1> 
 69846                              <1> ;NumOfKernelDevices equ $ - KDEV_NUMBER
 69847                              <1> 
 69848                              <1> ;KDEV_OADDR:
 69849                              <1> ;		dd otty ;tty  ; 1
 69850                              <1> ;		dd sret ;mem  ; 2
 69851                              <1> ; 		dd sret ;fd0  ; 3
 69852                              <1> ; 		dd sret ;fd1  ; 4
 69853                              <1> ;		dd sret ;hd0  ; 5
 69854                              <1> ;		dd sret ;hd1  ; 6
 69855                              <1> ;		dd sret ;hd2  ; 7
 69856                              <1> ;		dd sret ;hd3  ; 8
 69857                              <1> ;		dd sret ;lpt  ; 9
 69858                              <1> ;		dd ocvt ;tty0 ; 10
 69859                              <1> ;		dd ocvt ;tty1 ; 11
 69860                              <1> ;		dd ocvt ;tty2 ; 12
 69861                              <1> ;		dd ocvt ;tty3 ; 13
 69862                              <1> ;		dd ocvt ;tty4 ; 14
 69863                              <1> ;		dd ocvt ;tty5 ; 15
 69864                              <1> ;		dd ocvt ;tty6 ; 16
 69865                              <1> ;		dd ocvt ;tty7 ; 17
 69866                              <1> ;		dd ocvt ;tty8 ; 18
 69867                              <1> ;		dd ocvt ;tty9 ; 19
 69868                              <1> ;		;dd ocvt ;com1 ; 18
 69869                              <1> ;		;dd ocvt ;com2 ; 19
 69870                              <1> ;		dd sret ;null ; 20  
 69871                              <1> ;KDEV_CADDR:
 69872                              <1> ;		dd ctty ;tty  ; 1
 69873                              <1> ;		dd cret ;mem  ; 2
 69874                              <1> ; 		dd cret ;fd0  ; 3
 69875                              <1> ; 		dd cret ;fd1  ; 4
 69876                              <1> ;		dd cret ;hd0  ; 5
 69877                              <1> ;		dd cret ;hd1  ; 6
 69878                              <1> ; 		dd cret ;hd2  ; 7
 69879                              <1> ;		dd cret ;hd3  ; 8
 69880                              <1> ; 		dd cret ;lpt  ; 9
 69881                              <1> ;		dd ocvt ;tty0 ; 10
 69882                              <1> ;		dd ccvt ;tty1 ; 11
 69883                              <1> ;		dd ccvt ;tty2 ; 12
 69884                              <1> ; 		dd ccvt ;tty3 ; 13
 69885                              <1> ; 		dd ccvt ;tty4 ; 14
 69886                              <1> ; 		dd ccvt ;tty5 ; 15
 69887                              <1> ; 		dd ccvt ;tty6 ; 16
 69888                              <1> ; 		dd ccvt ;tty7 ; 17
 69889                              <1> ; 		dd ccvt ;tty8 ; 18
 69890                              <1> ; 		dd ccvt ;tty9 ; 19
 69891                              <1> ; 		;dd ccvt ;com1 ; 18
 69892                              <1> ; 		;dd ccvt ;com2 ; 19
 69893                              <1> ;		dd cret ;null ; 20
 69894                              <1> ;
 69895                              <1> ;KDEV_RADDR:
 69896                              <1> ;		dd rtty ;tty  ; 1
 69897                              <1> ;		dd rmem ;mem  ; 2
 69898                              <1> ;		dd rfd  ;fd0  ; 3
 69899                              <1> ; 		dd rfd  ;fd1  ; 4
 69900                              <1> ; 		dd rhd  ;hd0  ; 5
 69901                              <1> ; 		dd rhd  ;hd1  ; 6
 69902                              <1> ; 		dd rhd  ;hd2  ; 7
 69903                              <1> ; 		dd rhd  ;hd3  ; 8
 69904                              <1> ; 		dd rlpt ;lpt  ; 9
 69905                              <1> ; 		dd rcvt ;tty0 ; 10
 69906                              <1> ;		dd rcvt ;tty1 ; 11
 69907                              <1> ; 		dd rcvt ;tty2 ; 12
 69908                              <1> ; 		dd rcvt ;tty3 ; 13
 69909                              <1> ; 		dd rcvt ;tty4 ; 14
 69910                              <1> ; 		dd rcvt ;tty5 ; 15
 69911                              <1> ; 		dd rcvt ;tty6 ; 16
 69912                              <1> ; 		dd rcvt ;tty7 ; 17
 69913                              <1> ; 		dd rcvt ;tty8 ; 18
 69914                              <1> ; 		dd rcvt ;tty9 ; 19
 69915                              <1> ; 		;dd rcvt ;com1 ; 18
 69916                              <1> ; 		;dd rcvt ;com2 ; 19
 69917                              <1> ;		dd rnull ;null ; 20  
 69918                              <1> ;KDEV_WADDR:
 69919                              <1> ;		dd wtty ;tty  ; 1
 69920                              <1> ;		dd wmem ;mem  ; 2
 69921                              <1> ;		dd wfd  ;fd0  ; 3
 69922                              <1> ; 		dd wfd  ;fd1  ; 4
 69923                              <1> ; 		dd whd  ;hd0  ; 5
 69924                              <1> ; 		dd whd  ;hd1  ; 6
 69925                              <1> ; 		dd whd  ;hd2  ; 7
 69926                              <1> ; 		dd whd  ;hd3  ; 8
 69927                              <1> ; 		dd wlpt ;lpt  ; 9
 69928                              <1> ; 		dd xmtt ;tty0 ; 10
 69929                              <1> ;		dd xmtt ;tty1 ; 11
 69930                              <1> ; 		dd xmtt ;tty2 ; 12
 69931                              <1> ; 		dd xmtt ;tty3 ; 13
 69932                              <1> ; 		dd xmtt ;tty4 ; 14
 69933                              <1> ; 		dd xmtt ;tty5 ; 15
 69934                              <1> ; 		dd xmtt ;tty6 ; 16
 69935                              <1> ; 		dd xmtt ;tty7 ; 17
 69936                              <1> ; 		dd xmtt ;tty8 ; 18
 69937                              <1> ; 		dd xmtt ;tty9 ; 19
 69938                              <1> ; 		;dd xmtt ;com1 ; 18
 69939                              <1> ; 		;dd xmtt ;com2 ; 19
 69940                              <1> ;		dd wnull ;null ; 20  
 69941                              <1> 
 69942                              <1> ; DEV_ACCESS bits:
 69943                              <1> 	; bit 0 = accessable by normal users
 69944                              <1> 	; bit 1 = read access permission
 69945                              <1> 	; bit 2 = write access permission
 69946                              <1> 	; bit 3 = IOCTL permission to users
 69947                              <1> 	; bit 4 = block device if it is set
 69948                              <1> 	; bit 5 = 16 bit or 1024 byte data
 69949                              <1> 	; bit 6 = 32 bit or 2048 byte data
 69950                              <1> 	; bit 7 = installable device driver	
 69951                              <1> 
 69952                              <1> ;KDEV_ACCESS: ; 08/10/2016
 69953                              <1> ;		db  00000111b	; tty, 1
 69954                              <1> ;		db  00000111b	; mem, 2	
 69955                              <1> ;		db  10001111b	; fd0, 3	
 69956                              <1> ;		db  10001111b	; fd1, 4
 69957                              <1> ;		db  10001111b	; hd0, 5
 69958                              <1> ;		db  10001111b	; hd1, 6
 69959                              <1> ;		db  10001111b	; hd2, 7
 69960                              <1> ;		db  10001111b	; hd3, 8
 69961                              <1> ;		db  00000111b   ; lpt, 9
 69962                              <1> ;		db  00000111b	; tty0, 10
 69963                              <1> ;		db  00000111b	; tty1, 11
 69964                              <1> ;		db  00000111b	; tty2, 12
 69965                              <1> ;		db  00000111b	; tty3, 13
 69966                              <1> ;		db  00000111b	; tty4, 14
 69967                              <1> ;		db  00000111b	; tty5, 15
 69968                              <1> ;		db  00000111b	; tty6, 16
 69969                              <1> ;		db  00000111b	; tty7, 17
 69970                              <1> ;		db  00000111b	; tty8, 18
 69971                              <1> ;		db  00000111b	; tty9, 19
 69972                              <1> ;		;db 00000111b	; com1, 18
 69973                              <1> ;		;db 00000111b	; com2, 19
 69974                              <1> ;		db  00000000b   ; null, 0
 69975                              <1> 
 69976                              <1> ; 07/10/2016
 69977                              <1> ;NumOfInstallableDevices equ 8
 69978                              <1> ;NUMIDEV	equ NumOfInstallableDevices ; 8
 69979                              <1> ;NUMOFDEVICES	equ NumOfKernelDevices + NumOfInstallableDevices
 69980                              <1> 
 69981                              <1> ; 26/02/2017
 69982                              <1> ; IRQ Callback (& Signal Response Byte) service availibity
 69983                              <1> ; 'syscalbac'
 69984                              <1> ; ***************************************************
 69985                              <1> ; IRQ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
 69986                              <1> ; --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 69987                              <1> ; --- 00 00 00 01 02 03 00 04 00 05 06 07 08 09 00 00
 69988                              <1> ; ***************************************************
 69989                              <1> IRQenum:
 69990 0001378A 000000010203000400- <1> 	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
 69991 00013793 05060708090000      <1>
 69992                              <1> 
 69993                              <1> ; 28/08/2017
 69994                              <1> ; 20/08/2017
 69995                              <1> ; DMA Registers (for 'sysdma')
 69996                              <1> ; 02/07/2017 (sb16mod.s)
 69997 0001379A 00020406C0C4C8CC    <1> dma_adr:	db 0,2,4,6,0C0h,0C4h,0C8h,0CCh
 69998 000137A2 01030507C2C6CACE    <1> dma_cnt:	db 1,3,5,7,0C2h,0C6h,0CAh,0CEh
 69999 000137AA 878381828F8B898A    <1> dma_page:	db 87h,83h,81h,82h,8Fh,8Bh,89h,8Ah ; 03/08/2017
 70000 000137B2 0A0A0A0AD4D4D4D4    <1> dma_mask:	db 0Ah,0Ah,0Ah,0Ah,0D4h,0D4h,0D4h,0D4h
 70001 000137BA 0B0B0B0BD6D6D6D6    <1> dma_mod:	db 0Bh,0Bh,0Bh,0Bh,0D6h,0D6h,0D6h,0D6h
 70002 000137C2 0C0C0C0CD8D8D8D8    <1> dma_flip:	db 0Ch,0Ch,0Ch,0Ch,0D8h,0D8h,0D8h,0D8h	
 70003                                  
 70004                                  ; 27/08/2014
 70005                                  scr_row:
 70006 000137CA E0810B00                	dd 0B8000h + 0A0h + 0A0h + 0A0h ; Row 3
 70007                                  scr_col:
 70008 000137CE 00000000                	dd 0
 70009                                  
 70010 000137D2 90<rept>                Align 4
 70011                                  	; 15/04/2016
 70012                                  	; TRDOS 386 (TRDOS v2.0)
 70013                                  
 70014                                  	; 21/08/2014
 70015                                  ilist:
 70016                                  	;times 	32 dd cpu_except ; INT 0 to INT 1Fh
 70017                                  	;
 70018                                  	; Exception list
 70019                                  	; 25/08/2014	
 70020 000137D4 [CE0B0000]              	dd	exc0	; 0h,  Divide-by-zero Error
 70021 000137D8 [D50B0000]              	dd	exc1	
 70022 000137DC [DC0B0000]              	dd 	exc2	
 70023 000137E0 [E30B0000]              	dd	exc3	
 70024 000137E4 [E70B0000]              	dd	exc4	
 70025 000137E8 [EB0B0000]              	dd	exc5	
 70026 000137EC [EF0B0000]              	dd 	exc6	; 06h,  Invalid Opcode
 70027 000137F0 [F30B0000]              	dd	exc7	
 70028 000137F4 [F70B0000]              	dd	exc8	
 70029 000137F8 [FB0B0000]              	dd	exc9	
 70030 000137FC [FF0B0000]              	dd 	exc10	
 70031 00013800 [030C0000]              	dd	exc11
 70032 00013804 [070C0000]              	dd	exc12
 70033 00013808 [0B0C0000]              	dd	exc13	; 0Dh, General Protection Fault
 70034 0001380C [0F0C0000]              	dd 	exc14	; 0Eh, Page Fault
 70035 00013810 [130C0000]              	dd	exc15
 70036 00013814 [170C0000]              	dd	exc16
 70037 00013818 [1B0C0000]              	dd	exc17
 70038 0001381C [1F0C0000]              	dd 	exc18
 70039 00013820 [230C0000]              	dd	exc19
 70040 00013824 [270C0000]              	dd 	exc20
 70041 00013828 [2B0C0000]              	dd	exc21
 70042 0001382C [2F0C0000]              	dd	exc22
 70043 00013830 [330C0000]              	dd	exc23
 70044 00013834 [370C0000]              	dd 	exc24
 70045 00013838 [3B0C0000]              	dd	exc25
 70046 0001383C [3F0C0000]              	dd	exc26
 70047 00013840 [430C0000]              	dd	exc27
 70048 00013844 [470C0000]              	dd 	exc28
 70049 00013848 [4B0C0000]              	dd	exc29
 70050 0001384C [4F0C0000]              	dd 	exc30
 70051 00013850 [530C0000]              	dd	exc31
 70052                                  IRQ_list: ; 28/02/2017 ('syscalbac')
 70053                                  	; Interrupt list
 70054 00013854 [41090000]              	dd	timer_int	; INT 20h
 70055                                  		;dd irq0	
 70056 00013858 [9F100000]              	dd	kb_int		; 24/01/2016
 70057                                  		;dd irq1
 70058 0001385C [240B0000]              	dd	irq2
 70059                                  		; COM2 int
 70060 00013860 [280B0000]              	dd	irq3
 70061                                  		; COM1 int
 70062 00013864 [330B0000]              	dd	irq4
 70063 00013868 [3E0B0000]              	dd	irq5
 70064                                  ;DISKETTE_INT: ;06/02/2015
 70065 0001386C [D24D0000]              	dd	fdc_int		; 16/02/2015, IRQ 6 handler	
 70066                                  		;dd irq6
 70067                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
 70068                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
 70069 00013870 [AC0E0000]              	dd	default_irq7	; 25/02/2015
 70070                                  		;dd irq7
 70071                                  ; Real Time Clock Interrupt
 70072 00013874 [AC0A0000]              	dd	rtc_int		; 23/02/2015, IRQ 8 handler
 70073                                  		;dd irq8	; INT 28h
 70074 00013878 [4E0B0000]              	dd	irq9
 70075 0001387C [520B0000]              	dd	irq10
 70076 00013880 [560B0000]              	dd	irq11
 70077 00013884 [5A0B0000]              	dd	irq12
 70078 00013888 [5E0B0000]              	dd	irq13
 70079                                  ;HDISK_INT1:  ;06/02/2015 	
 70080 0001388C [54560000]              	dd	hdc1_int 	; 21/02/2015, IRQ 14 handler		
 70081                                  		;dd irq14
 70082                                  ;HDISK_INT2:  ;06/02/2015
 70083 00013890 [77560000]              	dd	hdc2_int 	; 21/02/2015, IRQ 15 handler		
 70084                                  		;dd irq15	; INT 2Fh
 70085                                  		; 14/08/2015
 70086                                  	;dd	sysent		; INT 30h (system calls)
 70087                                  
 70088                                  	; 15/04/2016
 70089                                  	; TRDOS 386(TRDOS v2.0) Software Interrupts
 70090                                  
 70091 00013894 [F1380100]              	dd	int30h		; Reserved for
 70092                                  				; !!! Retro UNIX (RUNIX) !!!
 70093                                  				; !!! SINGLIX !!! System Calls
 70094 00013898 [2E170000]              	dd	int31h		; Video BIOS (IBM PC/AT, Int 10h)
 70095 0001389C [FB0E0000]              	dd	int32h		; Keyboard Functions (IBM PC/AT, Int 16h)
 70096 000138A0 [744E0000]              	dd	int33h		; DISK I/O (IBM PC/AT, Int 13h)
 70097 000138A4 [BA1E0100]              	dd	int34h		; #IOCTL# (I/O port access support for ring 3)
 70098 000138A8 [61610000]              	dd	int35h		; Time/Date Functions (IBM PC/AT, Int 1Ah)
 70099 000138AC [600D0000]              	dd	ignore_int	; INT 36h : Timer Functions	
 70100 000138B0 [600D0000]              	dd	ignore_int	; INT 37h	
 70101 000138B4 [600D0000]              	dd	ignore_int	; INT 38h
 70102 000138B8 [600D0000]              	dd	ignore_int	; INT 39h
 70103 000138BC [600D0000]              	dd	ignore_int	; INT 3Ah	
 70104 000138C0 [600D0000]              	dd	ignore_int	; INT 3Bh
 70105 000138C4 [600D0000]              	dd	ignore_int	; INT 3Ch
 70106 000138C8 [600D0000]              	dd	ignore_int	; INT 3Dh	
 70107 000138CC [600D0000]              	dd	ignore_int	; INT 3Eh
 70108 000138D0 [600D0000]              	dd	ignore_int	; INT 3Fh
 70109 000138D4 [3ECB0000]              	dd	sysent		; INT 40h : !!! TRDOS 386 System Calls !!!
 70110                                  	;dd	ignore_int
 70111 000138D8 00000000                	dd	0
 70112                                  
 70113                                  ; 20/08/2014
 70114                                    ; /* This is the default interrupt "handler" :-) */ 
 70115                                    ; Linux v0.12 (head.s)
 70116                                  int_msg:
 70117 000138DC 556E6B6E6F776E2069-     	db "Unknown interrupt ! ", 0
 70118 000138E5 6E7465727275707420-
 70119 000138EE 212000             
 70120                                  
 70121                                  ; 15/04/2016
 70122                                  ; TRDOS 386 (TRDOS v2.0)
 70123                                  
 70124                                  ; 29/04/2016
 70125                                  int30h:
 70126                                  trdos_isc_routine:
 70127                                  	; 02/05/2016
 70128                                  	; 01/05/2016
 70129                                  	; 29/04/2016
 70130                                  	; 18/04/2016
 70131                                  	; 15/04/2016 (TRDOS 386 = TRDOS v2.0)
 70132                                  	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
 70133                                  	; 03/02/2011 ('trdos_ifc_routine')
 70134                                  	;
 70135 000138F1 8B1C24                  	mov	ebx, [esp] ; EIP (next)
 70136 000138F4 83EB02                  	sub	ebx, 2 ; EIP (CD ##h)
 70137                                  
 70138 000138F7 89C1                    	mov	ecx, eax
 70139 000138F9 8A4301                  	mov	al, [ebx+1] ; CDh ##h
 70140                                  
 70141 000138FC 66BA1000                	mov	dx, KDATA
 70142 00013900 8EDA                    	mov	ds, dx
 70143 00013902 8EC2                    	mov	es, dx
 70144                                  
 70145 00013904 FC                      	cld
 70146 00013905 8B15[80770100]          	mov	edx, [k_page_dir]
 70147 0001390B 0F22DA                  	mov	cr3, edx
 70148                                  
 70149 0001390E E8E607FFFF              	call	bytetohex
 70150 00013913 66A3[61370100]          	mov	[int_num_str], ax
 70151                                  
 70152 00013919 89D8                    	mov	eax, ebx ; EIP
 70153 0001391B E81908FFFF              	call	dwordtohex
 70154 00013920 8915[7D370100]          	mov	[eip_str], edx
 70155 00013926 A3[81370100]            	mov	[eip_str+4], eax
 70156                                  
 70157 0001392B 89C8                    	mov	eax, ecx
 70158 0001392D E80708FFFF              	call	dwordtohex
 70159 00013932 8915[6C370100]          	mov	[eax_str], edx
 70160 00013938 A3[70370100]            	mov	[eax_str+4], eax 	
 70161                                  
 70162 0001393D 43                      	inc	ebx
 70163 0001393E 8A03                    	mov	al, [ebx] ; Interrupt number
 70164                                  
 70165                                  trdos_isc_handler:
 70166 00013940 80FE30                  	cmp	dh, 30h ; Retro UNIX, SINGLIX System calls
 70167 00013943 7507                    	jne	short trdos_usi_handler
 70168 00013945 BE[FE360100]            	mov	esi, isc_msg
 70169 0001394A EB05                    	jmp	short loc_write_inv_system_call_msg
 70170                                  
 70171                                  trdos_usi_handler:
 70172 0001394C BE[14370100]            	mov	esi, usi_msg
 70173                                  
 70174                                  loc_write_inv_system_call_msg:
 70175 00013951 E8D432FFFF              	call	print_msg
 70176                                  	; 29/04/2016
 70177 00013956 BE[4A370100]            	mov	esi, inv_msg_for_trdos_v2
 70178 0001395B E8CA32FFFF              	call	print_msg
 70179                                  
 70180                                  loc_ifc_terminate_process:
 70181                                  	; u.uno = process number
 70182                                  	; 29/04/2016
 70183                                  
 70184                                  	; 02/05/2016
 70185 00013960 FE05[10010300]          	inc	byte [sysflg] ; 0FFh -> 0
 70186                                  
 70187 00013966 B801000000              	mov	eax, 1
 70188 0001396B E9BF94FFFF              	jmp	sysexit
 70189                                  
 70190                                  ; 07/03/2015
 70191                                  ; Temporary Code
 70192                                  display_disks:
 70193 00013970 803D[FC640000]00        	cmp 	byte [fd0_type], 0
 70194 00013977 7605                    	jna 	short ddsks1
 70195 00013979 E87D000000              	call	pdskm
 70196                                  ddsks1:
 70197 0001397E 803D[FD640000]00        	cmp	byte [fd1_type], 0
 70198 00013985 760C                    	jna	short ddsks2
 70199 00013987 C605[CB3A0100]31        	mov	byte [dskx], '1'
 70200 0001398E E868000000              	call	pdskm
 70201                                  ddsks2:
 70202 00013993 803D[FE640000]00        	cmp	byte [hd0_type], 0
 70203 0001399A 7654                    	jna	short ddsk6
 70204 0001399C 66C705[C93A0100]68-     	mov	word [dsktype], 'hd'
 70205 000139A4 64                 
 70206 000139A5 C605[CB3A0100]30        	mov	byte [dskx], '0'
 70207 000139AC E84A000000              	call	pdskm
 70208                                  ddsks3:
 70209 000139B1 803D[FF640000]00        	cmp	byte [hd1_type], 0
 70210 000139B8 7636                    	jna	short ddsk6
 70211 000139BA C605[CB3A0100]31        	mov	byte [dskx], '1'
 70212 000139C1 E835000000              	call	pdskm
 70213                                  ddsks4:
 70214 000139C6 803D[00650000]00        	cmp	byte [hd2_type], 0
 70215 000139CD 7621                    	jna	short ddsk6
 70216 000139CF C605[CB3A0100]32        	mov	byte [dskx], '2'
 70217 000139D6 E820000000              	call	pdskm
 70218                                  ddsks5:
 70219 000139DB 803D[01650000]00        	cmp	byte [hd3_type], 0
 70220 000139E2 760C                    	jna	short ddsk6
 70221 000139E4 C605[CB3A0100]33        	mov	byte [dskx], '3'
 70222 000139EB E80B000000              	call	pdskm
 70223                                  ddsk6:
 70224 000139F0 BE[0F3B0100]            	mov	esi, nextline
 70225 000139F5 E806000000              	call	pdskml
 70226                                  pdskm_ok:
 70227 000139FA C3                      	retn
 70228                                  pdskm:
 70229 000139FB BE[C73A0100]            	mov	esi, dsk_ready_msg
 70230                                  pdskml:	
 70231 00013A00 AC                      	lodsb
 70232 00013A01 08C0                    	or	al, al
 70233 00013A03 74F5                    	jz	short pdskm_ok
 70234 00013A05 56                      	push	esi
 70235                                  	; 13/05/2016
 70236 00013A06 BB07000000                      mov     ebx, 7  ; Black background, 
 70237                                  			; light gray forecolor
 70238                                  			; Video page 0 (bh=0)
 70239 00013A0B E80EE8FEFF              	call	_write_tty
 70240 00013A10 5E                      	pop	esi
 70241 00013A11 EBED                    	jmp	short pdskml
 70242                                  
 70243 00013A13 90                      Align 2
 70244                                  	; 21/08/2014
 70245                                  exc_msg:
 70246 00013A14 435055206578636570-     	db "CPU exception ! "
 70247 00013A1D 74696F6E202120     
 70248                                  excnstr: 		; 25/08/2014
 70249 00013A24 3F3F68202045495020-     	db "??h", "  EIP : "
 70250 00013A2D 3A20               
 70251                                  EIPstr: ; 29/08/2014
 70252 00013A2F 00<rept>                	times 12 db 0
 70253                                  
 70254                                  	; 23/02/2015
 70255                                  	; 25/08/2014
 70256                                  ;scounter:
 70257                                  ;	db 5
 70258                                  ;	db 19
 70259                                  
 70260                                  ; 06/11/2014
 70261                                  ; Memory Information message
 70262                                  ; 14/08/2015
 70263                                  msg_memory_info:
 70264 00013A3B 07                      	db 07h
 70265 00013A3C 0D0A                    	db 0Dh, 0Ah
 70266                                  	;db "MEMORY ALLOCATION INFO", 0Dh, 0Ah, 0Dh, 0Ah
 70267 00013A3E 546F74616C206D656D-     	db "Total memory : "
 70268 00013A47 6F7279203A20       
 70269                                  mem_total_b_str: ; 10 digits
 70270 00013A4D 303030303030303030-     	db "0000000000 bytes", 0Dh, 0Ah
 70271 00013A56 302062797465730D0A 
 70272 00013A5F 202020202020202020-     	db "               ", 20h, 20h, 20h
 70273 00013A68 202020202020202020 
 70274                                  mem_total_p_str: ; 7 digits
 70275 00013A71 303030303030302070-     	db "0000000 pages", 0Dh, 0Ah
 70276 00013A7A 616765730D0A       
 70277 00013A80 0D0A                    	db 0Dh, 0Ah
 70278 00013A82 46726565206D656D6F-     	db "Free memory  : "
 70279 00013A8B 727920203A20       
 70280                                  free_mem_b_str:  ; 10 digits
 70281 00013A91 3F3F3F3F3F3F3F3F3F-     	db "?????????? bytes", 0Dh, 0Ah
 70282 00013A9A 3F2062797465730D0A 
 70283 00013AA3 202020202020202020-     	db "               ", 20h, 20h, 20h
 70284 00013AAC 202020202020202020 
 70285                                  free_mem_p_str:  ; 7 digits
 70286 00013AB5 3F3F3F3F3F3F3F2070-     	db "??????? pages", 0Dh, 0Ah
 70287 00013ABE 616765730D0A       
 70288 00013AC4 0D0A00                  	db 0Dh, 0Ah, 0
 70289                                  
 70290                                  dsk_ready_msg:
 70291 00013AC7 0D0A                    	db 0Dh, 0Ah
 70292                                  dsktype:
 70293 00013AC9 6664                    	db 'fd'
 70294                                  dskx:
 70295 00013ACB 30                      	db '0'
 70296 00013ACC 20                      	db 20h
 70297 00013ACD 697320524541445920-     	db 'is READY ...'
 70298 00013AD6 2E2E2E             
 70299 00013AD9 00                      	db 0
 70300                                  
 70301                                  situp_error_msg:
 70302 00013ADA 0D0A                    	db 0Dh, 0Ah
 70303 00013ADC 4469736B2053657475-     	db 'Disk Setup TEST Error !' 
 70304 00013AE5 702054455354204572-
 70305 00013AEE 726F722021         
 70306 00013AF3 0D0A00                  	db 0Dh, 0Ah,0
 70307                                  
 70308                                  
 70309                                  setup_error_msg:
 70310 00013AF6 0D0A                    	db 0Dh, 0Ah
 70311 00013AF8 4469736B2053657475-     	db 'Disk Setup Error !' 
 70312 00013B01 70204572726F722021 
 70313 00013B0A 0D0A00                  	db 0Dh, 0Ah,0
 70314                                  
 70315                                  next2line: ; 08/02/2016
 70316 00013B0D 0D0A                    	db 0Dh, 0Ah
 70317                                  nextline:
 70318 00013B0F 0D0A00                  	db 0Dh, 0Ah, 0
 70319                                  
 70320                                  ; temporary
 70321                                  ; 19/12/2020
 70322                                  msg_lfb_addr:
 70323                                  	;db 0Dh, 0Ah
 70324 00013B12 4C696E656172206672-     	db "Linear frame buffer at "
 70325 00013B1B 616D65206275666665-
 70326 00013B24 7220617420         
 70327                                  lfb_addr_str: ; 8 (hex) digits
 70328 00013B29 303030303030303068-     	db "00000000h", 0Dh, 0Ah
 70329 00013B32 0D0A               
 70330 00013B34 0D0A00                  	db 0Dh, 0Ah, 0
 70331                                  
 70332                                  ; KERNEL - SYSINIT Messages
 70333                                  ; 24/08/2015
 70334                                  ; 13/04/2015 - (Retro UNIX 386 v1 Beginning)
 70335                                  ; 14/07/2013
 70336                                  ;kernel_init_err_msg:
 70337                                  ;	db 0Dh, 0Ah
 70338                                  ;	db 07h
 70339                                  ;	db 'Kernel initialization ERROR !'
 70340                                  ;	db 0Dh, 0Ah, 0 
 70341                                  
 70342                                  ;welcome_msg: 
 70343                                  ;	db 0Dh, 0Ah
 70344                                  ;	db 07h
 70345                                  ;	db 'Welcome to TRDOS 386 Operating System !'
 70346                                  ;	db 0Dh, 0Ah
 70347                                  ;	db 'by Erdogan Tan - 31/12/2017 (v2.0.0)'
 70348                                  ;	db 0Dh, 0Ah, 0
 70349                                  
 70350                                  panic_msg:
 70351 00013B37 0D0A07                  	db 0Dh, 0Ah, 07h
 70352 00013B3A 4552524F523A204B65-     	db 'ERROR: Kernel Panic !'
 70353 00013B43 726E656C2050616E69-
 70354 00013B4C 632021             
 70355 00013B4F 0D0A00                  	db 0Dh, 0Ah, 0
 70356                                  
 70357                                  ;msgl_drv_not_ready: 
 70358                                  ;	db 07h, 0Dh, 0Ah
 70359                                  ;       db 'Drive not ready or read error !'
 70360                                  ;       db 0Dh, 0Ah, 0
 70361                                  
 70362                                  starting_msg:
 70363                                  	;db "Turkish Rational DOS v2.0 [18/04/2021] ...", 0
 70364 00013B52 5475726B6973682052-     	db "Turkish Rational DOS v2.0 [11/08/2022] ...", 0
 70365 00013B5B 6174696F6E616C2044-
 70366 00013B64 4F532076322E30205B-
 70367 00013B6D 31312F30382F323032-
 70368 00013B76 325D202E2E2E00     
 70369                                  NextLine:
 70370 00013B7D 0D0A00                  	db 0Dh, 0Ah, 0
 70371                                  
 70372                                  %include 'audio.s' ; 03/04/2017
 70373                              <1> ; ****************************************************************************
 70374                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - audio.s
 70375                              <1> ; ----------------------------------------------------------------------------
 70376                              <1> ; Last Update: 06/08/2022  (Previous: 01/09/2020 - Kernel v2.0.4)
 70377                              <1> ; ----------------------------------------------------------------------------
 70378                              <1> ; Beginning: 03/04/2017
 70379                              <1> ; ----------------------------------------------------------------------------
 70380                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 70381                              <1> ; ****************************************************************************
 70382                              <1> 
 70383                              <1> ; AUDIO CONTROLLER & CODEC DEFINITIONS & CODE FOR TRDOS 386
 70384                              <1> 
 70385                              <1> ;=============================================================================
 70386                              <1> ;               EQUATES
 70387                              <1> ;=============================================================================
 70388                              <1> 
 70389                              <1> ; PCI EQUATES
 70390                              <1> 
 70391                              <1> BIT0  EQU 1
 70392                              <1> BIT1  EQU 2
 70393                              <1> BIT2  EQU 4
 70394                              <1> BIT3  EQU 8
 70395                              <1> BIT4  EQU 10h
 70396                              <1> BIT5  EQU 20h
 70397                              <1> BIT6  EQU 40h
 70398                              <1> BIT7  EQU 80h
 70399                              <1> BIT8  EQU 100h
 70400                              <1> BIT9  EQU 200h
 70401                              <1> BIT10 EQU 400h
 70402                              <1> BIT11 EQU 800h
 70403                              <1> BIT12 EQU 1000h
 70404                              <1> BIT13 EQU 2000h
 70405                              <1> BIT14 EQU 4000h
 70406                              <1> BIT15 EQU 8000h
 70407                              <1> BIT16 EQU 10000h
 70408                              <1> BIT17 EQU 20000h
 70409                              <1> BIT18 EQU 40000h
 70410                              <1> BIT19 EQU 80000h
 70411                              <1> BIT20 EQU 100000h
 70412                              <1> BIT21 EQU 200000h
 70413                              <1> BIT22 EQU 400000h
 70414                              <1> BIT23 EQU 800000h
 70415                              <1> BIT24 EQU 1000000h
 70416                              <1> BIT25 EQU 2000000h
 70417                              <1> BIT26 EQU 4000000h
 70418                              <1> BIT27 EQU 8000000h
 70419                              <1> BIT28 EQU 10000000h
 70420                              <1> BIT29 EQU 20000000h
 70421                              <1> BIT30 EQU 40000000h
 70422                              <1> BIT31 EQU 80000000h
 70423                              <1> NOT_BIT31 EQU 7FFFFFFFh
 70424                              <1> 
 70425                              <1> ; PCI equates
 70426                              <1> ; PCI function address (PFA)
 70427                              <1> ; bit 31 = 1
 70428                              <1> ; bit 23:16 = bus number     (0-255)
 70429                              <1> ; bit 15:11 = device number  (0-31)
 70430                              <1> ; bit 10:8 = function number (0-7)
 70431                              <1> ; bit 7:0 = register number  (0-255)
 70432                              <1> 
 70433                              <1> IO_ADDR_MASK    EQU     0FFFEh	; mask off bit 0 for reading BARs
 70434                              <1> PCI_INDEX_PORT  EQU     0CF8h
 70435                              <1> PCI_DATA_PORT   EQU     0CFCh
 70436                              <1> PCI32           EQU     BIT31	; bitflag to signal 32bit access
 70437                              <1> PCI16           EQU     BIT30	; bitflag for 16bit access
 70438                              <1> NOT_PCI32_PCI16	EQU	03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
 70439                              <1> 
 70440                              <1> PCI_FN0         EQU     0 << 8
 70441                              <1> PCI_FN1         EQU     1 << 8
 70442                              <1> PCI_FN2         EQU     2 << 8
 70443                              <1> PCI_FN3         EQU     3 << 8
 70444                              <1> PCI_FN4         EQU     4 << 8
 70445                              <1> PCI_FN5         EQU     5 << 8
 70446                              <1> PCI_FN6         EQU     6 << 8
 70447                              <1> PCI_FN7         EQU     7 << 8
 70448                              <1> 
 70449                              <1> PCI_CMD_REG	EQU	04h	; reg 04, command reg
 70450                              <1> IO_ENA		EQU	BIT0	; i/o decode enable
 70451                              <1> MEM_ENA		EQU	BIT1	; memory decode enable
 70452                              <1> BM_ENA		EQU     BIT2	; bus master enable
 70453                              <1> 
 70454                              <1> ; VIA VT8233 EQUATES
 70455                              <1> 
 70456                              <1> VIA_VID		equ 1106h	; VIA's PCI vendor ID
 70457                              <1> VT8233_DID      equ 3059h	; VT8233 (VT8235) device ID
 70458                              <1> 		
 70459                              <1> PCI_IO_BASE          equ 10h
 70460                              <1> AC97_INT_LINE        equ 3Ch
 70461                              <1> VIA_ACLINK_CTRL      equ 41h
 70462                              <1> VIA_ACLINK_STAT      equ 40h
 70463                              <1> VIA_ACLINK_C00_READY equ 01h ; primary codec ready
 70464                              <1> 	
 70465                              <1> VIA_REG_AC97	     equ 80h ; dword
 70466                              <1> 
 70467                              <1> VIA_ACLINK_CTRL_ENABLE	equ   80h ; 0: disable, 1: enable
 70468                              <1> VIA_ACLINK_CTRL_RESET	equ   40h ; 0: assert, 1: de-assert
 70469                              <1> VIA_ACLINK_CTRL_SYNC	equ   20h ; 0: release SYNC, 1: force SYNC hi
 70470                              <1> VIA_ACLINK_CTRL_VRA	equ   08h ; 0: disable VRA, 1: enable VRA
 70471                              <1> VIA_ACLINK_CTRL_PCM	equ   04h ; 0: disable PCM, 1: enable PCM
 70472                              <1> 					; 3D Audio Channel slots 3/4
 70473                              <1> VIA_ACLINK_CTRL_INIT	equ  (VIA_ACLINK_CTRL_ENABLE +                               VIA_ACLINK_CTRL_RESET +                               VIA_ACLINK_CTRL_PCM +                               VIA_ACLINK_CTRL_VRA)
 70474                              <1> 
 70475                              <1> CODEC_AUX_VOL		equ   04h
 70476                              <1> VIA_REG_AC97_BUSY	equ   01000000h ;(1<<24) 
 70477                              <1> VIA_REG_AC97_CMD_SHIFT	equ   10h ; 16
 70478                              <1> VIA_REG_AC97_PRIMARY_VALID equ 02000000h ;(1<<25)
 70479                              <1> VIA_REG_AC97_READ	equ   00800000h ;(1<<23)
 70480                              <1> VIA_REG_AC97_CODEC_ID_SHIFT   equ  1Eh ; 30
 70481                              <1> VIA_REG_AC97_CODEC_ID_PRIMARY equ  0
 70482                              <1> VIA_REG_AC97_DATA_SHIFT equ   0
 70483                              <1> VIADEV_PLAYBACK         equ   0
 70484                              <1> VIA_REG_OFFSET_STATUS   equ   0    ;; byte - channel status
 70485                              <1> VIA_REG_OFFSET_CONTROL  equ   01h  ;; byte - channel control
 70486                              <1> VIA_REG_CTRL_START	equ   80h  ;; WO
 70487                              <1> VIA_REG_CTRL_TERMINATE  equ   40h  ;; WO
 70488                              <1> VIA_REG_CTRL_PAUSE      equ   08h  ;; RW
 70489                              <1> VIA_REG_CTRL_RESET      equ   01h  ;; RW - probably reset? undocumented
 70490                              <1> VIA_REG_OFFSET_STOP_IDX equ   08h  ;; dword - stop index, channel type, sample rate
 70491                              <1> VIA8233_REG_TYPE_16BIT  equ   200000h ;; RW
 70492                              <1> VIA8233_REG_TYPE_STEREO equ   100000h ;; RW
 70493                              <1> VIA_REG_OFFSET_CURR_INDEX equ 0Fh ;; byte - channel current index (for via8233 only)
 70494                              <1> VIA_REG_OFFSET_TABLE_PTR equ  04h  ;; dword - channel table pointer
 70495                              <1> VIA_REG_OFFSET_CURR_PTR equ   04h  ;; dword - channel current pointer
 70496                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_L equ  02h ;; byte
 70497                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_R equ  03h ;; byte
 70498                              <1> VIA_REG_CTRL_AUTOSTART	equ   20h
 70499                              <1> VIA_REG_CTRL_INT_EOL	equ   02h
 70500                              <1> VIA_REG_CTRL_INT_FLAG	equ   01h
 70501                              <1> VIA_REG_CTRL_INT	equ  (VIA_REG_CTRL_INT_FLAG +                               VIA_REG_CTRL_INT_EOL +                               VIA_REG_CTRL_AUTOSTART)
 70502                              <1> 
 70503                              <1> VIA_REG_STAT_STOP_IDX	equ   10h    ;; RO ; 27/07/2020
 70504                              <1> 				     ; current index = stop index
 70505                              <1> VIA_REG_STAT_STOPPED	equ   04h    ;; RWC
 70506                              <1> VIA_REG_STAT_EOL	equ   02h    ;; RWC
 70507                              <1> VIA_REG_STAT_FLAG	equ   01h    ;; RWC
 70508                              <1> VIA_REG_STAT_ACTIVE	equ   80h    ;; RO
 70509                              <1> ; 28/11/2016
 70510                              <1> VIA_REG_STAT_LAST	equ   40h    ;; RO
 70511                              <1> VIA_REG_STAT_TRIGGER_QUEUED equ 08h  ;; RO
 70512                              <1> VIA_REG_CTRL_INT_STOP	equ   04h  ; Interrupt on Current Index = Stop Index
 70513                              <1> 		   		   ; and End of Block
 70514                              <1> 
 70515                              <1> VIA_REG_OFFSET_CURR_COUNT equ 0Ch ;; dword - channel current count, index
 70516                              <1> 
 70517                              <1> PORTB		EQU	061h
 70518                              <1> REFRESH_STATUS	EQU	010h	; Refresh signal status
 70519                              <1> 
 70520                              <1> ; AC97 Codec registers.
 70521                              <1> 
 70522                              <1> ; 22/07/2020
 70523                              <1> ; REALTEK ALC655 and ADI SOUNDMAX AD1980 CODEC MIXER REGISTERS
 70524                              <1> 
 70525                              <1> ; each codec/mixer register is 16bits
 70526                              <1> 
 70527                              <1> CODEC_RESET_REG                 equ     00h	; reset codec
 70528                              <1> CODEC_MASTER_VOL_REG            equ     02h	; master volume
 70529                              <1> CODEC_HP_VOL_REG                equ     04h	; headphone volume ; AD1980
 70530                              <1> CODEC_MASTER_MONO_VOL_REG       equ     06h	; master mono volume (mono-out)
 70531                              <1> ;CODEC_MASTER_TONE_REG          equ     08h	; master tone (R+L) ; (not used)
 70532                              <1> CODEC_PCBEEP_VOL_REG            equ     0Ah	; PC beep volume ; ALC655
 70533                              <1> CODEC_PHONE_VOL_REG             equ     0Ch	; phone volume
 70534                              <1> CODEC_MIC_VOL_REG               equ     0Eh	; mic volume
 70535                              <1> CODEC_LINE_IN_VOL_REG           equ     10h	; line in volume
 70536                              <1> CODEC_CD_VOL_REG                equ     12h	; CD volume
 70537                              <1> ;CODEC_VID_VOL_REG              equ     14h	; video volume ; (not used)
 70538                              <1> CODEC_AUX_VOL_REG               equ     16h	; aux volume
 70539                              <1> CODEC_PCM_OUT_REG               equ     18h	; PCM out volume
 70540                              <1> CODEC_RECORD_SELECT_REG         equ     1Ah	; record select
 70541                              <1> CODEC_RECORD_VOL_REG            equ     1Ch	; record volume (record gain)
 70542                              <1> ;CODEC_RECORD_MIC_VOL_REG       equ     1Eh	; record mic volume ; (not used)
 70543                              <1> CODEC_GP_REG                    equ     20h	; general purpose
 70544                              <1> ;CODEC_3D_CONTROL_REG           equ     22h	; 3D control
 70545                              <1> ;;CODEC_AUDIO_INT_PAGING_REG    equ	24h	; audio int & paging ; (not used) 
 70546                              <1> CODEC_POWER_CTRL_REG            equ     26h	; power down control
 70547                              <1> CODEC_EXT_AUDIO_REG             equ     28h	; extended audio ID
 70548                              <1> CODEC_EXT_AUDIO_CTRL_REG        equ     2Ah	; extended audio status/control
 70549                              <1> CODEC_PCM_FRONT_DACRATE_REG     equ     2Ch	; PCM front sample rate
 70550                              <1> CODEC_PCM_SURND_DACRATE_REG     equ     2Eh	; PCM surround sample rate
 70551                              <1> CODEC_PCM_LFE_DACRATE_REG       equ     30h	; PCM Center/LFE sample rate
 70552                              <1> CODEC_LR_ADCRATE_REG            equ     32h	; PCM input sample rate
 70553                              <1> CODEC_MIC_ADCRATE_REG           equ     34h	; mic in sample rate  ; AD1980
 70554                              <1> CODEC_PCM_LFE_VOL_REG           equ     36h	; PCM Center/LFE volume
 70555                              <1> CODEC_PCM_SURND_VOL_REG         equ     38h	; PCM surround volume
 70556                              <1> ;CODEC_SPDIF_CTRL_REG           equ     3Ah	; S/PDIF control
 70557                              <1> ; 22/07/2020
 70558                              <1> CODEC_MISC_CRTL_BITS_REG	equ	76h	; misc control bits ; AD1980
 70559                              <1> ;	
 70560                              <1> CODEC_VENDOR_ID1		equ	7Ch	; REALTEK: 414Ch, ADI: 4144h	
 70561                              <1> CODEC_VENDOR_ID2		equ	7Eh	; REALTEK: 4760h, ADI: 5370h	
 70562                              <1> 
 70563                              <1> ; VT8233 SGD bits (21/04/2017)
 70564                              <1> FLAG	EQU BIT30
 70565                              <1> EOL	EQU BIT31
 70566                              <1> 
 70567                              <1> ; INTEL ICH EQUATES
 70568                              <1> ; 28/05/2017
 70569                              <1> INTEL_VID	equ	8086h	; Intel's PCI vendor ID
 70570                              <1> ICH_DID		equ	2415h	; ICH (82801AA) device ID
 70571                              <1> NAMBAR_REG      equ	10h	; native audio mixer Base Address Register
 70572                              <1> NABMBAR_REG     equ	14h	; native audio bus mastering Base Addr Reg
 70573                              <1> 
 70574                              <1> PI_CR_REG       equ     0Bh     ; PCM in Control Register
 70575                              <1> PO_CR_REG	equ     1Bh     ; PCM out Control Register
 70576                              <1> MC_CR_REG	equ     2Bh     ; MIC in Control Register
 70577                              <1> 
 70578                              <1> PI_SR_REG	equ     6       ; PCM in Status register
 70579                              <1> PO_SR_REG	equ     16h     ; PCM out Status register
 70580                              <1> MC_SR_REG	equ     26h     ; MIC in Status register
 70581                              <1> 
 70582                              <1> IOCE 		equ     BIT4    ; interrupt on complete enable.
 70583                              <1> FEIFE		equ     BIT3    ; set if you want an interrupt to fire
 70584                              <1> LVBIE		equ     BIT2    ; last valid buffer interrupt enable.
 70585                              <1> RR 		equ     BIT1    ; reset registers. Nukes all regs
 70586                              <1>                                 ; except bits 4:2 of this register.
 70587                              <1>                                 ; Only set this bit if BIT 0 is 0
 70588                              <1> RPBM		equ     BIT0    ; Run/Pause
 70589                              <1> 				; set this bit to start the codec!
 70590                              <1> 
 70591                              <1> PI_BDBAR_REG	equ     0       ; PCM in buffer descriptor BAR
 70592                              <1> PO_BDBAR_REG	equ     10h     ; PCM out buffer descriptor BAR
 70593                              <1> MC_BDBAR_REG	equ     20h     ; MIC in buffer descriptor BAR
 70594                              <1> 
 70595                              <1> PI_CIV_REG	equ     4       ; PCM in current Index value (RO)
 70596                              <1> PO_CIV_REG	equ     14h     ; PCM out current Index value (RO)
 70597                              <1> MC_CIV_REG 	equ     24h     ; MIC in current Index value (RO)
 70598                              <1> 
 70599                              <1> PI_LVI_REG	equ     5       ; PCM in Last Valid Index
 70600                              <1> PO_LVI_REG	equ     15h     ; PCM out Last Valid Index
 70601                              <1> MC_LVI_REG	equ     25h     ; MIC in Last Valid Index
 70602                              <1> 
 70603                              <1> IOC		equ     BIT31	; Fire an interrupt whenever this
 70604                              <1>                 		; buffer is complete.
 70605                              <1> BUP		equ     BIT30	; Buffer Underrun Policy.
 70606                              <1> 
 70607                              <1> GLOB_CNT_REG	equ     2Ch     ; Global Control Register
 70608                              <1> GLOB_STS_REG	equ     30h     ; Global Status register (RO)
 70609                              <1> 
 70610                              <1> CTRL_ST_CREADY	equ   BIT8+BIT9+BIT28 ; Primary Codec Ready
 70611                              <1> 
 70612                              <1> CODEC_REG_POWERDOWN   equ 26h
 70613                              <1> CODEC_REG_ST          equ 26h
 70614                              <1> 
 70615                              <1> ; 22/06/2017
 70616                              <1> PO_PICB_REG	equ 18h	; PCM Out Position In Current Buffer Register
 70617                              <1> 
 70618                              <1> ;=============================================================================
 70619                              <1> ;               CODE
 70620                              <1> ;=============================================================================
 70621                              <1> 
 70622                              <1> ; CODE for INTEL ICH AC'97 AUDIO CONTROLLER
 70623                              <1> 
 70624                              <1> DetectICH:
 70625                              <1> 	; 10/06/2017
 70626                              <1> 	; 05/06/2017
 70627                              <1> 	; 29/05/2017
 70628                              <1> 	; 28/05/2017
 70629 00013B80 B886801524          <1> 	mov     eax, (ICH_DID << 16) + INTEL_VID
 70630 00013B85 E86E000000          <1>         call    pciFindDevice
 70631 00013B8A 730D                <1>         jnc     short d_ac97_1
 70632                              <1> d_ac97_0:
 70633                              <1> ; couldn't find the audio device!
 70634 00013B8C C3                  <1> 	retn
 70635                              <1> 
 70636                              <1> ; CODE for VIA VT8233 AUDIO CONTROLLER
 70637                              <1> 
 70638                              <1> DetectVT8233:
 70639                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 70640                              <1> 	; 10/06/2017
 70641                              <1> 	; 05/06/2017
 70642                              <1> 	; 29/05/2017
 70643                              <1> 	; 03/04/2017
 70644 00013B8D B806115930          <1> 	mov     eax, (VT8233_DID << 16) + VIA_VID
 70645 00013B92 E861000000          <1>         call    pciFindDevice
 70646                              <1> ;       jnc     short d_vt8233_0
 70647                              <1> ; couldn't find the audio device!
 70648                              <1> ;	retn
 70649 00013B97 72F3                <1> 	jc	short d_ac97_0  ; 28/05/2017
 70650                              <1> d_vt8233_0:
 70651                              <1> 	; 24/03/2017 ('player.asm')
 70652                              <1> 	; 12/11/2016 
 70653                              <1> 	; Erdogan Tan - 8/11/2016
 70654                              <1> 	; References: Kolibrios - vt823x.asm (2016)
 70655                              <1> 	;	      VIA VT8235 V-Link South Bridge (VT8235-VIA.PDF)(2002)
 70656                              <1> 	;	      lowlevel.eu - AC97 (2016)
 70657                              <1> 	;	      .wav player for DOS by Jeff Leyda (2002) -this file-
 70658                              <1> 	;	      Linux kernel - via82xx.c (2016)
 70659                              <1> d_ac97_1:
 70660                              <1> 	; eax = BUS/DEV/FN
 70661                              <1> 	;	00000000BBBBBBBBDDDDDFFF00000000
 70662                              <1> 	; edx = DEV/VENDOR
 70663                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
 70664                              <1> 
 70665 00013B99 A3[B0890100]        <1> 	mov	[audio_dev_id], eax
 70666 00013B9E 8915[B4890100]      <1> 	mov	[audio_vendor], edx
 70667                              <1> 
 70668                              <1> 	; init controller
 70669 00013BA4 B004                <1> 	mov	al, PCI_CMD_REG ; command register (04h)
 70670 00013BA6 E8DA000000          <1> 	call	pciRegRead32
 70671                              <1> 
 70672                              <1> 	; eax = BUS/DEV/FN/REG
 70673                              <1> 	; edx = STATUS/COMMAND
 70674                              <1> 	; 	SSSSSSSSSSSSSSSSCCCCCCCCCCCCCCCC
 70675 00013BAB 8915[B8890100]      <1> 	mov	[audio_stats_cmd], edx
 70676                              <1> 
 70677 00013BB1 B010                <1> 	mov	al, PCI_IO_BASE ; IO base address register (10h)
 70678                              <1> 	;mov	al, NAMBAR_REG	; Native Audio Mixer BAR (10h)
 70679 00013BB3 E8CD000000          <1> 	call	pciRegRead32
 70680                              <1> 
 70681 00013BB8 66813D[B4890100]86- <1> 	cmp	word [audio_vendor], 8086h ; AC'97 ?
 70682 00013BC0 80                  <1>
 70683 00013BC1 751D                <1> 	jne	short d_vt8233_1
 70684                              <1> 
 70685                              <1> 	;and	dx, 0FFFEh ; Audio Codec IO_ADDR_MASK
 70686                              <1> 	; 06/08/2022
 70687 00013BC3 80E2FE              <1> 	and	dl, 0FEh
 70688 00013BC6 668915[E0890100]    <1> 	mov	[NAMBAR], dx
 70689                              <1> 
 70690 00013BCD B014                <1> 	mov	al, NABMBAR_REG ; Native Audio Bus Mastering BAR (14h)
 70691 00013BCF E8B1000000          <1> 	call	pciRegRead32	
 70692                              <1> 
 70693                              <1> 	;and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK
 70694                              <1> 	; 06/08/2022
 70695 00013BD4 80E2C0              <1> 	and	dl, 0C0h
 70696 00013BD7 668915[E2890100]    <1> 	mov	[NABMBAR], dx
 70697                              <1>         ;mov	[audio_io_base], dx
 70698                              <1> 	
 70699 00013BDE EB0A                <1> 	jmp	short d_ac97_2
 70700                              <1> 
 70701                              <1> d_vt8233_1:
 70702                              <1> 	;and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK 
 70703                              <1> 	; 06/08/2022
 70704 00013BE0 80E2C0              <1> 	and	dl, 0C0h
 70705 00013BE3 668915[AE890100]    <1>         mov     [audio_io_base], dx
 70706                              <1> 
 70707                              <1> d_ac97_2:
 70708                              <1> 	; 10/06/2017
 70709 00013BEA B03C                <1> 	mov	al, AC97_INT_LINE ; Interrupt Line Register (3Ch)
 70710                              <1> 	;call	pciRegRead32
 70711 00013BEC E881000000          <1> 	call	pciRegRead8
 70712                              <1> 
 70713                              <1> 	;;and 	edx, 0FFh
 70714                              <1> 	; 06/08/2022
 70715                              <1> 	;and	dx, 0FFh
 70716                              <1> 
 70717 00013BF1 8815[AB890100]      <1>   	mov     [audio_intr], dl
 70718                              <1> 
 70719 00013BF7 C3                  <1> 	retn
 70720                              <1> 
 70721                              <1> 	;; (Note: Interrupts are already enabled by TRDOS 386 kernel!)
 70722                              <1> 	;mov	cx, dx
 70723                              <1> 	
 70724                              <1> 	;in	al, 0A1h ; irq 8-15
 70725                              <1> 	;mov	ah, al
 70726                              <1> 	;in	al, 21h  ; irq 0-7 
 70727                              <1> 	;btr	ax, dx	 ; unmask ; 17/03/2017
 70728                              <1> 	;;bts	ax, dx   ; MASK interrupt ; 10/06/2017 
 70729                              <1> 	;out	21h, al  ; irq <= 7
 70730                              <1> 	;mov	al, ah
 70731                              <1> 	;out	0A1h, al ; irq > 7
 70732                              <1> 	;
 70733                              <1> 	
 70734                              <1> 	; 10/06/2017
 70735                              <1> 	; === Intel ICH I/O Controller Hub Datasheet, Section 8.1.16 ===
 70736                              <1> 	; PRQ[n]_ROUT Register (61h, PRQB) Bit 7:
 70737                              <1> 	; Interrupt Routing Enable (IRQEN).
 70738                              <1> 	; 0 = The corresponding PIRQ is routed to one of the ISA-compatible
 70739                              <1> 	;     interrupts specified in bits[3:0].
 70740                              <1> 	; 1 = The PIRQ is not routed to the 8259.
 70741                              <1> 	; Note: If the PIRQ is intended to cause an interrupt to the ICHs 
 70742                              <1> 	;	integrated I/O APIC, then this bit should be set to 0 and 
 70743                              <1> 	;	the APIC_EN bit should be set to 1. 
 70744                              <1> 	;	The IRQEN must be set to 0 and the PIRQ routed to 
 70745                              <1> 	;	an 8259 interrupt via the IRQ Routing filed (bits[3:0).
 70746                              <1> 	;	The corresponding 8259 interrupt must be masked via the 
 70747                              <1> 	;	appropriated bit in the 8259s OCW1 (Interrupt Mask)
 70748                              <1> 	;	register. The IOAPIC must then be enabled by setting 
 70749                              <1> 	;	the APIC_EN bit in the GEN_CNTL register.
 70750                              <1> 
 70751                              <1> 	;mov	eax, 0F861h  ; D31:F0
 70752                              <1> 		;AL=61h : PIRQ[B] Routing Control Reg, LPC interface
 70753                              <1> 	;;mov	dl, [audio_intr]
 70754                              <1> 	;call	pciRegWrite8
 70755                              <1> 	;;mov	al, 0D0h ; General Control Register (GEN_CTL)
 70756                              <1> 	;;call	pciRegRead32
 70757                              <1> 	;;or	edx, 100h ; Bit 8, APIC_EN (Enable I/O APIC) 
 70758                              <1> 	;;;call	pciRegWrite32
 70759                              <1> 	;;and	edx, ~100h
 70760                              <1> 	;;call	pciRegWrite32 ; ; Bit 8, APIC_EN (Disable I/O APIC) 
 70761                              <1> 	;
 70762                              <1> 
 70763                              <1> 	;mov	dx, 4D1h	; 8259 ELCR2
 70764                              <1>     	;in	al, dx
 70765                              <1> 	;mov	ah, al
 70766                              <1> 	;;mov	dx, 4D0h 	; 8259 ELCR1
 70767                              <1> 	;dec	dl
 70768                              <1> 	;in	al, dx
 70769                              <1> 	;bts	ax, cx
 70770                              <1> 	;;mov	dx, 4D0h
 70771                              <1> 	;out	dx, al		; set level-triggered mode
 70772                              <1> 	;mov	al, ah ; 29/05/2017
 70773                              <1> 	;;mov	dx, 4D1h
 70774                              <1> 	;inc	dl
 70775                              <1> 	;out	dx, al		; set level-triggered mode
 70776                              <1> 
 70777                              <1> 	;xor	eax, eax ; 0
 70778                              <1> 
 70779                              <1> 	;retn
 70780                              <1> 
 70781                              <1> ; CODE for PCI
 70782                              <1> 
 70783                              <1> pciFindDevice:
 70784                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
 70785                              <1> 	;
 70786                              <1> 	; scan through PCI space looking for a device+vendor ID
 70787                              <1> 	;
 70788                              <1> 	; Entry: EAX=Device+Vendor ID
 70789                              <1> 	;
 70790                              <1> 	; Exit: EAX=PCI address if device found
 70791                              <1> 	;	 EDX=Device+Vendor ID
 70792                              <1> 	;        CY clear if found, set if not found. EAX invalid if CY set.
 70793                              <1> 	;
 70794                              <1> 	; Destroys: ebx, esi, edi, cl
 70795                              <1> 	;
 70796                              <1> 
 70797                              <1> 	;push	ecx
 70798 00013BF8 50                  <1> 	push	eax
 70799                              <1> 	;push	esi
 70800                              <1> 	;push	edi
 70801                              <1> 
 70802 00013BF9 89C6                <1>         mov     esi, eax                ; save off vend+device ID
 70803 00013BFB BF00FFFF7F          <1>         mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
 70804                              <1> 
 70805                              <1> nextPCIdevice:
 70806 00013C00 81C700010000        <1>         add     edi, 100h
 70807 00013C06 81FF00F8FF80        <1>         cmp     edi, 80FFF800h		; scanned all devices?
 70808 00013C0C F9                  <1>         stc
 70809 00013C0D 740C                <1>         je      short PCIScanExit       ; not found
 70810                              <1> 
 70811 00013C0F 89F8                <1>         mov     eax, edi                ; read PCI registers
 70812 00013C11 E86F000000          <1>         call    pciRegRead32
 70813 00013C16 39F2                <1>         cmp     edx, esi                ; found device?
 70814 00013C18 75E6                <1>         jne     short nextPCIdevice
 70815 00013C1A F8                  <1>         clc
 70816                              <1> 
 70817                              <1> PCIScanExit:
 70818 00013C1B 9C                  <1> 	pushf
 70819 00013C1C B8FFFFFF7F          <1> 	mov	eax, NOT_BIT31 	; 19/03/2017
 70820 00013C21 21F8                <1> 	and	eax, edi	; return only bus/dev/fn #
 70821 00013C23 9D                  <1> 	popf
 70822                              <1> 
 70823                              <1> 	;pop	edi
 70824                              <1> 	;pop	esi
 70825 00013C24 5A                  <1> 	pop	edx
 70826                              <1> 	;pop	ecx
 70827 00013C25 C3                  <1> 	retn
 70828                              <1> 
 70829                              <1> pciRegRead:
 70830                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
 70831                              <1> 	;
 70832                              <1> 	; 8/16/32bit PCI reader
 70833                              <1> 	;
 70834                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
 70835                              <1> 	;           BIT30 set if 32 bit access requested
 70836                              <1> 	;           BIT29 set if 16 bit access requested
 70837                              <1> 	;           otherwise defaults to 8 bit read
 70838                              <1> 	;
 70839                              <1> 	; Exit:  DL,DX,EDX register data depending on requested read size
 70840                              <1> 	;
 70841                              <1> 	; Note1: this routine is meant to be called via pciRegRead8,
 70842                              <1> 	;	 pciRegread16 or pciRegRead32, listed below.
 70843                              <1> 	;
 70844                              <1> 	; Note2: don't attempt to read 32 bits of data from a non dword
 70845                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit reads from
 70846                              <1> 	;	 non word aligned reg #
 70847                              <1> 	
 70848 00013C26 53                  <1> 	push	ebx
 70849 00013C27 51                  <1> 	push	ecx
 70850 00013C28 89C3                <1>         mov     ebx, eax		; save eax, dh
 70851 00013C2A 88F1                <1>         mov     cl, dh
 70852                              <1> 
 70853 00013C2C 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
 70854 00013C31 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
 70855 00013C36 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
 70856                              <1> 
 70857 00013C38 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
 70858 00013C3C EF                  <1>         out	dx, eax			; write PCI selector
 70859                              <1> 	
 70860 00013C3D 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
 70861 00013C41 88D8                <1>         mov     al, bl
 70862 00013C43 2403                <1>         and     al, 3			; figure out which port to
 70863 00013C45 00C2                <1>         add     dl, al			; read to
 70864                              <1> 
 70865 00013C47 F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
 70866 00013C4D 7507                <1>         jnz     short _pregr0
 70867 00013C4F EC                  <1> 	in	al, dx			; return 8 bits of data
 70868 00013C50 88C2                <1>         mov	dl, al
 70869 00013C52 88CE                <1> 	mov     dh, cl			; restore dh for 8 bit read
 70870 00013C54 EB12                <1> 	jmp	short _pregr2
 70871                              <1> _pregr0:	
 70872 00013C56 F7C300000080        <1> 	test    ebx, PCI32
 70873 00013C5C 7507                <1>         jnz	short _pregr1
 70874 00013C5E 66ED                <1> 	in	ax, dx
 70875 00013C60 6689C2              <1>         mov     dx, ax			; return 16 bits of data
 70876 00013C63 EB03                <1> 	jmp	short _pregr2
 70877                              <1> _pregr1:
 70878 00013C65 ED                  <1> 	in	eax, dx			; return 32 bits of data
 70879 00013C66 89C2                <1> 	mov	edx, eax
 70880                              <1> _pregr2:
 70881 00013C68 89D8                <1> 	mov     eax, ebx		; restore eax
 70882 00013C6A 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
 70883 00013C6F 59                  <1> 	pop	ecx
 70884 00013C70 5B                  <1> 	pop	ebx
 70885 00013C71 C3                  <1> 	retn
 70886                              <1> 
 70887                              <1> pciRegRead8:
 70888 00013C72 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
 70889 00013C77 EBAD                <1>         jmp     short pciRegRead	; call generic PCI access
 70890                              <1> 
 70891                              <1> pciRegRead16:
 70892 00013C79 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
 70893 00013C7E 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
 70894 00013C83 EBA1                <1>         jmp     short pciRegRead
 70895                              <1> 
 70896                              <1> pciRegRead32:
 70897 00013C85 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
 70898 00013C8A 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
 70899 00013C8F EB95                <1>         jmp     pciRegRead
 70900                              <1> 
 70901                              <1> pciRegWrite:
 70902                              <1> 	; 03/04/2017 ('pci.asm', 29/11/2016)
 70903                              <1> 	;
 70904                              <1> 	; 8/16/32bit PCI writer
 70905                              <1> 	;
 70906                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
 70907                              <1> 	;           BIT31 set if 32 bit access requested
 70908                              <1> 	;           BIT30 set if 16 bit access requested
 70909                              <1> 	;           otherwise defaults to 8bit read
 70910                              <1> 	;        DL/DX/EDX data to write depending on size
 70911                              <1> 	;
 70912                              <1> 	; Note1: this routine is meant to be called via pciRegWrite8, 
 70913                              <1> 	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
 70914                              <1> 	;
 70915                              <1> 	; Note2: don't attempt to write 32bits of data from a non dword
 70916                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit writes from
 70917                              <1> 	;	 non word aligned reg #
 70918                              <1> 
 70919 00013C91 53                  <1> 	push	ebx
 70920 00013C92 51                  <1> 	push	ecx
 70921 00013C93 89C3                <1>         mov     ebx, eax		; save eax, edx
 70922 00013C95 89D1                <1>         mov     ecx, edx
 70923 00013C97 25FFFFFF3F          <1> 	and     eax, NOT_PCI32_PCI16	; clear out data size request
 70924 00013C9C 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
 70925 00013CA1 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
 70926                              <1> 
 70927 00013CA3 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
 70928 00013CA7 EF                  <1>         out	dx, eax			; write PCI selector
 70929                              <1> 	
 70930 00013CA8 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
 70931 00013CAC 88D8                <1>         mov     al, bl
 70932 00013CAE 2403                <1>         and     al, 3			; figure out which port to
 70933 00013CB0 00C2                <1>         add     dl, al			; write to
 70934                              <1> 
 70935 00013CB2 F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
 70936 00013CB8 7505                <1>         jnz     short _pregw0
 70937 00013CBA 88C8                <1> 	mov	al, cl 			; put data into al
 70938 00013CBC EE                  <1> 	out	dx, al
 70939 00013CBD EB12                <1> 	jmp	short _pregw2
 70940                              <1> _pregw0:
 70941 00013CBF F7C300000080        <1> 	test    ebx, PCI32
 70942 00013CC5 7507                <1>         jnz     short _pregw1
 70943 00013CC7 6689C8              <1> 	mov	ax, cx			; put data into ax
 70944 00013CCA 66EF                <1> 	out	dx, ax
 70945 00013CCC EB03                <1> 	jmp	short _pregw2
 70946                              <1> _pregw1:
 70947 00013CCE 89C8                <1> 	mov	eax, ecx		; put data into eax 		
 70948 00013CD0 EF                  <1> 	out	dx, eax
 70949                              <1> _pregw2:
 70950 00013CD1 89D8                <1>         mov     eax, ebx		; restore eax
 70951 00013CD3 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
 70952 00013CD8 89CA                <1>         mov     edx, ecx		; restore dx
 70953 00013CDA 59                  <1> 	pop	ecx
 70954 00013CDB 5B                  <1> 	pop	ebx
 70955 00013CDC C3                  <1> 	retn
 70956                              <1> 
 70957                              <1> pciRegWrite8:
 70958 00013CDD 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
 70959 00013CE2 EBAD                <1>         jmp	short pciRegWrite	; call generic PCI access
 70960                              <1> 
 70961                              <1> pciRegWrite16:
 70962 00013CE4 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
 70963 00013CE9 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
 70964 00013CEE EBA1                <1>         jmp	short pciRegWrite
 70965                              <1> 
 70966                              <1> pciRegWrite32:
 70967 00013CF0 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
 70968 00013CF5 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
 70969 00013CFA EB95                <1>         jmp	pciRegWrite
 70970                              <1> 
 70971                              <1> init_codec:
 70972                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 70973                              <1> 	; 05/06/2017
 70974                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 70975                              <1> 	;
 70976 00013CFC A1[B0890100]        <1> 	mov	eax, [audio_dev_id]	
 70977 00013D01 B041                <1> 	mov	al, VIA_ACLINK_CTRL
 70978 00013D03 E86AFFFFFF          <1> 	call	pciRegRead8
 70979                              <1> 	; ?
 70980 00013D08 B040                <1> 	mov	al, VIA_ACLINK_STAT
 70981 00013D0A E863FFFFFF          <1> 	call	pciRegRead8
 70982 00013D0F F6C201              <1> 	test	dl, VIA_ACLINK_C00_READY
 70983 00013D12 7508                <1>         jnz     short _codec_ready_1
 70984 00013D14 E80D000000          <1> 	call	reset_codec
 70985 00013D19 7305                <1> 	jnc	short _codec_ready_2 ; eax = 1
 70986 00013D1B C3                  <1> 	retn
 70987                              <1> _codec_ready_1:
 70988                              <1> 	;mov	eax, 1
 70989                              <1> 	; 06/08/2022
 70990 00013D1C 29C0                <1> 	sub	eax, eax
 70991 00013D1E FEC0                <1> 	inc	al
 70992                              <1> 	; eax = 1
 70993                              <1> _codec_ready_2:
 70994 00013D20 E885000000          <1> 	call	codec_io_w16
 70995                              <1> detect_codec:
 70996 00013D25 C3                  <1> 	retn
 70997                              <1> 
 70998                              <1> reset_codec:
 70999                              <1> 	; 16/04/2017
 71000                              <1> 	; 23/03/2017 
 71001                              <1> 	; ('codec.asm')
 71002                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71003 00013D26 A1[B0890100]        <1> 	mov	eax, [audio_dev_id]
 71004 00013D2B B041                <1>  	mov	al, VIA_ACLINK_CTRL
 71005 00013D2D B2E0                <1>        	mov	dl, VIA_ACLINK_CTRL_ENABLE + VIA_ACLINK_CTRL_RESET + VIA_ACLINK_CTRL_SYNC
 71006 00013D2F E8A9FFFFFF          <1> 	call	pciRegWrite8
 71007                              <1> 
 71008 00013D34 E848000000          <1> 	call	delay_100ms 	; wait 100 ms
 71009                              <1> _rc_cold:
 71010 00013D39 E814000000          <1>         call    cold_reset
 71011 00013D3E 7301                <1>         jnc     short _reset_codec_ok
 71012                              <1> 	
 71013                              <1> 	; 16/04/2017
 71014                              <1>         ;xor	eax, eax	; timeout error
 71015                              <1>        	;stc
 71016 00013D40 C3                  <1> 	retn
 71017                              <1> 
 71018                              <1> _reset_codec_ok:
 71019                              <1> 	; 01/09/2020
 71020                              <1> 	; 15/08/2020
 71021                              <1> 	; 27/07/2020
 71022                              <1> 	; also reset codec by using index control register 0 of AD1980 or ALC655
 71023                              <1> 	; (to fix line out -2 channels audio playing- problem on AD1980 codec)  
 71024                              <1> 
 71025 00013D41 29C0                <1> 	sub	eax, eax
 71026 00013D43 BA00000000          <1> 	mov	edx, CODEC_RESET_REG ; 00h ; Reset register
 71027 00013D48 E8C0000000          <1> 	call	codec_write
 71028                              <1> 
 71029                              <1> 	;sub	eax, eax
 71030                              <1> 	; 01/09/2020
 71031                              <1> 	; 15/08/2020
 71032                              <1> 	; AD1980 BugFix
 71033                              <1> 	; (set HPSEL -headphone amp to be driven from mixer- and
 71034                              <1> 	;      CLDIS - center and LFE disable- bits)	
 71035                              <1> 	;mov	eax, 0C00h ; HPSEL = bit 10, CLDIS = bit 11 ; 01/09/2020
 71036                              <1>  	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h ; Misc Ctrl Bits ; AD1980
 71037                              <1> 	;call	codec_write
 71038                              <1> 
 71039 00013D4D 31C0                <1>         xor     eax, eax
 71040                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
 71041 00013D4F FEC0                <1>         inc	al
 71042 00013D51 C3                  <1> 	retn
 71043                              <1> 
 71044                              <1> cold_reset:
 71045                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71046                              <1> 	; 16/04/2017
 71047                              <1> 	; 23/03/2017
 71048                              <1> 	; ('codec.asm')
 71049                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71050                              <1> 	;mov	eax, [audio_dev_id]
 71051                              <1> 	;mov	al, VIA_ACLINK_CTRL
 71052 00013D52 30D2                <1> 	xor	dl, dl ; 0
 71053 00013D54 E884FFFFFF          <1> 	call	pciRegWrite8
 71054                              <1> 
 71055 00013D59 E823000000          <1> 	call	delay_100ms	; wait 100 ms
 71056                              <1> 
 71057                              <1> 	;; ACLink on, deassert ACLink reset, VSR, SGD data out
 71058                              <1>         ;; note - FM data out has trouble with non VRA codecs !!
 71059                              <1>         
 71060                              <1> 	;mov	eax, [audio_dev_id]
 71061                              <1> 	;mov	al, VIA_ACLINK_CTRL
 71062 00013D5E B2CC                <1> 	mov	dl, VIA_ACLINK_CTRL_INIT
 71063 00013D60 E878FFFFFF          <1> 	call	pciRegWrite8
 71064                              <1> 
 71065                              <1> 	;mov	ecx, 16	; total 2s
 71066                              <1> 	; 06/08/2022
 71067 00013D65 29C9                <1> 	sub	ecx, ecx
 71068 00013D67 B110                <1> 	mov	cl, 16
 71069                              <1> _crst_wait:
 71070                              <1> 	;mov	eax, [audio_dev_id]
 71071 00013D69 B040                <1> 	mov	al, VIA_ACLINK_STAT
 71072 00013D6B E802FFFFFF          <1> 	call	pciRegRead8	
 71073                              <1> 
 71074 00013D70 F6C201              <1>         test    dl, VIA_ACLINK_C00_READY
 71075 00013D73 750B                <1>         jnz     short _crst_ok
 71076                              <1> 
 71077 00013D75 51                  <1> 	push	ecx
 71078 00013D76 E806000000          <1> 	call	delay_100ms
 71079 00013D7B 59                  <1> 	pop	ecx
 71080                              <1> 
 71081 00013D7C 49                  <1>         dec     ecx
 71082 00013D7D 75EA                <1>         jnz     short _crst_wait
 71083                              <1> 
 71084                              <1> _crst_fail:
 71085 00013D7F F9                  <1>         stc
 71086                              <1> _crst_ok:
 71087 00013D80 C3                  <1> 	retn
 71088                              <1> 
 71089                              <1> delay_100ms:
 71090                              <1> 	; 29/05/2017
 71091                              <1> 	; 24/03/2017 ('codec.asm')
 71092                              <1> 	; wait 100 ms
 71093 00013D81 B990010000          <1> 	mov	ecx, 400  ; 400*0.25ms
 71094                              <1> _delay_x_ms:
 71095 00013D86 E803000000          <1> 	call	delay1_4ms
 71096 00013D8B E2F9                <1>         loop	_delay_x_ms
 71097 00013D8D C3                  <1> 	retn
 71098                              <1> 
 71099                              <1> ;       delay1_4ms - Delay for 1/4 millisecond.
 71100                              <1> ;	    1ms = 1000us
 71101                              <1> ;       Entry:
 71102                              <1> ;         None
 71103                              <1> ;       Exit:
 71104                              <1> ;	  None
 71105                              <1> ;
 71106                              <1> ;       Modified:
 71107                              <1> ;         None
 71108                              <1> ;
 71109                              <1> 
 71110                              <1> 	; 29/05/2017
 71111                              <1> 	; 23/04/2017
 71112                              <1> 	; 05/03/2017 (TRDOS 386)
 71113                              <1> 	; ('UTILS.ASM')
 71114                              <1> delay1_4ms:
 71115 00013D8E 50                  <1>         push    eax 
 71116 00013D8F 51                  <1>         push    ecx
 71117 00013D90 B110                <1>         mov	cl, 16		; close enough.
 71118                              <1> 
 71119 00013D92 E461                <1> 	in	al, PORTB ; 61h
 71120                              <1> 		
 71121 00013D94 2410                <1> 	and	al, REFRESH_STATUS ; 10h
 71122 00013D96 88C5                <1> 	mov	ch, al		; Start toggle state
 71123                              <1> _d4ms1:	
 71124 00013D98 E461                <1> 	in	al, PORTB	; Read system control port
 71125                              <1> 	
 71126 00013D9A 2410                <1> 	and	al, REFRESH_STATUS ; Refresh toggles 15.085 microseconds
 71127 00013D9C 38C5                <1> 	cmp	ch, al
 71128 00013D9E 74F8                <1> 	je	short _d4ms1	; Wait for state change
 71129                              <1> 
 71130 00013DA0 88C5                <1> 	mov	ch, al		; Update with new state
 71131 00013DA2 FEC9                <1> 	dec	cl
 71132 00013DA4 75F2                <1> 	jnz	short _d4ms1
 71133                              <1> 
 71134 00013DA6 F8                  <1> 	clc	; 29/05/2017
 71135                              <1> 
 71136 00013DA7 59                  <1>         pop     ecx
 71137 00013DA8 58                  <1>         pop     eax
 71138 00013DA9 C3                  <1>         retn
 71139                              <1> 
 71140                              <1> ; 10/04/2017 (TRDOS 386)
 71141                              <1> ; 12/11/2016
 71142                              <1> 
 71143                              <1> codec_io_w16: ;w32
 71144                              <1> 	; ('codec.asm')
 71145 00013DAA 668B15[AE890100]    <1>         mov	dx, [audio_io_base]
 71146 00013DB1 6681C28000          <1>         add     dx, VIA_REG_AC97
 71147 00013DB6 EF                  <1> 	out	dx, eax
 71148 00013DB7 C3                  <1>         retn
 71149                              <1> 
 71150                              <1> codec_io_r16: ;r32
 71151                              <1> 	; ('codec.asm')
 71152 00013DB8 668B15[AE890100]    <1>         mov     dx, [audio_io_base]
 71153 00013DBF 6681C28000          <1>         add     dx, VIA_REG_AC97
 71154 00013DC4 ED                  <1>         in	eax, dx
 71155 00013DC5 C3                  <1>         retn
 71156                              <1> 
 71157                              <1> ctrl_io_w8:
 71158                              <1> 	; ('codec.asm')
 71159 00013DC6 660315[AE890100]    <1>         add     dx, [audio_io_base]
 71160 00013DCD EE                  <1>         out	dx, al
 71161 00013DCE C3                  <1>         retn
 71162                              <1> 
 71163                              <1> ctrl_io_r8:
 71164                              <1> 	; ('codec.asm')
 71165 00013DCF 660315[AE890100]    <1>         add     dx, [audio_io_base]
 71166 00013DD6 EC                  <1>         in	al, dx
 71167 00013DD7 C3                  <1>         retn
 71168                              <1> 
 71169                              <1> ctrl_io_w32:
 71170                              <1> 	; ('codec.asm')
 71171 00013DD8 660315[AE890100]    <1>         add     dx, [audio_io_base]
 71172 00013DDF EF                  <1>         out	dx, eax
 71173 00013DE0 C3                  <1>         retn
 71174                              <1> 
 71175                              <1> ctrl_io_r32:
 71176                              <1> 	; ('codec.asm')
 71177 00013DE1 660315[AE890100]    <1>         add	dx, [audio_io_base]
 71178 00013DE8 ED                  <1> 	in	eax, dx
 71179                              <1> _cr_not_rdy:	; 06/08/2022
 71180 00013DE9 C3                  <1>         retn
 71181                              <1> 
 71182                              <1> codec_read:
 71183                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71184                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71185                              <1>         ; Use only primary codec.
 71186                              <1>         ; eax = register
 71187 00013DEA C1E010              <1>         shl     eax, VIA_REG_AC97_CMD_SHIFT
 71188 00013DED 0D00008002          <1>         or      eax, VIA_REG_AC97_PRIMARY_VALID + VIA_REG_AC97_READ
 71189                              <1> 
 71190 00013DF2 E8B3FFFFFF          <1> 	call    codec_io_w16
 71191                              <1> 
 71192                              <1>       	; codec_valid
 71193 00013DF7 E828000000          <1> 	call	codec_check_ready
 71194                              <1> 	;jnc	short _cr_ok
 71195                              <1> 	;retn
 71196                              <1> 	; 06/08/2022
 71197 00013DFC 72EB                <1> 	jc	short _cr_not_rdy
 71198                              <1> 	; ecx <= 20
 71199                              <1> _cr_ok:
 71200                              <1> 	; wait 25 ms
 71201                              <1> 	;mov	ecx, 80 ; (100*0.25 ms)
 71202                              <1> 	; 06/08/2022
 71203                              <1> 	;xor	ecx, ecx
 71204 00013DFE B150                <1> 	mov	cl, 80
 71205                              <1> 	; ecx = 80
 71206                              <1> _cr_wloop:
 71207 00013E00 E889FFFFFF          <1> 	call	delay1_4ms
 71208 00013E05 E2F9                <1> 	loop	_cr_wloop
 71209                              <1> 
 71210 00013E07 E8ACFFFFFF          <1>         call    codec_io_r16
 71211                              <1> 	; 06/08/2022
 71212                              <1> 	;and	eax, 0FFFFh
 71213 00013E0C C3                  <1>         retn
 71214                              <1> 
 71215                              <1> codec_write:
 71216                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71217                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71218                              <1>         ; Use only primary codec.
 71219                              <1>         
 71220                              <1> 	; eax = data (volume)
 71221                              <1> 	; edx = register (mixer register)
 71222                              <1> 	
 71223 00013E0D C1E210              <1> 	shl     edx, VIA_REG_AC97_CMD_SHIFT
 71224                              <1> 
 71225 00013E10 C1E000              <1>         shl     eax, VIA_REG_AC97_DATA_SHIFT ; shl eax, 0
 71226 00013E13 09C2                <1>         or      edx, eax
 71227                              <1> 
 71228 00013E15 B800000000          <1>         mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY
 71229 00013E1A C1E01E              <1>         shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
 71230 00013E1D 09D0                <1>         or      eax, edx
 71231                              <1> 
 71232 00013E1F E886FFFFFF          <1>         call    codec_io_w16
 71233                              <1>         ;mov    [codec.regs+esi], ax
 71234                              <1> 
 71235                              <1>         ;call	codec_check_ready
 71236                              <1>        	;retn
 71237                              <1> 	;jmp	short _codec_check_ready	
 71238                              <1> 
 71239                              <1> codec_check_ready:
 71240                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71241                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71242                              <1> 
 71243                              <1> _codec_check_ready:
 71244                              <1> 	;mov	ecx, 20	; total 2s
 71245                              <1> 	; 06/08/2022
 71246 00013E24 29C9                <1> 	sub	ecx, ecx
 71247 00013E26 B114                <1> 	mov	cl, 20
 71248                              <1> _ccr_wait:
 71249 00013E28 51                  <1> 	push	ecx
 71250                              <1> 
 71251 00013E29 E88AFFFFFF          <1>         call    codec_io_r16
 71252 00013E2E A900000001          <1>         test    eax, VIA_REG_AC97_BUSY
 71253 00013E33 740B                <1>         jz      short _ccr_ok
 71254                              <1> 
 71255 00013E35 E847FFFFFF          <1> 	call	delay_100ms
 71256                              <1> 
 71257 00013E3A 59                  <1> 	pop	ecx
 71258                              <1> 
 71259 00013E3B 49                  <1> 	dec     ecx
 71260 00013E3C 75EA                <1>         jnz     short _ccr_wait
 71261                              <1> 
 71262 00013E3E F9                  <1>         stc
 71263 00013E3F C3                  <1>         retn
 71264                              <1> 
 71265                              <1> _ccr_ok:
 71266 00013E40 59                  <1> 	pop	ecx
 71267 00013E41 25FFFF0000          <1> 	and     eax, 0FFFFh
 71268 00013E46 C3                  <1>         retn
 71269                              <1> 
 71270                              <1> codec_config:
 71271                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 71272                              <1> 	; 10/06/2017
 71273                              <1> 	; 29/05/2017
 71274                              <1> 	; 24/04/2017
 71275                              <1> 	; 21/04/2017
 71276                              <1> 	; 16/04/2017 (TRDOS 386 Kernel) 
 71277                              <1> 	; 15/11/2016 ('codec.asm', 'player.com')
 71278                              <1> 	; 14/11/2016
 71279                              <1> 	; 12/11/2016 - Erdogan Tan
 71280                              <1> 	;	     (Ref: KolibriOS, 'setup_codec', codec.inc)
 71281                              <1> 
 71282 00013E47 B802020000          <1> 	mov     eax, 0202h
 71283 00013E4C 66A3[DE890100]      <1> 	mov	[audio_master_volume], ax
 71284 00013E52 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
 71285                              <1> 	;mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
 71286                              <1> 	; 06/08/2022
 71287 00013E56 29D2                <1> 	sub	edx, edx
 71288 00013E58 B202                <1> 	mov	dl, CODEC_MASTER_VOL_REG ; 02h ; Line Out
 71289 00013E5A E8AEFFFFFF          <1> 	call	codec_write
 71290                              <1> 	;jc	short cconfig_error
 71291                              <1> 
 71292                              <1>  	;mov    eax, 0202h
 71293 00013E5F 66B80202            <1> 	mov     ax, 0202h
 71294                              <1> 	;mov	edx, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
 71295                              <1> 	; 06/08/2022
 71296 00013E63 29D2                <1> 	sub	edx, edx
 71297 00013E65 B218                <1> 	mov	dl, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
 71298 00013E67 E8A1FFFFFF          <1> 	call	codec_write
 71299                              <1> 	;jc	short cconfig_error
 71300                              <1>       
 71301                              <1>  	;mov    eax, 0202h
 71302 00013E6C 66B80202            <1> 	mov	ax, 0202h
 71303                              <1> 	;mov	edx, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
 71304                              <1> 	; 06/08/2022
 71305 00013E70 29D2                <1> 	sub	edx, edx
 71306 00013E72 B204                <1> 	mov	dl, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
 71307 00013E74 E894FFFFFF          <1> 	call	codec_write
 71308                              <1> 	;jc	short cconfig_error
 71309                              <1> 
 71310                              <1>  	;mov    eax, 08h
 71311                              <1>         ;mov    ax, 08h
 71312 00013E79 66B80880            <1> 	mov	ax, 8008h ; Mute
 71313                              <1> 	;mov	edx, 0Ch  ; AC97_PHONE_VOL ; TAD Input (Mono)
 71314                              <1> 	; 06/08/2022
 71315 00013E7D 29D2                <1> 	sub	edx, edx
 71316 00013E7F B20C                <1> 	mov	dl, 0Ch	; AC97_PHONE_VOL ; TAD Input (Mono)
 71317 00013E81 E887FFFFFF          <1> 	call	codec_write
 71318                              <1> 	;jc	short cconfig_error
 71319                              <1> 
 71320                              <1>  	;mov    eax, 0808h
 71321 00013E86 66B80808            <1> 	mov	ax, 0808h
 71322                              <1> 	;mov	edx, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
 71323                              <1> 	; 06/08/2022
 71324 00013E8A 29D2                <1> 	sub	edx, edx
 71325 00013E8C B210                <1> 	mov	dl, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
 71326 00013E8E E87AFFFFFF          <1> 	call	codec_write
 71327                              <1> 	;jc	short cconfig_error
 71328                              <1> 
 71329                              <1>  	;mov    eax, 0808h
 71330 00013E93 66B80808            <1> 	mov	ax, 0808h
 71331                              <1> 	;mov	edx, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
 71332                              <1> 	; 06/08/2022
 71333 00013E97 B212                <1> 	mov	dl, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
 71334 00013E99 E86FFFFFFF          <1> 	call	codec_write
 71335                              <1> 	;jc	short cconfig_error
 71336                              <1> 
 71337                              <1>  	;mov    eax, 0808h
 71338 00013E9E 66B80808            <1> 	mov     ax, 0808h
 71339                              <1>         ;mov	edx, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
 71340                              <1> 	; 06/08/2022
 71341 00013EA2 29D2                <1> 	sub	edx, edx
 71342 00013EA4 B216                <1> 	mov	dl, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
 71343                              <1> 	;call	codec_write
 71344                              <1> 	;;jc	short cconfig_error
 71345 00013EA6 E962FFFFFF          <1> 	jmp	codec_write ; 10/06/2017
 71346                              <1> 
 71347                              <1> ;	; Extended Audio Status (2Ah)
 71348                              <1> ;	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
 71349                              <1> ;	call	codec_read
 71350                              <1> ;	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
 71351                              <1> ;	;or     eax, 1			; set VRA (BIT0)
 71352                              <1> ;	or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
 71353                              <1> ;	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
 71354                              <1> ;	call	codec_write
 71355                              <1> ;	;jc	short cconfig_error
 71356                              <1> ;
 71357                              <1> ;set_sample_rate:
 71358                              <1> ;	;movzx	eax, word [audio_freq]
 71359                              <1> ;	mov	ax, [audio_freq]
 71360                              <1> ;	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
 71361                              <1> ;	;call	codec_write
 71362                              <1> ;	;retn
 71363                              <1> ;	jmp	codec_write
 71364                              <1> 	
 71365                              <1> ;cconfig_error:
 71366                              <1> ;	retn
 71367                              <1> 
 71368                              <1> vt8233_int_handler:
 71369                              <1> 	; 27/07/2020
 71370                              <1> 	; 22/07/2020
 71371                              <1> 	; Interrupt Handler for VIA VT8237R Audio Controller
 71372                              <1> 	; Note: called by 'dev_IRQ_service'
 71373                              <1> 	; 14/10/2017 
 71374                              <1> 	; 09/10/2017, 10/10/2017, 12/10/2017
 71375                              <1> 	; 13/06/2017
 71376                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
 71377                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('player.asm') 
 71378                              <1> 
 71379                              <1> 	;push	eax ; * must be saved !
 71380                              <1> 	;push	edx
 71381                              <1> 	;push	ecx
 71382                              <1> 	;push	ebx ; * must be saved !
 71383                              <1> 	;push	esi
 71384                              <1> 	;push	edi
 71385                              <1> 
 71386                              <1> 	;cmp	byte [audio_busy], 1
 71387                              <1> 	;jnb	short _ih0 ; 09/10/2017
 71388                              <1> 
 71389                              <1> 	;mov	byte [audio_flag_eol], 0
 71390                              <1> 
 71391 00013EAB 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
 71392 00013EAF E81BFFFFFF          <1>         call    ctrl_io_r8
 71393                              <1> 
 71394 00013EB4 A880                <1> 	test    al, VIA_REG_STAT_ACTIVE
 71395 00013EB6 7417                <1>         jz      short _ih0 ; 09/10/2017
 71396                              <1> 
 71397 00013EB8 2407                <1>         and     al, VIA_REG_STAT_EOL + VIA_REG_STAT_FLAG + VIA_REG_STAT_STOPPED
 71398 00013EBA A2[DD890100]        <1> 	mov	[audio_flag_eol], al
 71399 00013EBF 740E                <1>         jz	short _ih0 ; 09/10/2017
 71400                              <1> 
 71401                              <1> 	; 09/10/2017
 71402                              <1> 	;mov	byte [audio_busy], 1
 71403                              <1> 
 71404 00013EC1 803D[DC890100]01    <1> 	cmp	byte [audio_play_cmd], 1
 71405 00013EC8 7315                <1> 	jnb	short _ih1 ; 10/10/2017
 71406                              <1> 
 71407 00013ECA E84A000000          <1> 	call	channel_reset
 71408                              <1> _ih0:
 71409                              <1> 	; 09/10/2017
 71410 00013ECF A0[DD890100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
 71411 00013ED4 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
 71412 00013ED8 E8E9FEFFFF          <1>         call    ctrl_io_w8
 71413 00013EDD EB39                <1> 	jmp	short _ih4
 71414                              <1> _ih1:
 71415                              <1> vt8233_tuneLoop:
 71416 00013EDF A0[DD890100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
 71417 00013EE4 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
 71418 00013EE8 E8D9FEFFFF          <1>         call    ctrl_io_w8
 71419                              <1> 
 71420                              <1> 	; 22/07/2020
 71421                              <1> 	;; 12/10/2017
 71422                              <1> 	;mov	byte [audio_flag], 0 ; Reset	
 71423                              <1> 
 71424                              <1> 	; 10/10/2017
 71425                              <1> 	; 09/10/2017
 71426                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_FLAG
 71427                              <1> 	;jz	short _ih2 ; EOL
 71428                              <1> 
 71429                              <1> 	; 22/07/2020
 71430                              <1> 	; 14/10/2017
 71431                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_EOL
 71432                              <1> 	;jnz	short _ih2 ; EOL
 71433                              <1> 	;		   ; (Half Buffer 2 has been completed 
 71434                              <1> 	;		   ; and Half Buffer 1 will be played.)
 71435                              <1> 	
 71436                              <1> 	; FLAG  
 71437                              <1> 	; (Half Buffer 1 has been completed 
 71438                              <1> 	;  and Half Buffer 2 will be played.)
 71439                              <1> 
 71440                              <1> 	; 14/10/2017
 71441                              <1> 	;; (Continue to play.)
 71442                              <1> 	;mov	al, VIA_REG_CTRL_INT
 71443                              <1>        	;or	al, VIA_REG_CTRL_START
 71444                              <1>        	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
 71445                              <1>         ;call	ctrl_io_w8
 71446                              <1> 	; 12/10/2017
 71447                              <1> 	;mov	byte [audio_flag], 1 
 71448                              <1> 
 71449                              <1> 	; 22/07/2020
 71450                              <1> 	;inc	byte [audio_flag] ; = 1
 71451                              <1> _ih2: 
 71452                              <1> 	; 10/10/2017
 71453 00013EED 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff]
 71454 00013EF3 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size]
 71455 00013EF9 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
 71456                              <1> 	
 71457                              <1> 	; 22/07/2020
 71458                              <1> 	; 12/10/2017
 71459                              <1> 	;cmp	byte [audio_flag], 0
 71460                              <1> 	;ja	short _ih3 ; Playing Half Buffer 2 (Current: FLAG)
 71461                              <1> 	
 71462                              <1> 	; 27/07/2020
 71463                              <1> 	; 22/07/2020
 71464 00013EFB F605[D0890100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
 71465 00013F02 7402                <1> 	jz	short _ih3 ; Half Buffer 1 must be filled
 71466                              <1> 
 71467                              <1> 	; Half Buffer 2 must be filled
 71468 00013F04 01CF                <1> 	add	edi, ecx
 71469                              <1> _ih3:
 71470                              <1> 	; Update half buffer 2 while playing half buffer 1
 71471                              <1> 	; Update half buffer 1 while playing half buffer 2
 71472                              <1> 
 71473 00013F06 8B35[C0890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
 71474 00013F0C C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
 71475 00013F0F F3A5                <1> 	rep	movsd
 71476                              <1> 
 71477                              <1> 	; switch flag value ;
 71478 00013F11 8035[D0890100]01    <1> 	xor	byte [audio_flag], 1
 71479                              <1> 	; 12/10/2017
 71480                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2
 71481                              <1> 			   ; Next buffer (to update) is dma half buff 1
 71482                              <1> 	; 	       = 1 : Playing dma half buffer 1
 71483                              <1> 			   ; Next buffer (to update) is dma half buff 2
 71484                              <1> _ih4:	
 71485                              <1> 	; 28/05/2017
 71486                              <1> 	;mov	byte [audio_busy], 0 ; 09/10/2017
 71487                              <1> 	;
 71488                              <1> 	;pop	edi
 71489                              <1> 	;pop	esi
 71490                              <1> 	;pop	ebx ; * must be restored !
 71491                              <1> 	;pop	ecx
 71492                              <1> 	;pop	edx
 71493                              <1> 	;pop	eax ; * must be restored !
 71494                              <1> 
 71495 00013F18 C3                  <1> 	retn
 71496                              <1> 
 71497                              <1> channel_reset:
 71498                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 71499                              <1> 	; 24/06/2017
 71500                              <1> 	; 29/05/2017
 71501                              <1> 	; 23/03/2017
 71502                              <1> 	; 14/11/2016 - Erdogan Tan
 71503                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
 71504                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
 71505                              <1> 	; 06/08/2022
 71506 00013F19 29D2                <1> 	sub	edx, edx
 71507 00013F1B B201                <1> 	mov	dl, VIA_REG_OFFSET_CONTROL 
 71508                              <1> 	;mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE + VIA_REG_CTRL_RESET
 71509 00013F1D B848000000          <1>         mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE ; 24/06/2017       
 71510 00013F22 E89FFEFFFF          <1> 	call    ctrl_io_w8
 71511                              <1> 
 71512                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
 71513                              <1>         ;call   ctrl_io_r8
 71514                              <1> 
 71515                              <1> 	; wait for 50 ms
 71516                              <1> 	;mov	ecx, 160 ; (200*0.25 ms) ; 29/05/2017	
 71517                              <1> 	; 06/08/2022
 71518 00013F27 31C9                <1> 	xor	ecx, ecx
 71519 00013F29 B1A0                <1> 	mov	cl, 160
 71520                              <1> _ch_rst_wait:
 71521 00013F2B E85EFEFFFF          <1> 	call	delay1_4ms
 71522 00013F30 49                  <1> 	dec	ecx
 71523 00013F31 75F8                <1> 	jnz	short _ch_rst_wait     
 71524                              <1> 
 71525                              <1>         ; disable interrupts
 71526                              <1> 	;mov	edx, VIA_REG_OFFSET_CONTROL
 71527                              <1>         ; 06/08/2022
 71528 00013F33 29D2                <1> 	sub	edx, edx
 71529 00013F35 B201                <1> 	mov	dl, VIA_REG_OFFSET_CONTROL
 71530 00013F37 31C0                <1>  	xor     eax, eax
 71531 00013F39 E888FEFFFF          <1>         call    ctrl_io_w8
 71532                              <1> 
 71533                              <1>         ; clear interrupts
 71534                              <1>         ;mov	edx, VIA_REG_OFFSET_STATUS
 71535                              <1> 	; 06/08/2022
 71536 00013F3E 29D2                <1> 	sub	edx, edx
 71537                              <1> 	;mov	dl, VIA_REG_OFFSET_STATUS ; 0
 71538                              <1> 	; edx = 0
 71539                              <1> 	;mov	eax, 3
 71540                              <1>         ; 06/08/2022
 71541 00013F40 29C0                <1> 	sub	eax, eax
 71542 00013F42 B003                <1> 	mov	al, 3
 71543                              <1> 	; eax = 3
 71544 00013F44 E87DFEFFFF          <1> 	call	ctrl_io_w8
 71545                              <1> 
 71546                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_PTR
 71547                              <1> 	;xor	eax, eax
 71548                              <1> 	;call	ctrl_io_w32
 71549                              <1> 
 71550 00013F49 C3                  <1>         retn	
 71551                              <1> 
 71552                              <1> vt8233_stop: ; 22/04/2017
 71553 00013F4A C605[DC890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
 71554                              <1> _tlp2:
 71555                              <1> 	; 24/06/2017
 71556                              <1>         ; finished with song, stop everything
 71557                              <1> 	;mov	al, VIA_REG_CTRL_INT
 71558                              <1>         ;or	al, VIA_REG_CTRL_TERMINATE
 71559                              <1> 	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
 71560                              <1>         ;call	ctrl_io_w8
 71561                              <1> 
 71562                              <1>         ;call	channel_reset
 71563                              <1> 	;retn
 71564                              <1> 
 71565 00013F51 EBC6                <1> 	jmp	short channel_reset
 71566                              <1> 
 71567                              <1> set_vt8233_bdl: ; Set VT8237R Buffer Descriptor List
 71568                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71569                              <1> 	; 22/07/2020 - TRDOS 386 v2.0.2
 71570                              <1> 	; 28/05/2017
 71571                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
 71572                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
 71573                              <1> 	
 71574                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
 71575                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
 71576                              <1> 
 71577 00013F53 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
 71578 00013F55 89CE                <1> 	mov	esi, ecx
 71579                              <1> 
 71580 00013F57 BF[E4890100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
 71581                              <1> 	;mov	ecx, 32 / 2		; make 32 entries in BDL
 71582                              <1> 	; 06/08/2022
 71583 00013F5C 29C9                <1> 	sub	ecx, ecx
 71584 00013F5E B110                <1> 	mov	cl, 16
 71585                              <1> 
 71586 00013F60 EB05                <1> 	jmp	short s_vt8233_bdl1 
 71587                              <1> 
 71588                              <1> s_vt8233_bdl0:
 71589                              <1> 	; set buffer descriptor 0 to start of data file in memory
 71590                              <1> 
 71591 00013F62 A1[C8890100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
 71592                              <1>  
 71593                              <1> s_vt8233_bdl1:
 71594 00013F67 AB                  <1> 	stosd				; store dmabuffer1 address
 71595                              <1> 
 71596 00013F68 89C2                <1> 	mov	edx, eax
 71597                              <1> 
 71598                              <1> ; VIA VT8235.PDF: (Page 110) (Erdogan Tan, 29/11/2016)
 71599                              <1> 	;
 71600                              <1> 	; 	Audio SGD Table Format
 71601                              <1> 	;	-------------------------------
 71602                              <1> 	;	63   62    61-56    55-32  31-0
 71603                              <1> 	;	--   --   --------  -----  ----
 71604                              <1> 	;	EOL FLAG -reserved- Base   Base
 71605                              <1> 	;		    	    Count  Address
 71606                              <1> 	;		            [23:0] [31:0]
 71607                              <1> 	;	EOL: End Of Link. 
 71608                              <1> 	;	     1 indicates this block is the last of the link.
 71609                              <1> 	;	     If the channel Interrupt on EOL bit is set, then
 71610                              <1> 	;	     an interrupt is generated at the end of the transfer.
 71611                              <1> 	;
 71612                              <1> 	;	FLAG: Block Flag. If set, transfer pauses at the end of this
 71613                              <1> 	;	      block. If the channel Interrupt on FLAG bit is set,
 71614                              <1> 	;	      then an interrupt is generated at the end of this block.
 71615                              <1> 
 71616 00013F6A 89F0                <1> 	mov	eax, esi ; DMA half buffer size
 71617 00013F6C 01C2                <1> 	add	edx, eax
 71618 00013F6E 0D00000040          <1> 	or	eax, FLAG
 71619                              <1> 	;or	eax, EOL
 71620 00013F73 AB                  <1> 	stosd
 71621                              <1> 
 71622                              <1> ; 2nd buffer:
 71623                              <1> 
 71624 00013F74 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
 71625 00013F76 AB                  <1> 	stosd		 ; store dmabuffer2 address
 71626                              <1> 
 71627                              <1> ; set length to [audio_dmabuff_size]/2
 71628                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
 71629                              <1> ; 
 71630 00013F77 89F0                <1> 	mov	eax, esi ; DMA half buffer size
 71631                              <1> 	; 22/07/2020
 71632                              <1> 	;or	eax, EOL
 71633 00013F79 0D00000040          <1> 	or	eax, FLAG
 71634 00013F7E AB                  <1> 	stosd
 71635                              <1> 
 71636 00013F7F E2E1                <1> 	loop    s_vt8233_bdl0
 71637                              <1> 
 71638                              <1> 	; 22/07/2020
 71639 00013F81 814FFC00000080      <1> 	or	dword [edi-4], EOL
 71640                              <1> 	
 71641 00013F88 C3                  <1> 	retn
 71642                              <1> 
 71643                              <1> vt8233_start_play:
 71644                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 71645                              <1> 	; 01/09/2020 
 71646                              <1> 	; 22/07/2020 
 71647                              <1> 	; start to play audio data via VT8233 audio controller
 71648                              <1> 	; 13/06/2017
 71649                              <1> 	; 10/06/2017
 71650                              <1> 	; 24/04/2017 
 71651                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
 71652                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
 71653                              <1> 	; write buffer descriptor list address
 71654                              <1> 
 71655                              <1> 	; Extended Audio Status (2Ah)
 71656 00013F89 B82A000000          <1> 	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
 71657 00013F8E E857FEFFFF          <1> 	call	codec_read
 71658 00013F93 25FDFF0000          <1> 	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
 71659                              <1> 	;or     eax, 1			; set VRA (BIT0)
 71660                              <1> 	;or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
 71661 00013F98 0C05                <1> 	or	al, 5
 71662                              <1> 	; 01/09/2020	
 71663                              <1> 	;or	eax, 3805h ; AD1980 (PRK, PRJ, PRI = 1 .. only front DAC)
 71664                              <1> 	; 01/09/2020
 71665                              <1> 	;mov	edx, CODEC_EXT_AUDIO_CTRL_REG
 71666                              <1> 	;cmp	word [audio_freq], 0BB80h ; 48 kHz
 71667                              <1> 	;jne	short set_extd_audio_status_1
 71668                              <1> 	;and	al, 0FEh ; disable VRA bit (set sample rate to 48000 Hz)
 71669                              <1> 	;jmp	short set_extd_audio_status_2
 71670                              <1> ;set_extd_audio_status_1:
 71671 00013F9A BA2A000000          <1> 	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
 71672 00013F9F E869FEFFFF          <1> 	call	codec_write
 71673                              <1> 	;jc	short cconfig_error
 71674                              <1> 
 71675                              <1> set_sample_rate:
 71676                              <1> 	;movzx	eax, word [audio_freq]
 71677 00013FA4 66A1[DA890100]      <1> 	mov	ax, [audio_freq]
 71678 00013FAA BA2C000000          <1> 	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
 71679                              <1> ;set_extd_audio_status_2:
 71680 00013FAF E859FEFFFF          <1> 	call	codec_write
 71681                              <1> 
 71682                              <1> 	; 01/09/2020
 71683                              <1> 	; set AD1980 MCB register (Index 76h) to 0C00h
 71684                              <1> 	; (CLDIS, HPSEL)
 71685                              <1> 	;mov	ax, 0C00h
 71686                              <1> 	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h 
 71687                              <1> 	;			; Miscellaneous Control Bit Register
 71688                              <1> 	;call	codec_write
 71689                              <1> 	;
 71690                              <1> 
 71691 00013FB4 B8[E4890100]        <1>         mov	eax, audio_bdl_buff
 71692                              <1>   
 71693                              <1> 	; 12/11/2016 - Erdogan Tan 
 71694                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
 71695                              <1> 	;mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
 71696                              <1>         ; 06/08/2022
 71697 00013FB9 29D2                <1> 	sub	edx, edx
 71698                              <1> 	;mov	dl, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
 71699                              <1> 	; edx = 0
 71700 00013FBB E818FEFFFF          <1> 	call	ctrl_io_w32
 71701                              <1> 
 71702                              <1> 	;call	codec_check_ready
 71703                              <1> 
 71704 00013FC0 66BA0200            <1>   	mov	dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_L
 71705                              <1>         ;mov	eax, 2	; 31
 71706 00013FC4 B01F                <1> 	mov	al, 31
 71707 00013FC6 2A05[DE890100]      <1>         sub	al, [audio_master_volume_l]
 71708 00013FCC E8F5FDFFFF          <1> 	call	ctrl_io_w8
 71709                              <1> 
 71710                              <1> 	;call	codec_check_ready
 71711                              <1> 
 71712 00013FD1 66BA0300            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_R
 71713                              <1>         ;mov	ax, 2	; 31
 71714 00013FD5 B01F                <1> 	mov	al, 31
 71715 00013FD7 2A05[DF890100]      <1>         sub	al, [audio_master_volume_r]
 71716 00013FDD E8E4FDFFFF          <1> 	call    ctrl_io_w8
 71717                              <1> 
 71718                              <1> 	;call	codec_check_ready
 71719                              <1> ;
 71720                              <1> ;
 71721                              <1> ; All set. Let's play some music.
 71722                              <1> ;
 71723                              <1> ;
 71724                              <1>        	;mov    dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
 71725                              <1>         ;mov    ax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
 71726                              <1>         ;call   ctrl_io_w32
 71727                              <1> 
 71728                              <1> 	;call	codec_check_ready
 71729                              <1> 
 71730                              <1> 	; 08/12/2016
 71731                              <1> 	; 07/10/2016
 71732                              <1>         ;;mov    al, 1
 71733                              <1>         ;mov	al, 31
 71734                              <1> 	; 22/07/2020
 71735 00013FE2 B0FF                <1> 	mov	al, 0FFh
 71736 00013FE4 E813000000          <1> 	call    set_VT8233_LastValidIndex
 71737                              <1> 
 71738 00013FE9 C605[DC890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
 71739                              <1> 
 71740                              <1> 	; 22/07/2020
 71741                              <1> 	;mov	byte [audio_flag], 0  ; clear half buffer flag
 71742                              <1> 
 71743                              <1> vt8233_play: ; continue to play
 71744                              <1> 	; 22/04/2017
 71745                              <1> 	;mov	al, VIA_REG_CTRL_INT
 71746                              <1>        	;or	al, VIA_REG_CTRL_START
 71747                              <1>         ;;mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START
 71748                              <1> 	; 22/07/2020	
 71749 00013FF0 B0A1                <1> 	mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START + VIA_REG_CTRL_INT_FLAG
 71750                              <1> 
 71751 00013FF2 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
 71752 00013FF6 E8CBFDFFFF          <1>         call    ctrl_io_w8
 71753                              <1> 	;call	codec_check_ready
 71754                              <1> 	;retn
 71755                              <1> 	;jmp	codec_check_ready
 71756 00013FFB C3                  <1> 	retn
 71757                              <1> 
 71758                              <1> ;input AL = index # to stop on
 71759                              <1> set_VT8233_LastValidIndex:
 71760                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
 71761                              <1> 	; 23/07/2020
 71762                              <1> 	; 10/06/2017
 71763                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
 71764                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
 71765                              <1> 	; 19/11/2016
 71766                              <1> 	; 14/11/2016 - Erdogan Tan (Ref: VIA VT8235.PDF, Page 110)
 71767                              <1> 	; 12/11/2016 - Erdogan Tan
 71768                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
 71769                              <1> 	;push	edx
 71770                              <1> 	;push	ax
 71771 00013FFC 50                  <1> 	push	eax ; 23/07/2020
 71772                              <1> 	;push	ecx
 71773 00013FFD 0FB705[DA890100]    <1> 	movzx	eax, word [audio_freq] ; Hertz
 71774 00014004 BA00001000          <1> 	mov	edx, 100000h ; 2^20 = 1048576
 71775 00014009 F7E2                <1> 	mul	edx
 71776 0001400B B980BB0000          <1> 	mov	ecx, 48000	
 71777 00014010 F7F1                <1> 	div	ecx
 71778                              <1> 	;and	eax, 0FFFFFh
 71779                              <1> 	;pop	ecx
 71780                              <1> 	;pop	dx 
 71781 00014012 5A                  <1> 	pop	edx ; 23/07/2020
 71782 00014013 C1E218              <1> 	shl	edx, 24  ; STOP Index Setting: Bit 24 to 31
 71783 00014016 09D0                <1> 	or	eax, edx
 71784                              <1> 	; 19/11/2016
 71785 00014018 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16
 71786 0001401F 7505                <1> 	jne	short sLVI_1
 71787 00014021 0D00002000          <1> 	or	eax, VIA8233_REG_TYPE_16BIT
 71788                              <1> sLVI_1:
 71789 00014026 803D[D9890100]02    <1> 	cmp	byte [audio_stmo], 2
 71790 0001402D 7505                <1> 	jne	short sLVI_2
 71791 0001402F 0D00001000          <1> 	or	eax, VIA8233_REG_TYPE_STEREO
 71792                              <1> sLVI_2:
 71793                              <1> 	;mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
 71794                              <1> 	; 06/08/2022
 71795 00014034 29D2                <1> 	sub	edx, edx
 71796 00014036 B208                <1> 	mov	dl, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
 71797 00014038 E89BFDFFFF          <1> 	call    ctrl_io_w32
 71798                              <1> 	;call	codec_check_ready
 71799                              <1> 	;pop	edx
 71800 0001403D C3                  <1> 	retn
 71801                              <1> 
 71802                              <1> vt8233_pause: ; pause
 71803                              <1> 	; 10/06/2017
 71804                              <1> 	; 22/04/2017
 71805                              <1> 	;mov	al, VIA_REG_CTRL_INT
 71806                              <1>         ;or	al, VIA_REG_CTRL_PAUSE
 71807                              <1> 	; 23/07/2020
 71808 0001403E B029                <1> 	mov	al, VIA_REG_CTRL_PAUSE+VIA_REG_CTRL_INT_FLAG+VIA_REG_CTRL_AUTOSTART
 71809                              <1> 	
 71810 00014040 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
 71811 00014044 E87DFDFFFF          <1>         call    ctrl_io_w8
 71812                              <1> 	;call	codec_check_ready
 71813                              <1> 	;retn
 71814                              <1> 	;jmp	codec_check_ready
 71815 00014049 C3                  <1> 	retn
 71816                              <1> 
 71817                              <1> vt8233_reset: 
 71818                              <1> 	; 22/04/2017
 71819                              <1> 	; reset VT8237R (vt8233) Audio Controller
 71820                              <1> 	;cmp	byte [audio_play_cmd], 1
 71821                              <1> 	;jna	short vt8233_rst_0
 71822 0001404A C605[DC890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
 71823                              <1> vt8233_rst_0:
 71824 00014051 E8D0FCFFFF          <1> 	call	reset_codec
 71825 00014056 720A                <1> 	jc	short vt8233_rst_1 ; codec error !
 71826                              <1> 	; eax = 1
 71827 00014058 E84DFDFFFF          <1> 	call	codec_io_w16 ; w32
 71828 0001405D E8B7FEFFFF          <1> 	call	channel_reset
 71829                              <1> vt8233_rst_1:
 71830                              <1> vt8233_vol_1:	; 06/08/2022
 71831 00014062 C3                  <1> 	retn
 71832                              <1> 
 71833                              <1> vt8233_volume:
 71834                              <1> 	; set VT8237R (vt8233) sound volume level
 71835                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71836                              <1> 	; 24/04/2017
 71837                              <1> 	; 22/04/2017
 71838                              <1> 	; bl = component (0 = master/playback/lineout volume)
 71839                              <1> 	; cl = left channel volume level (0 to 31)
 71840                              <1> 	; ch = right channel volume level (0 to 31)
 71841                              <1> 
 71842 00014063 08DB                <1> 	or	bl, bl
 71843 00014065 75FB                <1> 	jnz	short vt8233_vol_1 ; temporary !
 71844 00014067 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
 71845 0001406B 38C1                <1> 	cmp	cl, al
 71846 0001406D 77F3                <1> 	ja	short vt8233_vol_1 ; temporary !
 71847 0001406F 38E5                <1> 	cmp	ch, ah
 71848 00014071 77EF                <1> 	ja	short vt8233_vol_1 ; temporary !
 71849 00014073 66890D[DE890100]    <1> 	mov	[audio_master_volume], cx
 71850 0001407A 6629C8              <1> 	sub	ax, cx
 71851                              <1> 	;mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
 71852                              <1> 	; 06/08/2022
 71853 0001407D 29D2                <1> 	sub	edx, edx
 71854 0001407F B202                <1> 	mov	dl, CODEC_MASTER_VOL_REG ; 02h ; Line Out
 71855                              <1> 	; 06/08/2022
 71856 00014081 E987FDFFFF          <1> 	jmp	codec_write
 71857                              <1> 	;call	codec_write
 71858                              <1> ;vt8233_vol_1:
 71859                              <1> 	;retn
 71860                              <1> 
 71861                              <1> ; CODE for SOUND BLASTER 16
 71862                              <1> 
 71863                              <1> DetectSB:
 71864                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 71865                              <1> 	; 24/04/2017
 71866                              <1> 	;pushad
 71867                              <1> ScanPort:
 71868                              <1> 	; 06/08/2022
 71869 00014086 66BB1002            <1> 	mov	bx, 0210h	; start scanning ports
 71870                              <1> 				; 210h, 220h, .. 260h
 71871                              <1> 	; 06/08/2022
 71872 0001408A 31C9                <1> 	xor	ecx, ecx
 71873 0001408C 88FE                <1> 	mov	dh, bh
 71874                              <1> ResetDSP:       
 71875                              <1> 	;mov	dx, bx		; try to reset the DSP.
 71876                              <1> 	;add	dx, 06h
 71877                              <1> 	; 06/08/2022
 71878 0001408E 88DA                <1> 	mov	dl, bl
 71879 00014090 80C206              <1> 	add	dl, 06h
 71880                              <1> 
 71881 00014093 B001                <1> 	mov	al, 1
 71882 00014095 EE                  <1> 	out	dx, al
 71883                              <1> 
 71884 00014096 EC                  <1> 	in	al, dx
 71885 00014097 EC                  <1> 	in	al, dx
 71886 00014098 EC                  <1> 	in	al, dx
 71887 00014099 EC                  <1> 	in	al, dx
 71888                              <1> 
 71889 0001409A 30C0                <1> 	xor     al, al
 71890 0001409C EE                  <1> 	out	dx, al
 71891                              <1> 
 71892                              <1> 	;add	dx, 08h
 71893                              <1> 	; 06/08/2022
 71894 0001409D 80C208              <1> 	add	dl, 08h
 71895                              <1> 	;mov	cx, 100
 71896 000140A0 B164                <1> 	mov	cl, 100
 71897                              <1> WaitID:
 71898 000140A2 EC                  <1> 	in	al, dx
 71899 000140A3 08C0                <1> 	or      al, al
 71900 000140A5 7804                <1> 	js      short GetID
 71901 000140A7 E2F9                <1> 	loop    WaitID
 71902 000140A9 EB0D                <1> 	jmp     short NextPort
 71903                              <1> GetID:          
 71904                              <1> 	;sub	dx, 04h
 71905                              <1> 	; 06/08/2022
 71906 000140AB 80EA04              <1> 	sub	dl, 04h
 71907 000140AE EC                  <1> 	in	al, dx
 71908 000140AF 3CAA                <1> 	cmp     al, 0AAh
 71909 000140B1 740F                <1> 	je      short Found
 71910                              <1> 	;add	dx, 04h
 71911                              <1> 	; 06/08/2022
 71912 000140B3 80C204              <1> 	add	dl, 04h
 71913 000140B6 E2EA                <1> 	loop    WaitID
 71914                              <1> NextPort:
 71915                              <1> 	;add	bx, 10h		; if not response,
 71916                              <1> 	; 06/08/2022
 71917 000140B8 80C310              <1> 	add	bl, 10h
 71918                              <1> 	;cmp	bx, 260h	; try the next port.
 71919 000140BB 80FB60              <1> 	cmp	bl, 60h
 71920 000140BE 76CE                <1> 	jbe     short ResetDSP
 71921 000140C0 F9                  <1> 	stc
 71922 000140C1 C3                  <1> 	retn
 71923                              <1> Found:
 71924 000140C2 66891D[AE890100]    <1> 	mov     [audio_io_base], bx	; SB Port Address Found!
 71925                              <1> ScanIRQ:
 71926                              <1> SetIrqs:
 71927 000140C9 28C0                <1> 	sub 	al, al ; 0
 71928 000140CB A2[A4890100]        <1> 	mov 	[IRQnum], al ; reset
 71929 000140D0 A2[AB890100]        <1> 	mov	[audio_intr], al ; reset
 71930                              <1> 
 71931                              <1> 	; ah > 0 -> set IRQ vector
 71932                              <1> 	; al = IRQ number
 71933                              <1> 	;mov	ax, 103h ; IRQ 3
 71934                              <1> 	;call	set_hardware_int_vector
 71935                              <1> 	;mov	ax, 104h ; IRQ 4
 71936                              <1> 	;call	set_hardware_int_vector
 71937 000140D5 66B80501            <1> 	mov	ax, 105h ; IRQ 5
 71938 000140D9 E8A9E1FFFF          <1> 	call	set_hardware_int_vector
 71939 000140DE 66B80701            <1> 	mov	ax, 107h ; IRQ 7
 71940 000140E2 E8A0E1FFFF          <1> 	call	set_hardware_int_vector
 71941                              <1> 
 71942 000140E7 668B15[AE890100]    <1> 	mov     dx, [audio_io_base] ; tells to the SB to
 71943                              <1> 	;add	dx, 0Ch		    ; generate a IRQ!
 71944                              <1> 	; 06/08/2022
 71945 000140EE 80C20C              <1> 	add	dl, 0Ch
 71946                              <1> WaitSb:
 71947 000140F1 EC                  <1> 	in	al, dx
 71948 000140F2 08C0                <1> 	or      al, al
 71949 000140F4 78FB                <1> 	js      short WaitSb
 71950 000140F6 B0F2                <1> 	mov     al, 0F2h
 71951 000140F8 EE                  <1> 	out	dx, al
 71952                              <1> 
 71953 000140F9 31C9                <1> 	xor     ecx, ecx	; wait until IRQ level
 71954                              <1> WaitIRQ: 
 71955 000140FB A0[A4890100]        <1> 	mov	al, [IRQnum]
 71956 00014100 3C00                <1> 	cmp     al, 0 ; is changed or timeout.
 71957 00014102 7706                <1> 	ja	short IrqOk
 71958 00014104 6649                <1> 	dec	cx
 71959 00014106 75F3                <1> 	jnz	short WaitIRQ
 71960 00014108 EB14                <1> 	jmp	short RestoreIrqs
 71961                              <1> IrqOk:
 71962 0001410A A2[AB890100]        <1> 	mov	[audio_intr], al ; set   
 71963 0001410F 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 71964                              <1> 	;add	dx, 0Eh
 71965                              <1> 	; 06/08/2022
 71966 00014116 80C20E              <1> 	add	dl, 0Eh
 71967 00014119 EC                  <1> 	in	al, dx	; SB acknowledge.
 71968 0001411A B020                <1> 	mov	al, 20h
 71969 0001411C E620                <1> 	out	20h, al	; Hardware acknowledge.
 71970                              <1> 
 71971                              <1> RestoreIrqs:
 71972                              <1> 	; ah = 0 -> reset IRQ vector
 71973                              <1> 	; al = IRQ number
 71974                              <1> 	;mov	ax, 3 ; IRQ 3
 71975                              <1> 	;call	set_hardware_int_vector
 71976                              <1> 	;mov	ax, 4 ; IRQ 4
 71977                              <1> 	;call	set_hardware_int_vector
 71978 0001411E 66B80500            <1> 	mov	ax, 5 ; IRQ 5
 71979 00014122 E860E1FFFF          <1> 	call	set_hardware_int_vector
 71980 00014127 66B80700            <1> 	mov	ax, 7 ; IRQ 7
 71981 0001412B E857E1FFFF          <1> 	call	set_hardware_int_vector
 71982                              <1> 
 71983 00014130 31D2                <1> 	xor	edx, edx
 71984 00014132 8915[B0890100]      <1> 	mov	[audio_dev_id], edx ; 0
 71985 00014138 8915[B4890100]      <1> 	mov	[audio_vendor], edx ; 0
 71986 0001413E 8915[B8890100]      <1> 	mov	[audio_stats_cmd], edx ; 0
 71987                              <1> 
 71988                              <1> 	;popad
 71989                              <1> 
 71990 00014144 803D[AB890100]01    <1> 	cmp     byte [audio_intr], 1 ; IRQ level was changed?
 71991                              <1> 	
 71992 0001414B C3                  <1> 	retn
 71993                              <1> 
 71994                              <1> %macro	SbOut	1
 71995                              <1> %%Wait:
 71996                              <1> 	in	al, dx
 71997                              <1> 	or	al, al
 71998                              <1> 	js	short %%Wait
 71999                              <1> 	mov	al, %1
 72000                              <1> 	out	dx, al
 72001                              <1> %endmacro
 72002                              <1> 
 72003                              <1> SbInit_play:
 72004                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5 
 72005                              <1> 	; 22/10/2017
 72006                              <1> 	; 20/10/2017
 72007                              <1> 	; 06/10/2017
 72008                              <1> 	; 13/07/2017 - 09/08/2017
 72009                              <1> 	; 24/04/2017 - 15/05/2017 - 24/06/2017
 72010                              <1> 	;pushad
 72011                              <1> SetBuffer:
 72012                              <1> 	;mov	byte [DmaFlag], 0
 72013                              <1> 
 72014 0001414C 8B1D[C8890100]      <1> 	mov	ebx, [audio_dma_buff] ; physical addr of DMA buff
 72015 00014152 89DF                <1> 	mov	edi, ebx
 72016 00014154 8B0D[CC890100]      <1> 	mov     ecx, [audio_dmabuff_size]
 72017                              <1> 
 72018 0001415A 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16
 72019 00014161 7531                <1> 	jne	short sbInit_0 ; set 8 bit DMA buffer
 72020                              <1> 	
 72021                              <1> 	; 09/08/2017
 72022                              <1> 	; convert byte count to word count
 72023 00014163 D1E9                <1> 	shr	ecx, 1
 72024 00014165 49                  <1> 	dec	ecx ; word count - 1
 72025                              <1> 	; convert byte offset to word offset
 72026 00014166 D1EB                <1> 	shr	ebx, 1
 72027                              <1> 
 72028                              <1> 	; 16 bit DMA buffer setting (DMA channel 5)
 72029 00014168 B005                <1> 	mov     al, 05h  ; set mask bit for channel 5  (4+1)
 72030 0001416A E6D4                <1> 	out	0D4h, al
 72031                              <1> 	
 72032 0001416C 30C0                <1> 	xor     al, al   ; stops all DMA processes on selected channel
 72033 0001416E E6D8                <1> 	out	0D8h, al ; clear selected channel register
 72034                              <1> 
 72035 00014170 88D8                <1> 	mov     al, bl	 ; byte 0 of DMA buffer offset in words (physical) 
 72036 00014172 E6C4                <1> 	out	0C4h, al ; DMA channel 5 port number
 72037                              <1> 
 72038 00014174 88F8                <1> 	mov     al, bh   ; byte 1 of DMA buffer offset in words (physical)   
 72039 00014176 E6C4                <1> 	out	0C4h, al
 72040                              <1> 	
 72041                              <1> 	; 09/08/2017
 72042 00014178 C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
 72043 0001417B 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary, it will be ignored)
 72044                              <1> 
 72045 0001417E 88D8                <1> 	mov     al, bl   ; byte 2 of DMA buffer address (physical) 
 72046 00014180 E68B                <1> 	out	8Bh, al  ; page register port addr for channel 5 ; 13/07/2017
 72047                              <1> 
 72048 00014182 88C8                <1> 	mov     al, cl   ; low byte of DMA count - 1
 72049 00014184 E6C6                <1> 	out	0C6h, al ; count register port addr for channel 1
 72050                              <1> 
 72051 00014186 88E8                <1> 	mov     al, ch   ; high byte of DMA count - 1
 72052 00014188 E6C6                <1> 	out	0C6h, al
 72053                              <1> 
 72054                              <1> 	; channel 5, read, autoinitialized, single mode
 72055                              <1> 	;mov	al, 49h
 72056 0001418A B059                <1> 	mov	al, 59h  ; 06/10/2017 
 72057 0001418C E6D6                <1> 	out	0D6h, al ; DMA mode register port address
 72058                              <1> 
 72059 0001418E B001                <1> 	mov     al, 01h  ; clear mask bit for channel 1
 72060 00014190 E6D4                <1> 	out	0D4h, al ; DMA mask register port address
 72061                              <1> 
 72062 00014192 EB28                <1> 	jmp	short ClearBuffer
 72063                              <1> 
 72064                              <1> sbInit_0:    
 72065 00014194 49                  <1> 	dec     ecx	; 09/08/2017
 72066                              <1> 
 72067                              <1> 	; 8 bit DMA buffer setting (DMA channel 1)
 72068 00014195 B005                <1> 	mov     al, 05h ; set mask bit for channel 1  (4+1)
 72069 00014197 E60A                <1> 	out	0Ah, al ; DMA mask register
 72070                              <1> 
 72071 00014199 30C0                <1> 	xor     al, al  ; stops all DMA processes on selected channel
 72072 0001419B E60C                <1> 	out	0Ch, al ; clear selected channel register
 72073                              <1> 
 72074 0001419D 88D8                <1> 	mov     al, bl	; byte 0 of DMA buffer address (physical)   
 72075 0001419F E602                <1> 	out	02h, al ; DMA channel 1 port number
 72076                              <1> 
 72077 000141A1 88F8                <1> 	mov     al, bh  ; byte 1 of DMA buffer address (physical)   
 72078 000141A3 E602                <1> 	out	02h, al
 72079                              <1> 
 72080 000141A5 C1EB10              <1> 	shr	ebx, 16
 72081                              <1> 
 72082 000141A8 88D8                <1> 	mov     al, bl  ; byte 2 of DMA buffer address (physical)   
 72083 000141AA E683                <1> 	out	83h, al ; page register port addr for channel 1
 72084                              <1> 
 72085 000141AC 88C8                <1> 	mov     al, cl  ; low byte of DMA count - 1
 72086 000141AE E603                <1> 	out	03h, al ; count register port addr for channel 1
 72087                              <1> 
 72088 000141B0 88E8                <1> 	mov     al, ch  ; high byte of DMA count - 1
 72089 000141B2 E603                <1> 	out	03h, al
 72090                              <1> 
 72091                              <1> 	; channel 1, read, autoinitialized, single mode
 72092                              <1> 	;mov	al, 49h
 72093 000141B4 B059                <1> 	mov	al, 59h ; 06/10/2017 
 72094 000141B6 E60B                <1> 	out	0Bh, al ; DMA mode register port address
 72095                              <1> 
 72096 000141B8 B001                <1> 	mov     al, 01h ; clear mask bit for channel 1
 72097 000141BA E60A                <1> 	out	0Ah, al ; DMA mask register port address
 72098                              <1> 
 72099                              <1> ClearBuffer:
 72100                              <1> 	;;mov	edi, [audio_dma_buff]
 72101                              <1> 	;;mov	ecx, [audio_dmabuff_size]
 72102                              <1> 	;inc	ecx
 72103                              <1> 	;mov	al, 80h
 72104                              <1> 	;;cld
 72105                              <1> 	;rep	stosb
 72106                              <1> SetIrq:
 72107                              <1> 	;mov	ebx, SbIrqhandler
 72108                              <1> 	;mov	al, [audio_intr] ; IRQ number	
 72109                              <1> 	;call	set_dev_IRQ_service
 72110                              <1> 	;; SETUP (audio) INTERRUPT CALLBACK SERVICE
 72111                              <1> 	;mov	bl, [audio_intr] ; IRQ number
 72112                              <1> 	;mov	bh, [audio_cb_mode]
 72113                              <1> 	;inc	bh  ; 1 = Signal Response Byte method (fixed value)
 72114                              <1> 	;	    ; 2 = Callback service method
 72115                              <1> 	;	    ; 3 = Auto Increment S.R.B. method 	
 72116                              <1> 	;mov	cl, [audio_srb]
 72117                              <1> 	;mov	edx, [audio_cb_addr]
 72118                              <1> 	;mov	al, [audio_user]
 72119                              <1>  	;call	set_irq_callback_service
 72120                              <1> ResetDsp:
 72121 000141BC 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 72122                              <1> 	;add	dx, 06h
 72123                              <1> 	; 06/08/2022
 72124 000141C3 80C206              <1> 	add	dl, 06h
 72125 000141C6 B001                <1> 	mov     al, 1
 72126 000141C8 EE                  <1> 	out	dx, al
 72127                              <1> 
 72128 000141C9 EC                  <1> 	in	al, dx
 72129 000141CA EC                  <1> 	in	al, dx
 72130 000141CB EC                  <1> 	in	al, dx
 72131 000141CC EC                  <1> 	in	al, dx
 72132                              <1> 
 72133 000141CD 30C0                <1> 	xor     al, al
 72134 000141CF EE                  <1> 	out	dx, al
 72135                              <1> 
 72136                              <1> 	;mov	cx, 100
 72137                              <1> 	; 06/08/2022
 72138 000141D0 29C9                <1> 	sub	ecx, ecx
 72139 000141D2 B164                <1> 	mov	cl, 100
 72140 000141D4 28E4                <1> 	sub	ah, ah ; 0
 72141                              <1> WaitId:         
 72142 000141D6 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 72143                              <1> 	;add	dx, 0Eh
 72144                              <1> 	; 06/08/2022
 72145 000141DD 80C20E              <1> 	add	dl, 0Eh
 72146 000141E0 EC                  <1> 	in	al, dx
 72147 000141E1 08C0                <1> 	or      al, al
 72148 000141E3 7807                <1> 	js      short sb_GetId
 72149 000141E5 E2EF                <1> 	loop    WaitId
 72150 000141E7 E9B1000000          <1> 	jmp     sb_Exit
 72151                              <1> sb_GetId:
 72152 000141EC 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 72153                              <1> 	;add	dx, 0Ah
 72154                              <1> 	; 06/08/2022
 72155 000141F3 80C20A              <1> 	add	dl, 0Ah
 72156 000141F6 EC                  <1> 	in	al, dx
 72157 000141F7 3CAA                <1> 	cmp     al, 0AAh
 72158 000141F9 7407                <1> 	je      short SbOk
 72159 000141FB E2D9                <1> 	loop    WaitId
 72160 000141FD E99B000000          <1> 	jmp	sb_Exit
 72161                              <1> SbOk:
 72162 00014202 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 72163                              <1> 	;add	dx, 0Ch
 72164                              <1> 	; 06/08/2022
 72165 00014209 80C20C              <1> 	add	dl, 0Ch
 72166                              <1> 	SbOut   0D1h ; Turn on speaker
 72167                              <2> %%Wait:
 72168 0001420C EC                  <2>  in al, dx
 72169 0001420D 08C0                <2>  or al, al
 72170 0001420F 78FB                <2>  js short %%Wait
 72171 00014211 B0D1                <2>  mov al, %1
 72172 00014213 EE                  <2>  out dx, al
 72173                              <1> 	SbOut   41h ; 8h bit or 16 bit transfer
 72174                              <2> %%Wait:
 72175 00014214 EC                  <2>  in al, dx
 72176 00014215 08C0                <2>  or al, al
 72177 00014217 78FB                <2>  js short %%Wait
 72178 00014219 B041                <2>  mov al, %1
 72179 0001421B EE                  <2>  out dx, al
 72180 0001421C 668B1D[DA890100]    <1> 	mov	bx, [audio_freq] ; sampling rate (Hz)
 72181                              <1> 	SbOut	bh ; sampling rate high byte
 72182                              <2> %%Wait:
 72183 00014223 EC                  <2>  in al, dx
 72184 00014224 08C0                <2>  or al, al
 72185 00014226 78FB                <2>  js short %%Wait
 72186 00014228 88F8                <2>  mov al, %1
 72187 0001422A EE                  <2>  out dx, al
 72188                              <1> 	SbOut	bl ; sampling rate low byte
 72189                              <2> %%Wait:
 72190 0001422B EC                  <2>  in al, dx
 72191 0001422C 08C0                <2>  or al, al
 72192 0001422E 78FB                <2>  js short %%Wait
 72193 00014230 88D8                <2>  mov al, %1
 72194 00014232 EE                  <2>  out dx, al
 72195                              <1> 
 72196                              <1> 	; 22/05/2017
 72197 00014233 E8BF000000          <1> 	call	sb16_volume_initial ; 15/05/2017
 72198                              <1> 	; 20/05/2017
 72199                              <1> 	;call	sb16_volume
 72200                              <1> 
 72201                              <1> StartDma: 
 72202                              <1> 	; autoinitialized mode
 72203 00014238 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
 72204 0001423F 7411                <1> 	je	short sb_play_1
 72205                              <1> 	; 8 bit samples
 72206 00014241 66BBC600            <1> 	mov	bx, 0C6h ; 8 bit output (0C6h)
 72207 00014245 803D[D9890100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
 72208 0001424C 7214                <1> 	jb	short sb_play_2
 72209 0001424E B720                <1> 	mov	bh, 20h	; 8 bit stereo (20h)
 72210 00014250 EB10                <1> 	jmp	short sb_play_2
 72211                              <1> sb_play_1:
 72212                              <1> 	; 16 bit samples
 72213 00014252 66BBB610            <1> 	mov	bx, 10B6h ; 16 bit output (0B6h)
 72214 00014256 803D[D9890100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
 72215 0001425D 7203                <1> 	jb	short sb_play_2
 72216 0001425F 80C720              <1> 	add	bh, 20h	; 16 bit stereo (30h)
 72217                              <1> sb_play_2:     
 72218                              <1> 	; PCM output (8/16 bit mono autoinitialized transfer)
 72219                              <1> 	SbOut   bl ; bCommand
 72220                              <2> %%Wait:
 72221 00014262 EC                  <2>  in al, dx
 72222 00014263 08C0                <2>  or al, al
 72223 00014265 78FB                <2>  js short %%Wait
 72224 00014267 88D8                <2>  mov al, %1
 72225 00014269 EE                  <2>  out dx, al
 72226                              <1> 	SbOut	bh ; bMode
 72227                              <2> %%Wait:
 72228 0001426A EC                  <2>  in al, dx
 72229 0001426B 08C0                <2>  or al, al
 72230 0001426D 78FB                <2>  js short %%Wait
 72231 0001426F 88F8                <2>  mov al, %1
 72232 00014271 EE                  <2>  out dx, al
 72233 00014272 8B1D[CC890100]      <1> 	mov	ebx, [audio_dmabuff_size]  ; 15/05/2017
 72234 00014278 D1EB                <1> 	shr	ebx, 1 ; half buffer size
 72235                              <1> 	; 20/10/2017	
 72236 0001427A 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit DMA
 72237 00014281 7502                <1> 	jne	short sb_play_3
 72238 00014283 D1EB                <1> 	shr	ebx, 1 ; byte count to word count
 72239                              <1> sb_play_3: 
 72240                              <1> 	;dec	bx  ; wBlkSize is one less than the actual size 
 72241                              <1> 	; 06/08/2022
 72242 00014285 4B                  <1> 	dec	ebx
 72243                              <1> 	SbOut   bl
 72244                              <2> %%Wait:
 72245 00014286 EC                  <2>  in al, dx
 72246 00014287 08C0                <2>  or al, al
 72247 00014289 78FB                <2>  js short %%Wait
 72248 0001428B 88D8                <2>  mov al, %1
 72249 0001428D EE                  <2>  out dx, al
 72250                              <1> 	SbOut   bh
 72251                              <2> %%Wait:
 72252 0001428E EC                  <2>  in al, dx
 72253 0001428F 08C0                <2>  or al, al
 72254 00014291 78FB                <2>  js short %%Wait
 72255 00014293 88F8                <2>  mov al, %1
 72256 00014295 EE                  <2>  out dx, al
 72257                              <1> 
 72258 00014296 C605[DC890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; playing !
 72259                              <1> 
 72260                              <1> 	;; Set Voice and master volumes
 72261                              <1> 	;mov	dx, [audio_io_base]
 72262                              <1> 	;add	dl, 4 ; Mixer chip Register Address Port
 72263                              <1> 	;SbOut	30h   ; select Master Volume Register (L)
 72264                              <1> 	;inc	dl    ; Mixer chip Register Data Port
 72265                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
 72266                              <1> 	;dec	dl
 72267                              <1> 	;SbOut	31h   ; select Master Volume Register (R)
 72268                              <1> 	;inc	dl
 72269                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
 72270                              <1> 	;dec	dl
 72271                              <1> 	;SbOut	32h   ; select Voice Volume Register (L)
 72272                              <1> 	;inc	dl
 72273                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
 72274                              <1> 	;dec	dl
 72275                              <1> 	;SbOut	33h   ; select Voice Volume Register (R)
 72276                              <1> 	;inc	dl
 72277                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)	
 72278                              <1> 	;;
 72279                              <1> 	;dec	dl
 72280                              <1> 	;SbOut	44h   ; select Treble Register (L)
 72281                              <1> 	;inc	dl
 72282                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
 72283                              <1> 	;dec	dl
 72284                              <1> 	;SbOut	45h   ; select Treble Register (R)
 72285                              <1> 	;inc	dl
 72286                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
 72287                              <1> 	;dec	dl
 72288                              <1> 	;SbOut	46h   ; select Bass Register (L)
 72289                              <1> 	;inc	dl
 72290                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)
 72291                              <1> 	;dec	dl
 72292                              <1> 	;SbOut	47h   ; select Bass Register (R)
 72293                              <1> 	;inc	dl
 72294                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)	
 72295                              <1> 
 72296                              <1> sb_Exit:           
 72297                              <1> 	;popad
 72298 0001429D C3                  <1> 	retn
 72299                              <1> 
 72300                              <1> sb16_int_handler:
 72301                              <1> 	; Interrupt Handler for Sound Blaster 16 Audio Card
 72302                              <1> 	; Note: called by 'dev_IRQ_service'
 72303                              <1> 	; 20/10/2017
 72304                              <1> 	; 12/10/2017
 72305                              <1> 	; 10/10/2017 
 72306                              <1> 	; 12/05/2017, 09/10/2017
 72307                              <1> 	; 24/04/2017 (TRDOS 386 kernel, 'audio.s')
 72308                              <1> 	; 10/03/2017 - 'PLAYWAV.PRG' ('playwav.s') 
 72309                              <1> 
 72310                              <1> 	;push	eax ; * must be saved !
 72311                              <1> 	;push	ebx ; * must be saved !
 72312                              <1> 	;push	ecx
 72313                              <1> 	;push	edx
 72314                              <1> 	;push	esi
 72315                              <1> 	;push	edi
 72316                              <1> 
 72317 0001429E 668B15[AE890100]    <1> 	mov     dx, [audio_io_base]
 72318                              <1> 	; 20/10/2017
 72319 000142A5 80C20F              <1> 	add     dl, 0Fh ; 2xFh (DSP 16 bit intr ack)
 72320 000142A8 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16
 72321 000142AF 7402                <1> 	je	short sb_irq_16bit_ack
 72322                              <1> sb_irq_8bit_ack:
 72323 000142B1 FECA                <1> 	dec	dl  ; 2xEh (DSP 8 bit intr ack)
 72324                              <1> sb_irq_16bit_ack:
 72325 000142B3 EC                  <1> 	in	al, dx
 72326                              <1> 
 72327                              <1> 	;cmp	byte [audio_busy], 0
 72328                              <1> 	;ja	short sb_irq_h3
 72329                              <1> 
 72330                              <1> 	;mov	byte [audio_busy], 1
 72331                              <1> 
 72332 000142B4 803D[DC890100]01    <1> 	cmp	byte [audio_play_cmd], 1
 72333 000142BB 7307                <1> 	jnb	short sb_irq_h1
 72334                              <1> sb_irq_h0:
 72335 000142BD E8A3000000          <1> 	call	sb16_stop
 72336 000142C2 EB2B                <1> 	jmp	short sb_irq_h3
 72337                              <1> sb_irq_h1:
 72338                              <1> 	;call	sb16_tuneloop
 72339                              <1> 	; 09/10/2017
 72340                              <1> sb16_tuneloop:
 72341 000142C4 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff]
 72342 000142CA 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size]
 72343 000142D0 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
 72344                              <1> 
 72345                              <1> 	; 22/05/2017
 72346 000142D2 F605[D0890100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
 72347 000142D9 7402                <1> 	jz	short sb_tlp1 ; EOL (Half Buffer 1 must be filled)
 72348                              <1> 	; FLAG (Half Buffer 2 must be filled)
 72349 000142DB 01CF                <1> 	add	edi, ecx
 72350                              <1> 	; 15/05/2017
 72351                              <1> sb_tlp1: 
 72352 000142DD 8B35[C0890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
 72353                              <1> 	;rep	movsb
 72354 000142E3 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
 72355 000142E6 F3A5                <1> 	rep	movsd 
 72356                              <1> 	;retn
 72357                              <1> 
 72358                              <1> 	; 10/10/2017
 72359                              <1> 	; switch flag value
 72360 000142E8 8035[D0890100]01    <1> 	xor	byte [audio_flag], 1
 72361                              <1> 
 72362                              <1> 	; 12/10/2017
 72363                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (odd intr count)
 72364                              <1> 			   ; Next buffer (to update) is dma half buff 1
 72365                              <1> 	; 	       = 1 : Playing dma half buffer 1 (even intr count)
 72366                              <1> 			   ; Next buffer (to update) is dma half buff 2
 72367                              <1> 
 72368                              <1> sb_irq_h3:
 72369                              <1> 	;mov	byte [audio_busy], 0
 72370                              <1> 
 72371                              <1> 	;pop	edi
 72372                              <1> 	;pop	esi
 72373                              <1> 	;pop	edx
 72374                              <1> 	;pop	ecx
 72375                              <1> 	;pop	ebx ; * must be restored !
 72376                              <1> 	;pop	eax ; * must be restored !
 72377                              <1> 	
 72378 000142EF C3                  <1> 	retn
 72379                              <1> 
 72380                              <1> sb16_volume:
 72381                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
 72382                              <1> 	; 22/10/2017
 72383                              <1> 	; mov [audio_master_volume_l], cl 
 72384                              <1> 	; mov [audio_master_volume_h], ch 
 72385 000142F0 66890D[DE890100]    <1> 	mov	[audio_master_volume], cx
 72386                              <1> sb16_volume_initial:
 72387                              <1> 	;push	dx ; DX (port address) must be saved
 72388                              <1> 	; 06/08/2022
 72389 000142F7 52                  <1> 	push	edx
 72390 000142F8 668B15[AE890100]    <1> 	mov	dx, [audio_io_base]
 72391                              <1> 	;add	dx, 4 ; Mixer chip address port
 72392                              <1> 	; 06/08/2022
 72393 000142FF 80C204              <1> 	add	dl, 4
 72394 00014302 B022                <1> 	mov	al, 22h ; master volume
 72395 00014304 EE                  <1> 	out	dx, al
 72396                              <1> 	;inc	dx
 72397                              <1> 	; 06/08/2022
 72398 00014305 42                  <1> 	inc	edx
 72399 00014306 8A25[DE890100]      <1> 	mov	ah, [audio_master_volume_l]
 72400 0001430C C0EC02              <1> 	shr	ah, 2 ; 32 -> 8 level
 72401 0001430F C0E405              <1> 	shl	ah, 5 ; bit 5 to 7
 72402 00014312 A0[DF890100]        <1> 	mov	al, [audio_master_volume_r]	
 72403 00014317 C0E802              <1> 	shr	al, 2 ; 32 -> 8 level
 72404                              <1> 	;and	al, 0Fh
 72405 0001431A D0E0                <1> 	shl	al, 1 ; bit 1 to 3
 72406 0001431C 08E0                <1> 	or	al, ah
 72407 0001431E EE                  <1> 	out	dx, al
 72408                              <1> 	;pop	dx ; DX (port address) must be restored
 72409                              <1> 	; 06/08/2022
 72410 0001431F 5A                  <1> 	pop	edx
 72411 00014320 C3                  <1> 	retn
 72412                              <1> 
 72413                              <1> sb16_pause:
 72414                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
 72415 00014321 668B15[AE890100]    <1> 	mov	dx, [audio_io_base]
 72416                              <1> 	;add	dx, 0Ch ; Command & Data Port
 72417                              <1> 	; 06/08/2022
 72418 00014328 80C20C              <1> 	add	dl, 0Ch
 72419 0001432B 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
 72420 00014332 7404                <1> 	je	short sb_pause_1
 72421                              <1> 	; 8 bit samples
 72422 00014334 B3D0                <1> 	mov	bl, 0D0h ; 8 bit DMA mode
 72423 00014336 EB02                <1> 	jmp	short sb_pause_2
 72424                              <1> sb_pause_1:
 72425                              <1> 	; 16 bit samples
 72426 00014338 B3D5                <1> 	mov	bl, 0D5h ; 16 bit DMA mode
 72427                              <1> sb_pause_2:     
 72428                              <1> 	SbOut   bl ; bCommand
 72429                              <2> %%Wait:
 72430 0001433A EC                  <2>  in al, dx
 72431 0001433B 08C0                <2>  or al, al
 72432 0001433D 78FB                <2>  js short %%Wait
 72433 0001433F 88D8                <2>  mov al, %1
 72434 00014341 EE                  <2>  out dx, al
 72435                              <1> sb_pause_3:
 72436 00014342 C3                  <1> 	retn
 72437                              <1> 
 72438                              <1> sb16_continue:
 72439                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
 72440 00014343 668B15[AE890100]    <1> 	mov	dx, [audio_io_base]
 72441                              <1> 	;add	dx, 0Ch ; Command & Data Port
 72442                              <1> 	; 06/08/2022
 72443 0001434A 80C20C              <1> 	add	dl, 0Ch
 72444 0001434D 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
 72445 00014354 7404                <1> 	je	short sb_cont_1
 72446                              <1> 	; 8 bit samples
 72447 00014356 B3D4                <1> 	mov	bl, 0D4h ; 8 bit DMA mode
 72448 00014358 EB02                <1> 	jmp	short sb_cont_2
 72449                              <1> sb_cont_1:
 72450                              <1> 	; 16 bit samples
 72451 0001435A B3D6                <1> 	mov	bl, 0D6h ; 16 bit DMA mode
 72452                              <1> sb_cont_2:     
 72453                              <1> 	SbOut   bl ; bCommand
 72454                              <2> %%Wait:
 72455 0001435C EC                  <2>  in al, dx
 72456 0001435D 08C0                <2>  or al, al
 72457 0001435F 78FB                <2>  js short %%Wait
 72458 00014361 88D8                <2>  mov al, %1
 72459 00014363 EE                  <2>  out dx, al
 72460                              <1> sb_cont_3:
 72461 00014364 C3                  <1> 	retn
 72462                              <1> 
 72463                              <1> sb16_stop:
 72464                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
 72465                              <1> 	; 24/04/2017
 72466 00014365 803D[DC890100]00    <1> 	cmp	byte [audio_play_cmd], 0
 72467 0001436C 7647                <1> 	jna	short sb16_stop_4
 72468                              <1> 
 72469                              <1> 	; 22/05/2017
 72470 0001436E 668B15[AE890100]    <1> 	mov	dx, [audio_io_base]
 72471                              <1> 	;add	dx, 0Ch
 72472                              <1> 	; 06/08/2022
 72473 00014375 80C20C              <1> 	add	dl, 0Ch
 72474                              <1> 
 72475 00014378 B3D9                <1> 	mov	bl, 0D9h ; exit auto-initialize 16 bit transfer
 72476                              <1> 	; stop  autoinitialized DMA transfer mode 
 72477 0001437A 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
 72478 00014381 7402                <1> 	je	short sb16_stop_1
 72479                              <1> 	;mov	bl, 0DAh ; exit auto-initialize 8 bit transfer
 72480 00014383 FEC3                <1> 	inc	bl
 72481                              <1> sb16_stop_1:
 72482                              <1> 	SbOut	bl ; exit auto-initialize transfer command
 72483                              <2> %%Wait:
 72484 00014385 EC                  <2>  in al, dx
 72485 00014386 08C0                <2>  or al, al
 72486 00014388 78FB                <2>  js short %%Wait
 72487 0001438A 88D8                <2>  mov al, %1
 72488 0001438C EE                  <2>  out dx, al
 72489                              <1> 
 72490 0001438D 30C0                <1> 	xor     al, al ; stops all DMA processes on selected channel
 72491                              <1> 
 72492 0001438F 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
 72493 00014396 7404                <1> 	je	short sb16_stop_2
 72494 00014398 E60C                <1> 	out	0Ch, al ; clear selected channel register
 72495 0001439A EB02                <1> 	jmp	short sb16_stop_3
 72496                              <1> 
 72497                              <1> sb16_stop_2:
 72498 0001439C E6D8                <1> 	out	0D8h, al ; clear selected channel register
 72499                              <1> 
 72500                              <1> sb16_stop_3:
 72501 0001439E C605[DC890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
 72502                              <1> SbDone:
 72503                              <1> 	;mov	dx, [audio_io_base]
 72504                              <1> 	;add	dx, 0Ch
 72505                              <1> 	SbOut   0D0h
 72506                              <2> %%Wait:
 72507 000143A5 EC                  <2>  in al, dx
 72508 000143A6 08C0                <2>  or al, al
 72509 000143A8 78FB                <2>  js short %%Wait
 72510 000143AA B0D0                <2>  mov al, %1
 72511 000143AC EE                  <2>  out dx, al
 72512                              <1> 	SbOut   0D3h
 72513                              <2> %%Wait:
 72514 000143AD EC                  <2>  in al, dx
 72515 000143AE 08C0                <2>  or al, al
 72516 000143B0 78FB                <2>  js short %%Wait
 72517 000143B2 B0D3                <2>  mov al, %1
 72518 000143B4 EE                  <2>  out dx, al
 72519                              <1> sb16_stop_4:
 72520 000143B5 C3                  <1> 	retn
 72521                              <1> 
 72522                              <1> sb16_reset:
 72523                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
 72524                              <1> 	; 24/04/2017
 72525 000143B6 668B15[AE890100]    <1> 	mov     dx, [audio_io_base] ; try to reset the DSP.
 72526                              <1> 	;add	dx, 06h
 72527                              <1> 	; 06/08/2022
 72528 000143BD 80C206              <1> 	add	dl, 06h
 72529 000143C0 B001                <1> 	mov	al, 1
 72530 000143C2 EE                  <1> 	out	dx, al
 72531                              <1> 
 72532 000143C3 EC                  <1> 	in	al, dx
 72533 000143C4 EC                  <1> 	in	al, dx
 72534 000143C5 EC                  <1> 	in	al, dx
 72535 000143C6 EC                  <1> 	in	al, dx
 72536                              <1> 
 72537 000143C7 30C0                <1> 	xor     al, al
 72538 000143C9 EE                  <1> 	out	dx, al
 72539                              <1> 
 72540                              <1> 	;add	dx, 08h
 72541                              <1> 	; 06/08/2022
 72542 000143CA 80C208              <1> 	add	dl, 08h
 72543                              <1> 	;mov	cx, 100
 72544 000143CD 29C9                <1> 	sub	ecx, ecx
 72545 000143CF B164                <1> 	mov	cl, 100
 72546                              <1> sbrstWaitID:
 72547 000143D1 EC                  <1> 	in	al, dx
 72548 000143D2 08C0                <1> 	or      al, al
 72549 000143D4 7804                <1> 	js      short sbrstGetID
 72550 000143D6 E2F9                <1> 	loop    sbrstWaitID
 72551 000143D8 F9                  <1> 	stc
 72552 000143D9 C3                  <1> 	retn
 72553                              <1> sbrstGetID:          
 72554                              <1> 	;sub	dx, 04h
 72555                              <1> 	; 06/08/2022
 72556 000143DA 80EA04              <1> 	sub	dl, 04h
 72557 000143DD EC                  <1> 	in	al, dx
 72558 000143DE 3CAA                <1> 	cmp     al, 0AAh
 72559 000143E0 7405                <1> 	je      short sb_rst_retn
 72560                              <1> 	;add	dx, 04h
 72561                              <1> 	; 06/08/2022
 72562 000143E2 80C204              <1> 	add	dl, 04h
 72563 000143E5 E2EA                <1> 	loop    sbrstWaitID
 72564                              <1> sb_rst_retn:
 72565 000143E7 C3                  <1> 	retn
 72566                              <1> 
 72567                              <1> ac97_codec_config:
 72568                              <1> 	; 10/06/2017
 72569                              <1> 	; 05/06/2017
 72570                              <1> 	; 29/05/2017
 72571                              <1> 	; 28/05/2017 (TRDOS 386, 'audio.s')
 72572                              <1> 	; 07/11/2016 (Erdogan Tan)
 72573                              <1> 	; Derived from 'codecConfig' procedure in 'CODEC.ASM'
 72574                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
 72575                              <1> 
 72576                              <1> 	;; 'PLAYER.ASM'
 72577                              <1> 	;; get ICH base address regs for mixer and bus master
 72578                              <1> 
 72579                              <1> init_ac97_controller: ; 10/06/2017
 72580 000143E8 A1[B0890100]        <1> 	mov	eax, [audio_dev_id]
 72581                              <1>         ;mov	al, NAMBAR_REG
 72582                              <1>         ;;call  pciRegRead16			; read PCI registers 10-11
 72583                              <1>         ;call	pciRegRead32
 72584                              <1> 	;and	dx, IO_ADDR_MASK 		; mask off BIT0
 72585                              <1> 	;;and	edx, IO_ADDR_MASK 
 72586                              <1> 
 72587                              <1>         ;mov	[NAMBAR], dx			; save audio mixer base addr
 72588                              <1> 
 72589                              <1>         ;mov    al, NABMBAR_REG
 72590                              <1>         ;;call	pciRegRead16
 72591                              <1>         ;call	pciRegRead32
 72592                              <1> 	;and	dx, 0FFC0h ; IO_ADDR_MASK
 72593                              <1> 	;;and	edx, 0FFC0h
 72594                              <1> 
 72595                              <1>         ;mov    [NABMBAR], dx			; save bus master base addr
 72596                              <1> 
 72597                              <1> 	;mov	eax, [audio_dev_id]
 72598 000143ED B004                <1>         mov     al, PCI_CMD_REG
 72599                              <1>         ;call	pciRegRead8			; read PCI command register
 72600 000143EF E885F8FFFF          <1>         call	pciRegRead16
 72601 000143F4 80CA05              <1> 	or      dl, IO_ENA+BM_ENA               ; enable IO and bus master
 72602                              <1>         ;call 	pciRegWrite8
 72603 000143F7 E8E8F8FFFF          <1> 	call	pciRegWrite16
 72604                              <1> 
 72605                              <1> 	; 'CODEC.ASM'
 72606                              <1> 
 72607                              <1> 	; enable codec, unmute stuff, set output rate
 72608                              <1> ;	; entry: [audio_freq] = desired sample rate
 72609                              <1> 		
 72610                              <1> ;	mov    	dx, [NAMBAR]               	
 72611                              <1> ;	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
 72612                              <1> ;	in     	ax, dx
 72613                              <1> ;	or	ax, 1
 72614                              <1> ;	out	dx, ax 				; Enable variable rate audio
 72615                              <1> 
 72616                              <1> ;       ;call    delay1_4ms
 72617                              <1> ;       ;call    delay1_4ms
 72618                              <1> ;       ;call    delay1_4ms
 72619                              <1> ;       ;call    delay1_4ms
 72620                              <1> 
 72621                              <1> ;	mov	ax, [audio_freq]		; sample rate
 72622                              <1> 
 72623                              <1> ;	mov    	dx, [NAMBAR]               	
 72624                              <1> ;	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
 72625                              <1> ;	out	dx, ax 				; out sample rate
 72626                              <1> 		
 72627                              <1> ;       ;call	delay1_4ms
 72628                              <1> ;       ;call	delay1_4ms
 72629                              <1> ;       ;call	delay1_4ms
 72630                              <1> ;       ;call	delay1_4ms
 72631                              <1> 
 72632                              <1> 	;mov	dx, [NAMBAR]			; mixer base address
 72633                              <1>         ;add	dx, CODEC_RESET_REG  		; reset register
 72634                              <1>         ;mov	ax, 42
 72635                              <1> 	;out	dx, ax                          ; reset
 72636                              <1> 
 72637                              <1> 	;mov    dx, [NABMBAR]			; bus master base address
 72638                              <1>         ;add	dx, GLOB_STS_REG
 72639                              <1>         ;mov	ax, 2
 72640                              <1> 	;out	dx, ax                         
 72641                              <1> 
 72642 000143FC E880F9FFFF          <1>         call    delay_100ms ; 29/05/2017
 72643                              <1> 
 72644                              <1> init_ac97_codec:
 72645                              <1> 	; 10/06/2017
 72646                              <1> 	; 29/05/2017
 72647                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
 72648                              <1> 	;	
 72649 00014401 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
 72650 00014405 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 72651 0001440C ED                  <1> 	in	eax, dx
 72652                              <1> 	; ?
 72653 0001440D 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
 72654 00014411 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 72655 00014418 ED                  <1> 	in	eax, dx
 72656                              <1> 
 72657 00014419 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
 72658 0001441C 744B                <1> 	je	short init_ac97_codec_err1
 72659                              <1> 
 72660 0001441E A900030010          <1> 	test	eax, CTRL_ST_CREADY
 72661 00014423 7507                <1> 	jnz	short _ac97_codec_ready
 72662                              <1> 
 72663 00014425 E8DB020000          <1> 	call	reset_ac97_codec
 72664 0001442A 723E                <1> 	jc	short init_ac97_codec_err2
 72665                              <1> 
 72666                              <1> _ac97_codec_ready:
 72667 0001442C 668B15[E0890100]    <1> 	mov	dx, [NAMBAR]
 72668                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
 72669 00014433 66EF                <1> 	out	dx, ax
 72670                              <1> 
 72671 00014435 31C0                <1> 	xor	eax, eax ; 0
 72672 00014437 668B15[E0890100]    <1> 	mov	dx, [NAMBAR]
 72673 0001443E 6683C226            <1> 	add	dx, CODEC_REG_POWERDOWN	
 72674 00014442 66EF                <1> 	out	dx, ax
 72675                              <1> 
 72676                              <1> 	; 10/06/2017
 72677                              <1> 	; 29/05/2017
 72678                              <1> 	; wait for 1 second
 72679 00014444 B9E8030000          <1> 	mov	ecx, 1000 ; 1000*0.25ms = 1s
 72680                              <1> _ac97_codec_rloop:
 72681 00014449 E840F9FFFF          <1> 	call	delay1_4ms
 72682 0001444E E83BF9FFFF          <1> 	call	delay1_4ms
 72683 00014453 E836F9FFFF          <1> 	call	delay1_4ms
 72684 00014458 E831F9FFFF          <1> 	call	delay1_4ms
 72685                              <1> 	;mov	dx, [NAMBAR]
 72686                              <1> 	;add	dx, CODEC_REG_POWERDOWN
 72687 0001445D 66ED                <1> 	in	ax, dx	
 72688 0001445F 6683E00F            <1> 	and	ax, 0Fh
 72689 00014463 3C0F                <1> 	cmp	al, 0Fh
 72690 00014465 7404                <1> 	je	short _ac97_codec_init_ok
 72691 00014467 E2E0                <1> 	loop	_ac97_codec_rloop 
 72692                              <1> 
 72693                              <1> init_ac97_codec_err1:
 72694 00014469 F9                  <1> 	stc
 72695                              <1> init_ac97_codec_err2:
 72696 0001446A C3                  <1> 	retn
 72697                              <1> 
 72698                              <1> _ac97_codec_init_ok:
 72699 0001446B B002                <1>         mov     al, 2 ; force set 16-bit 2-channel PCM
 72700 0001446D 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
 72701 00014471 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 72702 00014478 EF                  <1> 	out	dx, eax
 72703                              <1> 
 72704                              <1> 	;call	delay1_4ms
 72705                              <1> 
 72706                              <1> 	; 10/06/2017
 72707 00014479 E835020000          <1> 	call 	reset_ac97_controller
 72708                              <1> 
 72709                              <1> ;	call 	setup_ac97_codec
 72710                              <1> ;
 72711                              <1> ;detect_ac97_codec:
 72712                              <1> ;	retn
 72713                              <1> 
 72714                              <1> setup_ac97_codec:
 72715                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 72716                              <1> 	; 22/07/2020
 72717                              <1> 	; 10/06/2017
 72718                              <1> 	; 29/05/2017
 72719 0001447E B802020000          <1> 	mov     eax, 0202h
 72720 00014483 66A3[DE890100]      <1> 	mov	[audio_master_volume], ax
 72721 00014489 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31, 31
 72722                              <1> 	
 72723 0001448D 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72724 00014494 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
 72725                              <1> 	;xor	ax, ax 	; volume attenuation = 0 (max. volume)
 72726                              <1> 	; 06/08/2022
 72727 00014498 31C0                <1> 	xor	eax, eax
 72728 0001449A 66EF                <1> 	out     dx, ax
 72729                              <1>  
 72730 0001449C 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72731 000144A3 6683C206            <1>   	add     dx, CODEC_MASTER_MONO_VOL_REG	;06h 
 72732                              <1> 	;xor	ax, ax
 72733 000144A7 66EF                <1>   	out     dx, ax
 72734                              <1> 
 72735 000144A9 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72736 000144B0 6683C20A            <1>   	add     dx, CODEC_PCBEEP_VOL_REG	;0Ah 
 72737                              <1>   	;xor    ax, ax
 72738 000144B4 66EF                <1>   	out     dx, ax
 72739                              <1> 
 72740 000144B6 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72741 000144BD 6683C218            <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
 72742                              <1>   	;xor    ax, ax
 72743 000144C1 66EF                <1>   	out     dx, ax
 72744                              <1> 
 72745 000144C3 66B80880            <1> 	mov     ax, 8008h ; Mute
 72746 000144C7 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72747                              <1> 	; 22/07/2020
 72748 000144CE 6683C20C            <1> 	add	dx, CODEC_PHONE_VOL_REG		;0Ch
 72749                              <1> 				 ; AC97_PHONE_VOL ; TAD Input (Mono)
 72750 000144D2 66EF                <1>   	out     dx, ax
 72751                              <1> 
 72752 000144D4 66B80808            <1>         mov	ax, 0808h
 72753 000144D8 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72754 000144DF 6683C210            <1>         add	dx, CODEC_LINE_IN_VOL_REG ;10h ; Line Input (Stereo)	
 72755 000144E3 66EF                <1>   	out     dx, ax
 72756                              <1> 
 72757                              <1> 	;mov	ax, 0808h
 72758 000144E5 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72759 000144EC 6683C212            <1>         add	dx, CODEC_CD_VOL_REG ;12h ; CR Input (Stereo)
 72760 000144F0 66EF                <1>   	out     dx, ax
 72761                              <1> 
 72762                              <1> 	;mov	ax, 0808h
 72763 000144F2 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72764 000144F9 6683C216            <1>         add	dx, CODEC_AUX_VOL_REG ;16h ; Aux Input (Stereo)
 72765 000144FD 66EF                <1>   	out     dx, ax
 72766                              <1> 
 72767                              <1>         ;call    delay1_4ms
 72768                              <1>         ;call    delay1_4ms
 72769                              <1>         ;call    delay1_4ms
 72770                              <1>         ;call    delay1_4ms
 72771                              <1> 
 72772                              <1> detect_ac97_codec:
 72773 000144FF C3                  <1>         retn
 72774                              <1> 
 72775                              <1> set_ac97_bdl: ; Set AC97 (ICH) Buffer Descriptor List
 72776                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 72777                              <1> 	; 17/06/2017
 72778                              <1> 	; 11/06/2017
 72779                              <1> 	; 28/05/2017
 72780                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
 72781                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
 72782                              <1> 
 72783 00014500 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
 72784 00014502 89CE                <1> 	mov	esi, ecx
 72785                              <1> 
 72786 00014504 BF[E4890100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
 72787                              <1> 	;mov	ecx, 32 / 2		; make 32 entries in BDL
 72788                              <1> 	; 06/08/2022
 72789 00014509 29C9                <1> 	sub	ecx, ecx
 72790 0001450B B110                <1> 	mov	cl, 16
 72791                              <1> 
 72792 0001450D EB05                <1> 	jmp	short s_ac97_bdl1 
 72793                              <1> 
 72794                              <1> s_ac97_bdl0:
 72795                              <1> 	; set buffer descriptor 0 to start of data file in memory
 72796                              <1> 
 72797 0001450F A1[C8890100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
 72798                              <1>  
 72799                              <1> s_ac97_bdl1:
 72800 00014514 AB                  <1> 	stosd				; store dmabuffer1 address
 72801                              <1> 
 72802 00014515 89C2                <1> 	mov	edx, eax
 72803                              <1> 
 72804                              <1> ;
 72805                              <1> ; Buffer Descriptors List
 72806                              <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32 
 72807                              <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
 72808                              <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
 72809                              <1> ; entry describe various control things detailed below.
 72810                              <1> ; 
 72811                              <1> ; Buffer pointers must always be aligned on a Dword boundry.
 72812                              <1> ;
 72813                              <1> ;
 72814                              <1> 
 72815                              <1> ;IOC                     equ     BIT31	; Fire an interrupt whenever this
 72816                              <1>                                         ; buffer is complete.
 72817                              <1> 
 72818                              <1> ;BUP                     equ     BIT30  ; Buffer Underrun Policy.
 72819                              <1>                                         ; if this buffer is the last buffer
 72820                              <1>                                         ; in a playback, fill the remaining
 72821                              <1>                                         ; samples with 0 (silence) or not.
 72822                              <1>                                         ; It's a good idea to set this to 1
 72823                              <1>                                         ; for the last buffer in playback,
 72824                              <1>                                         ; otherwise you're likely to get a lot
 72825                              <1>                                         ; of noise at the end of the sound.
 72826                              <1> 
 72827                              <1> ;
 72828                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
 72829                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
 72830                              <1> ; Luckily for us, that's the same format as .wav files.
 72831                              <1> ;
 72832                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
 72833                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
 72834                              <1> ;
 72835                              <1> ; A value of 0 in these bits means play no samples.
 72836                              <1> ;
 72837                              <1> 
 72838 00014517 89F0                <1> 	mov	eax, esi ; DMA half buffer size
 72839 00014519 01C2                <1> 	add	edx, eax
 72840 0001451B D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
 72841                              <1> 	;or	eax, IOC+BUP
 72842 0001451D 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
 72843 00014522 AB                  <1> 	stosd
 72844                              <1> 
 72845                              <1> ; 2nd buffer:
 72846                              <1> 
 72847 00014523 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
 72848 00014525 AB                  <1> 	stosd		 ; store dmabuffer2 address
 72849                              <1> 
 72850                              <1> ; set length to [audio_dmabuff_size]/2
 72851                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
 72852                              <1> ; 
 72853 00014526 89F0                <1> 	mov	eax, esi ; DMA half buffer size
 72854 00014528 D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
 72855                              <1> 	;or	eax, IOC+BUP
 72856 0001452A 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
 72857 0001452F AB                  <1> 	stosd
 72858                              <1> 
 72859 00014530 E2DD                <1> 	loop    s_ac97_bdl0
 72860                              <1> 	
 72861 00014532 C3                  <1> 	retn
 72862                              <1> 
 72863                              <1> ac97_start_play:  
 72864                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 72865                              <1> 	; 28/05/2017
 72866                              <1> 	; Derived from 'playWav' procedure in 'ICHWAV.ASM'
 72867                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
 72868                              <1> 
 72869                              <1> 	; set output rate
 72870                              <1> 	; entry: [audio_freq] = desired sample rate
 72871                              <1> 		
 72872 00014533 668B15[E0890100]    <1> 	mov    	dx, [NAMBAR]               	
 72873 0001453A 6683C22A            <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
 72874 0001453E 66ED                <1> 	in     	ax, dx
 72875                              <1> 	;or	ax, 1
 72876                              <1> 	; 06/08/2022
 72877 00014540 0C01                <1> 	or	al, 1
 72878 00014542 66EF                <1> 	out	dx, ax 				; Enable variable rate audio
 72879                              <1> 
 72880                              <1>        ;call    delay1_4ms
 72881                              <1>        ;call    delay1_4ms
 72882                              <1>        ;call    delay1_4ms
 72883                              <1>        ;call    delay1_4ms
 72884                              <1> 
 72885 00014544 66A1[DA890100]      <1> 	mov	ax, [audio_freq]		; sample rate
 72886                              <1> 
 72887 0001454A 668B15[E0890100]    <1> 	mov    	dx, [NAMBAR]               	
 72888 00014551 6683C22C            <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
 72889 00014555 66EF                <1> 	out	dx, ax 				; out sample rate
 72890                              <1> 		
 72891                              <1>        ;call    delay1_4ms
 72892                              <1>        ;call    delay1_4ms
 72893                              <1>        ;call    delay1_4ms
 72894                              <1>        ;call    delay1_4ms
 72895                              <1> 
 72896                              <1> ;
 72897                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
 72898                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
 72899                              <1> ; reset.
 72900                              <1> ;
 72901 00014557 668B15[E2890100]    <1>         mov     dx, [NABMBAR]
 72902 0001455E 6683C21B            <1>         add     dx, PO_CR_REG                  ; set pointer to Cntl reg
 72903 00014562 B002                <1>         mov     al, RR                         ; set reset
 72904 00014564 EE                  <1>         out     dx, al                         ; self clearing bit
 72905                              <1> ;
 72906                              <1> ;	mov	edi, audio_bdl_buff
 72907                              <1> ;	mov	edx, [audio_dmabuff_size]
 72908                              <1> ;	shr	edx, 1
 72909                              <1> ;	mov	ecx, 32/2
 72910                              <1> ;ac97_set_bdl_buffer:
 72911                              <1> ;	; 1st half of DMA buffer
 72912                              <1> ;	mov	eax, [audio_dma_buff]
 72913                              <1> ;	push	eax
 72914                              <1> ;	stosd
 72915                              <1> ;	mov	eax, edx ; dma buffer size / 2
 72916                              <1> ;	or	eax, IOC+BUP
 72917                              <1> ;	stosd
 72918                              <1> ;	pop	eax
 72919                              <1> ;	; 2nd half of DMA buffer
 72920                              <1> ;	add	eax, edx
 72921                              <1> ;	stosd
 72922                              <1> ;	mov	eax, edx ; dma buffer size / 2
 72923                              <1> ;	or	eax, IOC+BUP
 72924                              <1> ;	stosd
 72925                              <1> ;	loop	ac97_set_bdl_buffer
 72926                              <1>  	
 72927                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
 72928                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
 72929                              <1> ;
 72930                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
 72931                              <1> ;
 72932 00014565 B8[E4890100]        <1>         mov	eax, audio_bdl_buff
 72933 0001456A 668B15[E2890100]    <1> 	mov	dx, [NABMBAR]
 72934 00014571 6683C210            <1> 	add	dx, PO_BDBAR_REG
 72935 00014575 EF                  <1> 	out	dx, eax
 72936                              <1> ;
 72937                              <1> ; All set. Let's play some music.
 72938                              <1> ;
 72939                              <1> ;
 72940                              <1> 	;mov	eax, 31
 72941                              <1> 	; 06/08/2022
 72942 00014576 29C0                <1> 	sub	eax, eax
 72943 00014578 B01F                <1> 	mov	al, 31
 72944 0001457A E816000000          <1> 	call    set_ac97_LastValidIndex
 72945                              <1> 
 72946 0001457F C605[DC890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
 72947                              <1> 
 72948                              <1> ac97_play: ; continue to play (after pause)
 72949                              <1> 	; 11/06/2017
 72950                              <1> 	; 29/05/2017
 72951                              <1> 	; 28/05/2017
 72952 00014586 668B15[E2890100]    <1>         mov     dx, [NABMBAR]
 72953 0001458D 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
 72954 00014591 B011                <1>         mov	al, IOCE+RPBM ; 29/05/2017
 72955                              <1>         ;mov	al, 1Dh ; (Ref: KolibriOS, intelac97.asm, 'play:')
 72956 00014593 EE                  <1> 	out     dx, al			; set start!
 72957                              <1> 
 72958                              <1> 	;mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
 72959                              <1> 
 72960 00014594 C3                  <1> 	retn
 72961                              <1> 
 72962                              <1> ;input AL = index # to stop on
 72963                              <1> set_ac97_LastValidIndex:
 72964                              <1> 	; 28/05/2017
 72965                              <1> 	; Derived from 'setLastValidIndex' procedure in 'ICHWAV.ASM'
 72966                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
 72967 00014595 668B15[E2890100]    <1> 	mov	dx, [NABMBAR]
 72968 0001459C 6683C215            <1> 	add	dx, PO_LVI_REG
 72969 000145A0 EE                  <1>         out     dx, al
 72970                              <1> 	;mov	[audio_lvi], al ; for ac97_int_handler
 72971 000145A1 C3                  <1> 	retn
 72972                              <1> 
 72973                              <1> ac97_volume:
 72974                              <1> 	; 28/05/2017
 72975                              <1> 	; bl = component (0 = master/playback/lineout volume)
 72976                              <1> 	; cl = left channel volume level (0 to 31)
 72977                              <1> 	; ch = right channel volume level (0 to 31)
 72978                              <1> 
 72979 000145A2 08DB                <1> 	or	bl, bl
 72980 000145A4 7523                <1> 	jnz	short ac97_vol_1 ; temporary !
 72981 000145A6 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
 72982 000145AA 38C1                <1> 	cmp	cl, al
 72983 000145AC 771B                <1> 	ja	short ac97_vol_1 ; temporary !
 72984 000145AE 38E5                <1> 	cmp	ch, ah
 72985 000145B0 7717                <1> 	ja	short ac97_vol_1 ; temporary !
 72986 000145B2 66890D[DE890100]    <1> 	mov	[audio_master_volume], cx
 72987 000145B9 6629C8              <1> 	sub	ax, cx
 72988 000145BC 668B15[E0890100]    <1>   	mov     dx, [NAMBAR]
 72989 000145C3 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG  ; 02h ; Line Out 
 72990 000145C7 66EF                <1>   	out     dx, ax
 72991                              <1> ac97_vol_1:
 72992                              <1> _ac97_ih5:	; 06/08/2022
 72993 000145C9 C3                  <1> 	retn
 72994                              <1> 
 72995                              <1> ac97_int_handler:
 72996                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 72997                              <1> 	; 12/10/2017
 72998                              <1> 	; 10/10/2017
 72999                              <1> 	; 09/10/2017
 73000                              <1> 	; 13/06/2017, 13/06/2017
 73001                              <1> 	; 10/06/2017, 11/06/2017
 73002                              <1> 	; Interrupt Handler for AC97 (ICH) Audio Controller
 73003                              <1> 	; Note: called by 'dev_IRQ_service' 
 73004                              <1> 	; 28/05/2017
 73005                              <1> 
 73006                              <1> 	;push	eax ; * must be saved !
 73007                              <1> 	;push	edx
 73008                              <1> 	;push	ecx
 73009                              <1> 	;push	ebx ; * must be saved !
 73010                              <1> 	;push	esi
 73011                              <1> 	;push	edi
 73012                              <1> 
 73013                              <1> 	;cmp	byte [audio_busy], 1
 73014                              <1> 	;jnb	_ac97_ih2 ; busy !
 73015                              <1> 
 73016 000145CA 66BA3000            <1>         mov     dx, GLOB_STS_REG
 73017 000145CE 660315[E2890100]    <1>         add	dx, [NABMBAR]
 73018 000145D5 ED                  <1> 	in	eax, dx
 73019                              <1> 
 73020 000145D6 83F8FF              <1>         cmp     eax, 0FFFFFFFFh ; -1
 73021                              <1> 	;je	_ac97_ih3 ; exit
 73022                              <1> 	; 06/08/2022
 73023 000145D9 74EE                <1> 	je	short _ac97_ih5
 73024                              <1> 
 73025                              <1>         ;test	eax, 40h ; PCM Out Interrupt
 73026                              <1> 	; 06/08/2022
 73027 000145DB A840                <1> 	test	al, 40h
 73028 000145DD 7506                <1> 	jnz     short _ac97_ih0
 73029                              <1> 
 73030 000145DF 85C0                <1> 	test	eax, eax
 73031                              <1> 	;jz	_ac97_ih3 ; exit
 73032                              <1> 	; 06/08/2022
 73033 000145E1 74E6                <1> 	jz	short _ac97_ih5
 73034                              <1> 
 73035                              <1>  	;mov	dx, GLOB_STS_REG
 73036                              <1>         ;add	dx, [NABMBAR]
 73037 000145E3 EF                  <1> 	out	dx, eax
 73038                              <1> 
 73039                              <1> 	;jmp	_ac97_ih3 ; exit
 73040                              <1> 	; 06/08/2022
 73041 000145E4 C3                  <1> 	retn
 73042                              <1> 
 73043                              <1> _ac97_ih0:
 73044 000145E5 50                  <1> 	push	eax
 73045                              <1> 	; 09/10/2017
 73046 000145E6 803D[DC890100]01    <1> 	cmp	byte [audio_play_cmd], 1
 73047 000145ED 727C                <1> 	jb	short _ac97_ih4 ; stop command !
 73048                              <1> 
 73049                              <1> 	;mov	byte [audio_busy], 1
 73050                              <1> 
 73051                              <1> 	;mov	al, 10h
 73052                              <1> 	;mov	dx, PO_CR_REG
 73053                              <1>         ;add	dx, [NABMBAR]
 73054                              <1> 	;out	dx, al
 73055                              <1> 
 73056 000145EF 66B81C00            <1> 	mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
 73057 000145F3 66BA1600            <1> 	mov	dx, PO_SR_REG
 73058 000145F7 660315[E2890100]    <1>         add	dx, [NABMBAR]
 73059 000145FE 66EF                <1> 	out	dx, ax
 73060                              <1> 
 73061 00014600 66BA1400            <1> 	mov	dx, PO_CIV_REG
 73062 00014604 660315[E2890100]    <1>         add	dx, [NABMBAR]
 73063 0001460B EC                  <1> 	in	al, dx
 73064                              <1> 
 73065                              <1> 	;cmp	al, [audio_civ] ; [audio_flag]
 73066                              <1> 	;je	short _ac97_ih2
 73067                              <1> 
 73068 0001460C A2[DD890100]        <1> 	mov	[audio_civ], al
 73069 00014611 FEC8                <1> 	dec	al
 73070                              <1> 	;inc	al ; 11/06/2017
 73071 00014613 241F                <1> 	and	al, 1Fh
 73072                              <1> 
 73073 00014615 66BA1500            <1>         mov     dx, PO_LVI_REG
 73074 00014619 660315[E2890100]    <1>         add	dx, [NABMBAR]
 73075 00014620 EE                  <1>         out	dx, al
 73076                              <1> 
 73077                              <1> 	; 12/10/2017
 73078 00014621 A0[DD890100]        <1> 	mov	al, [audio_civ]
 73079 00014626 FEC0                <1> 	inc	al
 73080 00014628 2401                <1> 	and	al, 1
 73081 0001462A A2[D0890100]        <1> 	mov	[audio_flag], al 
 73082                              <1> 	;; [audio_flag] : 0 = Buffer 1, 1 = Buffer 2
 73083                              <1> 	;
 73084 0001462F 58                  <1> 	pop	eax
 73085                              <1> 	;
 73086 00014630 83E040              <1> 	and     eax, 40h
 73087 00014633 668B15[E2890100]    <1>         mov	dx, [NABMBAR]
 73088 0001463A 6683C230            <1> 	add	dx, GLOB_STS_REG
 73089 0001463E EF                  <1> 	out	dx, eax
 73090                              <1> 
 73091                              <1> 	;; 13/06/2017
 73092                              <1> 	;mov	al, 11h ; IOCE + RPBM
 73093                              <1> 	;mov	dx, PO_CR_REG
 73094                              <1>         ;add	dx, [NABMBAR]
 73095                              <1> 	;out	dx, al
 73096                              <1> 
 73097                              <1> ac97_tuneloop:
 73098                              <1> 	; 09/10/2017
 73099 0001463F 8B3D[C8890100]      <1> 	mov	edi, [audio_dma_buff]
 73100 00014645 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size]
 73101 0001464B D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
 73102                              <1> 
 73103                              <1> 	; 12/10/2017
 73104 0001464D 803D[D0890100]00    <1> 	cmp 	byte [audio_flag], 0
 73105 00014654 7702                <1> 	ja	short _ac97_ih1  ; Playing Half Buffer 2 (Current: FLAG)
 73106                              <1> 	; Playing Half Buffer 1 (Current: EOL)	
 73107 00014656 01CF                <1> 	add	edi, ecx
 73108                              <1> _ac97_ih1: 
 73109                              <1> 	; Update half buffer 2 while playing half buffer 1 (next: FLAG)
 73110                              <1> 	; Update half buffer 1 while playing half buffer 2 (next: EOL)
 73111                              <1> 
 73112 00014658 8B35[C0890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
 73113 0001465E C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
 73114 00014661 F3A5                <1> 	rep	movsd 
 73115                              <1> 
 73116                              <1> 	; 10/10/2017
 73117                              <1> 	; switch flag value
 73118 00014663 8035[D0890100]01    <1> 	xor	byte [audio_flag], 1
 73119                              <1> 	; 12/10/2017
 73120                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (even index value)
 73121                              <1> 			   ; Next buffer (to update) is dma half buff 1
 73122                              <1> 	; 	       = 1 : Playing dma half buffer 1 (odd index value)
 73123                              <1> 			   ; Next buffer (to update) is dma half buff 2
 73124                              <1> _ac97_ih2:
 73125                              <1> 	;mov	byte [audio_busy], 0
 73126                              <1> _ac97_ih3:
 73127                              <1> 	;pop	edi
 73128                              <1> 	;pop	esi
 73129                              <1> 	;pop	ebx ; * must be restored !
 73130                              <1> 	;pop	ecx
 73131                              <1> 	;pop	edx
 73132                              <1> 	;pop	eax ; * must be restored !
 73133                              <1> 
 73134 0001466A C3                  <1> 	retn
 73135                              <1> 
 73136                              <1> _ac97_ih4:
 73137                              <1> 	; 09/10/2017
 73138 0001466B E818000000          <1> 	call	_ac97_stop
 73139                              <1> 	;
 73140 00014670 58                  <1> 	pop	eax
 73141                              <1> 	;
 73142 00014671 83E040              <1> 	and     eax, 40h
 73143 00014674 668B15[E2890100]    <1>         mov	dx, [NABMBAR]
 73144 0001467B 6683C230            <1> 	add	dx, GLOB_STS_REG
 73145 0001467F EF                  <1> 	out	dx, eax
 73146                              <1> 
 73147                              <1> 	;; 13/06/2017
 73148                              <1> 	;mov	al, 11h ; IOCE + RPBM
 73149                              <1> 	;mov	dx, PO_CR_REG
 73150                              <1>         ;add	dx, [NABMBAR]
 73151                              <1> 	;out	dx, al
 73152                              <1> 
 73153                              <1> 	; 10/10/2017
 73154                              <1> 	;jmp	short _ac97_ih3  ; exit
 73155 00014680 C3                  <1> 	retn
 73156                              <1> 
 73157                              <1> ac97_stop: 
 73158                              <1> 	; 28/05/2017
 73159 00014681 C605[DC890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
 73160                              <1> _ac97_stop: ; 09/10/2017
 73161                              <1> 	; 29/05/2017
 73162                              <1> 	;mov	dx, [NABMBAR]
 73163                              <1> 	;add	dx, PO_CR_REG
 73164                              <1> 	;mov	al, 0
 73165                              <1> 	;out	dx, al
 73166                              <1> 
 73167                              <1> 	; 11/06/2017
 73168 00014688 30C0                <1> 	xor	al, al ; 0
 73169 0001468A E813000000          <1> 	call	ac97_po_cmd
 73170                              <1> 
 73171                              <1> 	; (Ref: KolibriOS, intelac97.asm, 'stop:')
 73172                              <1> 	; Clear FIFOE, BCIS, LVBCI (Ref: Intel ICH hub manual)
 73173 0001468F 66B81C00            <1> 	mov     ax, 1Ch
 73174 00014693 668B15[E2890100]    <1> 	mov     dx, [NABMBAR]
 73175 0001469A 6683C216            <1> 	add     dx, PO_SR_REG
 73176 0001469E 66EF                <1> 	out     dx, ax
 73177                              <1> 
 73178                              <1> 	;retn
 73179                              <1> 
 73180                              <1> 	; 11/06/2017
 73181 000146A0 B002                <1> 	mov     al, RR
 73182                              <1> ac97_po_cmd:
 73183                              <1> 	 ;11/06/2017
 73184                              <1> 	; 29/05/2017
 73185 000146A2 668B15[E2890100]    <1> 	mov     dx, [NABMBAR]
 73186 000146A9 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
 73187 000146AD EE                  <1> 	out	dx, al
 73188 000146AE C3                  <1> 	retn
 73189                              <1> 
 73190                              <1> ac97_pause:
 73191                              <1> 	; 11/06/2017
 73192                              <1> 	; 29/05/2017
 73193 000146AF B010                <1> 	mov 	al, IOCE
 73194 000146B1 EBEF                <1> 	jmp	short ac97_po_cmd
 73195                              <1> 
 73196                              <1> reset_ac97_controller:
 73197                              <1> 	; 10/06/2017
 73198                              <1> 	; 29/05/2017
 73199                              <1> 	; 28/05/2017
 73200                              <1> 	; reset AC97 audio controller registers
 73201 000146B3 31C0                <1> 	xor     eax, eax
 73202 000146B5 66BA0B00            <1>         mov	dx, PI_CR_REG
 73203 000146B9 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73204 000146C0 EE                  <1> 	out     dx, al
 73205                              <1> 
 73206 000146C1 66BA1B00            <1>         mov     dx, PO_CR_REG
 73207 000146C5 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73208 000146CC EE                  <1> 	out     dx, al
 73209                              <1> 
 73210 000146CD 66BA2B00            <1>         mov     dx, MC_CR_REG
 73211 000146D1 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73212 000146D8 EE                  <1> 	out     dx, al
 73213                              <1> 
 73214 000146D9 B002                <1>         mov     al, RR
 73215 000146DB 66BA0B00            <1>         mov     dx, PI_CR_REG
 73216 000146DF 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73217 000146E6 EE                  <1> 	out     dx, al
 73218                              <1> 
 73219 000146E7 66BA1B00            <1>         mov     dx, PO_CR_REG
 73220 000146EB 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73221 000146F2 EE                  <1> 	out     dx, al
 73222                              <1> 
 73223 000146F3 66BA2B00            <1>         mov     dx, MC_CR_REG
 73224 000146F7 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73225 000146FE EE                  <1> 	out     dx, al
 73226                              <1> 
 73227 000146FF C3                  <1> 	retn
 73228                              <1> 
 73229                              <1> ac97_reset:
 73230                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73231                              <1> 	; 10/06/2017
 73232                              <1> 	; 29/05/2017
 73233                              <1> 	; 28/05/2017
 73234 00014700 E8AEFFFFFF          <1> 	call	reset_ac97_controller
 73235                              <1> 	; 29/05/2017
 73236                              <1> 	;jmp	reset_ac97_codec
 73237                              <1> reset_ac97_codec:
 73238                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
 73239 00014705 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
 73240 00014709 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73241 00014710 ED                  <1> 	in	eax, dx
 73242                              <1> 
 73243                              <1> 	;test	eax, 2
 73244                              <1> 	; 06/08/2022
 73245 00014711 A802                <1> 	test	al, 2
 73246 00014713 7407                <1> 	jz	short _r_ac97codec_cold	
 73247                              <1> 
 73248 00014715 E80F000000          <1> 	call	warm_ac97codec_reset
 73249 0001471A 7308                <1> 	jnc	short _r_ac97codec_ok
 73250                              <1> _r_ac97codec_cold:
 73251 0001471C E83B000000          <1>         call    cold_ac97codec_reset
 73252 00014721 7301                <1>         jnc     short _r_ac97codec_ok
 73253                              <1> 	
 73254                              <1> 	; 16/04/2017
 73255                              <1>         ;xor	eax, eax	; timeout error
 73256                              <1>        	;stc
 73257 00014723 C3                  <1> 	retn
 73258                              <1> 
 73259                              <1> _r_ac97codec_ok:
 73260 00014724 31C0                <1>         xor     eax, eax
 73261                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
 73262 00014726 FEC0                <1>         inc	al
 73263 00014728 C3                  <1> 	retn
 73264                              <1> 
 73265                              <1> warm_ac97codec_reset:
 73266                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73267                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
 73268                              <1>         ;mov	eax, 6
 73269                              <1> 	; 06/08/2022
 73270 00014729 29C0                <1> 	sub	eax, eax
 73271 0001472B B006                <1> 	mov	al, 6
 73272 0001472D 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
 73273 00014731 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73274 00014738 EF                  <1> 	out	dx, eax
 73275                              <1> 
 73276                              <1> 	;mov	ecx, 10	; total 1s
 73277                              <1> 	; 06/08/2022
 73278 00014739 31C9                <1> 	xor	ecx, ecx
 73279 0001473B B10A                <1> 	mov	cl, 10
 73280                              <1> _warm_ac97c_rst_wait:
 73281 0001473D 51                  <1> 	push	ecx
 73282 0001473E E83EF6FFFF          <1> 	call	delay_100ms
 73283 00014743 59                  <1> 	pop	ecx
 73284                              <1> 
 73285 00014744 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
 73286 00014748 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73287 0001474F ED                  <1> 	in	eax, dx
 73288                              <1> 
 73289 00014750 A900030010          <1> 	test	eax, CTRL_ST_CREADY
 73290 00014755 7504                <1> 	jnz	short _warm_ac97c_rst_ok
 73291                              <1> 
 73292 00014757 49                  <1>         dec     ecx
 73293 00014758 75E3                <1>         jnz     short _warm_ac97c_rst_wait
 73294                              <1> 
 73295                              <1> _warm_ac97c_rst_fail:
 73296 0001475A F9                  <1>         stc
 73297                              <1> _warm_ac97c_rst_ok:
 73298 0001475B C3                  <1> 	retn
 73299                              <1> 
 73300                              <1> cold_ac97codec_reset:
 73301                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73302                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
 73303                              <1>         ;mov	eax, 2
 73304                              <1> 	; 06/08/2022
 73305 0001475C 31C0                <1> 	xor	eax, eax
 73306 0001475E B002                <1> 	mov	al, 2
 73307 00014760 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
 73308 00014764 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73309 0001476B EF                  <1> 	out	dx, eax
 73310                              <1> 
 73311 0001476C E810F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
 73312 00014771 E80BF6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
 73313 00014776 E806F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
 73314 0001477B E801F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
 73315                              <1> 
 73316                              <1> 	;mov	ecx, 16	; total 20*100 ms = 2s
 73317                              <1> 	; 06/08/2022
 73318 00014780 31C9                <1> 	xor	ecx, ecx
 73319 00014782 B110                <1> 	mov	cl, 16
 73320                              <1> _cold_ac97c_rst_wait:
 73321 00014784 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
 73322 00014788 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73323 0001478F ED                  <1> 	in	eax, dx
 73324                              <1> 
 73325 00014790 A900030010          <1> 	test	eax, CTRL_ST_CREADY
 73326 00014795 750B                <1> 	jnz	short _cold_ac97c_rst_ok
 73327                              <1> 
 73328 00014797 51                  <1> 	push	ecx
 73329 00014798 E8E4F5FFFF          <1> 	call	delay_100ms
 73330 0001479D 59                  <1> 	pop	ecx
 73331                              <1> 
 73332 0001479E 49                  <1>         dec     ecx
 73333 0001479F 75E3                <1>         jnz     short _cold_ac97c_rst_wait
 73334                              <1> 
 73335                              <1> _cold_ac97c_rst_fail:
 73336 000147A1 F9                  <1>         stc
 73337                              <1> _cold_ac97c_rst_ok:
 73338 000147A2 C3                  <1> 	retn
 73339                              <1> 
 73340                              <1> sb16_current_sound_data:
 73341                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73342                              <1> 	; 20/08/2017
 73343                              <1> 	; 24/06/2017
 73344                              <1> 	; 22/06/2017
 73345                              <1> 	; get current sound (PCM out) data for graphics
 73346                              <1> 	; (for Sound Blaster 16)
 73347                              <1> 	; ebx = Physical address (on page boundary)
 73348                              <1> 	; ecx = Byte count
 73349                              <1> 	; [audio_buff_size]
 73350                              <1> 
 73351                              <1> 	;;mov	edi, [audio_buff_size]
 73352                              <1> 	;mov	edi, [audio_dmabuff_size]
 73353                              <1> 	;mov	esi, [audio_dma_buff]
 73354 000147A3 39CF                <1> 	cmp	edi, ecx
 73355 000147A5 7302                <1> 	jnb	short sb16_gcd_0
 73356 000147A7 89F9                <1> 	mov	ecx, edi
 73357                              <1> sb16_gcd_0:
 73358                              <1> 	; 06/08/2022
 73359 000147A9 31C0                <1> 	xor	eax, eax
 73360                              <1> 	; 20/08/2017
 73361 000147AB 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16
 73362 000147B2 750C                <1> 	jne	short sb16_gcd_1 ; 8 bit DMA channel
 73363 000147B4 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
 73364                              <1> 	;mov	dl, al
 73365                              <1> 	; 06/08/2022
 73366 000147B6 88C4                <1> 	mov	ah, al
 73367 000147B8 E4C6                <1> 	in	al, 0C6h
 73368                              <1> 	;mov	dh, al
 73369                              <1> 	;movzx	eax, dx
 73370                              <1> 	; 06/08/2022
 73371 000147BA 86E0                <1> 	xchg	ah, al
 73372 000147BC D1E0                <1> 	shl	eax, 1 ; word count -> byte count
 73373 000147BE EB4A                <1> 	jmp	short sb16_gcd_2	
 73374                              <1> sb16_gcd_1:
 73375 000147C0 E403                <1> 	in	al, 03h ; DMA channel 1 count register
 73376                              <1> 	;mov	dl, al
 73377                              <1> 	; 06/08/2022
 73378 000147C2 88C4                <1> 	mov	ah, al
 73379 000147C4 E403                <1> 	in	al, 03h
 73380                              <1> 	;mov	dh, al
 73381                              <1> 	;movzx	eax, dx
 73382                              <1> 	; 06/08/2022
 73383 000147C6 86E0                <1> 	xchg	ah, al
 73384 000147C8 EB40                <1> 	jmp	short sb16_gcd_2
 73385                              <1> ;sb16_gcd_2:	
 73386                              <1> ;	cmp	eax, ecx
 73387                              <1> ;	jnb	short sb16_gcd_3 
 73388                              <1> ;	; remain count < graphics bytes
 73389                              <1> ;	mov	eax, ecx ; fix remain count to data size
 73390                              <1> ;sb16_gcd_3:	
 73391                              <1> ;	sub	edi, eax
 73392                              <1> ;	jna	short sb16_gcd_4
 73393                              <1> ;	add	esi, edi ; dma buffer offset
 73394                              <1> ;sb16_gcd_4:
 73395                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
 73396                              <1> ;	mov	[u.r0], ecx
 73397                              <1> ;	rep	movsb
 73398                              <1> ;	retn
 73399                              <1> 
 73400                              <1> get_current_sound_data:
 73401                              <1> 	; 24/06/2017
 73402                              <1> 	; 22/06/2017
 73403                              <1> 	; get current sound (PCM out) data for graphics
 73404                              <1> 	;
 73405                              <1> 	; ebx = Physical address (on page boundary)
 73406                              <1> 	; ecx = Byte count
 73407                              <1> 	; [audio_buff_size]
 73408                              <1> 
 73409                              <1> 	;mov	edi, [audio_buff_size]
 73410 000147CA 8B3D[CC890100]      <1> 	mov	edi, [audio_dmabuff_size]
 73411 000147D0 8B35[C8890100]      <1> 	mov	esi, [audio_dma_buff]
 73412 000147D6 803D[A9890100]02    <1> 	cmp	byte [audio_device], 2
 73413 000147DD 72C4                <1> 	jb	short sb16_current_sound_data ; = 1
 73414 000147DF D1EF                <1> 	shr	edi, 1
 73415 000147E1 39CF                <1> 	cmp	edi, ecx
 73416 000147E3 7302                <1> 	jnb	short gcd_0
 73417 000147E5 89F9                <1> 	mov	ecx, edi
 73418                              <1> gcd_0:
 73419 000147E7 803D[A9890100]03    <1> 	cmp	byte [audio_device], 3
 73420 000147EE 7231                <1> 	jb	short ac97_current_sound_data ; = 2
 73421                              <1> 	; = 3
 73422                              <1> vt8233_current_sound_data:
 73423                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73424                              <1> 	; 22/06/2017
 73425                              <1> 	; 21/06/2017
 73426                              <1> 	; get current sound (PCM out) data for graphics
 73427                              <1> 	; (for VT 8233, VT 8237R)
 73428                              <1> 	; ebx = Physical address (on page boundary)
 73429                              <1> 	; ecx = Byte count
 73430                              <1> 	; [audio_buff_size]
 73431                              <1> 	
 73432                              <1> 	;;mov	edi, [audio_buff_size]
 73433                              <1> 	;mov	edi, [audio_dmabuff_size]
 73434                              <1> 	;mov	esi, [audio_dma_buff]
 73435                              <1> 	;shr	edi, 1
 73436                              <1> 	;cmp	edi, ecx
 73437                              <1> 	;jnb	short vt8233_gcd_1
 73438                              <1> 	;mov	ecx, edi
 73439                              <1> vt8233_gcd_1:
 73440                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_COUNT
 73441                              <1> 	; 06/08/2022
 73442 000147F0 31D2                <1> 	xor	edx, edx
 73443 000147F2 B20C                <1> 	mov	dl, VIA_REG_OFFSET_CURR_COUNT
 73444 000147F4 E8E8F5FFFF          <1> 	call	ctrl_io_r32
 73445 000147F9 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
 73446                              <1> 			 ; SGD index (bits 31-24) 
 73447 000147FB 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
 73448 00014801 7402                <1> 	jz	short vt8233_gcd_2
 73449                              <1> 	; the second half of DMA buffer
 73450 00014803 01FE                <1> 	add	esi, edi 
 73451                              <1> vt8233_gcd_2:	
 73452 00014805 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
 73453                              <1> ac97_gcd_2:
 73454                              <1> sb16_gcd_2:
 73455 0001480A 39C8                <1> 	cmp	eax, ecx
 73456 0001480C 7302                <1> 	jnb	short vt8233_gcd_3 
 73457                              <1> 	; remain count < graphics bytes
 73458 0001480E 89C8                <1> 	mov	eax, ecx ; fix remain count to data size
 73459                              <1> vt8233_gcd_3:
 73460 00014810 29C7                <1> 	sub	edi, eax
 73461 00014812 7602                <1> 	jna	short vt8233_gcd_4
 73462 00014814 01FE                <1> 	add	esi, edi ; dma buffer offset
 73463                              <1> vt8233_gcd_4:
 73464 00014816 89DF                <1> 	mov	edi, ebx ; buffer address (for graphics) 
 73465 00014818 890D[1C010300]      <1> 	mov	[u.r0], ecx
 73466 0001481E F3A4                <1> 	rep	movsb
 73467                              <1> vt8233_gcd_5:
 73468 00014820 C3                  <1> 	retn
 73469                              <1> 
 73470                              <1> ac97_current_sound_data:
 73471                              <1> 	; 23/06/2017
 73472                              <1> 	; 22/06/2017
 73473                              <1> 	; get current sound (PCM out) data for graphics
 73474                              <1> 	; (for AC'97, ICH)
 73475                              <1> 	; ebx = Physical address (on page boundary)
 73476                              <1> 	; ecx = Byte count
 73477                              <1> 	; [audio_buff_size]
 73478                              <1> 	
 73479                              <1> 	;;mov	edi, [audio_buff_size]
 73480                              <1> 	;mov	edi, [audio_dmabuff_size]
 73481                              <1> 	;mov	esi, [audio_dma_buff]
 73482                              <1> 	;shr	edi, 1
 73483                              <1> 	;cmp	edi, ecx
 73484                              <1> 	;jnb	short ac97_gcd_0
 73485                              <1> 	;mov	ecx, edi
 73486                              <1> ac97_gcd_0:
 73487 00014821 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
 73488 00014825 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73489 0001482C EC                  <1> 	in	al, dx ; current index value
 73490 0001482D A801                <1> 	test	al, 1
 73491 0001482F 7402                <1> 	jz	short ac97_gcd_1
 73492 00014831 01FE                <1> 	add	esi, edi
 73493                              <1> ac97_gcd_1:
 73494 00014833 31C0                <1> 	xor	eax, eax
 73495 00014835 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
 73496 00014839 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73497 00014840 66ED                <1> 	in	ax, dx ; remain dwords
 73498 00014842 C1E002              <1> 	shl	eax, 2 ; remain bytes ; 23/06/2017 
 73499 00014845 EBC3                <1> 	jmp	short ac97_gcd_2
 73500                              <1> ;	cmp	eax, ecx
 73501                              <1> ;	jnb	short ac97_gcd_2 
 73502                              <1> ;	; remain count < graphics bytes
 73503                              <1> ;	mov	eax, ecx ; fix remain count to data size
 73504                              <1> ;ac97_gcd_2:	
 73505                              <1> ;	sub	edi, eax
 73506                              <1> ;	jna	short ac97_gcd_3
 73507                              <1> ;	add	esi, edi ; dma buffer offset
 73508                              <1> ;ac97_gcd_3:
 73509                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
 73510                              <1> ;	mov	[u.r0], ecx
 73511                              <1> ;	rep	movsb
 73512                              <1> ;	retn
 73513                              <1> 
 73514                              <1> sb16_get_dma_buff_off:
 73515                              <1> 	; 28/10/2017
 73516                              <1> 	; 24/06/2017
 73517                              <1> 	; 22/06/2017
 73518                              <1> 	; get current (PCM OUT DMA buffer) pointer
 73519                              <1> 	; (for Sound Blaster 16)
 73520                              <1> 
 73521                              <1> 	;mov	ecx, [audio_dmabuff_size]
 73522                              <1> 	;xor	ebx, ebx
 73523                              <1> 	;shr	ecx, 1
 73524                              <1> sb16_gdmabo_0:
 73525                              <1> 	; 28/10/2017
 73526 00014847 803D[D8890100]10    <1> 	cmp	byte [audio_bps], 16
 73527 0001484E 750F                <1> 	jne	short sb16_gdmabo_1 ; 8 bit DMA channel
 73528                              <1> 	; 16 bit DMA channel
 73529 00014850 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
 73530 00014852 88C2                <1> 	mov	dl, al	
 73531 00014854 E4C6                <1> 	in	al, 0C6h
 73532 00014856 88C6                <1> 	mov     dh, al
 73533 00014858 0FB7C2              <1> 	movzx	eax, dx
 73534 0001485B D1E0                <1> 	shl	eax, 1 ; word count -> byte count
 73535 0001485D EB3C                <1> 	jmp	short sb16_gdmabo_2	
 73536                              <1> sb16_gdmabo_1:
 73537 0001485F E403                <1> 	in	al, 03h ; DMA channel 1 count register
 73538 00014861 88C2                <1> 	mov	dl, al	
 73539 00014863 E403                <1> 	in	al, 03h
 73540 00014865 88C6                <1> 	mov     dh, al
 73541 00014867 0FB7C2              <1> 	movzx	eax, dx
 73542 0001486A EB2F                <1> 	jmp	short sb16_gdmabo_2
 73543                              <1> 
 73544                              <1> get_dma_buffer_offset:
 73545                              <1> 	; 24/06/2017
 73546                              <1> 	; 22/06/2017
 73547                              <1> 	; get current sound (PCM out) data for graphics
 73548                              <1> 	;
 73549                              <1> 	; ebx = Physical address (on page boundary)
 73550                              <1> 	; ecx = Byte count
 73551                              <1> 	; [audio_buff_size]
 73552                              <1> 
 73553 0001486C 8B0D[CC890100]      <1> 	mov	ecx, [audio_dmabuff_size]
 73554 00014872 31DB                <1> 	xor	ebx, ebx
 73555                              <1> gdmabo_0:
 73556 00014874 803D[A9890100]02    <1> 	cmp	byte [audio_device], 2
 73557 0001487B 72CA                <1> 	jb	short sb16_get_dma_buff_off
 73558 0001487D 7429                <1> 	je	short ac97_get_dma_buff_off
 73559                              <1> 
 73560                              <1> vt8233_get_dma_buff_off:
 73561                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
 73562                              <1> 	; 24/06/2017
 73563                              <1> 	; 22/06/2017
 73564                              <1> 	; get current (PCM OUT DMA buffer) pointer
 73565                              <1> 	; (for VT 8233, VT 8237R)
 73566                              <1> 	
 73567                              <1> 	;mov	ecx, [audio_dmabuff_size]
 73568                              <1> 	;xor	ebx, ebx
 73569 0001487F D1E9                <1> 	shr	ecx, 1
 73570                              <1> vt8233_gdmabo_0:
 73571                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_COUNT
 73572                              <1> 	; 06/08/2022
 73573 00014881 31D2                <1> 	xor	edx, edx
 73574 00014883 B20C                <1> 	mov	dl, VIA_REG_OFFSET_CURR_COUNT
 73575 00014885 E857F5FFFF          <1> 	call	ctrl_io_r32
 73576 0001488A 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
 73577                              <1> 			 ; SGD index (bits 31-24) 
 73578 0001488C 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
 73579 00014892 7402                <1> 	jz	short vt8233_gdmabo_1
 73580                              <1> 	; the second half of DMA buffer
 73581 00014894 89CB                <1> 	mov	ebx, ecx 
 73582                              <1> vt8233_gdmabo_1:	
 73583 00014896 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
 73584                              <1> sb16_gdmabo_2:
 73585                              <1> ac97_gdmabo_2:
 73586 0001489B 29C1                <1> 	sub	ecx, eax
 73587 0001489D 7602                <1> 	jna	short vt8233_gdmabo_2
 73588 0001489F 01CB                <1> 	add	ebx, ecx ; dma buffer offset
 73589                              <1> vt8233_gdmabo_2:
 73590 000148A1 891D[1C010300]      <1> 	mov	[u.r0], ebx
 73591 000148A7 C3                  <1> 	retn
 73592                              <1> 
 73593                              <1> ac97_get_dma_buff_off:
 73594                              <1> 	; 24/06/2017
 73595                              <1> 	; 22/06/2017
 73596                              <1> 	; get current (PCM OUT DMA buffer) pointer
 73597                              <1> 	; (for AC'97, ICH)
 73598                              <1> 	; ebx = Physical address (on page boundary)
 73599                              <1> 	; ecx = Byte count
 73600                              <1> 	; [audio_buff_size]
 73601                              <1> 	
 73602                              <1> 	;mov	ecx, [audio_dmabuff_size]
 73603                              <1> 	;xor	ebx, ebx
 73604 000148A8 D1E9                <1> 	shr	ecx, 1
 73605                              <1> ac97_gdmabo_0:
 73606 000148AA 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
 73607 000148AE 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73608 000148B5 EC                  <1> 	in	al, dx ; current index value
 73609 000148B6 A801                <1> 	test	al, 1
 73610 000148B8 7402                <1> 	jz	short ac97_gdmabo_1
 73611 000148BA 89CB                <1> 	mov	ebx, ecx
 73612                              <1> ac97_gdmabo_1:
 73613 000148BC 31C0                <1> 	xor	eax, eax
 73614 000148BE 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
 73615 000148C2 660315[E2890100]    <1> 	add	dx, [NABMBAR]
 73616 000148C9 66ED                <1> 	in	ax, dx ; remain dwords
 73617 000148CB EBCE                <1> 	jmp	short ac97_gdmabo_2
 73618                                  
 73619 000148CD 90<rept>                align 4
 73620                                  
 73621                                  %include 'vgadata.s' ; 04/07/2016
 73622                              <1> ; ****************************************************************************************************
 73623                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vgadata.s  (palette and font data)
 73624                              <1> ; -----------------------------------------------------------------------------
 73625                              <1> ; Last Update: 01/01/2021
 73626                              <1> ; -----------------------------------------------------------------------------
 73627                              <1> ; Beginning: 16/01/2016
 73628                              <1> ; -----------------------------------------------------------------------------
 73629                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 73630                              <1> ; -----------------------------------------------------------------------------
 73631                              <1> ; Turkish Rational DOS
 73632                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 73633                              <1> ;
 73634                              <1> ; Derived from 'Plex86/Bochs VGABios' source code, vgabios-0.7a (2011)
 73635                              <1> ; by the LGPL VGABios Developers Team (2001-2008), 'vgatables.h'
 73636                              <1> ;
 73637                              <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 
 73638                              <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
 73639                              <1> ;
 73640                              <1> ; Palette and font data in assembly language format:
 73641                              <1> ; 'VBoxVgaBiosAlternative.asm'
 73642                              <1> 
 73643                              <1> ; ****************************************************************************************************
 73644                              <1> 
 73645                              <1> ; 25/11/2020 (TRDOS 386 v2.0.3)
 73646                              <1> ; ('vgatables.h' - 30/12/2019 - vruppert)
 73647                              <1>  
 73648                              <1> ; 04/07/2016
 73649                              <1> ; COLOR DATA
 73650                              <1> 
 73651                              <1> palette0: ; (63+1)*3
 73652 000148D0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 73653 000148D9 00000000000000      <1>
 73654 000148E0 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73655 000148E9 2A2A2A2A2A2A2A      <1>
 73656 000148F0 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73657 000148F9 2A2A2A2A2A2A2A      <1>
 73658 00014900 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73659 00014909 2A2A2A2A2A2A2A      <1>
 73660 00014910 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
 73661 00014919 3F3F3F3F3F3F3F      <1>
 73662 00014920 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
 73663 00014929 3F3F3F3F3F3F3F      <1>
 73664 00014930 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 73665 00014939 00000000000000      <1>
 73666 00014940 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73667 00014949 2A2A2A2A2A2A2A      <1>
 73668 00014950 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73669 00014959 2A2A2A2A2A2A2A      <1>
 73670 00014960 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
 73671 00014969 2A2A2A2A2A2A2A      <1>
 73672 00014970 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
 73673 00014979 3F3F3F3F3F3F3F      <1>
 73674 00014980 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
 73675 00014989 3F3F3F3F3F3F3F      <1>
 73676                              <1> palette1: ; (63+1)*3	
 73677 00014990 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
 73678 00014999 002A2A2A00002A      <1>
 73679 000149A0 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
 73680 000149A9 000000002A002A      <1>
 73681 000149B0 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
 73682 000149B9 2A2A15002A2A2A      <1>
 73683 000149C0 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
 73684 000149C9 153F3F3F15153F      <1>
 73685 000149D0 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
 73686 000149D9 151515153F153F      <1>
 73687 000149E0 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
 73688 000149E9 3F3F3F153F3F3F      <1>
 73689 000149F0 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
 73690 000149F9 002A2A2A00002A      <1>
 73691 00014A00 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
 73692 00014A09 000000002A002A      <1>
 73693 00014A10 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
 73694 00014A19 2A2A15002A2A2A      <1>
 73695 00014A20 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
 73696 00014A29 153F3F3F15153F      <1>
 73697 00014A30 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
 73698 00014A39 151515153F153F      <1>
 73699 00014A40 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
 73700 00014A49 3F3F3F153F3F3F      <1>
 73701                              <1> palette2: ; (63+1)*3
 73702 00014A50 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
 73703 00014A59 002A2A2A00002A      <1>
 73704 00014A60 002A2A2A002A2A2A00- <1>     db  000h, 02ah, 02ah, 02ah, 000h, 02ah, 02ah, 02ah, 000h, 000h, 015h, 000h, 000h, 03fh, 000h, 02ah
 73705 00014A69 001500003F002A      <1>
 73706 00014A70 15002A3F2A00152A00- <1>     db  015h, 000h, 02ah, 03fh, 02ah, 000h, 015h, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 02ah, 02ah, 03fh
 73707 00014A79 3F2A2A152A2A3F      <1>
 73708 00014A80 00150000152A003F00- <1>     db  000h, 015h, 000h, 000h, 015h, 02ah, 000h, 03fh, 000h, 000h, 03fh, 02ah, 02ah, 015h, 000h, 02ah
 73709 00014A89 003F2A2A15002A      <1>
 73710 00014A90 152A2A3F002A3F2A00- <1>     db  015h, 02ah, 02ah, 03fh, 000h, 02ah, 03fh, 02ah, 000h, 015h, 015h, 000h, 015h, 03fh, 000h, 03fh
 73711 00014A99 151500153F003F      <1>
 73712 00014AA0 15003F3F2A15152A15- <1>     db  015h, 000h, 03fh, 03fh, 02ah, 015h, 015h, 02ah, 015h, 03fh, 02ah, 03fh, 015h, 02ah, 03fh, 03fh
 73713 00014AA9 3F2A3F152A3F3F      <1>
 73714 00014AB0 15000015002A152A00- <1>     db  015h, 000h, 000h, 015h, 000h, 02ah, 015h, 02ah, 000h, 015h, 02ah, 02ah, 03fh, 000h, 000h, 03fh
 73715 00014AB9 152A2A3F00003F      <1>
 73716 00014AC0 002A3F2A003F2A2A15- <1>     db  000h, 02ah, 03fh, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 000h, 015h, 015h, 000h, 03fh, 015h, 02ah
 73717 00014AC9 001515003F152A      <1>
 73718 00014AD0 15152A3F3F00153F00- <1>     db  015h, 015h, 02ah, 03fh, 03fh, 000h, 015h, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 03fh, 02ah, 03fh
 73719 00014AD9 3F3F2A153F2A3F      <1>
 73720 00014AE0 15150015152A153F00- <1>     db  015h, 015h, 000h, 015h, 015h, 02ah, 015h, 03fh, 000h, 015h, 03fh, 02ah, 03fh, 015h, 000h, 03fh
 73721 00014AE9 153F2A3F15003F      <1>
 73722 00014AF0 152A3F3F003F3F2A15- <1>     db  015h, 02ah, 03fh, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
 73723 00014AF9 151515153F153F      <1>
 73724 00014B00 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
 73725 00014B09 3F3F3F153F3F3F      <1>
 73726                              <1> palette3: ; 256*3
 73727 00014B10 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
 73728 00014B19 002A2A2A00002A      <1>
 73729 00014B20 002A2A15002A2A2A15- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
 73730 00014B29 151515153F153F      <1>
 73731 00014B30 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
 73732 00014B39 3F3F3F153F3F3F      <1>
 73733 00014B40 000000050505080808- <1>     db  000h, 000h, 000h, 005h, 005h, 005h, 008h, 008h, 008h, 00bh, 00bh, 00bh, 00eh, 00eh, 00eh, 011h
 73734 00014B49 0B0B0B0E0E0E11      <1>
 73735 00014B50 11111414141818181C- <1>     db  011h, 011h, 014h, 014h, 014h, 018h, 018h, 018h, 01ch, 01ch, 01ch, 020h, 020h, 020h, 024h, 024h
 73736 00014B59 1C1C2020202424      <1>
 73737 00014B60 242828282D2D2D3232- <1>     db  024h, 028h, 028h, 028h, 02dh, 02dh, 02dh, 032h, 032h, 032h, 038h, 038h, 038h, 03fh, 03fh, 03fh
 73738 00014B69 323838383F3F3F      <1>
 73739 00014B70 00003F10003F1F003F- <1>     db  000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 03fh, 03fh
 73740 00014B79 2F003F3F003F3F      <1>
 73741 00014B80 002F3F001F3F00103F- <1>     db  000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh
 73742 00014B89 00003F10003F1F      <1>
 73743 00014B90 003F2F003F3F002F3F- <1>     db  000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h
 73744 00014B99 001F3F00103F00      <1>
 73745 00014BA0 003F00003F10003F1F- <1>     db  000h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h
 73746 00014BA9 003F2F003F3F00      <1>
 73747 00014BB0 2F3F001F3F00103F1F- <1>     db  02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh
 73748 00014BB9 1F3F271F3F2F1F      <1>
 73749 00014BC0 3F371F3F3F1F3F3F1F- <1>     db  03fh, 037h, 01fh, 03fh, 03fh, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h
 73750 00014BC9 373F1F2F3F1F27      <1>
 73751 00014BD0 3F1F1F3F271F3F2F1F- <1>     db  03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h
 73752 00014BD9 3F371F3F3F1F37      <1>
 73753 00014BE0 3F1F2F3F1F273F1F1F- <1>     db  03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh, 01fh, 01fh, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh
 73754 00014BE9 3F1F1F3F271F3F      <1>
 73755 00014BF0 2F1F3F371F3F3F1F37- <1>     db  02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh
 73756 00014BF9 3F1F2F3F1F273F      <1>
 73757 00014C00 2D2D3F312D3F362D3F- <1>     db  02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03fh, 03fh
 73758 00014C09 3A2D3F3F2D3F3F      <1>
 73759 00014C10 2D3A3F2D363F2D313F- <1>     db  02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h
 73760 00014C19 2D2D3F312D3F36      <1>
 73761 00014C20 2D3F3A2D3F3F2D3A3F- <1>     db  02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh
 73762 00014C29 2D363F2D313F2D      <1>
 73763 00014C30 2D3F2D2D3F312D3F36- <1>     db  02dh, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh
 73764 00014C39 2D3F3A2D3F3F2D      <1>
 73765 00014C40 3A3F2D363F2D313F00- <1>     db  03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h
 73766 00014C49 001C07001C0E00      <1>
 73767 00014C50 1C15001C1C001C1C00- <1>     db  01ch, 015h, 000h, 01ch, 01ch, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h
 73768 00014C59 151C000E1C0007      <1>
 73769 00014C60 1C00001C07001C0E00- <1>     db  01ch, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h
 73770 00014C69 1C15001C1C0015      <1>
 73771 00014C70 1C000E1C00071C0000- <1>     db  01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch, 000h, 000h, 01ch, 000h, 000h, 01ch, 007h, 000h, 01ch
 73772 00014C79 1C00001C07001C      <1>
 73773 00014C80 0E001C15001C1C0015- <1>     db  00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch
 73774 00014C89 1C000E1C00071C      <1>
 73775 00014C90 0E0E1C110E1C150E1C- <1>     db  00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 01ch, 01ch
 73776 00014C99 180E1C1C0E1C1C      <1>
 73777 00014CA0 0E181C0E151C0E111C- <1>     db  00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h
 73778 00014CA9 0E0E1C110E1C15      <1>
 73779 00014CB0 0E1C180E1C1C0E181C- <1>     db  00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh
 73780 00014CB9 0E151C0E111C0E      <1>
 73781 00014CC0 0E1C0E0E1C110E1C15- <1>     db  00eh, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh
 73782 00014CC9 0E1C180E1C1C0E      <1>
 73783 00014CD0 181C0E151C0E111C14- <1>     db  018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h
 73784 00014CD9 141C16141C1814      <1>
 73785 00014CE0 1C1A141C1C141C1C14- <1>     db  01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h
 73786 00014CE9 1A1C14181C1416      <1>
 73787 00014CF0 1C14141C16141C1814- <1>     db  01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah
 73788 00014CF9 1C1A141C1C141A      <1>
 73789 00014D00 1C14181C14161C1414- <1>     db  01ch, 014h, 018h, 01ch, 014h, 016h, 01ch, 014h, 014h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch
 73790 00014D09 1C14141C16141C      <1>
 73791 00014D10 18141C1A141C1C141A- <1>     db  018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h, 01ch
 73792 00014D19 1C14181C14161C      <1>
 73793 00014D20 000010040010080010- <1>     db  000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h, 010h, 010h
 73794 00014D29 0C001010001010      <1>
 73795 00014D30 000C10000810000410- <1>     db  000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h
 73796 00014D39 00001004001008      <1>
 73797 00014D40 00100C001010000C10- <1>     db  000h, 010h, 00ch, 000h, 010h, 010h, 000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h
 73798 00014D49 00081000041000      <1>
 73799 00014D50 001000001004001008- <1>     db  000h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h
 73800 00014D59 00100C00101000      <1>
 73801 00014D60 0C1000081000041008- <1>     db  00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h
 73802 00014D69 08100A08100C08      <1>
 73803 00014D70 100E08101008101008- <1>     db  010h, 00eh, 008h, 010h, 010h, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah
 73804 00014D79 0E10080C10080A      <1>
 73805 00014D80 100808100A08100C08- <1>     db  010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh
 73806 00014D89 100E081010080E      <1>
 73807 00014D90 10080C10080A100808- <1>     db  010h, 008h, 00ch, 010h, 008h, 00ah, 010h, 008h, 008h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h
 73808 00014D99 100808100A0810      <1>
 73809 00014DA0 0C08100E081010080E- <1>     db  00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah, 010h
 73810 00014DA9 10080C10080A10      <1>
 73811 00014DB0 0B0B100C0B100D0B10- <1>     db  00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 010h, 010h
 73812 00014DB9 0F0B10100B1010      <1>
 73813 00014DC0 0B0F100B0D100B0C10- <1>     db  00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh
 73814 00014DC9 0B0B100C0B100D      <1>
 73815 00014DD0 0B100F0B10100B0F10- <1>     db  00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh
 73816 00014DD9 0B0D100B0C100B      <1>
 73817 00014DE0 0B100B0B100C0B100D- <1>     db  00bh, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh
 73818 00014DE9 0B100F0B10100B      <1>
 73819 00014DF0 0F100B0D100B0C1000- <1>     db  00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 73820 00014DF9 00000000000000      <1>
 73821 00014E00 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 73822 00014E09 00000000000000      <1>
 73823                              <1> 
 73824                              <1> 
 73825                              <1> ; 04/07/2016
 73826                              <1> ; FONT DATA
 73827                              <1> 
 73828                              <1> CRT_CHAR_GEN:
 73829                              <1> vgafont8: 
 73830 00014E10 00000000000000007E- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 081h, 0a5h, 081h, 0bdh, 099h, 081h, 07eh
 73831 00014E19 81A581BD99817E      <1>
 73832 00014E20 7EFFDBFFC3E7FF7E6C- <1>     db  07eh, 0ffh, 0dbh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 06ch, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h
 73833 00014E29 FEFEFE7C381000      <1>
 73834 00014E30 10387CFE7C38100038- <1>     db  010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 038h, 07ch, 038h, 0feh, 0feh, 07ch, 038h, 07ch
 73835 00014E39 7C38FEFE7C387C      <1>
 73836 00014E40 1010387CFE7C387C00- <1>     db  010h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 07ch, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h
 73837 00014E49 00183C3C180000      <1>
 73838 00014E50 FFFFE7C3C3E7FFFF00- <1>     db  0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h
 73839 00014E59 3C664242663C00      <1>
 73840 00014E60 FFC399BDBD99C3FF0F- <1>     db  0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 00fh, 007h, 00fh, 07dh, 0cch, 0cch, 0cch, 078h
 73841 00014E69 070F7DCCCCCC78      <1>
 73842 00014E70 3C6666663C187E183F- <1>     db  03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 03fh, 033h, 03fh, 030h, 030h, 070h, 0f0h, 0e0h
 73843 00014E79 333F303070F0E0      <1>
 73844 00014E80 7F637F636367E6C099- <1>     db  07fh, 063h, 07fh, 063h, 063h, 067h, 0e6h, 0c0h, 099h, 05ah, 03ch, 0e7h, 0e7h, 03ch, 05ah, 099h
 73845 00014E89 5A3CE7E73C5A99      <1>
 73846 00014E90 80E0F8FEF8E0800002- <1>     db  080h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 080h, 000h, 002h, 00eh, 03eh, 0feh, 03eh, 00eh, 002h, 000h
 73847 00014E99 0E3EFE3E0E0200      <1>
 73848 00014EA0 183C7E18187E3C1866- <1>     db  018h, 03ch, 07eh, 018h, 018h, 07eh, 03ch, 018h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 000h
 73849 00014EA9 66666666006600      <1>
 73850 00014EB0 7FDBDB7B1B1B1B003E- <1>     db  07fh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 000h, 03eh, 063h, 038h, 06ch, 06ch, 038h, 0cch, 078h
 73851 00014EB9 63386C6C38CC78      <1>
 73852 00014EC0 000000007E7E7E0018- <1>     db  000h, 000h, 000h, 000h, 07eh, 07eh, 07eh, 000h, 018h, 03ch, 07eh, 018h, 07eh, 03ch, 018h, 0ffh
 73853 00014EC9 3C7E187E3C18FF      <1>
 73854 00014ED0 183C7E181818180018- <1>     db  018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h
 73855 00014ED9 1818187E3C1800      <1>
 73856 00014EE0 00180CFE0C18000000- <1>     db  000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h
 73857 00014EE9 3060FE60300000      <1>
 73858 00014EF0 0000C0C0C0FE000000- <1>     db  000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h
 73859 00014EF9 2466FF66240000      <1>
 73860 00014F00 00183C7EFFFF000000- <1>     db  000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 000h, 000h, 000h, 0ffh, 0ffh, 07eh, 03ch, 018h, 000h, 000h
 73861 00014F09 FFFF7E3C180000      <1>
 73862 00014F10 000000000000000030- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 078h, 078h, 030h, 030h, 000h, 030h, 000h
 73863 00014F19 78783030003000      <1>
 73864 00014F20 6C6C6C00000000006C- <1>     db  06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 0feh, 06ch, 06ch, 000h
 73865 00014F29 6CFE6CFE6C6C00      <1>
 73866 00014F30 307CC0780CF8300000- <1>     db  030h, 07ch, 0c0h, 078h, 00ch, 0f8h, 030h, 000h, 000h, 0c6h, 0cch, 018h, 030h, 066h, 0c6h, 000h
 73867 00014F39 C6CC183066C600      <1>
 73868 00014F40 386C3876DCCC760060- <1>     db  038h, 06ch, 038h, 076h, 0dch, 0cch, 076h, 000h, 060h, 060h, 0c0h, 000h, 000h, 000h, 000h, 000h
 73869 00014F49 60C00000000000      <1>
 73870 00014F50 183060606030180060- <1>     db  018h, 030h, 060h, 060h, 060h, 030h, 018h, 000h, 060h, 030h, 018h, 018h, 018h, 030h, 060h, 000h
 73871 00014F59 30181818306000      <1>
 73872 00014F60 00663CFF3C66000000- <1>     db  000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 000h
 73873 00014F69 3030FC30300000      <1>
 73874 00014F70 000000000030306000- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 060h, 000h, 000h, 000h, 0fch, 000h, 000h, 000h, 000h
 73875 00014F79 0000FC00000000      <1>
 73876 00014F80 000000000030300006- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 000h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h
 73877 00014F89 0C183060C08000      <1>
 73878 00014F90 7CC6CEDEF6E67C0030- <1>     db  07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 07ch, 000h, 030h, 070h, 030h, 030h, 030h, 030h, 0fch, 000h
 73879 00014F99 7030303030FC00      <1>
 73880 00014FA0 78CC0C3860CCFC0078- <1>     db  078h, 0cch, 00ch, 038h, 060h, 0cch, 0fch, 000h, 078h, 0cch, 00ch, 038h, 00ch, 0cch, 078h, 000h
 73881 00014FA9 CC0C380CCC7800      <1>
 73882 00014FB0 1C3C6CCCFE0C1E00FC- <1>     db  01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 01eh, 000h, 0fch, 0c0h, 0f8h, 00ch, 00ch, 0cch, 078h, 000h
 73883 00014FB9 C0F80C0CCC7800      <1>
 73884 00014FC0 3860C0F8CCCC7800FC- <1>     db  038h, 060h, 0c0h, 0f8h, 0cch, 0cch, 078h, 000h, 0fch, 0cch, 00ch, 018h, 030h, 030h, 030h, 000h
 73885 00014FC9 CC0C1830303000      <1>
 73886 00014FD0 78CCCC78CCCC780078- <1>     db  078h, 0cch, 0cch, 078h, 0cch, 0cch, 078h, 000h, 078h, 0cch, 0cch, 07ch, 00ch, 018h, 070h, 000h
 73887 00014FD9 CCCC7C0C187000      <1>
 73888 00014FE0 003030000030300000- <1>     db  000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 060h
 73889 00014FE9 30300000303060      <1>
 73890 00014FF0 183060C06030180000- <1>     db  018h, 030h, 060h, 0c0h, 060h, 030h, 018h, 000h, 000h, 000h, 0fch, 000h, 000h, 0fch, 000h, 000h
 73891 00014FF9 00FC0000FC0000      <1>
 73892 00015000 6030180C1830600078- <1>     db  060h, 030h, 018h, 00ch, 018h, 030h, 060h, 000h, 078h, 0cch, 00ch, 018h, 030h, 000h, 030h, 000h
 73893 00015009 CC0C1830003000      <1>
 73894 00015010 7CC6DEDEDEC0780030- <1>     db  07ch, 0c6h, 0deh, 0deh, 0deh, 0c0h, 078h, 000h, 030h, 078h, 0cch, 0cch, 0fch, 0cch, 0cch, 000h
 73895 00015019 78CCCCFCCCCC00      <1>
 73896 00015020 FC66667C6666FC003C- <1>     db  0fch, 066h, 066h, 07ch, 066h, 066h, 0fch, 000h, 03ch, 066h, 0c0h, 0c0h, 0c0h, 066h, 03ch, 000h
 73897 00015029 66C0C0C0663C00      <1>
 73898 00015030 F86C6666666CF800FE- <1>     db  0f8h, 06ch, 066h, 066h, 066h, 06ch, 0f8h, 000h, 0feh, 062h, 068h, 078h, 068h, 062h, 0feh, 000h
 73899 00015039 6268786862FE00      <1>
 73900 00015040 FE6268786860F0003C- <1>     db  0feh, 062h, 068h, 078h, 068h, 060h, 0f0h, 000h, 03ch, 066h, 0c0h, 0c0h, 0ceh, 066h, 03eh, 000h
 73901 00015049 66C0C0CE663E00      <1>
 73902 00015050 CCCCCCFCCCCCCC0078- <1>     db  0cch, 0cch, 0cch, 0fch, 0cch, 0cch, 0cch, 000h, 078h, 030h, 030h, 030h, 030h, 030h, 078h, 000h
 73903 00015059 30303030307800      <1>
 73904 00015060 1E0C0C0CCCCC7800E6- <1>     db  01eh, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 0e6h, 066h, 06ch, 078h, 06ch, 066h, 0e6h, 000h
 73905 00015069 666C786C66E600      <1>
 73906 00015070 F06060606266FE00C6- <1>     db  0f0h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 000h
 73907 00015079 EEFEFED6C6C600      <1>
 73908 00015080 C6E6F6DECEC6C60038- <1>     db  0c6h, 0e6h, 0f6h, 0deh, 0ceh, 0c6h, 0c6h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h
 73909 00015089 6CC6C6C66C3800      <1>
 73910 00015090 FC66667C6060F00078- <1>     db  0fch, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 078h, 0cch, 0cch, 0cch, 0dch, 078h, 01ch, 000h
 73911 00015099 CCCCCCDC781C00      <1>
 73912 000150A0 FC66667C6C66E60078- <1>     db  0fch, 066h, 066h, 07ch, 06ch, 066h, 0e6h, 000h, 078h, 0cch, 0e0h, 070h, 01ch, 0cch, 078h, 000h
 73913 000150A9 CCE0701CCC7800      <1>
 73914 000150B0 FCB4303030307800CC- <1>     db  0fch, 0b4h, 030h, 030h, 030h, 030h, 078h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 0fch, 000h
 73915 000150B9 CCCCCCCCCCFC00      <1>
 73916 000150C0 CCCCCCCCCC783000C6- <1>     db  0cch, 0cch, 0cch, 0cch, 0cch, 078h, 030h, 000h, 0c6h, 0c6h, 0c6h, 0d6h, 0feh, 0eeh, 0c6h, 000h
 73917 000150C9 C6C6D6FEEEC600      <1>
 73918 000150D0 C6C66C38386CC600CC- <1>     db  0c6h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 030h, 078h, 000h
 73919 000150D9 CCCC7830307800      <1>
 73920 000150E0 FEC68C183266FE0078- <1>     db  0feh, 0c6h, 08ch, 018h, 032h, 066h, 0feh, 000h, 078h, 060h, 060h, 060h, 060h, 060h, 078h, 000h
 73921 000150E9 60606060607800      <1>
 73922 000150F0 C06030180C06020078- <1>     db  0c0h, 060h, 030h, 018h, 00ch, 006h, 002h, 000h, 078h, 018h, 018h, 018h, 018h, 018h, 078h, 000h
 73923 000150F9 18181818187800      <1>
 73924 00015100 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
 73925 00015109 000000000000FF      <1>
 73926 00015110 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 076h, 000h
 73927 00015119 00780C7CCC7600      <1>
 73928 00015120 E060607C6666DC0000- <1>     db  0e0h, 060h, 060h, 07ch, 066h, 066h, 0dch, 000h, 000h, 000h, 078h, 0cch, 0c0h, 0cch, 078h, 000h
 73929 00015129 0078CCC0CC7800      <1>
 73930 00015130 1C0C0C7CCCCC760000- <1>     db  01ch, 00ch, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
 73931 00015139 0078CCFCC07800      <1>
 73932 00015140 386C60F06060F00000- <1>     db  038h, 06ch, 060h, 0f0h, 060h, 060h, 0f0h, 000h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 0f8h
 73933 00015149 0076CCCC7C0CF8      <1>
 73934 00015150 E0606C766666E60030- <1>     db  0e0h, 060h, 06ch, 076h, 066h, 066h, 0e6h, 000h, 030h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
 73935 00015159 00703030307800      <1>
 73936 00015160 0C000C0C0CCCCC78E0- <1>     db  00ch, 000h, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 0e0h, 060h, 066h, 06ch, 078h, 06ch, 0e6h, 000h
 73937 00015169 60666C786CE600      <1>
 73938 00015170 703030303030780000- <1>     db  070h, 030h, 030h, 030h, 030h, 030h, 078h, 000h, 000h, 000h, 0cch, 0feh, 0feh, 0d6h, 0c6h, 000h
 73939 00015179 00CCFEFED6C600      <1>
 73940 00015180 0000F8CCCCCCCC0000- <1>     db  000h, 000h, 0f8h, 0cch, 0cch, 0cch, 0cch, 000h, 000h, 000h, 078h, 0cch, 0cch, 0cch, 078h, 000h
 73941 00015189 0078CCCCCC7800      <1>
 73942 00015190 0000DC66667C60F000- <1>     db  000h, 000h, 0dch, 066h, 066h, 07ch, 060h, 0f0h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 01eh
 73943 00015199 0076CCCC7C0C1E      <1>
 73944 000151A0 0000DC766660F00000- <1>     db  000h, 000h, 0dch, 076h, 066h, 060h, 0f0h, 000h, 000h, 000h, 07ch, 0c0h, 078h, 00ch, 0f8h, 000h
 73945 000151A9 007CC0780CF800      <1>
 73946 000151B0 10307C303034180000- <1>     db  010h, 030h, 07ch, 030h, 030h, 034h, 018h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 076h, 000h
 73947 000151B9 00CCCCCCCC7600      <1>
 73948 000151C0 0000CCCCCC78300000- <1>     db  000h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 000h, 000h, 000h, 0c6h, 0d6h, 0feh, 0feh, 06ch, 000h
 73949 000151C9 00C6D6FEFE6C00      <1>
 73950 000151D0 0000C66C386CC60000- <1>     db  000h, 000h, 0c6h, 06ch, 038h, 06ch, 0c6h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 07ch, 00ch, 0f8h
 73951 000151D9 00CCCCCC7C0CF8      <1>
 73952 000151E0 0000FC983064FC001C- <1>     db  000h, 000h, 0fch, 098h, 030h, 064h, 0fch, 000h, 01ch, 030h, 030h, 0e0h, 030h, 030h, 01ch, 000h
 73953 000151E9 3030E030301C00      <1>
 73954 000151F0 1818180018181800E0- <1>     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
 73955 000151F9 30301C3030E000      <1>
 73956 00015200 76DC00000000000000- <1>     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
 73957 00015209 10386CC6C6FE00      <1>
 73958 00015210 78CCC0CC78180C7800- <1>     db  078h, 0cch, 0c0h, 0cch, 078h, 018h, 00ch, 078h, 000h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
 73959 00015219 CC00CCCCCC7E00      <1>
 73960 00015220 1C0078CCFCC078007E- <1>     db  01ch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 07eh, 0c3h, 03ch, 006h, 03eh, 066h, 03fh, 000h
 73961 00015229 C33C063E663F00      <1>
 73962 00015230 CC00780C7CCC7E00E0- <1>     db  0cch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 0e0h, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h
 73963 00015239 00780C7CCC7E00      <1>
 73964 00015240 3030780C7CCC7E0000- <1>     db  030h, 030h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 000h, 000h, 078h, 0c0h, 0c0h, 078h, 00ch, 038h
 73965 00015249 0078C0C0780C38      <1>
 73966 00015250 7EC33C667E603C00CC- <1>     db  07eh, 0c3h, 03ch, 066h, 07eh, 060h, 03ch, 000h, 0cch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
 73967 00015259 0078CCFCC07800      <1>
 73968 00015260 E00078CCFCC07800CC- <1>     db  0e0h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 0cch, 000h, 070h, 030h, 030h, 030h, 078h, 000h
 73969 00015269 00703030307800      <1>
 73970 00015270 7CC6381818183C00E0- <1>     db  07ch, 0c6h, 038h, 018h, 018h, 018h, 03ch, 000h, 0e0h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
 73971 00015279 00703030307800      <1>
 73972 00015280 C6386CC6FEC6C60030- <1>     db  0c6h, 038h, 06ch, 0c6h, 0feh, 0c6h, 0c6h, 000h, 030h, 030h, 000h, 078h, 0cch, 0fch, 0cch, 000h
 73973 00015289 300078CCFCCC00      <1>
 73974 00015290 1C00FC607860FC0000- <1>     db  01ch, 000h, 0fch, 060h, 078h, 060h, 0fch, 000h, 000h, 000h, 07fh, 00ch, 07fh, 0cch, 07fh, 000h
 73975 00015299 007F0C7FCC7F00      <1>
 73976 000152A0 3E6CCCFECCCCCE0078- <1>     db  03eh, 06ch, 0cch, 0feh, 0cch, 0cch, 0ceh, 000h, 078h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h
 73977 000152A9 CC0078CCCC7800      <1>
 73978 000152B0 00CC0078CCCC780000- <1>     db  000h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 0e0h, 000h, 078h, 0cch, 0cch, 078h, 000h
 73979 000152B9 E00078CCCC7800      <1>
 73980 000152C0 78CC00CCCCCC7E0000- <1>     db  078h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h, 000h, 0e0h, 000h, 0cch, 0cch, 0cch, 07eh, 000h
 73981 000152C9 E000CCCCCC7E00      <1>
 73982 000152D0 00CC00CCCC7C0CF8C3- <1>     db  000h, 0cch, 000h, 0cch, 0cch, 07ch, 00ch, 0f8h, 0c3h, 018h, 03ch, 066h, 066h, 03ch, 018h, 000h
 73983 000152D9 183C66663C1800      <1>
 73984 000152E0 CC00CCCCCCCC780018- <1>     db  0cch, 000h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 018h, 018h, 07eh, 0c0h, 0c0h, 07eh, 018h, 018h
 73985 000152E9 187EC0C07E1818      <1>
 73986 000152F0 386C64F060E6FC00CC- <1>     db  038h, 06ch, 064h, 0f0h, 060h, 0e6h, 0fch, 000h, 0cch, 0cch, 078h, 0fch, 030h, 0fch, 030h, 030h
 73987 000152F9 CC78FC30FC3030      <1>
 73988 00015300 F8CCCCFAC6CFC6C70E- <1>     db  0f8h, 0cch, 0cch, 0fah, 0c6h, 0cfh, 0c6h, 0c7h, 00eh, 01bh, 018h, 03ch, 018h, 018h, 0d8h, 070h
 73989 00015309 1B183C1818D870      <1>
 73990 00015310 1C00780C7CCC7E0038- <1>     db  01ch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 038h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
 73991 00015319 00703030307800      <1>
 73992 00015320 001C0078CCCC780000- <1>     db  000h, 01ch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 01ch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
 73993 00015329 1C00CCCCCC7E00      <1>
 73994 00015330 00F800F8CCCCCC00FC- <1>     db  000h, 0f8h, 000h, 0f8h, 0cch, 0cch, 0cch, 000h, 0fch, 000h, 0cch, 0ech, 0fch, 0dch, 0cch, 000h
 73995 00015339 00CCECFCDCCC00      <1>
 73996 00015340 3C6C6C3E007E000038- <1>     db  03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h
 73997 00015349 6C6C38007C0000      <1>
 73998 00015350 30003060C0CC780000- <1>     db  030h, 000h, 030h, 060h, 0c0h, 0cch, 078h, 000h, 000h, 000h, 000h, 0fch, 0c0h, 0c0h, 000h, 000h
 73999 00015359 0000FCC0C00000      <1>
 74000 00015360 000000FC0C0C0000C3- <1>     db  000h, 000h, 000h, 0fch, 00ch, 00ch, 000h, 000h, 0c3h, 0c6h, 0cch, 0deh, 033h, 066h, 0cch, 00fh
 74001 00015369 C6CCDE3366CC0F      <1>
 74002 00015370 C3C6CCDB376FCF0318- <1>     db  0c3h, 0c6h, 0cch, 0dbh, 037h, 06fh, 0cfh, 003h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 000h
 74003 00015379 18001818181800      <1>
 74004 00015380 003366CC6633000000- <1>     db  000h, 033h, 066h, 0cch, 066h, 033h, 000h, 000h, 000h, 0cch, 066h, 033h, 066h, 0cch, 000h, 000h
 74005 00015389 CC663366CC0000      <1>
 74006 00015390 228822882288228855- <1>     db  022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
 74007 00015399 AA55AA55AA55AA      <1>
 74008 000153A0 DB77DBEEDB77DBEE18- <1>     db  0dbh, 077h, 0dbh, 0eeh, 0dbh, 077h, 0dbh, 0eeh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74009 000153A9 18181818181818      <1>
 74010 000153B0 18181818F818181818- <1>     db  018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h
 74011 000153B9 18F818F8181818      <1>
 74012 000153C0 36363636F636363600- <1>     db  036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h
 74013 000153C9 000000FE363636      <1>
 74014 000153D0 0000F818F818181836- <1>     db  000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h
 74015 000153D9 36F606F6363636      <1>
 74016 000153E0 363636363636363600- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h
 74017 000153E9 00FE06F6363636      <1>
 74018 000153F0 3636F606FE00000036- <1>     db  036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h
 74019 000153F9 363636FE000000      <1>
 74020 00015400 1818F818F800000000- <1>     db  018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h
 74021 00015409 000000F8181818      <1>
 74022 00015410 181818181F00000018- <1>     db  018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h
 74023 00015419 181818FF000000      <1>
 74024 00015420 00000000FF18181818- <1>     db  000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h
 74025 00015429 1818181F181818      <1>
 74026 00015430 00000000FF00000018- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h
 74027 00015439 181818FF181818      <1>
 74028 00015440 18181F181F18181836- <1>     db  018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h
 74029 00015449 36363637363636      <1>
 74030 00015450 363637303F00000000- <1>     db  036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h
 74031 00015459 003F3037363636      <1>
 74032 00015460 3636F700FF00000000- <1>     db  036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h
 74033 00015469 00FF00F7363636      <1>
 74034 00015470 363637303736363600- <1>     db  036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
 74035 00015479 00FF00FF000000      <1>
 74036 00015480 3636F700F736363618- <1>     db  036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
 74037 00015489 18FF00FF000000      <1>
 74038 00015490 36363636FF00000000- <1>     db  036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h
 74039 00015499 00FF00FF181818      <1>
 74040 000154A0 00000000FF36363636- <1>     db  000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h
 74041 000154A9 3636363F000000      <1>
 74042 000154B0 18181F181F00000000- <1>     db  018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h
 74043 000154B9 001F181F181818      <1>
 74044 000154C0 000000003F36363636- <1>     db  000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h
 74045 000154C9 363636FF363636      <1>
 74046 000154D0 1818FF18FF18181818- <1>     db  018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h
 74047 000154D9 181818F8000000      <1>
 74048 000154E0 000000001F181818FF- <1>     db  000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74049 000154E9 FFFFFFFFFFFFFF      <1>
 74050 000154F0 00000000FFFFFFFFF0- <1>     db  000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
 74051 000154F9 F0F0F0F0F0F0F0      <1>
 74052 00015500 0F0F0F0F0F0F0F0FFF- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h
 74053 00015509 FFFFFF00000000      <1>
 74054 00015510 000076DCC8DC760000- <1>     db  000h, 000h, 076h, 0dch, 0c8h, 0dch, 076h, 000h, 000h, 078h, 0cch, 0f8h, 0cch, 0f8h, 0c0h, 0c0h
 74055 00015519 78CCF8CCF8C0C0      <1>
 74056 00015520 00FCCCC0C0C0C00000- <1>     db  000h, 0fch, 0cch, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
 74057 00015529 FE6C6C6C6C6C00      <1>
 74058 00015530 FCCC603060CCFC0000- <1>     db  0fch, 0cch, 060h, 030h, 060h, 0cch, 0fch, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 070h, 000h
 74059 00015539 007ED8D8D87000      <1>
 74060 00015540 00666666667C60C000- <1>     db  000h, 066h, 066h, 066h, 066h, 07ch, 060h, 0c0h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 000h
 74061 00015549 76DC1818181800      <1>
 74062 00015550 FC3078CCCC7830FC38- <1>     db  0fch, 030h, 078h, 0cch, 0cch, 078h, 030h, 0fch, 038h, 06ch, 0c6h, 0feh, 0c6h, 06ch, 038h, 000h
 74063 00015559 6CC6FEC66C3800      <1>
 74064 00015560 386CC6C66C6CEE001C- <1>     db  038h, 06ch, 0c6h, 0c6h, 06ch, 06ch, 0eeh, 000h, 01ch, 030h, 018h, 07ch, 0cch, 0cch, 078h, 000h
 74065 00015569 30187CCCCC7800      <1>
 74066 00015570 00007EDBDB7E000006- <1>     db  000h, 000h, 07eh, 0dbh, 0dbh, 07eh, 000h, 000h, 006h, 00ch, 07eh, 0dbh, 0dbh, 07eh, 060h, 0c0h
 74067 00015579 0C7EDBDB7E60C0      <1>
 74068 00015580 3860C0F8C060380078- <1>     db  038h, 060h, 0c0h, 0f8h, 0c0h, 060h, 038h, 000h, 078h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 000h
 74069 00015589 CCCCCCCCCCCC00      <1>
 74070 00015590 00FC00FC00FC000030- <1>     db  000h, 0fch, 000h, 0fch, 000h, 0fch, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 0fch, 000h
 74071 00015599 30FC303000FC00      <1>
 74072 000155A0 603018306000FC0018- <1>     db  060h, 030h, 018h, 030h, 060h, 000h, 0fch, 000h, 018h, 030h, 060h, 030h, 018h, 000h, 0fch, 000h
 74073 000155A9 3060301800FC00      <1>
 74074 000155B0 0E1B1B181818181818- <1>     db  00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 070h
 74075 000155B9 18181818D8D870      <1>
 74076 000155C0 303000FC0030300000- <1>     db  030h, 030h, 000h, 0fch, 000h, 030h, 030h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h
 74077 000155C9 76DC0076DC0000      <1>
 74078 000155D0 386C6C380000000000- <1>     db  038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h
 74079 000155D9 00001818000000      <1>
 74080 000155E0 00000000180000000F- <1>     db  000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 0ech, 06ch, 03ch, 01ch
 74081 000155E9 0C0C0CEC6C3C1C      <1>
 74082 000155F0 786C6C6C6C00000070- <1>     db  078h, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 070h, 018h, 030h, 060h, 078h, 000h, 000h, 000h
 74083 000155F9 18306078000000      <1>
 74084 00015600 00003C3C3C3C000000- <1>     db  000h, 000h, 03ch, 03ch, 03ch, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74085 00015609 00000000000000      <1>
 74086                              <1> vgafont14:
 74087 00015610 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74088 00015619 00000000000000      <1>
 74089 00015620 7E81A58181BD99817E- <1>     db  07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 07eh, 000h, 000h, 000h, 000h, 000h, 07eh, 0ffh
 74090 00015629 00000000007EFF      <1>
 74091 00015630 DBFFFFC3E7FF7E0000- <1>     db  0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 0feh, 0feh
 74092 00015639 000000006CFEFE      <1>
 74093 00015640 FEFE7C381000000000- <1>     db  0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch
 74094 00015649 000010387CFE7C      <1>
 74095 00015650 381000000000000018- <1>     db  038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h
 74096 00015659 3C3CE7E7E71818      <1>
 74097 00015660 3C0000000000183C7E- <1>     db  03ch, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h
 74098 00015669 FFFF7E18183C00      <1>
 74099 00015670 00000000000000183C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
 74100 00015679 3C180000000000      <1>
 74101 00015680 FFFFFFFFFFE7C3C3E7- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h
 74102 00015689 FFFFFFFFFF0000      <1>
 74103 00015690 00003C664242663C00- <1>     db  000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh
 74104 00015699 000000FFFFFFFF      <1>
 74105 000156A0 C399BDBD99C3FFFFFF- <1>     db  0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 01eh, 00eh, 01ah, 032h
 74106 000156A9 FF00001E0E1A32      <1>
 74107 000156B0 78CCCCCC7800000000- <1>     db  078h, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 066h, 066h, 03ch, 018h
 74108 000156B9 003C6666663C18      <1>
 74109 000156C0 7E181800000000003F- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 070h, 0f0h
 74110 000156C9 333F30303070F0      <1>
 74111 000156D0 E000000000007F637F- <1>     db  0e0h, 000h, 000h, 000h, 000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h
 74112 000156D9 63636367E7E6C0      <1>
 74113 000156E0 000000001818DB3CE7- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h
 74114 000156E9 3CDB1818000000      <1>
 74115 000156F0 000080C0E0F8FEF8E0- <1>     db  000h, 000h, 080h, 0c0h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h, 000h
 74116 000156F9 C0800000000000      <1>
 74117 00015700 02060E3EFE3E0E0602- <1>     db  002h, 006h, 00eh, 03eh, 0feh, 03eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch
 74118 00015709 0000000000183C      <1>
 74119 00015710 7E1818187E3C180000- <1>     db  07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h
 74120 00015719 00000066666666      <1>
 74121 00015720 666600666600000000- <1>     db  066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh
 74122 00015729 007FDBDBDB7B1B      <1>
 74123 00015730 1B1B1B000000007CC6- <1>     db  01bh, 01bh, 01bh, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h
 74124 00015739 60386CC6C66C38      <1>
 74125 00015740 0CC67C000000000000- <1>     db  00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 000h
 74126 00015749 000000FEFEFE00      <1>
 74127 00015750 00000000183C7E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h
 74128 00015759 187E3C187E0000      <1>
 74129 00015760 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
 74130 00015769 18180000000000      <1>
 74131 00015770 1818181818187E3C18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74132 00015779 00000000000000      <1>
 74133 00015780 180CFE0C1800000000- <1>     db  018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 060h
 74134 00015789 00000000003060      <1>
 74135 00015790 FE6030000000000000- <1>     db  0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h
 74136 00015799 00000000C0C0C0      <1>
 74137 000157A0 FE0000000000000000- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 028h, 06ch, 0feh, 06ch, 028h, 000h
 74138 000157A9 00286CFE6C2800      <1>
 74139 000157B0 000000000000001038- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h
 74140 000157B9 387C7CFEFE0000      <1>
 74141 000157C0 0000000000FEFE7C7C- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h
 74142 000157C9 38381000000000      <1>
 74143 000157D0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74144 000157D9 00000000000000      <1>
 74145 000157E0 183C3C3C1818001818- <1>     db  018h, 03ch, 03ch, 03ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 066h, 066h, 066h
 74146 000157E9 00000000666666      <1>
 74147 000157F0 240000000000000000- <1>     db  024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch
 74148 000157F9 0000006C6CFE6C      <1>
 74149 00015800 6C6CFE6C6C00000018- <1>     db  06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h
 74150 00015809 187CC6C2C07C06      <1>
 74151 00015810 86C67C181800000000- <1>     db  086h, 0c6h, 07ch, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 066h
 74152 00015819 00C2C60C183066      <1>
 74153 00015820 C60000000000386C6C- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 076h, 000h
 74154 00015829 3876DCCCCC7600      <1>
 74155 00015830 000000303030600000- <1>     db  000h, 000h, 000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74156 00015839 00000000000000      <1>
 74157 00015840 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h, 000h
 74158 00015849 180C0000000000      <1>
 74159 00015850 30180C0C0C0C0C1830- <1>     db  030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74160 00015859 00000000000000      <1>
 74161 00015860 663CFF3C6600000000- <1>     db  066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
 74162 00015869 00000000001818      <1>
 74163 00015870 7E1818000000000000- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74164 00015879 00000000000000      <1>
 74165 00015880 181818300000000000- <1>     db  018h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h
 74166 00015889 000000FE000000      <1>
 74167 00015890 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
 74168 00015899 00000000181800      <1>
 74169 000158A0 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
 74170 000158A9 60C08000000000      <1>
 74171 000158B0 00007CC6CEDEF6E6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
 74172 000158B9 C67C0000000000      <1>
 74173 000158C0 18387818181818187E- <1>     db  018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h
 74174 000158C9 00000000007CC6      <1>
 74175 000158D0 060C183060C6FE0000- <1>     db  006h, 00ch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 006h, 006h
 74176 000158D9 0000007CC60606      <1>
 74177 000158E0 3C0606C67C00000000- <1>     db  03ch, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh
 74178 000158E9 000C1C3C6CCCFE      <1>
 74179 000158F0 0C0C1E0000000000FE- <1>     db  00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 0c6h
 74180 000158F9 C0C0C0FC0606C6      <1>
 74181 00015900 7C00000000003860C0- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 07ch, 000h
 74182 00015909 C0FCC6C6C67C00      <1>
 74183 00015910 00000000FEC6060C18- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c6h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h
 74184 00015919 30303030000000      <1>
 74185 00015920 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
 74186 00015929 C67C0000000000      <1>
 74187 00015930 7CC6C6C67E06060C78- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h, 000h, 000h, 018h
 74188 00015939 00000000000018      <1>
 74189 00015940 180000001818000000- <1>     db  018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
 74190 00015949 00000000181800      <1>
 74191 00015950 000018183000000000- <1>     db  000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h
 74192 00015959 00060C18306030      <1>
 74193 00015960 180C06000000000000- <1>     db  018h, 00ch, 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h
 74194 00015969 00007E00007E00      <1>
 74195 00015970 000000000000603018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h
 74196 00015979 0C060C18306000      <1>
 74197 00015980 000000007CC6C60C18- <1>     db  000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h
 74198 00015989 18001818000000      <1>
 74199 00015990 00007CC6C6DEDEDEDC- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h, 000h
 74200 00015999 C07C0000000000      <1>
 74201 000159A0 10386CC6C6FEC6C6C6- <1>     db  010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h, 0fch, 066h
 74202 000159A9 0000000000FC66      <1>
 74203 000159B0 66667C666666FC0000- <1>     db  066h, 066h, 07ch, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h
 74204 000159B9 0000003C66C2C0      <1>
 74205 000159C0 C0C0C2663C00000000- <1>     db  0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h
 74206 000159C9 00F86C66666666      <1>
 74207 000159D0 666CF80000000000FE- <1>     db  066h, 06ch, 0f8h, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 062h, 066h
 74208 000159D9 66626878686266      <1>
 74209 000159E0 FE0000000000FE6662- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 0f0h, 000h
 74210 000159E9 6878686060F000      <1>
 74211 000159F0 000000003C66C2C0C0- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 066h, 03ah, 000h, 000h, 000h
 74212 000159F9 DEC6663A000000      <1>
 74213 00015A00 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
 74214 00015A09 C6C60000000000      <1>
 74215 00015A10 3C181818181818183C- <1>     db  03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 01eh, 00ch
 74216 00015A19 00000000001E0C      <1>
 74217 00015A20 0C0C0C0CCCCC780000- <1>     db  00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 0e6h, 066h, 06ch, 06ch
 74218 00015A29 000000E6666C6C      <1>
 74219 00015A30 786C6C66E600000000- <1>     db  078h, 06ch, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h
 74220 00015A39 00F06060606060      <1>
 74221 00015A40 6266FE0000000000C6- <1>     db  062h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 0c6h
 74222 00015A49 EEFEFED6C6C6C6      <1>
 74223 00015A50 C60000000000C6E6F6- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h
 74224 00015A59 FEDECEC6C6C600      <1>
 74225 00015A60 00000000386CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h
 74226 00015A69 C6C66C38000000      <1>
 74227 00015A70 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h
 74228 00015A79 60F00000000000      <1>
 74229 00015A80 7CC6C6C6C6D6DE7C0C- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h, 000h, 000h, 0fch, 066h
 74230 00015A89 0E00000000FC66      <1>
 74231 00015A90 66667C6C6666E60000- <1>     db  066h, 066h, 07ch, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 060h
 74232 00015A99 0000007CC6C660      <1>
 74233 00015AA0 380CC6C67C00000000- <1>     db  038h, 00ch, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 07eh, 07eh, 05ah, 018h, 018h, 018h
 74234 00015AA9 007E7E5A181818      <1>
 74235 00015AB0 18183C0000000000C6- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h
 74236 00015AB9 C6C6C6C6C6C6C6      <1>
 74237 00015AC0 7C0000000000C6C6C6- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 010h, 000h
 74238 00015AC9 C6C6C66C381000      <1>
 74239 00015AD0 00000000C6C6C6C6D6- <1>     db  000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 07ch, 06ch, 000h, 000h, 000h
 74240 00015AD9 D6FE7C6C000000      <1>
 74241 00015AE0 0000C6C66C3838386C- <1>     db  000h, 000h, 0c6h, 0c6h, 06ch, 038h, 038h, 038h, 06ch, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
 74242 00015AE9 C6C60000000000      <1>
 74243 00015AF0 666666663C1818183C- <1>     db  066h, 066h, 066h, 066h, 03ch, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h
 74244 00015AF9 0000000000FEC6      <1>
 74245 00015B00 8C183060C2C6FE0000- <1>     db  08ch, 018h, 030h, 060h, 0c2h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 03ch, 030h, 030h, 030h
 74246 00015B09 0000003C303030      <1>
 74247 00015B10 303030303C00000000- <1>     db  030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch
 74248 00015B19 0080C0E070381C      <1>
 74249 00015B20 0E060200000000003C- <1>     db  00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch
 74250 00015B29 0C0C0C0C0C0C0C      <1>
 74251 00015B30 3C00000010386CC600- <1>     db  03ch, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74252 00015B39 00000000000000      <1>
 74253 00015B40 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h
 74254 00015B49 0000000000FF00      <1>
 74255 00015B50 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74256 00015B59 00000000000000      <1>
 74257 00015B60 000000780C7CCCCC76- <1>     db  000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0e0h, 060h
 74258 00015B69 0000000000E060      <1>
 74259 00015B70 60786C6666667C0000- <1>     db  060h, 078h, 06ch, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
 74260 00015B79 0000000000007C      <1>
 74261 00015B80 C6C0C0C67C00000000- <1>     db  0c6h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch
 74262 00015B89 001C0C0C3C6CCC      <1>
 74263 00015B90 CCCC76000000000000- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h
 74264 00015B99 00007CC6FEC0C6      <1>
 74265 00015BA0 7C0000000000386C64- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 0f0h, 000h
 74266 00015BA9 60F0606060F000      <1>
 74267 00015BB0 0000000000000076CC- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
 74268 00015BB9 CCCC7C0CCC7800      <1>
 74269 00015BC0 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h
 74270 00015BC9 66E60000000000      <1>
 74271 00015BD0 18180038181818183C- <1>     db  018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 006h, 006h
 74272 00015BD9 00000000000606      <1>
 74273 00015BE0 000E0606060666663C- <1>     db  000h, 00eh, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h, 000h, 000h, 0e0h, 060h, 060h, 066h
 74274 00015BE9 000000E0606066      <1>
 74275 00015BF0 6C786C66E600000000- <1>     db  06ch, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h
 74276 00015BF9 00381818181818      <1>
 74277 00015C00 18183C000000000000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ech, 0feh, 0d6h, 0d6h, 0d6h
 74278 00015C09 0000ECFED6D6D6      <1>
 74279 00015C10 C60000000000000000- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 000h
 74280 00015C19 DC666666666600      <1>
 74281 00015C20 000000000000007CC6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h
 74282 00015C29 C6C6C67C000000      <1>
 74283 00015C30 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 000h, 000h
 74284 00015C39 7C6060F0000000      <1>
 74285 00015C40 00000076CCCCCC7C0C- <1>     db  000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h
 74286 00015C49 0C1E0000000000      <1>
 74287 00015C50 00DC76666060F00000- <1>     db  000h, 0dch, 076h, 066h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
 74288 00015C59 0000000000007C      <1>
 74289 00015C60 C6701CC67C00000000- <1>     db  0c6h, 070h, 01ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h
 74290 00015C69 00103030FC3030      <1>
 74291 00015C70 30361C000000000000- <1>     db  030h, 036h, 01ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch
 74292 00015C79 0000CCCCCCCCCC      <1>
 74293 00015C80 760000000000000000- <1>     db  076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 03ch, 018h, 000h
 74294 00015C89 666666663C1800      <1>
 74295 00015C90 00000000000000C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 06ch, 000h, 000h, 000h
 74296 00015C99 D6D6FE6C000000      <1>
 74297 00015CA0 0000000000C66C3838- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h
 74298 00015CA9 6CC60000000000      <1>
 74299 00015CB0 000000C6C6C6C67E06- <1>     db  000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h, 000h, 000h, 000h, 000h
 74300 00015CB9 0CF80000000000      <1>
 74301 00015CC0 00FECC183066FE0000- <1>     db  000h, 0feh, 0cch, 018h, 030h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 00eh, 018h, 018h, 018h
 74302 00015CC9 0000000E181818      <1>
 74303 00015CD0 701818180E00000000- <1>     db  070h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h
 74304 00015CD9 00181818180018      <1>
 74305 00015CE0 181818000000000070- <1>     db  018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h
 74306 00015CE9 1818180E181818      <1>
 74307 00015CF0 70000000000076DC00- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74308 00015CF9 00000000000000      <1>
 74309 00015D00 00000000000010386C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h
 74310 00015D09 C6C6FE00000000      <1>
 74311 00015D10 00003C66C2C0C0C266- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h, 000h
 74312 00015D19 3C0C067C000000      <1>
 74313 00015D20 CCCC00CCCCCCCCCC76- <1>     db  0cch, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h
 74314 00015D29 000000000C1830      <1>
 74315 00015D30 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 078h
 74316 00015D39 000010386C0078      <1>
 74317 00015D40 0C7CCCCC7600000000- <1>     db  00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 000h, 078h, 00ch, 07ch
 74318 00015D49 00CCCC00780C7C      <1>
 74319 00015D50 CCCC76000000006030- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch
 74320 00015D59 1800780C7CCCCC      <1>
 74321 00015D60 7600000000386C3800- <1>     db  076h, 000h, 000h, 000h, 000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h
 74322 00015D69 780C7CCCCC7600      <1>
 74323 00015D70 0000000000003C6660- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h
 74324 00015D79 663C0C063C0000      <1>
 74325 00015D80 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
 74326 00015D89 C67C0000000000      <1>
 74327 00015D90 CCCC007CC6FEC0C67C- <1>     db  0cch, 0cch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h
 74328 00015D99 00000000603018      <1>
 74329 00015DA0 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 000h, 038h
 74330 00015DA9 00000066660038      <1>
 74331 00015DB0 181818183C00000000- <1>     db  018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h
 74332 00015DB9 183C6600381818      <1>
 74333 00015DC0 18183C000000006030- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h
 74334 00015DC9 18003818181818      <1>
 74335 00015DD0 3C00000000C6C61038- <1>     db  03ch, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h
 74336 00015DD9 6CC6C6FEC6C600      <1>
 74337 00015DE0 0000386C3800386CC6- <1>     db  000h, 000h, 038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h, 000h, 000h
 74338 00015DE9 C6FEC6C6000000      <1>
 74339 00015DF0 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h
 74340 00015DF9 66FE0000000000      <1>
 74341 00015E00 0000CC76367ED8D86E- <1>     db  000h, 000h, 0cch, 076h, 036h, 07eh, 0d8h, 0d8h, 06eh, 000h, 000h, 000h, 000h, 000h, 03eh, 06ch
 74342 00015E09 00000000003E6C      <1>
 74343 00015E10 CCCCFECCCCCCCE0000- <1>     db  0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 07ch
 74344 00015E19 000010386C007C      <1>
 74345 00015E20 C6C6C6C67C00000000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h, 07ch, 0c6h, 0c6h
 74346 00015E29 00C6C6007CC6C6      <1>
 74347 00015E30 C6C67C000000006030- <1>     db  0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h
 74348 00015E39 18007CC6C6C6C6      <1>
 74349 00015E40 7C000000003078CC00- <1>     db  07ch, 000h, 000h, 000h, 000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h
 74350 00015E49 CCCCCCCCCC7600      <1>
 74351 00015E50 00000060301800CCCC- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h
 74352 00015E59 CCCCCC76000000      <1>
 74353 00015E60 0000C6C600C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h, 000h, 0c6h
 74354 00015E69 7E060C780000C6      <1>
 74355 00015E70 C6386CC6C6C6C66C38- <1>     db  0c6h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h
 74356 00015E79 00000000C6C600      <1>
 74357 00015E80 C6C6C6C6C6C67C0000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 018h, 03ch, 066h, 060h
 74358 00015E89 000018183C6660      <1>
 74359 00015E90 60663C181800000000- <1>     db  060h, 066h, 03ch, 018h, 018h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h
 74360 00015E99 386C6460F06060      <1>
 74361 00015EA0 60E6FC000000000066- <1>     db  060h, 0e6h, 0fch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 03ch, 018h, 07eh, 018h, 07eh, 018h
 74362 00015EA9 663C187E187E18      <1>
 74363 00015EB0 1800000000F8CCCCF8- <1>     db  018h, 000h, 000h, 000h, 000h, 0f8h, 0cch, 0cch, 0f8h, 0c4h, 0cch, 0deh, 0cch, 0cch, 0c6h, 000h
 74364 00015EB9 C4CCDECCCCC600      <1>
 74365 00015EC0 0000000E1B1818187E- <1>     db  000h, 000h, 000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h
 74366 00015EC9 18181818D87000      <1>
 74367 00015ED0 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch
 74368 00015ED9 CC76000000000C      <1>
 74369 00015EE0 18300038181818183C- <1>     db  018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h
 74370 00015EE9 00000000183060      <1>
 74371 00015EF0 007CC6C6C6C67C0000- <1>     db  000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h, 000h, 0cch
 74372 00015EF9 000018306000CC      <1>
 74373 00015F00 CCCCCCCC7600000000- <1>     db  0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h
 74374 00015F09 0076DC00DC6666      <1>
 74375 00015F10 66666600000076DC00- <1>     db  066h, 066h, 066h, 000h, 000h, 000h, 076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h
 74376 00015F19 C6E6F6FEDECEC6      <1>
 74377 00015F20 C6000000003C6C6C3E- <1>     db  0c6h, 000h, 000h, 000h, 000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h
 74378 00015F29 007E0000000000      <1>
 74379 00015F30 000000386C6C38007C- <1>     db  000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74380 00015F39 00000000000000      <1>
 74381 00015F40 0000303000303060C6- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
 74382 00015F49 C67C0000000000      <1>
 74383 00015F50 00000000FEC0C0C000- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74384 00015F59 00000000000000      <1>
 74385 00015F60 0000FE060606000000- <1>     db  000h, 000h, 0feh, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h
 74386 00015F69 0000C0C0C6CCD8      <1>
 74387 00015F70 3060DC860C183E0000- <1>     db  030h, 060h, 0dch, 086h, 00ch, 018h, 03eh, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h, 030h, 066h
 74388 00015F79 C0C0C6CCD83066      <1>
 74389 00015F80 CE9E3E060600000018- <1>     db  0ceh, 09eh, 03eh, 006h, 006h, 000h, 000h, 000h, 018h, 018h, 000h, 018h, 018h, 03ch, 03ch, 03ch
 74390 00015F89 180018183C3C3C      <1>
 74391 00015F90 180000000000000036- <1>     db  018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h
 74392 00015F99 6CD86C36000000      <1>
 74393 00015FA0 000000000000D86C36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h
 74394 00015FA9 6CD80000000000      <1>
 74395 00015FB0 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 055h, 0aah
 74396 00015FB9 441144114455AA      <1>
 74397 00015FC0 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 0ddh, 077h, 0ddh, 077h
 74398 00015FC9 AA55AADD77DD77      <1>
 74399 00015FD0 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 018h, 018h, 018h, 018h, 018h, 018h
 74400 00015FD9 77181818181818      <1>
 74401 00015FE0 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h
 74402 00015FE9 181818181818F8      <1>
 74403 00015FF0 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h
 74404 00015FF9 1818F818F81818      <1>
 74405 00016000 181818183636363636- <1>     db  018h, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h
 74406 00016009 3636F636363636      <1>
 74407 00016010 363600000000000000- <1>     db  036h, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h
 74408 00016019 FE363636363636      <1>
 74409 00016020 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 036h, 036h
 74410 00016029 18181818183636      <1>
 74411 00016030 363636F606F6363636- <1>     db  036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74412 00016039 36363636363636      <1>
 74413 00016040 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0feh
 74414 00016049 360000000000FE      <1>
 74415 00016050 06F636363636363636- <1>     db  006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh
 74416 00016059 36363636F606FE      <1>
 74417 00016060 000000000000363636- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h
 74418 00016069 36363636FE0000      <1>
 74419 00016070 000000001818181818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h
 74420 00016079 F818F800000000      <1>
 74421 00016080 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h
 74422 00016089 F8181818181818      <1>
 74423 00016090 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
 74424 00016099 00000000001818      <1>
 74425 000160A0 1818181818FF000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74426 000160A9 00000000000000      <1>
 74427 000160B0 000000FF1818181818- <1>     db  000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74428 000160B9 18181818181818      <1>
 74429 000160C0 181F18181818181800- <1>     db  018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
 74430 000160C9 000000000000FF      <1>
 74431 000160D0 000000000000181818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h
 74432 000160D9 18181818FF1818      <1>
 74433 000160E0 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h
 74434 000160E9 1F181F18181818      <1>
 74435 000160F0 181836363636363636- <1>     db  018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h
 74436 000160F9 37363636363636      <1>
 74437 00016100 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74438 00016109 00000000000000      <1>
 74439 00016110 0000003F3037363636- <1>     db  000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74440 00016119 36363636363636      <1>
 74441 00016120 36F700FF0000000000- <1>     db  036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
 74442 00016129 000000000000FF      <1>
 74443 00016130 00F736363636363636- <1>     db  000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h
 74444 00016139 36363636373037      <1>
 74445 00016140 363636363636000000- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h
 74446 00016149 0000FF00FF0000      <1>
 74447 00016150 000000003636363636- <1>     db  000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h
 74448 00016159 F700F736363636      <1>
 74449 00016160 36361818181818FF00- <1>     db  036h, 036h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h
 74450 00016169 FF000000000000      <1>
 74451 00016170 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74452 00016179 00000000000000      <1>
 74453 00016180 000000FF00FF181818- <1>     db  000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 74454 00016189 18181800000000      <1>
 74455 00016190 000000FF3636363636- <1>     db  000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74456 00016199 36363636363636      <1>
 74457 000161A0 363F00000000000018- <1>     db  036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh
 74458 000161A9 181818181F181F      <1>
 74459 000161B0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h
 74460 000161B9 00001F181F1818      <1>
 74461 000161C0 181818180000000000- <1>     db  018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h
 74462 000161C9 00003F36363636      <1>
 74463 000161D0 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h
 74464 000161D9 FF363636363636      <1>
 74465 000161E0 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74466 000161E9 18181818181818      <1>
 74467 000161F0 1818181818F8000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74468 000161F9 00000000000000      <1>
 74469 00016200 0000001F1818181818- <1>     db  000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74470 00016209 18FFFFFFFFFFFF      <1>
 74471 00016210 FFFFFFFFFFFFFFFF00- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
 74472 00016219 000000000000FF      <1>
 74473 00016220 FFFFFFFFFFFFF0F0F0- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
 74474 00016229 F0F0F0F0F0F0F0      <1>
 74475 00016230 F0F0F0F00F0F0F0F0F- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
 74476 00016239 0F0F0F0F0F0F0F      <1>
 74477 00016240 0F0FFFFFFFFFFFFFFF- <1>     db  00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74478 00016249 00000000000000      <1>
 74479 00016250 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h, 000h
 74480 00016259 DC760000000000      <1>
 74481 00016260 00007CC6FCC6C6FCC0- <1>     db  000h, 000h, 07ch, 0c6h, 0fch, 0c6h, 0c6h, 0fch, 0c0h, 0c0h, 040h, 000h, 000h, 000h, 0feh, 0c6h
 74482 00016269 C040000000FEC6      <1>
 74483 00016270 C6C0C0C0C0C0C00000- <1>     db  0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 06ch
 74484 00016279 0000000000FE6C      <1>
 74485 00016280 6C6C6C6C6C00000000- <1>     db  06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h
 74486 00016289 00FEC660301830      <1>
 74487 00016290 60C6FE000000000000- <1>     db  060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h
 74488 00016299 00007ED8D8D8D8      <1>
 74489 000162A0 700000000000000066- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h
 74490 000162A9 6666667C6060C0      <1>
 74491 000162B0 00000000000076DC18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h
 74492 000162B9 18181818000000      <1>
 74493 000162C0 00007E183C6666663C- <1>     db  000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h, 000h
 74494 000162C9 187E0000000000      <1>
 74495 000162D0 386CC6C6FEC6C66C38- <1>     db  038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch
 74496 000162D9 0000000000386C      <1>
 74497 000162E0 C6C6C66C6C6CEE0000- <1>     db  0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h, 000h, 01eh, 030h, 018h, 00ch
 74498 000162E9 0000001E30180C      <1>
 74499 000162F0 3E6666663C00000000- <1>     db  03eh, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh
 74500 000162F9 000000007EDBDB      <1>
 74501 00016300 7E0000000000000003- <1>     db  07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h
 74502 00016309 067EDBDBF37E60      <1>
 74503 00016310 C000000000001C3060- <1>     db  0c0h, 000h, 000h, 000h, 000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 030h, 01ch, 000h
 74504 00016319 607C6060301C00      <1>
 74505 00016320 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h
 74506 00016329 C6C6C6C6000000      <1>
 74507 00016330 000000FE0000FE0000- <1>     db  000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
 74508 00016339 FE000000000000      <1>
 74509 00016340 0018187E18180000FF- <1>     db  000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 030h, 018h
 74510 00016349 00000000003018      <1>
 74511 00016350 0C060C1830007E0000- <1>     db  00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h, 060h
 74512 00016359 0000000C183060      <1>
 74513 00016360 30180C007E00000000- <1>     db  030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h
 74514 00016369 000E1B1B181818      <1>
 74515 00016370 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h
 74516 00016379 1818181818D8D8      <1>
 74517 00016380 700000000000001818- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h
 74518 00016389 007E0018180000      <1>
 74519 00016390 00000000000076DC00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h
 74520 00016399 76DC0000000000      <1>
 74521 000163A0 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74522 000163A9 00000000000000      <1>
 74523 000163B0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74524 000163B9 00000000000000      <1>
 74525 000163C0 000000180000000000- <1>     db  000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 00ch
 74526 000163C9 00000F0C0C0C0C      <1>
 74527 000163D0 0CEC6C3C1C00000000- <1>     db  00ch, 0ech, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
 74528 000163D9 D86C6C6C6C6C00      <1>
 74529 000163E0 0000000000000070D8- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h
 74530 000163E9 3060C8F8000000      <1>
 74531 000163F0 00000000000000007C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h
 74532 000163F9 7C7C7C7C7C0000      <1>
 74533 00016400 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74534 00016409 00000000000000      <1>
 74535                              <1> vgafont16:
 74536 00016410 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74537 00016419 00000000000000      <1>
 74538 00016420 00007E81A58181BD99- <1>     db  000h, 000h, 07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 081h, 07eh, 000h, 000h, 000h, 000h
 74539 00016429 81817E00000000      <1>
 74540 00016430 00007EFFDBFFFFC3E7- <1>     db  000h, 000h, 07eh, 0ffh, 0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 0ffh, 07eh, 000h, 000h, 000h, 000h
 74541 00016439 FFFF7E00000000      <1>
 74542 00016440 000000006CFEFEFEFE- <1>     db  000h, 000h, 000h, 000h, 06ch, 0feh, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h
 74543 00016449 7C381000000000      <1>
 74544 00016450 0000000010387CFE7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h
 74545 00016459 38100000000000      <1>
 74546 00016460 000000183C3CE7E7E7- <1>     db  000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74547 00016469 18183C00000000      <1>
 74548 00016470 000000183C7EFFFF7E- <1>     db  000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74549 00016479 18183C00000000      <1>
 74550 00016480 000000000000183C3C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
 74551 00016489 18000000000000      <1>
 74552 00016490 FFFFFFFFFFFFE7C3C3- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74553 00016499 E7FFFFFFFFFFFF      <1>
 74554 000164A0 00000000003C664242- <1>     db  000h, 000h, 000h, 000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h
 74555 000164A9 663C0000000000      <1>
 74556 000164B0 FFFFFFFFFFC399BDBD- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74557 000164B9 99C3FFFFFFFFFF      <1>
 74558 000164C0 00001E0E1A3278CCCC- <1>     db  000h, 000h, 01eh, 00eh, 01ah, 032h, 078h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
 74559 000164C9 CCCC7800000000      <1>
 74560 000164D0 00003C666666663C18- <1>     db  000h, 000h, 03ch, 066h, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
 74561 000164D9 7E181800000000      <1>
 74562 000164E0 00003F333F30303030- <1>     db  000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 030h, 070h, 0f0h, 0e0h, 000h, 000h, 000h, 000h
 74563 000164E9 70F0E000000000      <1>
 74564 000164F0 00007F637F63636363- <1>     db  000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h, 000h, 000h, 000h
 74565 000164F9 67E7E6C0000000      <1>
 74566 00016500 0000001818DB3CE73C- <1>     db  000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h, 000h
 74567 00016509 DB181800000000      <1>
 74568 00016510 0080C0E0F0F8FEF8F0- <1>     db  000h, 080h, 0c0h, 0e0h, 0f0h, 0f8h, 0feh, 0f8h, 0f0h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h
 74569 00016519 E0C08000000000      <1>
 74570 00016520 0002060E1E3EFE3E1E- <1>     db  000h, 002h, 006h, 00eh, 01eh, 03eh, 0feh, 03eh, 01eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
 74571 00016529 0E060200000000      <1>
 74572 00016530 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
 74573 00016539 3C180000000000      <1>
 74574 00016540 000066666666666666- <1>     db  000h, 000h, 066h, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h
 74575 00016549 00666600000000      <1>
 74576 00016550 00007FDBDBDB7B1B1B- <1>     db  000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 01bh, 01bh, 000h, 000h, 000h, 000h
 74577 00016559 1B1B1B00000000      <1>
 74578 00016560 007CC660386CC6C66C- <1>     db  000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h
 74579 00016569 380CC67C000000      <1>
 74580 00016570 0000000000000000FE- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 0feh, 000h, 000h, 000h, 000h
 74581 00016579 FEFEFE00000000      <1>
 74582 00016580 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
 74583 00016589 3C187E00000000      <1>
 74584 00016590 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 74585 00016599 18181800000000      <1>
 74586 000165A0 000018181818181818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h
 74587 000165A9 7E3C1800000000      <1>
 74588 000165B0 0000000000180CFE0C- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
 74589 000165B9 18000000000000      <1>
 74590 000165C0 00000000003060FE60- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h
 74591 000165C9 30000000000000      <1>
 74592 000165D0 000000000000C0C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
 74593 000165D9 FE000000000000      <1>
 74594 000165E0 00000000002466FF66- <1>     db  000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h
 74595 000165E9 24000000000000      <1>
 74596 000165F0 000000001038387C7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h, 000h, 000h, 000h
 74597 000165F9 FEFE0000000000      <1>
 74598 00016600 00000000FEFE7C7C38- <1>     db  000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h, 000h
 74599 00016609 38100000000000      <1>
 74600 00016610 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74601 00016619 00000000000000      <1>
 74602 00016620 0000183C3C3C181818- <1>     db  000h, 000h, 018h, 03ch, 03ch, 03ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
 74603 00016629 00181800000000      <1>
 74604 00016630 006666662400000000- <1>     db  000h, 066h, 066h, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74605 00016639 00000000000000      <1>
 74606 00016640 0000006C6CFE6C6C6C- <1>     db  000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 000h
 74607 00016649 FE6C6C00000000      <1>
 74608 00016650 18187CC6C2C07C0606- <1>     db  018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h, 006h, 086h, 0c6h, 07ch, 018h, 018h, 000h, 000h
 74609 00016659 86C67C18180000      <1>
 74610 00016660 00000000C2C60C1830- <1>     db  000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 060h, 0c6h, 086h, 000h, 000h, 000h, 000h
 74611 00016669 60C68600000000      <1>
 74612 00016670 0000386C6C3876DCCC- <1>     db  000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74613 00016679 CCCC7600000000      <1>
 74614 00016680 003030306000000000- <1>     db  000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74615 00016689 00000000000000      <1>
 74616 00016690 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h
 74617 00016699 30180C00000000      <1>
 74618 000166A0 000030180C0C0C0C0C- <1>     db  000h, 000h, 030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h
 74619 000166A9 0C183000000000      <1>
 74620 000166B0 0000000000663CFF3C- <1>     db  000h, 000h, 000h, 000h, 000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h
 74621 000166B9 66000000000000      <1>
 74622 000166C0 000000000018187E18- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h
 74623 000166C9 18000000000000      <1>
 74624 000166D0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 030h, 000h, 000h, 000h
 74625 000166D9 18181830000000      <1>
 74626 000166E0 00000000000000FE00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74627 000166E9 00000000000000      <1>
 74628 000166F0 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
 74629 000166F9 00181800000000      <1>
 74630 00016700 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
 74631 00016709 60C08000000000      <1>
 74632 00016710 00003C66C3C3DBDBC3- <1>     db  000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h, 000h, 000h
 74633 00016719 C3663C00000000      <1>
 74634 00016720 000018387818181818- <1>     db  000h, 000h, 018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h
 74635 00016729 18187E00000000      <1>
 74636 00016730 00007CC6060C183060- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 0c6h, 0feh, 000h, 000h, 000h, 000h
 74637 00016739 C0C6FE00000000      <1>
 74638 00016740 00007CC606063C0606- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 006h, 03ch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74639 00016749 06C67C00000000      <1>
 74640 00016750 00000C1C3C6CCCFE0C- <1>     db  000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h
 74641 00016759 0C0C1E00000000      <1>
 74642 00016760 0000FEC0C0C0FC0606- <1>     db  000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74643 00016769 06C67C00000000      <1>
 74644 00016770 00003860C0C0FCC6C6- <1>     db  000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74645 00016779 C6C67C00000000      <1>
 74646 00016780 0000FEC606060C1830- <1>     db  000h, 000h, 0feh, 0c6h, 006h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h, 000h
 74647 00016789 30303000000000      <1>
 74648 00016790 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74649 00016799 C6C67C00000000      <1>
 74650 000167A0 00007CC6C6C67E0606- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h
 74651 000167A9 060C7800000000      <1>
 74652 000167B0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
 74653 000167B9 18180000000000      <1>
 74654 000167C0 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h
 74655 000167C9 18183000000000      <1>
 74656 000167D0 000000060C18306030- <1>     db  000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 006h, 000h, 000h, 000h, 000h
 74657 000167D9 180C0600000000      <1>
 74658 000167E0 00000000007E00007E- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74659 000167E9 00000000000000      <1>
 74660 000167F0 0000006030180C060C- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h, 000h, 000h, 000h
 74661 000167F9 18306000000000      <1>
 74662 00016800 00007CC6C60C181818- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
 74663 00016809 00181800000000      <1>
 74664 00016810 0000007CC6C6DEDEDE- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h
 74665 00016819 DCC07C00000000      <1>
 74666 00016820 000010386CC6C6FEC6- <1>     db  000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74667 00016829 C6C6C600000000      <1>
 74668 00016830 0000FC6666667C6666- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 066h, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h
 74669 00016839 6666FC00000000      <1>
 74670 00016840 00003C66C2C0C0C0C0- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h
 74671 00016849 C2663C00000000      <1>
 74672 00016850 0000F86C6666666666- <1>     db  000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h, 066h, 066h, 06ch, 0f8h, 000h, 000h, 000h, 000h
 74673 00016859 666CF800000000      <1>
 74674 00016860 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
 74675 00016869 6266FE00000000      <1>
 74676 00016870 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
 74677 00016879 6060F000000000      <1>
 74678 00016880 00003C66C2C0C0DEC6- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 0c6h, 066h, 03ah, 000h, 000h, 000h, 000h
 74679 00016889 C6663A00000000      <1>
 74680 00016890 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74681 00016899 C6C6C600000000      <1>
 74682 000168A0 00003C181818181818- <1>     db  000h, 000h, 03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74683 000168A9 18183C00000000      <1>
 74684 000168B0 00001E0C0C0C0C0CCC- <1>     db  000h, 000h, 01eh, 00ch, 00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
 74685 000168B9 CCCC7800000000      <1>
 74686 000168C0 0000E666666C78786C- <1>     db  000h, 000h, 0e6h, 066h, 066h, 06ch, 078h, 078h, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
 74687 000168C9 6666E600000000      <1>
 74688 000168D0 0000F0606060606060- <1>     db  000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
 74689 000168D9 6266FE00000000      <1>
 74690 000168E0 0000C3E7FFFFDBC3C3- <1>     db  000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
 74691 000168E9 C3C3C300000000      <1>
 74692 000168F0 0000C6E6F6FEDECEC6- <1>     db  000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74693 000168F9 C6C6C600000000      <1>
 74694 00016900 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74695 00016909 C6C67C00000000      <1>
 74696 00016910 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
 74697 00016919 6060F000000000      <1>
 74698 00016920 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h
 74699 00016929 D6DE7C0C0E0000      <1>
 74700 00016930 0000FC6666667C6C66- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 06ch, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
 74701 00016939 6666E600000000      <1>
 74702 00016940 00007CC6C660380C06- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 060h, 038h, 00ch, 006h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74703 00016949 C6C67C00000000      <1>
 74704 00016950 0000FFDB9918181818- <1>     db  000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74705 00016959 18183C00000000      <1>
 74706 00016960 0000C6C6C6C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74707 00016969 C6C67C00000000      <1>
 74708 00016970 0000C3C3C3C3C3C3C3- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
 74709 00016979 663C1800000000      <1>
 74710 00016980 0000C3C3C3C3C3DBDB- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 000h
 74711 00016989 FF666600000000      <1>
 74712 00016990 0000C3C3663C18183C- <1>     db  000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
 74713 00016999 66C3C300000000      <1>
 74714 000169A0 0000C3C3C3663C1818- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74715 000169A9 18183C00000000      <1>
 74716 000169B0 0000FFC3860C183060- <1>     db  000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h
 74717 000169B9 C1C3FF00000000      <1>
 74718 000169C0 00003C303030303030- <1>     db  000h, 000h, 03ch, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h
 74719 000169C9 30303C00000000      <1>
 74720 000169D0 00000080C0E070381C- <1>     db  000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
 74721 000169D9 0E060200000000      <1>
 74722 000169E0 00003C0C0C0C0C0C0C- <1>     db  000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 03ch, 000h, 000h, 000h, 000h
 74723 000169E9 0C0C3C00000000      <1>
 74724 000169F0 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74725 000169F9 00000000000000      <1>
 74726 00016A00 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h
 74727 00016A09 00000000FF0000      <1>
 74728 00016A10 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74729 00016A19 00000000000000      <1>
 74730 00016A20 0000000000780C7CCC- <1>     db  000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74731 00016A29 CCCC7600000000      <1>
 74732 00016A30 0000E06060786C6666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 078h, 06ch, 066h, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h
 74733 00016A39 66667C00000000      <1>
 74734 00016A40 00000000007CC6C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c0h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74735 00016A49 C0C67C00000000      <1>
 74736 00016A50 00001C0C0C3C6CCCCC- <1>     db  000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74737 00016A59 CCCC7600000000      <1>
 74738 00016A60 00000000007CC6FEC0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74739 00016A69 C0C67C00000000      <1>
 74740 00016A70 0000386C6460F06060- <1>     db  000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
 74741 00016A79 6060F000000000      <1>
 74742 00016A80 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
 74743 00016A89 CCCC7C0CCC7800      <1>
 74744 00016A90 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
 74745 00016A99 6666E600000000      <1>
 74746 00016AA0 000018180038181818- <1>     db  000h, 000h, 018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74747 00016AA9 18183C00000000      <1>
 74748 00016AB0 00000606000E060606- <1>     db  000h, 000h, 006h, 006h, 000h, 00eh, 006h, 006h, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h
 74749 00016AB9 06060666663C00      <1>
 74750 00016AC0 0000E06060666C7878- <1>     db  000h, 000h, 0e0h, 060h, 060h, 066h, 06ch, 078h, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h
 74751 00016AC9 6C66E600000000      <1>
 74752 00016AD0 000038181818181818- <1>     db  000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74753 00016AD9 18183C00000000      <1>
 74754 00016AE0 0000000000E6FFDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h
 74755 00016AE9 DBDBDB00000000      <1>
 74756 00016AF0 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
 74757 00016AF9 66666600000000      <1>
 74758 00016B00 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74759 00016B09 C6C67C00000000      <1>
 74760 00016B10 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h
 74761 00016B19 66667C6060F000      <1>
 74762 00016B20 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h
 74763 00016B29 CCCC7C0C0C1E00      <1>
 74764 00016B30 0000000000DC766660- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 076h, 066h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
 74765 00016B39 6060F000000000      <1>
 74766 00016B40 00000000007CC66038- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74767 00016B49 0CC67C00000000      <1>
 74768 00016B50 0000103030FC303030- <1>     db  000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h, 030h, 030h, 036h, 01ch, 000h, 000h, 000h, 000h
 74769 00016B59 30361C00000000      <1>
 74770 00016B60 0000000000CCCCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74771 00016B69 CCCC7600000000      <1>
 74772 00016B70 0000000000C3C3C3C3- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
 74773 00016B79 663C1800000000      <1>
 74774 00016B80 0000000000C3C3C3DB- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h
 74775 00016B89 DBFF6600000000      <1>
 74776 00016B90 0000000000C3663C18- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h
 74777 00016B99 3C66C300000000      <1>
 74778 00016BA0 0000000000C6C6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h
 74779 00016BA9 C6C67E060CF800      <1>
 74780 00016BB0 0000000000FECC1830- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0cch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
 74781 00016BB9 60C6FE00000000      <1>
 74782 00016BC0 00000E181818701818- <1>     db  000h, 000h, 00eh, 018h, 018h, 018h, 070h, 018h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h
 74783 00016BC9 18180E00000000      <1>
 74784 00016BD0 000018181818001818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 74785 00016BD9 18181800000000      <1>
 74786 00016BE0 0000701818180E1818- <1>     db  000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h, 018h, 070h, 000h, 000h, 000h, 000h
 74787 00016BE9 18187000000000      <1>
 74788 00016BF0 000076DC0000000000- <1>     db  000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74789 00016BF9 00000000000000      <1>
 74790 00016C00 0000000010386CC6C6- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h
 74791 00016C09 C6FE0000000000      <1>
 74792 00016C10 00003C66C2C0C0C0C2- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h
 74793 00016C19 663C0C067C0000      <1>
 74794 00016C20 0000CC0000CCCCCCCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74795 00016C29 CCCC7600000000      <1>
 74796 00016C30 000C1830007CC6FEC0- <1>     db  000h, 00ch, 018h, 030h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74797 00016C39 C0C67C00000000      <1>
 74798 00016C40 0010386C00780C7CCC- <1>     db  000h, 010h, 038h, 06ch, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74799 00016C49 CCCC7600000000      <1>
 74800 00016C50 0000CC0000780C7CCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74801 00016C59 CCCC7600000000      <1>
 74802 00016C60 0060301800780C7CCC- <1>     db  000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74803 00016C69 CCCC7600000000      <1>
 74804 00016C70 00386C3800780C7CCC- <1>     db  000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74805 00016C79 CCCC7600000000      <1>
 74806 00016C80 000000003C66606066- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 060h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h, 000h
 74807 00016C89 3C0C063C000000      <1>
 74808 00016C90 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74809 00016C99 C0C67C00000000      <1>
 74810 00016CA0 0000C600007CC6FEC0- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74811 00016CA9 C0C67C00000000      <1>
 74812 00016CB0 00603018007CC6FEC0- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74813 00016CB9 C0C67C00000000      <1>
 74814 00016CC0 000066000038181818- <1>     db  000h, 000h, 066h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74815 00016CC9 18183C00000000      <1>
 74816 00016CD0 00183C660038181818- <1>     db  000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74817 00016CD9 18183C00000000      <1>
 74818 00016CE0 006030180038181818- <1>     db  000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74819 00016CE9 18183C00000000      <1>
 74820 00016CF0 00C60010386CC6C6FE- <1>     db  000h, 0c6h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74821 00016CF9 C6C6C600000000      <1>
 74822 00016D00 386C3800386CC6C6FE- <1>     db  038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74823 00016D09 C6C6C600000000      <1>
 74824 00016D10 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 060h, 066h, 0feh, 000h, 000h, 000h, 000h
 74825 00016D19 6066FE00000000      <1>
 74826 00016D20 00000000006E3B1B7E- <1>     db  000h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h
 74827 00016D29 D8DC7700000000      <1>
 74828 00016D30 00003E6CCCCCFECCCC- <1>     db  000h, 000h, 03eh, 06ch, 0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h
 74829 00016D39 CCCCCE00000000      <1>
 74830 00016D40 0010386C007CC6C6C6- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74831 00016D49 C6C67C00000000      <1>
 74832 00016D50 0000C600007CC6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74833 00016D59 C6C67C00000000      <1>
 74834 00016D60 00603018007CC6C6C6- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74835 00016D69 C6C67C00000000      <1>
 74836 00016D70 003078CC00CCCCCCCC- <1>     db  000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74837 00016D79 CCCC7600000000      <1>
 74838 00016D80 0060301800CCCCCCCC- <1>     db  000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74839 00016D89 CCCC7600000000      <1>
 74840 00016D90 0000C60000C6C6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h
 74841 00016D99 C6C67E060C7800      <1>
 74842 00016DA0 00C6007CC6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74843 00016DA9 C6C67C00000000      <1>
 74844 00016DB0 00C600C6C6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74845 00016DB9 C6C67C00000000      <1>
 74846 00016DC0 0018187EC3C0C0C0C3- <1>     db  000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
 74847 00016DC9 7E181800000000      <1>
 74848 00016DD0 00386C6460F0606060- <1>     db  000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0e6h, 0fch, 000h, 000h, 000h, 000h
 74849 00016DD9 60E6FC00000000      <1>
 74850 00016DE0 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 74851 00016DE9 18181800000000      <1>
 74852 00016DF0 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h, 000h
 74853 00016DF9 6666F300000000      <1>
 74854 00016E00 000E1B1818187E1818- <1>     db  000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h, 000h
 74855 00016E09 181818D8700000      <1>
 74856 00016E10 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74857 00016E19 CCCC7600000000      <1>
 74858 00016E20 000C18300038181818- <1>     db  000h, 00ch, 018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
 74859 00016E29 18183C00000000      <1>
 74860 00016E30 00183060007CC6C6C6- <1>     db  000h, 018h, 030h, 060h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74861 00016E39 C6C67C00000000      <1>
 74862 00016E40 0018306000CCCCCCCC- <1>     db  000h, 018h, 030h, 060h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
 74863 00016E49 CCCC7600000000      <1>
 74864 00016E50 000076DC00DC666666- <1>     db  000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
 74865 00016E59 66666600000000      <1>
 74866 00016E60 76DC00C6E6F6FEDECE- <1>     db  076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 74867 00016E69 C6C6C600000000      <1>
 74868 00016E70 003C6C6C3E007E0000- <1>     db  000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74869 00016E79 00000000000000      <1>
 74870 00016E80 00386C6C38007C0000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74871 00016E89 00000000000000      <1>
 74872 00016E90 0000303000303060C0- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c0h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
 74873 00016E99 C6C67C00000000      <1>
 74874 00016EA0 000000000000FEC0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h
 74875 00016EA9 C0C00000000000      <1>
 74876 00016EB0 000000000000FE0606- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 006h, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h
 74877 00016EB9 06060000000000      <1>
 74878 00016EC0 00C0C0C2C6CC183060- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh, 000h, 000h
 74879 00016EC9 CE9B060C1F0000      <1>
 74880 00016ED0 00C0C0C2C6CC183066- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h, 006h, 000h, 000h
 74881 00016ED9 CE963E06060000      <1>
 74882 00016EE0 00001818001818183C- <1>     db  000h, 000h, 018h, 018h, 000h, 018h, 018h, 018h, 03ch, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h
 74883 00016EE9 3C3C1800000000      <1>
 74884 00016EF0 0000000000366CD86C- <1>     db  000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h, 000h, 000h, 000h
 74885 00016EF9 36000000000000      <1>
 74886 00016F00 0000000000D86C366C- <1>     db  000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h, 000h
 74887 00016F09 D8000000000000      <1>
 74888 00016F10 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h
 74889 00016F19 44114411441144      <1>
 74890 00016F20 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
 74891 00016F29 AA55AA55AA55AA      <1>
 74892 00016F30 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h
 74893 00016F39 77DD77DD77DD77      <1>
 74894 00016F40 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74895 00016F49 18181818181818      <1>
 74896 00016F50 18181818181818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74897 00016F59 18181818181818      <1>
 74898 00016F60 1818181818F818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74899 00016F69 18181818181818      <1>
 74900 00016F70 36363636363636F636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74901 00016F79 36363636363636      <1>
 74902 00016F80 00000000000000FE36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74903 00016F89 36363636363636      <1>
 74904 00016F90 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74905 00016F99 18181818181818      <1>
 74906 00016FA0 3636363636F606F636- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74907 00016FA9 36363636363636      <1>
 74908 00016FB0 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74909 00016FB9 36363636363636      <1>
 74910 00016FC0 0000000000FE06F636- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74911 00016FC9 36363636363636      <1>
 74912 00016FD0 3636363636F606FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74913 00016FD9 00000000000000      <1>
 74914 00016FE0 36363636363636FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74915 00016FE9 00000000000000      <1>
 74916 00016FF0 1818181818F818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74917 00016FF9 00000000000000      <1>
 74918 00017000 00000000000000F818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74919 00017009 18181818181818      <1>
 74920 00017010 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74921 00017019 00000000000000      <1>
 74922 00017020 18181818181818FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74923 00017029 00000000000000      <1>
 74924 00017030 00000000000000FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74925 00017039 18181818181818      <1>
 74926 00017040 181818181818181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74927 00017049 18181818181818      <1>
 74928 00017050 00000000000000FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74929 00017059 00000000000000      <1>
 74930 00017060 18181818181818FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74931 00017069 18181818181818      <1>
 74932 00017070 18181818181F181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74933 00017079 18181818181818      <1>
 74934 00017080 363636363636363736- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74935 00017089 36363636363636      <1>
 74936 00017090 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74937 00017099 00000000000000      <1>
 74938 000170A0 00000000003F303736- <1>     db  000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74939 000170A9 36363636363636      <1>
 74940 000170B0 3636363636F700FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74941 000170B9 00000000000000      <1>
 74942 000170C0 0000000000FF00F736- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74943 000170C9 36363636363636      <1>
 74944 000170D0 363636363637303736- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74945 000170D9 36363636363636      <1>
 74946 000170E0 0000000000FF00FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74947 000170E9 00000000000000      <1>
 74948 000170F0 3636363636F700F736- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74949 000170F9 36363636363636      <1>
 74950 00017100 1818181818FF00FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74951 00017109 00000000000000      <1>
 74952 00017110 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74953 00017119 00000000000000      <1>
 74954 00017120 0000000000FF00FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74955 00017129 18181818181818      <1>
 74956 00017130 00000000000000FF36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74957 00017139 36363636363636      <1>
 74958 00017140 363636363636363F00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74959 00017149 00000000000000      <1>
 74960 00017150 18181818181F181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74961 00017159 00000000000000      <1>
 74962 00017160 00000000001F181F18- <1>     db  000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74963 00017169 18181818181818      <1>
 74964 00017170 000000000000003F36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74965 00017179 36363636363636      <1>
 74966 00017180 36363636363636FF36- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
 74967 00017189 36363636363636      <1>
 74968 00017190 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74969 00017199 18181818181818      <1>
 74970 000171A0 18181818181818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74971 000171A9 00000000000000      <1>
 74972 000171B0 000000000000001F18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 74973 000171B9 18181818181818      <1>
 74974 000171C0 FFFFFFFFFFFFFFFFFF- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74975 000171C9 FFFFFFFFFFFFFF      <1>
 74976 000171D0 00000000000000FFFF- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
 74977 000171D9 FFFFFFFFFFFFFF      <1>
 74978 000171E0 F0F0F0F0F0F0F0F0F0- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
 74979 000171E9 F0F0F0F0F0F0F0      <1>
 74980 000171F0 0F0F0F0F0F0F0F0F0F- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
 74981 000171F9 0F0F0F0F0F0F0F      <1>
 74982 00017200 FFFFFFFFFFFFFF0000- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 74983 00017209 00000000000000      <1>
 74984 00017210 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h
 74985 00017219 D8DC7600000000      <1>
 74986 00017220 000078CCCCCCD8CCC6- <1>     db  000h, 000h, 078h, 0cch, 0cch, 0cch, 0d8h, 0cch, 0c6h, 0c6h, 0c6h, 0cch, 000h, 000h, 000h, 000h
 74987 00017229 C6C6CC00000000      <1>
 74988 00017230 0000FEC6C6C0C0C0C0- <1>     db  000h, 000h, 0feh, 0c6h, 0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h
 74989 00017239 C0C0C000000000      <1>
 74990 00017240 00000000FE6C6C6C6C- <1>     db  000h, 000h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h
 74991 00017249 6C6C6C00000000      <1>
 74992 00017250 000000FEC660301830- <1>     db  000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
 74993 00017259 60C6FE00000000      <1>
 74994 00017260 00000000007ED8D8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
 74995 00017269 D8D87000000000      <1>
 74996 00017270 000000006666666666- <1>     db  000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h, 000h, 000h, 000h
 74997 00017279 7C6060C0000000      <1>
 74998 00017280 0000000076DC181818- <1>     db  000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 74999 00017289 18181800000000      <1>
 75000 00017290 0000007E183C666666- <1>     db  000h, 000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
 75001 00017299 3C187E00000000      <1>
 75002 000172A0 000000386CC6C6FEC6- <1>     db  000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h
 75003 000172A9 C66C3800000000      <1>
 75004 000172B0 0000386CC6C6C66C6C- <1>     db  000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h
 75005 000172B9 6C6CEE00000000      <1>
 75006 000172C0 00001E30180C3E6666- <1>     db  000h, 000h, 01eh, 030h, 018h, 00ch, 03eh, 066h, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h
 75007 000172C9 66663C00000000      <1>
 75008 000172D0 00000000007EDBDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh, 0dbh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h
 75009 000172D9 7E000000000000      <1>
 75010 000172E0 00000003067EDBDBF3- <1>     db  000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h, 0c0h, 000h, 000h, 000h, 000h
 75011 000172E9 7E60C000000000      <1>
 75012 000172F0 00001C3060607C6060- <1>     db  000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 060h, 030h, 01ch, 000h, 000h, 000h, 000h
 75013 000172F9 60301C00000000      <1>
 75014 00017300 0000007CC6C6C6C6C6- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
 75015 00017309 C6C6C600000000      <1>
 75016 00017310 00000000FE0000FE00- <1>     db  000h, 000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h
 75017 00017319 00FE0000000000      <1>
 75018 00017320 0000000018187E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h
 75019 00017329 0000FF00000000      <1>
 75020 00017330 00000030180C060C18- <1>     db  000h, 000h, 000h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h
 75021 00017339 30007E00000000      <1>
 75022 00017340 0000000C1830603018- <1>     db  000h, 000h, 000h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h
 75023 00017349 0C007E00000000      <1>
 75024 00017350 00000E1B1B18181818- <1>     db  000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
 75025 00017359 18181818181818      <1>
 75026 00017360 1818181818181818D8- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
 75027 00017369 D8D87000000000      <1>
 75028 00017370 000000001818007E00- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
 75029 00017379 18180000000000      <1>
 75030 00017380 000000000076DC0076- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h
 75031 00017389 DC000000000000      <1>
 75032 00017390 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75033 00017399 00000000000000      <1>
 75034 000173A0 000000000000001818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75035 000173A9 00000000000000      <1>
 75036 000173B0 000000000000000018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75037 000173B9 00000000000000      <1>
 75038 000173C0 000F0C0C0C0C0CEC6C- <1>     db  000h, 00fh, 00ch, 00ch, 00ch, 00ch, 00ch, 0ech, 06ch, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h
 75039 000173C9 6C3C1C00000000      <1>
 75040 000173D0 00D86C6C6C6C6C0000- <1>     db  000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75041 000173D9 00000000000000      <1>
 75042 000173E0 0070D83060C8F80000- <1>     db  000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75043 000173E9 00000000000000      <1>
 75044 000173F0 000000007C7C7C7C7C- <1>     db  000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h, 000h, 000h, 000h
 75045 000173F9 7C7C0000000000      <1>
 75046 00017400 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
 75047 00017409 00000000000000      <1>
 75048                              <1> 
 75049                              <1> ; 01/01/2021 (TRDOS 386 v2.0.3)
 75050                              <1> 
 75051                              <1> %if 0
 75052                              <1> 
 75053                              <1> vgafont14alt:
 75054                              <1>     db  01dh, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 022h
 75055                              <1>     db  000h, 063h, 063h, 063h, 022h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02bh, 000h
 75056                              <1>     db  000h, 000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 02dh, 000h, 000h
 75057                              <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04dh, 000h, 000h, 0c3h
 75058                              <1>     db  0e7h, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh
 75059                              <1>     db  099h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h
 75060                              <1>     db  0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h
 75061                              <1>     db  0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h
 75062                              <1>     db  03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
 75063                              <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 061h
 75064                              <1>     db  0c3h, 0ffh, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh
 75065                              <1>     db  0dbh, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
 75066                              <1>     db  000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h
 75067                              <1>     db  000h, 000h, 091h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h
 75068                              <1>     db  000h, 09bh, 000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h
 75069                              <1>     db  09dh, 000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 000h, 000h, 000h, 09eh
 75070                              <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 0f3h, 000h, 000h, 000h, 0f1h, 000h
 75071                              <1>     db  000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 0ffh, 000h, 000h, 000h, 0f6h, 000h, 000h
 75072                              <1>     db  018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
 75073                              <1> vgafont16alt:
 75074                              <1>     db  01dh, 000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h
 75075                              <1>     db  000h, 030h, 000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h
 75076                              <1>     db  000h, 000h, 04dh, 000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h
 75077                              <1>     db  000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch
 75078                              <1>     db  000h, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch
 75079                              <1>     db  018h, 000h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh
 75080                              <1>     db  066h, 066h, 000h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch
 75081                              <1>     db  066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
 75082                              <1>     db  018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h
 75083                              <1>     db  030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h
 75084                              <1>     db  0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h
 75085                              <1>     db  0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h
 75086                              <1>     db  000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h, 078h, 000h, 000h, 000h
 75087                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h, 091h, 000h, 000h
 75088                              <1>     db  000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h, 09bh, 000h
 75089                              <1>     db  018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 09dh
 75090                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
 75091                              <1>     db  09eh, 000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h
 75092                              <1>     db  000h, 0abh, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh
 75093                              <1>     db  000h, 000h, 0ach, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h
 75094                              <1>     db  006h, 000h, 000h, 000h
 75095                              <1> 
 75096                              <1> %endif
 75097                                  
 75098                                  ; 20/11/2020
 75099                                  vbe2_bochs_vbios:
 75100                                  ;	db "BOCHS/QEMU"
 75101 00017410 424F4348532F51454D-     	db "BOCHS/QEMU/VIRTUALBOX"  ; 26/11/2020
 75102 00017419 552F5649525455414C-
 75103 00017422 424F58             
 75104                                  ;vbe_vnumber equ vbe2_bochs_vbios + 28 ; "3" or "2"
 75105                                  ; 26/11/2020
 75106                                  vbe_vnumber equ vbe2_bochs_vbios + 30 ; "3" or "2"
 75107                                  ; 15/11/2020
 75108                                  vesa_vbe3_bios_msg:
 75109                                  	;db " VESA VBE version 3 Video BIOS ..."
 75110 00017425 205645534120564245-     	db " VESA VBE3 Video BIOS ..." ; 26/11/2020
 75111 0001742E 3320566964656F2042-
 75112 00017437 494F53202E2E2E     
 75113 0001743E 0D0A0D0A00              	db 0Dh, 0Ah, 0Dh, 0Ah, 0
 75114                                  
 75115                                  ; 28/02/2021
 75116 00017443 18                      truecolor: db 24
 75117                                  
 75118                                  align 2
 75119                                  
 75120                                  ; EPOCH Variables
 75121                                  ; 13/04/2015 - Retro UNIX 386 v1 Beginning
 75122                                  ; 09/04/2013 epoch variables
 75123                                  ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
 75124                                  ;
 75125 00017444 B207                    year: 	dw 1970
 75126 00017446 0100                    month: 	dw 1
 75127 00017448 0100                    day: 	dw 1
 75128 0001744A 0000                    hour: 	dw 0
 75129 0001744C 0000                    minute: dw 0
 75130 0001744E 0000                    second: dw 0
 75131                                  
 75132                                  DMonth:
 75133 00017450 0000                    	dw 0
 75134 00017452 1F00                    	dw 31
 75135 00017454 3B00                    	dw 59
 75136 00017456 5A00                    	dw 90
 75137 00017458 7800                    	dw 120
 75138 0001745A 9700                    	dw 151
 75139 0001745C B500                    	dw 181
 75140 0001745E D400                    	dw 212
 75141 00017460 F300                    	dw 243
 75142 00017462 1101                    	dw 273
 75143 00017464 3001                    	dw 304
 75144 00017466 4E01                    	dw 334
 75145                                  
 75146                                  ; 15/11/2020
 75147 00017468 00                      db	0
 75148                                  kernel_version_msg: ; 07/08/2022
 75149 00017469 5452444F5320283338-     db	"TRDOS (386) Kernel v2.0.5 by Erdogan Tan"
 75150 00017472 3629204B65726E656C-
 75151 0001747B 2076322E302E352062-
 75152 00017484 79204572646F67616E-
 75153 0001748D 2054616E           
 75154 00017491 00                      db	0
 75155                                  
 75156                                  ; 20/02/2017
 75157                                  KERNELFSIZE  equ $  ; 04/07/2016
 75158                                  
 75159                                  bss_start:
 75160                                  
 75161                                  ABSOLUTE bss_start
 75162                                  
 75163 00017492 <res 00000006>          alignb 8 ; 25/12/2016
 75164                                  
 75165                                  	; 15/04/2016
 75166                                  	; TRDOS 386 (TRDOS v2.0)
 75167                                  	; 	80 interrupts 	
 75168                                  	; 11/03/2015
 75169                                  	; Interrupt Descriptor Table (20/08/2014)
 75170                                  idt:
 75171                                  	;resb	64*8 ; INT 0 to INT 3Fh
 75172                                  	; 15/04/2016
 75173 00017498 <res 00000280>          	resb	80*8 ; INT 0 to INT 4Fh
 75174                                  
 75175                                  idt_end:
 75176                                  
 75177                                  ;alignb 4
 75178                                  
 75179                                  task_state_segment:
 75180                                  	; 24/03/2015
 75181 00017718 <res 00000002>          tss.link:   resw 1
 75182 0001771A <res 00000002>          	    resw 1
 75183                                  ; tss offset 4	
 75184 0001771C <res 00000004>          tss.esp0:   resd 1
 75185 00017720 <res 00000002>          tss.ss0:    resw 1
 75186 00017722 <res 00000002>          	    resw 1	
 75187 00017724 <res 00000004>          tss.esp1:   resd 1
 75188 00017728 <res 00000002>          tss.ss1:    resw 1
 75189 0001772A <res 00000002>          	    resw 1 	
 75190 0001772C <res 00000004>          tss.esp2:   resd 1
 75191 00017730 <res 00000002>          tss.ss2:    resw 1
 75192 00017732 <res 00000002>          	    resw 1
 75193                                  ; tss offset 28
 75194 00017734 <res 00000004>          tss.CR3:    resd 1
 75195 00017738 <res 00000004>          tss.eip:    resd 1
 75196 0001773C <res 00000004>          tss.eflags: resd 1
 75197                                  ; tss offset 40
 75198 00017740 <res 00000004>          tss.eax:    resd 1		 		
 75199 00017744 <res 00000004>          tss.ecx:    resd 1
 75200 00017748 <res 00000004>          tss.edx:    resd 1
 75201 0001774C <res 00000004>          tss.ebx:    resd 1
 75202 00017750 <res 00000004>          tss.esp:    resd 1
 75203 00017754 <res 00000004>          tss.ebp:    resd 1
 75204 00017758 <res 00000004>          tss.esi:    resd 1
 75205 0001775C <res 00000004>          tss.edi:    resd 1
 75206                                  ; tss offset 72
 75207 00017760 <res 00000002>          tss.ES:     resw 1
 75208 00017762 <res 00000002>          	    resw 1	
 75209 00017764 <res 00000002>          tss.CS:	    resw 1
 75210 00017766 <res 00000002>          	    resw 1
 75211 00017768 <res 00000002>          tss.SS:	    resw 1
 75212 0001776A <res 00000002>          	    resw 1
 75213 0001776C <res 00000002>          tss.DS:	    resw 1
 75214 0001776E <res 00000002>          	    resw 1
 75215 00017770 <res 00000002>          tss.FS:	    resw 1
 75216 00017772 <res 00000002>          	    resw 1
 75217 00017774 <res 00000002>          tss.GS:	    resw 1
 75218 00017776 <res 00000002>          	    resw 1		
 75219 00017778 <res 00000002>          tss.LDTR:   resw 1
 75220 0001777A <res 00000002>          	    resw 1
 75221                                  ; tss offset 100		
 75222 0001777C <res 00000002>          	    resw 1		
 75223 0001777E <res 00000002>          tss.IOPB:   resw 1
 75224                                  ; tss offset 104 
 75225                                  tss_end:
 75226                                  
 75227 00017780 <res 00000004>          k_page_dir:  resd 1 ; Kernel's (System) Page Directory address
 75228                                  		    ; (Physical address = Virtual address)	 	
 75229 00017784 <res 00000004>          memory_size: resd 1 ; memory size in pages
 75230 00017788 <res 00000004>          free_pages:  resd 1 ; number of free pages		
 75231 0001778C <res 00000004>          next_page:   resd 1 ; offset value in M.A.T. for
 75232                                  		    ; first free page search
 75233 00017790 <res 00000004>          last_page:   resd 1 ; offset value in M.A.T. which
 75234                                  		    ; next free page search will be
 75235                                  		    ; stopped after it. (end of M.A.T.)
 75236 00017794 <res 00000004>          first_page:  resd 1 ; offset value in M.A.T. which
 75237                                  		    ; first free page search
 75238                                  		    ; will be started on it. (for user)
 75239 00017798 <res 00000004>          mat_size:    resd 1 ; Memory Allocation Table size in pages
 75240                                  
 75241                                  ; 20/11/2020
 75242                                  ;vbe2bios:   resw 1 ; VBE2 video bios ID (bochs/qemu)
 75243                                  ;		    ; (0B0C4h or 0B0C5h for bochs/plex86 vgabios)				
 75244                                  
 75245                                  ; 02/09/2014 (Retro UNIX 386 v1)
 75246                                  ; 04/12/2013 (Retro UNIX 8086 v1)
 75247 0001779C <res 00000002>          CRT_START:   resw 1 	  ; starting address in regen buffer
 75248                                  			  ; NOTE: active page only	
 75249 0001779E <res 00000010>          CURSOR_POSN: resw 8 ; cursor positions for video pages
 75250                                  ACTIVE_PAGE: 
 75251 000177AE <res 00000001>          ptty: 	     resb 1 ; current tty
 75252                                  ; 01/07/2015 - 29/01/2016
 75253 000177AF <res 00000001>          ccolor:	     resb 1 ; current color attribute
 75254                                  ; 26/10/2015
 75255                                  ; 07/09/2014
 75256 000177B0 <res 00000014>          ttychr:      resw ntty+2 ; Character buffer (multiscreen)
 75257                                  
 75258                                  ; 18/05/2015 (03/06/2013 - Retro UNIX 8086 v1 feature only!)
 75259 000177C4 <res 00000004>          p_time:      resd 1     ; present time (for systime & sysmdate)
 75260                                  
 75261                                  ; 18/05/2015 (16/08/2013 - Retro UNIX 8086 v1 feature only !)
 75262                                  ; (open mode locks for pseudo TTYs)
 75263                                  ; [ major tty locks (return error in any conflicts) ]
 75264 000177C8 <res 00000014>          ttyl:        resw ntty+2 ; opening locks for TTYs.
 75265                                  
 75266                                  ; 15/04/2015 (Retro UNIX 386 v1)
 75267                                  ; 22/09/2013 (Retro UNIX 8086 v1)
 75268 000177DC <res 0000000A>          wlist:       resb ntty+2 ; wait channel list (0 to 9 for TTYs)
 75269                                  ; 15/04/2015 (Retro UNIX 386 v1)
 75270                                  ;; 12/07/2014 -> sp_init set comm. parameters as 0E3h
 75271                                  ;; 0 means serial port is not available 
 75272                                  ;;comprm: ; 25/06/2014
 75273 000177E6 <res 00000001>          com1p:       resb 1  ;;0E3h
 75274 000177E7 <res 00000001>          com2p:       resb 1  ;;0E3h
 75275                                  
 75276                                  ; 17/11/2015
 75277                                  ; request for response (from the terminal)	
 75278 000177E8 <res 00000002>          req_resp:    resw 1 			
 75279                                  ; 07/11/2015
 75280 000177EA <res 00000001>          ccomport:    resb 1 ; current COM (serial) port
 75281                                  		    ; (0= COM1, 1= COM2)
 75282                                  ; 09/11/2015
 75283 000177EB <res 00000001>          comqr:	     resb 1 ; 'query or response' sign (u9.s, 'sndc')
 75284                                  ; 07/11/2015
 75285 000177EC <res 00000002>          rchar:	     resw 1 ; last received char for COM 1 and COM 2		
 75286 000177EE <res 00000002>          schar:	     resw 1 ; last sent char for COM 1 and COM 2
 75287                                  
 75288                                  ; 22/08/2014 (RTC)
 75289                                  ; (Packed BCD)
 75290 000177F0 <res 00000001>          time_seconds: resb 1
 75291 000177F1 <res 00000001>          time_minutes: resb 1
 75292 000177F2 <res 00000001>          time_hours:   resb 1
 75293 000177F3 <res 00000001>          date_wday:    resb 1
 75294 000177F4 <res 00000001>          date_day:     resb 1
 75295 000177F5 <res 00000001>          date_month:   resb 1			
 75296 000177F6 <res 00000001>          date_year:    resb 1
 75297 000177F7 <res 00000001>          date_century: resb 1
 75298                                  
 75299                                  ; 24/01/2016
 75300 000177F8 <res 00000004>          RTC_LH:	       resd 1
 75301 000177FC <res 00000001>          RTC_WAIT_FLAG: resb 1
 75302 000177FD <res 00000001>          USER_FLAG:     resb 1
 75303                                  ; 19/05/2016
 75304                                  ;RTC_second:
 75305 000177FE <res 00000001>          RTC_2Hz:       resb 1	; from 2Hz interrupt to 1Hz timer event function	
 75306                                  
 75307                                  %include 'diskbss.s'	; UNINITIALIZED DISK (BIOS) DATA
 75308                              <1> ; ****************************************************************************
 75309                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskbss.s
 75310                              <1> ; ----------------------------------------------------------------------------
 75311                              <1> ; Last Update: 06/08/2022 (Previous: 24/01/2016)
 75312                              <1> ; ----------------------------------------------------------------------------
 75313                              <1> ; Beginning: 24/01/2016
 75314                              <1> ; ----------------------------------------------------------------------------
 75315                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 75316                              <1> ; ----------------------------------------------------------------------------
 75317                              <1> ; Turkish Rational DOS
 75318                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
 75319                              <1> ;
 75320                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 75321                              <1> ; diskbss.inc (10/07/2015)
 75322                              <1> ;
 75323                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
 75324                              <1> ; ****************************************************************************
 75325                              <1> 
 75326                              <1> ; Retro UNIX 386 v1 Kernel - DISKBSS.INC
 75327                              <1> ; Last Modification: 10/07/2015
 75328                              <1> ;	(Unitialized Disk Parameters Data section for 'DISKIO.INC') 
 75329                              <1> 
 75330 000177FF <res 00000001>      <1> alignb 2
 75331                              <1> 
 75332                              <1> ;----------------------------------------
 75333                              <1> ;	TIMER DATA AREA 		:
 75334                              <1> ;----------------------------------------
 75335                              <1> 
 75336                              <1> TIMER_LH:	; 16/02/2015
 75337 00017800 <res 00000002>      <1> TIMER_LOW:      resw	1               ; LOW WORD OF TIMER COUNT
 75338 00017802 <res 00000002>      <1> TIMER_HIGH:     resw	1               ; HIGH WORD OF TIMER COUNT
 75339 00017804 <res 00000001>      <1> TIMER_OFL:      resb 	1               ; TIMER HAS ROLLED OVER SINCE LAST READ
 75340                              <1> 
 75341                              <1> ;----------------------------------------
 75342                              <1> ;	DISKETTE DATA AREAS		:
 75343                              <1> ;----------------------------------------
 75344                              <1> 
 75345 00017805 <res 00000001>      <1> SEEK_STATUS:	resb	1
 75346 00017806 <res 00000001>      <1> MOTOR_STATUS:	resb	1
 75347 00017807 <res 00000001>      <1> MOTOR_COUNT:	resb	1
 75348 00017808 <res 00000001>      <1> DSKETTE_STATUS:	resb	1
 75349 00017809 <res 00000007>      <1> NEC_STATUS:	resb	7
 75350                              <1> 
 75351                              <1> ;----------------------------------------
 75352                              <1> ;	ADDITIONAL MEDIA DATA		:
 75353                              <1> ;----------------------------------------
 75354                              <1> 
 75355 00017810 <res 00000001>      <1> LASTRATE:	resb 	1
 75356 00017811 <res 00000001>      <1> HF_STATUS:	resb 	1
 75357                              <1> ; 06/08/2022
 75358                              <1> ;HF_ERROR:	resb 	1
 75359 00017812 <res 00000001>      <1> HF_INT_FLAG:	resb 	1
 75360                              <1> ; 06/08/2022
 75361                              <1> ;HF_CNTRL:	resb 	1
 75362                              <1> ;DSK_STATE:	resb 	4
 75363                              <1> ; 06/08/2022
 75364 00017813 <res 00000002>      <1> DSK_STATE:	resb	2 	
 75365 00017815 <res 00000002>      <1> DSK_TRK:	resb 	2
 75366                              <1> 
 75367                              <1> ;----------------------------------------
 75368                              <1> ;	FIXED DISK DATA AREAS		:
 75369                              <1> ;----------------------------------------
 75370                              <1> 
 75371 00017817 <res 00000001>      <1> DISK_STATUS1:	resb 	1		; FIXED DISK STATUS
 75372 00017818 <res 00000001>      <1> HF_NUM:		resb 	1		; COUNT OF FIXED DISK DRIVES
 75373 00017819 <res 00000001>      <1> CONTROL_BYTE:	resb 	1		; HEAD CONTROL BYTE
 75374                              <1> ;@PORT_OFF	resb	1		; RESERVED (PORT OFFSET)
 75375                              <1> ;port1_off	resb	1		; Hard disk controller 1 - port offset
 75376                              <1> ;port2_off	resb	1		; Hard disk controller 2 - port offset
 75377                              <1> 
 75378 0001781A <res 00000002>      <1> alignb 4
 75379                              <1> 
 75380                              <1> ;HF_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
 75381                              <1> ;HF1_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
 75382                              <1> HF_TBL_VEC: ; 22/12/2014	
 75383 0001781C <res 00000004>      <1> HDPM_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
 75384 00017820 <res 00000004>      <1> HDPS_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
 75385 00017824 <res 00000004>      <1> HDSM_TBL_VEC:	resd	1 		; Secondary master disk param. tbl. pointer
 75386 00017828 <res 00000004>      <1> HDSS_TBL_VEC:	resd	1		; Secondary slave disk param. tbl. pointer
 75387                              <1> 
 75388                              <1> ; 03/01/2015
 75389 0001782C <res 00000001>      <1> LBAMode:     	resb	1
 75390                              <1> 
 75391                              <1> ; *****************************************************************************
 75392                                  
 75393                                  ;;; Real Mode Data (10/07/2015 - BSS)
 75394                                  
 75395                                  ;alignb 2
 75396                                  
 75397                                  ; 10/01/2016
 75398                                  %include 'trdoskx.s'	; UNINITIALIZED KERNEL (Logical Drive & FS) DATA
 75399                              <1> ; ****************************************************************************
 75400                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - UNINITIALIZED DATA : trdoskx.s
 75401                              <1> ; ----------------------------------------------------------------------------
 75402                              <1> ; Last Update: 29/06/2022 (Previous: 17/04/2021 - Kernel v2.0.4)
 75403                              <1> ; ----------------------------------------------------------------------------
 75404                              <1> ; Beginning: 04/01/2016
 75405                              <1> ; ----------------------------------------------------------------------------
 75406                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
 75407                              <1> ; ----------------------------------------------------------------------------
 75408                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
 75409                              <1> ; TRDOS2.ASM (09/11/2011)
 75410                              <1> ; ****************************************************************************
 75411                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
 75412                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
 75413                              <1> ; DIR.ASM      [17/01/2004] Last Update: 09/10/2011
 75414                              <1> ; CMD_INTR.ASM [29/01/2005] Last update: 09/11/2011
 75415                              <1> ; DRV_FAT.ASM  [07/07/2009] Last update: 21/08/2011
 75416                              <1> 
 75417 0001782D <res 00000003>      <1> alignb 4
 75418                              <1> 
 75419                              <1> ; MAINPROG.ASM
 75420 00017830 <res 00000004>      <1> MainProgCfg_FileSize:   resd 1 ; 14/04/2016
 75421 00017834 <res 00000004>      <1> MainProgCfg_LineOffset: resd 1 ; 14/04/2016
 75422                              <1> 
 75423 00017838 <res 00000004>      <1> Current_VolSerial: resd 1
 75424                              <1> 
 75425 0001783C <res 00000004>      <1> Current_Dir_FCluster: resd 1
 75426                              <1> 
 75427 00017840 <res 00000001>      <1> Current_Dir_Level: resb 1
 75428 00017841 <res 00000001>      <1> Current_FATType: resb 1
 75429 00017842 <res 00000001>      <1> Current_Drv: resb 1
 75430 00017843 <res 00000001>      <1> Current_Dir_Drv:   resb 1 ; '?'
 75431 00017844 <res 00000001>      <1>                    resb 1 ; ':'
 75432 00017845 <res 00000001>      <1> Current_Dir_Root:  resb 1 ; '/' 
 75433 00017846 <res 0000005A>      <1> Current_Directory: resb 90
 75434 000178A0 <res 00000001>      <1> End_Of_Current_Dir_Str: resb 1
 75435 000178A1 <res 00000001>      <1> Current_Dir_StrLen: resb 1   
 75436                              <1> 
 75437 000178A2 <res 00000001>      <1> CursorColumn: 	resb 1
 75438 000178A3 <res 00000001>      <1> CmdArgStart:    resb 1
 75439                              <1> 
 75440                              <1> ; 03/02/2016
 75441 000178A4 <res 0000004E>      <1> Remark:		resb 78
 75442                              <1> 
 75443 000178F2 <res 00000050>      <1> CommandBuffer: 	resb 80
 75444                              <1> 
 75445 00017942 <res 00000100>      <1> TextBuffer:	resb 256
 75446                              <1> 
 75447                              <1> MasterBootBuff:
 75448 00017A42 <res 000001BE>      <1> MasterBootCode: resb 1BEh
 75449 00017C00 <res 00000040>      <1> PartitionTable: resb 64
 75450 00017C40 <res 00000002>      <1> MBIDCode: resw 1
 75451                              <1> 
 75452                              <1> PTable_Buffer:
 75453 00017C42 <res 00000040>      <1> PTable_hd0: resb 64
 75454 00017C82 <res 00000040>      <1> PTable_hd1: resb 64
 75455 00017CC2 <res 00000040>      <1> PTable_hd2: resb 64
 75456 00017D02 <res 00000040>      <1> PTable_hd3: resb 64
 75457                              <1> ; 15/07/2020
 75458                              <1> ;PTable_ep0: resb 64
 75459                              <1> ;PTable_ep1: resb 64
 75460                              <1> ;PTable_ep2: resb 64
 75461                              <1> ;PTable_ep3: resb 64
 75462                              <1> 
 75463                              <1> ; 13/08/2020
 75464 00017D42 <res 00000001>      <1> scount: resb 1 ; 16/05/2016 (diskio.s, 'int33h:')
 75465 00017D43 <res 00000001>      <1> 	resb 1
 75466 00017D44 <res 00000001>      <1> 	resb 1
 75467 00017D45 <res 00000001>      <1> 	resb 1
 75468                              <1> 	
 75469 00017D46 <res 00000001>      <1> HD_LBA_yes: resb 1
 75470 00017D47 <res 00000001>      <1> PP_Counter: resb 1
 75471 00017D48 <res 00000001>      <1> EP_Counter: resb 1
 75472                              <1> ; 13/08/2020
 75473 00017D49 <res 00000001>      <1> LD_Counter: resb 1
 75474                              <1> 
 75475                              <1> ; 30/08/2020
 75476 00017D4A <res 00000004>      <1> MBR_EP_StartSector: resd 1 
 75477                              <1> 		; Extd partition start sector as in MBR
 75478 00017D4E <res 00000004>      <1> EP_StartSector: resd 1 ; next extd partition start sector
 75479                              <1> 	; 15/07/2020	
 75480                              <1>                 ;resd 1
 75481                              <1>                 ;resd 1
 75482                              <1> 
 75483                              <1> ; 20/07/2020
 75484 00017D52 <res 00000200>      <1> DOSBootSectorBuff: resb 512
 75485                              <1> ; 15/07/2020
 75486                              <1> ;DOSBootSectorBuff: resb 446 ; 1BEh
 75487                              <1> ;MiniPartitionTable: resb 64 ;  40h
 75488                              <1> ;MiniPartitionMagic: resw  1 ;  02h 		
 75489                              <1> 
 75490                              <1> FAT_BuffDescriptor:
 75491 00017F52 <res 00000004>      <1> FAT_CurrentCluster: resd 1
 75492 00017F56 <res 00000001>      <1> FAT_BuffValidData: resb 1
 75493 00017F57 <res 00000001>      <1> FAT_BuffDrvName: resb 1
 75494 00017F58 <res 00000002>      <1> FAT_BuffOffset: resw 1
 75495 00017F5A <res 00000004>      <1> FAT_BuffSector: resd 1
 75496                              <1> 
 75497 00017F5E <res 00000004>      <1> FAT_ClusterCounter: resd 1
 75498 00017F62 <res 00000004>      <1> LastCluster: resd 1
 75499                              <1> 
 75500                              <1> ; 16/05/2016
 75501                              <1> ;; 18/03/2016 (TRDOS v2.0)
 75502                              <1> ;ClusterBuffer_Valid: resb 1
 75503                              <1> 
 75504                              <1> ; 29/07/2022
 75505 00017F66 <res 00000001>      <1> resb 1
 75506                              <1> 
 75507                              <1> Dir_BuffDescriptor:
 75508 00017F67 <res 00000001>      <1> DirBuff_DRV: resb 1
 75509 00017F68 <res 00000001>      <1> DirBuff_FATType: resb 1
 75510 00017F69 <res 00000001>      <1> DirBuff_ValidData: resb 1
 75511 00017F6A <res 00000002>      <1> DirBuff_CurrentEntry: resw 1
 75512 00017F6C <res 00000002>      <1> DirBuff_LastEntry: resw 1
 75513 00017F6E <res 00000004>      <1> DirBuff_Cluster: resd 1 
 75514 00017F72 <res 00000002>      <1> DirBuffer_Size: resw 1
 75515                              <1> ;DirBuff_EntryCounter: resw 1
 75516                              <1> 
 75517                              <1> ; 01/02/2016
 75518                              <1> ; these are on (real mode) segment 8000h and later
 75519                              <1> ; FAT_Buffer:	resb 1536 ; 3 sectors
 75520                              <1> ; Dir_Buffer:	resb 512*32
 75521                              <1> ; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes
 75522                              <1> 
 75523                              <1> ; 18/01/2016
 75524                              <1> 
 75525 00017F74 <res 00000004>      <1> FreeClusterCount: resd 1
 75526                              <1> 
 75527 00017F78 <res 00000004>      <1> VolSize_Unit1:   resd 1
 75528 00017F7C <res 00000004>      <1> VolSize_Unit2:   resd 1
 75529                              <1> 
 75530 00017F80 <res 00000004>      <1> Vol_Tot_Sec_Str_Start:	    resd 1
 75531 00017F84 <res 0000000A>      <1> Vol_Tot_Sec_Str: 	    resb 10
 75532 00017F8E <res 00000001>      <1> Vol_Tot_Sec_Str_End:	    resb 1
 75533 00017F8F <res 00000001>      <1> resb 1
 75534 00017F90 <res 00000004>      <1> Vol_Free_Sectors_Str_Start: resd 1
 75535 00017F94 <res 0000000A>      <1> Vol_Free_Sectors_Str:	    resb 10				
 75536 00017F9E <res 00000001>      <1> Vol_Free_Sectors_Str_End:   resb 1
 75537                              <1> 
 75538                              <1> ; 10/02/2016
 75539 00017F9F <res 00000001>      <1> RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011
 75540                              <1> 
 75541                              <1> ; 24/01/2016
 75542 00017FA0 <res 00000080>      <1> PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
 75543                              <1> ; 06/02/2016
 75544 00018020 <res 00000004>      <1> CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
 75545 00018024 <res 00000001>      <1> CCD_Level:	resb 1 ; DIR.ASM
 75546 00018025 <res 00000001>      <1> Last_Dir_Level:	resb 1 ; DIR.ASM
 75547                              <1> ;
 75548 00018026 <res 00000002>      <1> CDLF_AttributesMask: resw 1 ; DIR.ASM
 75549 00018028 <res 00000004>      <1> CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
 75550 0001802C <res 00000002>      <1> CDLF_DEType:	resw 1 ; DIR.ASM
 75551                              <1> ;
 75552 0001802E <res 00000001>      <1> CD_COMMAND:	resb 1 ; DIR.ASM
 75553                              <1> 
 75554 0001802F <res 00000001>      <1> alignb 4
 75555                              <1> 
 75556                              <1> ; 29/01/2016
 75557 00018030 <res 00000001>      <1> Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011
 75558                              <1> 
 75559                              <1> ;alignb 4
 75560                              <1> ; 23/02/2016
 75561 00018031 <res 00000001>      <1> disk_rw_op:	resb 1 ; 0 = disk read, 1 = disk write
 75562                              <1> ;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
 75563                              <1> ; 31/01/2016
 75564 00018032 <res 00000001>      <1> retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
 75565 00018033 <res 00000001>      <1> disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
 75566 00018034 <res 00000004>      <1> sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)
 75567                              <1> 
 75568                              <1> ; 06/02/2016 (long name)
 75569 00018038 <res 00000002>      <1> FDE_AttrMask:	   resw 1 ; DIR.ASM
 75570 0001803A <res 00000002>      <1> AmbiguousFileName: resw 1 ; DIR.ASM
 75571 0001803C <res 00000001>      <1> PreviousAttr:	   resb 1 ; DIR.ASM
 75572                              <1> ;	
 75573 0001803D <res 00000001>      <1> LongNameFound:   resb 1	  ; DIR.ASM
 75574 0001803E <res 00000001>      <1> LFN_EntryLength: resb 1   ; DIR.ASM
 75575 0001803F <res 00000001>      <1> LFN_CheckSum:    resb 1   ; DIR.ASM
 75576 00018040 <res 00000084>      <1> LongFileName:    resb 132 ; DIR.ASM
 75577                              <1> 
 75578                              <1> ;PATH_Array_Ptr: resw 1 ; DIR.ASM
 75579 000180C4 <res 00000001>      <1> PATH_CDLevel:	 resb 1 ; DIR.ASM
 75580 000180C5 <res 00000001>      <1> PATH_Level:	 resb 1 ; DIR.ASM
 75581                              <1> 
 75582                              <1> ; 07/02/2016
 75583 000180C6 <res 0000000D>      <1> Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011
 75584                              <1> 
 75585                              <1> ; 10/02/2016
 75586 000180D3 <res 0000000D>      <1> Dir_Entry_Name:	resb 13 ; DIR.ASM
 75587                              <1> 
 75588                              <1> alignb 2
 75589                              <1> 
 75590 000180E0 <res 00000002>      <1> AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011
 75591                              <1> 
 75592                              <1> ; 10/02/2016 (128 bytes -> 126 bytes)
 75593                              <1> ; 08/02/2016
 75594                              <1> ;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
 75595 000180E2 <res 00000001>      <1> FindFile_Drv:		  resb 1
 75596 000180E3 <res 00000041>      <1> FindFile_Directory:	  resb 65
 75597 00018124 <res 0000000D>      <1> FindFile_Name:		  resb 13
 75598                              <1> FindFile_LongNameEntryLength:
 75599 00018131 <res 00000001>      <1> FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
 75600                              <1> ;Above 80 bytes form
 75601                              <1> ;TR-DOS Source/Destination File FullName Format/Structure
 75602 00018132 <res 00000002>      <1> FindFile_AttributesMask:  resw 1
 75603 00018134 <res 00000020>      <1> FindFile_DirEntry:	  resb 32
 75604 00018154 <res 00000004>      <1> FindFile_DirFirstCluster: resd 1
 75605 00018158 <res 00000004>      <1> FindFile_DirCluster:	  resd 1
 75606 0001815C <res 00000002>      <1> FindFile_DirEntryNumber:  resw 1
 75607 0001815E <res 00000002>      <1> FindFile_MatchCounter:	  resw 1
 75608 00018160 <res 00000002>      <1> FindFile_Reserved:	  resw 1 ; 06/03/2016
 75609                              <1> 
 75610 00018162 <res 00000004>      <1> First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
 75611 00018166 <res 00000004>      <1> Last_Slash_Pos: resd 1	; DIR.ASM 
 75612                              <1> 
 75613                              <1> ; 10/02/2016
 75614 0001816A <res 00000002>      <1> File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
 75615 0001816C <res 00000002>      <1> Dir_Count:      resw 1
 75616 0001816E <res 00000004>      <1> Total_FSize:    resd 1
 75617 00018172 <res 00000004>      <1> TFS_Dec_Begin:  resd 1
 75618 00018176 <res 0000000A>      <1>                 resb 10
 75619 00018180 <res 00000001>      <1> TFS_Dec_End:    resb 1
 75620                              <1> 
 75621 00018181 <res 00000001>      <1> PrintDir_RowCounter: resb 1
 75622                              <1> 
 75623 00018182 <res 00000002>      <1> alignb 4
 75624                              <1> ; 15/02/2015 ('show' command variables)
 75625 00018184 <res 00000004>      <1> Show_FDT:	resd 1
 75626 00018188 <res 00000004>      <1> Show_LDDDT:	resd 1
 75627 0001818C <res 00000004>      <1> Show_Cluster:	resd 1
 75628 00018190 <res 00000004>      <1> Show_FileSize:	resd 1
 75629 00018194 <res 00000004>      <1> Show_FilePointer: resd 1
 75630 00018198 <res 00000002>      <1> Show_ClusterPointer: resw 1
 75631 0001819A <res 00000002>      <1> Show_ClusterSize: resw 1
 75632 0001819C <res 00000001>      <1> Show_RowCount:	resb 1
 75633                              <1> 
 75634 0001819D <res 00000003>      <1> alignb 4
 75635                              <1> ; 21/02/2016
 75636 000181A0 <res 00000004>      <1> DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
 75637                              <1> ; 27/02/2016
 75638                              <1> ; DIR.ASM (09/10/2011)
 75639 000181A4 <res 00000004>      <1> DelFile_FCluster:	resd 1
 75640 000181A8 <res 00000002>      <1> DelFile_EntryCounter:	resw 1
 75641 000181AA <res 00000001>      <1> DelFile_LNEL:		resb 1
 75642 000181AB <res 00000001>      <1> resb 1
 75643                              <1> 
 75644                              <1> ; DIR.ASM
 75645 000181AC <res 00000004>      <1> mkdir_DirName_Offset: 	resd 1
 75646 000181B0 <res 00000004>      <1> mkdir_FFCluster:	resd 1
 75647 000181B4 <res 00000004>      <1> mkdir_LastDirCluster:	resd 1
 75648 000181B8 <res 00000004>      <1> mkdir_FreeSectors:	resd 1
 75649 000181BC <res 00000002>      <1> mkdir_attrib:		resw 1 
 75650 000181BE <res 00000001>      <1> mkdir_SecPerClust:	resb 1
 75651 000181BF <res 00000001>      <1> mkdir_add_new_cluster:	resb 1
 75652 000181C0 <res 0000000D>      <1> mkdir_Name:		resb 13
 75653 000181CD <res 00000002>      <1> resw 1 ; 01/03/2016
 75654                              <1> ; 27/02/2016
 75655 000181CF <res 00000001>      <1> RmDir_MultiClusters:	resb 1  
 75656 000181D0 <res 00000004>      <1> RmDir_DirEntryOffset:	resd 1 ; 01/03/2016 (word -> dword)
 75657 000181D4 <res 00000004>      <1> RmDir_ParentDirCluster: resd 1
 75658 000181D8 <res 00000004>      <1> RmDir_DirLastCluster:   resd 1
 75659 000181DC <res 00000004>      <1> RmDir_PreviousCluster:  resd 1
 75660                              <1> ; 22/02/2016
 75661 000181E0 <res 00000001>      <1> UPDLMDT_CDirLevel:	resb 1
 75662 000181E1 <res 00000004>      <1> UPDLMDT_CDirFCluster:	resd 1
 75663                              <1> 	
 75664 000181E5 <res 00000003>      <1> alignb 4
 75665                              <1> ; DRV_FAT.ASM ; 21/08/2011
 75666 000181E8 <res 00000004>      <1> gffc_next_free_cluster:  resd 1
 75667 000181EC <res 00000004>      <1> gffc_first_free_cluster: resd 1
 75668 000181F0 <res 00000004>      <1> gffc_last_free_cluster:  resd 1
 75669                              <1> 
 75670                              <1> ;29/04/2016
 75671                              <1> Cluster_Index: ; resd 1
 75672                              <1> ; 22/02/2016
 75673 000181F4 <res 00000004>      <1> ClusterValue:	resd 1
 75674                              <1> ; 04/03/2016
 75675 000181F8 <res 00000001>      <1> Attributes:	resb 1 
 75676                              <1> ;;CFS_error:  resb 1 ;; 01/03/2016
 75677 000181F9 <res 00000001>      <1> resb 1
 75678 000181FA <res 00000001>      <1> CFS_OPType: resb 1
 75679 000181FB <res 00000001>      <1> CFS_Drv:    resb 1
 75680 000181FC <res 00000004>      <1> CFS_CC:	    resd 1
 75681 00018200 <res 00000004>      <1> CFS_FAT32FSINFOSEC: resd 1
 75682 00018204 <res 00000004>      <1> CFS_FAT32FC: resd 1
 75683                              <1> 
 75684                              <1> ; 27/02/2016
 75685                              <1> ;alignb 4
 75686 00018208 <res 00000004>      <1> glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)
 75687                              <1> ; 22/10/2016
 75688 0001820C <res 00000004>      <1> glc_index:	 resd 1 ;  Last Cluster Index (22/10/2016)	
 75689                              <1> 
 75690                              <1> ; DIR.ASM
 75691 00018210 <res 00000002>      <1> DLN_EntryNumber: resw 1
 75692 00018212 <res 00000001>      <1> DLN_40h:	 resb 1
 75693                              <1> ; 28/02/2016
 75694 00018213 <res 00000001>      <1> TCC_FATErr:	 resb 1 ; DRV_FAT.ASM
 75695                              <1> 
 75696                              <1> alignb 4
 75697                              <1> ; DIR.ASM (09/10/2011)
 75698 00018214 <res 00000002>      <1> LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
 75699 00018216 <res 00000002>      <1> LCDE_ClusterSN:  resw 1
 75700 00018218 <res 00000004>      <1> LCDE_Cluster: 	 resd 1
 75701 0001821C <res 00000004>      <1> LCDE_ByteOffset: resd 1
 75702                              <1> 
 75703                              <1> ;alignb4
 75704                              <1> ; 06/03/2016 (word -> dword)
 75705                              <1> ; CMD_INTR.ASM (01/08/2010)
 75706 00018220 <res 00000004>      <1> SourceFilePath:	     resd 1
 75707 00018224 <res 00000004>      <1> DestinationFilePath: resd 1
 75708                              <1> 
 75709                              <1> ;alignb 4
 75710                              <1> ; 06/03/2016
 75711                              <1> ; FILE.ASM (09/10/2011)
 75712                              <1> ;Source File Structure (same with 'Find File' Structure)
 75713 00018228 <res 00000001>      <1> SourceFile_Drv:			resb 1
 75714 00018229 <res 00000041>      <1> SourceFile_Directory:		resb 65
 75715 0001826A <res 0000000D>      <1> SourceFile_Name:		resb 13
 75716                              <1> SourceFile_LongNameEntryLength: 
 75717 00018277 <res 00000001>      <1> SourceFile_LongNameYes:		resb 1 ; Sign for longname procedures
 75718                              <1> ;Above 80 bytes
 75719                              <1> ;is TR-DOS Source File FullName Format/Structure
 75720 00018278 <res 00000002>      <1> SourceFile_AttributesMask:	resw 1
 75721 0001827A <res 00000020>      <1> SourceFile_DirEntry:		resb 32
 75722 0001829A <res 00000004>      <1> SourceFile_DirFirstCluster:	resd 1
 75723 0001829E <res 00000004>      <1> SourceFile_DirCluster:		resd 1
 75724 000182A2 <res 00000002>      <1> SourceFile_DirEntryNumber:	resw 1
 75725 000182A4 <res 00000002>      <1> SourceFile_MatchCounter:	resw 1
 75726                              <1> ; 16/03/2016
 75727 000182A6 <res 00000001>      <1> SourceFile_SecPerClust:		resb 1
 75728 000182A7 <res 00000001>      <1> SourceFile_Reserved:		resb 1
 75729                              <1> ; Above is 128 bytes
 75730                              <1> 
 75731                              <1> ;Destination File Structure (same with 'Find File' Structure)
 75732 000182A8 <res 00000001>      <1> DestinationFile_Drv:		resb 1
 75733 000182A9 <res 00000041>      <1> DestinationFile_Directory: 	resb 65
 75734 000182EA <res 0000000D>      <1> DestinationFile_Name:		resb 13
 75735                              <1> DestinationFile_LongNameEntryLength:
 75736 000182F7 <res 00000001>      <1> DestinationFile_LongNameYes:	resb 1 ; Sign for longname procedures
 75737                              <1> ;Above 80 bytes
 75738                              <1> ;is TR-DOS Destination File FullName Format/Structure
 75739 000182F8 <res 00000002>      <1> DestinationFile_AttributesMask: resw 1
 75740 000182FA <res 00000020>      <1> DestinationFile_DirEntry:	resb 32
 75741 0001831A <res 00000004>      <1> DestinationFile_DirFirstCluster: resd 1
 75742 0001831E <res 00000004>      <1> DestinationFile_DirCluster:	resd 1
 75743 00018322 <res 00000002>      <1> DestinationFile_DirEntryNumber: resw 1
 75744 00018324 <res 00000002>      <1> DestinationFile_MatchCounter:	resw 1
 75745                              <1> ; 16/03/2016
 75746 00018326 <res 00000001>      <1> DestinationFile_SecPerClust:	resb 1
 75747 00018327 <res 00000001>      <1> DestinationFile_Reserved:	resb 1
 75748                              <1> ; Above is 128 bytes
 75749                              <1> 
 75750                              <1> ; 24/04/2016
 75751 00018328 <res 00000002>      <1> resw 1
 75752                              <1> 
 75753                              <1> ; 10/03/2016
 75754                              <1> ; FILE.ASM
 75755 0001832A <res 00000001>      <1> move_cmd_phase:	   resb 1
 75756 0001832B <res 00000001>      <1> msftdf_sf_df_drv:  resb 1
 75757 0001832C <res 00000004>      <1> msftdf_drv_offset: resd 1
 75758                              <1> 
 75759                              <1> ; 11/03/2016
 75760                              <1> ; DRV_FAT.ASM (21/08/2011)
 75761 00018330 <res 00000004>      <1> FAT_anc_LCluster:  resd 1
 75762 00018334 <res 00000004>      <1> FAT_anc_FFCluster: resd 1
 75763                              <1> 
 75764                              <1> ;alignb 4
 75765                              <1> 
 75766                              <1> ; 14/03/2016
 75767                              <1> ; TRDOS 386 = TRDOS v2.0 feature only !
 75768                              <1> ; 'allocate_memory_block' in 'memory.s'
 75769 00018338 <res 00000004>      <1> mem_ipg_count:	resd 1 ; page count (for contiguous allocation)
 75770 0001833C <res 00000004>      <1> mem_pg_count:	resd 1 ; page count (for count down)
 75771 00018340 <res 00000004>      <1> mem_aperture:	resd 1 ; contiguous free pages (current)
 75772 00018344 <res 00000004>      <1> mem_max_aperture: resd 1 ; maximum value of contiguous free pages
 75773 00018348 <res 00000004>      <1> mem_pg_pos:	resd 1 ; mem. position (page #) of current aperture
 75774 0001834C <res 00000004>      <1> mem_max_pg_pos: resd 1 ; mem. position (page #) of max. aperture
 75775                              <1> 
 75776                              <1> ; 15/03/2016
 75777                              <1> ; FILE.ASM ('copy_source_file_to_destination_file')
 75778 00018350 <res 00000001>      <1> copy_cmd_phase:       resb 1
 75779 00018351 <res 00000001>      <1> csftdf_rw_err:	      resb 1
 75780 00018352 <res 00000001>      <1> DestinationFileFound: resb 1
 75781 00018353 <res 00000001>      <1> csftdf_cdrv: 	      resb 1
 75782 00018354 <res 00000004>      <1> csftdf_filesize:      resd 1
 75783                              <1> ; TRDOS386 (TRDOS v2.0)
 75784 00018358 <res 00000004>      <1> csftdf_sf_mem_addr:   resd 1
 75785 0001835C <res 00000004>      <1> csftdf_sf_mem_bsize:  resd 1
 75786                              <1> ;
 75787                              <1> 
 75788 00018360 <res 00000004>      <1> csftdf_sf_cluster:    resd 1 ; 16/03/2016
 75789 00018364 <res 00000004>      <1> csftdf_df_cluster:    resd 1
 75790                              <1> ; 16/03/2016
 75791 00018368 <res 00000004>      <1> csftdf_r_size:        resd 1
 75792 0001836C <res 00000004>      <1> csftdf_w_size:        resd 1
 75793 00018370 <res 00000004>      <1> csftdf_sf_rbytes:     resd 1
 75794 00018374 <res 00000004>      <1> csftdf_df_wbytes:     resd 1
 75795 00018378 <res 00000001>      <1> csftdf_percentage:    resb 1
 75796                              <1> ; 17/03/2016
 75797 00018379 <res 00000001>      <1> csftdf_videopage:     resb 1
 75798 0001837A <res 00000002>      <1> csftdf_cursorpos:     resw 1
 75799 0001837C <res 00000004>      <1> csftdf_sf_drv_dt:     resd 1
 75800 00018380 <res 00000004>      <1> csftdf_df_drv_dt:     resd 1
 75801                              <1> 
 75802                              <1> ; 21/03/2016
 75803                              <1> ; 20/03/2016
 75804                              <1> ; FILE.ASM
 75805 00018384 <res 00000004>      <1> createfile_Name_Offset:  resd 1
 75806 00018388 <res 00000004>      <1> createfile_FreeSectors:  resd 1 
 75807 0001838C <res 00000004>      <1> createfile_size:         resd 1
 75808 00018390 <res 00000004>      <1> createfile_FFCluster:    resd 1 ; 11/03/2016
 75809 00018394 <res 00000004>      <1> createfile_LastDirCluster: resd 1
 75810 00018398 <res 00000004>      <1> createfile_Cluster:      resd 1
 75811 0001839C <res 00000004>      <1> createfile_PCluster:     resd 1
 75812 000183A0 <res 00000001>      <1> createfile_attrib:	 resb 1
 75813 000183A1 <res 00000001>      <1> createfile_SecPerClust:  resb 1
 75814 000183A2 <res 00000002>      <1> createfile_DirIndex:     resw 1
 75815 000183A4 <res 00000004>      <1> createfile_CCount:	 resd 1
 75816 000183A8 <res 00000002>      <1> createfile_BytesPerSec:	 resw 1 ; 23/03/2016
 75817 000183AA <res 00000001>      <1> createfile_wfc:	         resb 1
 75818 000183AB <res 00000001>      <1> createfile_UpdatePDir:	 resb 1 ; 31/03/2016
 75819                              <1> 
 75820                              <1> ;alignb 4
 75821                              <1> 
 75822                              <1> ; 11/04/2016
 75823 000183AC <res 00000002>      <1> env_var_length:	resw 1
 75824                              <1> 
 75825 000183AE <res 00000002>      <1> alignb 4
 75826                              <1> 
 75827                              <1> ; 25/04/2016
 75828 000183B0 <res 00000001>      <1> readi.valid:	resb 1 ; valid data (>0 = valid for readi)
 75829 000183B1 <res 00000001>      <1> readi.drv:	resb 1 ; drive number (0, 1,2,3,4..)
 75830 000183B2 <res 00000001>      <1> readi.spc:	resb 1 ; sectors per cluster for 'readi' drive
 75831 000183B3 <res 00000001>      <1> readi.s_index:  resb 1 ; sector index in current cluster (buffer)
 75832 000183B4 <res 00000004>      <1> readi.sector:	resd 1 ; current disk sector
 75833 000183B8 <res 00000002>      <1> readi.bpc:	resw 1 ; bytes per cluster - 1
 75834 000183BA <res 00000002>      <1> readi.offset:	resw 1 ; byte offset in cluster buffer
 75835 000183BC <res 00000004>      <1> readi.cluster:  resd 1 ; current cluster number
 75836 000183C0 <res 00000004>      <1> readi.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
 75837 000183C4 <res 00000004>      <1> readi.fclust:	resd 1 ; first cluster of the current cluster
 75838 000183C8 <res 00000004>      <1> readi.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
 75839                              <1> ;readi.buffer:	resd 1 ; readi sector buffer address
 75840                              <1> 
 75841                              <1> ;alignb 4
 75842                              <1> 
 75843 000183CC <res 00000001>      <1> writei.valid:	resb 1 ; valid data (>0 = valid for writei)
 75844 000183CD <res 00000001>      <1> writei.drv:	resb 1 ; drive number (0, 1,2,3,4..)
 75845 000183CE <res 00000001>      <1> writei.spc:	resb 1 ; sectors per cluster for 'writei' drive
 75846 000183CF <res 00000001>      <1> writei.s_index: resb 1 ; sector index in current cluster (buffer)
 75847 000183D0 <res 00000004>      <1> writei.sector:	resd 1 ; current disk sector
 75848 000183D4 <res 00000002>      <1> writei.bpc:	resw 1 ; bytes per cluster - 1
 75849 000183D6 <res 00000002>      <1> writei.offset:	resw 1 ; byte offset in cluster buffer
 75850 000183D8 <res 00000004>      <1> writei.cluster: resd 1 ; current cluster number
 75851 000183DC <res 00000004>      <1> writei.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
 75852 000183E0 <res 00000004>      <1> writei.fclust:  resd 1 ; first cluster of the current cluster
 75853 000183E4 <res 00000004>      <1> writei.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
 75854                              <1> ;writei.buffer:	resd 1 ; writei sector buffer address
 75855 000183E8 <res 00000004>      <1> writei.lclust:	resd 1 ; writei last cluster (mget_w) ; 23/10/2016
 75856 000183EC <res 00000004>      <1> writei.l_index:	resd 1 ; writei last cluster index (mget_w) ; 23/10/2016
 75857 000183F0 <res 00000001>      <1> writei.ofn:	resb 1 ; open file number (to be written) ; 23/10/2016
 75858                              <1> 
 75859 000183F1 <res 00000003>      <1> alignb 4
 75860                              <1> 
 75861                              <1> ; 29/04/2016
 75862 000183F4 <res 00000004>      <1> Run_CDirFC:	resd 1
 75863 000183F8 <res 00000001>      <1> Run_Auto_Path:	resb 1
 75864 000183F9 <res 00000001>      <1> Run_Manual_Path: resb 1 ; 0 -> auto path sequence needed
 75865 000183FA <res 00000001>      <1> EXE_ID:		resb 1	
 75866 000183FB <res 00000001>      <1> EXE_dot:	resb 1
 75867                              <1> 
 75868                              <1> ; 06/05/2016
 75869 000183FC <res 00000004>      <1> mainprog_return_addr: resd 1
 75870 00018400 <res 00000004>      <1> last_error:	resd 1  ; this will be used to return error code to MainProg
 75871                              <1> 			; 'lasterror' keyword will be used later to get the
 75872                              <1> 			; last error code/number/status.
 75873                              <1> ; 12/05/2016
 75874 00018404 <res 00000004>      <1> video_eax:	resd 1  ; eax return value of video function
 75875                              <1> 
 75876                              <1> ; 01/06/2016
 75877 00018408 <res 00000004>      <1> user_buffer:	resd 1  ; 'diskio.s' (INT 33h, Function 08h, floppy disk type)
 75878                              <1> 
 75879                              <1> ; 21/05/2016 - TRDOS 386 ('swap/switch', 'rswap', [u.pri])
 75880 0001840C <res 00000001>      <1> priority:	resb 1  ; running priority level of process (0,1,2)
 75881                              <1> 			; (run queue which is process comes from)
 75882                              <1> ; 22/05/2016 - TRDOS 386 ('set_run_sequence', 'rtc_int', 'u_timer')
 75883 0001840D <res 00000001>      <1> p_change:	resb 1  ; process change status (for timer events)
 75884                              <1> ; 23/05/2016 - TRDOS 386 ('clock')
 75885 0001840E <res 00000001>      <1> multi_tasking:	resb 1   ; Multi Tasking status (0 = disabled, >0 = enabled)
 75886                              <1> 			; (EBX will return with user buffer addr or disk type)
 75887                              <1> ; 07/06/2016
 75888 0001840F <res 00000001>      <1> timer_events:	resb 1  ; number of (active) timer events, <= 16		
 75889                              <1> 
 75890                              <1> ; 24/06/2016
 75891 00018410 <res 00000001>      <1> w_str_cmd:	resb 1	; WRITE_STRING command (0,1,2,3) ; video.s
 75892 00018411 <res 00000001>      <1> p_crt_mode:	resb 1  ; previous video mode (=3 or 0), backup mark/sign
 75893                              <1> ; 26/06/2016
 75894 00018412 <res 00000001>      <1> p_crt_page:	resb 1  ; previous active page (for 'set_mode')
 75895                              <1> ; 04/07/2016
 75896 00018413 <res 00000001>      <1> noclearmem:	resb 1  ; if set, 'SET MODE' (INT 31h) function (AH = 4)
 75897                              <1> 			; will not clear the video memory
 75898                              <1> 			; (usable for graphics modes only)
 75899                              <1> alignb 2
 75900 00018414 <res 00000002>      <1> CRT_LEN:	resw 1  ; length of regen buffer in bytes
 75901 00018416 <res 00000010>      <1> cursor_pposn:	resw 8  ; cursor positions backup
 75902                              <1> 
 75903                              <1> ; 10/07/2016 ('VGA_FONT_SETUP', INT 43H address for x86 real mode bios)
 75904 00018426 <res 00000004>      <1> VGA_INT43H:	resd 1	; 0 = default (not configured by user)
 75905                              <1> 			; 0FFFFFFFFh = user defined fonts
 75906                              <1> 			; address:
 75907                              <1> 			; 	vgafont8
 75908                              <1> 			; 	vgafont16
 75909                              <1> 			; 	vgafont14
 75910                              <1> 
 75911                              <1> ; 25/07/2016
 75912 0001842A <res 00000001>      <1> VGA_MTYPE:	resb 1  ; 0=CTEXT,1=MTEXT,2=CGA,3=PLANAR1,4=PLANAR4,5=LINEAR 
 75913                              <1> 
 75914                              <1> ; 23/10/2016
 75915 0001842B <res 00000001>      <1> setfmod		resb 1	; update last modification date&time sign (if >0)
 75916                              <1> 			; (it is Open File Number + 1, if > 0)
 75917                              <1> alignb 4
 75918                              <1> 
 75919                              <1> ; 16/10/2016
 75920 0001842C <res 00000004>      <1> FFF_UBuffer:	resd 1  ; User's buffer address for FFF & FNF system calls 
 75921                              <1> ; 15/10/2016
 75922 00018430 <res 00000001>      <1> FFF_Valid:	resb 1  ; Find First File Structure validation byte
 75923                              <1> 			; 0  = invalid (Find Next File can't use FFF struct)
 75924                              <1> 			; >0 = valid, return type for FFF and Find Next File
 75925                              <1> 			; 24 = basic parameters, 24 bytes
 75926                              <1> 			; 128 = entire FFF structure/table, 128 bytes
 75927                              <1> ; 16/10/2016 (FFF_Attrib: resw 1)
 75928 00018431 <res 00000001>      <1> FFF_Attrib:	resb 1	; Find First File attributes for Find Next File (LB)
 75929 00018432 <res 00000001>      <1> FFF_RType:	resb 1  ; FFF return type (0 = Basic, >0 = complete) (HB)
 75930                              <1> ; 16/10/2016 - 05/10/2016 (Set Working Path)
 75931 00018433 <res 00000001>      <1> SWP_inv_fname:	resb 1	; Set Working Path - Invalid File Name
 75932 00018434 <res 00000002>      <1> SWP_Mode:	resw 1	; Set Working Path - Mode
 75933 00018436 <res 00000001>      <1> SWP_DRV:	resb 1	; Set Working Path - Drive	
 75934 00018437 <res 00000001>      <1> SWP_DRV_chg:	resb 1	; Set Working Path - Drive Change
 75935                              <1> 
 75936                              <1> ; 27/02/2017
 75937 00018438 <res 00000001>      <1> fpready:	resb 1	; '80387 fpu is ready' flag	
 75938                              <1> 
 75939                              <1> ; 17/04/2021
 75940                              <1> ; (DEVICE parameters is disabled as temporary)
 75941                              <1> 
 75942                              <1> ; 08/10/2016
 75943                              <1> ;device_name:	resb 9  ; capitalized (and zero padded) device name
 75944                              <1> 			; (example: "TTY0",0,0,0,0,0")
 75945                              <1> 
 75946 00018439 <res 00000003>      <1> alignb 4
 75947                              <1> 
 75948                              <1> ; 08/10/2016
 75949                              <1> ; 07/10/2016
 75950                              <1> ; Table of kernel devices (which do not use installable device drivers)
 75951                              <1> ; has been coded into KERNEL (trdosk9.s) 
 75952                              <1> ; 07/10/2016
 75953                              <1> ; 8 installable device drivers available to install (NUMIDEV)
 75954                              <1> ;IDEV_PGDIR: resd NUMIDEV
 75955                              <1> 			; Page directories of installable device drivers
 75956                              <1> 			;
 75957                              <1> 			; Note: Virtual start address is always 400000h
 75958                              <1> 			; (end of the 1st 4MB). [org 400000h]
 75959                              <1> 			; Segments: KCODE, KDATA
 75960                              <1> 			; Method: call 400000h (after changing page dir) 	
 75961                              <1> 			; Query code located at the start (400000h).
 75962                              <1> 			; Query code returns with
 75963                              <1> 			;   eax = device type and driver version
 75964                              <1> 			;         AL = Device Type minor
 75965                              <1> 			;         AH = Device Type major
 75966                              <1> 			;         Byte 16-23 : Version minor
 75967                              <1> 			;	  Byte 24-31 : Version major - 1
 75968                              <1> 			;		       (0:0 -> 1.0)
 75969                              <1> 			;   ebx = initialization code address
 75970                              <1> 			;   ecx = configuration table address
 75971                              <1> 			;   edx = description table address
 75972                              <1> 			;   esi = device (default) name address (ASCIIZ)
 75973                              <1> 			;	 (name has "/DEV/" prefix)		
 75974                              <1> 			;   edi = dispatch table address
 75975                              <1> 			;        (for calling kernel-device functions)
 75976                              <1> 			;   ebp = address table address
 75977                              <1> 			; Initialization code returns with
 75978                              <1> 			;   eax = open code address
 75979                              <1> 			;   ecx = close code address 
 75980                              <1> 			;   ebx = read code address
 75981                              <1> 			;   edx = write code address 	
 75982                              <1> 			;   esi = IOCTL code address
 75983                              <1> 			;   edi = dispatch table address
 75984                              <1> 			;   ebp = address table address
 75985                              <1> 			; Address Table:
 75986                              <1> 			;    Offset 0  : open code address
 75987                              <1> 			;    Offset 4  : read code address
 75988                              <1> 			;    Offset 8  : write code address
 75989                              <1> 			;    Offset 12 : close code address
 75990                              <1> 			;    Offset 16 : IOCTL code address
 75991                              <1> 			;    Offset 20 : initialization code address
 75992                              <1> 			;    Offset 24 : description table address
 75993                              <1> 			;    Offset 28 : configuration table address
 75994                              <1> 			;    Offset 32 : device name address
 75995                              <1> 			;    Offset 36 : dispatch table address
 75996                              <1> 			;          (for calling kernel-device functions)
 75997                              <1> 
 75998                              <1> ;IDEV_NAME:  resb 8*NUMIDEV 
 75999                              <1> 			  ; 8 byte names of installable device drivers
 76000                              <1> 
 76001                              <1> ;IDEV_TYPE:  resb NUMIDEV ; Driver type of installable device drivers
 76002                              <1> ;IDEV_FLAGS: resb NUMIDEV ; Device access parameters for installable
 76003                              <1>                           ; device drivers (These values are set while
 76004                              <1> 			  ; the device driver is being loaded.)
 76005                              <1> ;IDEV_OADDR: resd NUMIDEV ; open function addr for installable dev driver
 76006                              <1> ;IDEV_CADDR: resd NUMIDEV ; close function addr for installable dev driver
 76007                              <1> ;IDEV_RADDR: resd NUMIDEV ; read function addr for installable dev driver
 76008                              <1> ;IDEV_WADDR: resd NUMIDEV ; write function addr for installable dev driver
 76009                              <1> 	
 76010                              <1> ; 08/10/2016	
 76011                              <1> ; 07/10/2016
 76012                              <1> ; Device Open and Access parameters
 76013                              <1> ;DEV_ACCESS:	resb NUMOFDEVICES    ; bit 0 = accessable by normal users
 76014                              <1> 				     ; bit 1 = read access permission
 76015                              <1> 				     ; bit 2 = write access permission
 76016                              <1> 				     ; bit 3 = IOCTL permission to users
 76017                              <1> 				     ; bit 4 = block device if it is set	
 76018                              <1> 				     ; bit 5 = 16 bit or 1024 byte data
 76019                              <1> 				     ; bit 6 = 32 bit or 2048 byte data
 76020                              <1> 				     ; bit 7 = installable device driver
 76021                              <1> ;DEV_R_OWNER:	resb NUMOFDEVICES    ; Reading owner no (u.uid) of devices		
 76022                              <1> ;DEV_R_OPENCOUNT: resb NUMOFDEVICES  ; Reading open count 
 76023                              <1> ;DEV_W_OWNER:	resb NUMOFDEVICES    ; Writing owner no (u.uid) of devices		
 76024                              <1> ;DEV_W_OPENCOUNT: resb NUMOFDEVICES  ; Writing open count
 76025                              <1> ;DEV_DRIVER:	resb NUMOFDEVICES    ; device driver number (1 to 7Fh)
 76026                              <1> 				     ; *if bit 7 is set (80 to FFh)
 76027                              <1> 				     ; *if it is installable device driver
 76028                              <1> 				     ; *index (0 to 7Fh)
 76029                              <1> 				     ; otherwise it is kernel device index
 76030                              <1> ;DEV_OPENMODE:	resb NUMOFDEVICES    ; 1 = read mode
 76031                              <1> 				     ; 2 = write mode
 76032                              <1> 				     ; 3 = read & write 	  
 76033                              <1> 				     ; 0 = not open (free)		
 76034                              <1> ;DEV_NAME_PTR:	resd NUMOFDEVICES    ; pointers to name addresses of drivers
 76035                              <1> 				     ; Address base: KDEV_NAME+		
 76036                              <1> 				     ; or IDEV_NAME+
 76037                              <1> ;DEV_R_POINTER:	resd NUMOFDEVICES    ; reading pointer, writing pointer	
 76038                              <1> ;DEV_W_POINTER:	resd NUMOFDEVICES    ; sector number if block device
 76039                              <1> 				     ; character offset if char device
 76040                              <1> alignb 4
 76041                              <1> 
 76042                              <1> ; 06/10/2016
 76043                              <1> ; Open File Parameters
 76044 0001843C <res 00000080>      <1> OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
 76045 000184BC <res 00000020>      <1> OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
 76046 000184DC <res 00000020>      <1> OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
 76047 000184FC <res 00000020>      <1> OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
 76048 0001851C <res 00000020>      <1> OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
 76049 0001853C <res 00000080>      <1> OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
 76050 000185BC <res 00000080>      <1> OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
 76051 0001863C <res 00000080>      <1> OF_DIRFCLUSTER:	resd OPENFILES  ; Directory First Clusters of open files
 76052 000186BC <res 00000080>      <1> OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
 76053 0001873C <res 00000080>      <1> OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
 76054 000187BC <res 00000080>      <1> OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
 76055 0001883C <res 00000080>      <1> OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
 76056                              <1> ; 24/10/2016
 76057 000188BC <res 00000040>      <1> OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster 
 76058                              <1> 				; Sector index = entry index / 16
 76059                              <1> ;alignb 2
 76060                              <1> 
 76061                              <1> DTA:		;resd 24	; Find First File data transfer area
 76062 000188FC <res 00000018>      <1> 		resb 24		; 29/07/2022		
 76063                              <1> 
 76064                              <1> ; 19/12/2016
 76065 00018914 <res 00000001>      <1> tcallback:	resb 1		; Timer callback method flag for 'systimer'
 76066 00018915 <res 00000001>      <1> trtc:		resb 1		; Timer interrupt type flag for 'systimer'
 76067                              <1> ; 20/02/2017
 76068 00018916 <res 00000001>      <1> no_page_swap:	resb 1		; Swap lock for Signal Response Byte pages 
 76069                              <1> ;;15/01/2017
 76070                              <1> ; 02/01/2017
 76071                              <1> ;;intflg:	resb 1		; software interrupt in progress signal
 76072                              <1> 				; (for timer interrupt)
 76073 00018917 <res 00000001>      <1> alignb 4
 76074                              <1> ; 13/04/2017
 76075                              <1> ;DEV_INTR:	resb NUMOFDEVICES ; Device Interrupt (IRQ) number + 1	
 76076                              <1> 				; (0= not available, 1= IRQ 0, 16= IRQ 15)
 76077 00018918 <res 00000040>      <1> DEV_INT_HNDLR:	resd 16		; Device Interrupt Handler addr, if > 0 	
 76078                              <1> 
 76079                              <1> ;alignb 4
 76080                              <1> 
 76081                              <1> ; 26/02/2017 ; IRQ Callback parameters ('syscalbac')
 76082                              <1> ;Index: ; 0 to 8
 76083                              <1> ;	0 = IRQ3, 1 = IRQ4, 2 = IRQ5, 3 = IRQ7
 76084                              <1> ;	4 = IRQ9, 5 = IRQ10, 6 = IRQ11, 7 = IRQ12, 8 = IRQ13  
 76085 00018958 <res 00000009>      <1> IRQ.owner:	resb 9		; owner, 0 = free, >0 = [u.uno]
 76086 00018961 <res 00000009>      <1> IRQ.dev:	resb 9		; 0 = default/kernel, >0 = device number
 76087 0001896A <res 00000009>      <1> IRQ.method:	resb 9 		; 0 = Signal Response Byte, 1 = Callback
 76088 00018973 <res 00000009>      <1> IRQ.srb:	resb 9 		; Signal Response/Return Byte value
 76089 0001897C <res 00000024>      <1> IRQ.addr:	resd 9		; Rignal Response Byte address (physical)
 76090                              <1> 				; or Callback service address (virtual)
 76091                              <1> ; 28/02/2017
 76092 000189A0 <res 00000004>      <1> IRQ_cr3:	resd 1		; for saving cr3 register in IRQ handler
 76093 000189A4 <res 00000001>      <1> IRQnum:		resb 1		; IRQ number for IRQ handler (trdosk8.s)
 76094                              <1> 
 76095                              <1> ; 10/04/2017
 76096                              <1> ; 03/04/2017
 76097                              <1> ; UNINITIALIZED AUDIO DATA
 76098 000189A5 <res 00000003>      <1> alignb 4
 76099 000189A8 <res 00000001>      <1> audio_pci:	resb 1
 76100 000189A9 <res 00000001>      <1> audio_device:	resb 1
 76101 000189AA <res 00000001>      <1> audio_mode:	resb 1
 76102 000189AB <res 00000001>      <1> audio_intr:	resb 1
 76103 000189AC <res 00000001>      <1> audio_busy:	resb 1  ; Busy flag for audio irq ; 21/04/2017
 76104 000189AD <res 00000001>      <1> audio_reserved: resb 1
 76105 000189AE <res 00000002>      <1> audio_io_base:	resw 1 	; Base I/O address of audio device
 76106 000189B0 <res 00000004>      <1> audio_dev_id:	resd 1	; BUS/DEV/FN ; 00000000BBBBBBBBDDDDDFFF00000000
 76107 000189B4 <res 00000004>      <1> audio_vendor:	resd 1
 76108 000189B8 <res 00000004>      <1> audio_stats_cmd: resd 1
 76109                              <1> ;
 76110 000189BC <res 00000004>      <1> audio_buffer:	resd 1	; virtual address of user's audio buffer
 76111 000189C0 <res 00000004>      <1> audio_p_buffer:	resd 1	; Physical address of user's audio buffer
 76112 000189C4 <res 00000004>      <1> audio_buff_size: resd 1 ; user's audio buffer size (half buffer size) 
 76113 000189C8 <res 00000004>      <1> audio_dma_buff: resd 1  ; dma buffer address
 76114 000189CC <res 00000004>      <1> audio_dmabuff_size: resd 1 ; dma buffer size (2 * half buffer size)
 76115 000189D0 <res 00000001>      <1> audio_flag:	resb 1  ; dma buffer flag (1st half = 0, 2nd half = 1)
 76116 000189D1 <res 00000001>      <1> audio_user:	resb 1	; user number of the owner
 76117 000189D2 <res 00000001>      <1> audio_cb_mode:	resb 1	; 0 = signal response byte method
 76118                              <1> 			; 1 = callback method
 76119                              <1> 			; 2 = s.r.b. method with auto increment
 76120 000189D3 <res 00000001>      <1> audio_srb:	resb 1	; signal response byte value
 76121 000189D4 <res 00000004>      <1> audio_cb_addr:	resd 1  ; callback service address or s.r.b. address
 76122                              <1> 			; (s.r.b. addr is physical, cbs addr is virtual)
 76123                              <1> 
 76124 000189D8 <res 00000001>      <1> audio_bps:	resb 1  ; selected mode: 8 bit, 16 bit
 76125 000189D9 <res 00000001>      <1> audio_stmo:	resb 1	; selected mode: mono /stereo
 76126 000189DA <res 00000002>      <1> audio_freq: 	resw 1	; sampling rate
 76127                              <1> 
 76128                              <1> ; 21/04/2017
 76129 000189DC <res 00000001>      <1> audio_play_cmd: resb 1  ; Play/Stop command (1 = play, 0 = stop)
 76130                              <1> audio_civ: ; 28/05/2017 ; Current Buffer Index (AC'97)
 76131 000189DD <res 00000001>      <1> audio_flag_eol:	resb 1  ; End of Link status (vt8233, EOL/FLAG)
 76132                              <1> 
 76133                              <1> audio_master_volume:
 76134 000189DE <res 00000001>      <1> audio_master_volume_l: resb 1 ; sound volume (lineout) left channel
 76135 000189DF <res 00000001>      <1> audio_master_volume_r: resb 1 ; sound volume (lineout) right channel
 76136                              <1> 
 76137                              <1> alignb 4
 76138                              <1> ; 28/05/2017
 76139                              <1> ; AC'97 Audio Controller Base Adress Registers
 76140 000189E0 <res 00000002>      <1> NAMBAR:		resw 1	; Native Audio Mixer Base Address
 76141 000189E2 <res 00000002>      <1> NABMBAR:	resw 1	; Native Audio Bus Mastering Base Address
 76142                              <1> 	
 76143                              <1> ;alignb 4
 76144                              <1> ; 21/04/2017
 76145 000189E4 <res 00000400>      <1> audio_bdl_buff:	resd 32*8 ; VT8233 (AC97) BDL Buffer Size
 76146                              <1> ; 12/05/2017
 76147 00018DE4 <res 00000004>      <1> base_addr:	resd 1	; 'direct_memory_access' (memory.s)
 76148                              <1> 
 76149                              <1> ; 28/08/2017
 76150                              <1> ; 20/08/2017
 76151 00018DE8 <res 00000001>      <1> 		resb 1  ;
 76152 00018DE9 <res 00000001>      <1> dma_user:	resb 1	; user number for sysdma
 76153 00018DEA <res 00000001>      <1> dma_channel:	resb 1	; dma channel for sysdma
 76154 00018DEB <res 00000001>      <1> dma_mode:	resb 1  ; dma mode for sysdma	
 76155 00018DEC <res 00000004>      <1> dma_addr:	resd 1	; dma buffer physical addr for sysdma
 76156 00018DF0 <res 00000004>      <1> dma_size:	resd 1  ; dma buffer size (in bytes) for sysdma
 76157 00018DF4 <res 00000004>      <1> dma_start:	resd 1  ; dma start address for sysdma
 76158 00018DF8 <res 00000004>      <1> dma_count:	resd 1  ; dma count (in bytes) for sysdma 
 76159                              <1> 
 76160 00018DFC <res 00007204>      <1> alignb 65536
 76161                              <1> ; 09/08/2017
 76162                              <1> ; 12/05/2017
 76163 00020000 <res 00010000>      <1> sb16_dma_buffer: resb 65536 ; DMA buffer for sb16 audio playing.
 76164                                  
 76165                                  ; 24/01/2016
 76166                                  %include 'ubss.s'	; UNINITIALIZED KERNEL (USER) DATA
 76167                              <1> ; ****************************************************************************
 76168                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - UNINITIALIZED USER DATA : ubss.s
 76169                              <1> ; ----------------------------------------------------------------------------
 76170                              <1> ; Last Update: 07/08/2022  (Previous: 28/02/2017)
 76171                              <1> ; ----------------------------------------------------------------------------
 76172                              <1> ; Beginning: 24/01/2016
 76173                              <1> ; ----------------------------------------------------------------------------
 76174                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
 76175                              <1> ; ----------------------------------------------------------------------------
 76176                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
 76177                              <1> ; ux.s (04/12/2015)
 76178                              <1> ; ****************************************************************************
 76179                              <1> 
 76180                              <1> ; Retro UNIX 386 v1 Kernel - ux.s
 76181                              <1> ; Last Modification: 04/12/2015
 76182                              <1> ;
 76183                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
 76184                              <1> ; (Modified from 
 76185                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
 76186                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
 76187                              <1> ; ----------------------------------------------------------------------------
 76188                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
 76189                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
 76190                              <1> ; <Bell Laboratories (17/3/1972)>
 76191                              <1> ; <Preliminary Release of UNIX Implementation Document>
 76192                              <1> ; (Section E10 (17/3/1972) - ux.s)
 76193                              <1> ; ****************************************************************************
 76194                              <1> ; Ref: Retro UNIX 386 v1.2 Kernel (v0.2.2.3) - ux.s - 15/07/2022
 76195                              <1> 
 76196                              <1> alignb 2
 76197                              <1> 
 76198                              <1> %if 0
 76199                              <1> 
 76200                              <1> inode:
 76201                              <1> 	;; 11/03/2013. 
 76202                              <1> 	;;Derived from UNIX v1 source code 'inode' structure (ux).
 76203                              <1> 	;;i.
 76204                              <1> 	;
 76205                              <1> 	;i.flgs: resw 1
 76206                              <1> 	;i.nlks: resb 1
 76207                              <1> 	;i.uid:	 resb 1
 76208                              <1>         ;i.size: resw 1 ; size
 76209                              <1> 	;i.dskp: resw 8 ; 16 bytes
 76210                              <1> 	;i.ctim: resd 1
 76211                              <1> 	;i.mtim: resd 1
 76212                              <1> 	;i.rsvd: resw 1 ; Reserved (ZERO/Undefined word for UNIX v1)
 76213                              <1> 
 76214                              <1> 	; 26/01/2020
 76215                              <1> 	; Retro UNIX 386 v2.0 - Modified UNIX v7 inode model
 76216                              <1> 	;	(15/09/2029 .. 18/12/2019)
 76217                              <1> 
 76218                              <1> 	i.flgs:   resw 1	; /* mode and type of file */
 76219                              <1> 	i.nlks:	  resw 1	; /* number of links to file */
 76220                              <1> 	i.uid:	  resw 1	; /* owner's user id */  - 0 to 65535 -
 76221                              <1> 	i.gid:	  resb 1	; /* owner's group id */ - o to 255 -
 76222                              <1> 	i.size_h: resb 1	; /* number of bytes in file */ ; byte 5
 76223                              <1> 	i.size:	  resd 1 ; size	; /* number of bytes in file */
 76224                              <1> 	i.dskp:	  resd 10 ; 40 bytes ; /* disk block addresses */
 76225                              <1> 	i.atim:	  resd 1	; /* time last accessed */
 76226                              <1> 	i.mtim:	  resd 1	; /* time last modified */
 76227                              <1> 	i.ctim:	  resd 1	; /* time created */
 76228                              <1> 
 76229                              <1> I_SIZE	equ $ - inode
 76230                              <1> 
 76231                              <1> %endif 
 76232                              <1> 
 76233                              <1> process:
 76234                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5 
 76235                              <1> 	; 27/02/2022
 76236                              <1> 	; 12/01/2022 - Retro UNIX 386 v1.2 
 76237                              <1> 	; 19/12/2016
 76238                              <1> 	; 21/05/2016
 76239                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
 76240                              <1> 	; 06/05/2015 - Retro UNIX 386 v1
 76241                              <1> 	; 11/03/2013 - 05/02/2014 (Retro UNIX 8086 v1)
 76242                              <1> 	;Derived from UNIX v1 source code 'proc' structure (ux).
 76243                              <1> 	;p.
 76244                              <1> 	
 76245 00030000 <res 00000020>      <1>         p.pid:   resw nproc
 76246 00030020 <res 00000020>      <1>         p.ppid:  resw nproc
 76247                              <1> 	;p.break: resw nproc ; 12/01/2022 (p.break is not used)
 76248 00030040 <res 00000010>      <1>         p.ttyc:  resb nproc ; console tty in Retro UNIX 8086 v1.
 76249                              <1> 	; 27/02/2022 (p.waitc is not used)
 76250                              <1> 	;p.waitc: resb nproc ; waiting channel in Retro UNIX 8086 v1.
 76251 00030050 <res 00000010>      <1> 	p.link:	 resb nproc
 76252 00030060 <res 00000010>      <1> 	p.stat:	 resb nproc
 76253                              <1> 
 76254                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 feature only !) 
 76255 00030070 <res 00000040>      <1> 	p.upage: resd nproc ; Physical address of the process's
 76256                              <1> 			    ; 'user' structure
 76257                              <1> 	; 21/05/2016	
 76258                              <1> 	; 19/05/2016 (TRDOS 386 feature only!)
 76259 000300B0 <res 00000010>      <1> 	p.timer: resb nproc ; number of timer events of the processs
 76260                              <1> 
 76261                              <1> 	; 19/12/2016
 76262 000300C0 <res 00000040>      <1> 	p.tcb:	resd nproc ; timer callback service address (if > 0)
 76263                              <1> 			  		 			 	  
 76264                              <1> P_SIZE	equ $ - process
 76265                              <1> 
 76266                              <1> ; fsp table (original UNIX v1)
 76267                              <1> ;
 76268                              <1> ;Entry
 76269                              <1> ;          15                                      0
 76270                              <1> ;  1     |---|---------------------------------------|
 76271                              <1> ;        |r/w|       i-number of open file           |
 76272                              <1> ;        |---|---------------------------------------| 
 76273                              <1> ;        |               device number               |
 76274                              <1> ;        |-------------------------------------------|
 76275                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
 76276                              <1> ;        |-------------------------------------------| 
 76277                              <1> ;        |  flag that says    | number of processes  |
 76278                              <1> ;        |   file deleted     | that have file open  |
 76279                              <1> ;        |-------------------------------------------| 
 76280                              <1> ;  2     |                                           |
 76281                              <1> ;        |-------------------------------------------| 
 76282                              <1> ;        |                                           |
 76283                              <1> ;        |-------------------------------------------|
 76284                              <1> ;        |                                           |
 76285                              <1> ;        |-------------------------------------------|
 76286                              <1> ;        |                                           |
 76287                              <1> ;        |-------------------------------------------| 
 76288                              <1> ;  3     |                                           | 
 76289                              <1> ;        |                                           |  
 76290                              <1> ;
 76291                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
 76292                              <1> 
 76293                              <1> ; 27/03/2020 - Retro UNIX 386 v2 - FSP (OPEN FILES) TABLE 
 76294                              <1> 
 76295                              <1> ;Entry
 76296                              <1> ;         15                    7                   0
 76297                              <1> ;  1     |-------------------------------------------|
 76298                              <1> ;        |   	     i-number of open file           |
 76299                              <1> ;        |-------------------------------------------| 
 76300                              <1> ;        |        high word of 32 bit i-number       |
 76301                              <1> ;        |-------------------------------------------|
 76302                              <1> ;        | open mode & status  |   device number     |
 76303                              <1> ;        |-------------------------------------------|
 76304                              <1> ;        |    reserved byte    |     open count      |
 76305                              <1> ;        |-------------------------------------------| 
 76306                              <1> ;        | offset pointer, i.e., r/w pointer to file |
 76307                              <1> ;        |-------------------------------------------|
 76308                              <1> ;        |   64 bit file offset pointer (bit 16-31)  | 
 76309                              <1> ;        |-------------------------------------------|
 76310                              <1> ;        |   64 bit file offset pointer (bit 32-47)  | 
 76311                              <1> ;        |-------------------------------------------|
 76312                              <1> ;        |   64 bit file offset pointer (bit 48-63)  | 
 76313                              <1> ;        |-------------------------------------------|
 76314                              <1> ;  2     |                                           |
 76315                              <1> ;        |-------------------------------------------| 
 76316                              <1> ;        |                                           |
 76317                              <1> ;        |-------------------------------------------|
 76318                              <1> ;        |                                           |
 76319                              <1> ;        |-------------------------------------------|
 76320                              <1> ;        |                                           |
 76321                              <1> ;        |-------------------------------------------| 
 76322                              <1> ;        |                                           | 
 76323                              <1> 
 76324                              <1> %if 0
 76325                              <1> 
 76326                              <1> ; (Retro UNIX 386 v1.2 - ux.s - 15/07/2022)
 76327                              <1> ; 22/11/2021
 76328                              <1> ; 21/07/2021 - Retro UNIX 386 v2 open file structure revision
 76329                              <1> 
 76330                              <1> struc file	; open files (fsp) structure ; (*)	
 76331                              <1>   .inode:  resw 1  ; inode number of open file (32 bit)
 76332                              <1>   .i32:	   resw 1  ; higher word of inode number (reserved)
 76333                              <1>   .drive:  resb 1  ; logical drive (disk) number
 76334                              <1>   .flags:  resb 1  ; open mode and status
 76335                              <1>   .count:  resb 1  ; number of processes that have file open
 76336                              <1>   ;.rsvd:  resb 1  ; reserved byte (for next versions)
 76337                              <1>   .mnt:    resb 1  ; mnttab index+1 (0 = not mounted)
 76338                              <1>   .offset: resd 1  ; file offset/pointer (64 bit) 
 76339                              <1>   .o64:	   resd 1  ; higher 32 bit of file offset
 76340                              <1>  .size:  ; = 16		
 76341                              <1> endstruc 
 76342                              <1> 
 76343                              <1> %endif
 76344                              <1> 
 76345                              <1> ; 23/07/2022
 76346                              <1> ;fsp:	resb nfiles * 16 ; (*)
 76347                              <1> 
 76348 00030100 <res 00000001>      <1> idev:	resb 1
 76349 00030101 <res 00000001>      <1> cdev:	resb 1	
 76350                              <1> 
 76351                              <1> ; 15/04/2015
 76352                              <1> ;fsp:	resb nfiles * 10 ; 11/05/2015 (8 -> 10)
 76353                              <1> ;idev:	resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
 76354                              <1> ;cdev:	resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
 76355                              <1> 
 76356                              <1> ; 18/05/2015
 76357                              <1> ; 26/04/2013 device/drive parameters (Retro UNIX 8086 v1 feature only!)
 76358                              <1> ; 'UNIX' device numbers (as in 'cdev' and 'u.cdrv')
 76359                              <1> ;	0 -> root device (which has Retro UNIX 8086 v1 file system)
 76360                              <1> ; 	1 -> mounted device (which has Retro UNIX 8086 v1 file system)
 76361                              <1> ; 'Retro UNIX 8086 v1' device numbers: (for disk I/O procedures)
 76362                              <1> ;	0 -> fd0 (physical drive, floppy disk 1), physical drive number = 0
 76363                              <1> ;	1 -> fd1 (physical drive, floppy disk 2), physical drive number = 1
 76364                              <1> ;	2 -> hd0 (physical drive, hard disk 1), physical drive number = 80h
 76365                              <1> ;	3 -> hd1 (physical drive, hard disk 2), physical drive number = 81h
 76366                              <1> ;	4 -> hd2 (physical drive, hard disk 3), physical drive number = 82h
 76367                              <1> ;	5 -> hd3 (physical drive, hard disk 4), physical drive number = 83h
 76368                              <1> 
 76369 00030102 <res 00000001>      <1> rdev:	resb 1 ; root device number ; Retro UNIX 8086 v1 feature only!
 76370                              <1> 	        ; as above, for physical drives numbers in following table
 76371 00030103 <res 00000001>      <1> mdev:	resb 1 ; mounted device number ; Retro UNIX 8086 v1 feature only!
 76372                              <1> 
 76373                              <1> ; 23/07/2022
 76374                              <1> ;; 15/04/2015
 76375                              <1> ;active: resb 1 
 76376                              <1> ;	 resb 1 ; 09/06/2015
 76377                              <1> 
 76378                              <1> ; 23/07/2022
 76379                              <1> ;mnti:	 resw 1
 76380                              <1> ; 07/08/2022
 76381 00030104 <res 00000002>      <1> mpid:	 resw 1
 76382                              <1> ;rootdir: resw 1
 76383 00030106 <res 00000004>      <1> rootdir: resd 1	
 76384                              <1> 
 76385                              <1> ; 21/05/2016 - TRDOS 386 (TRDOS v2.0) - priority levels, 3 run queues 
 76386                              <1> runq:
 76387 0003010A <res 00000002>      <1> runq_event:	 resw 1 ; high priority, 'run for event'            ; 2
 76388 0003010C <res 00000002>      <1> runq_normal:	 resw 1 ; normal/regular priority, 'run as reqular' ; 1
 76389 0003010E <res 00000002>      <1> runq_background: resw 1 ; low priority, 'run on background'         ; 0
 76390                              <1> ;
 76391                              <1> ; 23/07/2022
 76392                              <1> ;imod:	resb 1
 76393                              <1> ;smod:	resb 1
 76394                              <1> ;mmod:	resb 1
 76395 00030110 <res 00000001>      <1> sysflg:	resb 1
 76396 00030111 <res 00000001>      <1> 	resb 1	
 76397                              <1> 
 76398 00030112 <res 00000002>      <1> alignb 4
 76399                              <1> 
 76400                              <1> user:
 76401                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 76402                              <1> 	; 04/12/2021 - Retro UNIX 386 v1.2
 76403                              <1> 	; 13/01/2017
 76404                              <1> 	; 19/12/2016
 76405                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0) 
 76406                              <1> 	; 	       [u.pri] usage method modification
 76407                              <1> 	; 04/12/2015 
 76408                              <1> 	; 18/10/2015
 76409                              <1> 	; 12/10/2015
 76410                              <1> 	; 21/09/2015
 76411                              <1> 	; 24/07/2015
 76412                              <1> 	; 16/06/2015
 76413                              <1> 	; 09/06/2015
 76414                              <1> 	; 11/05/2015
 76415                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit modifications)
 76416                              <1> 	; 10/10/2013
 76417                              <1> 	; 11/03/2013. 
 76418                              <1> 	;Derived from UNIX v1 source code 'user' structure (ux).
 76419                              <1> 	;u.
 76420                              <1> 
 76421 00030114 <res 00000004>      <1> 	u.sp:	  resd 1 ; esp (kernel stack at the beginning of 'sysent')
 76422 00030118 <res 00000004>      <1> 	u.usp:	  resd 1 ; esp (kernel stack points to user's registers)
 76423 0003011C <res 00000004>      <1> 	u.r0:	  resd 1 ; eax
 76424 00030120 <res 00000002>      <1> 	u.cdir:	  resw 1
 76425 00030122 <res 00000002>      <1> 		  resw 1 ; 23/07/2022
 76426 00030124 <res 00000001>      <1> 	u.cdrv:	  resb 1 ; 23/07/2022
 76427 00030125 <res 00000001>      <1> 		  resb 1				  	
 76428 00030126 <res 0000000A>      <1> 	u.fp:	  resb 10
 76429                              <1> 	;u.fp:	  resb OPENFILES ; 23/07/202
 76430                              <1> 	u.fsp:	  ; 23/07/2022
 76431 00030130 <res 00000004>      <1> 	u.fofp:	  resd 1
 76432 00030134 <res 00000004>      <1> 	u.dirp:	  resd 1
 76433 00030138 <res 00000004>      <1> 	u.namep:  resd 1
 76434 0003013C <res 00000004>      <1> 	u.off:	  resd 1
 76435                              <1> 	;	  resd 1 ; 23/07/2022 (64 bit fptr)
 76436 00030140 <res 00000004>      <1> 	u.base:	  resd 1
 76437 00030144 <res 00000004>      <1> 	u.count:  resd 1
 76438 00030148 <res 00000004>      <1> 	u.nread:  resd 1
 76439 0003014C <res 00000004>      <1> 	u.break:  resd 1 ; break
 76440                              <1> 	; 10/01/2017 (TRDOS 386, relocation and dword alignment)
 76441                              <1> 	; tty number (rtty, rcvt, wtty)
 76442 00030150 <res 00000002>      <1> 	u.ttyp:	  resw 1 
 76443 00030152 <res 00000001>      <1> 	u.ttyn:	  resb 1 ; 28/07/2013 - Retro Unix 8086 v1 feature only !
 76444 00030153 <res 00000001>      <1> 	u.mode:   resb 1 ; 23/07/2022
 76445                              <1> 	;u.resb:  resb 1 ; 10/01/2017 (TRDOS 386, temporary)
 76446 00030154 <res 00000010>      <1> 	u.dirbuf: resb 16 ; 04/12/2015 (10 -> 16) 
 76447                              <1> 	;u.pri:	  resw 1 ; 14/02/2014
 76448 00030164 <res 00000001>      <1> 	u.quant:  resb 1 ; Retro UNIX 8086 v1 Feature only ! (uquant)
 76449 00030165 <res 00000001>      <1> 		  resb 1 ; 23/07/2022
 76450 00030166 <res 00000001>      <1> 	u.pri:	  resb 1 ; Modification: 21/05/2016 (priority levels: 0, 1, 2)
 76451 00030167 <res 00000001>      <1> 		  resb 1 ; 23/07/2022	
 76452 00030168 <res 00000002>      <1> 	u.intr:	  resw 1
 76453 0003016A <res 00000002>      <1> 	u.quit:	  resw 1
 76454                              <1> 	;u.emt:	  resw 1 ; 10/10/2013
 76455                              <1> 	;u.ilgins: resw 1 ; 10/01/2017
 76456                              <1> 	;u.cdrv:  resw 1 ; cdev
 76457 0003016C <res 00000001>      <1> 	u.bsys:	  resb 1
 76458 0003016D <res 00000001>      <1> 	u.uno:	  resb 1
 76459                              <1> 	; 23/07/2022
 76460                              <1> 	;u.uid:	  resw 1 ; uid	; 27/03/2021 - Retro UNIX 386 v2
 76461                              <1> 	;u.ruid:  resw 1	; 16 bit uid
 76462                              <1> 	;u.gid:	  resb 1 ; gid 	; 27/03/2021 - Retro UNIX 386 v2
 76463                              <1> 	;u.rgid:  resb 1
 76464                              <1> 	; 23/07/2022
 76465                              <1> 	;u.procp: resd 1 ; /* pointer to proc structure */
 76466 0003016E <res 00000001>      <1> 	u.uid:	  resb 1 ; uid
 76467 0003016F <res 00000001>      <1> 	u.ruid:   resb 1
 76468 00030170 <res 00000004>      <1>         u.upage:  resd 1 ; 16/04/2015 - Retro Unix 386 v1 feature only !
 76469 00030174 <res 00000004>      <1> 	u.pgdir:  resd 1 ; 09/03/2015 (page dir addr of process)
 76470 00030178 <res 00000004>      <1> 	u.ppgdir: resd 1 ; 06/05/2015 (page dir addr of the parent process)
 76471 0003017C <res 00000004>      <1> 	u.pbase:  resd 1 ; 20/05/2015 (physical base/transfer address)
 76472 00030180 <res 00000002>      <1> 	u.pcount: resw 1 ; 20/05/2015 (byte -transfer- count for page)
 76473                              <1> 	;u.pncount: resw 1 
 76474                              <1> 		; 16/06/2015 (byte -transfer- count for page, 'namei', 'mkdir')
 76475                              <1> 	;u.pnbase:  resd 1 
 76476                              <1> 		; 16/06/2015 (physical base/transfer address, 'namei', 'mkdir')
 76477                              <1> 			 ; 09/06/2015
 76478 00030182 <res 00000001>      <1> 	u.kcall:  resb 1 ; The caller is 'namei' (dskr) or 'mkdir' (dskw) sign		
 76479 00030183 <res 00000001>      <1> 	u.brwdev: resb 1 ; Block device number for direct I/O (bread & bwrite)
 76480                              <1> 			 ; 24/07/2015 - 24/06/2015
 76481                              <1> 	;u.args:  resd 1 ; arguments list (line) offset from start of [u.upage]
 76482                              <1> 			 ; (arg list/line is from offset [u.args] to 4096 in [u.upage])
 76483                              <1> 			 ; ([u.args] points to argument count -argc- address offset)
 76484                              <1>  			 ; 24/06/2015	  	
 76485                              <1> 	;u.core:  resd 1 ; physical start address of user's memory space (for sys exec)
 76486                              <1> 	;u.ecore: resd 1 ; physical end address of user's memory space (for sys exec)
 76487                              <1> 	; last error number
 76488 00030184 <res 00000004>      <1> 	u.error:  resd 1 ; 28/07/2013 - 09/03/2015 
 76489                              <1> 		         ; Retro UNIX 8086/386 v1 feature only!
 76490                              <1> 			 ; 21/09/2015 (debugging - page fault analyze)
 76491 00030188 <res 00000004>      <1> 	u.pfcount: resd 1 ; page fault count for (this) process (for sys geterr)
 76492                              <1> 		; 19/12/2016 (TRDOS 386)	
 76493 0003018C <res 00000004>      <1> 	u.tcb:	  resd 1 ; Timer callback address/flag which will be used by timer int
 76494                              <1> 		; 13/01/2017 (TRDOS 386)
 76495 00030190 <res 00000001>      <1> 	u.t_lock: resb 1 ; Timer interrupt (callback) lock (unlocked by 'sysrele')
 76496 00030191 <res 00000001>      <1> 	u.t_mode: resb 1 ; running mode during timer interrupt (0= system, 0FFh= user)
 76497                              <1> 		; 26/02/2017 (TRDOS 386)
 76498 00030192 <res 00000001>      <1> 	u.irqc:	  resb 1  ; Count of IRQ callback services (IRQs in use)
 76499                              <1> 		; 28/02/2017 (TRDOS 386) 
 76500 00030193 <res 00000001>      <1> 	u.irqwait: resb 1 ; IRQ waiting for callback service flag (IRQ number, If > 0)
 76501 00030194 <res 00000001>      <1> 	u.r_lock: resb 1 ; 'IRQ callback service is in progress' flag (IRQ lock)
 76502 00030195 <res 00000001>      <1> 	u.r_mode: resb 1 ; running mode during hadware interrupt
 76503                              <1> 	; 23/07/2022
 76504 00030196 <res 00000001>      <1> 	u.exit:	  resb 1 ; exit code
 76505                              <1> 	; 27/02/2017 (TRDOS 386) 
 76506 00030197 <res 00000001>      <1> 	u.fpsave: resb 1 ; TRDOS 386, 'save/restore FPU registers' flag
 76507                              <1> alignb 4
 76508                              <1> 	; !! wrong sizing in TRDOS 386 v2.0.4 (in 'ubss.s', 28/02/2017) !! 
 76509                              <1> 	;u.fpregs: resb 94 ; 94 byte area for saving and restoring FPU registers
 76510                              <1> 	; 23/07/2022
 76511 00030198 <res 0000006C>      <1> 	u.fpregs: resb 108 ; 108 byte area for saving and restoring FPU registers
 76512                              <1> 
 76513                              <1> alignb 4
 76514                              <1> 
 76515                              <1> U_SIZE	equ $ - user
 76516                              <1> 
 76517                              <1> ; 18/10/2015 - Retro UNIX 386 v1 (local variables for 'namei' and 'sysexec')
 76518 00030204 <res 00000004>      <1> pcore:	resd 1  ; physical start address of user's memory space (for sys exec)
 76519 00030208 <res 00000004>      <1> ecore:	resd 1  ; physical address of user's stack/last page (for sys exec)
 76520 0003020C <res 00000004>      <1> nbase:	resd 1	; physical base address for 'namei' & 'sysexec'
 76521                              <1> ; 23/07/202 - TRDOS 386 Kernel v2.0.5
 76522                              <1> ;ncount: resw 1
 76523 00030210 <res 00000004>      <1> ncount: resd 1	; remain byte count in page for 'namei' & 'sysexec'
 76524                              <1> ;argc:	resw 1
 76525 00030214 <res 00000004>      <1> argc:	resd 1	; argument count for 'sysexec'
 76526 00030218 <res 00000004>      <1> argv:	resd 1	; argument list (recent) address for 'sysexec'
 76527                              <1> 
 76528                              <1> ; 03/06/2015 - Retro UNIX 386 v1 Beginning
 76529                              <1> ; 07/04/2013 - 31/07/2013 - Retro UNIX 8086 v1
 76530 0003021C <res 00000001>      <1> rw:	resb 1 ;; Read/Write sign (iget)
 76531                              <1> ; 23/07/2022
 76532 0003021D <res 00000003>      <1> 	resb 3	
 76533                              <1> 
 76534                              <1> alignb 4
 76535                              <1> 
 76536                              <1> ; 24/04/2016
 76537 00030220 <res 00000004>      <1> ii:	resd 1 ; first cluster of the program file
 76538 00030224 <res 00000004>      <1> i.size:	resd 1 ; size of the program file
 76539                                  
 76540                                  alignb 4
 76541                                  
 76542                                  ; 23/05/2016 (TRDOS 386)
 76543                                  ; 14/10/2015 (Retro UNIX 386 v1, 'unix386.s')
 76544 00030228 <res 00000004>          cr3reg:	resd 1	; cr3 register content at the beginning of the timer
 76545                                  		; (or RTC) interrupt handler.
 76546                                  
 76547                                  ; 10/12/2016 (callback)
 76548                                  ; 10/06/2016
 76549                                  ; 19/05/2016
 76550                                  ; 18/05/2016 - TRDOS 386 feature only !
 76551                                  timer_set:
 76552 0003022C <res 00000100>          	resd 16*4   ; 256 bytes memory space for 16 timer events
 76553                                  	
 76554                                  	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
 76555                                  	;       Owner:	        resb 1 ; 0 = free
 76556                                  	;		  	       ;>0 = process number (u.uno)
 76557                                  	;	Callback:	resb 1 ; 0 = response byte address (phy)
 76558                                  	;				 1 = callback address (virtual)				
 76559                                  	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
 76560                                  	;		   	       ; 1 = Real Time Clock interrupt 
 76561                                  	;	Response:       resb 1 ; 0 to 255, signal return value
 76562                                  	;	Count Limit:	resd 1 ; count of ticks (total/set)
 76563                                  	;	Current Count: 	resd 1 ; count of ticks (current)
 76564                                  	;	Response Addr:  resd 1 ; response byte (pointer) address
 76565                                  	;			       ; (or callback -user service- address)	
 76566                                  
 76567                                  ; 17/04/2021
 76568                                  ; (memory page swap parameters are disabled as temporary)
 76569                                  ;
 76570                                  ; Memory (swap) Data (11/03/2015)
 76571                                  ; 09/03/2015
 76572                                  ;swpq_count: resw 1 ; count of pages on the swap queue
 76573                                  ;swp_drv:    resd 1 ; logical drive description table address of the swap drive/disk
 76574                                  ;swpd_size:  resd 1 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
 76575                                  ;swpd_free:  resd 1 ; free page blocks (4096 bytes) on swap disk/drive (logical)
 76576                                  ;swpd_next:  resd 1 ; next free page block
 76577                                  ;swpd_last:  resd 1 ; last swap page block	
 76578                                  
 76579                                  alignb 4
 76580                                  
 76581                                  ; 10/07/2015
 76582                                  ; 28/08/2014
 76583 0003032C <res 00000004>          error_code:	resd 1
 76584                                  ; 29/08/2014
 76585 00030330 <res 00000004>          FaultOffset:	resd 1
 76586                                  ; 21/09/2015
 76587 00030334 <res 00000004>          PF_Count:	resd 1	; total page fault count
 76588                                  		       	; (for debugging - page fault analyze)
 76589                                  		 	; 'page_fault_handler' (memory.inc)
 76590                                  			; 'sysgeterr' (u9.s)
 76591                                  
 76592                                  ; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 76593                                  ; 22/08/2015 (Retro UNIX 386 v1)
 76594                                  buffer: 
 76595 00030338 <res 00000008>          	resb	8 
 76596                                  readi_buffer:
 76597 00030340 <res 00000200>          	resb 	512
 76598 00030540 <res 00000008>          	resb	8
 76599                                  writei_buffer:
 76600 00030548 <res 00000200>          	resb	512	
 76601                                  ; 24/10/2016
 76602 00030748 <res 00000008>          	resb	8 
 76603                                  rw_buffer:
 76604 00030750 <res 00000800>          	resb 	2048 	; general purposed, r/w sector buffer
 76605                                  
 76606                                  %if 1
 76607                                  ; 17/01/2021
 76608 00030F50 <res 00000080>          edid_info:	resb 128 ; VESA EDID (monitor capabilities) info	
 76609                                  ; 28/11/2020
 76610 00030FD0 <res 00000001>          pmi32:		resb 1	; (>0) use VESA VBE3 protected mode calls 
 76611 00030FD1 <res 00000001>          vbe_mode_x:	resb 1  ; VESA VBE3 video bios mode set options
 76612 00030FD2 <res 00000002>          video_mode:	resw 1	; VESA VBE3 video mode (with option flags)
 76613                                  ; 30/11/2020
 76614 00030FD4 <res 00000004>          vbe3bios_addr:	resd 1	; new (writable mem) address of VBE3 bios
 76615                                  ; 02/12/2020
 76616 00030FD8 <res 00000004>          pmid_addr:	resd 1	; PMInfoBlock ('PMID') linear address
 76617                                  ; 14/01/2021
 76618                                  ; 06/12/2020		; VESA VBE 3 video state
 76619                                  ;vbe3stbufsize:	resw 1	; video regs/dac/bios state buffer size
 76620                                  ;			; block size in bytes
 76621                                  ; 16/01/2021
 76622 00030FDC <res 00000002>          vbe3stbsflags:	resw 1	; video regs/dac/bios state buffer size
 76623                                  ;			; pointer flags for buffer state options
 76624                                  %endif
 76625                                  
 76626                                  %if 1
 76627                                  ; 10/12/2020
 76628 00030FDE <res 00000010>          LFB_Info:	resb 16	; Linear Frame Buffer info block
 76629                                  ;
 76630                                  ;24/11/2020 - TRDOS 386 v2.0.3
 76631                                  ; BOCHS/PLEX86 VESA VBE3 MODE INFO extension to TRDOS 386 v2 kernel	
 76632 00030FEE <res 00000044>          MODE_INFO_LIST:	resb 68	; mode + 66 byte VESA vbe3 mode info (4F01h) 
 76633                                  %endif
 76634                                  
 76635                                  ; 05/01/2021
 76636 00031032 <res 00000001>          ufont:		resb 1	; (VGA graphics) user font flags
 76637                                  			; bit 7 - permission flag for int 31h
 76638                                  			; bit 4 - 8x16 user font ready/loaded flag  
 76639                                  			; bit 3 - 8x8 user font ready/loaded flag
 76640                                  			; bit 1 - select 8x16 user font (sysvideo)
 76641                                  			; bit 0 - select 8x8 user font (sysvideo)
 76642 00031033 <res 00000001>          		resb 1	; 19/01/2021
 76643                                  ; 17/01/2021
 76644 00031034 <res 00000001>          srvsf:		resb 1	; 'save restore video state' permission flag
 76645                                  ; 18/01/2021
 76646 00031035 <res 00000001>          srvso:		resb 1	; video state buffer save/restore option
 76647 00031036 <res 00000004>          VideoStateID:	resd 1	; used to verify state saved by same prog
 76648                                  ; 29/01/2021
 76649 0003103A <res 00000002>          v_width:	resw 1	; screen (display page) width
 76650 0003103C <res 00000001>          v_ops:		resb 1	; 'sysvideo' graphics data transfer option	
 76651 0003103D <res 00000001>          v_bpp:		resb 1	; bits per pixels ('sysvideo')
 76652 0003103E <res 00000004>          v_mem:		resd 1	; video memory ('sysvideo')	
 76653 00031042 <res 00000004>          v_siz:		resd 1	; video page size ('sysvideo')
 76654 00031046 <res 00000004>          v_str:		resd 1	; window start adress ('sysvideo')
 76655 0003104A <res 00000004>          v_end:		resd 1	; window end (end+1) adress ('sysvideo')
 76656                                  ; 31/01/2021
 76657                                  ; 01/01/2021
 76658                                  ;maskbuff:     ;resd 1	; user's bitmask buffer addr ('sysvideo')
 76659 0003104E <res 00000004>          maskcolor:	resd 1	; VGA/SVGA pixel mask color ('sysvideo')
 76660                                  ; 27/02/2021
 76661 00031052 <res 00000004>          pixcount:	resd 1	; pixel count ('sysvideo' window ops) 
 76662                                  ; 02/02/2021
 76663 00031056 <res 00000008>          buffer8:	resd 2	; 8 bytes small buffer for 'sysvideo'
 76664                                  
 76665                                  bss_end:
 76666                                  
 76667                                  ; 27/12/2013
 76668                                  _end:  ; end of kernel code
